Class ScannerFragment

  • 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

    public class ScannerFragment
    extends BaseFragment
    The 'Scan QR' page where users can use their rear camera to scan QR codes
    • Nested Class Summary

      • 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.Fragment

        mPreviousWho
    • Constructor Summary

      Constructors 
      Constructor Description
      ScannerFragment​(GameController gameController)
      Creates the ScannerFragment where users can scan and add new QR Codes to their profile
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      android.view.View onCreateView​(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState)
      Sets up the camera preview and ImageAnalysis usage on the ScannerFragment
      void onDestroy()
      Cleans up the camera when the user navigates from 'Scan QR', or when fragment is garbage collected
      void onRequestPermissionsResult​(int requestCode, java.lang.String[] permissions, int[] grantResults)
      Requests user to give app camera permissions
      • 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, onActivityCreated, onActivityResult, onAttach, onAttach, onAttachFragment, onConfigurationChanged, onContextItemSelected, onCreate, onCreateAnimation, onCreateAnimator, onCreateContextMenu, onCreateOptionsMenu, onDestroyOptionsMenu, onDestroyView, onDetach, onGetLayoutInflater, onHiddenChanged, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onOptionsItemSelected, onOptionsMenuClosed, onPause, onPictureInPictureModeChanged, onPrepareOptionsMenu, onPrimaryNavigationFragmentChanged, onResume, onSaveInstanceState, 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
      • Methods inherited from class java.lang.Object

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

      • ScannerFragment

        public ScannerFragment​(GameController gameController)
        Creates the ScannerFragment where users can scan and add new QR Codes to their profile
        Parameters:
        gameController - game controller
    • Method Detail

      • onCreateView

        @Nullable
        public android.view.View onCreateView​(@NonNull
                                              android.view.LayoutInflater inflater,
                                              @Nullable
                                              android.view.ViewGroup container,
                                              @Nullable
                                              android.os.Bundle savedInstanceState)
        Sets up the camera preview and ImageAnalysis usage on the ScannerFragment
        Overrides:
        onCreateView in class androidx.fragment.app.Fragment
        Parameters:
        inflater - The LayoutInflater object that can be used to inflate any views in the fragment,
        container - If non-null, this is the parent view that the fragment's UI should be attached to. The fragment should not add the view itself, but this can be used to generate the LayoutParams of the view.
        savedInstanceState - If non-null, this fragment is being re-constructed from a previous saved state as given here.
        Returns:
        The view that will show the user the 'Scan QR' page.
      • onRequestPermissionsResult

        public void onRequestPermissionsResult​(int requestCode,
                                               @NonNull
                                               java.lang.String[] permissions,
                                               @NonNull
                                               int[] grantResults)
        Requests user to give app camera permissions
        Overrides:
        onRequestPermissionsResult in class androidx.fragment.app.Fragment
        Parameters:
        requestCode - The request code passed in Fragment.requestPermissions(String[], int).
        permissions - The requested permissions. Never null.
        grantResults - The grant results for the corresponding permissions which is either PackageManager.PERMISSION_GRANTED or PackageManager.PERMISSION_DENIED. Never null.
      • onDestroy

        public void onDestroy()
        Cleans up the camera when the user navigates from 'Scan QR', or when fragment is garbage collected
        Overrides:
        onDestroy in class androidx.fragment.app.Fragment