Commit 836cc324 authored by fallenstardust's avatar fallenstardust

实现WINDBOT

parent b06d9c19
......@@ -13,7 +13,7 @@ android {
flavorDimensions "versionCode"
vectorDrawables.useSupportLibrary = true
ndk {
abiFilters "armeabi-v7a","armeabi"
abiFilters "armeabi-v7a"
}
}
compileOptions {
......
......@@ -50,6 +50,7 @@ public interface Constants {
String ASSET_LIMIT_PNG = ASSETS_PATH + "textures/lim.png";
String DEFAULT_FONT_NAME = "ygo.ttf";
String DATABASE_NAME = "cards.cdb";
String BOT_CONF = "bot.conf";
String WINDBOT_PATH="windbot";
String FONT_DIRECTORY = "fonts";
String CORE_STRING_PATH = "strings.conf";
......
......@@ -31,7 +31,6 @@ import com.nightonke.boommenu.BoomMenuButton;
import com.qihoo.appstore.common.updatesdk.lib.UpdateHelper;
import com.tubb.smrv.SwipeMenuRecyclerView;
import org.chromium.mojo.bindings.MessageReceiver;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
......@@ -46,7 +45,6 @@ import cn.garymb.ygomobile.YGOStarter;
import cn.garymb.ygomobile.bean.ServerInfo;
import cn.garymb.ygomobile.bean.events.ServerInfoEvent;
import cn.garymb.ygomobile.lite.R;
import cn.garymb.ygomobile.ui.activities.AboutActivity;
import cn.garymb.ygomobile.ui.activities.BaseActivity;
import cn.garymb.ygomobile.ui.activities.WebActivity;
import cn.garymb.ygomobile.ui.adapters.ServerListAdapter;
......@@ -60,8 +58,6 @@ import cn.garymb.ygomobile.ui.preference.SettingsActivity;
import cn.garymb.ygomobile.utils.AlipayPayUtils;
import libwindbot.windbot.WindBot;
import static cn.garymb.ygomobile.Constants.DATABASE_NAME;
abstract class HomeActivity extends BaseActivity implements NavigationView.OnNavigationItemSelectedListener{
protected SwipeMenuRecyclerView mServerList;
private ServerListAdapter mServerListAdapter;
......@@ -93,7 +89,6 @@ abstract class HomeActivity extends BaseActivity implements NavigationView.OnNav
TrPay.getInstance(HomeActivity.this).initPaySdk("e1014da420ea4405898c01273d6731b6","YGOMobile");
//autoupadte checking
checkForceUpdateSilent();
checkWindbot();
}
@Override
......@@ -102,17 +97,6 @@ abstract class HomeActivity extends BaseActivity implements NavigationView.OnNav
EventBus.getDefault().unregister(this);
}
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);
}
}
};
@Subscribe(threadMode = ThreadMode.MAIN)
public void onServerInfoEvent(ServerInfoEvent event) {
if (event.delete) {
......@@ -386,12 +370,5 @@ abstract class HomeActivity extends BaseActivity implements NavigationView.OnNav
long intervalMillis = 0 * 1000L;
UpdateHelper.getInstance().autoUpdate(getPackageName(), false, intervalMillis);
}
public void checkWindbot(){
WindBot.initAndroid(this.getFilesDir().getPath(),AppsSettings.get().getDataBasePath()+"/"+ DATABASE_NAME);
HomeActivity.MessageReceiver mReceiver = new HomeActivity.MessageReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction("RUN_WINDBOT");
getContext().registerReceiver(mReceiver, filter);
}
}
......@@ -170,6 +170,8 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
IOUtils.copyFilesFromAssets(mContext, getDatapath(Constants.CORE_EXPANSIONS),
mSettings.getExpansionsPath().getAbsolutePath(), true, needsUpdate);
}
//checkWindbot();
han.sendEmptyMessage(0);
} catch (Exception e) {
......@@ -301,7 +303,9 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
}
//替换换行符
File stringfile = new File(AppsSettings.get().getResourcePath(), Constants.CORE_STRING_PATH);
File botfile = new File(AppsSettings.get().getResourcePath(), Constants.BOT_CONF);
fixString(stringfile.getAbsolutePath());
fixString(botfile.getAbsolutePath());
return ERROR_NONE;
} catch (IOException e) {
if (Constants.DEBUG)
......@@ -321,17 +325,36 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
void onResCheckFinished(int result, boolean isNewVersion);
}
public void checkWindbot(){
Log.i("路径", mContext.getFilesDir().getPath());
Log.i("路径2", mSettings.getDataBasePath()+"/"+ DATABASE_NAME);
WindBot.initAndroid(mContext.getFilesDir().getPath(),mSettings.getDataBasePath()+"/"+ DATABASE_NAME);
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) {
public void handleMessage(Message msg)
{
// TODO: Implement this method
super.handleMessage(msg);
switch(msg.what){
case 0:
Log.i("运行了没?","运行了");
//checkWindbot();
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