package Ġorg . dd os ol it ary . gre end rag on fly Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . text . InputType Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroid . widget . Array Adapter Ċ import Ġandroid . widget . Auto Complete TextView Ċ import Ġandroid . widget . EditText Ċ import Ġandroid . widget . Filter Ċ import Ġandroidx . core . widget . add TextChanged Listener Ċ import Ġandroidx . fragment . app . Fragment Ċ import Ġandroidx . lifecycle . ViewModel Provider Ċ Ċ class ĠBind Login Fragment Ġ: ĠFragment () Ġ{ Ċ ĉ comp anion Ġobject Ġ{ Ċĉ ĉ private Ġconst Ġval ĠSTATE _ SELECTED _ ITEM Ġ= Ġ" selected Item " Ċ ĉ } ĊĊ ĉ private Ġval Ġvm Ġby Ġlazy Ġ{ ĠViewModel Provider ( require Activity ())[ Bind Account ViewModel :: class . java ] Ġ} ĊĊ ĉ override Ġfun ĠonCreate View ( Ċĉ ĉ in flater : ĠLayoutInflater , Ċĉ ĉ container : ĠViewGroup ?, Ċĉ ĉ savedInstanceState : ĠBundle ?, Ċ ĉ ): ĠView ? Ġ{ Ċĉ ĉ return Ġinflater . inflate ( R . layout . fragment _ bind _ login , Ġcontainer , Ġfalse ) Ċ ĉ } ĊĊ ĉ override Ġfun Ġon Save InstanceState ( out State : ĠBundle ) Ġ{ Ċĉ ĉ super . on Save InstanceState ( out State ) Ċĉ ĉ vm . selected School ?. let Ġ{ Ġout State . put Int ( STATE _ SELECTED _ ITEM , Ġit ) Ġ} Ċ ĉ } ĊĊ ĉ override Ġfun Ġon Activity Created ( savedInstanceState : ĠBundle ?) Ġ{ Ċĉ ĉ super . on Activity Created ( savedInstanceState ) Ċĉ ĉ vm . selected School Ġ= ĠsavedInstanceState ?. getInt ( STATE _ SELECTED _ ITEM , Ġ- 1 ) Ċĉĉ ĉ ?. let Ġ{ Ġif Ġ( it Ġ== Ġ- 1 ) Ġnull Ġelse Ġit Ġ} Ċĉ ĉ require View (). run Ġ{ Ċĉĉ ĉ vm . sch ools . observe ( view Lifecycle Owner ) Ġ{ Ċĉĉĉ ĉ findViewById < Auto Complete TextView >( R . id . dropdown _ sch ools ). apply Ġ{ Ċĉĉĉĉ ĉ val Ġadapter Ġ= Ġobject Ġ: ĠArray Adapter < Bind Account ViewModel . Api School Info >( Ċĉĉĉĉĉ ĉ context , Ġandroid . R . layout . simple _ spinner _ dropdown _ item , Ġit Ċĉĉĉĉ ĉ ) Ġ{ Ċĉĉĉĉĉ ĉ override Ġfun Ġget Filter (): ĠFilter Ġ= Ġobject Ġ: ĠFilter () Ġ{ Ċĉĉĉĉĉĉ ĉ override Ġfun Ġperform Filtering ( constraint : ĠCharSequence ?): ĠFilter Results Ġ= Ċĉĉĉĉĉĉĉ ĉ Filter Results (). apply Ġ{ Ċĉĉĉĉĉĉĉĉ ĉ values Ġ= Ġit Ċĉĉĉĉĉĉĉĉ ĉ count Ġ= Ġit . size Ċĉĉĉĉĉĉĉ ĉ } ĊĊĉĉĉĉĉĉ ĉ override Ġfun Ġpublish Results ( constraint : ĠCharSequence ?, Ġresults : ĠFilter Results ?) Ġ{ Ċĉĉĉĉĉĉĉ ĉ notify DataSet Changed () Ċĉĉĉĉĉĉ ĉ } Ċĉĉĉĉĉ ĉ } Ċĉĉĉĉ ĉ } Ċĉĉĉĉ ĉ setAdapter ( adapter ) Ċĉĉĉĉ ĉ input Type Ġ= ĠInput Type . TYPE _ NULL Ċĉĉĉĉ ĉ setOn ItemClickListener Ġ{ Ġ_, Ġ_, Ġposition , Ġ_ Ġ-> Ġvm . selected School Ġ= Ġposition Ġ} Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ċĉĉ ĉ findViewById < EditText >( R . id . input _ student _ id ). apply Ġ{ Ċĉĉĉ ĉ add TextChanged Listener Ġ{ Ġvm . student Id Ġ= Ġit . toString () Ġ} Ċĉĉ ĉ } Ċĉĉ ĉ findViewById < EditText >( R . id . input _ password ). apply Ġ{ Ċĉĉĉ ĉ add TextChanged Listener Ġ{ Ġvm . password Ġ= Ġit . toString () Ġ} Ċĉĉ ĉ } Ċĉ ĉ } Ċ ĉ } Ċ } Ċ