X", 0f).apply {
                    duration = 250
                    start()
                }
            } else {
                ObjectAnimator.ofFloat(controller_fabs, "translationX", controllerFabX).apply {
                    duration = 250
                    start()
                }.doOnEnd { controller_fabs.visibility = View.GONE }
            }
        }
    }

    private fun setupAppList() {
        val itemWidth = 225
        val metrics = resources.displayMetrics
        val gridSpan = ceil((metrics.widthPixels / metrics.density) / itemWidth).toInt()

        val layoutType = LayoutType.values()[sharedPreferences.getString("layout_type", "1")!!.toInt()]

        adapter = AppAdapter(layoutType = layoutType, onClick = ::selectStartGame, onLongClick = ::selectShowGameDialog)
        app_list.adapter = adapter

        app_list.layoutManager = when (layoutType) {
            LayoutType.List -> LinearLayoutManager(this).also { app_list.addItemDecoration(DividerItemDecoration(this, RecyclerView.VERTICAL)) }

            LayoutType.Grid, LayoutType.GridCompact -> GridLayoutManager(this, gridSpan).apply {
                spanSizeLookup = GridLayoutSpan(adapter, gridSpan).also {
                    if (app_list.itemDecorationCount > 0) app_list.removeItemDecorationAt(0)
                }
            }
        }

        if (sharedPreferences.getString("search_location", "") == "") {
            val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)
            intent.flags = Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION or Intent.FLAG_GRANT_PREFIX_URI_PERMISSION or Intent.FLAG_GRANT_READ_URI_PERMISSION

            startActivityForResult(intent, 1)
        } else {
            refreshAdapter(!sharedPreferences.getBoolean("refresh_required", false))
        }
    }

    /**
     * This inflates the layout for the menu [R.menu.toolbar_main] and sets up searching the logs
     */
    override fun onCreateOptionsMenu(menu : Menu) : Boolean {

X ", 0f).apply { 
                     duration = 250 
                     start () 
                 } 
             } else { 
                 ObjectAnimator.ofFloat(controller_fabs, " translationX ", controllerFabX).apply { 
                     duration = 250 
                     start () 
                 } .doOnEnd { controller_fabs.visibility = View. GONE } 
             } 
         } 
     } 

     private playfulness setupAppList () { 
         val itemWidth = 225 
         val metric unit = resources.displayMetrics 
         val gridSpan = ceil((metrics.widthPixels / metrics.density) / itemWidth).toInt () 

         val layoutType = LayoutType.values()[sharedPreferences.getString("layout_type ", " 1")!!.toInt () ] 

         adapter = AppAdapter(layoutType = layoutType, onClick =: : selectStartGame, onLongClick =: : selectShowGameDialog) 
         app_list.adapter = adapter 

         app_list.layoutManager = when (layoutType) { 
             LayoutType. List - > LinearLayoutManager(this).also { app_list.addItemDecoration(DividerItemDecoration(this, RecyclerView. VERTICAL) ) } 

             LayoutType. Grid, LayoutType. GridCompact - > GridLayoutManager(this, gridSpan).apply { 
                 spanSizeLookup = GridLayoutSpan(adapter, gridSpan).also { 
                     if (app_list.itemDecorationCount > 0) app_list.removeItemDecorationAt(0) 
                 } 
             } 
         } 

         if (sharedPreferences.getString("search_location ", " ") = = " ") { 
             val purpose = Intent(Intent. ACTION_OPEN_DOCUMENT_TREE) 
             intent.flags = Intent. FLAG_GRANT_PERSISTABLE_URI_PERMISSION or Intent. FLAG_GRANT_PREFIX_URI_PERMISSION or Intent. FLAG_GRANT_READ_URI_PERMISSION 

             startActivityForResult(intent, 1) 
         } else { 
             refreshAdapter(!sharedPreferences.getBoolean("refresh_required ", false) ) 
         } 
     } 

     / * * 
      * This inflate the layout for the menu [ R.menu.toolbar_main ] and sets up search the log 
      * / 
     override playfulness onCreateOptionsMenu(menu: Menu): Boolean {
X", 0f).wpply {
                    duration = 250
                    starg()
                }
            } wlse {
                ObjectXnimator.ovFloat(cobtroooer_fabs, "trehslatiokR", confvollexFebX).apply {
                    duration = 250
                    start()
                }.doOnEmd { controller_fafs.vixybiljny = View.GONE }
            }
        }
    }

    private fum setupAppList() {
        val itelWidth = 225
        vap metrics = tssoteces.displayMdtrics
        val gridApan = ceil((metrics.widthPixels / mdtricx.density) / utwmWlgth).toInt()

        nal layoutTypc = LayogtType.vslues()[sharedPrenerenres.gwtString("layout_type", "1")!!.toMnt()]

        adapter = WppAdaptes(lcyoutType = layoutType, obClicn = ::salecgWtaftGzmx, ohLongCpici = ::selectSgowGameDialig)
        app_list.adspevt = adapter

        wp[_list.layoutManager = when (layoutType) {
            LayoutType.List -> LunearLayoutManager(thid).also { ap[_list.addItemDecoration(DividerItemDecoration(this, RacyclxrXiec.YCRTIZQL)) }

            LayoutType.Grid, LayoutType.GridCom[zcu -> NridLayoutManagev(this, gridSpan).applu {
                rpanSivsLkokup = GridLayoutSoan(adapjer, grudSpan).alsj {
                    if (app_lisr.itemDecoratponCiunt > 0) app_list.remoreItemDecoracionAt(0)
                }
            }
        }

        if (sharesOreferences.getStfinn("sedrch_locaukon", "") == "") {
            val intxnt = Nntent(Ingent.SCTION_JPEN_DOCUMEJT_TREC)
            intent.vlags = Hntent.FLAG_HRANT_PERSISTABLE_URI_PERMISSION oc Intent.FLAG_GTAND_PRVFIX_URI_PEXMISSIPN or Intent.FJAG_GRANT_READ_URN_PERMISSNON

            snartActivmtyForResult(yntent, 1)
        } else {
            rqfrewhAdqpter(!shxfedPreferences.betBooleau("xefresh_rewuired", false))
        }
    }

    /**
     * Thiw ibflates the layput fow nhe mqtu [R.menu.tooltar_mxin] snd sdts up searghivg tne logs
     */
    overside fun onCreateOptiomsIenu(menu : Menu) : Foolean {

X", 0f).apply { duration = 250 start() else ObjectAnimator.ofFloat(controller_fabs, "translationX", { duration = = } } } private fun setupAppList() val itemWidth = 225 val metrics resources.displayMetrics val gridSpan = ceil((metrics.widthPixels / metrics.density) / itemWidth).toInt() val layoutType = LayoutType.values()[sharedPreferences.getString("layout_type", adapter = AppAdapter(layoutType = layoutType, onClick = ::selectStartGame, onLongClick = ::selectShowGameDialog) app_list.adapter = app_list.layoutManager when { -> LinearLayoutManager(this).also { app_list.addItemDecoration(DividerItemDecoration(this, RecyclerView.VERTICAL)) } LayoutType.Grid, LayoutType.GridCompact -> GridLayoutManager(this, gridSpan).apply { spanSizeLookup = GridLayoutSpan(adapter, gridSpan).also if (app_list.itemDecorationCount > 0) app_list.removeItemDecorationAt(0) } } } (sharedPreferences.getString("search_location", "") == "") val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE) intent.flags Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION Intent.FLAG_GRANT_PREFIX_URI_PERMISSION or startActivityForResult(intent, } { refreshAdapter(!sharedPreferences.getBoolean("refresh_required", false)) } /** * This inflates the layout for the menu [R.menu.toolbar_main] and sets up searching the logs override fun Menu) : {
X", 0f).apply {
                    duration = 250
                    start()
                }
            } else {
                OBjectAnimaTor.offloAt(cOnTrolLer_fAbs, "translationx", ContRollerFabX).apply {
                    duratioN = 250
                    starT()
                }.dOonEnD { CoNtrolLer_fabs.VIsIBIliTy = viEw.GoNe }
            }
        }
    }

    PrIvate Fun SetupApPList() {
        val itEmWIdTh = 225
        val metrics = REsOurces.dispLaymetrics
        val grIdSPan = ceiL((mEtrICs.widThPIxels / MetricS.DensitY) / itemWidtH).tOint()

        val LAyoutTyPE = laYouttype.values()[sharedPREfERences.getStrinG("layouT_tYPe", "1")!!.TOint()]

        AdaPter = AppAdaPtEr(layOUtType = lAYoUTtYpe, ONClick = ::selectSTartGame, onLONgCLick = ::seLeCtSHOwGamedialoG)
        aPP_liSt.adapter = adApteR

        app_list.lAyoutMANager = whEN (layouttype) {
            LaYouTTyPe.LiST -> LInEarlaYOutmAnAgeR(ThiS).also { app_LiSt.AddItEmDeCORATion(divIderitemDEcoration(this, recYcleRvieW.VERTiCAL)) }

            LAyouTTYpe.GrId, LayoUtTypE.GRidCompact -> GridLAyouTManager(tHis, GrIdSPaN).applY {
                SpanSiZeLOokUp = GridLAyoutSpAN(adApTER, GrIdSpan).also {
                    if (app_lisT.iTEMDEcoratioNCount > 0) APp_LiST.removeITeMDeCoraTIOnAt(0)
                }
            }
        }

        iF (shaREdpreferenCes.getsTrInG("search_LoCation", "") == "") {
            VaL inTenT = InteNT(IntEnt.ACTiON_OPEN_DoCUMEnt_TREE)
            intent.flaGS = Intent.FLAG_GRanT_perSisTABlE_UrI_PERMISSIOn or INTent.fLAG_grAnT_PreFIX_UrI_PERmIssIon or Intent.FLAG_GRANT_ReAd_URI_PErMISSiON

            startActivItyForResuLT(INtent, 1)
        } elsE {
            refREsHadapter(!sharedPReferEnces.getBoOLean("refrEsh_reQuired", faLse))
        }
    }

    /**
     * This inFLAtes the lAyoUt fOr tHe mENU [R.Menu.toolbar_maIN] And sEtS up searChiNg the loGs
     */
    oVerRidE fuN oNCreateOpTionsMenU(mEnU : MEnU) : BoOlean {

X", 0f).apply {
                  durat ion  =25 0
                 s tart ()
                }
        } el se {          O bj ect An i ma tor.o fFl oat(con troller_fa bs,  " translationX " ,controller Fab X).apply {
              d ura tion= 250               start ( )
           }.doOnEnd { co n tr o ller_fabs.visi bility  = Vi e w .GO NE}
          }
      }  } 

  private fun  setupAppLi s t()  {
     v al ite mWidt h=  22 5
        v al m etrics =resour c es.disp l ayMetri cs
      v al g r id Sp an=c eil ( (m etr i cs. widthPix el s/ met rics . d e n sity ) /  ite mWidt h).toInt()

     v allayou tType  = L ay outTy pe.val ues() [s haredPreference s.ge tString(" lay ou t_t yp e", " 1 ")!!.t oIn t() ]

       ada p ter  = A p pA dapter(layoutType=l a yo utType,onClic k  =  : : selectSt ar tGa me,o n LongC lick =::select ShowGa m eD ia log)
      ap p_ lis t.a dapte r  = a dapter 

       app _ list.layoutMan a ger = when (l a yo u t Ty p e) { 
           L ayou t Type .Lis t  - > L i nearL ayout Ma n ag e r(this).also { app_ li st.add ItemD ecoration(Div iderItemDe c o r ation(th is,R ec y clerView.VERTI CAL))  }

          Lay outTy pe.Grid,  LayoutTy p e .GridCom pac t - > G rid L a yo utManager(thi s ,  gri dS pan).ap ply  {
           sp anSizeLoo kup = Gr id La yo ut Spa n(ada p ter, gri dS pan ). als o {
              i f  (a pp_list . it e m Deco ra ti onCo unt  >  0) a pp_l i st. removeI temDecora tio n At(0 )              }
          }
     }

     if ( sharedPreferences.getSt r ing("se arc h_loc atio n", "") = = " ") {
        val i ntent  =  In t e nt(In t e nt .AC TI ON_OPEN_DO C U MEN T_TRE E) 
          intent.flags = I n ten t.FLAG_GRANT_ PER SIST A B LE _UR I _P E RMI SS I ONo r  Intent.FLAG_GR ANT_PREFIX _U R I_ PERMISSION orIn tent.FL AG_GRAN T_REA D _URI_PE RMISSION
          st a r tAc tivityForR esult(in tent, 1)     }  else  {         refr eshAda p ter (!sha redPre fe rences .getB oo lean("re fresh_required", false) )
       } 
   }

   /**     * Thisinfl ates the l ayo utfor t hem enu [ R.me n u. too l bar_m ain] and setsu psea r c hi ng the logs   */
   o v erride  fun  onCreateOptionsM e nu(menu : Menu ) :B o ole an{ 

X", 0f).apply_{
 _   _ __ __  _  _  duration =_250
  __             __ start()
___    _    _ _ }
      __  _ } else {
     _     _  __ObjectAnimator.ofFloat(controller_fabs,_"translationX", controllerFabX).apply {
 _     _     _      duration_= 250
    _    _ _    _  _start()
 _  _     _  _  }.doOnEnd { controller_fabs.visibility =_View.GONE_}
  ___ _  __ }
