com.qmuiteam.qmui.widget.dialog.QMUIDialog Java Examples

The following examples show how to use com.qmuiteam.qmui.widget.dialog.QMUIDialog. 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: PersonActivity.java    From PoetryWeather with Apache License 2.0 6 votes vote down vote up
/**
 * 单选对话框
 */
private void showRefreshSingleDialog() {
    final String[] items = new String[]{"每1小时", "每2小时", "每4小时","每8小时"};
    final int checkedIndex = refreshFlag;
    new QMUIDialog.CheckableDialogBuilder(PersonActivity.this)
            .setCheckedIndex(checkedIndex)
            .addItems(items, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    refreshForWeather = items[which];
                    sharedPreferencesEdit("refreshForWeather",refreshForWeather);
                    refreshForWeatherListView.setDetailText(refreshForWeather);
                    refreshFlag = which;
                    SharedPreferences.Editor editor = getSharedPreferences("person", MODE_PRIVATE).edit();
                    editor.putInt("refreshFlag", refreshFlag);
                    editor.apply();
                    EventBus.getDefault().postSticky(new RefreshTimeEvent("sendService"));
                    dialog.dismiss();
                    Toast.makeText(PersonActivity.this,"城市列表天气自动刷新间隔为"+refreshForWeather,Toast.LENGTH_SHORT).show();

                }
            })
            .create().show();
}
 
Example #2
Source File: AddAndEditPoetryActivity.java    From PoetryWeather with Apache License 2.0 6 votes vote down vote up
/**
 * 匹配天气多选输入框
 */
@SuppressLint("LongLogTag")
private void showWeatherPoetryMultiChoiceDialog(){
    final QMUIDialog.MultiCheckableDialogBuilder builder = new QMUIDialog.MultiCheckableDialogBuilder(AddAndEditPoetryActivity.this)
            .setCheckedItems(weatherItems)
            .addItems(items, (dialog, which) -> {

            });
    builder.addAction("取消", (dialog, index) -> dialog.dismiss());
    builder.addAction("提交", (dialog, index) -> {
        String text = "";
        sWeatherPoetry = "";
        weatherItems = builder.getCheckedItemIndexes();
        for (int i = 0; i < weatherItems.length; i++) {
            text += items[builder.getCheckedItemIndexes()[i]]+" ";
            sWeatherPoetry += items[builder.getCheckedItemIndexes()[i]] + " ";
        }
        Log.d(TAG, "sWeatherPoetry: "+sWeatherPoetry);
        weatherPoetryListView.setDetailText(text);
        dialog.dismiss();
    });
    builder.create().show();
}
 
Example #3
Source File: AddAndEditPoetryActivity.java    From PoetryWeather with Apache License 2.0 6 votes vote down vote up
/**
 * 清婉秀丽单选框
 */
private void showQWXLSingleChoiceDialog(){
    final String[] items = new String[]{"否", "是"};
    QMUIDialog.CheckableDialogBuilder checkableDialogBuilder = new QMUIDialog.CheckableDialogBuilder(AddAndEditPoetryActivity.this);
    if (qwxl >= 0) {
        checkableDialogBuilder.setCheckedIndex(qwxl);
    }
    checkableDialogBuilder.addItems(items, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            qwxl = which;
            isqwxlPoetryListView.setDetailText(items[qwxl]);
            dialog.dismiss();
        }
    }).create().show();
}
 
Example #4
Source File: Browse9PForumActivity.java    From v9porn with MIT License 6 votes vote down vote up
private void showTipDialog() {
    QMUIDialog.MessageDialogBuilder builder = new QMUIDialog.MessageDialogBuilder(this);
    builder.setTitle("温馨提示");
    builder.setMessage("1. 如果你看不到网页内容或者报错了,说明当前页面结构还不支持解析\n" +
            "2. 在你网速慢或者图片较大或者服务器响应慢的情况下,你会只看到少少的几行文字,这是正常的,你可以多刷新几次试试\n" +
            "3. 你可以点击某一张图进入浏览图片模式\n" +
            "4. 目前不支持查看评论及部分网页未适配屏幕宽度");
    builder.addAction("我知道了", new QMUIDialogAction.ActionListener() {
        @Override
        public void onClick(QMUIDialog dialog, int index) {
            presenter.setNeedShowTipFirstViewForum9Content(false);
            dialog.dismiss();
        }
    });
    builder.show();
}
 
