|
|
@@ -50,8 +50,6 @@ import rx.schedulers.Schedulers;
|
|
|
public class DialogAddAccount {
|
|
|
private Activity activity;
|
|
|
|
|
|
- private com.sheep.gamegroup.view.adapter.ArrayAdapter baseAdapter;
|
|
|
- private com.sheep.gamegroup.view.adapter.ArrayAdapter accountAdapter;
|
|
|
private List<GameAccountEntity> gameAccountEntity = new ArrayList<>();
|
|
|
private ArrayList<Object> gamePlatorEntity = new ArrayList<>();
|
|
|
private ArrayList<Object> gameAccountListEntity = new ArrayList<>();
|
|
|
@@ -61,33 +59,35 @@ public class DialogAddAccount {
|
|
|
private String account;
|
|
|
private String password;
|
|
|
private int task_type;
|
|
|
- Spinner game_account_game_list_spinner;
|
|
|
+ private TextView game_account_game_list_tv_spinner;
|
|
|
+ private EditText game_account_et;
|
|
|
+ private TextView game_account_plator_spinner_tv;
|
|
|
|
|
|
public DialogAddAccount(Activity activity) {
|
|
|
this.activity = activity;
|
|
|
}
|
|
|
|
|
|
- Handler mHandler = new Handler(){
|
|
|
+ Handler mHandler = new Handler() {
|
|
|
@Override
|
|
|
public void handleMessage(Message msg) {
|
|
|
super.handleMessage(msg);
|
|
|
try {
|
|
|
- switch (msg.what){
|
|
|
+ switch (msg.what) {
|
|
|
case 0:
|
|
|
- if(game_account_game_list_spinner == null)
|
|
|
+ if (game_account_game_list_tv_spinner == null)
|
|
|
return;
|
|
|
|
|
|
- game_account_game_list_spinner.setVisibility((Integer) msg.obj);
|
|
|
+ game_account_game_list_tv_spinner.setVisibility((Integer) msg.obj);
|
|
|
break;
|
|
|
}
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- public void showAddAccount(){
|
|
|
- if(activity == null)
|
|
|
+ public void showAddAccount() {
|
|
|
+ if (activity == null)
|
|
|
return;
|
|
|
platformData();
|
|
|
View dialog_parent = View.inflate(activity, R.layout.dialog_parent, null);
|
|
|
@@ -101,27 +101,8 @@ public class DialogAddAccount {
|
|
|
dialog_title.setText("添加账号");
|
|
|
|
|
|
TextView sureTv = view.findViewById(R.id.add_sure_tv);
|
|
|
- final EditText game_account_et = view.findViewById(R.id.game_account_et);
|
|
|
+ game_account_et = view.findViewById(R.id.game_account_et);
|
|
|
final EditText game_pwd_et = view.findViewById(R.id.game_pwd_et);
|
|
|
- final MyListview game_account_listview = view.findViewById(R.id.game_account_listview);
|
|
|
-
|
|
|
- accountAdapter = new com.sheep.gamegroup.view.adapter.ArrayAdapter<Object>(activity, R.layout.dialog_item_game_list, gameAccountListEntity){
|
|
|
- @Override
|
|
|
- public boolean convert(int position, View convertView, ViewGroup parent, Object item) {
|
|
|
- final GameAccountEntity gameAccountEntity = (GameAccountEntity) item;
|
|
|
- final TextView name_tv = ViewFindUtils.find(convertView, R.id.name_tv);
|
|
|
- name_tv.setText(gameAccountEntity.getTask_name()+"");
|
|
|
- convertView.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- game_account_et.setText(gameAccountEntity.getTask_name()+"");
|
|
|
- game_account_listview.setVisibility(View.GONE);
|
|
|
- }
|
|
|
- });
|
|
|
- return true;
|
|
|
- }
|
|
|
- };
|
|
|
- game_account_listview.setAdapter(accountAdapter);
|
|
|
|
|
|
game_account_et.addTextChangedListener(new TextWatcher() {
|
|
|
@Override
|
|
|
@@ -131,8 +112,7 @@ public class DialogAddAccount {
|
|
|
|
|
|
@Override
|
|
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
- if(!TextUtils.isEmpty(s) && s.length() > 4){
|
|
|
- game_account_listview.setVisibility(View.VISIBLE);
|
|
|
+ if (!TextUtils.isEmpty(s) && s.length() > 4) {
|
|
|
intitDataAccountList(s.toString());
|
|
|
}
|
|
|
}
|
|
|
@@ -143,20 +123,40 @@ public class DialogAddAccount {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- final TextView game_account_plator_spinner_tv = view.findViewById(R.id.game_account_plator_spinner_tv);
|
|
|
+ /**
|
|
|
+ * 平台列表
|
|
|
+ * gamePlatorEntity
|
|
|
+ * R.layout.dialog_item_game_list
|
|
|
+ */
|
|
|
+ game_account_plator_spinner_tv = view.findViewById(R.id.game_account_plator_spinner_tv);
|
|
|
game_account_plator_spinner_tv.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
- new SelfPopupWindow(activity, game_account_plator_spinner_tv).showPopup();
|
|
|
+ showPlotFormList();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- Spinner game_account_plator_spinner = view.findViewById(R.id.game_account_plator_spinner);
|
|
|
- game_account_game_list_spinner = view.findViewById(R.id.game_account_game_list_spinner);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 游戏列表
|
|
|
+ * gameAccountEntity
|
|
|
+ * if(game_type < 1) {
|
|
|
+ G.showToast("请选择游戏平台!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ intitDataGameList(game_type);
|
|
|
+ */
|
|
|
+ game_account_game_list_tv_spinner = view.findViewById(R.id.game_account_game_list_tv_spinner);
|
|
|
+ game_account_game_list_tv_spinner.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ intitDataGameList(game_type);
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
final RadioButton conmon_id = view.findViewById(R.id.conmon_id);
|
|
|
final RadioButton fixation_id = view.findViewById(R.id.fixation_id);
|
|
|
- RadioGroup radio_group= view.findViewById(R.id.radio_group);
|
|
|
+ RadioGroup radio_group = view.findViewById(R.id.radio_group);
|
|
|
radio_group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
|
|
@Override
|
|
|
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
|
|
@@ -167,72 +167,16 @@ public class DialogAddAccount {
|
|
|
|
|
|
Message message = new Message();
|
|
|
message.what = 0;
|
|
|
- if(id == R.id.conmon_id){
|
|
|
+ if (id == R.id.conmon_id) {
|
|
|
message.obj = View.GONE;
|
|
|
- game_account_game_list_spinner.setVisibility(View.GONE);
|
|
|
}
|
|
|
- if(id == R.id.fixation_id){
|
|
|
+ if (id == R.id.fixation_id) {
|
|
|
message.obj = View.VISIBLE;
|
|
|
- game_account_game_list_spinner.setVisibility(View.VISIBLE);
|
|
|
}
|
|
|
mHandler.sendMessage(message);
|
|
|
}
|
|
|
});
|
|
|
- /**
|
|
|
- * 平台列表
|
|
|
- */
|
|
|
- game_account_plator_spinner.setAdapter(new com.sheep.gamegroup.view.adapter.ArrayAdapter<Object>(activity, R.layout.dialog_item_game_list, gamePlatorEntity){
|
|
|
- @Override
|
|
|
- public boolean convert(int position, View convertView, ViewGroup parent, final Object item) {
|
|
|
- final GridViewEntity gridViewEntity = (GridViewEntity) item;
|
|
|
- final TextView name_tv = ViewFindUtils.find(convertView, R.id.name_tv);
|
|
|
- name_tv.setText(gridViewEntity.getName()+"");
|
|
|
- convertView.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View view) {
|
|
|
- task_type = Integer.parseInt(gridViewEntity.getTask_type());
|
|
|
- }
|
|
|
- });
|
|
|
- return true;
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- /**
|
|
|
- * 游戏列表
|
|
|
- */
|
|
|
- baseAdapter = new com.sheep.gamegroup.view.adapter.ArrayAdapter<GameAccountEntity>(activity, R.layout.dialog_item_game_list, gameAccountEntity){
|
|
|
- @Override
|
|
|
- public boolean convert(int position, View convertView, ViewGroup parent, final GameAccountEntity item) {
|
|
|
- final TextView name_tv = ViewFindUtils.find(convertView, R.id.name_tv);
|
|
|
- name_tv.setText(item.getTask_name()+"");
|
|
|
-// convertView.setOnClickListener(new View.OnClickListener() {
|
|
|
-// @Override
|
|
|
-// public void onClick(View view) {
|
|
|
-// task_id = item.getTask_id();
|
|
|
-// task_type = item.getTask_type();
|
|
|
-// }
|
|
|
-// });
|
|
|
- return true;
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- game_account_game_list_spinner.setAdapter(baseAdapter);
|
|
|
- game_account_game_list_spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
|
|
- @Override
|
|
|
- public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
|
|
|
|
|
- if(game_type < 1) {
|
|
|
- G.showToast("请选择游戏平台!");
|
|
|
- return;
|
|
|
- }
|
|
|
- intitDataGameList(game_type);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onNothingSelected(AdapterView<?> parent) {
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
|
|
|
/**
|
|
|
* 添加账号提交
|
|
|
@@ -243,20 +187,20 @@ public class DialogAddAccount {
|
|
|
|
|
|
account = game_account_et.getText().toString().trim();
|
|
|
password = game_pwd_et.getText().toString().trim();
|
|
|
- if(TextUtils.isEmpty(account)){
|
|
|
+ if (TextUtils.isEmpty(account)) {
|
|
|
G.showToast("请选择或输入游戏账号");
|
|
|
return;
|
|
|
}
|
|
|
- if(task_type < 1){
|
|
|
+ if (game_type < 1) {
|
|
|
G.showToast("请选择游戏平台");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
- jsonObject.put("account",account);
|
|
|
- jsonObject.put("password",password);
|
|
|
- jsonObject.put("task_id",task_id);
|
|
|
- jsonObject.put("task_type",task_type);
|
|
|
+ jsonObject.put("account", account);
|
|
|
+ jsonObject.put("password", password);
|
|
|
+ jsonObject.put("task_id", task_id);
|
|
|
+ jsonObject.put("game_type", game_type);
|
|
|
|
|
|
ViewUtil.newInstance().showProgress(activity);
|
|
|
SheepApp.getInstance()
|
|
|
@@ -270,13 +214,13 @@ public class DialogAddAccount {
|
|
|
public void onError(BaseMessage baseMessage) {
|
|
|
|
|
|
ViewUtil.newInstance().hideProgress(activity);
|
|
|
- G.showToast(baseMessage.getMsg()+"");
|
|
|
+ G.showToast(baseMessage.getMsg() + "");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onNext(BaseMessage baseMessage) {
|
|
|
ViewUtil.newInstance().hideProgress(activity);
|
|
|
- G.showToast(baseMessage.getMsg()+"");
|
|
|
+ G.showToast(baseMessage.getMsg() + "");
|
|
|
|
|
|
dialog.dismiss();
|
|
|
}
|
|
|
@@ -303,21 +247,23 @@ public class DialogAddAccount {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 平台数据
|
|
|
*/
|
|
|
- private void platformData(){
|
|
|
+ private void platformData() {
|
|
|
gamePlatorEntity.clear();
|
|
|
- gamePlatorEntity.add(new GridViewEntity(false, "平台游戏", 1002+""));
|
|
|
- gamePlatorEntity.add(new GridViewEntity(false, "小米游戏", 1004+""));
|
|
|
- gamePlatorEntity.add(new GridViewEntity(false, "腾讯游戏", 1003+""));
|
|
|
+ gamePlatorEntity.add(new GridViewEntity(false, "平台游戏", 1002 + ""));
|
|
|
+ gamePlatorEntity.add(new GridViewEntity(false, "小米游戏", 1004 + ""));
|
|
|
+ gamePlatorEntity.add(new GridViewEntity(false, "腾讯游戏", 1003 + ""));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 游戏任务列表
|
|
|
+ *
|
|
|
* @param game_type
|
|
|
*/
|
|
|
- private void intitDataGameList(int game_type){
|
|
|
+ private void intitDataGameList(int game_type) {
|
|
|
|
|
|
ViewUtil.newInstance().showProgress(activity);
|
|
|
SheepApp.getInstance()
|
|
|
@@ -331,25 +277,25 @@ public class DialogAddAccount {
|
|
|
public void onError(BaseMessage baseMessage) {
|
|
|
|
|
|
ViewUtil.newInstance().hideProgress(activity);
|
|
|
- G.showToast(baseMessage.getMsg()+"");
|
|
|
+ G.showToast(baseMessage.getMsg() + "");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onNext(BaseMessage baseMessage) {
|
|
|
ViewUtil.newInstance().hideProgress(activity);
|
|
|
List<GameAccountEntity> gameAccountEntitys = baseMessage.getDatas(GameAccountEntity.class);
|
|
|
- if(!ListUtil.isEmpty(gameAccountEntitys)){
|
|
|
+ if (!ListUtil.isEmpty(gameAccountEntitys)) {
|
|
|
gameAccountEntity.clear();
|
|
|
gameAccountEntity.addAll(gameAccountEntitys);
|
|
|
- if(baseAdapter != null)
|
|
|
- baseAdapter.notifyDataSetChanged();
|
|
|
+ showListGame();
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- private void intitDataAccountList(String account){
|
|
|
|
|
|
- if(game_type < 1) {
|
|
|
+ private void intitDataAccountList(String account) {
|
|
|
+
|
|
|
+ if (game_type < 1) {
|
|
|
G.showToast("请选择游戏平台!");
|
|
|
return;
|
|
|
}
|
|
|
@@ -365,20 +311,103 @@ public class DialogAddAccount {
|
|
|
public void onError(BaseMessage baseMessage) {
|
|
|
|
|
|
ViewUtil.newInstance().hideProgress(activity);
|
|
|
- G.showToast(baseMessage.getMsg()+"");
|
|
|
+ G.showToast(baseMessage.getMsg() + "");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onNext(BaseMessage baseMessage) {
|
|
|
ViewUtil.newInstance().hideProgress(activity);
|
|
|
List<GameAccountEntity> gameAccountEntitys = baseMessage.getDatas(GameAccountEntity.class);
|
|
|
- if(!ListUtil.isEmpty(gameAccountEntitys)){
|
|
|
+ if (!ListUtil.isEmpty(gameAccountEntitys)) {
|
|
|
gameAccountListEntity.clear();
|
|
|
gameAccountListEntity.addAll(gameAccountEntitys);
|
|
|
- if(accountAdapter != null)
|
|
|
- accountAdapter.notifyDataSetChanged();
|
|
|
+ showListAccount();
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 游戏列表显示
|
|
|
+ */
|
|
|
+ private void showListGame(){
|
|
|
+ SelfPopupWindow.newInstance()
|
|
|
+ .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();
|
|
|
+ SelfPopupWindow.newInstance().hidePop();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ new com.sheep.gamegroup.view.adapter.ArrayAdapter<GameAccountEntity>(activity, R.layout.dialog_item_game_list, gameAccountEntity) {
|
|
|
+ @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 + "");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .initPopup()
|
|
|
+ .showPop();
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 游戏列表显示
|
|
|
+ */
|
|
|
+ private void showListAccount(){
|
|
|
+ SelfPopupWindow.newInstance()
|
|
|
+ .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();
|
|
|
+ SelfPopupWindow.newInstance().hidePop();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ new com.sheep.gamegroup.view.adapter.ArrayAdapter<Object>(activity, R.layout.dialog_item_game_list, gameAccountListEntity) {
|
|
|
+ @Override
|
|
|
+ public boolean convert(int position, View convertView, ViewGroup parent, Object item) {
|
|
|
+ final TextView name_tv = ViewFindUtils.find(convertView, R.id.name_tv);
|
|
|
+ name_tv.setText(item + "");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .initPopup()
|
|
|
+ .showPop();
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 平台显示
|
|
|
+ */
|
|
|
+ private void showPlotFormList() {
|
|
|
+ SelfPopupWindow.newInstance()
|
|
|
+ .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;
|
|
|
+ }
|
|
|
+ SelfPopupWindow.newInstance().hidePop();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ new com.sheep.gamegroup.view.adapter.ArrayAdapter<Object>(activity, R.layout.dialog_item_game_list, gamePlatorEntity) {
|
|
|
+ @Override
|
|
|
+ public boolean convert(int position, View convertView, ViewGroup parent, Object item) {
|
|
|
+ final TextView name_tv = ViewFindUtils.find(convertView, R.id.name_tv);
|
|
|
+ name_tv.setText(item + "");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .initPopup()
|
|
|
+ .showPop();
|
|
|
+ }
|
|
|
}
|