Class NotificationFragment

java.lang.Object
androidx.fragment.app.Fragment
androidx.fragment.app.DialogFragment
com.example.lottery.fragment.NotificationFragment
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 NotificationFragment extends androidx.fragment.app.DialogFragment
DialogFragment used by Organizers to input a notification message.

This fragment handles the UI for composing a notification. The actual sending logic is handled by the listener (e.g., EntrantsListActivity or OrganizerNotificationsActivity) which will create entries in the global 'notifications' collection and individual user 'inbox' subcollections.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Interface for components that handle the actual notification sending logic.

    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
    Initializes and returns a new NotificationFragment with a default title.
    Initializes and returns a new NotificationFragment with a specific title.
    void
    onAttach(android.content.Context context)
    Attaches the fragment to its context and ensures it implements the NotificationFragment.NotificationListener.
    android.app.Dialog
    onCreateDialog(android.os.Bundle savedInstanceState)
    Creates and returns the notification composition dialog.

    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

    • NotificationFragment

      public NotificationFragment()
  • Method Details

    • newInstance

      public static NotificationFragment newInstance()
      Initializes and returns a new NotificationFragment with a default title.
      Returns:
      a new notification fragment
    • newInstance

      public static NotificationFragment newInstance(String title)
      Initializes and returns a new NotificationFragment with a specific title.
      Parameters:
      title - The title to display on the dialog.
      Returns:
      a new notification fragment
    • onAttach

      public void onAttach(@NonNull android.content.Context context)
      Attaches the fragment to its context and ensures it implements the NotificationFragment.NotificationListener.
      Overrides:
      onAttach in class androidx.fragment.app.DialogFragment
      Parameters:
      context - The context to which the fragment is being attached.
      Throws:
      RuntimeException - if the context or parent fragment does not implement NotificationFragment.NotificationListener.
    • onCreateDialog

      @NonNull public android.app.Dialog onCreateDialog(@Nullable android.os.Bundle savedInstanceState)
      Creates and returns the notification composition dialog.
      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.
      Returns:
      A built AlertDialog for notification input.