备份,准备回滚为无插件化

This commit is contained in:
Yutousama 2018-05-07 15:22:02 +08:00
parent 58c306dafd
commit 6194d1c46f
13 changed files with 331 additions and 156 deletions

View File

@ -25,7 +25,7 @@
</value> </value>
</option> </option>
</component> </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" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

View File

@ -5,11 +5,12 @@ package com.yutou.jianrmg_v2.basemodel.Network;
*/ */
public class HttpApi { public class HttpApi {
// public static final String HOME_URL="http://192.168.31.240:8088/android/"; //zzz_gz wifi // public static final String HOME_URL="http://192.168.31.240:8088/android/"; //zzz_gz wifi
public static final String HOME_URL="http://192.168.137.1:8088/android/"; //笔记本本身WIFI public static final String HOME_URL="http://192.168.137.1:8088/android/"; //笔记本本身WIFI
// public static final String HOME_URL="http://game.yutou233.cn/android/"; //服务器 // 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_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_TYPE="mod/getType.do";
public static final String MOD_REMOD="mod/remod.do"; public static final String MOD_REMOD="mod/remod.do";
public static final String MOD_USER_LIST="mod/user.do"; public static final String MOD_USER_LIST="mod/user.do";

View File

@ -126,9 +126,9 @@ public class HttpUtils {
sum += len; sum += len;
int progress = (int) (sum * 1.0f / total * 100); 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); Thread.sleep(10);
} }*/
} }
fos.flush(); fos.flush();

View File

