I have a PinDialogFragment
which loads from the MainActivity.java
class when it is time to enter a password. I created a static global in the fragment
class which is set to the appropriate Textview
and I then set it from MainActivity
. It should display the amount of attempts you have left in the Textview
.
I am not getting a NPE's but it doesn't set anything and the text remains the same despite the fact that it has been called.
In MainActivity:
final PinDialogFragment pinDialog = PinDialogFragment.newInstance(2);
pinDialog.setCheckRsaPinCallback(new checkPin()
{
@Override
public boolean checkPin(char[] pin) throws Exception
{
boolean pinIsCorrect = RSA.checkIfPinIsCorrect(pin);
System.out.println("is the pin correct: " + pinIsCorrect);
if (pinIsCorrect)
{
pinDialog.dismiss();
return true;
}
else if (numberOfAttempts < 3) //pin is not correct
{
//this does nothing
PinDialogFragment.enterPinView.setText("Incorrect Password: number of" +
" attempts left: " + numberOfAttempts);
PinDialogFragment.enterPinView.invalidate();
System.out.println("pin dialog: " + PinDialogFragment.enterPinView.getText());
numberOfAttempts++;
openExistingUserPinDialog();
}
else
{
//if wrong 3 times then crash the app
android.os.Process.killProcess(android.os.Process.myPid());
}
return false;
}
});
pinDialog.show(getFragmentManager(), "PinDialogFragment");
In PinDialogFragment:
public static TextView enterPinView;
private void initKeys(View v)
{
editPin = (EditText) v.findViewById(R.id.edit_pin_confirm);
enterPinView = (TextView) v.findViewById(R.id.enterPin);
.......
}