Class AlertChallengeFragment

  • All Implemented Interfaces:
    android.content.ComponentCallbacks, android.view.View.OnCreateContextMenuListener, androidx.lifecycle.LifecycleOwner, androidx.lifecycle.ViewModelStoreOwner, androidx.savedstate.SavedStateRegistryOwner, AlertChallengeView, MvpView

    public class AlertChallengeFragment
    extends androidx.fragment.app.Fragment
    implements AlertChallengeView
    Headless fragment to handle the check for alert challenges. Must manually attach and call the showAlertChallengeAsDialog() method. This class will show all the alert challenges returned by the server. To listen for results, use FragmentResultListener and use the ALERT_CHALLENGE_REQUEST_KEY, having the ALERT_CHALLENGE_FINISHED and ALERT_CHALLENGE_ERROR as bundle keys of the result.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class androidx.fragment.app.Fragment

        androidx.fragment.app.Fragment.InstantiationException, androidx.fragment.app.Fragment.SavedState
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected androidx.fragment.app.FragmentResultListener createFragmentResultListener()  
      protected AlertChallengePresenter<AlertChallengeView> createPresenter()  
      void displayAlertChallenge​(Challenge challenge)
      Method called to display the alert challenge
      boolean hasStarted()  
      void onActivityResult​(int requestCode, int resultCode, android.content.Intent data)  
      void onAlertChallengeFailed​(java.lang.String error)
      Method called when an error occurred while retrieving the alert challenge
      void onAlertChallengeSuccess()
      Method called after all alert challenges are completed or no alert challenge is available
      void onAttach​(android.content.Context context)  
      android.view.View onCreateView​(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState)  
      void onDestroyView()  
      void onSaveInstanceState​(android.os.Bundle outState)  
      void showAlertChallenge​(boolean showDialogBeforeChallenge)
      Check for existing alert challenges and will show it in a new screen or activity
      void showAlertChallengeAsDialog()
      Check for existing alert challenges and will show it as dialog
      • Methods inherited from class androidx.fragment.app.Fragment

        dump, equals, getActivity, getAllowEnterTransitionOverlap, getAllowReturnTransitionOverlap, getArguments, getChildFragmentManager, getContext, getEnterTransition, getExitTransition, getFragmentManager, getHost, getId, getLayoutInflater, getLayoutInflater, getLifecycle, getLoaderManager, getParentFragment, getReenterTransition, getResources, getRetainInstance, getReturnTransition, getSavedStateRegistry, getSharedElementEnterTransition, getSharedElementReturnTransition, getString, getString, getTag, getTargetFragment, getTargetRequestCode, getText, getUserVisibleHint, getView, getViewLifecycleOwner, getViewLifecycleOwnerLiveData, getViewModelStore, hashCode, hasOptionsMenu, instantiate, instantiate, isAdded, isDetached, isHidden, isInLayout, isMenuVisible, isRemoving, isResumed, isStateSaved, isVisible, onActivityCreated, onAttach, onAttachFragment, onConfigurationChanged, onContextItemSelected, onCreate, onCreateAnimation, onCreateAnimator, onCreateContextMenu, onCreateOptionsMenu, onDestroy, onDestroyOptionsMenu, onDetach, onGetLayoutInflater, onHiddenChanged, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onOptionsItemSelected, onOptionsMenuClosed, onPause, onPictureInPictureModeChanged, onPrepareOptionsMenu, onPrimaryNavigationFragmentChanged, onRequestPermissionsResult, onResume, onStart, onStop, onViewCreated, onViewStateRestored, postponeEnterTransition, postponeEnterTransition, registerForContextMenu, requestPermissions, requireActivity, requireArguments, requireContext, requireFragmentManager, requireHost, requireParentFragment, requireView, setAllowEnterTransitionOverlap, setAllowReturnTransitionOverlap, setArguments, setEnterSharedElementCallback, setEnterTransition, setExitSharedElementCallback, setExitTransition, setHasOptionsMenu, setInitialSavedState, setMenuVisibility, setReenterTransition, setRetainInstance, setReturnTransition, setSharedElementEnterTransition, setSharedElementReturnTransition, setTargetFragment, setUserVisibleHint, shouldShowRequestPermissionRationale, startActivity, startActivity, startActivityForResult, startActivityForResult, startIntentSenderForResult, startPostponedEnterTransition, toString, unregisterForContextMenu
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • ALERT_CHALLENGE_REQUEST_KEY

        public static final java.lang.String ALERT_CHALLENGE_REQUEST_KEY
        The fragment listener request key for listening the results
        See Also:
        Constant Field Values
      • ALERT_CHALLENGE_DIALOG_REQUEST_KEY

        public static final java.lang.String ALERT_CHALLENGE_DIALOG_REQUEST_KEY
        The fragment listener request key of this class for listening results from AlertChallengeDialog
        See Also:
        Constant Field Values
      • ALERT_CHALLENGE_FINISHED

        public static final int ALERT_CHALLENGE_FINISHED
        The fragment result after all alert challenges are completed
        See Also:
        Constant Field Values
      • ALERT_CHALLENGE_ERROR

        public static final int ALERT_CHALLENGE_ERROR
        The fragment result when an error occurred while fetching for the alert challenges
        See Also:
        Constant Field Values
      • ALERT_CHALLENGE_ERROR_KEY

        public static final java.lang.String ALERT_CHALLENGE_ERROR_KEY
        The bundle extra key for the error message
        See Also:
        Constant Field Values
    • Constructor Detail

      • AlertChallengeFragment

        public AlertChallengeFragment()
    • Method Detail

      • onAttach

        public void onAttach​(@NonNull
                             android.content.Context context)
        Overrides:
        onAttach in class androidx.fragment.app.Fragment
      • onSaveInstanceState

        public void onSaveInstanceState​(@NonNull
                                        android.os.Bundle outState)
        Overrides:
        onSaveInstanceState in class androidx.fragment.app.Fragment
      • onActivityResult

        public void onActivityResult​(int requestCode,
                                     int resultCode,
                                     @Nullable
                                     android.content.Intent data)
        Overrides:
        onActivityResult in class androidx.fragment.app.Fragment
      • showAlertChallengeAsDialog

        public void showAlertChallengeAsDialog()
        Check for existing alert challenges and will show it as dialog
        See Also:
        showAlertChallenge(boolean)
      • showAlertChallenge

        public void showAlertChallenge​(boolean showDialogBeforeChallenge)
        Check for existing alert challenges and will show it in a new screen or activity
        Parameters:
        showDialogBeforeChallenge - true to show a dialog before showing the challenge, otherwise false.
        See Also:
        showAlertChallengeAsDialog()
      • onAlertChallengeFailed

        public void onAlertChallengeFailed​(java.lang.String error)
        Description copied from interface: AlertChallengeView
        Method called when an error occurred while retrieving the alert challenge
        Specified by:
        onAlertChallengeFailed in interface AlertChallengeView
        Parameters:
        error - the error message
      • hasStarted

        public boolean hasStarted()
        Returns:
        true if check for alert challenges has started. otherwise false
      • createFragmentResultListener

        protected androidx.fragment.app.FragmentResultListener createFragmentResultListener()
        Returns:
        an instance of the fragment result listener for listening from AlertChallengeDialog results
      • onCreateView

        @Nullable
        public android.view.View onCreateView​(android.view.LayoutInflater inflater,
                                              android.view.ViewGroup container,
                                              android.os.Bundle savedInstanceState)
        Overrides:
        onCreateView in class androidx.fragment.app.Fragment
      • onDestroyView

        public void onDestroyView()
        Overrides:
        onDestroyView in class androidx.fragment.app.Fragment