Example #5
Source File: AddAndEditPoetryActivity.java    From PoetryWeather with Apache License 2.0 6 votes vote down vote up
/**
 * 激越高亢单选框
 */
private void showJYGKSingleChoiceDialog(){
    final String[] items = new String[]{"否", "是"};
    QMUIDialog.CheckableDialogBuilder checkableDialogBuilder = new QMUIDialog.CheckableDialogBuilder(AddAndEditPoetryActivity.this);
    if (jygk >= 0) {
        checkableDialogBuilder.setCheckedIndex(jygk);
    }
    checkableDialogBuilder.addItems(items, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            jygk = which;
            isjygkPoetryListView.setDetailText(items[jygk]);
            dialog.dismiss();
        }
    }).create().show();
}
 
Example #6
Source File: AddAndEditPoetryActivity.java    From PoetryWeather with Apache License 2.0 6 votes vote down vote up
/**
 * 语言绮丽单选框
 */
private void showYYQLSingleChoiceDialog(){
    final String[] items = new String[]{"否", "是"};
    QMUIDialog.CheckableDialogBuilder checkableDialogBuilder = new QMUIDialog.CheckableDialogBuilder(AddAndEditPoetryActivity.this);
    if (yyql >= 0) {
        checkableDialogBuilder.setCheckedIndex(yyql);
    }
    checkableDialogBuilder.addItems(items, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            yyql = which;
            isyyqlPoetryListView.setDetailText(items[yyql]);
            dialog.dismiss();
        }
    }).create().show();
}
 
Example #7
Source File: SettingActivity.java    From v9porn with MIT License 6 votes vote down vote up
private void showPlaybackEngineChoiceDialog(final QMUICommonListItemView qmuiCommonListItemView) {
    final int checkedIndex = presenter.getPlaybackEngine();
    new QMUIDialog.CheckableDialogBuilder(this)
            .setTitle("播放引擎选择")
            .setCheckedIndex(checkedIndex)
            .addItems(PlaybackEngine.PLAY_ENGINE_ITEMS, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    presenter.setPlaybackEngine(which);
                    qmuiCommonListItemView.setDetailText(PlaybackEngine.PLAY_ENGINE_ITEMS[which]);
                    showMessage("设置成功", TastyToast.SUCCESS);
                    dialog.dismiss();
                }
            })
            .show();
}
 
Example #8
Source File: PersonActivity.java    From PoetryWeather with Apache License 2.0 6 votes vote down vote up
/**
 * 单选对话框
 */
private void showSingleDialog() {
    final String[] items = new String[]{"男", "女", "保密"};
    final int checkedIndex = sexFlag;
    new QMUIDialog.CheckableDialogBuilder(PersonActivity.this)
            .setCheckedIndex(checkedIndex)
            .addItems(items, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    sex = items[which];
                    sharedPreferencesEdit("sex",sex);
                    sexListView.setDetailText(sex);
                    sexFlag = which;
                    SharedPreferences.Editor editor = getSharedPreferences("person", MODE_PRIVATE).edit();
                    editor.putInt("sexFlag", sexFlag);
                    editor.apply();
                    dialog.dismiss();
                    Toast.makeText(PersonActivity.this,"您的性别已修改为"+sex,Toast.LENGTH_SHORT).show();

                }
            })
            .create().show();
}
 
Example #9
Source File: UserLoginActivity.java    From v9porn with MIT License 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_user_register) {
        new QMUIDialog.MessageDialogBuilder(this)
                .setMessage("注册功能已停止支持,请去9*porn官网注册,之后再来登录!")
                .addAction("知道了", new QMUIDialogAction.ActionListener() {
                    @Override
                    public void onClick(QMUIDialog dialog, int index) {
                        dialog.dismiss();
                    }
                })
                .show();
        return true;
    }

    return super.onOptionsItemSelected(item);
}
 
