备份,准备回滚为无插件化
This commit is contained in:
parent
58c306dafd
commit
6194d1c46f
Binary file not shown.
@ -25,7 +25,7 @@
|
||||
</value>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
@ -10,6 +10,7 @@ public class HttpApi {
|
||||
// public static final String HOME_URL="http://game.yutou233.cn/android/"; //服务器
|
||||
|
||||
public static final String MOD_ALL="mod/all.do";
|
||||
public static final String MOD_MODS="mod/getMods.do";
|
||||
public static final String MOD_TYPE="mod/getType.do";
|
||||
public static final String MOD_REMOD="mod/remod.do";
|
||||
public static final String MOD_USER_LIST="mod/user.do";
|
||||
|
@ -126,9 +126,9 @@ public class HttpUtils {
|
||||
sum += len;
|
||||
int progress = (int) (sum * 1.0f / total * 100);
|
||||
// 下载中
|
||||
while (!downloadFileInerface.downloading(getNameFromUrl(url),progress,total)){
|
||||
/* while (!downloadFileInerface.downloading(getNameFromUrl(url),progress,total)){
|
||||
Thread.sleep(10);
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
fos.flush();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.yutou.jianrmg_v2.basemodel.Tools;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
@ -78,6 +79,7 @@ public class ActivitysManager {
|
||||
/**
|
||||
* 退出应用程序
|
||||
*/
|
||||
@SuppressLint("MissingPermission")
|
||||
public static void AppExit(Context context) {
|
||||
try {
|
||||
finishAllActivity();
|
||||
|
@ -14,6 +14,7 @@ import android.widget.Toast;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.kaopiz.kprogresshud.KProgressHUD;
|
||||
import com.yutou.jianrmg_v2.basemodel.Application;
|
||||
import com.yutou.jianrmg_v2.basemodel.Data.AppData;
|
||||
import com.yutou.jianrmg_v2.basemodel.Data.MGamePackname;
|
||||
import com.yutou.jianrmg_v2.basemodel.Data.TMod;
|
||||
@ -46,6 +47,7 @@ public class ModUtils {
|
||||
private List<TModfile> modfiles;
|
||||
private KProgressHUD hud;
|
||||
private TMod mod;
|
||||
|
||||
public static ModUtils init(Context context) {
|
||||
if (modUtils == null) {
|
||||
modUtils = new ModUtils();
|
||||
@ -53,31 +55,37 @@ public class ModUtils {
|
||||
modUtils.setContext(context);
|
||||
return modUtils;
|
||||
}
|
||||
|
||||
private void setContext(Context context) {
|
||||
this.context = context;
|
||||
hud = Utils.showLoading(context, "安装中", "请稍后");
|
||||
}
|
||||
|
||||
private ModUtils() {
|
||||
handler = new Handler();
|
||||
}
|
||||
|
||||
public void setMod(TMod mod) {
|
||||
this.mod = mod;
|
||||
getModDownloadInfo();
|
||||
}
|
||||
|
||||
public List<TModfile> getModfiles() {
|
||||
return modfiles;
|
||||
}
|
||||
|
||||
public void installMod(TMod mod) {
|
||||
this.mod = mod;
|
||||
install();
|
||||
}
|
||||
|
||||
private void install() {
|
||||
if (modfiles == null) {
|
||||
Toast.makeText(context, "正在加载数据,请稍后再试", Toast.LENGTH_LONG).show();
|
||||
getModDownloadInfo();
|
||||
return;
|
||||
}
|
||||
Log.i("安装mod",changeMod(mod,modfiles)+"");
|
||||
Log.i("安装mod", (!isInstallMod(mod)) + " " + changeMod(mod, modfiles) + "");
|
||||
if (!isInstallMod(mod) && changeMod(mod, modfiles)) {
|
||||
install(mod);
|
||||
} else {
|
||||
@ -104,6 +112,7 @@ public class ModUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void install(final TMod mod) {
|
||||
List<String> clientList = new ArrayList<>();
|
||||
for (MGamePackname packname : AppData.packnames) {
|
||||
@ -147,9 +156,11 @@ public class ModUtils {
|
||||
dialog.show();
|
||||
|
||||
}
|
||||
|
||||
private void notRootInstall(File src, String path) {
|
||||
|
||||
}
|
||||
|
||||
private void rootInstall(File src, String path) {
|
||||
RootUtils root = RootUtils.init(context);
|
||||
if (RootUtils.su()) {
|
||||
@ -174,6 +185,7 @@ public class ModUtils {
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
|
||||
public void reBackMod(TMod tMod) {
|
||||
final MaterialDialog dialog = new MaterialDialog(context);
|
||||
dialog.setTitle("将还原 " + tMod.getTitle());
|
||||
@ -198,12 +210,14 @@ public class ModUtils {
|
||||
dialog.setNegativeButton("放弃", new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
dialog.dismiss();;
|
||||
dialog.dismiss();
|
||||
;
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
|
||||
}
|
||||
|
||||
private void backupOrRoot(File srcFile, String srcPath, String backupClient, TMod mod) {
|
||||
RootUtils root = RootUtils.init(context);
|
||||
if (RootUtils.su()) {
|
||||
@ -221,6 +235,7 @@ public class ModUtils {
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
private void downloadMod() {
|
||||
Toast.makeText(context, "开始下载", Toast.LENGTH_LONG).show();
|
||||
Intent intent = new Intent(context.getApplicationContext(), DownloadService.class);
|
||||
@ -252,12 +267,12 @@ public class ModUtils {
|
||||
|
||||
@Override
|
||||
public void over() {
|
||||
|
||||
Utils.toast(context, "下载完成");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
|
||||
Utils.toast(context, "开始下载");
|
||||
}
|
||||
});
|
||||
service.start(modfiles);
|
||||
@ -271,6 +286,7 @@ public class ModUtils {
|
||||
}, Context.BIND_AUTO_CREATE);
|
||||
Log.i("绑定下载:", isBindService + "");
|
||||
}
|
||||
|
||||
private void getModDownloadInfo() {
|
||||
modfiles = null;
|
||||
try {
|
||||
@ -303,6 +319,7 @@ public class ModUtils {
|
||||
public static String getModInstallPath(TMod mod) {
|
||||
return Utils.getSDCardPath() + "/" + mod.getId() + "/";
|
||||
}
|
||||
|
||||
public static boolean isInstallMod(TMod mod) {
|
||||
File modPath = new File(Utils.getSDCardPath() + "/" + mod.getId() + "/");
|
||||
for (int i = 0; i < modPath.listFiles().length; i++) {
|
||||
@ -314,19 +331,24 @@ public class ModUtils {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean changeMod(TMod mod, List<TModfile> modfiles) {
|
||||
File modPath = new File(Utils.getSDCardPath() + "/" + mod.getId() + "/");
|
||||
Log.i("检测mod是否完整", "位置:" + Utils.getSDCardPath() + "/" + mod.getId() + "/" + " exists:" + modPath.exists());
|
||||
for (TModfile modfile : modfiles) {
|
||||
if (new File(Utils.getSDCardPath() + "/" + mod.getId() + "/" + modfile.getFilename()).isFile())
|
||||
if (!new File(Utils.getSDCardPath() + "/" + mod.getId() + "/" + modfile.getFilename()).exists()) {
|
||||
Log.i("不完整的", "位置:" + Utils.getSDCardPath() + "/" + mod.getId() + "/" + " exists:" + modPath.exists());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static File getModPath(TMod mod) {
|
||||
return getModPath(mod, "");
|
||||
}
|
||||
|
||||
public static File getModPath(TMod mod, String name) {
|
||||
File path = new File(Utils.getSDCardPath() + "/" + mod.getId() + "/" + name);
|
||||
if (!path.exists()) {
|
||||
|
@ -68,6 +68,7 @@ public class DownloadService extends Service {
|
||||
puase=false;
|
||||
list.addAll(addList);
|
||||
downloadInterface.start();
|
||||
startNotification();
|
||||
download= new Download(this);
|
||||
|
||||
}
|
||||
@ -126,7 +127,6 @@ public class DownloadService extends Service {
|
||||
if(!download.isAlive||!download.isAlive()||!download.isInterrupted())
|
||||
{
|
||||
this.service=service;
|
||||
service.startNotification();
|
||||
start();
|
||||
}
|
||||
}
|
||||
|
@ -2,5 +2,8 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ListView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/listView"></ListView>
|
||||
</LinearLayout>
|
32
ResModl/src/main/res/layout/item_download.xml
Normal file
32
ResModl/src/main/res/layout/item_download.xml
Normal file
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/white"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/image"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_margin="20dp" />
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_margin="20dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="标题"
|
||||
android:textSize="18sp"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
@ -1,14 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="70dp"
|
||||
android:layout_marginTop="10dp">
|
||||
android:layout_height="80dp"
|
||||
android:layout_marginTop="20dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/download"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="@color/white"
|
||||
android:orientation="horizontal">
|
||||
|
||||
|
@ -0,0 +1,54 @@
|
||||
package com.jianrmg_v2.usermodel.Adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DownloadItemAdapter extends BaseAdapter {
|
||||
private Context context;
|
||||
private List<?> list;
|
||||
|
||||
public DownloadItemAdapter(Context context, List<?> list) {
|
||||
this.context = context;
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int i) {
|
||||
return list.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
Items items;
|
||||
if(view==null){
|
||||
view= LayoutInflater.from(context).inflate(com.yutou.jianrmg_v2.resmodl.R.layout.item_download,null);
|
||||
items=new Items();
|
||||
|
||||
view.setTag(items);
|
||||
}else{
|
||||
items= (Items) view.getTag();
|
||||
}
|
||||
return view;
|
||||
}
|
||||
private class Items{
|
||||
ImageView icon;
|
||||
TextView title;
|
||||
}
|
||||
}
|
@ -4,20 +4,80 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.yutou.jianrmg_v2.basemodel.Interfaces.HttpInterface;
|
||||
import com.yutou.jianrmg_v2.basemodel.Network.HttpApi;
|
||||
import com.yutou.jianrmg_v2.basemodel.Network.HttpUtils;
|
||||
import com.yutou.jianrmg_v2.basemodel.Tools.Utils;
|
||||
import com.yutou.jianrmg_v2.resmodl.R;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import Interfaces.BaseActivityInterface;
|
||||
|
||||
public class DownloadListActivity implements BaseActivityInterface ,Serializable {
|
||||
private Context context;
|
||||
private LinearLayout layout;
|
||||
private View view;
|
||||
private ListView listView;
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState, LinearLayout layout, Context context, Intent intent) {
|
||||
this.context=context;
|
||||
this.layout=layout;
|
||||
this.view= LayoutInflater.from(context).inflate(R.layout.activity_download_list,null);
|
||||
getDownloadFileList();
|
||||
initViews();
|
||||
layout.addView(view);
|
||||
}
|
||||
private void getDownloadFileList(){
|
||||
JSONObject json=new JSONObject();
|
||||
File rootPath=new File(Utils.getSDCardPath());
|
||||
try{
|
||||
JSONArray array=new JSONArray();
|
||||
for (File path : rootPath.listFiles()) {
|
||||
if (path.isDirectory()){
|
||||
try {
|
||||
array.put(Integer.valueOf(path.getName())+"");
|
||||
}catch (Exception e){}
|
||||
}
|
||||
}
|
||||
json.put("ids",array);
|
||||
HttpUtils.post(HttpApi.HOME_URL + HttpApi.MOD_MODS, json, new HttpInterface() {
|
||||
@Override
|
||||
public void httpGetData(String string, int code) {
|
||||
try {
|
||||
JSONObject json=new JSONObject(string);
|
||||
if(json.getInt("code")!=100){
|
||||
return;
|
||||
}
|
||||
JSONArray dataList=json.getJSONArray("data");
|
||||
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void httpError(Exception e) {
|
||||
|
||||
}
|
||||
});
|
||||
}catch (Exception e){}
|
||||
return;
|
||||
}
|
||||
private void initViews(){
|
||||
listView=view.findViewById(R.id.listView);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -7,7 +7,7 @@ buildscript {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.1.1'
|
||||
classpath 'com.android.tools.build:gradle:3.1.2'
|
||||
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
|
||||
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user