package Ġcom . str v academy . dr ab ek j . movie app . ui . actors Ċ Ċ import Ġandroid . app . Search Manager Ċ import Ġandroid . content . Context Ċ import Ġandroid . database . Matrix Cursor Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . support . v 7 . widget . Search View Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . Menu Ċ import Ġandroid . view . Menu Inflater Ċ import Ġandroid . view . input method . Input Method Manager Ċ import Ġcom . str v academy . dr ab ek j . movie app . R Ċ import Ġcom . str v academy . dr ab ek j . movie app . ui . actor detail . Actor Detail Activity Ċ import Ġcom . str v academy . dr ab ek j . movie app . databinding . Fragment Act ors Binding Ċ import Ġcom . str v academy . dr ab ek j . movie app . model . entity . Actor Entity Ċ import Ġcom . str v academy . dr ab ek j . movie app . ui . movies . Search Actor Results Adapter Ċ import Ġcom . str v academy . dr ab ek j . movie app . utils . base components . Base Fragment Ċ import Ġorg . alf on z . mv vm . A lf on z Activity ĊĊ Ċ class ĠAct ors Fragment : ĠBase Fragment < Act ors View , ĠAct ors ViewModel , ĠFragment Act ors Binding >(), ĠAct ors View Ġ{ Ċ ĉ var Ġsearch View : ĠSearch View ? Ġ= Ġnull ĊĊĊ ĉ override Ġfun Ġget ViewModel Class (): ĠClass < Act ors ViewModel > Ġ{ Ċĉ ĉ return ĠAct ors ViewModel :: class . java Ċ ĉ } ĊĊ ĉ override Ġfun Ġinf late Binding Layout ( in flater : ĠLayoutInflater ?): ĠFragment Act ors Binding Ġ{ Ċĉ ĉ return ĠFragment Act ors Binding . inflate ( in flater !! ) Ċ ĉ } ĊĊ ĉ override Ġfun Ġon Activity Created ( savedInstanceState : ĠBundle ?) Ġ{ Ċĉ ĉ super . on Activity Created ( savedInstanceState ) Ċĉ ĉ setup Toolbar () Ċ ĉ } ĊĊ ĉ override Ġfun ĠonCreate Options Menu ( menu : ĠMenu ?, Ġinflater : ĠMenu Inflater ?) Ġ{ Ċĉ ĉ in flater !!. inflate ( R . menu . toolbar _ main , Ġmenu ) Ċĉ ĉ super . onCreate Options Menu ( menu , Ġinflater ) ĊĊĉ ĉ setup Search View ( menu ) Ċ ĉ } ĊĊ ĉ private Ġfun Ġsetup Toolbar () Ġ{ Ċĉ ĉ ( activity Ġas ĠA lf on z Activity ). setup ActionBar ( A lf on z Activity . IND IC ATOR _ NONE , ĠgetString ( R . string . actors Toolbar Title )) Ċĉ ĉ set Has Options Menu ( true ) Ċ ĉ } ĊĊ ĉ override Ġfun Ġon Actor Click ( actor : ĠActor Entity ) Ġ{ Ċĉ ĉ if Ġ( actor . id Ġ!= Ġnull ) Ċĉĉ ĉ Actor Detail Activity . start As Intent ( activity , Ġactor . id !! ) Ċ ĉ } ĊĊ ĉ private Ġfun Ġsetup Search View ( menu : ĠMenu ?) Ġ{ Ċĉ ĉ val Ġsearch Manager Ġ= Ġactivity . getSystem Service ( Context . SEARCH _ SERVICE ) Ġas ĠSearch Manager Ċĉ ĉ val Ġsearch Item Ġ= Ġmenu !!. find Item ( R . id . action _ search ) Ċĉ ĉ search View Ġ= Ġsearch Item . action View Ġas ĠSearch View ĊĊĉ ĉ search View ?. set Search able Info ( search Manager . get Search able Info ( activity . component Name )) Ċĉ ĉ val Ġadapter Ġ= ĠviewModel . create Search Adapter () Ċĉ ĉ search View ?. suggestions Adapter Ġ= Ġadapter ĊĊĉ ĉ search View ?. setOn Query Text Listener ( object Ġ: ĠSearch View . On Query Text Listener Ġ{ Ċĉĉ ĉ override Ġfun Ġon Query Text Submit ( query : ĠString ): ĠBoolean Ġ{ Ċĉĉĉ ĉ // Ġhide Ġkeyboard Ċĉĉĉ ĉ val Ġinput Manager Ġ= Ġcontext . getSystem Service ( Context . INPUT _ METHOD _ SERVICE ) Ġas ĠInput Method Manager Ċĉĉĉ ĉ input Manager . hide Soft Input From Window ( activity . current Focus . window Token , ĠInput Method Manager . HIDE _ NOT _ ALWAYS ) ĊĊĉĉĉ ĉ return Ġtrue Ċĉĉ ĉ } ĊĊĉĉ ĉ override Ġfun Ġon Query Text Change ( new Text : ĠString ): ĠBoolean Ġ{ Ċĉĉĉ ĉ viewModel . load Data ( new Text ) Ċĉĉĉ ĉ return Ġtrue Ċĉĉ ĉ } Ċĉ ĉ }) Ċĉ ĉ search View ?. setOn Suggestion Listener ( object Ġ: ĠSearch View . On Suggestion Listener Ġ{ Ċĉĉ ĉ override Ġfun Ġon Suggestion Select ( position : ĠInt ): ĠBoolean Ġ{ Ġreturn Ġfalse Ġ} ĊĊĉĉ ĉ override Ġfun Ġon Suggestion Click ( position : ĠInt ): ĠBoolean Ġ{ Ċĉĉĉ ĉ val Ġsearch Cursor Ġ= Ġadapter . cursor Ċĉĉĉ ĉ if Ġ( search Cursor . moveTo Position ( position )) Ġ{ Ċĉĉĉĉ ĉ val Ġid Ġ= Ġsearch Cursor . getInt ( search Cursor . getColumnIndex ( Search Actor Results Adapter . RESULT _ COLUMN _ ID )) Ċĉĉĉĉ ĉ Actor Detail Activity . start As Intent ( activity , Ġid ) Ċĉĉĉ ĉ } ĊĊĉĉĉ ĉ return Ġtrue Ċĉĉ ĉ } Ċĉ ĉ }) Ċ ĉ } ĊĊ ĉ override Ġfun Ġshow Actor Results ( cursor : ĠMatrix Cursor ) Ġ{ Ċĉ ĉ search View ?. suggestions Adapter ?. swap Cursor ( cursor ) Ċ ĉ } ĊĊ ĉ comp anion Ġobject Ġ{ Ċĉ ĉ val ĠTAG Ġ= Ġ" actors _ fragment " ĊĊĉ ĉ fun Ġnew Instance (): ĠAct ors Fragment Ġ{ Ċĉĉ ĉ return ĠAct ors Fragment () Ċĉ ĉ } Ċ ĉ } Ċ }