Search in sources :

Example 1 with MainActivityActionMode

use of com.amaze.filemanager.utils.MainActivityActionMode in project AmazeFileManager by TeamAmaze.

the class MainActivity method onCreate.

/**
 * Called when the activity is first created.
 */
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_toolbar);
    intent = getIntent();
    dataUtils = DataUtils.getInstance();
    if (savedInstanceState != null) {
        listItemSelected = savedInstanceState.getBoolean(KEY_SELECTED_LIST_ITEM, false);
    }
    initialisePreferences();
    initializeInteractiveShell();
    dataUtils.registerOnDataChangedListener(new SaveOnDataUtilsChange(drawer));
    AppConfig.getInstance().setMainActivityContext(this);
    initialiseViews();
    utilsHandler = AppConfig.getInstance().getUtilsHandler();
    cloudHandler = new CloudHandler(this, AppConfig.getInstance().getExplorerDatabase());
    // TODO: 7/12/2017 not init when actionIntent != null
    initialiseFab();
    mainActivityHelper = new MainActivityHelper(this);
    mainActivityActionMode = new MainActivityActionMode(new WeakReference<>(MainActivity.this));
    if (CloudSheetFragment.isCloudProviderAvailable(this)) {
        LoaderManager.getInstance(this).initLoader(REQUEST_CODE_CLOUD_LIST_KEYS, null, this);
    }
    path = intent.getStringExtra("path");
    openProcesses = intent.getBooleanExtra(KEY_INTENT_PROCESS_VIEWER, false);
    if (intent.getStringArrayListExtra(TAG_INTENT_FILTER_FAILED_OPS) != null) {
        ArrayList<HybridFileParcelable> failedOps = intent.getParcelableArrayListExtra(TAG_INTENT_FILTER_FAILED_OPS);
        if (failedOps != null) {
            mainActivityHelper.showFailedOperationDialog(failedOps, this);
        }
    }
    checkForExternalIntent(intent);
    drawer.setDrawerIndicatorEnabled();
    if (!getBoolean(PREFERENCE_BOOKMARKS_ADDED)) {
        utilsHandler.addCommonBookmarks();
        getPrefs().edit().putBoolean(PREFERENCE_BOOKMARKS_ADDED, true).commit();
    }
    checkForExternalPermission();
    Completable.fromRunnable(() -> {
        dataUtils.setHiddenFiles(utilsHandler.getHiddenFilesConcurrentRadixTree());
        dataUtils.setHistory(utilsHandler.getHistoryLinkedList());
        dataUtils.setGridfiles(utilsHandler.getGridViewList());
        dataUtils.setListfiles(utilsHandler.getListViewList());
        dataUtils.setBooks(utilsHandler.getBookmarksList());
        ArrayList<String[]> servers = new ArrayList<>();
        servers.addAll(utilsHandler.getSmbList());
        servers.addAll(utilsHandler.getSftpList());
        dataUtils.setServers(servers);
    }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new CompletableObserver() {

        @Override
        public void onSubscribe(Disposable d) {
        }

        @Override
        public void onComplete() {
            drawer.refreshDrawer();
            invalidateFragmentAndBundle(savedInstanceState);
        }

        @Override
        public void onError(Throwable e) {
            e.printStackTrace();
        }
    });
    initStatusBarResources(findViewById(R.id.drawer_layout));
}
Also used : Disposable(io.reactivex.disposables.Disposable) CloudHandler(com.amaze.filemanager.database.CloudHandler) ArrayList(java.util.ArrayList) MainActivityHelper(com.amaze.filemanager.utils.MainActivityHelper) HybridFileParcelable(com.amaze.filemanager.filesystem.HybridFileParcelable) SaveOnDataUtilsChange(com.amaze.filemanager.asynchronous.SaveOnDataUtilsChange) MainActivityActionMode(com.amaze.filemanager.utils.MainActivityActionMode) WeakReference(java.lang.ref.WeakReference) CompletableObserver(io.reactivex.CompletableObserver)

Aggregations

SaveOnDataUtilsChange (com.amaze.filemanager.asynchronous.SaveOnDataUtilsChange)1 CloudHandler (com.amaze.filemanager.database.CloudHandler)1 HybridFileParcelable (com.amaze.filemanager.filesystem.HybridFileParcelable)1 MainActivityActionMode (com.amaze.filemanager.utils.MainActivityActionMode)1 MainActivityHelper (com.amaze.filemanager.utils.MainActivityHelper)1 CompletableObserver (io.reactivex.CompletableObserver)1 Disposable (io.reactivex.disposables.Disposable)1 WeakReference (java.lang.ref.WeakReference)1 ArrayList (java.util.ArrayList)1