package Ġcom . ger ard br ad sh aw . v 2 mix up . ui . editor Ċ Ċ import Ġandroid . net . Uri Ċ import Ġandroid . util . Log Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġcom . ger ard br ad sh aw . coll age view . Coll age View Factory Ċ import Ġcom . ger ard br ad sh aw . v 2 mix up . R Ċ import Ġjava . util . Linked HashMap Ċ Ċ class ĠEditor ViewModel Ġ: ĠViewModel () Ġ{ ĊĊĠ Ġval Ġcoll age Icon Id To Type Ġ= ĠLinkedHashMap < Int , ĠColl age View Factory . Coll age Layout Type >() ĊĠ Ġval Ġratio StringTo Value Ġ= ĠLinkedHashMap < String , ĠFloat >() ĊĠ Ġval Ġcanvas AspectRatio Ġ= ĠMutable LiveData < Float >() ĊĠ Ġval Ġimage U ris Ġ= ĠarrayOf Null s < Uri >( 8 ) ĊĊĠ Ġinit Ġ{ ĊĠĠĠ Ġinit AspectRatio Map () ĊĠĠĠ Ġinit Coll age TypeMap () ĊĠĠĠ Ġcanvas AspectRatio . value Ġ= Ġ 1 f ĊĠ Ġ} ĊĊĠ Ġfun Ġadd Image Uri ( uri : ĠUri , Ġposition : ĠInt ) Ġ{ ĊĠĠĠ Ġif Ġ( position Ġ>= Ġimage U ris . size ) ĠLog . d ( TAG , Ġ" Cannot Ġsave ĠURI . ĠInvalid Ġposition .") ĊĠĠĠ Ġelse Ġimage U ris [ position ] Ġ= Ġuri ĊĠ Ġ} ĊĊĠ Ġfun Ġreset Image U ris () Ġ{ ĊĠĠĠ Ġfor Ġ( i Ġin Ġimage U ris . indices ) Ġ{ ĊĠĠĠĠĠ Ġimage U ris [ i ] Ġ= Ġnull ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġfun Ġset AspectRatio ( ratio : ĠFloat ) Ġ{ ĊĠĠĠ Ġcanvas AspectRatio . value Ġ= Ġratio ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġinit Coll age TypeMap () Ġ{ ĊĠĠĠ Ġcoll age Icon Id To Type [ R . drawable . ic _ coll age _ 2 _ image _ vertical ] Ġ= ĊĠĠĠĠĠ ĠColl age View Factory . Coll age Layout Type . TWO _ IMAGE _ VERTICAL ĊĊĠĠĠ Ġcoll age Icon Id To Type [ R . drawable . ic _ coll age _ 2 _ image _ horizontal ] Ġ= ĊĠĠĠĠĠ ĠColl age View Factory . Coll age Layout Type . TWO _ IMAGE _ HORIZONTAL ĊĊĠĠĠ Ġcoll age Icon Id To Type [ R . drawable . ic _ coll age _ type _ 3 image 0 ] Ġ= ĊĠĠĠĠĠ ĠColl age View Factory . Coll age Layout Type . TH REE _ IMAGE _ 0 ĊĊĠĠĠ Ġcoll age Icon Id To Type [ R . drawable . ic _ coll age _ type _ 3 image 1 ] Ġ= ĊĠĠĠĠĠ ĠColl age View Factory . Coll age Layout Type . TH REE _ IMAGE _ 1 ĊĊĠĠĠ Ġcoll age Icon Id To Type [ R . drawable . ic _ coll age _ type _ 3 image 2 ] Ġ= ĊĠĠĠĠĠ ĠColl age View Factory . Coll age Layout Type . TH REE _ IMAGE _ 2 ĊĊĠĠĠ Ġcoll age Icon Id To Type [ R . drawable . ic _ coll age _ type _ 3 image 3 ] Ġ= ĊĠĠĠĠĠ ĠColl age View Factory . Coll age Layout Type . TH REE _ IMAGE _ 3 ĊĊĠĠĠ Ġcoll age Icon Id To Type [ R . drawable . ic _ coll age _ type _ 3 image 4 ] Ġ= ĊĠĠĠĠĠ ĠColl age View Factory . Coll age Layout Type . TH REE _ IMAGE _ HORIZONTAL ĊĊĠĠĠ Ġcoll age Icon Id To Type [ R . drawable . ic _ coll age _ type _ 3 image 5 ] Ġ= ĊĠĠĠĠĠ ĠColl age View Factory . Coll age Layout Type . TH REE _ IMAGE _ VERTICAL ĊĊĠĠĠ Ġcoll age Icon Id To Type [ R . drawable . ic _ coll age _ type _ 4 image 0 ] Ġ= ĊĠĠĠĠĠ ĠColl age View Factory . Coll age Layout Type . FO UR _ IMAGE _ 0 ĊĊĠĠĠ Ġcoll age Icon Id To Type [ R . drawable . ic _ coll age _ type _ 4 image 1 ] Ġ= ĊĠĠĠĠĠ ĠColl age View Factory . Coll age Layout Type . FO UR _ IMAGE _ 1 ĊĊĠĠĠ Ġcoll age Icon Id To Type [ R . drawable . ic _ coll age _ type _ 4 image 2 ] Ġ= ĊĠĠĠĠĠ ĠColl age View Factory . Coll age Layout Type . FO UR _ IMAGE _ 2 ĊĊĠĠĠ Ġcoll age Icon Id To Type [ R . drawable . ic _ coll age _ type _ 4 image 3 ] Ġ= ĊĠĠĠĠĠ ĠColl age View Factory . Coll age Layout Type . FO UR _ IMAGE _ 3 ĊĊĠĠĠ Ġcoll age Icon Id To Type [ R . drawable . ic _ coll age _ type _ 4 image 4 ] Ġ= ĊĠĠĠĠĠ ĠColl age View Factory . Coll age Layout Type . FO UR _ IMAGE _ 4 ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġinit AspectRatio Map () Ġ{ ĊĠĠĠ Ġratio StringTo Value [" 1 : 1 "] Ġ= Ġ 1 f ĊĊĠĠĠ Ġratio StringTo Value [" 1 6 : 9 "] Ġ= Ġ 1 6 f Ġ/ Ġ 9 f ĊĠĠĠ Ġratio StringTo Value [" 9 : 1 6 "] Ġ= Ġ 9 f Ġ/ Ġ 1 6 f ĊĊĠĠĠ Ġratio StringTo Value [" 1 0 : 8 "] Ġ= Ġ 1 0 f Ġ/ Ġ 8 f ĊĠĠĠ Ġratio StringTo Value [" 8 : 1 0 "] Ġ= Ġ 8 f Ġ/ Ġ 1 0 f ĊĊĠĠĠ Ġratio StringTo Value [" 7 : 5 "] Ġ= Ġ 7 f Ġ/ Ġ 5 f ĊĠĠĠ Ġratio StringTo Value [" 5 : 7 "] Ġ= Ġ 5 f Ġ/ Ġ 7 f ĊĊĠĠĠ Ġratio StringTo Value [" 4 : 3 "] Ġ= Ġ 4 f Ġ/ Ġ 3 f ĊĠĠĠ Ġratio StringTo Value [" 3 : 4 "] Ġ= Ġ 3 f Ġ/ Ġ 4 f ĊĊĠĠĠ Ġratio StringTo Value [" 5 : 3 "] Ġ= Ġ 5 f Ġ/ Ġ 3 f ĊĠĠĠ Ġratio StringTo Value [" 3 : 5 "] Ġ= Ġ 3 f Ġ/ Ġ 5 f ĊĊĠĠĠ Ġratio StringTo Value [" 3 : 2 "] Ġ= Ġ 3 f Ġ/ Ġ 2 f ĊĠĠĠ Ġratio StringTo Value [" 2 : 3 "] Ġ= Ġ 2 f Ġ/ Ġ 3 f ĊĠ Ġ} ĊĊĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠ Ġprivate Ġconst Ġval ĠTAG Ġ= Ġ" Editor ViewModel " ĊĠ Ġ} Ċ }