Search in sources :

Example 1 with EditTextView

use of com.moro.mtweaks.views.recyclerview.EditTextView in project MTweaks-KernelAdiutorMOD by morogoku.

the class CreateFragment method addItems.

@Override
protected void addItems(List<RecyclerViewItem> items) {
    mEditTextViews.clear();
    mCodeViews.clear();
    for (final Items.Setting setting : mSettings) {
        if (setting.isScript()) {
            final CodeView codeView = new CodeView();
            codeView.setTitle(setting.getName(getActivity()));
            codeView.setSummary(setting.getDescription(getActivity()));
            codeView.setRequired(setting.isRequired());
            codeView.setCode(setting.getDefault());
            codeView.setTesting(setting.getUnit() != Items.Setting.Unit.APPLY);
            codeView.setOnItemClickListener(new RecyclerViewItem.OnItemClickListener() {

                @Override
                public void onClick(RecyclerViewItem item) {
                    Intent intent = new Intent(getActivity(), EditorActivity.class);
                    intent.putExtra(EditorActivity.TITLE_INTENT, setting.getName(getActivity()).toString());
                    intent.putExtra(EditorActivity.TEXT_INTENT, codeView.getCode());
                    startActivityForResult(intent, mSettings.indexOf(setting));
                }
            });
            codeView.setOnTestListener(new CodeView.OnTestListener() {

                @Override
                public void onTestResult(CodeView codeView, String output) {
                    showFab();
                }
            });
            items.add(codeView);
            mCodeViews.put(setting, codeView);
        } else if (setting.getUnit() != Items.Setting.Unit.ID) {
            EditTextView editTextView = new EditTextView();
            editTextView.setTitle(setting.getName(getActivity()));
            if (setting.isRequired()) {
                editTextView.setHint(getString(R.string.required));
            }
            if (setting.getUnit() == Items.Setting.Unit.INTEGER) {
                editTextView.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED);
            }
            editTextView.setText(setting.getDefault());
            editTextView.setTextWatcher(new TextWatcher() {

                @Override
                public void beforeTextChanged(CharSequence s, int start, int count, int after) {
                }

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {
                }

                @Override
                public void afterTextChanged(Editable s) {
                    showFab();
                }
            });
            items.add(editTextView);
            mEditTextViews.put(setting, editTextView);
        }
    }
}
Also used : Intent(android.content.Intent) RecyclerViewItem(com.moro.mtweaks.views.recyclerview.RecyclerViewItem) CodeView(com.moro.mtweaks.views.recyclerview.customcontrols.CodeView) EditorActivity(com.moro.mtweaks.activities.EditorActivity) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) Items(com.moro.mtweaks.utils.tools.customcontrols.Items) EditTextView(com.moro.mtweaks.views.recyclerview.EditTextView)

Aggregations

Intent (android.content.Intent)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 EditorActivity (com.moro.mtweaks.activities.EditorActivity)1 Items (com.moro.mtweaks.utils.tools.customcontrols.Items)1 EditTextView (com.moro.mtweaks.views.recyclerview.EditTextView)1 RecyclerViewItem (com.moro.mtweaks.views.recyclerview.RecyclerViewItem)1 CodeView (com.moro.mtweaks.views.recyclerview.customcontrols.CodeView)1