I have a ViewHolder and in bindView() method set a OnLongClickListener.
When I rotate device and long click on list item java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState exception occurs.
I've already override show() method and tested commitAllowingStateLoss but still get exception.
Anyone can help me?
public void bindView(final FragmentActivity activity) {
...
itemView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
FingerprintDialogFragment fingerprintDialogFragment = FingerprintDialogFragment.getInstance(DecreeItemViewHolder.this);
fingerprintDialogFragment.show(activity.getSupportFragmentManager(), FINGERPRINT_DIALOG_TAG);
return true;
});
}
}
I solved the problem by a delegation...
Add checkFingerprintAuthentication() method in Caller Class:
void checkFingerprintAuthentication() {
FingerprintDialogFragment fingerprintDialogFragment = FingerprintDialogFragment.getInstance(this);
fingerprintDialogFragment.show(getActivity().getSupportFragmentManager(), FINGERPRINT_DIALOG_TAG);
}
Send Caller Class as a parameter to View Holder and call checkFingerprintAuthentication():
public void bindView(final DecreeCartableController cartableController) {
...
itemView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
cartableController.checkFingerprintAuthentication();
return true;
}
});
}
problem solved! :)