Java Code Examples for com.qmuiteam.qmui.widget.dialog.QMUIDialog#MenuDialogBuilder

The following examples show how to use com.qmuiteam.qmui.widget.dialog.QMUIDialog#MenuDialogBuilder . 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: PhotoImageActivity.java    From v9porn with MIT License 5 votes vote down vote up
private void showSavePictureDialog( String imageUrl) {
    final String saveUrl;
    if (imageUrl.contains("_")){
        saveUrl=imgUrl.split("_")[0];
    }else {
        saveUrl=imageUrl;
    }
    QMUIDialog.MenuDialogBuilder builder = new QMUIDialog.MenuDialogBuilder(this);
    builder.addItem("保存原图", (dialog, which) -> {
        GlideApp.with(PhotoImageActivity.this).downloadOnly().load(Uri.parse(saveUrl)).into(new SimpleTarget<File>() {
            @Override
            public void onResourceReady(@NonNull File resource, @Nullable Transition<? super File> transition) {
                File filePath = new File(SDCardUtils.DOWNLOAD_IMAGE_PATH);
                if (!filePath.exists()) {
                    if (!filePath.mkdirs()) {
                        showMessage("创建文件夹失败了", TastyToast.ERROR);
                        return;
                    }
                }
                File file = new File(filePath, UUID.randomUUID().toString() + ".jpg");
                try {
                    FileUtils.copyFile(resource, file);
                    showMessage("保存图片成功了", TastyToast.SUCCESS);
                    notifySystemGallery(file);
                } catch (IOException e) {
                    e.printStackTrace();
                    showMessage("保存图片失败了", TastyToast.ERROR);
                }
            }
        });
        dialog.dismiss();
    });
    builder.show();
}
 
Example 2
Source File: PictureViewerActivity.java    From v9porn with MIT License 5 votes vote down vote up
private void showSavePictureDialog(final String imageUrl) {
    QMUIDialog.MenuDialogBuilder builder = new QMUIDialog.MenuDialogBuilder(this);
    builder.addItem("保存图片", (dialog, which) -> {
        GlideApp.with(PictureViewerActivity.this).downloadOnly().load(Uri.parse(imageUrl)).into(new SimpleTarget<File>() {
            @Override
            public void onResourceReady(@NonNull File resource, @Nullable Transition<? super File> transition) {
                File filePath = new File(SDCardUtils.DOWNLOAD_IMAGE_PATH);
                if (!filePath.exists()) {
                    if (!filePath.mkdirs()) {
                        showMessage("创建文件夹失败了", TastyToast.ERROR);
                        return;
                    }
                }
                File file = new File(filePath, UUID.randomUUID().toString() + ".jpg");
                try {
                    FileUtils.copyFile(resource, file);
                    showMessage("保存图片成功了", TastyToast.SUCCESS);
                    notifySystemGallery(file);
                } catch (IOException e) {
                    e.printStackTrace();
                    showMessage("保存图片失败了", TastyToast.ERROR);
                }
            }
        });
        dialog.dismiss();
    });
    builder.show();
}
 
Example 3
Source File: PhotoImageActivity.java    From v9porn with MIT License 5 votes vote down vote up
private void showSavePictureDialog( String imageUrl) {
    final String saveUrl;
    if (imageUrl.contains("_")){
        saveUrl=imgUrl.split("_")[0];
    }else {
        saveUrl=imageUrl;
    }
    QMUIDialog.MenuDialogBuilder builder = new QMUIDialog.MenuDialogBuilder(this);
    builder.addItem("保存原图", (dialog, which) -> {
        GlideApp.with(PhotoImageActivity.this).downloadOnly().load(Uri.parse(saveUrl)).into(new SimpleTarget<File>() {
            @Override
            public void onResourceReady(@NonNull File resource, @Nullable Transition<? super File> transition) {
                File filePath = new File(SDCardUtils.DOWNLOAD_IMAGE_PATH);
                if (!filePath.exists()) {
                    if (!filePath.mkdirs()) {
                        showMessage("创建文件夹失败了", TastyToast.ERROR);
                        return;
                    }
                }
                File file = new File(filePath, UUID.randomUUID().toString() + ".jpg");
                try {
                    FileUtils.copyFile(resource, file);
                    showMessage("保存图片成功了", TastyToast.SUCCESS);
                    notifySystemGallery(file);
                } catch (IOException e) {
                    e.printStackTrace();
                    showMessage("保存图片失败了", TastyToast.ERROR);
                }
            }
        });
        dialog.dismiss();
    });
    builder.show();
}
 
Example 4
Source File: PictureViewerActivity.java    From v9porn with MIT License 5 votes vote down vote up
private void showSavePictureDialog(final String imageUrl) {
    QMUIDialog.MenuDialogBuilder builder = new QMUIDialog.MenuDialogBuilder(this);
    builder.addItem("保存图片", (dialog, which) -> {
        GlideApp.with(PictureViewerActivity.this).downloadOnly().load(Uri.parse(imageUrl)).into(new SimpleTarget<File>() {
            @Override
            public void onResourceReady(@NonNull File resource, @Nullable Transition<? super File> transition) {
                File filePath = new File(SDCardUtils.DOWNLOAD_IMAGE_PATH);
                if (!filePath.exists()) {
                    if (!filePath.mkdirs()) {
                        showMessage("创建文件夹失败了", TastyToast.ERROR);
                        return;
                    }
                }
                File file = new File(filePath, UUID.randomUUID().toString() + ".jpg");
                try {
                    FileUtils.copyFile(resource, file);
                    showMessage("保存图片成功了", TastyToast.SUCCESS);
                    notifySystemGallery(file);
                } catch (IOException e) {
                    e.printStackTrace();
                    showMessage("保存图片失败了", TastyToast.ERROR);
                }
            }
        });
        dialog.dismiss();
    });
    builder.show();
}