Browse Source

Don't refresh TabLay0ut onResume if no prefs were actually changd lm0a

Wazakindjes 1 year ago
parent
commit
7f30a9ff50

BIN
app/rem0t0.apk


+ 1 - 1
app/src/app_rem0t0/src/main/AndroidManifest.xml

@@ -2,7 +2,7 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
 	xmlns:tools="http://schemas.android.com/tools"
 	package="com.jemoeder.lief.rem0t0"
-	android:versionName="1.0">
+	android:versionName="1.0.1">
 
 	<!-- Need an internet connection to work 0bv lol -->
 	<uses-permission android:name="android.permission.INTERNET" />

+ 40 - 20
app/src/app_rem0t0/src/main/java/com/jemoeder/lief/rem0t0/MainActivity.java

@@ -66,6 +66,10 @@ public class MainActivity extends AppCompatActivity {
 	private String authkey;
 	private String serbur;
 	private String pot;
+	private boolean lastpref_rem0t0_ledstrip = false;
+	private boolean lastpref_rem0t0_hdmiswitch = false;
+	private boolean lastpref_rem0t0_stereo = false;
+	private boolean lastpref_rem0t0_tv = false;
 
 	// Socket shit fam
 	private boolean coldstart = true;
@@ -261,27 +265,43 @@ public class MainActivity extends AppCompatActivity {
 				connectem();
 		}
 
-		// (Re)build tabbed layout m9
-		int tabnum = 0;
-		tabberin0.removeAllTabs();
-		if(wrapass.muhprefs.getBoolean("prefs_rem0t0_ledstrip", true)) {
-			tabberin0.addTab(tabberin0.newTab().setText(txt_ledstrip));
-			demtabs.put(tabnum++, txt_ledstrip);
-		}
-		if(wrapass.muhprefs.getBoolean("prefs_rem0t0_hdmiswitch", true)) {
-			tabberin0.addTab(tabberin0.newTab().setText(txt_hdmiswitch));
-			demtabs.put(tabnum++, txt_hdmiswitch);
-		}
-		if(wrapass.muhprefs.getBoolean("prefs_rem0t0_stereo", true)) {
-			tabberin0.addTab(tabberin0.newTab().setText(txt_stereo));
-			demtabs.put(tabnum++, txt_stereo);
-		}
-		if(wrapass.muhprefs.getBoolean("prefs_rem0t0_tv", true)) {
-			tabberin0.addTab(tabberin0.newTab().setText(txt_tv));
-			demtabs.put(tabnum++, txt_tv);
+		boolean curpref_rem0t0_ledstrip = wrapass.muhprefs.getBoolean("prefs_rem0t0_ledstrip", true);
+		boolean curpref_rem0t0_hdmiswitch = wrapass.muhprefs.getBoolean("prefs_rem0t0_hdmiswitch", true);
+		boolean curpref_rem0t0_stereo = wrapass.muhprefs.getBoolean("prefs_rem0t0_stereo", true);
+		boolean curpref_rem0t0_tv = wrapass.muhprefs.getBoolean("prefs_rem0t0_tv", true);
+		boolean shitchanged = false;
+		if(lastpref_rem0t0_ledstrip != curpref_rem0t0_ledstrip || lastpref_rem0t0_hdmiswitch != curpref_rem0t0_hdmiswitch ||
+				lastpref_rem0t0_stereo != curpref_rem0t0_stereo || lastpref_rem0t0_tv != curpref_rem0t0_tv)
+			shitchanged = true;
+
+		lastpref_rem0t0_ledstrip = curpref_rem0t0_ledstrip;
+		lastpref_rem0t0_hdmiswitch = curpref_rem0t0_hdmiswitch;
+		lastpref_rem0t0_stereo = curpref_rem0t0_stereo;
+		lastpref_rem0t0_tv = curpref_rem0t0_tv;
+
+		if(shitchanged) {
+			// Full (re)build tabbed layout if needed m9
+			int tabnum = 0;
+			tabberin0.removeAllTabs();
+			if(lastpref_rem0t0_ledstrip) {
+				tabberin0.addTab(tabberin0.newTab().setText(txt_ledstrip));
+				demtabs.put(tabnum++, txt_ledstrip);
+			}
+			if(lastpref_rem0t0_hdmiswitch) {
+				tabberin0.addTab(tabberin0.newTab().setText(txt_hdmiswitch));
+				demtabs.put(tabnum++, txt_hdmiswitch);
+			}
+			if(lastpref_rem0t0_stereo) {
+				tabberin0.addTab(tabberin0.newTab().setText(txt_stereo));
+				demtabs.put(tabnum++, txt_stereo);
+			}
+			if(lastpref_rem0t0_tv) {
+				tabberin0.addTab(tabberin0.newTab().setText(txt_tv));
+				demtabs.put(tabnum++, txt_tv);
+			}
+			final PagerAdapter adapter = new rem0t0PagerAdapter(getSupportFragmentManager(), tabnum);
+			viewPager.setAdapter(adapter);
 		}
-		final PagerAdapter adapter = new rem0t0PagerAdapter(getSupportFragmentManager(), tabnum);
-		viewPager.setAdapter(adapter);
 
 		super.onResume();
 	}

+ 2 - 2
app/src/app_rem0t0/version.properties

@@ -1,2 +1,2 @@
-#Sun Nov 03 19:23:19 CET 2019
-VERSION_CODE=308
+#Thu Nov 14 15:19:02 CET 2019
+VERSION_CODE=310