DocumentsUI 文件打开

 

 

 

 

RootsFragment

 

 

BaseActivity.java

refreshCurrentRootAndDirectory(){

  refreshDirectory()

}

 

FilesActivity.java

refreshDirectory(){

     DirectoryFragment.showDirectory(fm, root, cwd, anim);

}

 

 

 

 

frameworks/base/packages/DocumentsUI/src/com/android/documentsui/dirlist/

DirectoryFragment.java

onActivityCreated(){

          mAdapter = new SectionBreakDocumentsAdapterWrapper(
                this, new ModelBackedDocumentsAdapter(this, mIconHelper));
        mRecView.setAdapter(mAdapter);

}

 

 

SectionBreakDocumentsAdapterWrapper.java

onCreateViewHolder()

 

ModelBackedDocumentsAdapter.java

onCreateViewHolder(){

case ITEM_TYPE_DOCUMENT:
                        holder = new GridDocumentHolder(mEnv.getContext(), parent, mIconHelper);
                        break;

mEnv.initDocumentHolder(holder);

}

 

 

 

GridDocumentHolder.java

DocumentHolder.java

onSingleTapUp(){

   else if (Events.isTouchEvent(event)) {

           return mEventListener.onActivate(this);

     }

}

 

 

 

DirectoryFragment.java

private class ItemEventListener implements DocumentHolder.EventListener {
        @Override
        public boolean onActivate(DocumentHolder doc) {//点击该文件
        Log.d(TAG, "onActivate= " + doc);
            // Toggle selection if we're in selection mode, othewise, view item.
            if (mSelectionManager.hasSelection()) {
                mSelectionManager.toggleSelection(doc.modelId);
            } else {
                handleViewItem(doc.modelId);
            }
            return true;
        }

handleViewItem(){

   ((BaseActivity) getActivity()).onDocumentPicked(doc, mModel);

}

 

 

FilesActivity.java

onDocumentPicked()

openDocument(){ //启动能打开该文件的应用

     // Fall back to traditional VIEW action...
        intent = new Intent(Intent.ACTION_VIEW);

     startActivity(intent);

}

 

 

 

你可能感兴趣的:(Android,应用)