package Ġjp . b gl b . bon bor u . be haviors . app Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . support . design . widget . Coordinator Layout Ċ import Ġandroid . support . v 7 . app . AppCompatActivity Ċ import Ġandroid . view . View Ċ import Ġandroid . widget . Button Ċ import Ġandroid . widget . ImageView Ċ import Ġbutter knife . bind View Ċ import Ġjp . b gl b . bon bor u . be haviors . Y outube Like Behavior Ċ Ċ /** Ċ * ĠCopyright Ġ( C ) Ġ 2 0 1 7 ĠT ets u ya ĠMas uda Ċ * Ċ * ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ * Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ * ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ * Ċ * Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ * Ċ * ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ * Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ * ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ * ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ * Ġlimitations Ġunder Ġthe ĠLicense . Ċ */ Ċ class ĠY outube Behavior Activity () Ġ: ĠAppCompatActivity (), ĠY outube Like Behavior . On Behavior State Listener Ġ{ ĊĠ Ġval Ġroot Ġby Ġbind View < Coordinator Layout >( R . id . root ) ĊĠ Ġval Ġshow Ġby Ġbind View < Button >( R . id . show ) ĊĠ Ġval Ġreset Ġby Ġbind View < Button >( R . id . reset ) ĊĊĠ Ġvar Ġmedia : ĠImageView ? Ġ= Ġnull ĊĠ Ġvar Ġdescription : ĠView ? Ġ= Ġnull ĊĠ Ġvar Ġw ipe : ĠButton ? Ġ= Ġnull ĊĊĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠ ĠsetContentView ( R . layout . activity _ youtube ) ĊĊĠĠĠ Ġshow . setOnClickListener Ġ{ ĊĠĠĠĠĠ Ġmedia Ġ= Ġlayout Inflater . inflate ( R . layout . include _ media , Ġroot , Ġfalse ) Ġas ĠImageView ĊĠĠĠĠĠ Ġdescription Ġ= Ġlayout Inflater . inflate ( R . layout . include _ description , Ġroot , Ġfalse ) ĊĠĠĠĠĠ Ġw ipe Ġ= Ġdescription ?. findViewById ( R . id . w ipe ) Ġas ĠButton ĊĠĠĠĠĠ Ġval Ġbehavior Ġ= ĠY outube Like Behavior . from ( media ) ĊĠĠĠĠĠ Ġbehavior ?. listener Ġ= Ġthis ĊĊĠĠĠĠĠ Ġroot . addView ( media ) ĊĠĠĠĠĠ Ġroot . addView ( description ) ĊĊĠĠĠĠĠ Ġw ipe ?. setOnClickListener Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbehavior Ġ= ĠY outube Like Behavior . from ( media ) ĊĠĠĠĠĠĠĠ Ġbehavior ?. update State ( Y outube Like Behavior . STATE _ SH R INK ) ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġreset . setOnClickListener Ġ{ ĊĠĠĠĠĠ Ġval Ġbehavior Ġ= ĠY outube Like Behavior . from ( media ) ĊĠĠĠĠĠ Ġbehavior ?. update State ( Y outube Like Behavior . STATE _ EXP AN DED ) ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġon Behavior StateChanged ( newState : ĠLong ) Ġ{ ĊĠĠĠ Ġif Ġ( newState Ġ== ĠY outube Like Behavior . STATE _ TO _ RIGHT Ġ|| ĠnewState Ġ== ĠY outube Like Behavior . STATE _ TO _ LEFT ) Ġ{ ĊĠĠĠĠĠ Ġroot . remove View ( media ) ĊĠĠĠĠĠ Ġroot . remove View ( description ) ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ } Ċ