0

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;
        });
    }
}
manfcas
  • 1,933
  • 7
  • 28
  • 47
Hamed
  • 5,867
  • 4
  • 32
  • 56

1 Answers1

0

I solved the problem by a delegation...

  1. Add checkFingerprintAuthentication() method in Caller Class:

    void checkFingerprintAuthentication() {
        FingerprintDialogFragment fingerprintDialogFragment = FingerprintDialogFragment.getInstance(this);
        fingerprintDialogFragment.show(getActivity().getSupportFragmentManager(), FINGERPRINT_DIALOG_TAG);
    }
    
  2. 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! :)

Hamed
  • 5,867
  • 4
  • 32
  • 56