Example #10
Source File: AboutActivity.java    From v9porn with MIT License 6 votes vote down vote up
private void actionCleanFile(QMUIDialog.MultiCheckableDialogBuilder builder) {
    int selectIndexLength = builder.getCheckedItemIndexes().length;
    List<File> fileDirList = new ArrayList<>();
    for (int i = 0; i < selectIndexLength; i++) {
        int indexCheck = builder.getCheckedItemIndexes()[i];
        switch (indexCheck) {
            case 0:
                fileDirList.add(AppCacheUtils.getRxCacheDir(AboutActivity.this));
                break;
            case 1:
                fileDirList.add(AppCacheUtils.getVideoCacheDir(AboutActivity.this));
                break;
            case 2:
                fileDirList.add(AppCacheUtils.getGlideDiskCacheDir(AboutActivity.this));
            default:
        }
    }
    if (fileDirList.size() == 0) {
        showMessage("未选择任何条目,无法清除缓存", TastyToast.INFO);
        return;
    }
    presenter.cleanCacheFile(fileDirList);
}
 
Example #11
Source File: MainActivity.java    From v9porn with MIT License 6 votes vote down vote up
private void showUpdateDialog(final UpdateVersion updateVersion) {
    QMUIDialog.MessageDialogBuilder builder = new QMUIDialog.MessageDialogBuilder(this);
    builder.setTitle("发现新版本--v" + updateVersion.getVersionName());
    builder.setMessage(updateVersion.getUpdateMessage());
    builder.addAction("立即更新", (dialog, index) -> {
        dialog.dismiss();
        showMessage("开始下载", TastyToast.INFO);
        Intent intent = new Intent(MainActivity.this, UpdateDownloadService.class);
        intent.putExtra("updateVersion", updateVersion);
        startService(intent);
    });
    builder.addAction("稍后更新", (dialog, index) -> dialog.dismiss());
    builder.addAction("该版本不再提示", (dialog, index) -> {
        //保存版本号,用户对于此版本选择了不在提示
        presenter.setIgnoreUpdateVersionCode(updateVersion.getVersionCode());
        dialog.dismiss();
    });
    builder.show();
}
 
Example #12
Source File: Browse9PForumActivity.java    From v9porn with MIT License 6 votes vote down vote up
private void showTipDialog() {
    QMUIDialog.MessageDialogBuilder builder = new QMUIDialog.MessageDialogBuilder(this);
    builder.setTitle("温馨提示");
    builder.setMessage("1. 如果你看不到网页内容或者报错了,说明当前页面结构还不支持解析\n" +
            "2. 在你网速慢或者图片较大或者服务器响应慢的情况下,你会只看到少少的几行文字,这是正常的,你可以多刷新几次试试\n" +
            "3. 你可以点击某一张图进入浏览图片模式\n" +
            "4. 目前不支持查看评论及部分网页未适配屏幕宽度");
    builder.addAction("我知道了", new QMUIDialogAction.ActionListener() {
        @Override
        public void onClick(QMUIDialog dialog, int index) {
            presenter.setNeedShowTipFirstViewForum9Content(false);
            dialog.dismiss();
        }
    });
    builder.show();
}
 
Example #13
Source File: PoetryActivity.java    From PoetryWeather with Apache License 2.0 6 votes vote down vote up
private void showCheckPriorDialog() {
    final String[] check = new String[1];
    final String[] items = {"低", "标准", "高"};
    QMUIDialog.CheckableDialogBuilder checkableDialogBuilder = new QMUIDialog.CheckableDialogBuilder(PoetryActivity.this);
    checkableDialogBuilder.addItems(items, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            check[0] = items[i];
            priorOwnPoetry.setDetailText(items[i]);
            switch (items[i]) {
                case "低":
                    PrefUtils.putInt("priorPoetry", 1, PoetryActivity.this);
                    break;
                case "标准":
                    PrefUtils.putInt("priorPoetry", 2, PoetryActivity.this);
                    break;
                case "高":
                    PrefUtils.putInt("priorPoetry", 4, PoetryActivity.this);
                    break;
                default:
                    break;
            }
            dialogInterface.dismiss();
        }
    }).create().show();
}
 