@ -1,5 +1,6 @@
package com.yutou.jianrmg_v2.basemodel.Tools; package com.yutou.jianrmg_v2.basemodel.Tools;
import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.content.Context; import android.content.Context;
@ -78,6 +79,7 @@ public class ActivitysManager {
/** /**
* 退出应用程序 * 退出应用程序
*/ */
@SuppressLint("MissingPermission")
public static void AppExit(Context context) { public static void AppExit(Context context) {
try { try {
finishAllActivity(); finishAllActivity();

View File

@ -14,6 +14,7 @@ import android.widget.Toast;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.kaopiz.kprogresshud.KProgressHUD; 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.AppData;
import com.yutou.jianrmg_v2.basemodel.Data.MGamePackname; import com.yutou.jianrmg_v2.basemodel.Data.MGamePackname;
import com.yutou.jianrmg_v2.basemodel.Data.TMod; import com.yutou.jianrmg_v2.basemodel.Data.TMod;
@ -46,43 +47,50 @@ public class ModUtils {
private List<TModfile> modfiles; private List<TModfile> modfiles;
private KProgressHUD hud; private KProgressHUD hud;
private TMod mod; private TMod mod;
public static ModUtils init(Context context){
if(modUtils==null){ public static ModUtils init(Context context) {
modUtils=new ModUtils(); if (modUtils == null) {
modUtils = new ModUtils();
} }
modUtils.setContext(context); modUtils.setContext(context);
return modUtils; return modUtils;
} }
private void setContext(Context context){
this.context=context; private void setContext(Context context) {
hud=Utils.showLoading(context,"安装中","请稍后"); this.context = context;
hud = Utils.showLoading(context, "安装中", "请稍后");
} }
private ModUtils(){
handler=new Handler(); private ModUtils() {
handler = new Handler();
} }
public void setMod(TMod mod){
this.mod=mod; public void setMod(TMod mod) {
this.mod = mod;
getModDownloadInfo(); getModDownloadInfo();
} }
public List<TModfile> getModfiles(){
public List<TModfile> getModfiles() {
return modfiles; return modfiles;
} }
public void installMod(TMod mod){
this.mod=mod; public void installMod(TMod mod) {
this.mod = mod;
install(); install();
} }
private void install(){
if(modfiles==null){ private void install() {
Toast.makeText(context,"正在加载数据,请稍后再试",Toast.LENGTH_LONG).show(); if (modfiles == null) {
Toast.makeText(context, "正在加载数据,请稍后再试", Toast.LENGTH_LONG).show();
getModDownloadInfo(); getModDownloadInfo();
return; return;
} }
Log.i("安装mod",changeMod(mod,modfiles)+""); Log.i("安装mod", (!isInstallMod(mod)) + " " + changeMod(mod, modfiles) + "");
if(!isInstallMod(mod)&&changeMod(mod,modfiles)){ if (!isInstallMod(mod) && changeMod(mod, modfiles)) {
install(mod); install(mod);
}else{ } else {
if(getModPath(mod).listFiles().length>0&&!changeMod(mod,modfiles)){ if (getModPath(mod).listFiles().length > 0 && !changeMod(mod, modfiles)) {
final MaterialDialog dialog=new MaterialDialog(context); final MaterialDialog dialog = new MaterialDialog(context);
dialog.setTitle("mod已损失"); dialog.setTitle("mod已损失");
dialog.setMessage("当前mod文件有缺失是否重新下载"); dialog.setMessage("当前mod文件有缺失是否重新下载");
dialog.setPositiveButton("确定", new View.OnClickListener() { dialog.setPositiveButton("确定", new View.OnClickListener() {
@ -99,42 +107,43 @@ public class ModUtils {
} }
}); });
dialog.show(); dialog.show();
}else { } else {
downloadMod(); downloadMod();
} }
} }
} }
private void install(final TMod mod){
List<String> clientList=new ArrayList<>(); private void install(final TMod mod) {
List<String> clientList = new ArrayList<>();
for (MGamePackname packname : AppData.packnames) { for (MGamePackname packname : AppData.packnames) {
clientList.add(packname.getZhname()+"("+packname.getPackname()+")"); clientList.add(packname.getZhname() + "(" + packname.getPackname() + ")");
} }
final MaterialDialog dialog=new MaterialDialog(context); final MaterialDialog dialog = new MaterialDialog(context);
dialog.setTitle("选择安装客户端"); dialog.setTitle("选择安装客户端");
ListView listView=new ListView(context); ListView listView = new ListView(context);
listView.setAdapter(new ArrayAdapter<String>(context,android.R.layout.simple_list_item_1,clientList)); listView.setAdapter(new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, clientList));
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override @Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
MGamePackname packname=AppData.packnames.get(i); MGamePackname packname = AppData.packnames.get(i);
hud.show(); hud.show();
for (TModfile modfile : modfiles) { for (TModfile modfile : modfiles) {
File file=getModPath(mod,modfile.getFilename()); File file = getModPath(mod, modfile.getFilename());
if(packname.getZhname().contains("[ROOT]")){ if (packname.getZhname().contains("[ROOT]")) {
backupOrRoot(file,"/data/data/"+packname.getPackname()+modfile.getInstallpathid(),packname.getPackname(),mod); backupOrRoot(file, "/data/data/" + packname.getPackname() + modfile.getInstallpathid(), packname.getPackname(), mod);
rootInstall(file,"/data/data/"+packname.getPackname()+modfile.getInstallpathid()); rootInstall(file, "/data/data/" + packname.getPackname() + modfile.getInstallpathid());
}else{ } else {
} }
} }
try { try {
new File(getModInstallPath(mod)+packname.getPackname()+".lock").createNewFile(); new File(getModInstallPath(mod) + packname.getPackname() + ".lock").createNewFile();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
hud.dismiss(); hud.dismiss();
dialog.dismiss(); dialog.dismiss();
Toast.makeText(context,"安装成功,重启游戏生效",Toast.LENGTH_LONG).show(); Toast.makeText(context, "安装成功,重启游戏生效", Toast.LENGTH_LONG).show();
} }
}); });
dialog.setContentView(listView); dialog.setContentView(listView);
@ -147,48 +156,51 @@ public class ModUtils {
dialog.show(); dialog.show();
} }
private void notRootInstall(File src,String path){
private void notRootInstall(File src, String path) {
} }
private void rootInstall(File src,String path){
RootUtils root=RootUtils.init(context); private void rootInstall(File src, String path) {
if(RootUtils.su()){ RootUtils root = RootUtils.init(context);
root.exec("\\cp -f "+src.getAbsolutePath()+" "+path); if (RootUtils.su()) {
root.exec("chmod 777 "+src.getAbsolutePath()+" "+path+src.getName()); root.exec("\\cp -f " + src.getAbsolutePath() + " " + path);
}else { root.exec("chmod 777 " + src.getAbsolutePath() + " " + path + src.getName());
final MaterialDialog dialog=new MaterialDialog(context); } else {
dialog.setTitle("错误"); final MaterialDialog dialog = new MaterialDialog(context);
dialog.setMessage("未获取到ROOT权限\n提示魔改专用端可免ROOT使用魔改以及更多功能"); dialog.setTitle("错误");
dialog.setPositiveButton("确定", new View.OnClickListener() { dialog.setMessage("未获取到ROOT权限\n提示魔改专用端可免ROOT使用魔改以及更多功能");
@Override dialog.setPositiveButton("确定", new View.OnClickListener() {
public void onClick(View view) { @Override
dialog.dismiss(); public void onClick(View view) {
} dialog.dismiss();
}); }
dialog.setNegativeButton("下载魔改专用客户端", new View.OnClickListener() { });
@Override dialog.setNegativeButton("下载魔改专用客户端", new View.OnClickListener() {
public void onClick(View view) { @Override
dialog.dismiss(); public void onClick(View view) {
} dialog.dismiss();
}); }
dialog.show(); });
} dialog.show();
}
} }
public void reBackMod(TMod tMod) { public void reBackMod(TMod tMod) {
final MaterialDialog dialog=new MaterialDialog(context); final MaterialDialog dialog = new MaterialDialog(context);
dialog.setTitle("将还原 "+tMod.getTitle()); dialog.setTitle("将还原 " + tMod.getTitle());
final List<String> clientList=getInstallClens(); final List<String> clientList = getInstallClens();
ListView listView=new ListView(context); ListView listView = new ListView(context);
listView.setAdapter(new ArrayAdapter<String>(context,android.R.layout.simple_list_item_1,clientList)); listView.setAdapter(new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, clientList));
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override @Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
RootUtils root=RootUtils.init(context); RootUtils root = RootUtils.init(context);
for (TModfile modfile : modfiles) { for (TModfile modfile : modfiles) {
if(getModPath(mod,"backup/"+clientList.get(i)+"/"+modfile.getFilename()).exists()){ if (getModPath(mod, "backup/" + clientList.get(i) + "/" + modfile.getFilename()).exists()) {
root.exec("\\cp -f "+getModInstallPath(mod)+"backup/"+clientList.get(i)+"/"+modfile.getFilename()+" "+"/data/data/"+clientList.get(i)+modfile.getInstallpathid()); root.exec("\\cp -f " + getModInstallPath(mod) + "backup/" + clientList.get(i) + "/" + modfile.getFilename() + " " + "/data/data/" + clientList.get(i) + modfile.getInstallpathid());
}else{ } else {
root.exec("rm -f "+"/data/data/"+clientList.get(i)+modfile.getInstallpathid()+modfile.getFilename()); root.exec("rm -f " + "/data/data/" + clientList.get(i) + modfile.getInstallpathid() + modfile.getFilename());
} }
} }
dialog.dismiss(); dialog.dismiss();
@ -198,94 +210,98 @@ public class ModUtils {
dialog.setNegativeButton("放弃", new View.OnClickListener() { dialog.setNegativeButton("放弃", new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
dialog.dismiss();; dialog.dismiss();
;
} }
}); });
dialog.show(); dialog.show();
} }
private void backupOrRoot(File srcFile,String srcPath,String backupClient,TMod mod){
private void backupOrRoot(File srcFile, String srcPath, String backupClient, TMod mod) {
RootUtils root = RootUtils.init(context); RootUtils root = RootUtils.init(context);
if(RootUtils.su()) { if (RootUtils.su()) {
File backup = getModPath(mod, "backup/"+backupClient); File backup = getModPath(mod, "backup/" + backupClient);
File file=new File(backup.getAbsolutePath()+"/"+srcFile.getName()); File file = new File(backup.getAbsolutePath() + "/" + srcFile.getName());
if(file.exists()){ if (file.exists()) {
return; return;
} }
if (!backup.exists()) { if (!backup.exists()) {
Log.i("获取ROOT","2"); Log.i("获取ROOT", "2");
backup.mkdirs(); backup.mkdirs();
} }
root.exec("chmod 777 "+srcPath+srcFile.getName()); root.exec("chmod 777 " + srcPath + srcFile.getName());
root.exec("\\cp -f"+srcPath+srcFile.getName()+" "+backup+"/"); root.exec("\\cp -f" + srcPath + srcFile.getName() + " " + backup + "/");
}else{ } else {
} }
} }
private void downloadMod(){
Toast.makeText(context,"开始下载",Toast.LENGTH_LONG).show(); private void downloadMod() {
Intent intent=new Intent(context.getApplicationContext(), DownloadService.class); Toast.makeText(context, "开始下载", Toast.LENGTH_LONG).show();
Intent intent = new Intent(context.getApplicationContext(), DownloadService.class);
intent.setPackage(context.getPackageName()); intent.setPackage(context.getPackageName());
boolean isBindService=context.getApplicationContext().bindService(intent, new ServiceConnection() { boolean isBindService = context.getApplicationContext().bindService(intent, new ServiceConnection() {
@Override @Override
public void onServiceConnected(ComponentName componentName, IBinder iBinder) { public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
DownloadService.ServiceBinder binder=(DownloadService.ServiceBinder)iBinder; DownloadService.ServiceBinder binder = (DownloadService.ServiceBinder) iBinder;
DownloadService service=binder.getService(new DownloadInterface() { DownloadService service = binder.getService(new DownloadInterface() {
@Override @Override
public void getDownloadList(int size) { public void getDownloadList(int size) {
} }
@Override @Override
public void getDownloadFile(TModfile modfile) { public void getDownloadFile(TModfile modfile) {
} }
@Override @Override
public void getDownloadFileSize(int size) { public void getDownloadFileSize(int size) {
} }
@Override @Override
public void getCurrent(int current) { public void getCurrent(int current) {
} }
@Override @Override
public void over() { public void over() {
Utils.toast(context, "下载完成");
}
} @Override
public void start() {
@Override Utils.toast(context, "开始下载");
public void start() { }
});
} service.start(modfiles);
});
service.start(modfiles);
} }
@Override @Override
public void onServiceDisconnected(ComponentName componentName) { public void onServiceDisconnected(ComponentName componentName) {
Log.i("下载服务","绑定失败:"+componentName); Log.i("下载服务", "绑定失败:" + componentName);
} }
},Context.BIND_AUTO_CREATE); }, Context.BIND_AUTO_CREATE);
Log.i("绑定下载:",isBindService+""); Log.i("绑定下载:", isBindService + "");
} }
private void getModDownloadInfo(){
modfiles=null; private void getModDownloadInfo() {
try{ modfiles = null;
JSONObject json=new JSONObject(); try {
json.put("mid",mod.getId()); JSONObject json = new JSONObject();
json.put("mid", mod.getId());
json.put("uid", AppData.user.getId()); json.put("uid", AppData.user.getId());
HttpUtils.post(HttpApi.HOME_URL + HttpApi.MOD_DOWNLOAD, json, new HttpInterface() { HttpUtils.post(HttpApi.HOME_URL + HttpApi.MOD_DOWNLOAD, json, new HttpInterface() {
@Override @Override
public void httpGetData(String string, int code) { public void httpGetData(String string, int code) {
try{ try {
JSONObject json=new JSONObject(string); JSONObject json = new JSONObject(string);
if(json.getInt("code")==100){ if (json.getInt("code") == 100) {
modfiles= JSON.parseArray(json.getJSONArray("data").toString(),TModfile.class); modfiles = JSON.parseArray(json.getJSONArray("data").toString(), TModfile.class);
} }
}catch (Exception e){ } catch (Exception e) {
} }
} }
@ -295,53 +311,59 @@ public class ModUtils {
} }
}); });
}catch (Exception e){ } catch (Exception e) {
} }
} }
public static String getModInstallPath(TMod mod){ public static String getModInstallPath(TMod mod) {
return Utils.getSDCardPath()+"/"+mod.getId()+"/"; return Utils.getSDCardPath() + "/" + mod.getId() + "/";
} }
public static boolean isInstallMod(TMod mod){
File modPath=new File(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++) { for (int i = 0; i < modPath.listFiles().length; i++) {
Log.i("检测mod是否安装","位置:"+modPath.listFiles()[i].getAbsolutePath()+" exists:"+modPath.listFiles()[i].exists()+" .lock="+(modPath.listFiles()[i].getName().contains(".lock"))); Log.i("检测mod是否安装", "位置:" + modPath.listFiles()[i].getAbsolutePath() + " exists:" + modPath.listFiles()[i].exists() + " .lock=" + (modPath.listFiles()[i].getName().contains(".lock")));
if(modPath.listFiles()[i].getName().contains(".lock")){ if (modPath.listFiles()[i].getName().contains(".lock")) {
return true; return true;
} }
} }
return false; return false;
} }
public static boolean changeMod(TMod mod, List<TModfile> modfiles){
File modPath=new File(Utils.getSDCardPath()+"/"+mod.getId()+"/"); public static boolean changeMod(TMod mod, List<TModfile> modfiles) {
Log.i("检测mod是否完整","位置:"+Utils.getSDCardPath()+"/"+mod.getId()+"/"+" exists:"+modPath.exists()); File modPath = new File(Utils.getSDCardPath() + "/" + mod.getId() + "/");
Log.i("检测mod是否完整", "位置:" + Utils.getSDCardPath() + "/" + mod.getId() + "/" + " exists:" + modPath.exists());
for (TModfile modfile : modfiles) { for (TModfile modfile : modfiles) {
if(!new File(Utils.getSDCardPath()+"/"+mod.getId()+"/"+modfile.getFilename()).exists()){ if (new File(Utils.getSDCardPath() + "/" + mod.getId() + "/" + modfile.getFilename()).isFile())
return false; if (!new File(Utils.getSDCardPath() + "/" + mod.getId() + "/" + modfile.getFilename()).exists()) {
} Log.i("不完整的", "位置:" + Utils.getSDCardPath() + "/" + mod.getId() + "/" + " exists:" + modPath.exists());
return false;
}
} }
return true; return true;
} }
public static File getModPath(TMod mod){
return getModPath(mod,""); 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); public static File getModPath(TMod mod, String name) {
if(!path.exists()){ File path = new File(Utils.getSDCardPath() + "/" + mod.getId() + "/" + name);
if (!path.exists()) {
path.mkdirs(); path.mkdirs();
} }
return path; return path;
} }
public List<String> getInstallClens() { public List<String> getInstallClens() {
List<String> installClens=new ArrayList<>(); List<String> installClens = new ArrayList<>();
File modPath=getModPath(mod); File modPath = getModPath(mod);
if(modPath.exists()){ if (modPath.exists()) {
for (int i = 0; i < modPath.listFiles().length; i++) { for (int i = 0; i < modPath.listFiles().length; i++) {
if(modPath.listFiles()[i].getName().contains(".lock")){ if (modPath.listFiles()[i].getName().contains(".lock")) {
installClens.add(modPath.listFiles()[i].getName().split("\\.")[0]); installClens.add(modPath.listFiles()[i].getName().split("\\.")[0]);
} }
} }

View File

@ -68,6 +68,7 @@ public class DownloadService extends Service {
puase=false; puase=false;
list.addAll(addList); list.addAll(addList);
downloadInterface.start(); downloadInterface.start();
startNotification();
download= new Download(this); download= new Download(this);
} }
@ -126,7 +127,6 @@ public class DownloadService extends Service {
if(!download.isAlive||!download.isAlive()||!download.isInterrupted()) if(!download.isAlive||!download.isAlive()||!download.isInterrupted())
{ {
this.service=service; this.service=service;
service.startNotification();
start(); start();
} }
} }

View File

@ -2,5 +2,8 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent" android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/listView"></ListView>
</LinearLayout> </LinearLayout>

View 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>

View File

@ -1,14 +1,15 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="70dp" android:layout_height="80dp"
android:layout_marginTop="10dp"> android:layout_marginTop="20dp">
<LinearLayout <LinearLayout
android:id="@+id/download" android:id="@+id/download"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:background="@color/white" android:background="@color/white"
android:orientation="horizontal"> android:orientation="horizontal">

View File

@ -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;
}
}

View File

@ -4,20 +4,80 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View;
import android.widget.LinearLayout; 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.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import Interfaces.BaseActivityInterface; import Interfaces.BaseActivityInterface;
public class DownloadListActivity implements BaseActivityInterface ,Serializable { public class DownloadListActivity implements BaseActivityInterface ,Serializable {
private Context context; private Context context;
private LinearLayout layout; private View view;
private ListView listView;
@Override @Override
public void onCreate(Bundle savedInstanceState, LinearLayout layout, Context context, Intent intent) { public void onCreate(Bundle savedInstanceState, LinearLayout layout, Context context, Intent intent) {
this.context=context; 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 @Override

View File

@ -7,7 +7,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { 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.github.dcendents:android-maven-gradle-plugin:1.4.1'
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0" classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0"