v.find vs getDialog.find consistency and fix more textview/edittext

This commit is contained in:
Matthew Wong 2015-07-18 16:04:23 -04:00
parent 01b7b2102d
commit dcf66672fe
2 changed files with 7 additions and 7 deletions

View file

@ -123,7 +123,7 @@ public class SshKeyGen extends AppCompatActivity {
b.setOnClickListener(new View.OnClickListener() { b.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
TextView textView = (TextView) getDialog().findViewById(R.id.public_key); TextView textView = (TextView) v.findViewById(R.id.public_key);
ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE); ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("public key", textView.getText().toString()); ClipData clip = ClipData.newPlainText("public key", textView.getText().toString());
clipboard.setPrimaryClip(clip); clipboard.setPrimaryClip(clip);

View file

@ -86,16 +86,16 @@ public class pwgenDialogFragment extends DialogFragment {
@Override @Override
public void onShow(DialogInterface dialog) { public void onShow(DialogInterface dialog) {
setPreferences(); setPreferences();
EditText textView = (EditText) view.findViewById(R.id.passwordText); EditText editText = (EditText) view.findViewById(R.id.passwordText);
textView.setText(pwgen.generate(getActivity().getApplicationContext()).get(0)); editText.setText(pwgen.generate(getActivity().getApplicationContext()).get(0));
Button b = ad.getButton(AlertDialog.BUTTON_NEUTRAL); Button b = ad.getButton(AlertDialog.BUTTON_NEUTRAL);
b.setOnClickListener(new View.OnClickListener() { b.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
setPreferences(); setPreferences();
EditText textView = (EditText) getDialog().findViewById(R.id.passwordText); EditText editText = (EditText) view.findViewById(R.id.passwordText);
textView.setText(pwgen.generate(getActivity().getApplicationContext()).get(0)); editText.setText(pwgen.generate(callingActivity.getApplicationContext()).get(0));
} }
}); });
} }
@ -120,9 +120,9 @@ public class pwgenDialogFragment extends DialogFragment {
if (!((CheckBox) getDialog().findViewById(R.id.pronounceable)).isChecked()) { if (!((CheckBox) getDialog().findViewById(R.id.pronounceable)).isChecked()) {
preferences.add("s"); preferences.add("s");
} }
EditText textView = (EditText) getDialog().findViewById(R.id.lengthNumber); EditText editText = (EditText) getDialog().findViewById(R.id.lengthNumber);
try { try {
int length = Integer.valueOf(textView.getText().toString()); int length = Integer.valueOf(editText.getText().toString());
return pwgen.setPrefs(getActivity().getApplicationContext(), preferences, length); return pwgen.setPrefs(getActivity().getApplicationContext(), preferences, length);
} catch(NumberFormatException e) { } catch(NumberFormatException e) {
return pwgen.setPrefs(getActivity().getApplicationContext(), preferences); return pwgen.setPrefs(getActivity().getApplicationContext(), preferences);