Java Code Examples for com.hippo.unifile.UniFile#fromUri()

The following examples show how to use com.hippo.unifile.UniFile#fromUri() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Settings.java    From MHViewer with Apache License 2.0 6 votes vote down vote up
@Nullable
public static UniFile getDownloadLocation() {
    UniFile dir = null;
    try {
        Uri.Builder builder = new Uri.Builder();
        builder.scheme(getString(KEY_DOWNLOAD_SAVE_SCHEME, null));
        builder.encodedAuthority(getString(KEY_DOWNLOAD_SAVE_AUTHORITY, null));
        builder.encodedPath(getString(KEY_DOWNLOAD_SAVE_PATH, null));
        builder.encodedQuery(getString(KEY_DOWNLOAD_SAVE_QUERY, null));
        builder.encodedFragment(getString(KEY_DOWNLOAD_SAVE_FRAGMENT, null));
        dir = UniFile.fromUri(sContext, builder.build());
    } catch (Throwable e) {
        ExceptionUtils.throwIfFatal(e);
        // Ignore
    }
    return dir != null ? dir : UniFile.fromFile(AppConfig.getDefaultDownloadDir());
}
 
Example 2
Source File: GalleryActivity2.java    From Nimingban with Apache License 2.0 6 votes vote down vote up
private boolean handlerIntent(Intent intent) {
    if (intent == null) {
        return false;
    }

    String action = intent.getAction();
    if (ACTION_SINGLE_IMAGE.equals(action)) {
        int site = intent.getIntExtra(KEY_SITE, -1);
        String id = intent.getStringExtra(KEY_ID);
        String key = intent.getStringExtra(KEY_KEY);
        String image = intent.getStringExtra(KEY_IMAGE);
        if (Site.isValid(site) && id != null && key != null && image != null) {
            mGalleryAdapter = new SingleImageAdapter(Site.fromId(site), id, key, image);
            return true;
        }
    } else if (ACTION_IMAGE_FILE.equals(action)) {
        Uri fileUri = intent.getParcelableExtra(KEY_UNI_FILE_URI);
        UniFile file = UniFile.fromUri(this, fileUri);
        if (file != null) {
            mGalleryAdapter = new ImageFileAdapter(file);
            return true;
        }
    }
    return false;
}
 
Example 3
Source File: Settings.java    From Nimingban with Apache License 2.0 6 votes vote down vote up
@Nullable
public static UniFile getImageSaveLocation() {
    UniFile dir = null;
    try {
        Uri.Builder builder = new Uri.Builder();
        builder.scheme(getString(KEY_IMAGE_SAVE_SCHEME, null));
        builder.encodedAuthority(getString(KEY_IMAGE_SAVE_AUTHORITY, null));
        builder.encodedPath(getString(KEY_IMAGE_SAVE_PATH, null));
        builder.encodedQuery(getString(KEY_IMAGE_SAVE_QUERY, null));
        builder.encodedFragment(getString(KEY_IMAGE_SAVE_FRAGMENT, null));
        dir = UniFile.fromUri(sContext, builder.build());
    } catch (Exception e) {
        e.printStackTrace();
    }
    return dir != null ? dir : UniFile.fromFile(NMBAppConfig.getImageDir());
}
 
Example 4
Source File: Settings.java    From EhViewer with Apache License 2.0 6 votes vote down vote up
@Nullable
public static UniFile getDownloadLocation() {
    UniFile dir = null;
    try {
        Uri.Builder builder = new Uri.Builder();
        builder.scheme(getString(KEY_DOWNLOAD_SAVE_SCHEME, null));
        builder.encodedAuthority(getString(KEY_DOWNLOAD_SAVE_AUTHORITY, null));
        builder.encodedPath(getString(KEY_DOWNLOAD_SAVE_PATH, null));
        builder.encodedQuery(getString(KEY_DOWNLOAD_SAVE_QUERY, null));
        builder.encodedFragment(getString(KEY_DOWNLOAD_SAVE_FRAGMENT, null));
        dir = UniFile.fromUri(sContext, builder.build());
    } catch (Throwable e) {
        ExceptionUtils.throwIfFatal(e);
        // Ignore
    }
    return dir != null ? dir : UniFile.fromFile(AppConfig.getDefaultDownloadDir());
}
 
Example 5
Source File: HeaderImageView.java    From Nimingban with Apache License 2.0 5 votes vote down vote up
@Override
protected void onRestoreInstanceState(Parcelable state) {
    Bundle saved = (Bundle) state;
    Uri uri = saved.getParcelable(KEY_IMAGE_UNI_FILE_URI);
    if (uri != null) {
        UniFile file = UniFile.fromUri(getContext(), uri);
        if (file != null && file.exists()) {
            setImageFile(file);
        }
    }

    super.onRestoreInstanceState(saved.getParcelable(KEY_SUPER));
}
 
Example 6
Source File: ArchiveGalleryProvider.java    From MHViewer with Apache License 2.0 4 votes vote down vote up
public ArchiveGalleryProvider(Context context, Uri uri) {
  file = UniFile.fromUri(context, uri);
}
 
Example 7
Source File: ArchiveGalleryProvider.java    From EhViewer with Apache License 2.0 4 votes vote down vote up
public ArchiveGalleryProvider(Context context, Uri uri) {
  file = UniFile.fromUri(context, uri);
}