55import util .Helpers ;
66
77import java .io .File ;
8- import java .io .IOException ;
9- import java .nio .file .Files ;
10- import java .nio .file .Paths ;
118import java .util .*;
129
1310public class AppState {
1411 public static AppState instance = new AppState ();
1512 public File apkFile ;
1613 public File dataZip ;
17- public byte [] rawData ;
18- public TreeMap <String , String > swapOptions = new TreeMap <String , String >();;
14+ public TreeMap <String , String > swapOptions = new TreeMap <>();
1915 public TreeMap <String , String > playlistSwap = new TreeMap <>();
2016 public JadbDevice adbDevice ;
2117 public DropmixSharedAssets assetsHandler ;
@@ -48,7 +44,7 @@ public void setData(byte[] sharedAssets, byte[] level0) {
4844 }
4945
5046 public DropmixSharedAssetsCard [] getCards () {
51- ArrayList <DropmixSharedAssetsCard > cards = new ArrayList <DropmixSharedAssetsCard >();
47+ ArrayList <DropmixSharedAssetsCard > cards = new ArrayList <>();
5248 try {
5349 int seasonIdx = 0 ;
5450 DropmixSharedAssetsSeason season = this .assetsHandler .seasons .get (seasonIdx ++);
@@ -63,7 +59,7 @@ public DropmixSharedAssetsCard[] getCards() {
6359 }
6460 }
6561 public DropmixSharedAssetsPlaylist [] getPlaylists () {
66- Set <String > playlistNames = new HashSet <String >();
62+ Set <String > playlistNames = new HashSet <>();
6763 for (DropmixSharedAssetsCard c : AppState .getInstance ().getCards ()) {
6864 playlistNames .add (c .data .get (DropmixSharedAssetsCard .SeriesIcon ));
6965 }
@@ -77,9 +73,8 @@ public DropmixSharedAssetsPlaylist[] getPlaylists() {
7773 seasons .add (playlist );
7874 }
7975 // this is required to sort the playlists in the common order
80- Collections .sort (seasons , new Comparator <DropmixSharedAssetsPlaylist >(){
81- public int compare (DropmixSharedAssetsPlaylist o1 , DropmixSharedAssetsPlaylist o2 )
82- {
76+ seasons .sort (new Comparator <DropmixSharedAssetsPlaylist >() {
77+ public int compare (DropmixSharedAssetsPlaylist o1 , DropmixSharedAssetsPlaylist o2 ) {
8378 int val = o1 .season .compareTo (o2 .season );
8479 if (val == 0 ) {
8580 // baffler and promo are both empty
@@ -91,6 +86,9 @@ public int compare(DropmixSharedAssetsPlaylist o1, DropmixSharedAssetsPlaylist o
9186 }
9287 int card1 = Integer .parseInt (o1 .cardId );
9388 int card2 = Integer .parseInt (o2 .cardId );
89+ if (card1 == card2 ) {
90+ return 0 ;
91+ }
9492 return card1 > card2 ? 1 : -1 ;
9593 }
9694 return val ;
@@ -117,7 +115,7 @@ public void setPlaylistSwap(String p1, String p2) throws Exception {
117115 throw new Exception ("value-in-use" );
118116 }
119117 for (DropmixSharedAssetsPlaylist pl : this .getPlaylists ()) {
120- if (pl .name == p1 || pl .name == p2 ) {
118+ if (pl .name . equals ( p1 ) || pl .name . equals ( p2 ) ) {
121119 if (pl .playlistCount != 15 ) {
122120 throw new Exception ("invalid-playlist" );
123121 }
@@ -187,13 +185,13 @@ public static TreeMap<String, String> getCardSwapFromPlaylist(TreeMap<String, St
187185 for (String key : plSwap .values ()) {
188186 String value = plSwap .get (key );
189187 String validator = plSwap .get (value );
190- if (value == null || validator == null || !key .equals (validator )) {
188+ if (value == null || !key .equals (validator )) {
191189 throw new RuntimeException ("playlist-swap-sync-issue" );
192190 }
193191 }
194192 String [] playlistNames = plSwap .keySet ().toArray (new String [0 ]);
195193 DropmixSharedAssetsPlaylist [] playlists = getInstance ().getPlaylists ();
196- TreeMap <String , DropmixSharedAssetsPlaylist > dropmixSharedAssetsPlaylistTreeMap = new TreeMap <String , DropmixSharedAssetsPlaylist >();
194+ TreeMap <String , DropmixSharedAssetsPlaylist > dropmixSharedAssetsPlaylistTreeMap = new TreeMap <>();
197195 TreeMap <String , String > generatedCardSwap = new TreeMap <>();
198196 Set <String > alreadySwappedPlaylists = new HashSet <>();
199197 for (DropmixSharedAssetsPlaylist pl : playlists ) {
@@ -213,7 +211,7 @@ public static TreeMap<String, String> getCardSwapFromPlaylist(TreeMap<String, St
213211 generatedCardSwap .put (srcPl .cards [i ], swapPl .cards [i ]);
214212 generatedCardSwap .put (swapPl .cards [i ], srcPl .cards [i ]);
215213 } catch (Exception e ) {
216- continue ;
214+ e . printStackTrace () ;
217215 }
218216 }
219217 if (includeBafflers ) {
0 commit comments