commit
This commit is contained in:
parent
6ffb7f87d6
commit
6011cc77f2
@ -44,6 +44,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
ArrayAdapter<String> starAdapter;
|
||||
|
||||
Spinner sp;
|
||||
|
||||
MyHandler handler = new MyHandler(this);
|
||||
|
||||
private static final String TAG = "run.evan.gost";
|
||||
@ -96,7 +98,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
appPreferences = getSharedPreferences("app", MODE_PRIVATE);
|
||||
|
||||
|
||||
Spinner sp = findViewById(R.id.spinner);
|
||||
sp = findViewById(R.id.spinner);
|
||||
starAdapter = new ArrayAdapter<String>(this, R.layout.item_select);
|
||||
starAdapter.setDropDownViewResource(R.layout.item_dropdown);
|
||||
sp.setAdapter(starAdapter);
|
||||
@ -202,6 +204,12 @@ public class MainActivity extends AppCompatActivity {
|
||||
String basedir = getApplication().getApplicationInfo().nativeLibraryDir;
|
||||
String config = configEditText.getText().toString();
|
||||
|
||||
if (null != sp.getSelectedItem()) {
|
||||
String key = sp.getSelectedItem().toString();
|
||||
appPreferences.edit().putString("lastConfig", key).apply();
|
||||
}
|
||||
|
||||
|
||||
if (process == null) {
|
||||
if ("".contains(config)) {
|
||||
Toast.makeText(getApplicationContext(), R.string.toast_tip_config_empty, Toast.LENGTH_LONG).show();
|
||||
@ -285,8 +293,19 @@ public class MainActivity extends AppCompatActivity {
|
||||
private void reloadConfig() {
|
||||
starAdapter.clear();
|
||||
Map<String, ?> all = configPreferences.getAll();
|
||||
String lastConfig = appPreferences.getString("lastConfig", "");
|
||||
int count = 0;
|
||||
boolean lastValid = false;
|
||||
for (String s : all.keySet()) {
|
||||
starAdapter.add(s);
|
||||
if (s.equals(lastConfig)) {
|
||||
sp.setSelection(count);
|
||||
lastValid = true;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
if (!lastValid) {
|
||||
appPreferences.edit().putString("lastConfig", "").apply();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
android:id="@+id/textTipConfig"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="18sp"
|
||||
android:text="@string/text_tip_config" />
|
||||
|
||||
<Spinner
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="45dp"
|
||||
android:layout_height="40dp"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="14sp"
|
||||
android:textSize="18sp"
|
||||
android:gravity="center"/>
|
@ -1,4 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
android:layout_height="match_parent"
|
||||
android:textSize="18sp"
|
||||
/>
|
Loading…
Reference in New Issue
Block a user