|
|
@@ -1,5 +1,9 @@
|
|
|
package com.sheep.gamegroup.view.activity;
|
|
|
|
|
|
+import android.annotation.SuppressLint;
|
|
|
+import android.app.Activity;
|
|
|
+import android.content.Intent;
|
|
|
+import android.net.Uri;
|
|
|
import android.support.v7.widget.AppCompatAutoCompleteTextView;
|
|
|
import android.support.v7.widget.LinearLayoutManager;
|
|
|
import android.support.v7.widget.RecyclerView;
|
|
|
@@ -17,8 +21,10 @@ import android.widget.ImageView;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.arialyy.aria.core.download.DownloadTask;
|
|
|
import com.kfzs.duanduan.event.BigEvent;
|
|
|
+import com.kfzs.duanduan.event.EventTypes;
|
|
|
import com.sheep.gamegroup.absBase.BaseActivity;
|
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
import com.sheep.gamegroup.model.entity.RecyleObj;
|
|
|
@@ -39,12 +45,14 @@ import com.sheep.gamegroup.view.adapter.ArrayAdapter;
|
|
|
import com.sheep.gamegroup.view.adapter.TryMakeMoneyAdp;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
+import com.sheep.jiuyan.samllsheep.utils.ClassFileHelper;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.G;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
|
|
|
|
|
|
import org.greenrobot.eventbus.EventBus;
|
|
|
import org.greenrobot.eventbus.Subscribe;
|
|
|
|
|
|
+import java.io.File;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Locale;
|
|
|
@@ -56,6 +64,7 @@ import rx.functions.Action1;
|
|
|
import rx.schedulers.Schedulers;
|
|
|
|
|
|
import static com.sheep.gamegroup.util.UMConfigUtils.Event.SEARCH_GAME_COMMIT;
|
|
|
+import static com.sheep.gamegroup.view.adapter.TryMakeMoneyAdp.PUBLIC_TAG_PREFIX_TEXTVIEW_LIST;
|
|
|
|
|
|
/**
|
|
|
* Created by realicing on 2018/04/.
|
|
|
@@ -76,6 +85,8 @@ public class ActSearchGame extends BaseActivity {
|
|
|
@BindView(R.id.download_mgr_empty_view)
|
|
|
View download_mgr_empty_view;
|
|
|
|
|
|
+ private int type;//1:小米游戏过来
|
|
|
+
|
|
|
@Override
|
|
|
protected int getLayoutId() {
|
|
|
return R.layout.act_search_game;
|
|
|
@@ -85,6 +96,7 @@ public class ActSearchGame extends BaseActivity {
|
|
|
|
|
|
@Override
|
|
|
public void initView() {
|
|
|
+ type = getIntent().getIntExtra("where_come", 0);
|
|
|
EventBus.getDefault().register(this);
|
|
|
activity = this;
|
|
|
TitleBarUtils.getInstance()
|
|
|
@@ -115,10 +127,10 @@ public class ActSearchGame extends BaseActivity {
|
|
|
// search_game_input.setThreshold(1);
|
|
|
}
|
|
|
|
|
|
- private AdbCommonRecycler<TaskReleaseEty> adapter;
|
|
|
+ private AdbCommonRecycler<Object> adapter;
|
|
|
private void initList() {
|
|
|
search_game_list.setLayoutManager(new LinearLayoutManager(activity));
|
|
|
- adapter = new AdbCommonRecycler<TaskReleaseEty>(activity, list) {
|
|
|
+ adapter = new AdbCommonRecycler<Object>(activity, list) {
|
|
|
|
|
|
@Override
|
|
|
public int getViewIdByType(int type) {
|
|
|
@@ -126,12 +138,10 @@ public class ActSearchGame extends BaseActivity {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void convert(ViewHolder holder, final TaskReleaseEty item) {
|
|
|
+ public void convert(ViewHolder holder, final Object item) {
|
|
|
View itemView = holder.itemView;
|
|
|
- final TaskEty taskEty;
|
|
|
- if (item == null || (taskEty = item.getTask()) == null) {
|
|
|
+ if(item == null)
|
|
|
return;
|
|
|
- }
|
|
|
ImageView find_information_game_icon = (ImageView) itemView.findViewById(R.id.find_information_game_icon);
|
|
|
TextView find_information_game_name = (TextView) itemView.findViewById(R.id.find_information_game_name);
|
|
|
TextView find_information_game_surplus = (TextView) itemView.findViewById(R.id.find_information_game_surplus);
|
|
|
@@ -139,21 +149,46 @@ public class ActSearchGame extends BaseActivity {
|
|
|
TextView find_information_game_yuan = (TextView) itemView.findViewById(R.id.find_information_game_yuan);
|
|
|
TextView find_information_game_task_bottom = (TextView) itemView.findViewById(R.id.find_information_game_task_bottom);
|
|
|
TextView find_information_game_task_top = (TextView) itemView.findViewById(R.id.find_information_game_task_top);
|
|
|
- ViewUtil.centerImage(find_information_game_icon, taskEty.getIcon());
|
|
|
- ViewUtil.setText(find_information_game_name, item.getName());
|
|
|
- ViewUtil.setText(find_information_game_surplus);
|
|
|
- ViewUtil.setText(find_information_game_time, taskEty.getDetailShow());
|
|
|
- find_information_game_yuan.setVisibility(View.INVISIBLE);//这里必须为INVISIBLE,因为要显示两个按钮,下面的按钮位置不动
|
|
|
- find_information_game_task_top.setVisibility(View.VISIBLE);
|
|
|
- find_information_game_task_top.setText("立即充值");
|
|
|
- find_information_game_task_top.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View view) {
|
|
|
- ViewUtil.showGamePayAccount(activity, taskEty.getThird_task_id(), item.getName());
|
|
|
+
|
|
|
+ if(item instanceof TaskReleaseEty){
|
|
|
+ final TaskReleaseEty items = (TaskReleaseEty) item;
|
|
|
+ final TaskEty taskEty;
|
|
|
+ if ((taskEty = items.getTask()) == null) {
|
|
|
+ return;
|
|
|
}
|
|
|
- });
|
|
|
- item.getDownloadHelper().updateDownloadTaskView(activity, taskEty, find_information_game_task_bottom);
|
|
|
- find_information_game_task_bottom.setTag("PUBLIC_TAG_PREFIX_TEXTVIEW_LIST" + taskEty.getDownload_link());
|
|
|
+ ViewUtil.centerImage(find_information_game_icon, taskEty.getIcon());
|
|
|
+ ViewUtil.setText(find_information_game_name, items.getName());
|
|
|
+ ViewUtil.setText(find_information_game_surplus);
|
|
|
+ ViewUtil.setText(find_information_game_time, taskEty.getDetailShow());
|
|
|
+ find_information_game_yuan.setVisibility(View.INVISIBLE);//这里必须为INVISIBLE,因为要显示两个按钮,下面的按钮位置不动
|
|
|
+ find_information_game_task_top.setVisibility(View.VISIBLE);
|
|
|
+ find_information_game_task_top.setText("立即充值");
|
|
|
+ find_information_game_task_top.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ ViewUtil.showGamePayAccount(activity, taskEty.getThird_task_id(), items.getName());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ items.getDownloadHelper().updateDownloadTaskView(activity, taskEty, find_information_game_task_bottom);
|
|
|
+ find_information_game_task_bottom.setTag("PUBLIC_TAG_PREFIX_TEXTVIEW_LIST" + taskEty.getDownload_link());
|
|
|
+ }else if(item instanceof XiaomiGameEntity){
|
|
|
+ final XiaomiGameEntity items = (XiaomiGameEntity) item;
|
|
|
+ ViewUtil.centerImage(find_information_game_icon, items.getIcon());
|
|
|
+ ViewUtil.setText(find_information_game_name, items.getName());
|
|
|
+ ViewUtil.setText(find_information_game_surplus);
|
|
|
+ ViewUtil.setText(find_information_game_time, "");
|
|
|
+ find_information_game_yuan.setVisibility(View.INVISIBLE);//这里必须为INVISIBLE,因为要显示两个按钮,下面的按钮位置不动
|
|
|
+ find_information_game_task_top.setVisibility(View.VISIBLE);
|
|
|
+ if(items.getReceive_account() == 0){//未领取账号
|
|
|
+ CommonUtil.getInstance()
|
|
|
+ .xiaomiRevieceAcctoun(find_information_game_task_top, items, activity);
|
|
|
+ }else {
|
|
|
+ items.getDownloadHelper().updateDownloadTaskView((Activity) activity, items, find_information_game_task_top);
|
|
|
+ find_information_game_task_top.setTag(PUBLIC_TAG_PREFIX_TEXTVIEW_LIST + items.getDownload_url());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
};
|
|
|
search_game_list.setAdapter(adapter);
|
|
|
@@ -223,37 +258,42 @@ public class ActSearchGame extends BaseActivity {
|
|
|
|
|
|
List<SearchGameRecord> searchGameRecordList = new ArrayList<>();
|
|
|
List<TaskReleaseEty> hotList = new ArrayList<>();
|
|
|
- List<TaskReleaseEty> list = new ArrayList<>();
|
|
|
+ List<Object> list = new ArrayList<>();
|
|
|
|
|
|
@Override
|
|
|
public void initData() {
|
|
|
//初始化搜索历史
|
|
|
- List<SearchGameRecord> newSgrList = MyDbManager.getInstance().getAllSearchGameRecord();
|
|
|
+ List<SearchGameRecord> newSgrList = MyDbManager.getInstance().getAllSearchGameRecord(type);
|
|
|
ListUtil.addAll(searchGameRecordList, newSgrList);
|
|
|
inputAdapter.notifyDataSetChanged();
|
|
|
- //初始化热门列表
|
|
|
- SheepApp.getInstance().getNetComponent().getApiService()
|
|
|
- .releaseTask(1, 9,
|
|
|
- SheepApp.getInstance().getConnectAddress().getPlatForm(), 1,
|
|
|
- 0, 0,
|
|
|
- "1002,1003,1004", 3)
|
|
|
- .subscribeOn(Schedulers.io())
|
|
|
- .observeOn(AndroidSchedulers.mainThread())
|
|
|
- .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.mContext) {
|
|
|
- @Override
|
|
|
- public void onError(BaseMessage baseMessage) {
|
|
|
- CommonUtil.getInstance().updateEmptyView(download_mgr_empty_view, true);
|
|
|
- search_game_hot.setVisibility(View.GONE);
|
|
|
- search_game_list.setVisibility(View.GONE);
|
|
|
- }
|
|
|
+ if(type == 1){
|
|
|
+ search_game_hot.setVisibility(View.GONE);
|
|
|
+ }else {
|
|
|
+ //初始化热门列表
|
|
|
+ SheepApp.getInstance().getNetComponent().getApiService()
|
|
|
+ .releaseTask(1, 9,
|
|
|
+ SheepApp.getInstance().getConnectAddress().getPlatForm(), 1,
|
|
|
+ 0, 0,
|
|
|
+ "1002,1003,1004", 3)
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.mContext) {
|
|
|
+ @Override
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
+ CommonUtil.getInstance().updateEmptyView(download_mgr_empty_view, true);
|
|
|
+ search_game_hot.setVisibility(View.GONE);
|
|
|
+ search_game_list.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onNext(BaseMessage baseMessage) {
|
|
|
+ List<TaskReleaseEty> newList = baseMessage.getDatas(TaskReleaseEty.class);
|
|
|
+ ListUtil.addAll(hotList, newList);
|
|
|
+ hotAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public void onNext(BaseMessage baseMessage) {
|
|
|
- List<TaskReleaseEty> newList = baseMessage.getDatas(TaskReleaseEty.class);
|
|
|
- ListUtil.addAll(hotList, newList);
|
|
|
- hotAdapter.notifyDataSetChanged();
|
|
|
- }
|
|
|
- });
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -278,6 +318,7 @@ public class ActSearchGame extends BaseActivity {
|
|
|
SearchGameRecord searchGameRecord = new SearchGameRecord();
|
|
|
searchGameRecord.setInput(inputText);
|
|
|
searchGameRecord.setTime(System.currentTimeMillis());
|
|
|
+ searchGameRecord.setType(type);
|
|
|
MyDbManager.getInstance().saveOrUpdate(searchGameRecord);
|
|
|
searchGameRecordList.add(searchGameRecord);
|
|
|
// initInput();
|
|
|
@@ -287,27 +328,51 @@ public class ActSearchGame extends BaseActivity {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- CommonUtil.getInstance()
|
|
|
- .gameTask(activity, "1002,1003,1004", inputText, new Action1<BaseMessage>() {
|
|
|
- @Override
|
|
|
- public void call(BaseMessage baseMessage) {
|
|
|
- try {
|
|
|
- if(baseMessage == null){
|
|
|
-
|
|
|
- G.showToast("暂无游戏");
|
|
|
- list.clear();
|
|
|
- notifyDataSetChanged();
|
|
|
- }else {
|
|
|
- List<TaskReleaseEty> newList = baseMessage.getDatas(TaskReleaseEty.class);
|
|
|
- list.clear();
|
|
|
- ListUtil.addAll(list, newList);
|
|
|
- notifyDataSetChanged();
|
|
|
+ if(type == 1){
|
|
|
+ CommonUtil.getInstance()
|
|
|
+ .xiaomiGame(activity,1, 100, inputText, new Action1<BaseMessage>() {
|
|
|
+ @Override
|
|
|
+ public void call(BaseMessage baseMessage) {
|
|
|
+ try {
|
|
|
+ if(baseMessage == null){
|
|
|
+
|
|
|
+ G.showToast("暂无游戏");
|
|
|
+ list.clear();
|
|
|
+ notifyDataSetChanged();
|
|
|
+ }else {
|
|
|
+ List<XiaomiGameEntity> newList = baseMessage.getDatas(XiaomiGameEntity.class);
|
|
|
+ list.clear();
|
|
|
+ ListUtil.addAll(list, newList);
|
|
|
+ notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
}
|
|
|
- }
|
|
|
- });
|
|
|
+ });
|
|
|
+ }else {
|
|
|
+ CommonUtil.getInstance()
|
|
|
+ .gameTask(activity, "1002,1003,1004", inputText, new Action1<BaseMessage>() {
|
|
|
+ @Override
|
|
|
+ public void call(BaseMessage baseMessage) {
|
|
|
+ try {
|
|
|
+ if(baseMessage == null){
|
|
|
+
|
|
|
+ G.showToast("暂无游戏");
|
|
|
+ list.clear();
|
|
|
+ notifyDataSetChanged();
|
|
|
+ }else {
|
|
|
+ List<TaskReleaseEty> newList = baseMessage.getDatas(TaskReleaseEty.class);
|
|
|
+ list.clear();
|
|
|
+ ListUtil.addAll(list, newList);
|
|
|
+ notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void notifyDataSetChanged() {
|