-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
RiivolutionBootActivity.java
97 lines (76 loc) · 3.04 KB
/
RiivolutionBootActivity.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// SPDX-License-Identifier: GPL-2.0-or-later
package org.dolphinemu.dolphinemu.features.riivolution.ui;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.activities.EmulationActivity;
import org.dolphinemu.dolphinemu.features.riivolution.model.RiivolutionPatches;
import org.dolphinemu.dolphinemu.features.settings.model.StringSetting;
import org.dolphinemu.dolphinemu.utils.DirectoryInitialization;
public class RiivolutionBootActivity extends AppCompatActivity
{
private static final String ARG_GAME_PATH = "game_path";
private static final String ARG_GAME_ID = "game_id";
private static final String ARG_REVISION = "revision";
private static final String ARG_DISC_NUMBER = "disc_number";
private RiivolutionPatches mPatches;
public static void launch(Context context, String gamePath, String gameId, int revision,
int discNumber)
{
Intent launcher = new Intent(context, RiivolutionBootActivity.class);
launcher.putExtra(ARG_GAME_PATH, gamePath);
launcher.putExtra(ARG_GAME_ID, gameId);
launcher.putExtra(ARG_REVISION, revision);
launcher.putExtra(ARG_DISC_NUMBER, discNumber);
context.startActivity(launcher);
}
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_riivolution_boot);
Intent intent = getIntent();
String path = getIntent().getStringExtra(ARG_GAME_PATH);
String gameId = intent.getStringExtra(ARG_GAME_ID);
int revision = intent.getIntExtra(ARG_REVISION, -1);
int discNumber = intent.getIntExtra(ARG_DISC_NUMBER, -1);
String loadPath = StringSetting.MAIN_LOAD_PATH.getStringGlobal();
if (loadPath.isEmpty())
loadPath = DirectoryInitialization.getUserDirectory() + "/Load";
TextView textSdRoot = findViewById(R.id.text_sd_root);
textSdRoot.setText(getString(R.string.riivolution_sd_root, loadPath + "/Riivolution"));
Button buttonStart = findViewById(R.id.button_start);
buttonStart.setOnClickListener((v) ->
{
if (mPatches != null)
mPatches.saveConfig();
EmulationActivity.launch(this, path, true);
});
new Thread(() ->
{
RiivolutionPatches patches = new RiivolutionPatches(gameId, revision, discNumber);
patches.loadConfig();
runOnUiThread(() -> populateList(patches));
}).start();
}
@Override
protected void onStop()
{
super.onStop();
if (mPatches != null)
mPatches.saveConfig();
}
private void populateList(RiivolutionPatches patches)
{
mPatches = patches;
RecyclerView recyclerView = findViewById(R.id.recycler_view);
recyclerView.setAdapter(new RiivolutionAdapter(this, patches));
recyclerView.setLayoutManager(new LinearLayoutManager(this));
}
}