Commit cf4c3ac0 authored by fallenstardust's avatar fallenstardust

debug

parent eb400ab3
package cn.garymb.ygomobile.ui.home; package cn.garymb.ygomobile.ui.home;
import android.content.BroadcastReceiver;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter;
import android.graphics.Color; import android.graphics.Color;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.widget.Toast; import android.widget.Toast;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
...@@ -26,9 +31,11 @@ import cn.garymb.ygomobile.ui.plus.VUiKit; ...@@ -26,9 +31,11 @@ import cn.garymb.ygomobile.ui.plus.VUiKit;
import cn.garymb.ygomobile.utils.ComponentUtils; import cn.garymb.ygomobile.utils.ComponentUtils;
import cn.garymb.ygomobile.utils.IOUtils; import cn.garymb.ygomobile.utils.IOUtils;
import cn.garymb.ygomobile.utils.NetUtils; import cn.garymb.ygomobile.utils.NetUtils;
import libwindbot.windbot.WindBot;
import static cn.garymb.ygomobile.Constants.ACTION_RELOAD; import static cn.garymb.ygomobile.Constants.ACTION_RELOAD;
import static cn.garymb.ygomobile.Constants.CORE_PICS_ZIP; import static cn.garymb.ygomobile.Constants.CORE_PICS_ZIP;
import static cn.garymb.ygomobile.Constants.DATABASE_NAME;
import static cn.garymb.ygomobile.Constants.NETWORK_IMAGE; import static cn.garymb.ygomobile.Constants.NETWORK_IMAGE;
import static cn.garymb.ygomobile.Constants.PREF_DEF_GAME_DIR; import static cn.garymb.ygomobile.Constants.PREF_DEF_GAME_DIR;
import static cn.garymb.ygomobile.ui.home.ResCheckTask.getDatapath; import static cn.garymb.ygomobile.ui.home.ResCheckTask.getDatapath;
...@@ -42,6 +49,8 @@ public class MainActivity extends HomeActivity { ...@@ -42,6 +49,8 @@ public class MainActivity extends HomeActivity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
YGOStarter.onCreated(this); YGOStarter.onCreated(this);
//checkWindbot();
han.sendEmptyMessage(0);
mImageUpdater = new ImageUpdater(this); mImageUpdater = new ImageUpdater(this);
//资源复制 //资源复制
checkResourceDownload((error, isNew) -> { checkResourceDownload((error, isNew) -> {
...@@ -87,6 +96,7 @@ public class MainActivity extends HomeActivity { ...@@ -87,6 +96,7 @@ public class MainActivity extends HomeActivity {
protected void onDestroy() { protected void onDestroy() {
YGOStarter.onDestroy(this); YGOStarter.onDestroy(this);
super.onDestroy(); super.onDestroy();
unregisterReceiver(mReceiver);
} }
@Override @Override
...@@ -152,4 +162,44 @@ public class MainActivity extends HomeActivity { ...@@ -152,4 +162,44 @@ public class MainActivity extends HomeActivity {
/* checkResourceDownload((result, isNewVersion) -> { /* checkResourceDownload((result, isNewVersion) -> {
Toast.makeText(this, R.string.tip_reset_game_res, Toast.LENGTH_SHORT).show(); Toast.makeText(this, R.string.tip_reset_game_res, Toast.LENGTH_SHORT).show();
});*/ });*/
public class MessageReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals("RUN_WINDBOT")) {
String args = intent.getStringExtra("args");
WindBot.runAndroid(args);
}
}
}
public void checkWindbot() {
try {
WindBot.initAndroid(getFilesDir().getPath(), AppsSettings.get().getDataBasePath() + "/" + DATABASE_NAME);
}catch (Throwable e){
e.printStackTrace();
}
MessageReceiver mReceiver = new MessageReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction("RUN_WINDBOT");
registerReceiver(mReceiver, filter);
}
Handler han = new Handler() {
@Override
public void handleMessage(Message msg) {
// TODO: Implement this method
super.handleMessage(msg);
switch (msg.what) {
case 0:
checkWindbot();
break;
}
}
};
} }
...@@ -170,10 +170,6 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> { ...@@ -170,10 +170,6 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
IOUtils.copyFilesFromAssets(mContext, getDatapath(Constants.CORE_EXPANSIONS), IOUtils.copyFilesFromAssets(mContext, getDatapath(Constants.CORE_EXPANSIONS),
mSettings.getExpansionsPath().getAbsolutePath(), true, needsUpdate); mSettings.getExpansionsPath().getAbsolutePath(), true, needsUpdate);
} }
//checkWindbot();
han.sendEmptyMessage(0);
} catch (Exception e) { } catch (Exception e) {
if (Constants.DEBUG) if (Constants.DEBUG)
Log.e(TAG, "check", e); Log.e(TAG, "check", e);
...@@ -324,44 +320,4 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> { ...@@ -324,44 +320,4 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
public interface ResCheckListener { public interface ResCheckListener {
void onResCheckFinished(int result, boolean isNewVersion); void onResCheckFinished(int result, boolean isNewVersion);
} }
public void checkWindbot() {
Log.i("路径", mContext.getFilesDir().getPath());
Log.i("路径2", mSettings.getDataBasePath() + "/" + DATABASE_NAME);
try {
WindBot.initAndroid(mContext.getFilesDir().getPath(), mSettings.getDataBasePath() + "/" + DATABASE_NAME);
}catch (Throwable e){
e.printStackTrace();
}
ResCheckTask.MessageReceiver mReceiver = new ResCheckTask.MessageReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction("RUN_WINDBOT");
mContext.registerReceiver(mReceiver, filter);
}
public class MessageReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals("RUN_WINDBOT")) {
String args = intent.getStringExtra("args");
WindBot.runAndroid(args);
}
}
}
Handler han = new Handler() {
@Override
public void handleMessage(Message msg) {
// TODO: Implement this method
super.handleMessage(msg);
switch (msg.what) {
case 0:
checkWindbot();
break;
}
}
};
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment