use of com.amaze.filemanager.asynchronous.SaveOnDataUtilsChange 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));
}
Aggregations