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.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 theshowAlertChallengeAsDialog()
method. This class will show all the alert challenges returned by the server. To listen for results, useFragmentResultListener
and use theALERT_CHALLENGE_REQUEST_KEY
, having theALERT_CHALLENGE_FINISHED
andALERT_CHALLENGE_ERROR
as bundle keys of the result.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ALERT_CHALLENGE_DIALOG_REQUEST_KEY
The fragment listener request key of this class for listening results fromAlertChallengeDialog
static int
ALERT_CHALLENGE_ERROR
The fragment result when an error occurred while fetching for the alert challengesstatic java.lang.String
ALERT_CHALLENGE_ERROR_KEY
The bundle extra key for the error messagestatic int
ALERT_CHALLENGE_FINISHED
The fragment result after all alert challenges are completedstatic java.lang.String
ALERT_CHALLENGE_REQUEST_KEY
The fragment listener request key for listening the resultsstatic java.lang.String
ALERT_CHALLENGE_RESULT_KEY
The bundle extra key for the result from checking of alert challenges, which can be eitherALERT_CHALLENGE_FINISHED
orALERT_CHALLENGE_ERROR
static java.lang.String
CHALLENGE_DIALOG_RESULT_KEY
The bundle extra key for the fragment result fromAlertChallengeDialog
static int
CHALLENGE_DIALOG_SUCCESS
The fragment result after a challenge response success fromAlertChallengeDialog
static java.lang.String
TAG
-
Constructor Summary
Constructors Constructor Description AlertChallengeFragment()
-
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 challengeboolean
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 challengevoid
onAlertChallengeSuccess()
Method called after all alert challenges are completed or no alert challenge is availablevoid
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 activityvoid
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
-
-
-
-
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_FINISHED
orALERT_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:
onAttach
in classandroidx.fragment.app.Fragment
-
onSaveInstanceState
public void onSaveInstanceState(@NonNull android.os.Bundle outState)
- Overrides:
onSaveInstanceState
in classandroidx.fragment.app.Fragment
-
onActivityResult
public void onActivityResult(int requestCode, int resultCode, @Nullable android.content.Intent data)
- Overrides:
onActivityResult
in 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:AlertChallengeView
Method called to display the alert challenge- Specified by:
displayAlertChallenge
in interfaceAlertChallengeView
- Parameters:
challenge
- the challenge to be shown
-
onAlertChallengeSuccess
public void onAlertChallengeSuccess()
Description copied from interface:AlertChallengeView
Method called after all alert challenges are completed or no alert challenge is available- Specified by:
onAlertChallengeSuccess
in interfaceAlertChallengeView
-
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 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
AlertChallengeDialog
results
-
onCreateView
@Nullable public android.view.View onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState)
- Overrides:
onCreateView
in classandroidx.fragment.app.Fragment
-
onDestroyView
public void onDestroyView()
- Overrides:
onDestroyView
in classandroidx.fragment.app.Fragment
-
-