Merge branch '2.0' of https://git.oschina.net/dreamhua/GH-ASSISTv1.45 into 2.0
Conflicts: app/src/main/java/com/gh/gamecenter/NewsDetailActivity.java app/src/main/res/drawable/progressbar_normal_radius_style.xml app/src/main/res/layout/fragment_news.xml app/src/main/res/layout/plugin_container_fragments.xml
This commit is contained in:
958
app/src/main/java/com/gh/gamecenter/GameDetailsActivity.java
Normal file
958
app/src/main/java/com/gh/gamecenter/GameDetailsActivity.java
Normal file
@ -0,0 +1,958 @@
|
||||
//package com.gh.gamecenter;
|
||||
//
|
||||
//import android.content.Context;
|
||||
//import android.content.Intent;
|
||||
//import android.graphics.Color;
|
||||
//import android.os.Bundle;
|
||||
//import android.os.Handler;
|
||||
//import android.support.v7.widget.LinearLayoutManager;
|
||||
//import android.support.v7.widget.RecyclerView;
|
||||
//import android.text.TextUtils;
|
||||
//import android.view.LayoutInflater;
|
||||
//import android.view.View;
|
||||
//import android.view.ViewGroup;
|
||||
//import android.widget.ImageView;
|
||||
//import android.widget.LinearLayout;
|
||||
//import android.widget.ProgressBar;
|
||||
//import android.widget.RelativeLayout;
|
||||
//import android.widget.TextView;
|
||||
//import android.widget.Toast;
|
||||
//
|
||||
//import com.android.volley.NoConnectionError;
|
||||
//import com.android.volley.Response;
|
||||
//import com.android.volley.TimeoutError;
|
||||
//import com.android.volley.VolleyError;
|
||||
//import com.gh.base.AppController;
|
||||
//import com.gh.base.BaseActivity;
|
||||
//import com.gh.common.constant.Config;
|
||||
//import com.gh.common.util.ConcernUtils;
|
||||
//import com.gh.common.util.DataUtils;
|
||||
//import com.gh.common.util.DialogUtils;
|
||||
//import com.gh.common.util.DisplayUtils;
|
||||
//import com.gh.common.util.FileUtils;
|
||||
//import com.gh.common.util.ImageUtils;
|
||||
//import com.gh.common.util.MD5Utils;
|
||||
//import com.gh.common.util.NetworkUtils;
|
||||
//import com.gh.common.util.PackageUtils;
|
||||
//import com.gh.common.util.PlatformUtils;
|
||||
//import com.gh.common.util.Utils;
|
||||
//import com.gh.common.view.DownloadDialog;
|
||||
//import com.gh.common.view.HorizontalItemDecoration;
|
||||
//import com.gh.download.DataWatcher;
|
||||
//import com.gh.download.DownloadEntry;
|
||||
//import com.gh.download.DownloadManager;
|
||||
//import com.gh.gamecenter.entity.ApkEntity;
|
||||
//import com.gh.gamecenter.entity.GameDetailsEntity;
|
||||
//import com.gh.gamecenter.entity.GameEntity;
|
||||
//import com.gh.gamecenter.entity.NewsEntity;
|
||||
//import com.gh.gamecenter.eventbus.EBNewsType;
|
||||
//import com.gh.gamecenter.eventbus.EBPutUrl;
|
||||
//import com.gh.gamecenter.eventbus.EBRedDot;
|
||||
//import com.gh.gamecenter.manager.ConcernManager;
|
||||
//import com.gh.gamecenter.manager.DataCollectionManager;
|
||||
//import com.gh.gamecenter.manager.PackageManager;
|
||||
//import com.gh.gamecenter.volley.extended.JsonArrayExtendedRequest;
|
||||
//import com.gh.gamecenter.volley.extended.JsonObjectExtendedRequest;
|
||||
//import com.google.gson.Gson;
|
||||
//import com.google.gson.reflect.TypeToken;
|
||||
//
|
||||
//import org.json.JSONArray;
|
||||
//import org.json.JSONException;
|
||||
//import org.json.JSONObject;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.HashMap;
|
||||
//import java.util.Map;
|
||||
//
|
||||
//import de.greenrobot.event.EventBus;
|
||||
//
|
||||
///**
|
||||
// * Created by khy on 2016/8/12.
|
||||
// */
|
||||
//public class GameDetailsActivity extends BaseActivity implements View.OnClickListener{
|
||||
//
|
||||
// private RecyclerView detailsRecyclerView;
|
||||
// private GameDetailsAdapter detailsAdapter;
|
||||
// private LinearLayout llLoading;
|
||||
// private LinearLayout noConnection;
|
||||
// private TextView tvDowload,tvPer;
|
||||
// private ImageView iv_share;
|
||||
// private ProgressBar progressBar;
|
||||
//
|
||||
// private GameDetailsEntity entity;
|
||||
// private GameEntity gameEntity;
|
||||
// private DownloadEntry downloadEntry;
|
||||
// private ConcernManager concernManager;
|
||||
//
|
||||
// private String gameId ;
|
||||
// private String entrance;
|
||||
//
|
||||
// private int concernCode = 0;//0关注不做操作,1添加关注,2删除关注
|
||||
//
|
||||
// private boolean isConcern = false;
|
||||
//
|
||||
// private Handler handler = new Handler();
|
||||
//
|
||||
// private DataWatcher dataWatcher = new DataWatcher() {
|
||||
// @Override
|
||||
// public void onDataChanged(HashMap<String, DownloadEntry> downloadingEntries) {
|
||||
// if (gameEntity != null && gameEntity.getApk().size() == 1) {
|
||||
// String url = gameEntity.getApk().get(0).getUrl();
|
||||
// for (Map.Entry<String, DownloadEntry> entry : downloadingEntries
|
||||
// .entrySet()) {
|
||||
// if (url.equals(entry.getValue().getUrl())) {
|
||||
// if (!"pause".equals(DownloadManager.getInstance(GameDetailsActivity.this).getStatus(entry.getValue().getUrl()))) {
|
||||
// downloadEntry = entry.getValue();
|
||||
// invalidate();
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// @Override
|
||||
// protected void onCreate(Bundle savedInstanceState) {
|
||||
// super.onCreate(savedInstanceState);
|
||||
//
|
||||
// View contentView = View.inflate(this, R.layout.activity_new_gamedetails, null);
|
||||
//
|
||||
// RelativeLayout reuse_actionbar = (RelativeLayout) contentView.findViewById(R.id.reuse_actionbar);
|
||||
// iv_share = new ImageView(this);
|
||||
// iv_share.setImageResource(R.drawable.share_icon);
|
||||
// RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
|
||||
// DisplayUtils.dip2px(this, 20), DisplayUtils.dip2px(this, 20));
|
||||
// params.addRule( RelativeLayout.CENTER_VERTICAL);
|
||||
// params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT );
|
||||
// params.setMargins(0, 0, DisplayUtils.dip2px(this, 10), 0);
|
||||
// reuse_actionbar.addView(iv_share,params);
|
||||
//
|
||||
// gameId = getIntent().getStringExtra("gameId");
|
||||
// entrance = getIntent().getStringExtra("entrance");
|
||||
// if (gameId != null) {
|
||||
//
|
||||
// } else {
|
||||
// gameEntity = (GameEntity) AppController.get("GameEntity", true);
|
||||
// gameId = gameEntity.getId();
|
||||
// }
|
||||
//
|
||||
// if (gameEntity != null && gameEntity.getName() != null) {
|
||||
// init(contentView, gameEntity.getName());
|
||||
// } else {
|
||||
// init(contentView);
|
||||
// }
|
||||
//
|
||||
// //初始化关注
|
||||
// concernManager = new ConcernManager(getApplicationContext());
|
||||
// for (int i = 0; i < concernManager.getConcernGame().size(); i++) {
|
||||
// if (concernManager.getConcernGame().get(i).getId().equals(gameId)){
|
||||
// isConcern = true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// tvDowload = (TextView) findViewById(R.id.gamedetails_tv_download);
|
||||
// progressBar = (ProgressBar) findViewById(R.id.gamedetails_progressbar);
|
||||
// llLoading = (LinearLayout) findViewById(R.id.gamedetails_ll_loading);
|
||||
// tvPer = (TextView) findViewById(R.id.gamedetails_tv_per);
|
||||
// noConnection = (LinearLayout) findViewById(R.id.reuse_no_connection);
|
||||
// detailsRecyclerView = (RecyclerView) findViewById(R.id.gamedetails_rv);
|
||||
// detailsAdapter = new GameDetailsAdapter(this);
|
||||
// detailsRecyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||
// detailsRecyclerView.setAdapter(detailsAdapter);
|
||||
// if (gameEntity != null) {
|
||||
// initDowload();
|
||||
// } else {
|
||||
//
|
||||
// }
|
||||
// tvDowload.setOnClickListener(this);
|
||||
// tvPer.setOnClickListener(this);
|
||||
// noConnection.setOnClickListener(this);
|
||||
// iv_share.setOnClickListener(this);
|
||||
//
|
||||
// }
|
||||
// @Override
|
||||
// public void onClick(final View v) {
|
||||
// switch (v.getId()){
|
||||
// case R.id.gamedetails_tv_download:
|
||||
// Map<String, Object> kv0 = new HashMap<String, Object>();
|
||||
// kv0.put("点击", "下载");
|
||||
// DataUtils.onEvent(GameDetailsActivity.this, "插件数据", gameEntity.getName(),
|
||||
// kv0);
|
||||
// if (gameEntity.getApk() != null && !gameEntity.getApk().isEmpty()) {
|
||||
// if (NetworkUtils.isWifiConnected(this)) {
|
||||
// download(v);
|
||||
// } else {
|
||||
// DialogUtils.showDownloadDialog(this, new DialogUtils.ConfiremListener() {
|
||||
// @Override
|
||||
// public void onConfirem() {
|
||||
// download(v);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// } else {
|
||||
// toast("稍等片刻~!游戏正在上传中...");
|
||||
// }
|
||||
// break;
|
||||
// case R.id.gamedetails_tv_per:
|
||||
// String str = tvPer.getText().toString();
|
||||
// if ("下载中".equals(str)) {
|
||||
// startActivity(new Intent(this, DownloadManagerActivity.class));
|
||||
// } else if ("安装".equals(str)) {
|
||||
// final String path = downloadEntry.getPath();
|
||||
// PackageManager manager = new PackageManager(this);
|
||||
// if (manager.launchSetup(path)) {
|
||||
// startActivity(PackageUtils.getInstallIntent(path));
|
||||
// } else {
|
||||
// DialogUtils.showPluginDialog(this, new DialogUtils.ConfiremListener() {
|
||||
// @Override
|
||||
// public void onConfirem() {
|
||||
// MainActivity.uninstallMap.put(
|
||||
// PackageUtils.getPackageNameByPath(GameDetailsActivity.this, path), path);
|
||||
// startActivity(PackageUtils.getUninstallIntent(GameDetailsActivity.this,
|
||||
// path));
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// case R.id.reuse_no_connection:
|
||||
// noConnection.setVisibility(View.GONE);
|
||||
// llLoading.setVisibility(View.VISIBLE);
|
||||
// handler.postDelayed(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// getGameDetail();
|
||||
// }
|
||||
// },1000);
|
||||
// break;
|
||||
// }
|
||||
// if (v == iv_share){
|
||||
// Map<String, Object> kv = new HashMap<String, Object>();
|
||||
// kv.put("点击", "分享");
|
||||
// DataUtils.onEvent(this, "插件数据", gameEntity.getName(), kv);
|
||||
//
|
||||
// Map<String, Object> map = new HashMap<String, Object>();
|
||||
// map.put("location", "分享");
|
||||
// map.put("createOn", System.currentTimeMillis() / 1000);
|
||||
// map.put("news", gameEntity.getName());
|
||||
// map.put("page", "游戏详情");
|
||||
// DataCollectionManager.onEvent(this, "click-item", map);
|
||||
//
|
||||
// String url = "http://112.124.59.31/game_center/static/game_"
|
||||
// + gameEntity.getId() + ".html";
|
||||
// showShare(url, gameEntity.getName(), gameEntity.getIcon(), null, gameEntity.getTag(), entrance, "游戏");
|
||||
// }
|
||||
// }
|
||||
// private void invalidate() {
|
||||
// progressBar.setProgress((int) (downloadEntry.getPercent() * 10));
|
||||
// tvPer.setTextColor(0xFFFFFFFF);
|
||||
// switch (downloadEntry.getStatus()) {
|
||||
// case downloading:
|
||||
// case pause:
|
||||
// case timeout:
|
||||
// case neterror:
|
||||
// case waiting:
|
||||
// tvPer.setText("下载中");
|
||||
// break;
|
||||
// case done:
|
||||
// EventBus.getDefault().post(
|
||||
// new EBPutUrl(gameEntity.getApk().get(0).getPackageName(),
|
||||
// downloadEntry.getUrl()));
|
||||
// tvPer.setText("安装");
|
||||
// break;
|
||||
// case cancel:
|
||||
// case hijack:
|
||||
// tvDowload.setVisibility(View.VISIBLE);
|
||||
// progressBar.setVisibility(View.GONE);
|
||||
// tvPer.setVisibility(View.GONE);
|
||||
// if (TextUtils.isEmpty(entity.getDownloadAddWord())) {
|
||||
// tvDowload.setText("下载《" + gameEntity.getName() + "》");
|
||||
// } else {
|
||||
// tvDowload.setText("下载《" + gameEntity.getName() + "》"
|
||||
// + entity.getDownloadAddWord());
|
||||
// }
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void initDowload() {
|
||||
// if (gameEntity == null || gameEntity.getApk() == null || gameEntity.getApk().isEmpty()) {
|
||||
// tvDowload.setText("暂无下载");
|
||||
// tvDowload.setBackgroundResource(R.drawable.textview_gray_style);
|
||||
// tvDowload.setTextColor(0xFF999999);
|
||||
// tvDowload.setClickable(false);
|
||||
// } else {
|
||||
// boolean isInstalled = false;
|
||||
// if (gameEntity.getApk() != null
|
||||
// && gameEntity.getApk().size() == 1
|
||||
// && PackageManager.isInstalled(gameEntity.getApk().get(0)
|
||||
// .getPackageName())) {
|
||||
// isInstalled = true;
|
||||
// }
|
||||
// tvDowload.setVisibility(View.VISIBLE);
|
||||
// progressBar.setVisibility(View.GONE);
|
||||
// tvPer.setVisibility(View.GONE);
|
||||
// if (isInstalled) {
|
||||
// if (TextUtils.isEmpty(gameEntity.getDownloadAddWord())) {
|
||||
// tvDowload.setText("启动《" + gameEntity.getName() + "》");
|
||||
// } else {
|
||||
// tvDowload.setText("启动《" + gameEntity.getName() + "》" + gameEntity.getDownloadAddWord());
|
||||
// }
|
||||
// } else {
|
||||
// if (TextUtils.isEmpty(gameEntity.getDownloadAddWord())) {
|
||||
// tvDowload.setText("下载《" + gameEntity.getName() + "》");
|
||||
// } else {
|
||||
// tvDowload.setText("下载《" + gameEntity.getName() + "》" + gameEntity.getDownloadAddWord());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// private void download(View v) {
|
||||
// if (gameEntity.getApk().size() == 1) {
|
||||
// if (tvDowload.getText().toString().contains("启动")) {
|
||||
//
|
||||
// Map<String, Object> kv = new HashMap<String, Object>();
|
||||
// kv.put("版本", gameEntity.getApk().get(0).getPlatform());
|
||||
// DataUtils.onEvent(GameDetailsActivity.this, "游戏启动",
|
||||
// gameEntity.getName(), kv);
|
||||
//
|
||||
// PackageUtils.launchApplicationByPackageName(
|
||||
// this, gameEntity.getApk().get(0).getPackageName());
|
||||
// } else {
|
||||
// ApkEntity apkEntity = gameEntity.getApk().get(0);
|
||||
// String msg = FileUtils.isCanDownload(apkEntity.getSize());
|
||||
// if (TextUtils.isEmpty(msg)) {
|
||||
// Map<String, Object> kv = new HashMap<String, Object>();
|
||||
// kv.put("版本", apkEntity.getPlatform());
|
||||
// kv.put("状态", "下载开始");
|
||||
// DataUtils.onEvent(GameDetailsActivity.this,
|
||||
// "游戏下载", gameEntity.getName(), kv);
|
||||
//
|
||||
// Map<String, Object> kv2 = new HashMap<String, Object>();
|
||||
// kv2.put("版本", apkEntity.getPlatform());
|
||||
// kv2.put("状态", "下载开始");
|
||||
// kv2.put("位置", entrance + "-游戏详情-开始");
|
||||
// DataUtils.onEvent(GameDetailsActivity.this,
|
||||
// "游戏下载位置", gameEntity.getName(), kv2);
|
||||
//
|
||||
// Map<String, Object> kv3 = new HashMap<String, Object>();
|
||||
// kv3.put(entrance, "下载数");
|
||||
// kv3.put(entrance, "下载开始");
|
||||
// DataUtils.onEvent(GameDetailsActivity.this,
|
||||
// "应用数据", gameEntity.getName(), kv3);
|
||||
//
|
||||
// Map<String, Object> map = new HashMap<String, Object>();
|
||||
// map.put("game", gameEntity.getName());
|
||||
// map.put("method", "正常");
|
||||
// map.put("platform",
|
||||
// PlatformUtils.getInstance(
|
||||
// this)
|
||||
// .getPlatformName(
|
||||
// gameEntity.getApk().get(0)
|
||||
// .getPlatform()));
|
||||
// map.put("status", "开始");
|
||||
// map.put("location", "游戏详情:" + gameEntity.getName());
|
||||
// map.put("from", entrance);
|
||||
// map.put("network",
|
||||
// NetworkUtils.getConnectedType(this));
|
||||
// map.put("createdOn",
|
||||
// System.currentTimeMillis() / 1000);
|
||||
// DataCollectionManager.onEvent(this, "download", map);
|
||||
//
|
||||
// DownloadEntry entry = new DownloadEntry();
|
||||
//
|
||||
// entry.setUrl(apkEntity.getUrl());
|
||||
// entry.setName(gameEntity.getName());
|
||||
// entry.setPath(FileUtils.getDownloadPath(
|
||||
// GameDetailsActivity.this,
|
||||
// MD5Utils.getContentMD5(gameEntity.getName()
|
||||
// + "_"
|
||||
// + System.currentTimeMillis())
|
||||
// + ".apk"));
|
||||
// HashMap<String, String> meta = new HashMap<String, String>();
|
||||
// meta.put("ETag", apkEntity.getEtag());
|
||||
// meta.put("icon", gameEntity.getIcon());
|
||||
// meta.put("platform", apkEntity.getPlatform());
|
||||
// meta.put("gameId", gameEntity.getId());
|
||||
// meta.put("entrance", entrance + "-游戏详情");
|
||||
// meta.put("location", "游戏详情:" + gameEntity.getName());
|
||||
// entry.setMeta(meta);
|
||||
//
|
||||
// DownloadManager.getInstance(this).add(entry);
|
||||
//
|
||||
// EventBus.getDefault().post(new EBRedDot(1));
|
||||
//
|
||||
// tvDowload.setVisibility(View.GONE);
|
||||
// progressBar.setVisibility(View.VISIBLE);
|
||||
// tvPer.setVisibility(View.VISIBLE);
|
||||
// progressBar.setProgress(0);
|
||||
// tvPer.setText("0.0%");
|
||||
//
|
||||
// DownloadManager.getInstance(this).putStatus(entry.getUrl(), "downloading");
|
||||
//
|
||||
// } else {
|
||||
// toast(msg);
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// DownloadDialog.getInstance(GameDetailsActivity.this)
|
||||
// .showPopupWindow(v, gameEntity,
|
||||
// entrance + "-游戏详情",
|
||||
// "游戏详情:" + gameEntity.getName());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void getGameNews() {
|
||||
// String url = Config.HOST + "v1d45/game/" + gameId + "/news?limit=3";
|
||||
// JsonArrayExtendedRequest request = new JsonArrayExtendedRequest(url,
|
||||
// new Response.Listener<JSONArray>() {
|
||||
// @Override
|
||||
// public void onResponse(JSONArray response) {
|
||||
// Utils.log(response.toString());
|
||||
// if (!isDestroy) {
|
||||
// Gson gson = new Gson();
|
||||
// ArrayList<NewsEntity> news = gson.fromJson(
|
||||
// response.toString(),
|
||||
// new TypeToken<ArrayList<NewsEntity>>() {
|
||||
// }.getType());
|
||||
// if (entity!= null && news != null) {
|
||||
// entity.setNews(news);
|
||||
// }
|
||||
// llLoading.setVisibility(View.GONE);
|
||||
// detailsAdapter.notifyDataSetChanged();
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// new Response.ErrorListener() {
|
||||
// @Override
|
||||
// public void onErrorResponse(VolleyError error) {
|
||||
// // 无网络连接和访问超时
|
||||
// if (error.getClass().equals(NoConnectionError.class)
|
||||
// || error.getClass().equals(TimeoutError.class)) {
|
||||
// if (!isDestroy) {
|
||||
// llLoading.setVisibility(View.GONE);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// AppController.addToRequestQueue(request, GameDetailsActivity.class);
|
||||
// }
|
||||
//
|
||||
// private void getGameDigest() {
|
||||
// String url = Config.HOST + "v1d45/game/" + gameId + "/digest";
|
||||
// JsonObjectExtendedRequest request = new JsonObjectExtendedRequest(url,
|
||||
// new Response.Listener<JSONObject>() {
|
||||
// @Override
|
||||
// public void onResponse(JSONObject response) {
|
||||
// Gson gson = new Gson();
|
||||
// gameEntity = gson.fromJson(response.toString(), GameEntity.class);
|
||||
// initDowload();
|
||||
// getGameDetail();
|
||||
// }
|
||||
// },
|
||||
// new Response.ErrorListener() {
|
||||
// @Override
|
||||
// public void onErrorResponse(VolleyError error) {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// AppController.addToRequestQueue(request, GameDetailsActivity.class);
|
||||
// }
|
||||
//
|
||||
// private void getGameDetail() {
|
||||
// String url = Config.HOST + "v2d0/game/" + gameId + "/detail";
|
||||
// JsonObjectExtendedRequest request = new JsonObjectExtendedRequest(url,
|
||||
// new Response.Listener<JSONObject>() {
|
||||
// @Override
|
||||
// public void onResponse(JSONObject response) {
|
||||
//
|
||||
// Utils.log(response.toString());
|
||||
// Gson gson = new Gson();
|
||||
// GameDetailsEntity gameDetailsEntity = gson
|
||||
// .fromJson(response.toString(), GameDetailsEntity.class);
|
||||
// if (entity != null && entity.getNews() != null) {
|
||||
// gameDetailsEntity.setNews(entity.getNews());
|
||||
// }
|
||||
// entity = gameDetailsEntity;
|
||||
// HashMap<String, ArrayList<String>> map = new HashMap<String, ArrayList<String>>();
|
||||
// if (!response.isNull("news_type")) {
|
||||
// try {
|
||||
// JSONArray newsType = response
|
||||
// .getJSONArray("news_type");
|
||||
// for (int i = 0, size = newsType.length(); i < size; i++) {
|
||||
// JSONObject jsonObject = newsType
|
||||
// .getJSONObject(i);
|
||||
// JSONArray subType = jsonObject
|
||||
// .getJSONArray("sub_type");
|
||||
// ArrayList<String> list = new ArrayList<String>();
|
||||
// for (int j = 0; j < subType.length(); j++) {
|
||||
// list.add(subType.getString(j));
|
||||
// }
|
||||
// map.put(jsonObject.getString("type"),
|
||||
// list);
|
||||
// }
|
||||
// } catch (JSONException e) {
|
||||
//
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// for (String type : map.keySet()) {
|
||||
// EventBus.getDefault().post(
|
||||
// new EBNewsType(type, map.get(type)));
|
||||
// }
|
||||
// llLoading.setVisibility(View.GONE);
|
||||
// noConnection.setVisibility(View.GONE);
|
||||
// detailsAdapter.notifyDataSetChanged();
|
||||
//
|
||||
// getGameNews();
|
||||
// }
|
||||
// },
|
||||
// new Response.ErrorListener() {
|
||||
// @Override
|
||||
// public void onErrorResponse(VolleyError error) {
|
||||
// noConnection.setVisibility(View.VISIBLE);
|
||||
// // 无网络连接和访问超时
|
||||
// }
|
||||
// });
|
||||
// AppController.addToRequestQueue(request, GameDetailsActivity.class);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void onResume() {
|
||||
// super.onResume();
|
||||
// if (gameEntity != null && gameEntity.getApk().size() == 1) {
|
||||
// if (PackageManager.isInstalled(gameEntity.getApk().get(0)
|
||||
// .getPackageName())) {
|
||||
// tvDowload.setVisibility(View.VISIBLE);
|
||||
// progressBar.setVisibility(View.GONE);
|
||||
// tvPer.setVisibility(View.GONE);
|
||||
// tvDowload.setText("启动《" + gameEntity.getName() + "》");
|
||||
// if (entity != null && TextUtils.isEmpty(entity.getDownloadAddWord())) {
|
||||
// tvDowload.setText("启动《" + gameEntity.getName()
|
||||
// + "》");
|
||||
// } else {
|
||||
// tvDowload.setText("启动《" + gameEntity.getName()
|
||||
// + "》" + gameEntity.getDownloadAddWord());
|
||||
// }
|
||||
// } else {
|
||||
// String url = gameEntity.getApk().get(0).getUrl();
|
||||
// for (DownloadEntry entry : DownloadManager.getInstance(this).getAll()) {
|
||||
// if (url.equals(entry.getUrl())) {
|
||||
// downloadEntry = entry;
|
||||
// tvDowload.setVisibility(View.GONE);
|
||||
// progressBar.setVisibility(View.VISIBLE);
|
||||
// tvPer.setVisibility(View.VISIBLE);
|
||||
// invalidate();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// DownloadManager.getInstance(this).addObserver(dataWatcher);
|
||||
// }
|
||||
// @Override
|
||||
// protected void onDestroy() {
|
||||
// super.onDestroy();
|
||||
// String uuid = ConcernUtils.uuid(this);
|
||||
// if (isConcern && concernCode ==2) {
|
||||
// //取消关注
|
||||
// ConcernUtils.deleteConcernData(Config.HOST + "v2d0/device/" + uuid + "/concern/" + gameId, new ConcernUtils.DownJsonListener() {
|
||||
// @Override
|
||||
// public void downSucced(String str) {
|
||||
// Utils.log("删除提交成功==游戏详情");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void downFailed() {
|
||||
// Utils.log("删除提交失败==游戏详情");
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// }else if (!isConcern && concernCode == 1) {
|
||||
// //添加关注
|
||||
// ConcernUtils.postConcernGameId(gameId, Config.HOST + "v2d0/device/" + uuid + "/concern", new ConcernUtils.DownJsonListener() {
|
||||
// @Override
|
||||
// public void downSucced(String str) {
|
||||
// Utils.log("关注提交成功==游戏详情");
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void downFailed() {
|
||||
// Utils.log("关注提交失败==游戏详情");
|
||||
// }
|
||||
// });
|
||||
// }else {
|
||||
// Utils.log("无关注操作==游戏详情");
|
||||
// }
|
||||
// gameId = null;
|
||||
// entrance = null;
|
||||
// detailsAdapter = null;
|
||||
// detailsRecyclerView = null;
|
||||
// llLoading = null;
|
||||
// noConnection = null;
|
||||
// entity = null;
|
||||
// gameEntity = null;
|
||||
// tvDowload = null;
|
||||
// tvPer = null;
|
||||
// progressBar = null;
|
||||
// downloadEntry = null;
|
||||
// concernManager = null;
|
||||
// handler = null;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public class GameDetailsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
|
||||
// private Context context;
|
||||
//
|
||||
// public GameDetailsAdapter(Context context) {
|
||||
// this.context = context;
|
||||
// if (gameEntity != null) {
|
||||
// getGameDetail();
|
||||
// } else {
|
||||
// getGameDigest();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getItemViewType(int position){
|
||||
// if (position == 0){
|
||||
// return 0;
|
||||
// } else if (entity.getTag() != null && entity.getTag().size() > 0 && position == 1) {
|
||||
// return 1;
|
||||
// } else if (entity.getNews() != null && entity.getNews().size() > 0
|
||||
// && (position == 1 || entity.getTag() != null && entity.getTag().size() > 0 && position == 2)) {
|
||||
// return 2;
|
||||
// } else if (entity.getGallery() != null && entity.getGallery().size() > 0) {
|
||||
// return 3;
|
||||
// } else {
|
||||
// return super.getItemViewType(position);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
// View view ;
|
||||
// switch (viewType){
|
||||
// case 0:
|
||||
// view = LayoutInflater.from(context).inflate(R.layout.gamedetails_rv_item_top,parent,false);
|
||||
// return new TopViewHolder(view);
|
||||
// case 1:
|
||||
// view = LayoutInflater.from(context).inflate(R.layout.gamedetails_rv_item_plugin,parent,false);
|
||||
// return new PluginViewHolder(view);
|
||||
// case 2:
|
||||
// view = LayoutInflater.from(context).inflate(R.layout.gamedetails_rv_item_zixun,parent,false);
|
||||
// return new ZiXunViewHolder(view);
|
||||
// case 3:
|
||||
// view = LayoutInflater.from(context).inflate(R.layout.gamedetails_rv_item_game,parent,false);
|
||||
// return new GameViewHolder(view);
|
||||
// default:
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
// if (holder instanceof TopViewHolder){
|
||||
// TopViewHolder topViewHolder = (TopViewHolder) holder;
|
||||
// initTopViewHolder(topViewHolder);
|
||||
// } else if (holder instanceof PluginViewHolder){
|
||||
// PluginViewHolder pluginViewHolder = (PluginViewHolder) holder;
|
||||
// initPluginViewHolder(pluginViewHolder);
|
||||
// } else if (holder instanceof ZiXunViewHolder){
|
||||
// ZiXunViewHolder ziXunViewHolder = (ZiXunViewHolder) holder;
|
||||
// initZiXunViewHolder(ziXunViewHolder);
|
||||
// } else if (holder instanceof GameViewHolder){
|
||||
// GameViewHolder gameViewHolder = (GameViewHolder) holder;
|
||||
// initGameViewHolder(gameViewHolder);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void initGameViewHolder(GameViewHolder gameViewHolder) {
|
||||
// gameViewHolder.gamepic_rv.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));
|
||||
// gameViewHolder.gamepic_rv.setAdapter(new GamePicAdapter());
|
||||
// gameViewHolder.gamepic_rv.addItemDecoration(new HorizontalItemDecoration(
|
||||
// context, 1, entity.getGallery().size()));
|
||||
// gameViewHolder.game_content.setText(entity.getDes());
|
||||
// }
|
||||
//
|
||||
// private void initZiXunViewHolder(ZiXunViewHolder ziXunViewHolder) {
|
||||
// LinearLayout llContainer = ziXunViewHolder.llContainer;
|
||||
// int childCount = llContainer.getChildCount();
|
||||
// if (entity.getNews().size() < 3) {
|
||||
// ziXunViewHolder.llMore.setVisibility(View.GONE);
|
||||
// }else if (entity.getNews().size() == 0) {
|
||||
// ziXunViewHolder.view.setVisibility(View.GONE);
|
||||
// }
|
||||
// if ( childCount == 0) {
|
||||
// for (int i = 0; i < entity.getNews().size(); i++) {
|
||||
// RelativeLayout rlChild = (RelativeLayout) View.inflate(context, R.layout.gamedetails_zixun_item, null);
|
||||
//
|
||||
// TextView tv_tag = (TextView) rlChild.findViewById(R.id.gamedetails_rv_item_zixun_tag);
|
||||
// ViewGroup.LayoutParams layoutParams = tv_tag.getLayoutParams();
|
||||
// layoutParams.width = DisplayUtils.dip2px(GameDetailsActivity.this,28);
|
||||
// layoutParams.height = DisplayUtils.dip2px(GameDetailsActivity.this,17);
|
||||
// tv_tag.setLayoutParams(layoutParams);
|
||||
// if ("活动".equals(entity.getNews().get(i).getType())){
|
||||
// tv_tag.setTextColor(Color.WHITE);
|
||||
// tv_tag.setBackgroundResource(R.drawable.textview_orange_style);
|
||||
// } else if ("公告".equals(entity.getNews().get(i).getType())){
|
||||
// tv_tag.setTextColor(Color.WHITE);
|
||||
// tv_tag.setBackgroundResource(R.drawable.textview_red_style);
|
||||
// } else {
|
||||
// tv_tag.setTextColor(Color.WHITE);
|
||||
// tv_tag.setBackgroundResource(R.drawable.textview_blue_style);
|
||||
// }
|
||||
// tv_tag.setText(entity.getNews().get(i).getType());
|
||||
//
|
||||
// TextView tv_title = (TextView) rlChild.findViewById(R.id.gamedetails_rv_item_zixun_title);
|
||||
// rlChild.setBackgroundResource(R.drawable.cardview_item_style);
|
||||
// tv_title.setText(entity.getNews().get(i).getTitle());
|
||||
//
|
||||
// llContainer.addView(rlChild);
|
||||
// final int finalI = i;
|
||||
// rlChild.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// Intent intent = new Intent(context,NewsActivity.class);
|
||||
// intent.putExtra("newsId",entity.getNews().get(finalI).getId());
|
||||
// intent.putExtra("entrance","游戏详情");
|
||||
// context.startActivity(intent);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// ziXunViewHolder.llMore.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// if (entity.getArticleTypes()!= null&&gameEntity.getId()!=null&&gameEntity.getName()!= null){
|
||||
// Intent intent = new Intent(context,GameNewsActivity.class);
|
||||
// intent.putExtra("articleTypes",entity.getArticleTypes());
|
||||
// intent.putExtra("gameName",gameEntity.getName());
|
||||
// intent.putExtra("gameId",gameId);
|
||||
// context.startActivity(intent);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// private void initPluginViewHolder(PluginViewHolder pluginViewHolder) {
|
||||
// LinearLayout llContainer = pluginViewHolder.llContainer;
|
||||
// int childCount = llContainer.getChildCount();
|
||||
// if (childCount == 0){
|
||||
// for (int i = 0; i < entity.getTag().size() + 1; i++) {
|
||||
// RelativeLayout rlChild = (RelativeLayout) View.inflate(context, R.layout.gamedetails_plugin_item, null);
|
||||
// ImageView iv = (ImageView) rlChild.findViewById(R.id.gamedetails_hint);
|
||||
// TextView tv_hint = (TextView) rlChild.findViewById(R.id.gamedetails_tv_hint);
|
||||
// TextView tv_content = (TextView) rlChild.findViewById(R.id.gamedetails_tv_content);
|
||||
// if (i == entity.getTag().size()) {
|
||||
// tv_content.setText(entity.getRemind());
|
||||
// tv_hint.setText("温馨提示");
|
||||
// } else {
|
||||
// tv_content.setText(entity.getTag().get(i).getDes());
|
||||
// tv_hint.setText(entity.getTag().get(i).getName());
|
||||
// ImageUtils.getInstance(context).display(entity.getTag().get(i).getIcon(),iv);
|
||||
// }
|
||||
// llContainer.addView(rlChild);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// private void initTopViewHolder(final TopViewHolder topViewHolder) {
|
||||
// topViewHolder.tv_info.setText(gameEntity.getBrief());
|
||||
// topViewHolder.tv_name.setText(gameEntity.getName());
|
||||
// ImageUtils.getInstance(context).display(gameEntity.getIcon(),topViewHolder.iv_game);
|
||||
// if (gameEntity.getApk() == null) {
|
||||
// ApkEntity apkEntity = gameEntity.getApk().get(0);
|
||||
// topViewHolder.tv_info.setText(String.format("V%s | %s", apkEntity.getVersion(), apkEntity.getSize()));
|
||||
// } else {
|
||||
// topViewHolder.tv_info.setText("");
|
||||
// }
|
||||
// topViewHolder.tv_concern.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// if ("关注".equals(topViewHolder.tv_concern.getText().toString())) {
|
||||
//
|
||||
// Map<String, Object> kv = new HashMap<>();
|
||||
// kv.put("状态", "关注");
|
||||
// DataUtils.onEvent(GameDetailsActivity.this, "游戏关注", gameEntity.getName(), kv);
|
||||
//
|
||||
// Map<String, Object> kv2 = new HashMap<>();
|
||||
// kv2.put("点击", "关注");
|
||||
// DataUtils.onEvent(GameDetailsActivity.this, "插件数据", gameEntity.getName(), kv2);
|
||||
//
|
||||
// Map<String, Object> map = new HashMap<>();
|
||||
// map.put("game", gameEntity.getName());
|
||||
// map.put("type", "关注");
|
||||
// map.put("createdOn", System.currentTimeMillis() / 1000);
|
||||
// DataCollectionManager.onEvent(GameDetailsActivity.this, "concern", map);
|
||||
// concernCode = 1;
|
||||
// concernManager.addByEntity(gameEntity);
|
||||
// topViewHolder.tv_concern.setText("取消关注");
|
||||
// topViewHolder.tv_concern.setBackgroundResource(R.drawable.border_red_bg);
|
||||
// topViewHolder.tv_concern.setTextColor(0xffbc2132);
|
||||
// Toast.makeText(context,"关注成功",Toast.LENGTH_SHORT).show();
|
||||
// } else {
|
||||
// Map<String, Object> kv2 = new HashMap<>();
|
||||
// kv2.put("点击", "取消关注");
|
||||
// DataUtils.onEvent(GameDetailsActivity.this, "插件数据", gameEntity.getName(), kv2);
|
||||
//
|
||||
// showCancelDialog(topViewHolder.tv_concern);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// }
|
||||
// private void showCancelDialog(final TextView attention) {
|
||||
// DialogUtils.showCancelDialog(context, new DialogUtils.ConfiremListener() {
|
||||
// @Override
|
||||
// public void onConfirem() {
|
||||
// Map<String, Object> kv = new HashMap<>();
|
||||
// kv.put("状态", "取消关注");
|
||||
// DataUtils.onEvent(GameDetailsActivity.this, "游戏关注",
|
||||
// gameEntity.getName(), kv);
|
||||
//
|
||||
// Map<String, Object> map = new HashMap<>();
|
||||
// map.put("game", gameEntity.getName());
|
||||
// map.put("type", "关注");
|
||||
// map.put("createdOn", System.currentTimeMillis() / 1000);
|
||||
// DataCollectionManager.onEvent(GameDetailsActivity.this,
|
||||
// "concern", map);
|
||||
//
|
||||
// concernCode = 2;
|
||||
// concernManager.deleteConcern(gameEntity.getId());
|
||||
// attention.setText("关注");
|
||||
// attention
|
||||
// .setBackgroundResource(R.drawable.textview_red_style);
|
||||
// attention.setTextColor(0xffffffff);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getItemCount() {
|
||||
// if (entity != null) {
|
||||
// int index = 1;
|
||||
// if (entity.getTag() != null && entity.getTag().size() > 0) {
|
||||
// index++;
|
||||
// }
|
||||
// if (entity.getNews() != null && entity.getNews().size() > 0) {
|
||||
// index++;
|
||||
// }
|
||||
// if (entity.getGallery() != null && entity.getGallery().size() > 0) {
|
||||
// index++;
|
||||
// }
|
||||
// return index;
|
||||
// } else {
|
||||
// return 0;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public class TopViewHolder extends RecyclerView.ViewHolder{
|
||||
//
|
||||
// TextView tv_name, tv_info, tv_concern;
|
||||
// ImageView iv_game;
|
||||
//
|
||||
// public TopViewHolder(View itemView) {
|
||||
// super(itemView);
|
||||
//
|
||||
// tv_name = (TextView) itemView.findViewById(R.id.gamedetails_game_name);
|
||||
// tv_concern = (TextView) itemView.findViewById(R.id.gamedetails_concern_btn);
|
||||
// tv_info = (TextView) itemView.findViewById(R.id.gamedetails_top_tv_info);
|
||||
// iv_game = (ImageView) itemView.findViewById(R.id.gamedetails_game_thumb);
|
||||
// if (isConcern) {
|
||||
// tv_concern.setText("取消关注");
|
||||
// tv_concern.setBackgroundResource(R.drawable.border_red_bg);
|
||||
// tv_concern.setTextColor(0xffbc2132);
|
||||
// } else {
|
||||
// tv_concern.setText("关注");
|
||||
// tv_concern.setBackgroundResource(R.drawable.textview_red_style);
|
||||
// tv_concern.setTextColor(0xffffffff);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public class PluginViewHolder extends RecyclerView.ViewHolder {
|
||||
// View view;
|
||||
// LinearLayout llContainer;
|
||||
// public PluginViewHolder(View itemView) {
|
||||
// super(itemView);
|
||||
// view = itemView;
|
||||
// llContainer = (LinearLayout) view.findViewById(R.id.gamedetails_rv_item_plugin_ll);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public class ZiXunViewHolder extends RecyclerView.ViewHolder {
|
||||
// View view;
|
||||
// LinearLayout llContainer;
|
||||
// LinearLayout llMore;
|
||||
// public ZiXunViewHolder(View itemView) {
|
||||
// super(itemView);
|
||||
// view = itemView;
|
||||
// llContainer = (LinearLayout) view.findViewById(R.id.gamedetails_rv_item_zixun_ll);
|
||||
// llMore = (LinearLayout) view.findViewById(R.id.gamedetails_rv_item_zixun_more);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public class GameViewHolder extends RecyclerView.ViewHolder {
|
||||
//
|
||||
// RecyclerView gamepic_rv;
|
||||
// TextView game_content;
|
||||
//
|
||||
// public GameViewHolder(View itemView) {
|
||||
// super(itemView);
|
||||
//
|
||||
// gamepic_rv = (RecyclerView) itemView.findViewById(R.id.gamedetails_rv_item_game_rv);
|
||||
// game_content = (TextView) itemView.findViewById(R.id.gamedetails_rv_item_game_content);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// public class GamePicAdapter extends RecyclerView.Adapter<GamePicAdapter.ViewHolder>{
|
||||
//
|
||||
// @Override
|
||||
// public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
// View inflate = LayoutInflater.from(GameDetailsActivity.this).inflate(R.layout.gamedetails_screenshot_item, parent, false);
|
||||
// return new ViewHolder(inflate);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onBindViewHolder(final ViewHolder holder, int position) {
|
||||
// ImageUtils.getInstance(GameDetailsActivity.this).display(entity.getGallery().get(position), holder.gamepic_iv);
|
||||
// holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// Intent intent = new Intent(GameDetailsActivity.this,ViewImageActivity.class);
|
||||
// intent.putExtra("urls", entity.getGallery());
|
||||
// intent.putExtra("current", holder.getPosition());
|
||||
// startActivity(intent);
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getItemCount() {
|
||||
// return entity.getGallery().size();
|
||||
// }
|
||||
//
|
||||
// public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
//
|
||||
// ImageView gamepic_iv;
|
||||
//
|
||||
// public ViewHolder(View itemView) {
|
||||
// super(itemView);
|
||||
//
|
||||
// gamepic_iv = (ImageView) itemView.findViewById(R.id.screenshot_item_iv);
|
||||
// gamepic_iv.setPadding(
|
||||
// DisplayUtils.dip2px(getApplicationContext(), 2),
|
||||
// 0,
|
||||
// DisplayUtils.dip2px(getApplicationContext(), 2),
|
||||
// 0);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@ -154,6 +154,7 @@ public class GameNewsActivity extends BaseActivity implements View.OnClickListen
|
||||
game_news_list.scrollToPosition(0);
|
||||
game_news_top_type_list.setVisibility(View.GONE);
|
||||
ivSearch.setVisibility(View.GONE);
|
||||
adapter.openKeyBoard();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -739,7 +739,7 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener
|
||||
essaydetail_ll_bottom.setVisibility(View.VISIBLE);
|
||||
essaydetail_rv_show.setPadding(0, 0, 0, DisplayUtils.dip2px(getApplicationContext(), 44));
|
||||
essaydetail_tv_download.setText("暂无下载");
|
||||
essaydetail_tv_download.setBackgroundResource(R.drawable.game_item_btn_pause_style);
|
||||
essaydetail_tv_download.setBackgroundResource(R.drawable.progressbar_normal_radius_style);
|
||||
essaydetail_tv_download.setTextColor(getResources().getColor(R.color.btn_gray));
|
||||
essaydetail_tv_download.setClickable(false);
|
||||
} else if (Config.isShow(this)) {
|
||||
|
||||
@ -244,22 +244,47 @@ public class NewsSearchActivity extends BaseActivity {
|
||||
R.layout.refresh_footerview, parent, false);
|
||||
return new FooterViewHolder(view);
|
||||
}else {
|
||||
LinearLayout linearLayout = new LinearLayout(getApplicationContext());
|
||||
linearLayout.setOrientation(LinearLayout.HORIZONTAL);
|
||||
linearLayout.setBackgroundResource(R.drawable.cardview_item_style);
|
||||
|
||||
TextView tvType = new TextView(getApplicationContext());
|
||||
tvType.setTextSize(12);
|
||||
tvType.setPadding(DisplayUtils.dip2px(NewsSearchActivity.this,1), 0, DisplayUtils.dip2px(NewsSearchActivity.this,1), 0);
|
||||
|
||||
TextView textView = new TextView(getApplicationContext());
|
||||
textView.setPadding(DisplayUtils.dip2px(NewsSearchActivity.this,10),DisplayUtils.dip2px(NewsSearchActivity.this,10)
|
||||
,0,DisplayUtils.dip2px(NewsSearchActivity.this,10));
|
||||
,0, DisplayUtils.dip2px(NewsSearchActivity.this,10));
|
||||
textView.setTextColor(Color.parseColor("#3a3a3a"));
|
||||
textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
textView.setBackgroundResource(R.drawable.cardview_item_style);
|
||||
textView.setSingleLine();
|
||||
return new ViewHolder(textView);
|
||||
|
||||
linearLayout.addView(tvType);
|
||||
linearLayout.addView(textView);
|
||||
|
||||
return new ViewHolder(linearLayout);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
|
||||
if (holder instanceof ViewHolder){
|
||||
((ViewHolder) holder).textView.setText(newsEntities.get(position).getTitle());
|
||||
((ViewHolder) holder).textView.setOnClickListener(new View.OnClickListener() {
|
||||
ViewHolder viewHolder = (ViewHolder) holder;
|
||||
|
||||
if ("活动".equals(newsEntities.get(position).getType())){
|
||||
viewHolder.tvType.setTextColor(Color.WHITE);
|
||||
viewHolder.tvType.setBackgroundResource(R.drawable.textview_orange_style);
|
||||
} else if ("公告".equals(newsEntities.get(position).getType())){
|
||||
viewHolder.tvType.setTextColor(Color.WHITE);
|
||||
viewHolder.tvType.setBackgroundResource(R.drawable.textview_red_style);
|
||||
} else {
|
||||
viewHolder.tvType.setTextColor(Color.WHITE);
|
||||
viewHolder.tvType.setBackgroundResource(R.drawable.textview_blue_style);
|
||||
}
|
||||
viewHolder.tvType.setText(newsEntities.get(position).getType());
|
||||
|
||||
viewHolder.tvTitle.setText(newsEntities.get(position).getTitle());
|
||||
viewHolder.tvTitle.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getApplicationContext(),NewsDetailActivity.class);
|
||||
@ -270,6 +295,7 @@ public class NewsSearchActivity extends BaseActivity {
|
||||
});
|
||||
}else if (holder instanceof FooterViewHolder){
|
||||
FooterViewHolder viewHolder = (FooterViewHolder) holder;
|
||||
viewHolder.itemView.setPadding(0, 0, 0, 0);
|
||||
if (isNetworkError) {
|
||||
viewHolder.footerview_progressbar.setVisibility(View.GONE);
|
||||
viewHolder.footerview_tv_loading.setText("加载失败,点击重试");
|
||||
@ -304,10 +330,14 @@ public class NewsSearchActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder{
|
||||
TextView textView;
|
||||
LinearLayout linearLayout;
|
||||
TextView tvType;
|
||||
TextView tvTitle;
|
||||
public ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
textView = (TextView) itemView;
|
||||
linearLayout = (LinearLayout) itemView;
|
||||
tvType = (TextView) linearLayout.getChildAt(0);
|
||||
tvTitle = (TextView) linearLayout.getChildAt(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,9 +2,12 @@ package com.gh.gamecenter.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -19,6 +22,7 @@ import com.gh.common.constant.Config;
|
||||
import com.gh.common.util.ConcernUtils;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.util.Utils;
|
||||
import com.gh.common.view.HorizontalItemDecoration;
|
||||
@ -255,14 +259,32 @@ public class GameDetailAdapter extends RecyclerView.Adapter {
|
||||
}
|
||||
}
|
||||
|
||||
private void initPluginViewHolder(GameDetailPluginViewHolder viewHolder) {
|
||||
private void initPluginViewHolder(final GameDetailPluginViewHolder viewHolder) {
|
||||
ArrayList<TagEntity> tags = gameDetailEntity.getTag();
|
||||
if (!TextUtils.isEmpty(gameDetailEntity.getRemind())) {
|
||||
TagEntity tagEntity = new TagEntity();
|
||||
tagEntity.setName("温馨提示");
|
||||
tagEntity.setDes(gameDetailEntity.getRemind());
|
||||
tags.add(tagEntity);
|
||||
tags.add(0,tagEntity);
|
||||
}
|
||||
|
||||
viewHolder.gamedetail_ll_plugin.setVisibility(View.GONE);
|
||||
viewHolder.open_plugin_detail_ll.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (viewHolder.gamedetail_ll_plugin.getVisibility() == View.GONE){
|
||||
viewHolder.gamedetail_ll_plugin.setVisibility(View.VISIBLE);
|
||||
viewHolder.gamedetail_ll_plugin_colse.setVisibility(View.GONE);
|
||||
viewHolder.open_plugin_detail_img.setImageResource(R.drawable.up_img);
|
||||
viewHolder.open_plugin_detail_tv.setText("收起");
|
||||
}else {
|
||||
viewHolder.gamedetail_ll_plugin.setVisibility(View.GONE);
|
||||
viewHolder.gamedetail_ll_plugin_colse.setVisibility(View.VISIBLE);
|
||||
viewHolder.open_plugin_detail_img.setImageResource(R.drawable.down_img);
|
||||
viewHolder.open_plugin_detail_tv.setText("详情");
|
||||
}
|
||||
}
|
||||
});
|
||||
int childCount = viewHolder.gamedetail_ll_plugin.getChildCount();
|
||||
if (childCount == 0) {
|
||||
View view;
|
||||
@ -276,11 +298,110 @@ public class GameDetailAdapter extends RecyclerView.Adapter {
|
||||
tv_content = (TextView) view.findViewById(R.id.gamedetail_tv_content);
|
||||
tv_content.setText(tags.get(i).getDes());
|
||||
tv_hint.setText(tags.get(i).getName());
|
||||
|
||||
if (i == 0){
|
||||
tv_hint.setTextColor(Color.parseColor("#00B7FA"));
|
||||
}
|
||||
if (!TextUtils.isEmpty(tags.get(i).getIcon())) {
|
||||
ImageUtils.getInstance(context).display(tags.get(i).getIcon(), iv_hint);
|
||||
}
|
||||
|
||||
viewHolder.gamedetail_ll_plugin.addView(view);
|
||||
}
|
||||
|
||||
view = View.inflate(context, R.layout.gamedetail_plugin_item, null);
|
||||
iv_hint = (ImageView) view.findViewById(R.id.gamedetail_iv_hint);
|
||||
tv_hint = (TextView) view.findViewById(R.id.gamedetail_tv_hint);
|
||||
tv_content = (TextView) view.findViewById(R.id.gamedetail_tv_content);
|
||||
tv_content.setText(tags.get(0).getDes());
|
||||
tv_hint.setText(tags.get(0).getName());
|
||||
tv_hint.setTextColor(Color.parseColor("#00B7FA"));
|
||||
|
||||
if (!TextUtils.isEmpty(tags.get(0).getIcon())) {
|
||||
ImageUtils.getInstance(context).display(tags.get(0).getIcon(), iv_hint);
|
||||
}
|
||||
viewHolder.gamedetail_ll_plugin_colse.addView(view);
|
||||
|
||||
RecyclerView recyclerView = new RecyclerView(context);
|
||||
recyclerView.setLayoutManager(new GridLayoutManager(context, 3));
|
||||
|
||||
int index = (int) Math.ceil((tags.size()-1) / 3.0);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT
|
||||
, DisplayUtils.dip2px(context, index * 28));
|
||||
params.setMargins(0, DisplayUtils.dip2px(context, index * 3), 0, 0);
|
||||
|
||||
recyclerView.setLayoutParams(params);
|
||||
recyclerView.setAdapter(new PluginAdapter(tags));
|
||||
viewHolder.gamedetail_ll_plugin_colse.addView(recyclerView);
|
||||
}
|
||||
}
|
||||
private class PluginAdapter extends RecyclerView.Adapter<PluginAdapter.ViewHolder>{
|
||||
private ArrayList<TagEntity> tags;
|
||||
|
||||
public PluginAdapter(ArrayList<TagEntity> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
LinearLayout linearLayout = new LinearLayout(context);
|
||||
linearLayout.setOrientation(LinearLayout.HORIZONTAL);
|
||||
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, DisplayUtils.dip2px(context, 28));
|
||||
linearLayout.setLayoutParams(llParams);
|
||||
|
||||
switch (viewType%3) {
|
||||
case 0:
|
||||
linearLayout.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
|
||||
break;
|
||||
case 1:
|
||||
linearLayout.setGravity(Gravity.CENTER);
|
||||
break;
|
||||
default:
|
||||
linearLayout.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
|
||||
}
|
||||
|
||||
ImageView pluginIcon = new ImageView(context);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(DisplayUtils.dip2px(context, 15), DisplayUtils.dip2px(context, 15));
|
||||
params.setMargins(0, 0, DisplayUtils.dip2px(context, 5), 0);
|
||||
pluginIcon.setLayoutParams(params);
|
||||
|
||||
TextView pluginTitle = new TextView(context);
|
||||
pluginTitle.setTextSize(15);
|
||||
pluginTitle.setTextColor(Color.parseColor("#06d0a8"));
|
||||
|
||||
linearLayout.addView(pluginIcon);
|
||||
linearLayout.addView(pluginTitle);
|
||||
return new ViewHolder(linearLayout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(PluginAdapter.ViewHolder holder, int position) {
|
||||
holder.pluginTitle.setText(tags.get(position+1).getName());
|
||||
ImageUtils.getInstance(context).display(tags.get(position+1).getIcon(), holder.pluginIcon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return tags.size()-1;
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder{
|
||||
|
||||
LinearLayout linearLayout;
|
||||
ImageView pluginIcon;
|
||||
TextView pluginTitle;
|
||||
|
||||
public ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
linearLayout = (LinearLayout) itemView;
|
||||
pluginIcon = (ImageView) linearLayout.getChildAt(0);
|
||||
pluginTitle = (TextView) linearLayout.getChildAt(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.volley.Response;
|
||||
@ -56,6 +57,7 @@ public class GameNewsAdapter extends RecyclerView.Adapter {
|
||||
private boolean isLoading;
|
||||
private boolean isRemove;
|
||||
private boolean isNetworkError;
|
||||
private boolean isOpenKeyBoard;
|
||||
|
||||
public GameNewsAdapter(Context context,
|
||||
ArrayList<String> tList,
|
||||
@ -75,6 +77,7 @@ public class GameNewsAdapter extends RecyclerView.Adapter {
|
||||
isLoading = false;
|
||||
isRemove = false;
|
||||
isNetworkError = false;
|
||||
isOpenKeyBoard = false;
|
||||
|
||||
addList(0);
|
||||
}
|
||||
@ -219,6 +222,13 @@ public class GameNewsAdapter extends RecyclerView.Adapter {
|
||||
footerViewHolder.item_pb_loading.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else if (holder instanceof GameNewsSearchViewHolder){
|
||||
if (isOpenKeyBoard){
|
||||
((GameNewsSearchViewHolder) holder).game_news_et_search.requestFocus();
|
||||
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
|
||||
isOpenKeyBoard = false;
|
||||
}
|
||||
|
||||
GameNewsSearchViewHolder searchViewHolder = ((GameNewsSearchViewHolder) holder);
|
||||
searchViewHolder.game_news_tv_search.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -264,4 +274,9 @@ public class GameNewsAdapter extends RecyclerView.Adapter {
|
||||
return isNetworkError;
|
||||
}
|
||||
|
||||
public void openKeyBoard() {
|
||||
isOpenKeyBoard = true;
|
||||
notifyItemChanged(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -99,7 +99,8 @@ public class GameNewsTypeListAdapter extends RecyclerView.Adapter<GameNewsTypeVi
|
||||
|
||||
public void setNewsType(String newsType, int position) {
|
||||
this.newsType = newsType;
|
||||
notifyItemChanged(currentPosition);
|
||||
notifyItemChanged(position);
|
||||
notifyDataSetChanged();//感觉 position 和 currentPosition 不准确,只能用这个刷新了
|
||||
// notifyItemChanged(currentPosition);
|
||||
// notifyItemChanged(position);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,9 @@ package com.gh.gamecenter.adapter.viewholder;
|
||||
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.gamecenter.R;
|
||||
|
||||
@ -12,11 +14,19 @@ import com.gh.gamecenter.R;
|
||||
public class GameDetailPluginViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
public LinearLayout gamedetail_ll_plugin;
|
||||
public LinearLayout open_plugin_detail_ll;
|
||||
public ImageView open_plugin_detail_img;
|
||||
public LinearLayout gamedetail_ll_plugin_colse;
|
||||
public TextView open_plugin_detail_tv;
|
||||
|
||||
public GameDetailPluginViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
gamedetail_ll_plugin = (LinearLayout) itemView.findViewById(R.id.gamedetail_ll_plugin);
|
||||
open_plugin_detail_ll = (LinearLayout) itemView.findViewById(R.id.open_plugin_detail_ll);
|
||||
open_plugin_detail_img = (ImageView) itemView.findViewById(R.id.open_plugin_detail_img);
|
||||
gamedetail_ll_plugin_colse = (LinearLayout) itemView.findViewById(R.id.gamedetail_ll_plugin_colse);
|
||||
open_plugin_detail_tv = (TextView) itemView.findViewById(R.id.open_plugin_detail_tv);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user