mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 08:09:26 +01:00
Android: Run installWAD on separate thread
This commit is contained in:
parent
2d6d0c86cc
commit
c5c080b235
@ -511,7 +511,7 @@ public final class NativeLibrary
|
||||
}
|
||||
|
||||
// Show the AlertDialog on the main thread.
|
||||
emulationActivity.runOnUiThread(() -> builder.show());
|
||||
emulationActivity.runOnUiThread(builder::show);
|
||||
|
||||
// Wait for the lock to notify that it is complete.
|
||||
synchronized (lock)
|
||||
|
@ -262,7 +262,6 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
|
||||
}
|
||||
|
||||
private final String[] mGamePaths;
|
||||
private Thread mEmulationThread;
|
||||
private State state;
|
||||
private Surface mSurface;
|
||||
private boolean mRunWhenSurfaceIsValid;
|
||||
@ -399,7 +398,7 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
|
||||
mRunWhenSurfaceIsValid = false;
|
||||
if (state == State.STOPPED)
|
||||
{
|
||||
mEmulationThread = new Thread(() ->
|
||||
Thread emulationThread = new Thread(() ->
|
||||
{
|
||||
NativeLibrary.SurfaceChanged(mSurface);
|
||||
if (loadPreviousTemporaryState)
|
||||
@ -413,8 +412,7 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
|
||||
NativeLibrary.Run(mGamePaths);
|
||||
}
|
||||
}, "NativeEmulation");
|
||||
mEmulationThread.start();
|
||||
|
||||
emulationThread.start();
|
||||
}
|
||||
else if (state == State.PAUSED)
|
||||
{
|
||||
|
@ -1,11 +1,13 @@
|
||||
package org.dolphinemu.dolphinemu.ui.main;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import org.dolphinemu.dolphinemu.BuildConfig;
|
||||
@ -121,13 +123,30 @@ public final class MainPresenter
|
||||
|
||||
public void installWAD(String file)
|
||||
{
|
||||
if (NativeLibrary.InstallWAD(file))
|
||||
final Activity mainPresenterActivity = (Activity) mContext;
|
||||
|
||||
AlertDialog dialog = new AlertDialog.Builder(mContext, R.style.DolphinDialogBase).create();
|
||||
dialog.setTitle("Installing WAD");
|
||||
dialog.setMessage("Installing...");
|
||||
dialog.setCancelable(false);
|
||||
dialog.show();
|
||||
|
||||
Thread installWADThread = new Thread(() ->
|
||||
{
|
||||
Toast.makeText(mContext, R.string.wad_install_success, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else
|
||||
{
|
||||
Toast.makeText(mContext, R.string.wad_install_failure, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
if (NativeLibrary.InstallWAD(file))
|
||||
{
|
||||
mainPresenterActivity.runOnUiThread(
|
||||
() -> Toast.makeText(mContext, R.string.wad_install_success, Toast.LENGTH_SHORT)
|
||||
.show());
|
||||
}
|
||||
else
|
||||
{
|
||||
mainPresenterActivity.runOnUiThread(
|
||||
() -> Toast.makeText(mContext, R.string.wad_install_failure, Toast.LENGTH_SHORT)
|
||||
.show());
|
||||
}
|
||||
mainPresenterActivity.runOnUiThread(dialog::dismiss);
|
||||
}, "InstallWAD");
|
||||
installWADThread.start();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user