Class AlertChallengeFragment
- java.lang.Object
-
- androidx.fragment.app.Fragment
-
- com.cheetahdigital.challenges.ui.alert.AlertChallengeFragment
-
- All Implemented Interfaces:
android.content.ComponentCallbacks,android.view.View.OnCreateContextMenuListener,androidx.activity.result.ActivityResultCaller,androidx.lifecycle.HasDefaultViewModelProviderFactory,androidx.lifecycle.LifecycleOwner,androidx.lifecycle.ViewModelStoreOwner,androidx.savedstate.SavedStateRegistryOwner,AlertChallengeView,com.cheetahdigital.uikit.architecture.mvp.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 theshowAlertChallengeAsDialog()method. This class will show all the alert challenges returned by the server. To listen for results, useFragmentResultListenerand use theALERT_CHALLENGE_REQUEST_KEY, having theALERT_CHALLENGE_FINISHEDandALERT_CHALLENGE_ERRORas bundle keys of the result.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringALERT_CHALLENGE_DIALOG_REQUEST_KEYThe fragment listener request key of this class for listening results fromAlertChallengeDialogstatic intALERT_CHALLENGE_ERRORThe fragment result when an error occurred while fetching for the alert challengesstatic java.lang.StringALERT_CHALLENGE_ERROR_KEYThe bundle extra key for the error messagestatic intALERT_CHALLENGE_FINISHEDThe fragment result after all alert challenges are completedstatic java.lang.StringALERT_CHALLENGE_REQUEST_KEYThe fragment listener request key for listening the resultsstatic java.lang.StringALERT_CHALLENGE_RESULT_KEYThe bundle extra key for the result from checking of alert challenges, which can be eitherALERT_CHALLENGE_FINISHEDorALERT_CHALLENGE_ERRORstatic java.lang.StringCHALLENGE_DIALOG_RESULT_KEYThe bundle extra key for the fragment result fromAlertChallengeDialogstatic intCHALLENGE_DIALOG_SUCCESSThe fragment result after a challenge response success fromAlertChallengeDialogstatic java.lang.StringTAG
-
Constructor Summary
Constructors Constructor Description AlertChallengeFragment()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected androidx.fragment.app.FragmentResultListenercreateFragmentResultListener()protected AlertChallengePresenter<AlertChallengeView>createPresenter()voiddisplayAlertChallenge(Challenge challenge)Method called to display the alert challengebooleanhasStarted()voidonActivityResult(int requestCode, int resultCode, android.content.Intent data)voidonAlertChallengeFailed(java.lang.String error)Method called when an error occurred while retrieving the alert challengevoidonAlertChallengeSuccess()Method called after all alert challenges are completed or no alert challenge is availablevoidonAttach(android.content.Context context)android.view.ViewonCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState)voidonDestroyView()voidonSaveInstanceState(android.os.Bundle outState)voidshowAlertChallenge(boolean showDialogBeforeChallenge)Check for existing alert challenges and will show it in a new screen or activityvoidshowAlertChallengeAsDialog()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, getDefaultViewModelProviderFactory, getEnterTransition, getExitTransition, getFragmentManager, getHost, getId, getLayoutInflater, getLayoutInflater, getLifecycle, getLoaderManager, getParentFragment, getParentFragmentManager, 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, registerForActivityResult, registerForActivityResult, 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
-
-
-
-
Field Detail
-
TAG
public static final java.lang.String TAG
- See Also:
- Constant Field Values
-
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 fromAlertChallengeDialog- See Also:
- Constant Field Values
-
CHALLENGE_DIALOG_RESULT_KEY
public static final java.lang.String CHALLENGE_DIALOG_RESULT_KEY
The bundle extra key for the fragment result fromAlertChallengeDialog- See Also:
- Constant Field Values
-
CHALLENGE_DIALOG_SUCCESS
public static final int CHALLENGE_DIALOG_SUCCESS
The fragment result after a challenge response success fromAlertChallengeDialog- See Also:
- Constant Field Values
-
ALERT_CHALLENGE_RESULT_KEY
public static final java.lang.String ALERT_CHALLENGE_RESULT_KEY
The bundle extra key for the result from checking of alert challenges, which can be eitherALERT_CHALLENGE_FINISHEDorALERT_CHALLENGE_ERROR- 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
-
-
Method Detail
-
onAttach
public void onAttach(@NonNull android.content.Context context)- Overrides:
onAttachin classandroidx.fragment.app.Fragment
-
onSaveInstanceState
public void onSaveInstanceState(@NonNull android.os.Bundle outState)- Overrides:
onSaveInstanceStatein classandroidx.fragment.app.Fragment
-
onActivityResult
public void onActivityResult(int requestCode, int resultCode, @Nullable android.content.Intent data)- Overrides:
onActivityResultin classandroidx.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()
-
createPresenter
protected AlertChallengePresenter<AlertChallengeView> createPresenter()
- Returns:
- instance of
AlertChallengePresenter
-
displayAlertChallenge
public void displayAlertChallenge(Challenge challenge)
Description copied from interface:AlertChallengeViewMethod called to display the alert challenge- Specified by:
displayAlertChallengein interfaceAlertChallengeView- Parameters:
challenge- the challenge to be shown
-
onAlertChallengeSuccess
public void onAlertChallengeSuccess()
Description copied from interface:AlertChallengeViewMethod called after all alert challenges are completed or no alert challenge is available- Specified by:
onAlertChallengeSuccessin interfaceAlertChallengeView
-
onAlertChallengeFailed
public void onAlertChallengeFailed(java.lang.String error)
Description copied from interface:AlertChallengeViewMethod called when an error occurred while retrieving the alert challenge- Specified by:
onAlertChallengeFailedin interfaceAlertChallengeView- 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
AlertChallengeDialogresults
-
onCreateView
@Nullable public android.view.View onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState)- Overrides:
onCreateViewin classandroidx.fragment.app.Fragment
-
onDestroyView
public void onDestroyView()
- Overrides:
onDestroyViewin classandroidx.fragment.app.Fragment
-
-