• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java KeyboardUtil类的典型用法和代码示例

java 4次浏览

本文整理汇总了Java中com.mikepenz.materialdrawer.util.KeyboardUtil的典型用法代码示例。如果您正苦于以下问题:Java KeyboardUtil类的具体用法?Java KeyboardUtil怎么用?Java KeyboardUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

KeyboardUtil类属于com.mikepenz.materialdrawer.util包,在下文中一共展示了KeyboardUtil类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: calculateDosage

点赞 2

import com.mikepenz.materialdrawer.util.KeyboardUtil; //导入依赖的package包/类
private void calculateDosage() {
    boolean invalidInput = false;

    int inputCount = 0;
    for (DosageInputView view : dosageInputViews) {

        String value = view.getInputView().getText().toString();

        if (value.length() == 0) {
            invalidInput = true;
            break;
        }

        // store input value into working parameter
        mProduct.getParameters().get(mUnitMeasurement)[inputCount].
                setValue(Double.parseDouble(String.valueOf(view.getInputView().getText().toString())));
        inputCount++;
    }
    if (invalidInput) {
        Toast.makeText(getActivity(), getString(R.string.invalid_parameters),
                Toast.LENGTH_LONG).show();
        return;
    }

    SeachemDosage[] dosages;

    try {
        dosages = mProduct.calculateDosage(mUnitMeasurement);

        // prevent negative dosages
        for (SeachemDosage dosage : dosages) {
            if (dosage.getAmount() <= 0) {
                throw new ArithmeticException("Dosage can't be negative.");
            }
        }
    } catch (ArithmeticException ex) {
        Log.e(TAG, ex.toString());
        Toast.makeText(getActivity(), getString(R.string.calculation_error), Toast.LENGTH_LONG).show();
        return;
    }

    // hide keyboard after calculation
    KeyboardUtil.hideKeyboard(getActivity());

    MaterialDialog.Builder builder = new MaterialDialog.Builder(getContext());
    MaterialDialog dosageDialog = new DosageDialog(builder, dosages,
            mProduct.getWarnings(),
            mProduct.getNotes())
            .getDialog(getContext());

    dosageDialog.show();

    DoserApplication.getDoserPreferences().incrementTotalCalculations();
}
 

开发者ID:NateShoffner,
项目名称:Seachem-Doser,
代码行数:55,
代码来源:ProductFragment.java

示例2: onCancel

点赞 2

import com.mikepenz.materialdrawer.util.KeyboardUtil; //导入依赖的package包/类
@Override
public void onCancel(DialogInterface dialog) {
	KeyboardUtil.hideKeyboard(getActivity());
}
 

开发者ID:grote,
项目名称:Transportr,
代码行数:5,
代码来源:SpecialLocationFragment.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)