public final void showDialog() { EditText localEditText; if (this.gFV != null) localEditText = this.gFV; while (true) { ViewGroup.LayoutParams localLayoutParams = localEditText.getLayoutParams(); if ((localLayoutParams instanceof ViewGroup.MarginLayoutParams)) { ViewGroup.MarginLayoutParams localMarginLayoutParams = (ViewGroup.MarginLayoutParams) localLayoutParams; int i = localEditText.getResources().getDimensionPixelSize(g.aaQ); localMarginLayoutParams.leftMargin = i; localMarginLayoutParams.rightMargin = i; localMarginLayoutParams.topMargin = i; localMarginLayoutParams.bottomMargin = i; } if (localEditText.getParent() != null) ((ViewGroup) localEditText.getParent()).removeView(localEditText); this.dpV = h.a( getContext(), getTitle().toString(), localEditText, a.m(getContext(), n.bee), a.m(getContext(), n.bds), new k(this, localEditText), new l(this)); return; localEditText = new EditText(getContext()); localEditText.setLayoutParams(new ViewGroup.LayoutParams(-1, -2)); localEditText.setSingleLine(true); localEditText.setText(this.value); } }
private boolean commitValue() throws ElementFailureException { try { Utils.runCommand(command + " \"" + lastEdit.toString() + '"'); String result = getLiveValue(); if (!result.equals(getStoredValue())) Utils.db.setValue(command, result); try { stored = Integer.parseInt(result); } catch (NumberFormatException ignored) { stored = result; } lastLive = lastEdit = stored; textView.setText(lastLive.toString()); if (editText != null && editText.getParent() != null) if (((LinearLayout) editText.getParent()).findViewById(tv_id) == textView) editText.setText(lastLive.toString()); valueCheck(); return true; } catch (Exception e) { throw new ElementFailureException(this, e); } }
/** OnClickListener methods */ @Override public void onClick(View view) { if (editText == null) { editText = new EditText(Utils.mainActivity); editText.setGravity(Gravity.CENTER); editText.setImeOptions(EditorInfo.IME_ACTION_DONE); } if (inputType != null) { if (inputType.toLowerCase().equals("numeric")) editText.setInputType(InputType.TYPE_CLASS_NUMBER); else editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); } else if (lastLive instanceof Integer) editText.setInputType(InputType.TYPE_CLASS_NUMBER); else editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); textView.setVisibility(View.GONE); if (editText.getParent() != null) { ((LinearLayout) editText.getParent()).findViewById(tv_id).setVisibility(View.VISIBLE); ((LinearLayout) editText.getParent()).removeView(editText); } elementFrame.addView(editText); editText.setOnEditorActionListener(this); editText.setText(lastEdit.toString()); editText.requestFocus(); editText.setSelection(0, editText.getText().length()); Utils.imm.showSoftInput(editText, InputMethodManager.SHOW_FORCED); }
public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder exerciseInfo = new AlertDialog.Builder(getActivity()); final View view = getActivity().getLayoutInflater().inflate(R.layout.exercise_info_frag, null); exerciseInfo.setView(view); name = (EditText) view.findViewById(R.id.exerciseInfoNameField); sets = (EditText) view.findViewById(R.id.exerciseInfoSetsField); reps = (EditText) view.findViewById(R.id.exerciseInfoRepsField); info = (EditText) view.findViewById(R.id.exerciseInfoInfoField); // set values of EditTexts Bundle bundle = getArguments(); String timed = bundle.getString("timed"); name.setText(bundle.getString("name")); sets.setText(bundle.getString("sets")); if (timed.equals("n")) reps.setText(bundle.getString("reps")); // only if exercise is not timed info.setText(bundle.getString("info")); // don't want EditTexts to be editable name.setEnabled(false); sets.setEnabled(false); reps.setEnabled(false); info.setEnabled(false); // google search for "[exercise name] exercise example video" findVideo = (Button) view.findViewById(R.id.find_video); findVideo.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { String urlName = name.getText().toString().replaceAll(" ", "%20"); Uri uri = Uri.parse("http://google.com/#q=" + urlName + "%20exercise%20example%20video"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); } }); // don't show reps count if it's a timed exercise if (timed.equals("y")) { TextView repsTitle = (TextView) view.findViewById(R.id.exerciseInfoReps); ((LinearLayout) name.getParent()).removeView(repsTitle); ((LinearLayout) name.getParent()).removeView(reps); } // don't show info if it's blank if (bundle.getString("info") == null || bundle.getString("info").equals("")) { TextView infoTitle = (TextView) view.findViewById(R.id.exerciseInfoInfo); ((LinearLayout) name.getParent()).removeView(infoTitle); ((LinearLayout) name.getParent()).removeView(info); } return exerciseInfo.create(); }
@Override public void setDefaults() { if (original != null) { lastEdit = lastLive = original; textView.setText(lastLive.toString()); if (editText != null && editText.getParent() != null) if (((LinearLayout) editText.getParent()).findViewById(tv_id) == textView) editText.setText(lastLive.toString()); valueCheck(); } ActionValueNotifierHandler.propagate(this, ActionValueEvent.RESET); }
private void displaySnackbar() { View parentView = (View) title.getParent(); Snackbar.make( parentView, title.getText().toString() + " succesfully uploaded", Snackbar.LENGTH_LONG) .show(); }