Example #14
Source File: SettingActivity.java    From v9porn with MIT License 6 votes vote down vote up
private void showPlaybackEngineChoiceDialog(final QMUICommonListItemView qmuiCommonListItemView) {
    final int checkedIndex = presenter.getPlaybackEngine();
    new QMUIDialog.CheckableDialogBuilder(this)
            .setTitle("播放引擎选择")
            .setCheckedIndex(checkedIndex)
            .addItems(PlaybackEngine.PLAY_ENGINE_ITEMS, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    presenter.setPlaybackEngine(which);
                    qmuiCommonListItemView.setDetailText(PlaybackEngine.PLAY_ENGINE_ITEMS[which]);
                    showMessage("设置成功", TastyToast.SUCCESS);
                    dialog.dismiss();
                }
            })
            .show();
}
 
Example #15
Source File: UserLoginActivity.java    From v9porn with MIT License 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_user_register) {
        new QMUIDialog.MessageDialogBuilder(this)
                .setMessage("注册功能已停止支持,请去9*porn官网注册,之后再来登录!")
                .addAction("知道了", new QMUIDialogAction.ActionListener() {
                    @Override
                    public void onClick(QMUIDialog dialog, int index) {
                        dialog.dismiss();
                    }
                })
                .show();
        return true;
    }

    return super.onOptionsItemSelected(item);
}
 
Example #16
Source File: AboutActivity.java    From v9porn with MIT License 6 votes vote down vote up
private void actionCleanFile(QMUIDialog.MultiCheckableDialogBuilder builder) {
    int selectIndexLength = builder.getCheckedItemIndexes().length;
    List<File> fileDirList = new ArrayList<>();
    for (int i = 0; i < selectIndexLength; i++) {
        int indexCheck = builder.getCheckedItemIndexes()[i];
        switch (indexCheck) {
            case 0:
                fileDirList.add(AppCacheUtils.getRxCacheDir(AboutActivity.this));
                break;
            case 1:
                fileDirList.add(AppCacheUtils.getVideoCacheDir(AboutActivity.this));
                break;
            case 2:
                fileDirList.add(AppCacheUtils.getGlideDiskCacheDir(AboutActivity.this));
            default:
        }
    }
    if (fileDirList.size() == 0) {
        showMessage("未选择任何条目,无法清除缓存", TastyToast.INFO);
        return;
    }
    presenter.cleanCacheFile(fileDirList);
}
 
Example #17
Source File: MainActivity.java    From v9porn with MIT License 6 votes vote down vote up
private void showUpdateDialog(final UpdateVersion updateVersion) {
    QMUIDialog.MessageDialogBuilder builder = new QMUIDialog.MessageDialogBuilder(this);
    builder.setTitle("发现新版本--v" + updateVersion.getVersionName());
    builder.setMessage(updateVersion.getUpdateMessage());
    builder.addAction("立即更新", (dialog, index) -> {
        dialog.dismiss();
        showMessage("开始下载", TastyToast.INFO);
        Intent intent = new Intent(MainActivity.this, UpdateDownloadService.class);
        intent.putExtra("updateVersion", updateVersion);
        startService(intent);
    });
    builder.addAction("稍后更新", (dialog, index) -> dialog.dismiss());
    builder.addAction("该版本不再提示", (dialog, index) -> {
        //保存版本号,用户对于此版本选择了不在提示
        presenter.setIgnoreUpdateVersionCode(updateVersion.getVersionCode());
        dialog.dismiss();
    });
    builder.show();
}
 
Example #18
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 #19
Source File: PersonActivity.java    From PoetryWeather with Apache License 2.0 5 votes vote down vote up
/**
 * 多选框弹窗
 */
