Commit 4bc05604 authored by fallenstardust's avatar fallenstardust

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

parent 6acb5abe
......@@ -6,14 +6,25 @@ import android.os.*;
import android.view.*;
import android.view.View.*;
import android.widget.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.*;
import android.support.v7.widget.*;
import cn.garymb.ygodata.YGOGameOptions;
import cn.garymb.ygomobile.Constants;
import cn.garymb.ygomobile.YGOStarter;
import cn.garymb.ygomobile.bean.ServerInfo;
import cn.garymb.ygomobile.bean.ServerList;
import cn.garymb.ygomobile.lite.R;
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
......@@ -116,13 +127,48 @@ public class ServiceDuelAssistant extends Service
isdis = false;
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){
......
......@@ -4,21 +4,22 @@
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical"
android:background="#00000000">
android:background="#00FFFFFF">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center_horizontal">
android:gravity="center_horizontal"
android:background="@drawable/window">
<TextView
android:textColor="@color/gold"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Text"
android:layout_margin="10dp"
android:id="@+id/ds_text"
android:textColor="#000000"/>
android:id="@+id/ds_text" />
<LinearLayout
android:layout_height="wrap_content"
......@@ -26,22 +27,26 @@
android:orientation="horizontal">
<Button
android:textColor="@color/colorPrimary"
android:textColor="@color/white"
style="?android:attr/buttonBarButtonStyle"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/join_game"
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
android:textColor="@color/colorPrimary"
android:textColor="@color/white"
style="?android:attr/buttonBarButtonStyle"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/search_close"
android:layout_weight="1"
android:id="@+id/ds_qx"/>
android:id="@+id/ds_qx" />
</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