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);
}
}
}
Aggregations