mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-17 08:35:37 -04:00
Make use of the MCOptionListener
This commit is contained in:
parent
81018bf517
commit
a5d0c89be6
@ -20,7 +20,7 @@ import static net.kdt.pojavlaunch.utils.MCOptionUtils.getMcScale;
|
|||||||
public class MainActivity extends BaseMainActivity {
|
public class MainActivity extends BaseMainActivity {
|
||||||
public static ControlLayout mControlLayout;
|
public static ControlLayout mControlLayout;
|
||||||
|
|
||||||
private FileObserver fileObserver;
|
private MCOptionUtils.MCOptionListener optionListener;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@ -53,26 +53,9 @@ public class MainActivity extends BaseMainActivity {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Recompute the gui scale when options are changed
|
||||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q){
|
optionListener = MCOptionUtils::getMcScale;
|
||||||
fileObserver = new FileObserver(new File(Tools.DIR_GAME_NEW + "/options.txt"), FileObserver.MODIFY) {
|
MCOptionUtils.addMCOptionListener(optionListener);
|
||||||
@Override
|
|
||||||
public void onEvent(int i, @Nullable String s) {
|
|
||||||
MCOptionUtils.load();
|
|
||||||
getMcScale();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}else{
|
|
||||||
fileObserver = new FileObserver(Tools.DIR_GAME_NEW + "/options.txt", FileObserver.MODIFY) {
|
|
||||||
@Override
|
|
||||||
public void onEvent(int i, @Nullable String s) {
|
|
||||||
MCOptionUtils.load();
|
|
||||||
getMcScale();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
fileObserver.startWatching();
|
|
||||||
|
|
||||||
mControlLayout = findViewById(R.id.main_control_layout);
|
mControlLayout = findViewById(R.id.main_control_layout);
|
||||||
mControlLayout.setModifiable(false);
|
mControlLayout.setModifiable(false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user