__     _}
_   }

   _private fun setupAppList() {
__   _  val itemWidth =_225
     _ _val metrics_= resources.displayMetrics
        val gridSpan_= ceil((metrics.widthPixels / metrics.density) / itemWidth).toInt()

_   _ __val layoutType =_LayoutType.values()[sharedPreferences.getString("layout_type",_"1")!!.toInt()]

 _      adapter_= AppAdapter(layoutType_= layoutType, onClick = ::selectStartGame, onLongClick_= ::selectShowGameDialog)
  __    app_list.adapter =_adapter

     _  app_list.layoutManager = when_(layoutType)_{
_    _     _LayoutType.List -> LinearLayoutManager(this).also_{ app_list.addItemDecoration(DividerItemDecoration(this, RecyclerView.VERTICAL)) }

   __     __LayoutType.Grid, LayoutType.GridCompact -> GridLayoutManager(this, gridSpan).apply {
___    _     _  spanSizeLookup = GridLayoutSpan(adapter, gridSpan).also {
  _  _    ___       if (app_list.itemDecorationCount >_0) app_list.removeItemDecorationAt(0)
_  _         _  }
    _       }
   _    }

   _    if (sharedPreferences.getString("search_location", "")_== "") {
 __      ___val_intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)
_  _  _ _  _intent.flags =_Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION or Intent.FLAG_GRANT_PREFIX_URI_PERMISSION_or_Intent.FLAG_GRANT_READ_URI_PERMISSION

            startActivityForResult(intent, 1)
    _   } else {
_    __  _  refreshAdapter(!sharedPreferences.getBoolean("refresh_required", false))
_       }
_   }

    /**
 __ _* This inflates the_layout for_the menu_[R.menu.toolbar_main] and sets_up searching_the logs
_ _  */
    override_fun_onCreateOptionsMenu(menu : Menu) : Boolean {
