Commit 4bc05604 authored by fallenstardust's avatar fallenstardust

修复空指针&调整弹窗配色

parent 6acb5abe
...@@ -6,14 +6,25 @@ import android.os.*; ...@@ -6,14 +6,25 @@ import android.os.*;
import android.view.*; import android.view.*;
import android.view.View.*; import android.view.View.*;
import android.widget.*; import android.widget.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.*; import java.util.*;
import android.support.v7.widget.*; import android.support.v7.widget.*;
import cn.garymb.ygodata.YGOGameOptions; import cn.garymb.ygodata.YGOGameOptions;
import cn.garymb.ygomobile.Constants;
import cn.garymb.ygomobile.YGOStarter; import cn.garymb.ygomobile.YGOStarter;
import cn.garymb.ygomobile.bean.ServerInfo; import cn.garymb.ygomobile.bean.ServerInfo;
import cn.garymb.ygomobile.bean.ServerList;
import cn.garymb.ygomobile.lite.R; import cn.garymb.ygomobile.lite.R;
import cn.garymb.ygomobile.ui.adapters.ServerListAdapter; import cn.garymb.ygomobile.ui.adapters.ServerListAdapter;
import cn.garymb.ygomobile.ui.home.ServerListManager;
import cn.garymb.ygomobile.utils.IOUtils;
import cn.garymb.ygomobile.utils.XmlUtils;
import static cn.garymb.ygomobile.Constants.ASSET_SERVER_LIST;
public class ServiceDuelAssistant extends Service public class ServiceDuelAssistant extends Service
...@@ -116,13 +127,48 @@ public class ServiceDuelAssistant extends Service ...@@ -116,13 +127,48 @@ public class ServiceDuelAssistant extends Service
isdis = false; isdis = false;
mWindowManager.removeView(mFloatLayout); mWindowManager.removeView(mFloatLayout);
} }
ServerInfo serverInfo=new ServerListAdapter(ServiceDuelAssistant.this).getItem(0); ServerListAdapter mServerListAdapter=new ServerListAdapter(ServiceDuelAssistant.this);
ServerListManager mServerListManager = new ServerListManager(ServiceDuelAssistant.this, mServerListAdapter);
mServerListManager.syncLoadData();
File xmlFile = new File(getFilesDir(), Constants.SERVER_FILE);
VUiKit.defer().when(() -> {
ServerList assetList = readList(ServiceDuelAssistant.this.getAssets().open(ASSET_SERVER_LIST));
ServerList fileList = xmlFile.exists() ? readList(new FileInputStream(xmlFile)) : null;
if (fileList == null) {
return assetList;
}
if (fileList.getVercode() < assetList.getVercode()) {
xmlFile.delete();
return assetList;
}
return fileList;
}).done((list) -> {
if (list != null) {
ServerInfo serverInfo=list.getServerInfoList().get(0);
duelIntent(ServiceDuelAssistant.this,serverInfo.getServerAddr(),serverInfo.getPort(),serverInfo.getPlayerName(),password); duelIntent(ServiceDuelAssistant.this,serverInfo.getServerAddr(),serverInfo.getPort(),serverInfo.getPlayerName(),password);
}
});
} }
}); });
} }
private ServerList readList(InputStream in) {
ServerList list = null;
try {
list = XmlUtils.get().getObject(ServerList.class, in);
} catch (Exception e) {
} finally {
IOUtils.close(in);
}
return list;
}
//决斗跳转 //决斗跳转
public static void duelIntent(Context context,String ip, int dk, String name, String password){ public static void duelIntent(Context context,String ip, int dk, String name, String password){
......
...@@ -4,21 +4,22 @@ ...@@ -4,21 +4,22 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:background="#00000000"> android:background="#00FFFFFF">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:gravity="center_horizontal"> android:gravity="center_horizontal"
android:background="@drawable/window">
<TextView <TextView
android:textColor="@color/gold"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:text="Text" android:text="Text"
android:layout_margin="10dp" android:layout_margin="10dp"
android:id="@+id/ds_text" android:id="@+id/ds_text" />
android:textColor="#000000"/>
<LinearLayout <LinearLayout
android:layout_height="wrap_content" android:layout_height="wrap_content"
...@@ -26,22 +27,26 @@ ...@@ -26,22 +27,26 @@
android:orientation="horizontal"> android:orientation="horizontal">
<Button <Button
android:textColor="@color/colorPrimary" android:textColor="@color/white"
style="?android:attr/buttonBarButtonStyle" style="?android:attr/buttonBarButtonStyle"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:text="@string/join_game" android:text="@string/join_game"
android:layout_weight="1" android:layout_weight="1"
android:id="@+id/ds_join"/> android:id="@+id/ds_join" />
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_margin="20dp" />
<Button <Button
android:textColor="@color/colorPrimary" android:textColor="@color/white"
style="?android:attr/buttonBarButtonStyle" style="?android:attr/buttonBarButtonStyle"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:text="@string/search_close" android:text="@string/search_close"
android:layout_weight="1" android:layout_weight="1"
android:id="@+id/ds_qx"/> android:id="@+id/ds_qx" />
</LinearLayout> </LinearLayout>
......
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