Merge branch '2.0' of https://git.oschina.net/dreamhua/GH-ASSISTv1.45 into 2.0
Conflicts: app/src/main/java/com/gh/common/util/DialogUtils.java
This commit is contained in:
147
app/src/main/java/com/gh/common/util/ConcernUtils.java
Normal file
147
app/src/main/java/com/gh/common/util/ConcernUtils.java
Normal file
@ -0,0 +1,147 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
import com.android.volley.Request;
|
||||
import com.android.volley.Response;
|
||||
import com.android.volley.VolleyError;
|
||||
import com.gh.base.AppController;
|
||||
import com.gh.gamecenter.volley.extended.ConcernJsonArrayExtendedRequest;
|
||||
import com.gh.gamecenter.volley.extended.JsonArrayExtendedRequest;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by khy on 2016/8/24.
|
||||
*/
|
||||
public class ConcernUtils {
|
||||
public static void LoadConcernData(final String url, final DownJsonListener listener){
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
JsonArrayExtendedRequest request = new JsonArrayExtendedRequest(url, new Response.Listener<JSONArray>() {
|
||||
@Override
|
||||
public void onResponse(JSONArray response) {
|
||||
if (listener != null){
|
||||
listener.downSucced(response.toString());
|
||||
}
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
if (listener != null){
|
||||
listener.downFailed();
|
||||
}
|
||||
}
|
||||
});
|
||||
request.setShouldCache(false);
|
||||
AppController.addToRequestQueue(request);
|
||||
}
|
||||
}).start();
|
||||
|
||||
}
|
||||
public static void PostConcernGameId(final String postData, final String postUrl,final DownJsonListener listener){
|
||||
new Thread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
JSONArray jsonArray = null;
|
||||
try {
|
||||
jsonArray = new JSONArray(postData);
|
||||
} catch (JSONException e) {
|
||||
|
||||
}
|
||||
ConcernJsonArrayExtendedRequest request = new ConcernJsonArrayExtendedRequest(Request.Method.POST, postUrl, jsonArray, new Response.Listener<JSONArray>() {
|
||||
@Override
|
||||
public void onResponse(JSONArray response) {
|
||||
listener.downSucced("关注成功");
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
listener.downFailed();
|
||||
}
|
||||
});
|
||||
request.setShouldCache(false);
|
||||
AppController.addToRequestQueue(request);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
public static void DeleteConcernData(final String url, final DownJsonListener listener){
|
||||
final JSONArray jsonArray = new JSONArray();
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ConcernJsonArrayExtendedRequest request = new ConcernJsonArrayExtendedRequest(Request.Method.DELETE, url, jsonArray, new Response.Listener<JSONArray>() {
|
||||
@Override
|
||||
public void onResponse(JSONArray response) {
|
||||
listener.downSucced("删除成功");
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
listener.downFailed();
|
||||
}
|
||||
});
|
||||
request.setShouldCache(false);
|
||||
AppController.addToRequestQueue(request);
|
||||
}
|
||||
}).start();
|
||||
|
||||
}
|
||||
public static void UpdateConcernData(final String url,String updateData,final DownJsonListener listener){
|
||||
if (updateData.length()<3){
|
||||
updateData = "";
|
||||
}
|
||||
JSONArray jsonArray = null;
|
||||
try {
|
||||
jsonArray = new JSONArray(updateData);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
final JSONArray finalJsonArray = jsonArray;
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ConcernJsonArrayExtendedRequest request = new ConcernJsonArrayExtendedRequest(Request.Method.PUT, url, finalJsonArray, new Response.Listener<JSONArray>() {
|
||||
@Override
|
||||
public void onResponse(JSONArray response) {
|
||||
listener.downSucced("跟新设备关注成功");
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
listener.downFailed();
|
||||
}
|
||||
});
|
||||
request.setShouldCache(false);
|
||||
AppController.addToRequestQueue(request);
|
||||
}
|
||||
|
||||
}).start();
|
||||
}
|
||||
|
||||
public interface DownJsonListener {
|
||||
|
||||
void downSucced(String str);
|
||||
void downFailed();
|
||||
|
||||
}
|
||||
//获取设备号ID
|
||||
public static String UUID(Context context){
|
||||
final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
|
||||
final String tmDevice, tmSerial, tmPhone, androidId;
|
||||
tmDevice = "" + tm.getDeviceId();
|
||||
tmSerial = "" + tm.getSimSerialNumber();
|
||||
androidId = "" + android.provider.Settings.Secure.getString(context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
|
||||
|
||||
UUID deviceUuid = new UUID(androidId.hashCode(), ((long)tmDevice.hashCode() << 32) | tmSerial.hashCode());
|
||||
return deviceUuid.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,17 +37,17 @@ public class DialogUtils {
|
||||
|
||||
final Dialog dialog = new Dialog(context);
|
||||
View view = View.inflate(context,
|
||||
R.layout.search_history_delete_dialog, null);
|
||||
R.layout.common_alertdialog, null);
|
||||
TextView title = (TextView) view
|
||||
.findViewById(R.id.delete_dialog_title);
|
||||
.findViewById(R.id.alertdialog_title);
|
||||
title.setText("警告");
|
||||
TextView content = (TextView) view
|
||||
.findViewById(R.id.delete_dialog_message);
|
||||
.findViewById(R.id.alertdialog_content);
|
||||
|
||||
content.setText("您当前网络环境异常,下载地址已被替换(网络劫持),请更换网络环境进行下载。");
|
||||
|
||||
TextView cancel = (TextView) view
|
||||
.findViewById(R.id.delete_dialog_cancel);
|
||||
.findViewById(R.id.alertdialog_cannel);
|
||||
cancel.setText("取消");
|
||||
cancel.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
@ -56,7 +56,7 @@ public class DialogUtils {
|
||||
}
|
||||
});
|
||||
TextView confirem = (TextView) view
|
||||
.findViewById(R.id.delete_dialog_confirm);
|
||||
.findViewById(R.id.alertdialog_confirm);
|
||||
confirem.setText("确定");
|
||||
confirem.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
@ -130,14 +130,16 @@ public class DialogUtils {
|
||||
|
||||
public static void showWarningDialog(Context context, String msg, final ConfiremListener listener) {
|
||||
final Dialog dialog = new Dialog(context);
|
||||
View view = View.inflate(context, R.layout.search_history_delete_dialog, null);
|
||||
TextView title = (TextView) view.findViewById(R.id.delete_dialog_title);
|
||||
title.setText("警告");
|
||||
TextView content = (TextView) view.findViewById(R.id.delete_dialog_message);
|
||||
View view = View.inflate(context, R.layout.common_alertdialog, null);
|
||||
TextView title = (TextView) view
|
||||
.findViewById(R.id.alertdialog_title);
|
||||
title.setText("下载提示");
|
||||
TextView content = (TextView) view.findViewById(R.id.alertdialog_content);
|
||||
|
||||
content.setText(msg);
|
||||
|
||||
TextView cancel = (TextView) view.findViewById(R.id.delete_dialog_cancel);
|
||||
TextView cancel = (TextView) view
|
||||
.findViewById(R.id.alertdialog_cannel);
|
||||
cancel.setText("取消");
|
||||
cancel.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
@ -145,7 +147,8 @@ public class DialogUtils {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
TextView confirem = (TextView) view.findViewById(R.id.delete_dialog_confirm);
|
||||
TextView confirem = (TextView) view
|
||||
.findViewById(R.id.alertdialog_confirm);
|
||||
confirem.setText("继续");
|
||||
confirem.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -162,7 +165,7 @@ public class DialogUtils {
|
||||
}
|
||||
|
||||
public static void showWarningDialog(Context context, ConfiremListener listener) {
|
||||
showWarningDialog(context, "您当前的网络为2G/3G/4G,下载将会消耗移动流量,是否继续下载?", listener);
|
||||
showWarningDialog(context, "您当前使用的网络为2G/3G/4G,开始下载将会消耗移动流量,确定下载?", listener);
|
||||
}
|
||||
|
||||
public static void showSuccessDialog(Context context) {
|
||||
@ -224,18 +227,18 @@ public class DialogUtils {
|
||||
public static void showPluginDialog(Context context, final ConfiremListener cListener,
|
||||
final DismissListener dListener) {
|
||||
final Dialog dialog = new Dialog(context);
|
||||
View view = View.inflate(context, R.layout.search_history_delete_dialog, null);
|
||||
TextView title = (TextView) view.findViewById(R.id.delete_dialog_title);
|
||||
View view = View.inflate(context, R.layout.common_alertdialog, null);
|
||||
TextView title = (TextView) view.findViewById(R.id.alertdialog_title);
|
||||
title.setText("插件化安装");
|
||||
TextView content = (TextView) view
|
||||
.findViewById(R.id.delete_dialog_message);
|
||||
.findViewById(R.id.alertdialog_content);
|
||||
Spanned spanned = Html.fromHtml("您将进行插件化安装以实现插件功能,此过程将"
|
||||
+ "<font color=\"#ff0000\">卸载</font>" + "当前使用的版本并"
|
||||
+ "<font color=\"#ff0000\">安装插件版本</font>" + "。");
|
||||
content.setText(spanned);
|
||||
|
||||
TextView cancel = (TextView) view
|
||||
.findViewById(R.id.delete_dialog_cancel);
|
||||
.findViewById(R.id.alertdialog_cannel);
|
||||
cancel.setText("取消");
|
||||
cancel.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
@ -244,7 +247,7 @@ public class DialogUtils {
|
||||
}
|
||||
});
|
||||
TextView confirm = (TextView) view
|
||||
.findViewById(R.id.delete_dialog_confirm);
|
||||
.findViewById(R.id.alertdialog_confirm);
|
||||
confirm.setText("确定");
|
||||
confirm.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
|
||||
947
app/src/main/java/com/gh/gamecenter/NewGameDetailsActivity.java
Normal file
947
app/src/main/java/com/gh/gamecenter/NewGameDetailsActivity.java
Normal file
@ -0,0 +1,947 @@
|
||||
package com.gh.gamecenter;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.Html;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
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.constant.Constants;
|
||||
import com.gh.common.util.ConcernUtils;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
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.DismissEntity;
|
||||
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.EBPWDismiss;
|
||||
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 NewGameDetailsActivity extends BaseActivity implements View.OnClickListener{
|
||||
private String gameId ;
|
||||
private String entrance;
|
||||
private GameDetailsAdapter detailsAdapter;
|
||||
private Context context = this;
|
||||
private RecyclerView detailsRecyclerView;
|
||||
private LinearLayout llLoading;
|
||||
private LinearLayout noConnection;
|
||||
private GameDetailsEntity entity = new GameDetailsEntity();
|
||||
private GameEntity gameEntity;
|
||||
private TextView tvDowload,tvPer;
|
||||
private ProgressBar progressBar;
|
||||
private ArrayMap<String, String> statusMap;
|
||||
private DismissEntity dismissEntity;
|
||||
private DownloadEntry downloadEntry;
|
||||
private ConcernManager concernManager;
|
||||
|
||||
private boolean isConcern = false;
|
||||
private int concernCode = 0;//0关注不做操作,1添加关注,2删除关注
|
||||
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(statusMap.get(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);
|
||||
gameId = getIntent().getStringExtra("gameId");
|
||||
entrance = getIntent().getStringExtra("entrance");
|
||||
if (gameId != null) {
|
||||
|
||||
} else {
|
||||
gameEntity = (GameEntity) AppController.get("GameEntity", true);
|
||||
gameId = gameEntity.getId();
|
||||
}
|
||||
|
||||
init(contentView,gameEntity.getName());
|
||||
dismissEntity = new DismissEntity(false);
|
||||
statusMap = new ArrayMap<>();
|
||||
|
||||
//初始化关注
|
||||
concernManager = new ConcernManager(getApplicationContext());
|
||||
for (int i = 0; i < concernManager.getAllConcern().size(); i++) {
|
||||
if (concernManager.getAllConcern().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(context);
|
||||
detailsRecyclerView.setLayoutManager(new LinearLayoutManager(context));
|
||||
detailsRecyclerView.setAdapter(detailsAdapter);
|
||||
if (entity != null) {
|
||||
initDowload();
|
||||
} else {
|
||||
|
||||
}
|
||||
tvDowload.setOnClickListener(this);
|
||||
tvPer.setOnClickListener(this);
|
||||
noConnection.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(NewGameDetailsActivity.this, "插件数据", gameEntity.getName(),
|
||||
kv0);
|
||||
if (gameEntity.getApk() != null && !gameEntity.getApk().isEmpty()) {
|
||||
if (NetworkUtils.isWifiConnected(this)) {
|
||||
download(v);
|
||||
} else {
|
||||
DialogUtils.showWarningDialog(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)) {
|
||||
statusMap.put(downloadEntry.getUrl(), "downloading");
|
||||
tvPer.setText(downloadEntry.getPercent() + "%");
|
||||
Message msg = Message.obtain();
|
||||
msg.what = Constants.CONTINUE_DOWNLOAD_TASK;
|
||||
msg.obj = downloadEntry.getUrl();
|
||||
DownloadManager.getInstance(context).put(downloadEntry.getUrl(),
|
||||
System.currentTimeMillis());
|
||||
DownloadManager.getInstance(context).sendMessageDelayed(msg, 1000);
|
||||
} else if ("安装".equals(str)) {
|
||||
final String path = downloadEntry.getPath();
|
||||
PackageManager manager = new PackageManager(
|
||||
context);
|
||||
if (manager.launchSetup(path)) {
|
||||
startActivity(PackageUtils.getInstallIntent(path));
|
||||
} else {
|
||||
DialogUtils.showPluginDialog(this, new DialogUtils.ConfiremListener() {
|
||||
@Override
|
||||
public void onConfirem() {
|
||||
MainActivity.uninstallMap.put(
|
||||
PackageUtils.getPackageNameByPath(NewGameDetailsActivity.this, path), path);
|
||||
startActivity(PackageUtils.getUninstallIntent(NewGameDetailsActivity.this,
|
||||
path));
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
} else if("等待".equals(str)){
|
||||
|
||||
} else {
|
||||
statusMap.put(downloadEntry.getUrl(), "pause");
|
||||
tvPer.setText("继续");
|
||||
Message msg = Message.obtain();
|
||||
msg.what = Constants.PAUSE_DOWNLOAD_TASK;
|
||||
msg.obj = downloadEntry.getUrl();
|
||||
DownloadManager.getInstance(context).put(downloadEntry.getUrl(),
|
||||
System.currentTimeMillis());
|
||||
DownloadManager.getInstance(context).sendMessageDelayed(msg, 1000);
|
||||
}
|
||||
break;
|
||||
case R.id.reuse_no_connection:
|
||||
noConnection.setVisibility(View.GONE);
|
||||
llLoading.setVisibility(View.VISIBLE);
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
getGameNews();
|
||||
getGameDetail();
|
||||
}
|
||||
},1000);
|
||||
}
|
||||
}
|
||||
private void invalidate() {
|
||||
progressBar.setProgress((int) (downloadEntry.getPercent() * 10));
|
||||
switch (downloadEntry.getStatus()) {
|
||||
case downloading:
|
||||
tvPer.setText(downloadEntry.getPercent() + "%");
|
||||
break;
|
||||
case pause:
|
||||
case timeout:
|
||||
case neterror:
|
||||
tvPer.setText("继续");
|
||||
break;
|
||||
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.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(NewGameDetailsActivity.this, "游戏启动",
|
||||
gameEntity.getName(), kv);
|
||||
|
||||
PackageUtils.launchApplicationByPackageName(
|
||||
context, 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(NewGameDetailsActivity.this,
|
||||
"游戏下载", gameEntity.getName(), kv);
|
||||
|
||||
Map<String, Object> kv2 = new HashMap<String, Object>();
|
||||
kv2.put("版本", apkEntity.getPlatform());
|
||||
kv2.put("状态", "下载开始");
|
||||
kv2.put("位置", entrance + "-游戏详情-开始");
|
||||
DataUtils.onEvent(NewGameDetailsActivity.this,
|
||||
"游戏下载位置", gameEntity.getName(), kv2);
|
||||
|
||||
Map<String, Object> kv3 = new HashMap<String, Object>();
|
||||
kv3.put(entrance, "下载数");
|
||||
kv3.put(entrance, "下载开始");
|
||||
DataUtils.onEvent(NewGameDetailsActivity.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(
|
||||
context)
|
||||
.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(
|
||||
NewGameDetailsActivity.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(
|
||||
context).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%");
|
||||
|
||||
statusMap.put(entry.getUrl(), "downloading");
|
||||
|
||||
} else {
|
||||
toast(msg);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!dismissEntity.isShow()) {
|
||||
dismissEntity.setShow(true);
|
||||
DownloadDialog
|
||||
.getInstance(NewGameDetailsActivity.this)
|
||||
.showPopupWindow(v, gameEntity,
|
||||
entrance + "-游戏详情", statusMap,
|
||||
"游戏详情:" + 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());
|
||||
Gson gson = new Gson();
|
||||
ArrayList<NewsEntity> news = gson.fromJson(
|
||||
response.toString(),
|
||||
new TypeToken<ArrayList<NewsEntity>>() {
|
||||
}.getType());
|
||||
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)) {
|
||||
llLoading.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
AppController.addToRequestQueue(request, NewGameDetailsActivity.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.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();
|
||||
}
|
||||
}, new Response.ErrorListener() {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
noConnection.setVisibility(View.VISIBLE);
|
||||
// 无网络连接和访问超时
|
||||
}
|
||||
});
|
||||
AppController.addToRequestQueue(request, NewGameDetailsActivity.class);
|
||||
}
|
||||
public void onEventMainThread(EBPWDismiss dismiss) {
|
||||
if (dismissEntity != null) {
|
||||
dismissEntity.setShow(false);
|
||||
}
|
||||
}
|
||||
|
||||
@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 (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(
|
||||
context).getAll()) {
|
||||
if (url.equals(entry.getUrl())) {
|
||||
downloadEntry = entry;
|
||||
tvDowload.setVisibility(View.GONE);
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
tvPer.setVisibility(View.VISIBLE);
|
||||
invalidate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
DownloadManager.getInstance(context).addObserver(
|
||||
dataWatcher);
|
||||
}
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
String uuid = ConcernUtils.UUID(this);
|
||||
if (isConcern == true&&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 == false&& 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;
|
||||
context = null;
|
||||
detailsRecyclerView = null;
|
||||
llLoading = null;
|
||||
noConnection = null;
|
||||
entity = null;
|
||||
gameEntity = null;
|
||||
tvDowload = null;
|
||||
tvPer = null;
|
||||
progressBar = null;
|
||||
statusMap = null;
|
||||
dismissEntity = null;
|
||||
downloadEntry = null;
|
||||
concernManager = null;
|
||||
handler = null;
|
||||
}
|
||||
|
||||
|
||||
public class GameDetailsAdapter extends RecyclerView.Adapter<GameDetailsAdapter.ViewHolder>{
|
||||
private Context context;
|
||||
|
||||
public GameDetailsAdapter(Context context) {
|
||||
this.context = context;
|
||||
getGameDetail();
|
||||
getGameNews();
|
||||
}
|
||||
@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 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(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) LayoutInflater.from(context).inflate(R.layout.gamedetails_zixun_item,null);
|
||||
TextView tv_tag = (TextView) rlChild.findViewById(R.id.gamedetails_rv_item_zixun_tag);
|
||||
TextView tv_title = (TextView) rlChild.findViewById(R.id.gamedetails_rv_item_zixun_title);
|
||||
tv_tag.setText(entity.getNews().get(i).getType());
|
||||
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,GameDeatilsNewsActivity.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) LayoutInflater.from(context).inflate(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);
|
||||
ApkEntity apkEntity = gameEntity.getApk().get(0);
|
||||
topViewHolder.tv_info.setText("V" + apkEntity.getVersion() + " | "
|
||||
+ apkEntity.getSize());
|
||||
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<String, Object>();
|
||||
kv.put("状态", "关注");
|
||||
DataUtils.onEvent(NewGameDetailsActivity.this, "游戏关注", gameEntity.getName(), kv);
|
||||
|
||||
Map<String, Object> kv2 = new HashMap<String, Object>();
|
||||
kv2.put("点击", "关注");
|
||||
DataUtils.onEvent(NewGameDetailsActivity.this, "插件数据", gameEntity.getName(), kv2);
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("game", gameEntity.getName());
|
||||
map.put("type", "关注");
|
||||
map.put("createdOn", System.currentTimeMillis() / 1000);
|
||||
DataCollectionManager.onEvent(NewGameDetailsActivity.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<String, Object>();
|
||||
kv2.put("点击", "取消关注");
|
||||
DataUtils.onEvent(NewGameDetailsActivity.this, "插件数据", gameEntity.getName(), kv2);
|
||||
|
||||
showCancelDialog(topViewHolder.tv_concern);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
private void showCancelDialog(final TextView attention) {
|
||||
final Dialog dialog = new Dialog(context);
|
||||
View view = View.inflate(context, R.layout.common_alertdialog,
|
||||
null);
|
||||
TextView title = (TextView) view.findViewById(R.id.alertdialog_title);
|
||||
title.setText("取消关注");
|
||||
TextView cancel = (TextView) view.findViewById(R.id.alertdialog_cannel);
|
||||
cancel.setText("暂不取消");
|
||||
TextView confirm = (TextView) view.findViewById(R.id.alertdialog_confirm);
|
||||
confirm.setText("确定取消");
|
||||
cancel.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
TextView message = (TextView) view.findViewById(R.id.alertdialog_content);
|
||||
|
||||
Spanned content = Html
|
||||
.fromHtml("取消关注游戏后,您将无法及时收到游戏的<font color='#ff0000'>攻略</font>、<font color='#ff0000'>资讯</font>等最新动态提醒,您确定取消吗?");
|
||||
message.setText(content);
|
||||
|
||||
view.findViewById(R.id.alertdialog_confirm).setOnClickListener(
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
Map<String, Object> kv = new HashMap<String, Object>();
|
||||
kv.put("状态", "取消关注");
|
||||
DataUtils.onEvent(NewGameDetailsActivity.this, "游戏关注",
|
||||
gameEntity.getName(), kv);
|
||||
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("game", gameEntity.getName());
|
||||
map.put("type", "关注");
|
||||
map.put("createdOn", System.currentTimeMillis() / 1000);
|
||||
DataCollectionManager.onEvent(NewGameDetailsActivity.this,
|
||||
"concern", map);
|
||||
|
||||
concernCode = 2;
|
||||
concernManager.deleteConcern(gameEntity.getId());
|
||||
dialog.dismiss();
|
||||
attention.setText("关注");
|
||||
attention
|
||||
.setBackgroundResource(R.drawable.textview_red_style);
|
||||
attention.setTextColor(0xffffffff);
|
||||
}
|
||||
});
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
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;
|
||||
}
|
||||
public class TopViewHolder extends ViewHolder{
|
||||
View view;
|
||||
TextView tv_name,tv_info,tv_concern;
|
||||
ImageView iv_game;
|
||||
public TopViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
view = itemView;
|
||||
tv_name = (TextView) view.findViewById(R.id.gamedetails_game_name);
|
||||
tv_concern = (TextView) view.findViewById(R.id.gamedetails_concern_btn);
|
||||
tv_info = (TextView) view.findViewById(R.id.gamedetails_top_tv_info);
|
||||
iv_game = (ImageView) view.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 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 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 ViewHolder{
|
||||
View view;
|
||||
RecyclerView gamepic_rv;
|
||||
TextView game_content;
|
||||
|
||||
public GameViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
view = itemView;
|
||||
gamepic_rv = (RecyclerView) view.findViewById(R.id.gamedetails_rv_item_game_rv);
|
||||
game_content = (TextView) view.findViewById(R.id.gamedetails_rv_item_game_content);
|
||||
}
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder{
|
||||
public ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
}
|
||||
}
|
||||
public class GamePicAdapter extends RecyclerView.Adapter<GamePicAdapter.ViewHolder>{
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View inflate = LayoutInflater.from(context).inflate(R.layout.gamedetails_screenshot_item, parent, false);
|
||||
return new ViewHolder(inflate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, final int position) {
|
||||
holder.gamepic_iv.setImageResource(R.drawable.me_icon);
|
||||
holder.gamepic_iv.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
ImageUtils.getInstance(context).display(entity.getGallery().get(position),holder.gamepic_iv);
|
||||
holder.view.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(NewGameDetailsActivity.this,ViewImageActivity.class);
|
||||
intent.putExtra("urls",entity.getGallery());
|
||||
intent.putExtra("currentItem",position);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
View view;
|
||||
ImageView gamepic_iv;
|
||||
public ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
view = itemView;
|
||||
gamepic_iv = (ImageView) view.findViewById(R.id.screenshot_item_iv);
|
||||
gamepic_iv.setPadding((int)(context.getResources().getDisplayMetrics().density*2),0,(int)(context.getResources().getDisplayMetrics().density*2),0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,6 +2,7 @@ package com.gh.gamecenter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
@ -73,6 +74,8 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
|
||||
private int checkSizeIndex;
|
||||
|
||||
private Context context = this;
|
||||
|
||||
private DataWatcher dataWatcher = new DataWatcher() {
|
||||
|
||||
@Override
|
||||
@ -229,8 +232,31 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
checkUpdate();
|
||||
break;
|
||||
case R.id.setting_rl_cache:
|
||||
dialog = DialogUtils.showWaitDialog(this, "清除缓存中...");
|
||||
claerCache();
|
||||
final Dialog dialog_hint = new Dialog(this);
|
||||
View view = View.inflate(this, R.layout.common_alertdialog, null);
|
||||
TextView dialog_title = (TextView) view.findViewById(R.id.alertdialog_title);
|
||||
TextView dialog_content = (TextView) view.findViewById(R.id.alertdialog_content);
|
||||
dialog_content.setText("清空缓存后未安装的游戏可能需要重新下载,确定清空?");
|
||||
dialog_title.setText("清除缓存");
|
||||
view.findViewById(R.id.alertdialog_cannel)
|
||||
.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dialog_hint.dismiss();
|
||||
}
|
||||
});
|
||||
view.findViewById(R.id.alertdialog_confirm)
|
||||
.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dialog_hint.dismiss();
|
||||
dialog = DialogUtils.showWaitDialog(context, "清除缓存中...");
|
||||
claerCache();
|
||||
}
|
||||
});
|
||||
dialog_hint.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog_hint.setContentView(view);
|
||||
dialog_hint.show();
|
||||
break;
|
||||
case R.id.setting_rl_feedback:
|
||||
startActivity(new Intent(SettingActivity.this,
|
||||
|
||||
@ -131,18 +131,18 @@ public class SuggestionActivity extends BaseActivity implements OnClickListener
|
||||
// 弹出确认对话框
|
||||
private void showConfirmDialog(final String email) {
|
||||
final Dialog confirmDialog = new Dialog(this);
|
||||
View view = View.inflate(this, R.layout.search_history_delete_dialog,
|
||||
View view = View.inflate(this, R.layout.common_alertdialog,
|
||||
null);
|
||||
TextView title = (TextView) view.findViewById(R.id.delete_dialog_title);
|
||||
TextView title = (TextView) view.findViewById(R.id.alertdialog_title);
|
||||
title.setText("温馨提示");
|
||||
TextView content = (TextView) view
|
||||
.findViewById(R.id.delete_dialog_message);
|
||||
.findViewById(R.id.alertdialog_content);
|
||||
|
||||
content.setText("填写联系方式有助于我们更好的一对一地解决您的问题,确定不填写吗?");
|
||||
|
||||
TextView cancel = (TextView) view
|
||||
.findViewById(R.id.delete_dialog_cancel);
|
||||
cancel.setText("填写");
|
||||
.findViewById(R.id.alertdialog_cannel);
|
||||
cancel.setText("我要填写");
|
||||
cancel.setTextColor(0xffFFFFFF);
|
||||
cancel.setBackgroundResource(R.drawable.textview_blue_style);
|
||||
cancel.setOnClickListener(new OnClickListener() {
|
||||
@ -167,8 +167,8 @@ public class SuggestionActivity extends BaseActivity implements OnClickListener
|
||||
}
|
||||
});
|
||||
TextView confirm = (TextView) view
|
||||
.findViewById(R.id.delete_dialog_confirm);
|
||||
confirm.setText("提交");
|
||||
.findViewById(R.id.alertdialog_confirm);
|
||||
confirm.setText("直接提交");
|
||||
confirm.setTextColor(0xff999999);
|
||||
confirm.setBackgroundResource(R.drawable.textview_cancel_style);
|
||||
confirm.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.gh.gamecenter.news;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
@ -281,12 +282,12 @@ public class News1FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
private void initNewsImage2ViewHolder(NewsImage2ViewHolder viewHolder, final NewsEntity newsEntity, final int position) {
|
||||
DisplayMetrics outMetrics = new DisplayMetrics();
|
||||
fragment.getActivity().getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
|
||||
int width = (outMetrics.widthPixels - 4 * DisplayUtils.dip2px(context, 8)) / 3;
|
||||
int width = (outMetrics.widthPixels - 2 * DisplayUtils.dip2px(context, 4)-(int)(outMetrics.density*34)) / 3;
|
||||
int height = (int) (width * 3 / 4f);
|
||||
LinearLayout.LayoutParams lparams1 = new LinearLayout.LayoutParams(width, height);
|
||||
viewHolder.fm_read2_special2_thumb1.setLayoutParams(lparams1);
|
||||
LinearLayout.LayoutParams lparams2 = new LinearLayout.LayoutParams(width, height);
|
||||
lparams2.leftMargin = DisplayUtils.dip2px(context, 8);
|
||||
lparams2.leftMargin = DisplayUtils.dip2px(context, 4);
|
||||
viewHolder.fm_read2_special2_thumb2.setLayoutParams(lparams2);
|
||||
viewHolder.fm_read2_special2_thumb3.setLayoutParams(lparams2);
|
||||
|
||||
@ -466,12 +467,21 @@ public class News1FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
}
|
||||
|
||||
private void setType(TextView textView, String type) {
|
||||
|
||||
ViewGroup.LayoutParams layoutParams = textView.getLayoutParams();
|
||||
layoutParams.width = DisplayUtils.dip2px(context,28);
|
||||
layoutParams.height = DisplayUtils.dip2px(context,17);
|
||||
textView.setLayoutParams(layoutParams);
|
||||
|
||||
if ("活动".equals(type)){
|
||||
textView.setTextColor(context.getResources().getColor(R.color.type_huodong));
|
||||
textView.setTextColor(Color.WHITE);
|
||||
textView.setBackgroundResource(R.drawable.textview_orange_style);
|
||||
} else if ("公告".equals(type)){
|
||||
textView.setTextColor(context.getResources().getColor(R.color.type_gonggao));
|
||||
textView.setTextColor(Color.WHITE);
|
||||
textView.setBackgroundResource(R.drawable.textview_red_style);
|
||||
} else {
|
||||
textView.setTextColor(context.getResources().getColor(R.color.type_gonglue));
|
||||
textView.setTextColor(Color.WHITE);
|
||||
textView.setBackgroundResource(R.drawable.textview_blue_style);
|
||||
}
|
||||
textView.setText(type);
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.gh.gamecenter.news;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.support.v4.util.ArrayMap;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
@ -265,6 +266,7 @@ public class News2FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
NewsUtils.startNewsActivity(context, newsEntity, "资讯-原创");
|
||||
}
|
||||
});
|
||||
viewHolder.fm_read_tv_read.setTextColor(Color.parseColor("#9a9a9a"));
|
||||
ImageUtils.getInstance(context).display(newsEntity.getThumbnail().getUrl().get(0), viewHolder.fm_read_iv_thumb);
|
||||
viewHolder.fm_read_tv_title.setText(newsEntity.getTitle());
|
||||
Integer views = viewsMap.get(newsEntity.getId());
|
||||
@ -280,15 +282,14 @@ public class News2FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
private void initNewsImage2ViewHolder(NewsImage2ViewHolder viewHolder, final NewsEntity newsEntity, final int position) {
|
||||
DisplayMetrics outMetrics = new DisplayMetrics();
|
||||
fragment.getActivity().getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
|
||||
int width = (outMetrics.widthPixels - 4 * DisplayUtils.dip2px(context, 8)) / 3;
|
||||
int width = (outMetrics.widthPixels - 2 * DisplayUtils.dip2px(context, 4)-(int)(outMetrics.density*34)) / 3;
|
||||
int height = (int) (width * 3 / 4f);
|
||||
LinearLayout.LayoutParams lparams1 = new LinearLayout.LayoutParams(width, height);
|
||||
viewHolder.fm_read2_special2_thumb1.setLayoutParams(lparams1);
|
||||
LinearLayout.LayoutParams lparams2 = new LinearLayout.LayoutParams(width, height);
|
||||
lparams2.leftMargin = DisplayUtils.dip2px(context, 8);
|
||||
lparams2.leftMargin = DisplayUtils.dip2px(context, 4);
|
||||
viewHolder.fm_read2_special2_thumb2.setLayoutParams(lparams2);
|
||||
viewHolder.fm_read2_special2_thumb3.setLayoutParams(lparams2);
|
||||
|
||||
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@ -465,14 +466,24 @@ public class News2FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
}
|
||||
|
||||
private void setType(TextView textView, String type) {
|
||||
|
||||
ViewGroup.LayoutParams layoutParams = textView.getLayoutParams();
|
||||
layoutParams.width = DisplayUtils.dip2px(context,28);
|
||||
layoutParams.height = DisplayUtils.dip2px(context,17);
|
||||
textView.setLayoutParams(layoutParams);
|
||||
|
||||
if ("评测".equals(type)){
|
||||
textView.setTextColor(context.getResources().getColor(R.color.type_huodong));
|
||||
textView.setTextColor(Color.WHITE);
|
||||
textView.setBackgroundResource(R.drawable.textview_red_style);
|
||||
} else if ("杂谈".equals(type)){
|
||||
textView.setTextColor(context.getResources().getColor(R.color.type_gonggao));
|
||||
textView.setTextColor(Color.WHITE);
|
||||
textView.setBackgroundResource(R.drawable.textview_orange_style);
|
||||
} else if ("专题".equals(type)) {
|
||||
textView.setTextColor(context.getResources().getColor(R.color.type_xinyou));
|
||||
textView.setTextColor(Color.WHITE);
|
||||
textView.setBackgroundResource(R.drawable.textview_blue_style);
|
||||
} else {
|
||||
textView.setTextColor(context.getResources().getColor(R.color.type_gonglue));
|
||||
textView.setTextColor(Color.WHITE);
|
||||
textView.setBackgroundResource(R.drawable.textview_blue_style);
|
||||
}
|
||||
textView.setText(type);
|
||||
}
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
package com.gh.gamecenter.volley.extended;
|
||||
|
||||
import com.android.volley.NetworkResponse;
|
||||
import com.android.volley.Response;
|
||||
import com.android.volley.toolbox.HttpHeaderParser;
|
||||
import com.gh.common.util.Utils;
|
||||
|
||||
import org.json.JSONArray;
|
||||
|
||||
/**
|
||||
* Created by khy on 2016/8/24.
|
||||
*
|
||||
* 当请求成功时而返回值为空,不做判断
|
||||
* 返回值为空
|
||||
*/
|
||||
public class ConcernJsonArrayExtendedRequest extends JsonExtendedRequest<JSONArray>{
|
||||
private String url;
|
||||
|
||||
public ConcernJsonArrayExtendedRequest(int method, String url,
|
||||
JSONArray jsonRequest, Response.Listener<JSONArray> listener,
|
||||
Response.ErrorListener errorListener) {
|
||||
super(method, url, (jsonRequest == null) ? null : jsonRequest
|
||||
.toString(), listener, errorListener);
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Response<JSONArray> parseNetworkResponse(NetworkResponse response) {
|
||||
Utils.log(url + " = " + response.statusCode);
|
||||
return Response.success(new JSONArray(), HttpHeaderParser.parseCacheHeaders(response));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user