private void showMultiChoiceDialog() {
    final String[] items = new String[]{"清婉秀丽", "激越高亢", "语言绮丽"};
    final QMUIDialog.MultiCheckableDialogBuilder builder = new QMUIDialog.MultiCheckableDialogBuilder(PersonActivity.this)
            .addItems(items, (dialog, which) -> {});
    Log.d(TAG, "showMultiChoiceDialog: "+preferenceFlag.length);
    builder.setCheckedItems(preferenceFlag);
    builder.addAction("取消", (dialog, index) -> dialog.dismiss());
    builder.addAction("提交", (dialog, index) -> {
        String result = "您选择了 ";
        preference = "";
        for (int i = 0; i < builder.getCheckedItemIndexes().length; i++) {
            result += "" + items[builder.getCheckedItemIndexes()[i]] + " ";
            preference += items[builder.getCheckedItemIndexes()[i]] + " ";
        }
        //sharedPreferences存数组
        preferenceFlag = builder.getCheckedItemIndexes();
        Log.d(TAG, "showMultiChoiceDialog: indexes"+builder.getCheckedItemIndexes().length);
        JSONArray jsonArray = new JSONArray();
        for (int c : preferenceFlag) {
            jsonArray.put(c);
            Log.d(TAG, "showMultiChoiceDialog: c"+c);
        }
        Log.d(TAG, "showMultiChoiceDialog: jsonArray"+jsonArray.length());
        sharedPreferencesEdit("preferenceFlag",jsonArray.toString());
        sharedPreferencesEdit("preference",preference);
        preferenceListView.setDetailText(preference);
        Toast.makeText(PersonActivity.this, result, Toast.LENGTH_SHORT).show();
        dialog.dismiss();
    });
    builder.create(mCurrentDialogStyle).show();
}
 
Example #20
Source File: QMUIDialogActivity.java    From BaseUIFrame with MIT License 5 votes vote down vote up
/**
 * 菜单类型对话框 直接选择确认不带Check选项标识
 */
private void showMenuDialog() {
    final String[] items = new String[]{"选项1", "选项2", "选项3"};
    new QMUIDialog.MenuDialogBuilder(mActivity)
            .addItems(items, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    ToastUtil.showToast("你选择了 " + items[which]);
                    dialog.dismiss();
                }
            }).show();
}
 
Example #21
Source File: PersonActivity.java    From PoetryWeather with Apache License 2.0 5 votes vote down vote up
@Override
public View onBuildContent(QMUIDialog dialog, ScrollView parent) {
    LinearLayout layout = new LinearLayout(mContext);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setLayoutParams(new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    int padding = QMUIDisplayHelper.dp2px(mContext, 20);
    layout.setPadding(padding, padding, padding, padding);
    mEditText = new EditText(mContext);
    QMUIViewHelper.setBackgroundKeepingPadding(mEditText, QMUIResHelper.getAttrDrawable(mContext, R.attr.qmui_list_item_bg_with_border_bottom));
    mEditText.setHint("在此输入您的个性签名,字数限制在50个以内");
    mEditText.setText(signature
    );
    LinearLayout.LayoutParams editTextLP = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, QMUIDisplayHelper.dpToPx(100));
    editTextLP.bottomMargin = QMUIDisplayHelper.dp2px(getContext(), 15);
    mEditText.setLayoutParams(editTextLP);
    layout.addView(mEditText);
    TextView textView = new TextView(mContext);
    textView.setLineSpacing(QMUIDisplayHelper.dp2px(getContext(), 4), 1.0f);
    textView.setText("推荐输入诗词作为个性签名。\n" +
            "例如:\n" +
            "众里寻他千百度,蓦然回首,那人却在灯火阑珊处。");
    textView.setTextColor(ContextCompat.getColor(getContext(), R.color.gray));
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    layout.addView(textView);
    return layout;
}
 
Example #22
Source File: QMUIDialogActivity.java    From BaseUIFrame with MIT License 5 votes vote down vote up
/**
 * 单选菜单类型对话框
 */
private void showSingleChoiceDialog() {
    final String[] items = new String[]{"选项1", "选项2", "选项3"};
    final int checkedIndex = 0;
    new QMUIDialog.CheckableDialogBuilder(mActivity)
            .setCheckedIndex(checkedIndex)
            .addItems(items, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    ToastUtil.showToast("你选择了 " + items[which]);
                    dialog.dismiss();
                }
            }).show();
}
 
