Class CountryDialog

  • All Implemented Interfaces:
    android.content.ComponentCallbacks, android.content.DialogInterface.OnCancelListener, android.content.DialogInterface.OnDismissListener, android.view.View.OnCreateContextMenuListener, androidx.lifecycle.LifecycleOwner, androidx.lifecycle.ViewModelStoreOwner, androidx.savedstate.SavedStateRegistryOwner

    public class CountryDialog
    extends androidx.fragment.app.DialogFragment
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  CountryDialog.Country  
      static interface  CountryDialog.CountryListener
      Callback used when country is clicked.
      • Nested classes/interfaces inherited from class androidx.fragment.app.Fragment

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

      Fields 
      Modifier and Type Field Description
      java.lang.String TAG  
      • Fields inherited from class androidx.fragment.app.DialogFragment

        STYLE_NO_FRAME, STYLE_NO_INPUT, STYLE_NO_TITLE, STYLE_NORMAL
    • Constructor Summary

      Constructors 
      Constructor Description
      CountryDialog()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.List<CountryDialog.Country> getCountryList()  
      java.lang.String getCountryNameFromCode​(java.lang.String countryCode)  
      void onAttach​(android.content.Context context)  
      void onAttachFragment​(androidx.fragment.app.Fragment childFragment)  
      void onCreate​(android.os.Bundle savedInstanceState)  
      android.view.View onCreateView​(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState)  
      void onDismiss​(android.content.DialogInterface dialog)  
      void onViewCreated​(android.view.View view, android.os.Bundle savedInstanceState)  
      void setCountryList​(java.util.List<CountryDialog.Country> countryList)
      Set a custom country list to be populated upon creating the dialog
      void setCountryListener​(CountryDialog.CountryListener listener)
      Set a listener to handle country click event
      • Methods inherited from class androidx.fragment.app.DialogFragment

        dismiss, dismissAllowingStateLoss, getDialog, getShowsDialog, getTheme, isCancelable, onActivityCreated, onCancel, onCreateDialog, onDestroyView, onDetach, onGetLayoutInflater, onSaveInstanceState, onStart, onStop, requireDialog, setCancelable, setShowsDialog, setStyle, setupDialog, show, show, showNow
      • 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, onActivityResult, onAttach, onConfigurationChanged, onContextItemSelected, onCreateAnimation, onCreateAnimator, onCreateContextMenu, onCreateOptionsMenu, onDestroy, onDestroyOptionsMenu, onHiddenChanged, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onOptionsItemSelected, onOptionsMenuClosed, onPause, onPictureInPictureModeChanged, onPrepareOptionsMenu, onPrimaryNavigationFragmentChanged, onRequestPermissionsResult, onResume, 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

      • TAG

        public final java.lang.String TAG
    • Constructor Detail

      • CountryDialog

        public CountryDialog()
    • Method Detail

      • onCreate

        public void onCreate​(@Nullable
                             android.os.Bundle savedInstanceState)
        Overrides:
        onCreate in class androidx.fragment.app.DialogFragment
      • onCreateView

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

        public void onViewCreated​(@NonNull
                                  android.view.View view,
                                  @Nullable
                                  android.os.Bundle savedInstanceState)
        Overrides:
        onViewCreated in class androidx.fragment.app.Fragment
      • getCountryList

        public java.util.List<CountryDialog.Country> getCountryList()
        Returns:
        the list of countries.
      • onAttach

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

        public void onAttachFragment​(@NonNull
                                     androidx.fragment.app.Fragment childFragment)
        Overrides:
        onAttachFragment in class androidx.fragment.app.Fragment
      • getCountryNameFromCode

        public java.lang.String getCountryNameFromCode​(java.lang.String countryCode)
        Parameters:
        countryCode - country code used to search in the list
        Returns:
        country name matching the country code
      • setCountryList

        public void setCountryList​(java.util.List<CountryDialog.Country> countryList)
        Set a custom country list to be populated upon creating the dialog
        Parameters:
        countryList - list of country to be used/displayed in the list
      • setCountryListener

        public void setCountryListener​(CountryDialog.CountryListener listener)
        Set a listener to handle country click event
        Parameters:
        listener - listener for handling country click
      • onDismiss

        public void onDismiss​(@NonNull
                              android.content.DialogInterface dialog)
        Specified by:
        onDismiss in interface android.content.DialogInterface.OnDismissListener
        Overrides:
        onDismiss in class androidx.fragment.app.DialogFragment