Code clean up
This commit is contained in:
parent
cdae2ebde1
commit
ef0639797e
|
@ -36,7 +36,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
@BindView(R.id.nav_view)
|
||||
NavigationView navigationView;
|
||||
|
||||
public void requestPermissions()
|
||||
private void requestPermissions()
|
||||
{
|
||||
if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.zane.smapiinstaller.constant;
|
||||
|
||||
public class Constants {
|
||||
public static String MOD_PATH = "StardewValley/Mods";
|
||||
public static String LOG_PATH = "StardewValley/ErrorLogs/SMAPI-latest.txt";
|
||||
public static final String MOD_PATH = "StardewValley/Mods";
|
||||
public static final String LOG_PATH = "StardewValley/ErrorLogs/SMAPI-latest.txt";
|
||||
|
||||
public static String TARGET_PACKAGE_NAME = "com.zane.stardewvalley";
|
||||
public static final String TARGET_PACKAGE_NAME = "com.zane.stardewvalley";
|
||||
}
|
||||
|
|
|
@ -44,9 +44,9 @@ public class ApkPatcher {
|
|||
|
||||
private static final String PASSWORD = "android";
|
||||
|
||||
private Context context;
|
||||
private final Context context;
|
||||
|
||||
private static String TAG = "PATCHER";
|
||||
private static final String TAG = "PATCHER";
|
||||
|
||||
public ApkPatcher(Context context) {
|
||||
this.context = context;
|
||||
|
|
|
@ -10,11 +10,9 @@ import android.util.Log;
|
|||
import android.view.View;
|
||||
|
||||
import com.afollestad.materialdialogs.MaterialDialog;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.io.CharStreams;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.zane.smapiinstaller.R;
|
||||
|
@ -24,7 +22,6 @@ import org.zeroturnaround.zip.ZipUtil;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -109,26 +106,20 @@ public class CommonLogic {
|
|||
public static void showAlertDialog(View view, int title, String message) {
|
||||
Activity activity = getActivityFromView(view);
|
||||
if(activity != null && !activity.isFinishing()) {
|
||||
activity.runOnUiThread(()->{
|
||||
new MaterialDialog.Builder(activity).title(title).content(message).positiveText(R.string.ok).show();
|
||||
});
|
||||
activity.runOnUiThread(()-> new MaterialDialog.Builder(activity).title(title).content(message).positiveText(R.string.ok).show());
|
||||
}
|
||||
}
|
||||
public static void showAlertDialog(View view, int title, int message) {
|
||||
Activity activity = getActivityFromView(view);
|
||||
if(activity != null && !activity.isFinishing()) {
|
||||
activity.runOnUiThread(()->{
|
||||
new MaterialDialog.Builder(activity).title(title).content(message).positiveText(R.string.ok).show();
|
||||
});
|
||||
activity.runOnUiThread(()-> new MaterialDialog.Builder(activity).title(title).content(message).positiveText(R.string.ok).show());
|
||||
}
|
||||
}
|
||||
|
||||
public static void showConfirmDialog(View view, int title, int message, MaterialDialog.SingleButtonCallback callback) {
|
||||
Activity activity = getActivityFromView(view);
|
||||
if(activity != null && !activity.isFinishing()) {
|
||||
activity.runOnUiThread(()->{
|
||||
new MaterialDialog.Builder(activity).title(title).content(message).positiveText(R.string.confirm).negativeText(R.string.cancel).onAny(callback).show();
|
||||
});
|
||||
activity.runOnUiThread(()-> new MaterialDialog.Builder(activity).title(title).content(message).positiveText(R.string.confirm).negativeText(R.string.cancel).onAny(callback).show());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import com.zane.smapiinstaller.constant.Constants;
|
|||
|
||||
public class GameLauncher {
|
||||
|
||||
private View root;
|
||||
private final View root;
|
||||
|
||||
public GameLauncher(View root) {
|
||||
this.root = root;
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package com.zane.smapiinstaller.logic;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import pxb.android.axml.NodeVisitor;
|
||||
|
||||
public class ManifestTagVisitor extends NodeVisitor {
|
||||
class ManifestTagVisitor extends NodeVisitor {
|
||||
|
||||
private Predicate<AttrArgs> attrProcessLogic;
|
||||
private final Predicate<AttrArgs> attrProcessLogic;
|
||||
|
||||
public ManifestTagVisitor(NodeVisitor nv, Predicate<AttrArgs> attrProcessLogic) {
|
||||
super(nv);
|
||||
|
@ -33,7 +32,7 @@ public class ManifestTagVisitor extends NodeVisitor {
|
|||
int type;
|
||||
Object obj;
|
||||
|
||||
public AttrArgs(String ns, String name, int resourceId, int type, Object obj) {
|
||||
AttrArgs(String ns, String name, int resourceId, int type, Object obj) {
|
||||
this.ns = ns;
|
||||
this.name = name;
|
||||
this.resourceId = resourceId;
|
||||
|
|
|
@ -26,9 +26,9 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
|||
|
||||
public class ModAssetsManager {
|
||||
|
||||
private View root;
|
||||
private final View root;
|
||||
|
||||
private static String TAG = "MANAGER";
|
||||
private static final String TAG = "MANAGER";
|
||||
|
||||
public ModAssetsManager(View root) {
|
||||
this.root = root;
|
||||
|
|
|
@ -4,11 +4,9 @@ import android.os.Bundle;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
@ -16,10 +14,6 @@ import butterknife.BindView;
|
|||
import butterknife.ButterKnife;
|
||||
|
||||
import com.zane.smapiinstaller.R;
|
||||
import com.zane.smapiinstaller.entity.ModManifestEntry;
|
||||
import com.zane.smapiinstaller.logic.ModAssetsManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ConfigFragment extends Fragment {
|
||||
|
||||
|
|
|
@ -1,20 +1,17 @@
|
|||
package com.zane.smapiinstaller.ui.config;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
|
||||
import com.zane.smapiinstaller.entity.ModManifestEntry;
|
||||
import com.zane.smapiinstaller.logic.ModAssetsManager;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
public class ConfigViewModel extends ViewModel {
|
||||
class ConfigViewModel extends ViewModel {
|
||||
|
||||
private MutableLiveData<List<ModManifestEntry>> modList;
|
||||
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package com.zane.smapiinstaller.ui.config;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.afollestad.materialdialogs.DialogAction;
|
||||
import com.zane.smapiinstaller.R;
|
||||
import com.zane.smapiinstaller.entity.ModManifestEntry;
|
||||
import com.zane.smapiinstaller.logic.CommonLogic;
|
||||
|
@ -51,7 +50,7 @@ public class ModManifestAdapter extends RecyclerView.Adapter<ModManifestAdapter.
|
|||
|
||||
static class ViewHolder extends RecyclerView.ViewHolder{
|
||||
private String modPath;
|
||||
public void setModPath(String modPath) {
|
||||
void setModPath(String modPath) {
|
||||
this.modPath = modPath;
|
||||
File file = new File(modPath, "config.json");
|
||||
if(!file.exists()) {
|
||||
|
@ -73,13 +72,11 @@ public class ModManifestAdapter extends RecyclerView.Adapter<ModManifestAdapter.
|
|||
}
|
||||
@OnClick(R.id.button_remove_mod) void removeMod() {
|
||||
CommonLogic.showConfirmDialog(itemView, R.string.confirm, R.string.confirm_delete_mod, (dialog, which)->{
|
||||
switch (which){
|
||||
case POSITIVE:
|
||||
if (which == DialogAction.POSITIVE) {
|
||||
File file = new File(modPath);
|
||||
if(file.exists()) {
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -5,20 +5,18 @@ import android.os.Environment;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.navigation.NavController;
|
||||
import androidx.navigation.Navigation;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
|
||||
import com.afollestad.materialdialogs.DialogAction;
|
||||
import com.zane.smapiinstaller.R;
|
||||
import com.zane.smapiinstaller.constant.Constants;
|
||||
import com.zane.smapiinstaller.logic.CommonLogic;
|
||||
import com.zane.smapiinstaller.ui.config.ConfigFragmentDirections;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
@ -38,12 +36,10 @@ public class HelpFragment extends Fragment {
|
|||
}
|
||||
@OnClick(R.id.button_release) void release() {
|
||||
CommonLogic.showConfirmDialog(this.getView(), R.string.confirm, R.string.test_message, (dialog, which)-> {
|
||||
switch (which) {
|
||||
case POSITIVE:
|
||||
if(this.getString(R.string.test_message).contains("860453392")) {
|
||||
if (which == DialogAction.POSITIVE) {
|
||||
if (this.getString(R.string.test_message).contains("860453392")) {
|
||||
CommonLogic.openUrl(this.getContext(), "mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D" + "AAflCLHiWw1haM1obu_f-CpGsETxXc6b");
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import androidx.lifecycle.LiveData;
|
|||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
public class HelpViewModel extends ViewModel {
|
||||
class HelpViewModel extends ViewModel {
|
||||
|
||||
private MutableLiveData<String> mText;
|
||||
|
||||
|
|
Loading…
Reference in New Issue