Example #23
Source File: QMUIDialogActivity.java    From BaseUIFrame with MIT License 5 votes vote down vote up
@Override
public View onBuildContent(QMUIDialog dialog, ScrollView parent) {
    //初始化布局
    LinearLayout layout = new LinearLayout(mContext);
    layout.setOrientation(LinearLayout.VERTICAL);
    //设置布局参数
    layout.setLayoutParams(new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    int padding = QMUIDisplayHelper.dp2px(mContext, 20);//内边距20dp
    layout.setPadding(padding, padding, padding, padding);
    //初始化组件
    mEditText = new EditText(mContext);
    QMUIViewHelper.setBackgroundKeepingPadding(mEditText, QMUIResHelper.getAttrDrawable(mContext, R.attr.qmui_list_item_bg_with_border_bottom));
    mEditText.setHint("输入框");
    LinearLayout.LayoutParams editTextLP = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, QMUIDisplayHelper.dpToPx(50));
    editTextLP.bottomMargin = QMUIDisplayHelper.dp2px(mActivity, 15);
    mEditText.setLayoutParams(editTextLP);
    layout.addView(mEditText);

    TextView textView = new TextView(mContext);
    textView.setLineSpacing(QMUIDisplayHelper.dp2px(mActivity, 4), 1.0f);
    textView.setText("观察聚焦输入框后,键盘升起降下时 dialog 的高度自适应变化。\n\n" +
            "QMUI Android 的设计目的是用于辅助快速搭建一个具备基本设计还原效果的 Android 项目," +
            "同时利用自身提供的丰富控件及兼容处理,让开发者能专注于业务需求而无需耗费精力在基础代码的设计上。" +
            "不管是新项目的创建,或是已有项目的维护,均可使开发效率和项目质量得到大幅度提升。");
    textView.setTextColor(ContextCompat.getColor(mActivity, R.color.app_color_description));
    textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    layout.addView(textView);

    return layout;
}
 
Example #24
Source File: FireflyDialog.java    From smart-farmer-android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreateContent(QMUIDialog dialog, ViewGroup parent, Context context) {

    View view = LayoutInflater.from(context).inflate(R.layout.dialog_input_common, parent, false);
    mEditText = view.findViewById(R.id.dialog_edit_input);
    mEditText.setFocusable(true);
    mEditText.setFocusableInTouchMode(true);
    mEditText.setImeOptions(EditorInfo.IME_ACTION_GO);

    if (!QMUILangHelper.isNullOrEmpty(mDefaultText)) {
        mEditText.setText(mDefaultText);
    }

    if (mTransformationMethod != null) {
        mEditText.setTransformationMethod(mTransformationMethod);
    } else {
        mEditText.setInputType(mInputType);
    }

    if (mPlaceholder != null) {
        mEditText.setHint(mPlaceholder);
    }

    QMUISpanTouchFixTextView textView = view.findViewById(R.id.dialog_text);
    if (mDescription != null) {
        textView.setMovementMethodDefault();
        textView.setText(mDescription);
        textView.setVisibility(View.VISIBLE);
    } else {
        textView.setVisibility(View.GONE);
    }

    parent.addView(view);
}
 
Example #25
Source File: FireflyDialog.java    From smart-farmer-android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onAfter(QMUIDialog dialog, LinearLayout parent, Context context) {
    super.onAfter(dialog, parent, context);
    final InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    dialog.setOnDismissListener(dialog1 -> inputMethodManager.hideSoftInputFromWindow(mEditText.getWindowToken(), 0));
    if (startWithKeyboard) {
        mEditText.postDelayed(() -> {
            mEditText.requestFocus();
            inputMethodManager.showSoftInput(mEditText, 0);
        }, 300);
    }
}
 
Example #26
Source File: AddAndEditPoetryActivity.java    From PoetryWeather with Apache License 2.0 5 votes vote down vote up
/**
 * 诗词下句可输入对话框
 */
