Class SampleFragment

java.lang.Object
androidx.fragment.app.Fragment
androidx.fragment.app.DialogFragment
com.example.lottery.fragment.SampleFragment
All Implemented Interfaces:
android.content.ComponentCallbacks, android.content.DialogInterface.OnCancelListener, android.content.DialogInterface.OnDismissListener, android.view.View.OnCreateContextMenuListener, androidx.activity.result.ActivityResultCaller, androidx.lifecycle.HasDefaultViewModelProviderFactory, androidx.lifecycle.LifecycleOwner, androidx.lifecycle.ViewModelStoreOwner, androidx.savedstate.SavedStateRegistryOwner

public class SampleFragment extends androidx.fragment.app.DialogFragment
fragment for user to enter the number of invitations they want to send

Responsibilities:

  • ask user to input a number and then call sampling in the EntrantsListActivity to sample entrants
  • implement US 02.05.02 Be able to sample number of attendees to register for the event
  • Keep the custom bottom navigation active on the details screen.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    interface for the activity who want to use the sample fragment to implement, like a communication channel

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

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

    Fields inherited from class androidx.fragment.app.DialogFragment

    STYLE_NO_FRAME, STYLE_NO_INPUT, STYLE_NO_TITLE, STYLE_NORMAL

    Fields inherited from class androidx.fragment.app.Fragment

    mPreviousWho
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    initialize a new fragment
    newInstance(long defaultSize)
    Creates a new fragment with a pre-filled default sample size.
    void
    onAttach(android.content.Context context)
    check whether implemented the communication channel or not
    android.app.Dialog
    onCreateDialog(android.os.Bundle savedInstanceState)
    assemble the fragment

    Methods inherited from class androidx.fragment.app.DialogFragment

    dismiss, dismissAllowingStateLoss, dismissNow, getDialog, getShowsDialog, getTheme, isCancelable, onActivityCreated, onCancel, onCreate, onDestroyView, onDetach, onDismiss, onGetLayoutInflater, onSaveInstanceState, onStart, onStop, onViewStateRestored, requireDialog, setCancelable, setShowsDialog, setStyle, setupDialog, show, show, showNow

    Methods inherited from class androidx.fragment.app.Fragment

    dump, equals, getActivity, getAllowEnterTransitionOverlap, getAllowReturnTransitionOverlap, getArguments, getChildFragmentManager, getContext, getDefaultViewModelCreationExtras, 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, onActivityResult, onAttach, onAttachFragment, onConfigurationChanged, onContextItemSelected, onCreateAnimation, onCreateAnimator, onCreateContextMenu, onCreateOptionsMenu, onCreateView, onDestroy, onDestroyOptionsMenu, onHiddenChanged, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onOptionsItemSelected, onOptionsMenuClosed, onPause, onPictureInPictureModeChanged, onPrepareOptionsMenu, onPrimaryNavigationFragmentChanged, onRequestPermissionsResult, onResume, onViewCreated, 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

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SampleFragment

      public SampleFragment()
  • Method Details

    • newInstance

      public static SampleFragment newInstance()
      initialize a new fragment
      Returns:
      initialized SampleFragment
    • newInstance

      public static SampleFragment newInstance(long defaultSize)
      Creates a new fragment with a pre-filled default sample size.
      Parameters:
      defaultSize - the maximum number of entrants that can be sampled
      Returns:
      configured SampleFragment
    • onAttach

      public void onAttach(@NonNull android.content.Context context)
      check whether implemented the communication channel or not
      Overrides:
      onAttach in class androidx.fragment.app.DialogFragment
      Parameters:
      context -
    • onCreateDialog

      @NonNull public android.app.Dialog onCreateDialog(@Nullable android.os.Bundle savedInstanceState)
      assemble the fragment
      Overrides:
      onCreateDialog in class androidx.fragment.app.DialogFragment
      Parameters:
      savedInstanceState - The last saved instance state of the Fragment, or null if this is a freshly created Fragment. get text from user
      Returns:
      a built fragment which can prompt user to enter a number for sampling