/**
* Handles the call-back from a file chooser dialog when a file is selected. This is used for
* communication between the {@code FileChooserDialog} and the export/import fragments. The
* originating fragment that opened the file chooser dialog should set the "tag" of the file
* chooser dialog to the value of the fragment tag that this activity uses to identify that
* originating fragment. This activity will then forward this notification to that fragment,
* which is expected to implement this same interface method.
*
* @param dialog
* The file chooser dialog that has reported the file selection.
* @param file
* The file that was chosen.
*/
@Override
public void onFileSelection(@NonNull FileChooserDialog dialog, @NonNull File file) {
// This "relay" scheme ensures that this activity is not embroiled in the gory details of
// what the "destinationFrag" wanted with the file.
final Fragment destinationFrag = fragmentManager.findFragmentByTag(FRAG_TAG_EXIM_DIALOG);
if (destinationFrag instanceof FileChooserDialog.FileCallback) {
((FileChooserDialog.FileCallback) destinationFrag).onFileSelection(dialog, file);
} else {
// This is not expected unless there is a bug to be fixed.
Log.e(TAG, "onFileSelection(): Unknown or incompatible fragment: " + destinationFrag.getTag());
}
}
MainActivity.java 文件源码
java
阅读 22
收藏 0
点赞 0
评论 0
项目:TwistyTimer
作者:
评论列表
文章目录