|
|
@@ -3,6 +3,7 @@ package com.sheep.gamegroup.view.dialog;
|
|
|
import android.app.Activity;
|
|
|
import android.content.DialogInterface;
|
|
|
import android.os.Handler;
|
|
|
+import android.os.Looper;
|
|
|
import android.os.Message;
|
|
|
import android.support.v7.app.AlertDialog;
|
|
|
import android.text.Editable;
|
|
|
@@ -12,26 +13,20 @@ import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
import android.widget.AdapterView;
|
|
|
-import android.widget.ArrayAdapter;
|
|
|
-import android.widget.BaseAdapter;
|
|
|
-import android.widget.CheckBox;
|
|
|
import android.widget.EditText;
|
|
|
import android.widget.LinearLayout;
|
|
|
import android.widget.RadioButton;
|
|
|
import android.widget.RadioGroup;
|
|
|
-import android.widget.Spinner;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.kfzs.duanduan.utils.NumberFormatUtils;
|
|
|
import com.kfzs.duanduan.utils.dlg.ViewFindUtils;
|
|
|
-import com.sheep.gamegroup.model.entity.Agreement;
|
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
import com.sheep.gamegroup.model.entity.GameAccountEntity;
|
|
|
import com.sheep.gamegroup.model.entity.GridViewEntity;
|
|
|
import com.sheep.gamegroup.model.util.SheepSubscriber;
|
|
|
import com.sheep.gamegroup.util.ListUtil;
|
|
|
-import com.sheep.gamegroup.util.MyListview;
|
|
|
import com.sheep.gamegroup.util.ViewUtil;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
@@ -43,6 +38,8 @@ import java.util.List;
|
|
|
import rx.android.schedulers.AndroidSchedulers;
|
|
|
import rx.schedulers.Schedulers;
|
|
|
|
|
|
+import static com.sheep.gamegroup.util.UMConfigUtils.Event.USER_GAME_ACCOUNT_ADD_COMMIT;
|
|
|
+
|
|
|
/**
|
|
|
* Created by ljy on 2018/7/10.
|
|
|
*/
|
|
|
@@ -51,14 +48,13 @@ public class DialogAddAccount {
|
|
|
private Activity activity;
|
|
|
|
|
|
private List<GameAccountEntity> gameAccountEntity = new ArrayList<>();
|
|
|
- private ArrayList<Object> gamePlatorEntity = new ArrayList<>();
|
|
|
- private ArrayList<Object> gameAccountListEntity = new ArrayList<>();
|
|
|
+ private ArrayList<GridViewEntity> gamePlatorEntity = new ArrayList<>();
|
|
|
+ private ArrayList<GameAccountEntity> gameAccountListEntity = new ArrayList<>();
|
|
|
|
|
|
private int game_type;
|
|
|
private int task_id;
|
|
|
private String account;
|
|
|
private String password;
|
|
|
- private int task_type;
|
|
|
private TextView game_account_game_list_tv_spinner;
|
|
|
private EditText game_account_et;
|
|
|
private TextView game_account_plator_spinner_tv;
|
|
|
@@ -67,7 +63,7 @@ public class DialogAddAccount {
|
|
|
this.activity = activity;
|
|
|
}
|
|
|
|
|
|
- Handler mHandler = new Handler() {
|
|
|
+ private Handler mHandler = new Handler(Looper.getMainLooper()) {
|
|
|
@Override
|
|
|
public void handleMessage(Message msg) {
|
|
|
super.handleMessage(msg);
|
|
|
@@ -135,7 +131,7 @@ public class DialogAddAccount {
|
|
|
showPlotFormList();
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+ selectPlatform(0);
|
|
|
|
|
|
/**
|
|
|
* 游戏列表
|
|
|
@@ -184,7 +180,7 @@ public class DialogAddAccount {
|
|
|
sureTv.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
-
|
|
|
+ USER_GAME_ACCOUNT_ADD_COMMIT.onEvent();
|
|
|
account = game_account_et.getText().toString().trim();
|
|
|
password = game_pwd_et.getText().toString().trim();
|
|
|
if (TextUtils.isEmpty(account)) {
|
|
|
@@ -332,10 +328,7 @@ public class DialogAddAccount {
|
|
|
.SelfPopupWindow(activity, game_account_game_list_tv_spinner, new AdapterView.OnItemClickListener() {
|
|
|
@Override
|
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
- GameAccountEntity entity = gameAccountEntity.get(position);
|
|
|
- G.showToast(entity.getTask_name() + "");
|
|
|
- game_account_game_list_tv_spinner.setText(gameAccountEntity.get(position).getTask_name() + "");
|
|
|
- task_id = entity.getTask_id();
|
|
|
+ selectGame(position);
|
|
|
SelfPopupWindow.newInstance().hidePop();
|
|
|
}
|
|
|
},
|
|
|
@@ -343,13 +336,15 @@ public class DialogAddAccount {
|
|
|
@Override
|
|
|
public boolean convert(int position, View convertView, ViewGroup parent, GameAccountEntity item) {
|
|
|
final TextView name_tv = ViewFindUtils.find(convertView, R.id.name_tv);
|
|
|
- name_tv.setText(item.getTask_name() + "");
|
|
|
+ ViewUtil.setText(name_tv, item.getTask_name());
|
|
|
return true;
|
|
|
}
|
|
|
})
|
|
|
.initPopup()
|
|
|
.showPop();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 账号列表显示
|
|
|
*/
|
|
|
@@ -358,24 +353,30 @@ public class DialogAddAccount {
|
|
|
.SelfPopupWindow(activity, game_account_et, new AdapterView.OnItemClickListener() {
|
|
|
@Override
|
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
- GameAccountEntity entity = (GameAccountEntity) gameAccountListEntity.get(position);
|
|
|
- G.showToast(entity.getTask_name() + "");
|
|
|
- game_account_et.setText(gameAccountEntity.get(position).getTask_name() + "");
|
|
|
-// task_id = entity.getTask_id();
|
|
|
+ selectAccount(position);
|
|
|
SelfPopupWindow.newInstance().hidePop();
|
|
|
}
|
|
|
},
|
|
|
- new com.sheep.gamegroup.view.adapter.ArrayAdapter<Object>(activity, R.layout.dialog_item_game_list, gameAccountListEntity) {
|
|
|
+ new com.sheep.gamegroup.view.adapter.ArrayAdapter<GameAccountEntity>(activity, R.layout.dialog_item_game_list, gameAccountListEntity) {
|
|
|
@Override
|
|
|
- public boolean convert(int position, View convertView, ViewGroup parent, Object item) {
|
|
|
+ public boolean convert(int position, View convertView, ViewGroup parent, GameAccountEntity item) {
|
|
|
final TextView name_tv = ViewFindUtils.find(convertView, R.id.name_tv);
|
|
|
- name_tv.setText(((GameAccountEntity)item).getTask_name() + "");
|
|
|
+ ViewUtil.setText(name_tv, item.getTask_name());
|
|
|
return true;
|
|
|
}
|
|
|
})
|
|
|
.initPopup()
|
|
|
.showPop();
|
|
|
}
|
|
|
+
|
|
|
+ private void selectAccount(int position) {
|
|
|
+ GameAccountEntity item = ListUtil.getIndex(gameAccountListEntity, position);
|
|
|
+ if(item == null)
|
|
|
+ return;
|
|
|
+ ViewUtil.setText(game_account_et, item.getTask_name());
|
|
|
+// task_id = entity.getTask_id();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 平台显示
|
|
|
*/
|
|
|
@@ -384,27 +385,40 @@ public class DialogAddAccount {
|
|
|
.SelfPopupWindow(activity, game_account_plator_spinner_tv, new AdapterView.OnItemClickListener() {
|
|
|
@Override
|
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
- GridViewEntity gridViewEntity = (GridViewEntity) gamePlatorEntity.get(position);
|
|
|
- G.showToast(gridViewEntity.getName() + "");
|
|
|
- game_account_plator_spinner_tv.setText(gridViewEntity.getName() + "");
|
|
|
- try {
|
|
|
- game_type = Integer.parseInt(gridViewEntity.getTask_type());
|
|
|
- } catch (NumberFormatException e) {
|
|
|
- e.printStackTrace();
|
|
|
- task_type = 0;
|
|
|
- }
|
|
|
+ selectPlatform(position);
|
|
|
SelfPopupWindow.newInstance().hidePop();
|
|
|
}
|
|
|
},
|
|
|
- new com.sheep.gamegroup.view.adapter.ArrayAdapter<Object>(activity, R.layout.dialog_item_game_list, gamePlatorEntity) {
|
|
|
+ new com.sheep.gamegroup.view.adapter.ArrayAdapter<GridViewEntity>(activity, R.layout.dialog_item_game_list, gamePlatorEntity) {
|
|
|
@Override
|
|
|
- public boolean convert(int position, View convertView, ViewGroup parent, Object item) {
|
|
|
+ public boolean convert(int position, View convertView, ViewGroup parent, GridViewEntity item) {
|
|
|
final TextView name_tv = ViewFindUtils.find(convertView, R.id.name_tv);
|
|
|
- name_tv.setText(((GridViewEntity)item).getName() + "");
|
|
|
+ ViewUtil.setText(name_tv, item.getName());
|
|
|
return true;
|
|
|
}
|
|
|
})
|
|
|
.initPopup()
|
|
|
.showPop();
|
|
|
}
|
|
|
+
|
|
|
+ private void selectPlatform(int position) {
|
|
|
+ GridViewEntity item = ListUtil.getIndex(gamePlatorEntity, position);
|
|
|
+ if(item == null)
|
|
|
+ return;
|
|
|
+ ViewUtil.setText(game_account_plator_spinner_tv, item.getName());
|
|
|
+ int new_game_type = NumberFormatUtils.parseInteger(item.getTask_type());
|
|
|
+ if(new_game_type != game_type) {//选择不同平台时,游戏重置
|
|
|
+ ViewUtil.setText(game_account_game_list_tv_spinner);
|
|
|
+ task_id = 0;
|
|
|
+ }
|
|
|
+ game_type = new_game_type;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void selectGame(int position) {
|
|
|
+ GameAccountEntity item = ListUtil.getIndex(gameAccountEntity, position);
|
|
|
+ if(item == null)
|
|
|
+ return;
|
|
|
+ ViewUtil.setText(game_account_game_list_tv_spinner, item.getTask_name());
|
|
|
+ task_id = item.getTask_id();
|
|
|
+ }
|
|
|
}
|