private void showSecondPoetryEditTextDialog() {
    QMUIDialog.EditTextDialogBuilder builder = new QMUIDialog.EditTextDialogBuilder(AddAndEditPoetryActivity.this);
    builder.setTitle("诗词下句")
            .setPlaceholder("请输入诗词,限制在10字以内")
            .setDefaultText(sSecondPotry)
            .addAction("取消", (dialog, index) -> dialog.dismiss())
            .addAction("确定", (dialog, index) -> {
                CharSequence secondPoetry = builder.getEditText().getText();
                if (secondPoetry != null && secondPoetry.length() > 0 && secondPoetry.length() <= 10) {
                    String str = stringFilter(secondPoetry.toString());
                    if (!secondPoetry.toString().equals(str)) {
                        Toast.makeText(AddAndEditPoetryActivity.this,"请输入纯汉字",Toast.LENGTH_SHORT).show();
                        return;
                    }
                    dialog.dismiss();
                    sSecondPotry = secondPoetry.toString();
                    secondPoetryListView.setDetailText(sSecondPotry);
                } else if (secondPoetry.length() >= 10) {
                    Toast.makeText(AddAndEditPoetryActivity.this, "您输入的诗词过长,请限制在10个汉字以内", Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(AddAndEditPoetryActivity.this, "您未输入任何内容,请重新输入", Toast.LENGTH_SHORT).show();
                }
            })
            .create().show();

}
 
Example #27
Source File: AddAndEditPoetryActivity.java    From PoetryWeather with Apache License 2.0 5 votes vote down vote up
/**
 * 诗词上句可输入对话框
 */
private void showFirstPoetryEditTextDialog() {
    QMUIDialog.EditTextDialogBuilder builder = new QMUIDialog.EditTextDialogBuilder(AddAndEditPoetryActivity.this);
    builder.setTitle("诗词上句")
            .setPlaceholder("请输入诗词,限制在10字以内")
            .setDefaultText(sFirstPoetry)
            .addAction("取消", (dialog, index) -> dialog.dismiss())
            .addAction("确定", (dialog, index) -> {
                CharSequence firstPoetry = builder.getEditText().getText();
                if (firstPoetry != null && firstPoetry.length() > 0 && firstPoetry.length() <= 10) {
                    String str = stringFilter(firstPoetry.toString());
                    if (!firstPoetry.toString().equals(str)) {
                        Toast.makeText(AddAndEditPoetryActivity.this,"请输入纯汉字",Toast.LENGTH_SHORT).show();
                        return;
                    }
                    dialog.dismiss();
                    sFirstPoetry = firstPoetry.toString();
                    firstPoetryListView.setDetailText(sFirstPoetry);
                } else if (firstPoetry.length() >= 10) {
                    Toast.makeText(AddAndEditPoetryActivity.this, "您输入的诗词过长,请限制在10个汉字以内", Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(AddAndEditPoetryActivity.this, "您未输入任何内容,请重新输入", Toast.LENGTH_SHORT).show();
                }
            })
            .create().show();

}
 
Example #28
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 #29
Source File: WelcomeActivity.java    From BlogDemo with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // 解决Android应用Launcher重复启动的问题
    if (!isTaskRoot() && getIntent() != null) {
        String action = getIntent().getAction();
        if (getIntent().hasCategory(Intent.CATEGORY_LAUNCHER) && Intent.ACTION_MAIN.equals(action)) {
            finish();
            return;
        }
    }
    setContentView(R.layout.activity_welcome);

    // 全屏,透明状态栏
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        View decorView = getWindow().getDecorView();
        int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
        decorView.setSystemUiVisibility(option);
        getWindow().setStatusBarColor(Color.TRANSPARENT);
    }

    new QMUIDialog.MessageDialogBuilder(this)
            .setMessage("服务器地址为:" + BuildConfig.SERVER_URL)
            .addAction(R.string.btn_confirm, new QMUIDialogAction.ActionListener() {
                @Override
                public void onClick(QMUIDialog dialog, int index) {
                    dialog.dismiss();
                    new Handler().postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            MainActivity.actionStart(WelcomeActivity.this);
                            finish();
                        }
                    }, 1500);
                }
            })
            .show();
}
 
Example #30
Source File: SettingActivity.java    From v9porn with MIT License 5 votes vote down vote up
private void showForbiddenReleaseMemoryTipInfoDialog() {
    QMUIDialog.MessageDialogBuilder builder = new QMUIDialog.MessageDialogBuilder(this);
    builder.setTitle("温馨提示");
    builder.setMessage("为了获得较好的体验,新版本程序占用内存较高,这可能导致后台运行而系统内存不足时成为系统回收内存的优先对象(尤其在低内存手机上),因此我做了自动释放内存功能,但这同时也会使体验有所下降,你可以强制关闭次功能,建议开启");
    builder.addAction("知道了", new QMUIDialogAction.ActionListener() {
        @Override
        public void onClick(QMUIDialog dialog, int index) {
            dialog.dismiss();
        }
    });
    builder.show();
}