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

View File

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

View File

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

View File

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

View File

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