Search in sources :

Example 1 with Loader

use of androidx.loader.content.Loader in project AmazeFileManager by TeamAmaze.

the class MainActivity method addConnection.

@Override
public void addConnection(OpenMode service) {
    try {
        if (cloudHandler.findEntry(service) != null) {
            // cloud entry already exists
            Toast.makeText(this, getResources().getString(R.string.connection_exists), Toast.LENGTH_LONG).show();
        } else {
            Toast.makeText(MainActivity.this, getResources().getString(R.string.please_wait), Toast.LENGTH_LONG).show();
            Bundle args = new Bundle();
            args.putInt(ARGS_KEY_LOADER, service.ordinal());
            // check if we already had done some work on the loader
            Loader loader = getSupportLoaderManager().getLoader(REQUEST_CODE_CLOUD_LIST_KEY);
            if (loader != null && loader.isStarted()) {
                // making sure that loader is not started
                getSupportLoaderManager().destroyLoader(REQUEST_CODE_CLOUD_LIST_KEY);
            }
            getSupportLoaderManager().initLoader(REQUEST_CODE_CLOUD_LIST_KEY, args, this);
        }
    } catch (CloudPluginException e) {
        e.printStackTrace();
        Toast.makeText(this, getResources().getString(R.string.cloud_error_plugin), Toast.LENGTH_LONG).show();
    }
}
Also used : CloudPluginException(com.amaze.filemanager.file_operations.exceptions.CloudPluginException) Bundle(android.os.Bundle) CursorLoader(androidx.loader.content.CursorLoader) Loader(androidx.loader.content.Loader)

Aggregations

Bundle (android.os.Bundle)1 CursorLoader (androidx.loader.content.CursorLoader)1 Loader (androidx.loader.content.Loader)1 CloudPluginException (com.amaze.filemanager.file_operations.exceptions.CloudPluginException)1