Search in sources :

Example 1 with OpenDirMessage

use of com.foobnix.pdf.search.activity.msg.OpenDirMessage in project LibreraReader by foobnix.

the class DefaultListeners method getOnItemClickListener.

public static ResultResponse<FileMeta> getOnItemClickListener(final Activity a) {
    return new ResultResponse<FileMeta>() {

        @Override
        public boolean onResultRecive(FileMeta result) {
            if (isTagCicked(a, result)) {
                return true;
            }
            final File item = new File(result.getPath());
            if (item.isDirectory()) {
                Intent intent = // 
                new Intent(UIFragment.INTENT_TINT_CHANGE).putExtra(MainTabs2.EXTRA_PAGE_NUMBER, // 
                UITab.getCurrentTabIndex(UITab.BrowseFragment));
                LocalBroadcastManager.getInstance(a).sendBroadcast(intent);
                EventBus.getDefault().post(new OpenDirMessage(result.getPath()));
            } else {
                ExtUtils.openFile(a, result);
            }
            return false;
        }
    };
}
Also used : ResultResponse(com.foobnix.android.utils.ResultResponse) OpenDirMessage(com.foobnix.pdf.search.activity.msg.OpenDirMessage) Intent(android.content.Intent) File(java.io.File) DocumentFile(android.support.v4.provider.DocumentFile) FileMeta(com.foobnix.dao2.FileMeta)

Example 2 with OpenDirMessage

use of com.foobnix.pdf.search.activity.msg.OpenDirMessage in project LibreraReader by foobnix.

the class DefaultListeners method getOnItemLongClickListener.

public static ResultResponse<FileMeta> getOnItemLongClickListener(final Activity a, final FileMetaAdapter searchAdapter) {
    return new ResultResponse<FileMeta>() {

        @Override
        public boolean onResultRecive(final FileMeta result) {
            if (ExtUtils.isExteralSD(result.getPath())) {
                return false;
            }
            if (isTagCicked(a, result)) {
                return true;
            }
            File item = new File(result.getPath());
            if (item.isDirectory()) {
                Intent intent = // 
                new Intent(UIFragment.INTENT_TINT_CHANGE).putExtra(MainTabs2.EXTRA_PAGE_NUMBER, // 
                UITab.getCurrentTabIndex(UITab.BrowseFragment));
                LocalBroadcastManager.getInstance(a).sendBroadcast(intent);
                EventBus.getDefault().post(new OpenDirMessage(result.getPath()));
                return true;
            }
            Runnable onDeleteAction = new Runnable() {

                @Override
                public void run() {
                    deleteFile(a, searchAdapter, result);
                }
            };
            if (ExtUtils.doifFileExists(a, item)) {
                FileInformationDialog.showFileInfoDialog(a, item, onDeleteAction);
            }
            return true;
        }
    };
}
Also used : ResultResponse(com.foobnix.android.utils.ResultResponse) OpenDirMessage(com.foobnix.pdf.search.activity.msg.OpenDirMessage) Intent(android.content.Intent) File(java.io.File) DocumentFile(android.support.v4.provider.DocumentFile) FileMeta(com.foobnix.dao2.FileMeta)

Aggregations

Intent (android.content.Intent)2 DocumentFile (android.support.v4.provider.DocumentFile)2 ResultResponse (com.foobnix.android.utils.ResultResponse)2 FileMeta (com.foobnix.dao2.FileMeta)2 OpenDirMessage (com.foobnix.pdf.search.activity.msg.OpenDirMessage)2 File (java.io.File)2