This commit is contained in:
ShirosakiMio 2024-09-09 13:56:14 +08:00
parent 80cff6c269
commit 988b177011
5 changed files with 35 additions and 31 deletions

View File

@ -16,7 +16,6 @@ import androidx.core.view.forEach
import androidx.databinding.DataBindingUtil import androidx.databinding.DataBindingUtil
import com.mio.util.AnimUtil import com.mio.util.AnimUtil
import com.mio.util.AnimUtil.Companion.interpolator import com.mio.util.AnimUtil.Companion.interpolator
import com.mio.util.AnimUtil.Companion.startAfter
import com.tungsten.fcl.R import com.tungsten.fcl.R
import com.tungsten.fcl.databinding.ActivityMainBinding import com.tungsten.fcl.databinding.ActivityMainBinding
import com.tungsten.fcl.game.JarExecutorHelper import com.tungsten.fcl.game.JarExecutorHelper
@ -265,7 +264,7 @@ class MainActivity : FCLActivity(), OnSelectListener, View.OnClickListener {
} }
manage -> { manage -> {
val version = Profiles.getSelectedVersion() val version = Profiles.getSelectedProfile().selectedVersion
if (version == null) { if (version == null) {
refreshMenuView(null) refreshMenuView(null)
title.setTextWithAnim(getString(R.string.version)) title.setTextWithAnim(getString(R.string.version))
@ -472,13 +471,13 @@ class MainActivity : FCLActivity(), OnSelectListener, View.OnClickListener {
bind.apply { bind.apply {
AnimUtil.playTranslationX( AnimUtil.playTranslationX(
leftMenu, leftMenu,
ThemeEngine.getInstance().getTheme().animationSpeed * 30L, ThemeEngine.getInstance().getTheme().animationSpeed * 200L,
-100f, -100f,
0f 0f
).interpolator(BounceInterpolator()).start() ).interpolator(BounceInterpolator()).start()
AnimUtil.playTranslationX( AnimUtil.playTranslationX(
rightMenu, rightMenu,
ThemeEngine.getInstance().getTheme().animationSpeed * 30L, ThemeEngine.getInstance().getTheme().animationSpeed * 200L,
100f, 100f,
0f 0f
).interpolator(BounceInterpolator()).start() ).interpolator(BounceInterpolator()).start()

View File

@ -102,8 +102,9 @@ public class Controllers {
initialized = true; initialized = true;
CALLBACKS.forEach(callback -> { CALLBACKS.forEach(callback -> {
Schedulers.androidUIThread().execute(callback::run); Schedulers.androidUIThread().execute(callback);
}); });
CALLBACKS.clear();
} }
private static ArrayList<Controller> getControllersFromDisk() { private static ArrayList<Controller> getControllersFromDisk() {

View File

@ -359,14 +359,15 @@ public final class VersionSetting implements Cloneable {
} }
public void checkController() { public void checkController() {
Controllers.addCallback(() -> {
Controllers.checkControllers(); Controllers.checkControllers();
Controller controller = Controllers.getControllers().stream() Controller controller = Controllers.getControllers().stream()
.filter(it -> it.getName().equals(getController())) .filter(it -> it.getName().equals(getController()))
.findFirst() .findFirst()
.orElse(Controllers.getControllers().get(0)); .orElse(Controllers.getControllers().get(0));
setController(controller.getName()); setController(controller.getName());
});
} }
public void addPropertyChangedListener(InvalidationListener listener) { public void addPropertyChangedListener(InvalidationListener listener) {

View File

@ -47,14 +47,14 @@ public class ManageUI extends FCLMultiPageUI implements TabLayout.OnTabSelectedL
container = findViewById(R.id.container); container = findViewById(R.id.container);
tabLayout.addOnTabSelectedListener(this); tabLayout.addOnTabSelectedListener(this);
container.post(this::initPages); initPages();
listenerHolder.add(EventBus.EVENT_BUS.channel(RefreshedVersionsEvent.class).registerWeak(event -> checkSelectedVersion(), EventPriority.HIGHEST)); listenerHolder.add(EventBus.EVENT_BUS.channel(RefreshedVersionsEvent.class).registerWeak(event -> checkSelectedVersion(), EventPriority.HIGHEST));
} }
@Override @Override
public void onStart() { public void onStart() {
super.onStart(); super.onStart();
addLoadingCallback(()->{
// If we jumped to game list page and deleted this version // If we jumped to game list page and deleted this version
// and back to this page, we should return to main page. // and back to this page, we should return to main page.
if (!getProfile().getRepository().isLoaded() || if (!getProfile().getRepository().isLoaded() ||
@ -67,11 +67,8 @@ public class ManageUI extends FCLMultiPageUI implements TabLayout.OnTabSelectedL
}); });
return; return;
} }
if (pageManager == null) {
pageManager = new ManagePageManager(getContext(), container, ManagePageManager.PAGE_ID_MANAGE_MANAGE, null);
}
loadVersion(getVersion(), getProfile()); loadVersion(getVersion(), getProfile());
});
} }
@Override @Override

View File

@ -17,11 +17,14 @@ public abstract class FCLCommonUI extends FCLBaseUI {
private UILoadingCallback callback; private UILoadingCallback callback;
private boolean init = false;
public FCLCommonUI(Context context, FCLUILayout parent, @LayoutRes int id) { public FCLCommonUI(Context context, FCLUILayout parent, @LayoutRes int id) {
super(context); super(context);
this.parent = parent; this.parent = parent;
setContentView(id, () -> { setContentView(id, () -> {
onCreate(); onCreate();
init = true;
if (callback != null) { if (callback != null) {
callback.onLoad(); callback.onLoad();
} }
@ -78,5 +81,8 @@ public abstract class FCLCommonUI extends FCLBaseUI {
public void addLoadingCallback(UILoadingCallback callback) { public void addLoadingCallback(UILoadingCallback callback) {
this.callback = callback; this.callback = callback;
if (init) {
callback.onLoad();
}
} }
} }