diff --git a/app/src/main/java/com/gh/base/BaseDetailActivity.java b/app/src/main/java/com/gh/base/BaseDetailActivity.java index be705425b9..3f32292bc6 100644 --- a/app/src/main/java/com/gh/base/BaseDetailActivity.java +++ b/app/src/main/java/com/gh/base/BaseDetailActivity.java @@ -229,12 +229,17 @@ public abstract class BaseDetailActivity extends BaseActivity implements View.On } } else { String status = GameUtils.getDownloadBtnText(this, gameEntity); - if ("插件化".equals(status)) { - detail_tv_download.setBackgroundResource(R.drawable.game_item_btn_plugin_style); - } else if ("打开".equals(status)) { - detail_tv_download.setBackgroundResource(R.drawable.game_item_btn_launch_style); - } else { - detail_tv_download.setBackgroundResource(R.drawable.game_item_btn_download_style); + + switch (status) { + case "插件化": + detail_tv_download.setBackgroundResource(R.drawable.game_item_btn_plugin_style); + break; + case "打开": + detail_tv_download.setBackgroundResource(R.drawable.game_item_btn_launch_style); + break; + default: + detail_tv_download.setBackgroundResource(R.drawable.game_item_btn_download_style); + break; } if (TextUtils.isEmpty(downloadAddWord)) { diff --git a/app/src/main/java/com/gh/base/GHPushMessageReceiver.java b/app/src/main/java/com/gh/base/GHPushMessageReceiver.java index 82ad3c8f97..b77d46b362 100644 --- a/app/src/main/java/com/gh/base/GHPushMessageReceiver.java +++ b/app/src/main/java/com/gh/base/GHPushMessageReceiver.java @@ -99,50 +99,55 @@ public class GHPushMessageReceiver extends PushMessageReceiver { if ("ALL".equals(channel) || channel.equalsIgnoreCase(packageChannel)) { String type = jsonObject.getString(KEY_TYPE); Utils.log("type = " + type); - if ("NEWS".equals(type)) { - // 新闻推送 - JSONArray jsonArray = jsonObject.getJSONArray("package"); - ArrayMap map = getInstalledMapFromLocal(context); - for (int i = 0; i < jsonArray.length(); i++) { - Boolean b = map.get(jsonArray.getString(i)); - if (b != null) { - // 显示推送的消息 - showNotification(context, jsonObject, 0); - break; + JSONArray jsonArray; + ArrayMap map; + switch (type) { + case "NEWS": + // 新闻推送 + jsonArray = jsonObject.getJSONArray("package"); + map = getInstalledMapFromLocal(context); + for (int i = 0; i < jsonArray.length(); i++) { + Boolean b = map.get(jsonArray.getString(i)); + if (b != null) { + // 显示推送的消息 + showNotification(context, jsonObject, 0); + break; + } } - } - } else if ("PLUGIN_UPDATE".equals(type)) { - // 插件更新推送 - JSONArray jsonArray = jsonObject.getJSONArray("apk"); - ArrayMap map = getInstalledMapFromLocal(context); - for (int i = 0; i < jsonArray.length(); i++) { - JSONObject apk = jsonArray.getJSONObject(i); - String packageName = apk.getString("package"); - Boolean b = map.get(packageName); - if (b != null) { - // 判断是否gh_version是否相同 - String gh_version = (String) PackageUtils - .getMetaData(context, packageName, "gh_version"); - if (gh_version != null) { - gh_version = gh_version.substring(2); - // 判断gh_version是否相同 - if (gh_version.equals(apk.getString("gh_version"))) { - // 判断version是否相同 - String version = PackageUtils.getVersionByPackage(context, packageName); - if (apk.getString("version").equals(version)) { - // 版本相同,无需显示插件更新,继续查看是否有可更新的游戏包 - continue; + break; + case "PLUGIN_UPDATE": + // 插件更新推送 + jsonArray = jsonObject.getJSONArray("apk"); + map = getInstalledMapFromLocal(context); + for (int i = 0; i < jsonArray.length(); i++) { + JSONObject apk = jsonArray.getJSONObject(i); + String packageName = apk.getString("package"); + Boolean b = map.get(packageName); + if (b != null) { + // 判断是否gh_version是否相同 + String gh_version = (String) PackageUtils + .getMetaData(context, packageName, "gh_version"); + if (gh_version != null) { + gh_version = gh_version.substring(2); + // 判断gh_version是否相同 + if (gh_version.equals(apk.getString("gh_version"))) { + // 判断version是否相同 + String version = PackageUtils.getVersionByPackage(context, packageName); + if (apk.getString("version").equals(version)) { + // 版本相同,无需显示插件更新,继续查看是否有可更新的游戏包 + continue; + } } } + // 显示推送的消息 + showNotification(context, jsonObject, 1); + break; } - // 显示推送的消息 - showNotification(context, jsonObject, 1); - break; } - } - } else if ("NEW_GAME".equals(type)) { - // 新游推送 - showNotification(context, jsonObject, 2); + break; + case "NEW_GAME": + // 新游推送 + showNotification(context, jsonObject, 2); } } } @@ -254,18 +259,24 @@ public class GHPushMessageReceiver extends PushMessageReceiver { bundle.putString(KEY_ENTRANCE, ENTRANCE_MIPUSH); String type = response.getString(KEY_TYPE); String target = response.getString(KEY_TARGET); - if (HOST_ARTICLE.equals(type)) { - bundle.putString(KEY_TO, "NewsDetailActivity"); - bundle.putString(KEY_NEWSID, target); - } else if (HOST_GAME.equals(type)) { - bundle.putString(KEY_TO, "GameDetailActivity"); - bundle.putString(KEY_GAMEID, target); - } else if (HOSt_COLUMN.equals(type)) { - bundle.putString(KEY_TO, "SubjectActivity"); - bundle.putString(KEY_ID, target); - } else if (HOST_WEB.equals(type)) { - bundle.putString(KEY_TO, "WebActivity"); - bundle.putString(KEY_URL, target); + + switch (type) { + case HOST_ARTICLE: + bundle.putString(KEY_TO, "NewsDetailActivity"); + bundle.putString(KEY_NEWSID, target); + break; + case HOST_GAME: + bundle.putString(KEY_TO, "GameDetailActivity"); + bundle.putString(KEY_GAMEID, target); + break; + case HOSt_COLUMN: + bundle.putString(KEY_TO, "SubjectActivity"); + bundle.putString(KEY_ID, target); + break; + case HOST_WEB: + bundle.putString(KEY_TO, "WebActivity"); + bundle.putString(KEY_URL, target); + break; } EntranceUtils.jumpActivity(context, bundle); } catch (JSONException e) { diff --git a/app/src/main/java/com/gh/base/GHUmengNotificationClickHandler.java b/app/src/main/java/com/gh/base/GHUmengNotificationClickHandler.java index 4c2506ad38..6345092a9a 100644 --- a/app/src/main/java/com/gh/base/GHUmengNotificationClickHandler.java +++ b/app/src/main/java/com/gh/base/GHUmengNotificationClickHandler.java @@ -24,18 +24,23 @@ public class GHUmengNotificationClickHandler extends UmengNotificationClickHandl bundle.putString(EntranceUtils.KEY_ENTRANCE, EntranceUtils.ENTRANCE_UMENG); String type = response.getString(EntranceUtils.KEY_TYPE); String target = response.getString(EntranceUtils.KEY_TARGET); - if (EntranceUtils.HOST_ARTICLE.equals(type)) { - bundle.putString(EntranceUtils.KEY_TO, "NewsDetailActivity"); - bundle.putString(EntranceUtils.KEY_NEWSID, target); - } else if (EntranceUtils.HOST_GAME.equals(type)) { - bundle.putString(EntranceUtils.KEY_TO, "GameDetailActivity"); - bundle.putString(EntranceUtils.KEY_GAMEID, target); - } else if (EntranceUtils.HOSt_COLUMN.equals(type)) { - bundle.putString(EntranceUtils.KEY_TO, "SubjectActivity"); - bundle.putString(EntranceUtils.KEY_ID, target); - } else if (EntranceUtils.HOST_WEB.equals(type)) { - bundle.putString(EntranceUtils.KEY_TO, "WebActivity"); - bundle.putString(EntranceUtils.KEY_URL, target); + switch (type) { + case EntranceUtils.HOST_ARTICLE: + bundle.putString(EntranceUtils.KEY_TO, "NewsDetailActivity"); + bundle.putString(EntranceUtils.KEY_NEWSID, target); + break; + case EntranceUtils.HOST_GAME: + bundle.putString(EntranceUtils.KEY_TO, "GameDetailActivity"); + bundle.putString(EntranceUtils.KEY_GAMEID, target); + break; + case EntranceUtils.HOSt_COLUMN: + bundle.putString(EntranceUtils.KEY_TO, "SubjectActivity"); + bundle.putString(EntranceUtils.KEY_ID, target); + break; + case EntranceUtils.HOST_WEB: + bundle.putString(EntranceUtils.KEY_TO, "WebActivity"); + bundle.putString(EntranceUtils.KEY_URL, target); + break; } EntranceUtils.jumpActivity(context, bundle); } catch (JSONException e) { diff --git a/app/src/main/java/com/gh/common/util/ConcernContentUtils.java b/app/src/main/java/com/gh/common/util/ConcernContentUtils.java index 496e7dac7a..4c07df02b1 100644 --- a/app/src/main/java/com/gh/common/util/ConcernContentUtils.java +++ b/app/src/main/java/com/gh/common/util/ConcernContentUtils.java @@ -25,28 +25,33 @@ public class ConcernContentUtils { int index = 0; for (int i = 0, size = (int) Math.ceil(list.size() / 3.0f); i < size; i++) { int type = count % 3; - if (type == 0) { - LinearLayout ll = new LinearLayout(context); - ll.setOrientation(LinearLayout.HORIZONTAL); - for (int j = 0; j < 3; j++) { - ll.addView(getImageView(context, list, entrance, index, width, 0)); + LinearLayout ll; + switch (type) { + case 0: + ll = new LinearLayout(context); + ll.setOrientation(LinearLayout.HORIZONTAL); + for (int j = 0; j < 3; j++) { + ll.addView(getImageView(context, list, entrance, index, width, 0)); + index += 1; + } + linearLayout.addView(ll); + count -= 3; + break; + case 1: + linearLayout.addView(getImageView(context, list, entrance, index, width, 1)); + count -= 1; index += 1; - } - linearLayout.addView(ll); - count -= 3; - } else if (type == 1) { - linearLayout.addView(getImageView(context, list, entrance, index, width, 1)); - count -= 1; - index += 1; - } else if (type == 2) { - LinearLayout ll = new LinearLayout(context); - ll.setOrientation(LinearLayout.HORIZONTAL); - for (int j = 0; j < 2; j++) { - ll.addView(getImageView(context, list, entrance, index, width, 2)); - index += 1; - } - linearLayout.addView(ll); - count -= 2; + break; + case 2: + ll = new LinearLayout(context); + ll.setOrientation(LinearLayout.HORIZONTAL); + for (int j = 0; j < 2; j++) { + ll.addView(getImageView(context, list, entrance, index, width, 2)); + index += 1; + } + linearLayout.addView(ll); + count -= 2; + break; } } } @@ -54,34 +59,39 @@ public class ConcernContentUtils { private static SimpleDraweeView getImageView(final Context context, final List list, final String entrance, final int position, int width, int type) { SimpleDraweeView imageView; - if (type == 0) { - imageView = new SimpleDraweeView(context); - LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams( - 0, width / 3 - DisplayUtils.dip2px(context, 4)); - lparams.setMargins(DisplayUtils.dip2px(context, 2), 0, - DisplayUtils.dip2px(context, 2), DisplayUtils.dip2px(context, 4)); - lparams.weight = 1; - imageView.setLayoutParams(lparams); - ImageUtils.getInstance().display(context.getResources(), imageView, - ScalingUtils.ScaleType.CENTER_CROP, list.get(position)); - } else if (type == 1) { - imageView = new SimpleDraweeView(context); - LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(width, width / 2); - lparams.setMargins(DisplayUtils.dip2px(context, 2), 0, - DisplayUtils.dip2px(context, 2), DisplayUtils.dip2px(context, 4)); - imageView.setLayoutParams(lparams); - ImageUtils.getInstance().display(context.getResources(), imageView, - ScalingUtils.ScaleType.CENTER_CROP, list.get(position)); - } else { - imageView = new SimpleDraweeView(context); - LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams( - 0, width / 2 - DisplayUtils.dip2px(context, 4)); - lparams.setMargins(DisplayUtils.dip2px(context, 2), 0, - DisplayUtils.dip2px(context, 2), DisplayUtils.dip2px(context, 4)); - lparams.weight = 1; - imageView.setLayoutParams(lparams); - ImageUtils.getInstance().display(context.getResources(), imageView, - ScalingUtils.ScaleType.CENTER_CROP, list.get(position)); + LinearLayout.LayoutParams lparams; + switch (type) { + case 0: + imageView = new SimpleDraweeView(context); + lparams = new LinearLayout.LayoutParams( + 0, width / 3 - DisplayUtils.dip2px(context, 4)); + lparams.setMargins(DisplayUtils.dip2px(context, 2), 0, + DisplayUtils.dip2px(context, 2), DisplayUtils.dip2px(context, 4)); + lparams.weight = 1; + imageView.setLayoutParams(lparams); + ImageUtils.getInstance().display(context.getResources(), imageView, + ScalingUtils.ScaleType.CENTER_CROP, list.get(position)); + break; + case 1: + imageView = new SimpleDraweeView(context); + lparams = new LinearLayout.LayoutParams(width, width / 2); + lparams.setMargins(DisplayUtils.dip2px(context, 2), 0, + DisplayUtils.dip2px(context, 2), DisplayUtils.dip2px(context, 4)); + imageView.setLayoutParams(lparams); + ImageUtils.getInstance().display(context.getResources(), imageView, + ScalingUtils.ScaleType.CENTER_CROP, list.get(position)); + break; + default: + imageView = new SimpleDraweeView(context); + lparams = new LinearLayout.LayoutParams( + 0, width / 2 - DisplayUtils.dip2px(context, 4)); + lparams.setMargins(DisplayUtils.dip2px(context, 2), 0, + DisplayUtils.dip2px(context, 2), DisplayUtils.dip2px(context, 4)); + lparams.weight = 1; + imageView.setLayoutParams(lparams); + ImageUtils.getInstance().display(context.getResources(), imageView, + ScalingUtils.ScaleType.CENTER_CROP, list.get(position)); + break; } imageView.setOnClickListener(new View.OnClickListener() { @Override diff --git a/app/src/main/java/com/gh/common/util/DownloadItemUtils.java b/app/src/main/java/com/gh/common/util/DownloadItemUtils.java index 92eaf80a13..752cab5ce3 100644 --- a/app/src/main/java/com/gh/common/util/DownloadItemUtils.java +++ b/app/src/main/java/com/gh/common/util/DownloadItemUtils.java @@ -329,48 +329,55 @@ public class DownloadItemUtils { final String location) { String str = downloadBtn.getText().toString(); - if ("下载".equals(str)) { - if (NetworkUtils.isWifiConnected(context)) { - download(context, gameEntity, downloadBtn, entrance, location); - } else { - DialogUtils.showDownloadDialog(context, new DialogUtils.ConfirmListener() { - @Override - public void onConfirm() { - download(context, gameEntity, downloadBtn, entrance, location); - } - }); - } - } else if ("插件化".equals(str)) { - if (NetworkUtils.isWifiConnected(context)) { - plugin(context, gameEntity, downloadBtn, entrance, location); - } else { - DialogUtils.showDownloadDialog(context, new DialogUtils.ConfirmListener() { - @Override - public void onConfirm() { - plugin(context, gameEntity, downloadBtn, entrance, location); - } - }); - } - } else if ("安装".equals(str)) { - install(context, gameEntity, position, adapter); - } else if ("启动".equals(str)) { - DataUtils.onGameLaunchEvent(context, gameEntity.getName(), gameEntity.getApk().get(0).getPlatform(), location); + switch (str) { + case "下载": + if (NetworkUtils.isWifiConnected(context)) { + download(context, gameEntity, downloadBtn, entrance, location); + } else { + DialogUtils.showDownloadDialog(context, new DialogUtils.ConfirmListener() { + @Override + public void onConfirm() { + download(context, gameEntity, downloadBtn, entrance, location); + } + }); + } + break; + case "插件化": + if (NetworkUtils.isWifiConnected(context)) { + plugin(context, gameEntity, downloadBtn, entrance, location); + } else { + DialogUtils.showDownloadDialog(context, new DialogUtils.ConfirmListener() { + @Override + public void onConfirm() { + plugin(context, gameEntity, downloadBtn, entrance, location); + } + }); + } + break; + case "安装": + install(context, gameEntity, position, adapter); + break; + case "启动": + DataUtils.onGameLaunchEvent(context, gameEntity.getName(), gameEntity.getApk().get(0).getPlatform(), location); - PackageUtils.launchApplicationByPackageName(context, gameEntity.getApk().get(0).getPackageName()); - } else if ("下载中".equals(str)) { - context.startActivity( - DownloadManagerActivity.getDownloadMangerIntent(context, gameEntity.getApk().get(0).getUrl(), entrance + "+(" + location.split(":")[0] + ")")); - } else if ("更新".equals(str)) { - if (NetworkUtils.isWifiConnected(context)) { - update(context, gameEntity, entrance, location); - } else { - DialogUtils.showDownloadDialog(context, new DialogUtils.ConfirmListener() { - @Override - public void onConfirm() { - update(context, gameEntity, entrance, location); - } - }); - } + PackageUtils.launchApplicationByPackageName(context, gameEntity.getApk().get(0).getPackageName()); + break; + case "下载中": + context.startActivity( + DownloadManagerActivity.getDownloadMangerIntent(context, gameEntity.getApk().get(0).getUrl(), entrance + "+(" + location.split(":")[0] + ")")); + break; + case "更新": + if (NetworkUtils.isWifiConnected(context)) { + update(context, gameEntity, entrance, location); + } else { + DialogUtils.showDownloadDialog(context, new DialogUtils.ConfirmListener() { + @Override + public void onConfirm() { + update(context, gameEntity, entrance, location); + } + }); + } + break; } } diff --git a/app/src/main/java/com/gh/common/util/FileUtils.java b/app/src/main/java/com/gh/common/util/FileUtils.java index ce2360e9d3..151de7ac1d 100644 --- a/app/src/main/java/com/gh/common/util/FileUtils.java +++ b/app/src/main/java/com/gh/common/util/FileUtils.java @@ -284,20 +284,24 @@ public class FileUtils { int statusCode = connection.getResponseCode(); Utils.log("statusCode = " + statusCode); - if (statusCode == 200) { - // {"icon":"http:\/\/gh-test-1.oss-cn-qingdao.aliyuncs.com\/pic\/57e4f4d58a3200042d29492f.jpg"} - JSONObject response = new JSONObject(b.toString().trim()); - response.put("statusCode", 200); - return response; - } else if (statusCode == 403) { - JSONObject response = new JSONObject(b.toString().trim()); - response.put("statusCode", 403); - return response; - } else if (statusCode == 401) { - JSONObject response = new JSONObject(); - response.put("statusCode", 401); - return response; + JSONObject response = null; + switch (statusCode) { + case 200: + // {"icon":"http:\/\/gh-test-1.oss-cn-qingdao.aliyuncs.com\/pic\/57e4f4d58a3200042d29492f.jpg"} + response = new JSONObject(b.toString().trim()); + response.put("statusCode", 200); + break; + case 403: + response = new JSONObject(b.toString().trim()); + response.put("statusCode", 403); + break; + case 401: + response = new JSONObject(); + response.put("statusCode", 401); + break; } + + return response; } catch (Exception e) { // 显示异常信息 e.printStackTrace(); diff --git a/app/src/main/java/com/gh/common/util/LibaoUtils.java b/app/src/main/java/com/gh/common/util/LibaoUtils.java index 24784bf6d7..a41c6b55b7 100644 --- a/app/src/main/java/com/gh/common/util/LibaoUtils.java +++ b/app/src/main/java/com/gh/common/util/LibaoUtils.java @@ -327,12 +327,16 @@ public class LibaoUtils { if (TextUtils.isEmpty(libaoCode)) { try { String detail = responseBody.getString("detail"); - if ("maintaining".equals(detail)) { - Utils.toast(context, "网络状态异常,请稍后再试"); - } else if ("fail to compete".equals(detail)) { - Utils.toast(context, "淘号失败,稍后重试"); - } else { - Utils.toast(context, "淘号异常"); + switch (detail) { + case "maintaining": + Utils.toast(context, "网络状态异常,请稍后再试"); + break; + case "fail to compete": + Utils.toast(context, "淘号失败,稍后重试"); + break; + default: + Utils.toast(context, "淘号异常"); + break; } } catch (JSONException e) { e.printStackTrace(); @@ -391,33 +395,43 @@ public class LibaoUtils { JSONObject errorJson = new JSONObject(exception.response().errorBody().string()); String detail = errorJson.getString("detail"); Utils.toast(context, "返回::" + detail); - if ("coming".equals(detail)) { - Utils.toast(context, "礼包领取时间未开始"); - } else if ("finish".equals(detail)) { - Utils.toast(context, "礼包领取时间已结束"); - } else if ("fetched".equals(detail)) { - Utils.toast(context, "你已领过这个礼包了"); - getCunHaoXiang(context, true); + switch (detail) { + case "coming": + Utils.toast(context, "礼包领取时间未开始"); + break; + case "finish": + Utils.toast(context, "礼包领取时间已结束"); + break; + case "fetched": + Utils.toast(context, "你已领过这个礼包了"); + getCunHaoXiang(context, true); + + int[][] states2 = new int[2][]; + states2[0] = new int[]{android.R.attr.state_pressed}; + states2[1] = new int[]{}; + int[] colors2 = new int[]{Color.WHITE, + Color.parseColor("#ffb13c")}; + ColorStateList sl2 = new ColorStateList(states2, colors2); + libaoBtn.setText("已淘号"); + libaoBtn.setBackgroundResource(R.drawable.libao_taoed_style); + libaoBtn.setTextColor(sl2); + libaoEntity.setStatus("taoed"); + break; + case "try tao": + case "used up": + DialogUtils.showHintDialog(context, "礼包已领光" + , "手速不够快,礼包已经被抢光了,十分抱歉", "知道了"); + break; + case "maintaining": + Utils.toast(context, "网络状态异常,请稍后再试"); + break; + case "fail to compete": + Utils.toast(context, "淘号失败,稍后重试"); + break; + default: + Utils.toast(context, "操作失败"); + break; - int[][] states2 = new int[2][]; - states2[0] = new int[]{android.R.attr.state_pressed}; - states2[1] = new int[]{}; - int[] colors2 = new int[]{Color.WHITE, - Color.parseColor("#ffb13c")}; - ColorStateList sl2 = new ColorStateList(states2, colors2); - libaoBtn.setText("已淘号"); - libaoBtn.setBackgroundResource(R.drawable.libao_taoed_style); - libaoBtn.setTextColor(sl2); - libaoEntity.setStatus("taoed"); - } else if ("try tao".equals(detail) || "used up".equals(detail)) { - DialogUtils.showHintDialog(context, "礼包已领光" - , "手速不够快,礼包已经被抢光了,十分抱歉", "知道了"); - } else if ("maintaining".equals(detail)) { - Utils.toast(context, "网络状态异常,请稍后再试"); - } else if ("fail to compete".equals(detail)) { - Utils.toast(context, "淘号失败,稍后重试"); - } else { - Utils.toast(context, "操作失败"); } } catch (Exception ex) { ex.printStackTrace(); @@ -509,43 +523,50 @@ public class LibaoUtils { JSONObject errorJson = new JSONObject(string); String detail = errorJson.getString("detail"); - if ("coming".equals(detail)) { - Utils.toast(context, "礼包领取时间未开始"); - } else if ("finish".equals(detail)) { - Utils.toast(context, "礼包领取时间已结束"); - } else if ("fetched".equals(detail)) { - Utils.toast(context, "你已领过这个礼包了"); - int countdown = 0; - if (errorJson.toString().contains("countdown")) { - countdown = errorJson.getInt("countdown"); - } - if (countdown > 0 && countdown < 60 * 10) { - EventBus.getDefault().post(new EBUISwitch(REFRESH_LIBAO_TIME, countdown)); - } else { - getCunHaoXiang(context, true); - } + switch (detail) { + case "coming": + Utils.toast(context, "礼包领取时间未开始"); + break; + case "finish": + Utils.toast(context, "礼包领取时间已结束"); + break; + case "fetched": + Utils.toast(context, "你已领过这个礼包了"); + int countdown = 0; + if (errorJson.toString().contains("countdown")) { + countdown = errorJson.getInt("countdown"); + } + if (countdown > 0 && countdown < 60 * 10) { + EventBus.getDefault().post(new EBUISwitch(REFRESH_LIBAO_TIME, countdown)); + } else { + getCunHaoXiang(context, true); + } - int[][] states = new int[2][]; - states[0] = new int[]{android.R.attr.state_pressed}; - states[1] = new int[]{}; - int[] colors = new int[]{Color.WHITE, - Color.parseColor("#06D0A8")}; - ColorStateList sl = new ColorStateList(states, colors); - libaoBtn.setText("已领取"); - libaoBtn.setBackgroundResource(R.drawable.libao_linged_style); - libaoBtn.setTextColor(sl); + int[][] states = new int[2][]; + states[0] = new int[]{android.R.attr.state_pressed}; + states[1] = new int[]{}; + int[] colors = new int[]{Color.WHITE, + Color.parseColor("#06D0A8")}; + ColorStateList sl = new ColorStateList(states, colors); + libaoBtn.setText("已领取"); + libaoBtn.setBackgroundResource(R.drawable.libao_linged_style); + libaoBtn.setTextColor(sl); - libaoEntity.setStatus("linged"); - } else if ("try tao".equals(detail) || "used up".equals(detail)) { - DialogUtils.showHintDialog(context, "礼包已领光" - , "手速不够快,礼包已经被抢光了,十分抱歉", "知道了"); - libaoEntity.setStatus("used_up"); - initLibaoBtn(context, libaoBtn, libaoEntity, libaoDao, isInstallRequired, adapter, entrance); - - } else if ("maintaining".equals(detail)) { - Utils.toast(context, "网络状态异常,请稍后再试"); - } else { - Utils.toast(context, "操作失败"); + libaoEntity.setStatus("linged"); + break; + case "try tao": + case "used up": + DialogUtils.showHintDialog(context, "礼包已领光" + , "手速不够快,礼包已经被抢光了,十分抱歉", "知道了"); + libaoEntity.setStatus("used_up"); + initLibaoBtn(context, libaoBtn, libaoEntity, libaoDao, isInstallRequired, adapter, entrance); + break; + case "maintaining": + Utils.toast(context, "网络状态异常,请稍后再试"); + break; + default: + Utils.toast(context, "操作失败"); + break; } } catch (Exception ex) { ex.printStackTrace(); diff --git a/app/src/main/java/com/gh/common/util/NewsUtils.java b/app/src/main/java/com/gh/common/util/NewsUtils.java index c51e1a396d..7d8155cc3c 100644 --- a/app/src/main/java/com/gh/common/util/NewsUtils.java +++ b/app/src/main/java/com/gh/common/util/NewsUtils.java @@ -24,16 +24,20 @@ public class NewsUtils { * 根据新闻类型获取标签背景资源 */ public static int getDrawableIdByType(String type) { - if ("活动".equals(type) || "高阶".equals(type)) { - return R.drawable.textview_red_up; - } else if ("公告".equals(type) || "中期".equals(type)) { - return R.drawable.textview_orange_up; - } else if ("新游".equals(type)) { - return R.drawable.textview_green_up; - } else if ("热门".equals(type) || "置顶".equals(type)) { - return R.drawable.textview_all_red_up; - } else { - return R.drawable.textview_blue_up; + switch (type) { + case "活动": + case "高阶": + return R.drawable.textview_red_up; + case "公告": + case "中期": + return R.drawable.textview_orange_up; + case "新游": + return R.drawable.textview_green_up; + case "热门": + case "置顶": + return R.drawable.textview_all_red_up; + default: + return R.drawable.textview_blue_up; } } @@ -86,18 +90,25 @@ public class NewsUtils { } textView.setTextColor(Color.WHITE); - if ("活动".equals(type)) { - textView.setBackgroundResource(R.drawable.textview_orange_style); - } else if ("公告".equals(type)) { - textView.setBackgroundResource(R.drawable.textview_red_style); - } else if ("评测".equals(type)) { - textView.setBackgroundResource(R.drawable.textview_red_style); - } else if ("杂谈".equals(type)) { - textView.setBackgroundResource(R.drawable.textview_orange_style); - } else if ("专题".equals(type)) { - textView.setBackgroundResource(R.drawable.textview_blue_style); - } else { - textView.setBackgroundResource(R.drawable.textview_blue_style); + switch (type) { + case "活动": + textView.setBackgroundResource(R.drawable.textview_orange_style); + break; + case "公告": + textView.setBackgroundResource(R.drawable.textview_red_style); + break; + case "评测": + textView.setBackgroundResource(R.drawable.textview_red_style); + break; + case "杂谈": + textView.setBackgroundResource(R.drawable.textview_orange_style); + break; + case "专题": + textView.setBackgroundResource(R.drawable.textview_blue_style); + break; + default: + textView.setBackgroundResource(R.drawable.textview_blue_style); + break; } } diff --git a/app/src/main/java/com/gh/download/DownloadManager.java b/app/src/main/java/com/gh/download/DownloadManager.java index 273b1bced0..89f0ffad1b 100644 --- a/app/src/main/java/com/gh/download/DownloadManager.java +++ b/app/src/main/java/com/gh/download/DownloadManager.java @@ -49,26 +49,28 @@ public class DownloadManager { handler = new Handler(context.getMainLooper()) { @Override public void handleMessage(Message msg) { - if (msg.what == Constants.CONTINUE_DOWNLOAD_TASK) { - String url = (String) msg.obj; - if (System.currentTimeMillis() - lastTimeMap.get(url) >= 1000) { - resume(url); - } - } else if (msg.what == Constants.PAUSE_DOWNLOAD_TASK) { - String url = (String) msg.obj; - if (System.currentTimeMillis() - lastTimeMap.get(url) >= 1000) { - pause(url); - } - } else if (msg.what == Constants.DOWNLOAD_ROLL) { - String name = (String) msg.obj; - LinkedBlockingQueue queue = platformMap.get(name); - if (queue.size() > 1) { - queue.offer(queue.poll()); - Message message = Message.obtain(); - message.obj = name; - message.what = Constants.DOWNLOAD_ROLL; - sendMessageDelayed(message, 3000); - } + String url = (String) msg.obj; + switch (msg.what) { + case Constants.CONTINUE_DOWNLOAD_TASK: + if (System.currentTimeMillis() - lastTimeMap.get(url) >= 1000) { + resume(url); + } + break; + case Constants.PAUSE_DOWNLOAD_TASK: + if (System.currentTimeMillis() - lastTimeMap.get(url) >= 1000) { + pause(url); + } + break; + case Constants.DOWNLOAD_ROLL: + LinkedBlockingQueue queue = platformMap.get(url); + if (queue.size() > 1) { + queue.offer(queue.poll()); + Message message = Message.obtain(); + message.obj = url; + message.what = Constants.DOWNLOAD_ROLL; + sendMessageDelayed(message, 3000); + } + break; } } }; diff --git a/app/src/main/java/com/gh/gamecenter/CropImageActivity.java b/app/src/main/java/com/gh/gamecenter/CropImageActivity.java index 2a87228a14..b50a42dc16 100644 --- a/app/src/main/java/com/gh/gamecenter/CropImageActivity.java +++ b/app/src/main/java/com/gh/gamecenter/CropImageActivity.java @@ -56,12 +56,16 @@ public class CropImageActivity extends BaseActivity { private Handler handler = new Handler() { @Override public void handleMessage(Message msg) { - if (msg.what == 0) { - toast("上传成功"); - } else if (msg.what == 1) { - toast("上传失败"); - } else if (msg.what == 2) { - toast("修改太频繁,请稍后再试"); + switch (msg.what) { + case 0: + toast("上传成功"); + break; + case 1: + toast("上传失败"); + break; + case 2: + toast("修改太频繁,请稍后再试"); + break; } } }; diff --git a/app/src/main/java/com/gh/gamecenter/FileReceiverActivity.java b/app/src/main/java/com/gh/gamecenter/FileReceiverActivity.java index 049c9d906f..48f7d1441e 100644 --- a/app/src/main/java/com/gh/gamecenter/FileReceiverActivity.java +++ b/app/src/main/java/com/gh/gamecenter/FileReceiverActivity.java @@ -135,23 +135,30 @@ public class FileReceiverActivity extends BaseActivity implements OnReceiverCanc return; } FileInfo fileInfo = mFileInfos.get(index); - if (msg.what == FileInfo.FLAG_DEFAULT) { // 传输中更新界面 - long progress = (long) msg.obj; - fileInfo.setProgress(progress); - fileInfo.setResult(FileInfo.FLAG_DEFAULT); - } else if (msg.what == FileInfo.FLAG_SUCCESS) { // 传输成功更新界面 - fileInfo.setResult(FileInfo.FLAG_SUCCESS); - if (index == mFileInfos.size() - 1) initSenderHint(false); - } else if (msg.what == FileInfo.FLAG_FAILURE) { // 传输失败更新界面 - fileInfo.setResult(FileInfo.FLAG_FAILURE); - if (index == mFileInfos.size() - 1) initSenderHint(false); - } else if (msg.what == FileInfo.FLAG_CANCEL) { // 传输取消更新界面 - fileInfo.setResult(FileInfo.FLAG_CANCEL); - if (index == mFileInfos.size() - 1) initSenderHint(false); - } else if (msg.what == FileInfo.FLAG_NO_MEMORY) { - Utils.toast(FileReceiverActivity.this, "手机空间不足"); - fileInfo.setResult(FileInfo.FLAG_NO_MEMORY); // 接收方内存不足 - if (index == mFileInfos.size() - 1) initSenderHint(true); + + switch (msg.what) { + case FileInfo.FLAG_DEFAULT:// 传输中更新界面 + long progress = (long) msg.obj; + fileInfo.setProgress(progress); + fileInfo.setResult(FileInfo.FLAG_DEFAULT); + break; + case FileInfo.FLAG_SUCCESS:// 传输成功更新界面 + fileInfo.setResult(FileInfo.FLAG_SUCCESS); + if (index == mFileInfos.size() - 1) initSenderHint(false); + break; + case FileInfo.FLAG_FAILURE: // 传输失败更新界面 + fileInfo.setResult(FileInfo.FLAG_FAILURE); + if (index == mFileInfos.size() - 1) initSenderHint(false); + break; + case FileInfo.FLAG_CANCEL: // 传输取消更新界面 + fileInfo.setResult(FileInfo.FLAG_CANCEL); + if (index == mFileInfos.size() - 1) initSenderHint(false); + break; + case FileInfo.FLAG_NO_MEMORY: + Utils.toast(FileReceiverActivity.this, "手机空间不足"); + fileInfo.setResult(FileInfo.FLAG_NO_MEMORY); // 接收方内存不足 + if (index == mFileInfos.size() - 1) initSenderHint(true); + break; } Utils.log("FileReceiverActivity:: 刷新位置::" + index + "刷新状态::" + msg.what); diff --git a/app/src/main/java/com/gh/gamecenter/FileSenderActivity.java b/app/src/main/java/com/gh/gamecenter/FileSenderActivity.java index 603e2fecca..ec252756e0 100644 --- a/app/src/main/java/com/gh/gamecenter/FileSenderActivity.java +++ b/app/src/main/java/com/gh/gamecenter/FileSenderActivity.java @@ -81,27 +81,28 @@ public class FileSenderActivity extends BaseActivity implements FileSenderAdapte @Override public void handleMessage(Message msg) { super.handleMessage(msg); - if (msg.what == FileInfo.FLAG_DEFAULT) { - int position = (int) msg.obj; - mFileInfos.get(position).setResult(FileInfo.FLAG_DEFAULT); - mSenderAdapter.notifyItemChanged(position); - } else if (msg.what == FileInfo.FLAG_SUCCESS) { - int position = (int) msg.obj; - mFileInfos.get(position).setResult(FileInfo.FLAG_SUCCESS); - mSenderAdapter.notifyItemChanged(position); - if (position == mFileInfos.size() - 1) initSenderHint(); - } else if (msg.what == FileInfo.FLAG_FAILURE) { - int position = (int) msg.obj; - mFileInfos.get(position).setResult(FileInfo.FLAG_FAILURE); - mSenderAdapter.notifyItemChanged(position); - if (position == mFileInfos.size() - 1) initSenderHint(); - } else if (msg.what == FileInfo.FLAG_CANCEL) { - int position = (int) msg.obj; - mFileInfos.get(position).setResult(FileInfo.FLAG_CANCEL); - mSenderAdapter.notifyItemChanged(position); - if (position == mFileInfos.size() - 1) initSenderHint(); + int position = (int) msg.obj; + switch (msg.what) { + case FileInfo.FLAG_DEFAULT: + mFileInfos.get(position).setResult(FileInfo.FLAG_DEFAULT); + mSenderAdapter.notifyItemChanged(position); + break; + case FileInfo.FLAG_SUCCESS: + mFileInfos.get(position).setResult(FileInfo.FLAG_SUCCESS); + mSenderAdapter.notifyItemChanged(position); + if (position == mFileInfos.size() - 1) initSenderHint(); + break; + case FileInfo.FLAG_FAILURE: + mFileInfos.get(position).setResult(FileInfo.FLAG_FAILURE); + mSenderAdapter.notifyItemChanged(position); + if (position == mFileInfos.size() - 1) initSenderHint(); + break; + case FileInfo.FLAG_CANCEL: + mFileInfos.get(position).setResult(FileInfo.FLAG_CANCEL); + mSenderAdapter.notifyItemChanged(position); + if (position == mFileInfos.size() - 1) initSenderHint(); + break; } - } }; diff --git a/app/src/main/java/com/gh/gamecenter/LibaoActivity.java b/app/src/main/java/com/gh/gamecenter/LibaoActivity.java index e11ed99e6c..f16b0a0bd0 100644 --- a/app/src/main/java/com/gh/gamecenter/LibaoActivity.java +++ b/app/src/main/java/com/gh/gamecenter/LibaoActivity.java @@ -129,18 +129,22 @@ public class LibaoActivity extends BaseActivity implements View.OnClickListener, @Override public void onPageSelected(int position) { - if (position == 0) { - mZuixinTv.setSelected(true); - mGuanzhuTv.setSelected(false); - mChunhaoxiangTv.setSelected(false); - } else if (position == 1) { - mZuixinTv.setSelected(false); - mGuanzhuTv.setSelected(true); - mChunhaoxiangTv.setSelected(false); - } else if (position == 2) { - mZuixinTv.setSelected(false); - mGuanzhuTv.setSelected(false); - mChunhaoxiangTv.setSelected(true); + switch (position) { + case 0: + mZuixinTv.setSelected(true); + mGuanzhuTv.setSelected(false); + mChunhaoxiangTv.setSelected(false); + break; + case 1: + mZuixinTv.setSelected(false); + mGuanzhuTv.setSelected(true); + mChunhaoxiangTv.setSelected(false); + break; + case 2: + mZuixinTv.setSelected(false); + mGuanzhuTv.setSelected(false); + mChunhaoxiangTv.setSelected(true); + break; } } diff --git a/app/src/main/java/com/gh/gamecenter/LibaoDetailActivity.java b/app/src/main/java/com/gh/gamecenter/LibaoDetailActivity.java index c672968cfa..4ffcb1e53e 100644 --- a/app/src/main/java/com/gh/gamecenter/LibaoDetailActivity.java +++ b/app/src/main/java/com/gh/gamecenter/LibaoDetailActivity.java @@ -82,6 +82,15 @@ public class LibaoDetailActivity extends BaseDetailActivity implements LibaoDeta return intent; } + @NonNull + public static Intent getIntentById(Context context, String id, String entrance) { + Intent intent = new Intent(context, LibaoDetailActivity.class); + intent.putExtra(EntranceUtils.KEY_ENTRANCE, entrance); + intent.putExtra("id", id); + return intent; + } + + @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); diff --git a/app/src/main/java/com/gh/gamecenter/MessageDetailActivity.java b/app/src/main/java/com/gh/gamecenter/MessageDetailActivity.java index dcaaf4d836..5abe7d7be8 100644 --- a/app/src/main/java/com/gh/gamecenter/MessageDetailActivity.java +++ b/app/src/main/java/com/gh/gamecenter/MessageDetailActivity.java @@ -475,17 +475,23 @@ public class MessageDetailActivity extends BaseActivity implements OnCommentCall try { JSONObject errorJson = new JSONObject(exception.response().errorBody().string()); String detail = errorJson.getString("detail"); - if ("too frequent".equals(detail)) { - toast("别话痨哦~休息一会再来评论吧~"); - } else if ("user blocked".equals(detail)) { - toast("账号状态异常,暂时无法发表评论"); - } else if ("article blocked".equals(detail)) { - toast("文章异常,无法发表评论"); - setSoftInput(false); - } else if ("illegal".equals(detail)) { - toast("评论内容可能包括敏感信息,请修改后再发表"); - } else { - toast("评论失败,未知原因"); + switch (detail) { + case "too frequent": + toast("别话痨哦~休息一会再来评论吧~"); + break; + case "user blocked": + toast("账号状态异常,暂时无法发表评论"); + break; + case "article blocked": + toast("文章异常,无法发表评论"); + setSoftInput(false); + break; + case "illegal": + toast("评论内容可能包括敏感信息,请修改后再发表"); + break; + default: + toast("评论失败,未知原因"); + break; } } catch (Exception ex) { ex.printStackTrace(); diff --git a/app/src/main/java/com/gh/gamecenter/NewsDetailActivity.java b/app/src/main/java/com/gh/gamecenter/NewsDetailActivity.java index 309d5efd3a..5c68b041bd 100644 --- a/app/src/main/java/com/gh/gamecenter/NewsDetailActivity.java +++ b/app/src/main/java/com/gh/gamecenter/NewsDetailActivity.java @@ -7,6 +7,7 @@ import android.content.SharedPreferences; import android.os.Bundle; import android.os.Handler; import android.os.SystemClock; +import android.support.annotation.NonNull; import android.support.v4.content.ContextCompat; import android.support.v4.view.MotionEventCompat; import android.support.v7.widget.LinearLayoutManager; @@ -178,6 +179,14 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener } + @NonNull + public static Intent getIntentById(Context context, String newsId, String entrance) { + Intent intent = new Intent(context, NewsDetailActivity.class); + intent.putExtra(EntranceUtils.KEY_ENTRANCE, entrance); + intent.putExtra("newsId", newsId); + return intent; + } + // @Override // protected void onActivityResult(int requestCode, int resultCode, Intent data) { // super.onActivityResult(requestCode, resultCode, data); diff --git a/app/src/main/java/com/gh/gamecenter/SearchActivity.java b/app/src/main/java/com/gh/gamecenter/SearchActivity.java index 10b47accde..de7445cb4b 100644 --- a/app/src/main/java/com/gh/gamecenter/SearchActivity.java +++ b/app/src/main/java/com/gh/gamecenter/SearchActivity.java @@ -206,53 +206,59 @@ public class SearchActivity extends BaseActivity { private void search(String type, String key) { searchType = type; - if ("auto".equals(type)) { - //自动搜索 - searchKey = key; - setResultPresentModel(1); - } else if ("default".equals(type)) { - //默认搜索 - isSearchDetail = true; - searchKey = key; - searchInput.setText(key); - searchInput.setSelection(searchInput.getText().length()); - setResultPresentModel(2); - isSearchDetail = false; - } else if ("remen".equals(type)) { - //热门搜索 - isSearchDetail = true; - searchKey = key; - Utils.log("=======key::" + key); - searchInput.setText(key); - searchInput.setSelection(searchInput.getText().length()); - setResultPresentModel(2); - isSearchDetail = false; - } else if ("history".equals(type)) { - //历史搜索 - isSearchDetail = true; - searchKey = key; - searchInput.setText(key); - searchInput.setSelection(searchInput.getText().length()); - setResultPresentModel(2); - isSearchDetail = false; - } else if ("initiative".equals(type)) { - //主动搜索 - String newSearchKey = searchInput.getText().toString().trim(); - if (newSearchKey.length() < 1) { - String hint = searchInput.getHint().toString(); - if (!TextUtils.isEmpty(hint) && !"搜索游戏...".equals(hint)) { - dao.add(hint); - search("default", hint); + switch (type) { + case "auto": + //自动搜索 + searchKey = key; + setResultPresentModel(1); + break; + case "default": + //默认搜索 + isSearchDetail = true; + searchKey = key; + searchInput.setText(key); + searchInput.setSelection(searchInput.getText().length()); + setResultPresentModel(2); + isSearchDetail = false; + break; + case "remen": + //热门搜索 + isSearchDetail = true; + searchKey = key; + Utils.log("=======key::" + key); + searchInput.setText(key); + searchInput.setSelection(searchInput.getText().length()); + setResultPresentModel(2); + isSearchDetail = false; + break; + case "history": + //历史搜索 + isSearchDetail = true; + searchKey = key; + searchInput.setText(key); + searchInput.setSelection(searchInput.getText().length()); + setResultPresentModel(2); + isSearchDetail = false; + break; + case "initiative": + //主动搜索 + String newSearchKey = searchInput.getText().toString().trim(); + if (newSearchKey.length() < 1) { + String hint = searchInput.getHint().toString(); + if (!TextUtils.isEmpty(hint) && !"搜索游戏...".equals(hint)) { + dao.add(hint); + search("default", hint); + } + } else if (!newSearchKey.equals(searchKey) || currentTab != 2) { + searchKey = newSearchKey; + if (!TextUtils.isEmpty(searchKey)) { + dao.add(searchKey); + setResultPresentModel(2); + } else { + toast("请输入搜索内容"); + } } - } else if (!newSearchKey.equals(searchKey) || currentTab != 2) { - searchKey = newSearchKey; - if (!TextUtils.isEmpty(searchKey)) { - dao.add(searchKey); - setResultPresentModel(2); - } else { - toast("请输入搜索内容"); - } - } + break; } } @@ -284,16 +290,22 @@ public class SearchActivity extends BaseActivity { @Subscribe(threadMode = ThreadMode.MAIN) public void onEvent(EBSearch search) { - if ("history".equals(search.getType())) { - search("history", search.getKey()); - } else if ("remen".equals(search.getType())) { - search("remen", search.getKey()); - } else if ("click".equals(search.getType())) { - DataCollectionUtils.uploadSearchClick(this, searchKey, searchType, "搜索页面", - search.getGameId(), search.getGameName()); - } else if ("search".equals(search.getType())) { - DataCollectionUtils.uploadSearch(this, searchKey, searchType, "搜索页面", - search.getGameId(), search.getGameName()); + + switch (search.getType()) { + case "history": + search("history", search.getKey()); + break; + case "remen": + search("remen", search.getKey()); + break; + case "click": + DataCollectionUtils.uploadSearchClick(this, searchKey, searchType, "搜索页面", + search.getGameId(), search.getGameName()); + break; + case "search": + DataCollectionUtils.uploadSearch(this, searchKey, searchType, "搜索页面", + search.getGameId(), search.getGameName()); + break; } } diff --git a/app/src/main/java/com/gh/gamecenter/WeiBoShareActivity.java b/app/src/main/java/com/gh/gamecenter/WeiBoShareActivity.java index cdf49c470f..e1e48abe0d 100644 --- a/app/src/main/java/com/gh/gamecenter/WeiBoShareActivity.java +++ b/app/src/main/java/com/gh/gamecenter/WeiBoShareActivity.java @@ -71,7 +71,7 @@ public class WeiBoShareActivity extends Activity implements WbShareCallback { ispopupWindow = extras.getBoolean("ispopupWindow"); isToolsBox = extras.getBoolean("isToolsBox"); - Utils.toast(this, "分享跳转中..."); + Utils.toast(this, getString(R.string.share_skip)); mWeiboShareAPI = new WbShareHandler(this); mWeiboShareAPI.registerApp(); @@ -116,8 +116,8 @@ public class WeiBoShareActivity extends Activity implements WbShareCallback { WebpageObject webObject = new WebpageObject(); webObject.identify = Utility.generateGUID(); webObject.title = ""; - webObject.description = "光环助手"; - webObject.defaultText = "光环助手"; + webObject.description = getString(R.string.app_name); + webObject.defaultText = getString(R.string.app_name); webObject.actionUrl = shareUrl; webObject.setThumbImage(bgBitmap); @@ -138,19 +138,19 @@ public class WeiBoShareActivity extends Activity implements WbShareCallback { @Override public void onWbShareSuccess() { - Toast.makeText(this, "分享成功", Toast.LENGTH_SHORT).show(); + Toast.makeText(this, R.string.share_success_hint, Toast.LENGTH_SHORT).show(); finish(); } @Override public void onWbShareCancel() { - Toast.makeText(this, "分享取消", Toast.LENGTH_SHORT).show(); + Toast.makeText(this, R.string.share_cancel_hint, Toast.LENGTH_SHORT).show(); finish(); } @Override public void onWbShareFail() { - Toast.makeText(this, "分享失败", Toast.LENGTH_SHORT).show(); + Toast.makeText(this, R.string.share_fail_hint, Toast.LENGTH_SHORT).show(); finish(); } } diff --git a/app/src/main/java/com/gh/gamecenter/adapter/FileReceiverAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/FileReceiverAdapter.java index 9664b07ec7..464361c292 100644 --- a/app/src/main/java/com/gh/gamecenter/adapter/FileReceiverAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/adapter/FileReceiverAdapter.java @@ -80,72 +80,83 @@ public class FileReceiverAdapter extends BaseRecyclerAdapter { @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { - if (viewType == ItemViewType.LOADING) { - View view = mLayoutInflater.inflate(R.layout.refresh_footerview, viewGroup, false); - return new FooterViewHolder(view); - } else if (viewType == ItemViewType.GAME_TEST) { - View view = mLayoutInflater.inflate(R.layout.game_test_item, viewGroup, false); - return new GameTestViewHolder(view); - } else if (viewType == 100) { - View view = new View(mContext); - view.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, DisplayUtils.dip2px(mContext, 4))); - return new ReuseViewHolder(view); + View view; + switch (viewType) { + case ItemViewType.LOADING: + view = mLayoutInflater.inflate(R.layout.refresh_footerview, viewGroup, false); + return new FooterViewHolder(view); + case ItemViewType.GAME_TEST: + view = mLayoutInflater.inflate(R.layout.game_test_item, viewGroup, false); + return new GameTestViewHolder(view); + case 100: + view = new View(mContext); + view.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, DisplayUtils.dip2px(mContext, 4))); + default: + return null; } - return null; } @Override diff --git a/app/src/main/java/com/gh/gamecenter/adapter/KcSelectGameAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/KcSelectGameAdapter.java index 6c3fb98c0f..7f4583793b 100644 --- a/app/src/main/java/com/gh/gamecenter/adapter/KcSelectGameAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/adapter/KcSelectGameAdapter.java @@ -166,28 +166,31 @@ public class KcSelectGameAdapter extends BaseRecyclerAdapter { @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { - if (viewType == ItemViewType.GAME_NORMAL) { - View view = mLayoutInflater.inflate(R.layout.kc_game_select_item, parent, false); - return new KcSelectGameViewHolder(view); - } else if (viewType == ItemViewType.LOADING) { - View view = mLayoutInflater.inflate(R.layout.refresh_footerview, parent, false); - return new FooterViewHolder(view); - } else if (viewType == 101) { - TextView textView = new TextView(mContext); - LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, - DisplayUtils.dip2px(mContext, 40)); - if (mGameList.size() == 0) { - params.setMargins(0, DisplayUtils.dip2px(mContext, 43), 0, 0); - } - textView.setLayoutParams(params); - textView.setGravity(Gravity.CENTER_VERTICAL); - textView.setPadding(DisplayUtils.dip2px(mContext, 20), 0, 0, 0); - textView.setTextColor(ContextCompat.getColor(mContext, R.color.title)); - textView.setBackgroundColor(Color.WHITE); - textView.setText("已安装的应用(" + mApkList.size() + ")"); - return new ReuseViewHolder(textView); + View view; + switch (viewType) { + case ItemViewType.GAME_NORMAL: + view = mLayoutInflater.inflate(R.layout.kc_game_select_item, parent, false); + return new KcSelectGameViewHolder(view); + case ItemViewType.LOADING: + view = mLayoutInflater.inflate(R.layout.refresh_footerview, parent, false); + return new FooterViewHolder(view); + case 100: + TextView textView = new TextView(mContext); + LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, + DisplayUtils.dip2px(mContext, 40)); + if (mGameList.size() == 0) { + params.setMargins(0, DisplayUtils.dip2px(mContext, 43), 0, 0); + } + textView.setLayoutParams(params); + textView.setGravity(Gravity.CENTER_VERTICAL); + textView.setPadding(DisplayUtils.dip2px(mContext, 20), 0, 0, 0); + textView.setTextColor(ContextCompat.getColor(mContext, R.color.title)); + textView.setBackgroundColor(Color.WHITE); + textView.setText("已安装的应用(" + mApkList.size() + ")"); + return new ReuseViewHolder(textView); + default: + return null; } - return null; } @Override diff --git a/app/src/main/java/com/gh/gamecenter/adapter/PlatformAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/PlatformAdapter.java index 5a63c6a442..c3b0227d2d 100644 --- a/app/src/main/java/com/gh/gamecenter/adapter/PlatformAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/adapter/PlatformAdapter.java @@ -143,44 +143,52 @@ public class PlatformAdapter extends BaseRecyclerAdapter { } } else { String status = viewHolder.mDownloadItemTvStatus.getText().toString(); - if ("下载中".equals(status) - || "插件化下载中".equals(status) - || "更新下载中".equals(status)) { - // 打开下载管理界面 - DownloadManagerActivity.startDownloadManagerActivity(mContext, apkEntity.getUrl() - , mEntrance + "(" + mLocation.split(":")[0] + ")"); - } else if ("启动".equals(status)) { - Map kv = new HashMap<>(); - kv.put("版本", apkEntity.getPlatform()); - DataUtils.onEvent(mContext, "游戏启动", mGameEntity.getName(), kv); + switch (status) { + case "下载中": + case "插件化下载中": + case "更新下载中": + // 打开下载管理界面 + DownloadManagerActivity.startDownloadManagerActivity(mContext, apkEntity.getUrl() + , mEntrance + "(" + mLocation.split(":")[0] + ")"); + break; + case "启动": + Map kv = new HashMap<>(); + kv.put("版本", apkEntity.getPlatform()); + DataUtils.onEvent(mContext, "游戏启动", mGameEntity.getName(), kv); - PackageUtils.launchApplicationByPackageName(mContext, apkEntity.getPackageName()); - } else if ("安装".equals(status) || "安装更新".equals(status)) { - install(apkEntity, position); - } else if ("插件化".equals(status)) { - if (NetworkUtils.isWifiConnected(mContext)) { - download(apkEntity, viewHolder.mDownloadItemTvStatus, "插件化"); - } else { - DialogUtils.showDownloadDialog(mContext, new DialogUtils.ConfirmListener() { - @Override - public void onConfirm() { - download(apkEntity, viewHolder.mDownloadItemTvStatus, "插件化"); - } - }); - } - } else if ("安装插件".equals(status)) { - showPluginDialog(apkEntity, PlatformAdapter.this, position); - } else if ("更新".equals(status)) { - if (NetworkUtils.isWifiConnected(mContext)) { - update(apkEntity); - } else { - DialogUtils.showDownloadDialog(mContext, new DialogUtils.ConfirmListener() { - @Override - public void onConfirm() { - update(apkEntity); - } - }); - } + PackageUtils.launchApplicationByPackageName(mContext, apkEntity.getPackageName()); + break; + case "安装": + case "安装更新": + install(apkEntity, position); + break; + case "插件化": + if (NetworkUtils.isWifiConnected(mContext)) { + download(apkEntity, viewHolder.mDownloadItemTvStatus, "插件化"); + } else { + DialogUtils.showDownloadDialog(mContext, new DialogUtils.ConfirmListener() { + @Override + public void onConfirm() { + download(apkEntity, viewHolder.mDownloadItemTvStatus, "插件化"); + } + }); + } + break; + case "安装插件": + showPluginDialog(apkEntity, PlatformAdapter.this, position); + break; + case "更新": + if (NetworkUtils.isWifiConnected(mContext)) { + update(apkEntity); + } else { + DialogUtils.showDownloadDialog(mContext, new DialogUtils.ConfirmListener() { + @Override + public void onConfirm() { + update(apkEntity); + } + }); + } + break; } } } diff --git a/app/src/main/java/com/gh/gamecenter/changeskin/ChangeSkinUtils.java b/app/src/main/java/com/gh/gamecenter/changeskin/ChangeSkinUtils.java index dcd5253123..05303f7702 100644 --- a/app/src/main/java/com/gh/gamecenter/changeskin/ChangeSkinUtils.java +++ b/app/src/main/java/com/gh/gamecenter/changeskin/ChangeSkinUtils.java @@ -131,27 +131,34 @@ public class ChangeSkinUtils { if (SkinConfig.PG_STATE == SkinConfig.TYPE_UPDATE) { String showTxt = "点击开始更新(" + patchSize + "MB)"; changeViewState(showTxt, "blue", SkinConfig.TYPE_UPDATE, true); - } else if (downState == 0) { - tvPatch.setText("检测更新"); - tvPatch.setVisibility(View.VISIBLE); - pgPatch.setVisibility(View.GONE); - tvPer.setVisibility(View.GONE); - } else if (downState == 1) { - tvPatch.setVisibility(View.GONE); - pgPatch.setVisibility(View.VISIBLE); - tvPer.setVisibility(View.VISIBLE); - pgPatch.setProgress(pg); - tvPer.setText("继续"); - } else if (downState == 2) { - tvPatch.setVisibility(View.GONE); - pgPatch.setVisibility(View.VISIBLE); - tvPer.setVisibility(View.VISIBLE); - tvPer.setText(pg + "% (" + speed + ")"); - } else if (downState == 3) { - tvPatch.setText("更新完成"); - tvPatch.setVisibility(View.VISIBLE); - pgPatch.setVisibility(View.GONE); - tvPer.setVisibility(View.GONE); + } else { + switch (downState) { + case 0: + tvPatch.setText("检测更新"); + tvPatch.setVisibility(View.VISIBLE); + pgPatch.setVisibility(View.GONE); + tvPer.setVisibility(View.GONE); + break; + case 1: + tvPatch.setVisibility(View.GONE); + pgPatch.setVisibility(View.VISIBLE); + tvPer.setVisibility(View.VISIBLE); + pgPatch.setProgress(pg); + tvPer.setText("继续"); + break; + case 2: + tvPatch.setVisibility(View.GONE); + pgPatch.setVisibility(View.VISIBLE); + tvPer.setVisibility(View.VISIBLE); + tvPer.setText(pg + "% (" + speed + ")"); + break; + case 3: + tvPatch.setText("更新完成"); + tvPatch.setVisibility(View.VISIBLE); + pgPatch.setVisibility(View.GONE); + tvPer.setVisibility(View.GONE); + break; + } } holder.skinDownloadTv.setOnClickListener(new View.OnClickListener() { diff --git a/app/src/main/java/com/gh/gamecenter/changeskin/DownloadUtils.java b/app/src/main/java/com/gh/gamecenter/changeskin/DownloadUtils.java index 71e6a11b66..f9a4939d56 100644 --- a/app/src/main/java/com/gh/gamecenter/changeskin/DownloadUtils.java +++ b/app/src/main/java/com/gh/gamecenter/changeskin/DownloadUtils.java @@ -98,19 +98,23 @@ public class DownloadUtils { int statusCode = urlConnection.getResponseCode(); /* 200 represents HTTP OK */ - if (statusCode == 200) { - is = urlConnection.getInputStream(); - byte[] data = readStream(is); - String json = new String(data); - //下载完的json发送到handler - Message msg = Message.obtain(); - msg.what = SkinConfig.MSG_DOWNLOAD_OVER; - msg.obj = json; - handler.sendMessage(msg); - } else if (statusCode == 404) { - handler.sendEmptyMessage(SkinConfig.MSG_DOWNLOAD_OVER); - } else if (statusCode == 302) { - downloadJson(params, handler); + switch (statusCode) { + case 200: + is = urlConnection.getInputStream(); + byte[] data = readStream(is); + String json = new String(data); + //下载完的json发送到handler + Message msg = Message.obtain(); + msg.what = SkinConfig.MSG_DOWNLOAD_OVER; + msg.obj = json; + handler.sendMessage(msg); + break; + case 404: + handler.sendEmptyMessage(SkinConfig.MSG_DOWNLOAD_OVER); + break; + case 302: + downloadJson(params, handler); + break; } } catch (IOException e) { diff --git a/app/src/main/java/com/gh/gamecenter/download/GameDownloadFragmentAdapter.java b/app/src/main/java/com/gh/gamecenter/download/GameDownloadFragmentAdapter.java index 2fb0f57382..4d3b3f5733 100644 --- a/app/src/main/java/com/gh/gamecenter/download/GameDownloadFragmentAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/download/GameDownloadFragmentAdapter.java @@ -227,97 +227,104 @@ class GameDownloadFragmentAdapter extends BaseRecyclerAdapter { String str = ((TextView) v).getText().toString(); final String url = downloadEntity.getUrl(); DownloadManager.getInstance(mContext).put(url, System.currentTimeMillis()); - if ("继续".equals(str) || "下载".equals(str)) { - if (NetworkUtils.isWifiConnected(mContext)) { - LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams( - 0, LinearLayout.LayoutParams.WRAP_CONTENT); - lparams.weight = 4; - viewHolder.dm_item_tv_downloads.setLayoutParams(lparams); - viewHolder.dm_item_tv_downloads.setTextColor(ContextCompat.getColor(mContext, R.color.theme)); - viewHolder.dm_item_tv_downloads.setText(String.format("%s(剩%s)", - SpeedUtils.getSpeed(downloadEntity.getSpeed()), - SpeedUtils.getRemainTime(downloadEntity.getSize(), - downloadEntity.getProgress(), downloadEntity.getSpeed() * 1024))); - viewHolder.dm_item_iv_delete.setVisibility(View.GONE); + switch (str) { + case "继续": + case "下载": + if (NetworkUtils.isWifiConnected(mContext)) { + LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams( + 0, LinearLayout.LayoutParams.WRAP_CONTENT); + lparams.weight = 4; + viewHolder.dm_item_tv_downloads.setLayoutParams(lparams); + viewHolder.dm_item_tv_downloads.setTextColor(ContextCompat.getColor(mContext, R.color.theme)); + viewHolder.dm_item_tv_downloads.setText(String.format("%s(剩%s)", + SpeedUtils.getSpeed(downloadEntity.getSpeed()), + SpeedUtils.getRemainTime(downloadEntity.getSize(), + downloadEntity.getProgress(), downloadEntity.getSpeed() * 1024))); + viewHolder.dm_item_iv_delete.setVisibility(View.GONE); - viewHolder.dm_item_tv_startorpause.setBackgroundResource(R.drawable.game_item_btn_pause_style); - viewHolder.dm_item_tv_startorpause.setText("暂停"); + viewHolder.dm_item_tv_startorpause.setBackgroundResource(R.drawable.game_item_btn_pause_style); + viewHolder.dm_item_tv_startorpause.setText("暂停"); - statusMap.put(url, "downloading"); - notifyItemChanged(doneList.isEmpty() ? 0 : 1 + doneList.size()); + statusMap.put(url, "downloading"); + notifyItemChanged(doneList.isEmpty() ? 0 : 1 + doneList.size()); - Message msg = Message.obtain(); - msg.what = Constants.CONTINUE_DOWNLOAD_TASK; - msg.obj = url; - DownloadManager.getInstance(mContext).sendMessageDelayed(msg, 1000); - } else { - DialogUtils.showDownloadDialog(mContext, new DialogUtils.ConfirmListener() { - @Override - public void onConfirm() { - LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams( - 0, LinearLayout.LayoutParams.WRAP_CONTENT); - lparams.weight = 4; - viewHolder.dm_item_tv_downloads.setLayoutParams(lparams); - viewHolder.dm_item_tv_downloads.setTextColor(ContextCompat.getColor(mContext, R.color.theme)); - viewHolder.dm_item_tv_downloads.setText(String.format("%s(剩%s)", - SpeedUtils.getSpeed(downloadEntity.getSpeed()), - SpeedUtils.getRemainTime(downloadEntity.getSize(), - downloadEntity.getProgress(), downloadEntity.getSpeed() * 1024))); - viewHolder.dm_item_iv_delete.setVisibility(View.GONE); - - viewHolder.dm_item_tv_startorpause.setBackgroundResource(R.drawable.game_item_btn_pause_style); - viewHolder.dm_item_tv_startorpause.setText("暂停"); - - statusMap.put(url, "downloading"); - notifyItemChanged(doneList.isEmpty() ? 0 : 1 + doneList.size()); - - Message msg = Message.obtain(); - msg.what = Constants.CONTINUE_DOWNLOAD_TASK; - msg.obj = url; - DownloadManager.getInstance(mContext).sendMessageDelayed(msg, 1000); - } - }); - } - } else if ("安装".equals(str)) { - final String path = downloadEntity.getPath(); - if (downloadEntity.isPluggable() - && PackageManager.isInstalled(downloadEntity.getPackageName())) { - showPluginDialog(downloadEntity.getPath()); - } else { - if (FileUtils.isEmptyFile(path)) { - Toast.makeText(mContext, "解析包出错(可能被误删了),请重新下载", Toast.LENGTH_SHORT).show(); - removeDownload(downloadEntity); + Message msg = Message.obtain(); + msg.what = Constants.CONTINUE_DOWNLOAD_TASK; + msg.obj = url; + DownloadManager.getInstance(mContext).sendMessageDelayed(msg, 1000); } else { - if (downloadEntity.getName().contains("光环助手")) { - mContext.startActivity(PackageUtils.getInstallIntent(mContext, path)); + DialogUtils.showDownloadDialog(mContext, new DialogUtils.ConfirmListener() { + @Override + public void onConfirm() { + LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams( + 0, LinearLayout.LayoutParams.WRAP_CONTENT); + lparams.weight = 4; + viewHolder.dm_item_tv_downloads.setLayoutParams(lparams); + viewHolder.dm_item_tv_downloads.setTextColor(ContextCompat.getColor(mContext, R.color.theme)); + viewHolder.dm_item_tv_downloads.setText(String.format("%s(剩%s)", + SpeedUtils.getSpeed(downloadEntity.getSpeed()), + SpeedUtils.getRemainTime(downloadEntity.getSize(), + downloadEntity.getProgress(), downloadEntity.getSpeed() * 1024))); + viewHolder.dm_item_iv_delete.setVisibility(View.GONE); + + viewHolder.dm_item_tv_startorpause.setBackgroundResource(R.drawable.game_item_btn_pause_style); + viewHolder.dm_item_tv_startorpause.setText("暂停"); + + statusMap.put(url, "downloading"); + notifyItemChanged(doneList.isEmpty() ? 0 : 1 + doneList.size()); + + Message msg = Message.obtain(); + msg.what = Constants.CONTINUE_DOWNLOAD_TASK; + msg.obj = url; + DownloadManager.getInstance(mContext).sendMessageDelayed(msg, 1000); + } + }); + } + break; + case "安装": + final String path = downloadEntity.getPath(); + if (downloadEntity.isPluggable() + && PackageManager.isInstalled(downloadEntity.getPackageName())) { + showPluginDialog(downloadEntity.getPath()); + } else { + if (FileUtils.isEmptyFile(path)) { + Toast.makeText(mContext, "解析包出错(可能被误删了),请重新下载", Toast.LENGTH_SHORT).show(); + removeDownload(downloadEntity); } else { - PackageUtils.launchSetup(mContext, path); + if (downloadEntity.getName().contains("光环助手")) { + mContext.startActivity(PackageUtils.getInstallIntent(mContext, path)); + } else { + PackageUtils.launchSetup(mContext, path); + } } } - } - } else if ("暂停".equals(str)) { - viewHolder.dm_item_tv_startorpause.setBackgroundResource(R.drawable.game_item_btn_download_style); - viewHolder.dm_item_tv_startorpause.setText("继续"); - LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams( - LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); - viewHolder.dm_item_tv_downloads.setLayoutParams(lparams); - viewHolder.dm_item_tv_downloads.setTextColor(0xFF9A9A9A); - viewHolder.dm_item_tv_downloads.setText("已暂停"); - viewHolder.dm_item_iv_delete.setVisibility(View.VISIBLE); - statusMap.put(url, "pause"); - notifyItemChanged(doneList.isEmpty() ? 0 : 1 + doneList.size()); - Message msg = Message.obtain(); - msg.what = Constants.PAUSE_DOWNLOAD_TASK; - msg.obj = url; - DownloadManager.getInstance(mContext).sendMessageDelayed(msg, 1000); - } else if ("等待".equals(str)) { - Toast.makeText(mContext, "最多只能同时启动3个下载任务", Toast.LENGTH_SHORT).show(); - } else if ("启动".equals(str)) { - Map kv = new HashMap<>(); - kv.put("版本", downloadEntity.getPlatform()); - DataUtils.onEvent(mContext, "游戏启动", downloadEntity.getName(), kv); + break; + case "暂停": + viewHolder.dm_item_tv_startorpause.setBackgroundResource(R.drawable.game_item_btn_download_style); + viewHolder.dm_item_tv_startorpause.setText("继续"); + LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); + viewHolder.dm_item_tv_downloads.setLayoutParams(lparams); + viewHolder.dm_item_tv_downloads.setTextColor(0xFF9A9A9A); + viewHolder.dm_item_tv_downloads.setText("已暂停"); + viewHolder.dm_item_iv_delete.setVisibility(View.VISIBLE); + statusMap.put(url, "pause"); + notifyItemChanged(doneList.isEmpty() ? 0 : 1 + doneList.size()); + Message msg = Message.obtain(); + msg.what = Constants.PAUSE_DOWNLOAD_TASK; + msg.obj = url; + DownloadManager.getInstance(mContext).sendMessageDelayed(msg, 1000); + break; + case "等待": + Toast.makeText(mContext, "最多只能同时启动3个下载任务", Toast.LENGTH_SHORT).show(); + break; + case "启动": + Map kv = new HashMap<>(); + kv.put("版本", downloadEntity.getPlatform()); + DataUtils.onEvent(mContext, "游戏启动", downloadEntity.getName(), kv); - PackageUtils.launchApplicationByPackageName(mContext, downloadEntity.getPackageName()); + PackageUtils.launchApplicationByPackageName(mContext, downloadEntity.getPackageName()); + break; } } }); diff --git a/app/src/main/java/com/gh/gamecenter/fragment/NewsFragment.java b/app/src/main/java/com/gh/gamecenter/fragment/NewsFragment.java index 7680eab5a0..87e0557d9f 100644 --- a/app/src/main/java/com/gh/gamecenter/fragment/NewsFragment.java +++ b/app/src/main/java/com/gh/gamecenter/fragment/NewsFragment.java @@ -111,14 +111,19 @@ public class NewsFragment extends BaseFragment_ViewPager_Checkable { protected void onPageChanged(int index) { super.onPageChanged(index); EventBus.getDefault().post(new EBUISwitch(EB_NEWSFRAGMENT_TAG, index)); - if (index == 0) { - DataCollectionUtils.uploadPosition(getActivity(), "资讯", "1", "资讯"); - } else if (index == 1) { - DataCollectionUtils.uploadPosition(getActivity(), "资讯", "2", "攻略"); - } else if (index == 2) { - DataCollectionUtils.uploadPosition(getActivity(), "资讯", "3", "原创"); - } else if (index == 3) { - DataCollectionUtils.uploadPosition(getActivity(), "资讯", "4", "关注"); + switch (index) { + case 0: + DataCollectionUtils.uploadPosition(getActivity(), "资讯", "1", "资讯"); + break; + case 1: + DataCollectionUtils.uploadPosition(getActivity(), "资讯", "2", "攻略"); + break; + case 2: + DataCollectionUtils.uploadPosition(getActivity(), "资讯", "3", "原创"); + break; + case 3: + DataCollectionUtils.uploadPosition(getActivity(), "资讯", "4", "关注"); + break; } } diff --git a/app/src/main/java/com/gh/gamecenter/fragment/SearchToolbarFragment.java b/app/src/main/java/com/gh/gamecenter/fragment/SearchToolbarFragment.java index 1c7c97ea88..7c41be72bb 100644 --- a/app/src/main/java/com/gh/gamecenter/fragment/SearchToolbarFragment.java +++ b/app/src/main/java/com/gh/gamecenter/fragment/SearchToolbarFragment.java @@ -179,29 +179,37 @@ public class SearchToolbarFragment extends BaseFragment implements View.OnClickL @Override public void onClick(View v) { final int id = v.getId(); - if (id == R.id.actionbar_rl_download) { - DataUtils.onEvent(getActivity(), "主页", "下载图标"); - DataCollectionUtils.uploadClick(getActivity(), "下载图标", "主页"); + Intent intent; - DownloadManagerActivity.startDownloadManagerActivity(getContext(), null, "(工具栏)"); - } else if (id == R.id.actionbar_iv_search) { - DataUtils.onEvent(getActivity(), "主页", "搜索图标"); - DataCollectionUtils.uploadClick(getActivity(), "搜索图标", "主页"); + switch (id) { + case R.id.actionbar_rl_download: + DataUtils.onEvent(getActivity(), "主页", "下载图标"); + DataCollectionUtils.uploadClick(getActivity(), "下载图标", "主页"); - Intent intent = SearchActivity.getIntent(getContext(), true, mSearchHintTv.getHint().toString(), "(工具栏)"); - startActivity(intent); - } else if (id == R.id.actionbar_search_input || id == R.id.actionbar_search_rl) { - DataUtils.onEvent(getActivity(), "主页", "搜索框"); - DataCollectionUtils.uploadClick(getActivity(), "搜索框", "主页"); + DownloadManagerActivity.startDownloadManagerActivity(getContext(), null, "(工具栏)"); + break; + case R.id.actionbar_iv_search: + DataUtils.onEvent(getActivity(), "主页", "搜索图标"); + DataCollectionUtils.uploadClick(getActivity(), "搜索图标", "主页"); - Intent intent = SearchActivity.getIntent(getContext(), false, mSearchHintTv.getHint().toString(), "(工具栏)"); - startActivity(intent); - } else if (id == R.id.actionbar_notification) { - DataUtils.onEvent(getActivity(), "主页", "关注图标"); - DataCollectionUtils.uploadClick(getActivity(), "关注图标", "主页"); + intent = SearchActivity.getIntent(getContext(), true, mSearchHintTv.getHint().toString(), "(工具栏)"); + startActivity(intent); + break; + case R.id.actionbar_search_input: + case R.id.actionbar_search_rl: + DataUtils.onEvent(getActivity(), "主页", "搜索框"); + DataCollectionUtils.uploadClick(getActivity(), "搜索框", "主页"); - Intent intent = ConcernActivity.getIntent(getContext(), "(工具栏)"); - startActivity(intent); + intent = SearchActivity.getIntent(getContext(), false, mSearchHintTv.getHint().toString(), "(工具栏)"); + startActivity(intent); + break; + case R.id.actionbar_notification: + DataUtils.onEvent(getActivity(), "主页", "关注图标"); + DataCollectionUtils.uploadClick(getActivity(), "关注图标", "主页"); + + intent = ConcernActivity.getIntent(getContext(), "(工具栏)"); + startActivity(intent); + break; } } diff --git a/app/src/main/java/com/gh/gamecenter/game/GameFragmentAdapter.java b/app/src/main/java/com/gh/gamecenter/game/GameFragmentAdapter.java index 3e1f486b88..ac02213bb9 100644 --- a/app/src/main/java/com/gh/gamecenter/game/GameFragmentAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/game/GameFragmentAdapter.java @@ -451,23 +451,25 @@ public class GameFragmentAdapter extends BaseRecyclerAdapter { @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { - if (viewType == ItemViewType.GAME_SLIDE) { - DisplayMetrics outMetrics = new DisplayMetrics(); - mGameFragment.getActivity().getWindowManager().getDefaultDisplay().getMetrics(outMetrics); - return new GameViewPagerViewHolder(mLayoutInflater.inflate(R.layout.game_viewpager_item, parent, false), - outMetrics.widthPixels); - } else if (viewType == ItemViewType.COLUMN_HEADER) { - return new GameHeadViewHolder(mLayoutInflater.inflate(R.layout.game_head_item, parent, false)); - } else if (viewType == ItemViewType.GAME_NORMAL) { - return new GameNormalViewHolder(mLayoutInflater.inflate(R.layout.game_normal_item, parent, false)); - } else if (viewType == ItemViewType.GAME_TEST) { - return new GameTestViewHolder(mLayoutInflater.inflate(R.layout.game_test_item, parent, false)); - } else if (viewType == ItemViewType.GAME_IMAGE) { - return new GameImageViewHolder(mLayoutInflater.inflate(R.layout.game_image_item, parent, false)); - } else if (viewType == ItemViewType.LOADING) { - return new FooterViewHolder(mLayoutInflater.inflate(R.layout.refresh_footerview, parent, false)); + switch (viewType) { + case ItemViewType.GAME_SLIDE: + DisplayMetrics outMetrics = new DisplayMetrics(); + mGameFragment.getActivity().getWindowManager().getDefaultDisplay().getMetrics(outMetrics); + return new GameViewPagerViewHolder(mLayoutInflater.inflate(R.layout.game_viewpager_item, parent, false), + outMetrics.widthPixels); + case ItemViewType.COLUMN_HEADER: + return new GameHeadViewHolder(mLayoutInflater.inflate(R.layout.game_head_item, parent, false)); + case ItemViewType.GAME_NORMAL: + return new GameNormalViewHolder(mLayoutInflater.inflate(R.layout.game_normal_item, parent, false)); + case ItemViewType.GAME_TEST: + return new GameTestViewHolder(mLayoutInflater.inflate(R.layout.game_test_item, parent, false)); + case ItemViewType.GAME_IMAGE: + return new GameImageViewHolder(mLayoutInflater.inflate(R.layout.game_image_item, parent, false)); + case ItemViewType.LOADING: + return new FooterViewHolder(mLayoutInflater.inflate(R.layout.refresh_footerview, parent, false)); + default: + return null; } - return null; } @Override @@ -851,19 +853,23 @@ public class GameFragmentAdapter extends BaseRecyclerAdapter { DataCollectionUtils.uploadClick(mContext, name + "-大图", "游戏-专题"); - if ("game".equals(entity.getType())) { - GameDetailActivity.startGameDetailActivity(mContext, entity.getLink(), "(游戏-专题:" + name + "-大图)"); - } else if ("news".equals(entity.getType())) { - // 统计阅读量 - NewsUtils.statNewsViews(entity.getLink()); + switch (entity.getType()) { + case "game": + GameDetailActivity.startGameDetailActivity(mContext, entity.getLink(), "(游戏-专题:" + name + "-大图)"); + break; + case "news": + // 统计阅读量 + NewsUtils.statNewsViews(entity.getLink()); - Intent intent = new Intent(mContext, NewsDetailActivity.class); - intent.putExtra("newsId", entity.getLink()); - intent.putExtra(EntranceUtils.KEY_ENTRANCE, "(游戏-专题:" + name + "-大图)"); - mContext.startActivity(intent); - } else if ("column".equals(entity.getType())) { - SubjectActivity.startSubjectActivity(mContext, entity.getLink(), entity.getName(), false - , "(游戏-专题:" + name + "-大图)"); + Intent intent = new Intent(mContext, NewsDetailActivity.class); + intent.putExtra("newsId", entity.getLink()); + intent.putExtra(EntranceUtils.KEY_ENTRANCE, "(游戏-专题:" + name + "-大图)"); + mContext.startActivity(intent); + break; + case "column": + SubjectActivity.startSubjectActivity(mContext, entity.getLink(), entity.getName(), false + , "(游戏-专题:" + name + "-大图)"); + break; } } }); diff --git a/app/src/main/java/com/gh/gamecenter/gamedetail/XinXiAdapter.java b/app/src/main/java/com/gh/gamecenter/gamedetail/XinXiAdapter.java index e0a103a913..945bec0f7a 100644 --- a/app/src/main/java/com/gh/gamecenter/gamedetail/XinXiAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/gamedetail/XinXiAdapter.java @@ -343,7 +343,7 @@ public class XinXiAdapter extends BaseRecyclerAdapter { return 1; } else if (position_plugin != -1 && position_plugin == position) { return 2; - } else if (position_intro != -1 && position_intro == position) { + } else if (position_intro != -1 && position_intro == position) { return 4; } else if (position_gametag != -1 && position_gametag == position) { return 5; diff --git a/app/src/main/java/com/gh/gamecenter/kuaichuan/WifiMgr.java b/app/src/main/java/com/gh/gamecenter/kuaichuan/WifiMgr.java index b533f8332d..0afbaba1d0 100644 --- a/app/src/main/java/com/gh/gamecenter/kuaichuan/WifiMgr.java +++ b/app/src/main/java/com/gh/gamecenter/kuaichuan/WifiMgr.java @@ -62,33 +62,37 @@ public class WifiMgr { config.SSID = "\"" + ssid + "\""; - if (type == WIFICIPHER_NOPASS) { -// config.wepKeys[0] = ""; - config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); + switch (type) { + case WIFICIPHER_NOPASS: + // config.wepKeys[0] = ""; + config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); // config.wepTxKeyIndex = 0; // 无密码连接WIFI时,连接不上wifi,需要注释两行代码 // config.wepKeys[0] = ""; // config.wepTxKeyIndex = 0; - } else if (type == WIFICIPHER_WEP) { - config.hiddenSSID = true; - config.wepKeys[0] = "\"" + password + "\""; - config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED); - config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); - config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); - config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40); - config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104); - config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); - config.wepTxKeyIndex = 0; - } else if (type == WIFICIPHER_WPA) { - config.preSharedKey = "\"" + password + "\""; - config.hiddenSSID = true; - config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN); - config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); - config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK); - config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP); - config.allowedProtocols.set(WifiConfiguration.Protocol.WPA); - config.status = WifiConfiguration.Status.ENABLED; + break; + case WIFICIPHER_WEP: + config.hiddenSSID = true; + config.wepKeys[0] = "\"" + password + "\""; + config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED); + config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); + config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); + config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40); + config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104); + config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); + config.wepTxKeyIndex = 0; + break; + case WIFICIPHER_WPA: + config.preSharedKey = "\"" + password + "\""; + config.hiddenSSID = true; + config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN); + config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); + config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK); + config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP); + config.allowedProtocols.set(WifiConfiguration.Protocol.WPA); + config.status = WifiConfiguration.Status.ENABLED; + break; } return config; diff --git a/app/src/main/java/com/gh/gamecenter/news/News1FragmentAdapter.java b/app/src/main/java/com/gh/gamecenter/news/News1FragmentAdapter.java index a408484b67..49a2f874a6 100644 --- a/app/src/main/java/com/gh/gamecenter/news/News1FragmentAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/news/News1FragmentAdapter.java @@ -82,24 +82,27 @@ public class News1FragmentAdapter extends BaseRecyclerAdapter { @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { - if (viewType == ItemViewType.NEWS_IMAGE1) { - View view = LayoutInflater.from(parent.getContext()).inflate( - R.layout.news_image1_item, parent, false); - return new NewsImage1ViewHolder(view); - } else if (viewType == ItemViewType.NEWS_IMAGE2) { - View view = LayoutInflater.from(parent.getContext()).inflate( - R.layout.news_image2_item, parent, false); - return new NewsImage2ViewHolder(view); - } else if (viewType == ItemViewType.NEWS_IMAGE3) { - View view = LayoutInflater.from(parent.getContext()).inflate( - R.layout.news_image3_item, parent, false); - return new NewsImage3ViewHolder(view); - } else if (viewType == ItemViewType.LOADING) { - View view = LayoutInflater.from(parent.getContext()).inflate( - R.layout.refresh_footerview, parent, false); - return new FooterViewHolder(view); + View view; + switch (viewType) { + case ItemViewType.NEWS_IMAGE1: + view = LayoutInflater.from(parent.getContext()).inflate( + R.layout.news_image1_item, parent, false); + return new NewsImage1ViewHolder(view); + case ItemViewType.NEWS_IMAGE2: + view = LayoutInflater.from(parent.getContext()).inflate( + R.layout.news_image2_item, parent, false); + return new NewsImage2ViewHolder(view); + case ItemViewType.NEWS_IMAGE3: + view = LayoutInflater.from(parent.getContext()).inflate( + R.layout.news_image3_item, parent, false); + return new NewsImage3ViewHolder(view); + case ItemViewType.LOADING: + view = LayoutInflater.from(parent.getContext()).inflate( + R.layout.refresh_footerview, parent, false); + return new FooterViewHolder(view); + default: + return null; } - return null; } @Override diff --git a/app/src/main/java/com/gh/gamecenter/news/News4FragmentAdapter.java b/app/src/main/java/com/gh/gamecenter/news/News4FragmentAdapter.java index f8e7df5ea9..f55806823d 100644 --- a/app/src/main/java/com/gh/gamecenter/news/News4FragmentAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/news/News4FragmentAdapter.java @@ -85,24 +85,27 @@ public class News4FragmentAdapter extends BaseRecyclerAdapter { @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { - if (viewType == ItemViewType.NEWS_IMAGE1) { - View view = LayoutInflater.from(parent.getContext()).inflate( - R.layout.news_image1_item, parent, false); - return new NewsImage1ViewHolder(view); - } else if (viewType == ItemViewType.NEWS_IMAGE2) { - View view = LayoutInflater.from(parent.getContext()).inflate( - R.layout.news_image2_item, parent, false); - return new NewsImage2ViewHolder(view); - } else if (viewType == ItemViewType.NEWS_IMAGE3) { - View view = LayoutInflater.from(parent.getContext()).inflate( - R.layout.news_image3_item, parent, false); - return new NewsImage3ViewHolder(view); - } else if (viewType == ItemViewType.LOADING) { - View view = LayoutInflater.from(parent.getContext()).inflate( - R.layout.refresh_footerview, parent, false); - return new FooterViewHolder(view); + View view; + switch (viewType) { + case ItemViewType.NEWS_IMAGE1: + view = LayoutInflater.from(parent.getContext()).inflate( + R.layout.news_image1_item, parent, false); + return new NewsImage1ViewHolder(view); + case ItemViewType.NEWS_IMAGE2: + view = LayoutInflater.from(parent.getContext()).inflate( + R.layout.news_image2_item, parent, false); + return new NewsImage2ViewHolder(view); + case ItemViewType.NEWS_IMAGE3: + view = LayoutInflater.from(parent.getContext()).inflate( + R.layout.news_image3_item, parent, false); + return new NewsImage3ViewHolder(view); + case ItemViewType.LOADING: + view = LayoutInflater.from(parent.getContext()).inflate( + R.layout.refresh_footerview, parent, false); + return new FooterViewHolder(view); + default: + return null; } - return null; } @Override diff --git a/app/src/main/java/com/gh/gamecenter/newsdetail/NewsDetailAdapter.java b/app/src/main/java/com/gh/gamecenter/newsdetail/NewsDetailAdapter.java index 4f3544d2b5..ab1552b02e 100644 --- a/app/src/main/java/com/gh/gamecenter/newsdetail/NewsDetailAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/newsdetail/NewsDetailAdapter.java @@ -23,6 +23,8 @@ import android.widget.TextView; import android.widget.Toast; import com.facebook.drawee.view.SimpleDraweeView; +import com.gh.base.OnRequestCallBackListener; +import com.gh.base.adapter.BaseRecyclerAdapter; import com.gh.common.constant.Config; import com.gh.common.util.CommentUtils; import com.gh.common.util.ConcernUtils; @@ -30,7 +32,6 @@ import com.gh.common.util.DataCollectionUtils; import com.gh.common.util.DataUtils; import com.gh.common.util.DialogUtils; import com.gh.common.util.DisplayUtils; -import com.gh.common.util.EntranceUtils; import com.gh.common.util.ImageUtils; import com.gh.common.util.NewsUtils; import com.gh.common.util.PostCommentUtils; @@ -45,7 +46,7 @@ import com.gh.gamecenter.R; import com.gh.gamecenter.SubjectActivity; import com.gh.gamecenter.ViewImageActivity; import com.gh.gamecenter.WebActivity; -import com.gh.base.adapter.BaseRecyclerAdapter; +import com.gh.gamecenter.adapter.viewholder.GameDetailTopViewHolder; import com.gh.gamecenter.adapter.viewholder.NewsDetailCommentListViewHolder; import com.gh.gamecenter.db.VoteDao; import com.gh.gamecenter.db.info.VoteInfo; @@ -54,8 +55,6 @@ import com.gh.gamecenter.entity.CommentEntity; import com.gh.gamecenter.entity.GameEntity; import com.gh.gamecenter.entity.NewsDetailEntity; import com.gh.gamecenter.entity.NewsEntity; -import com.gh.gamecenter.adapter.viewholder.GameDetailTopViewHolder; -import com.gh.base.OnRequestCallBackListener; import com.gh.gamecenter.manager.ConcernManager; import com.gh.gamecenter.retrofit.Response; import com.gh.gamecenter.retrofit.RetrofitManager; @@ -156,20 +155,24 @@ public class NewsDetailAdapter extends BaseRecyclerAdapter { @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { - if (viewType == 0) { - View view = mLayoutInflater.inflate(R.layout.newsdetail_item_content, parent, false); - return new NewsDetailContentViewHolder(view); - } else if (viewType == 1) { - View view = mLayoutInflater.inflate(R.layout.gamedetail_item_top, parent, false); - return new GameDetailTopViewHolder(view); - } else if (viewType == 2) { - View view = mLayoutInflater.inflate(R.layout.newsdetail_item_news_more, parent, false); - return new NewsDetailNewsMoreViewHolder(view); - } else if (viewType == 100) { - View view = mLayoutInflater.inflate(R.layout.news_detail_comment, parent, false); - return new NewsDetailCommentListViewHolder(view); + View view; + switch (viewType) { + case 0: + view = mLayoutInflater.inflate(R.layout.newsdetail_item_content, parent, false); + return new NewsDetailContentViewHolder(view); + case 1: + view = mLayoutInflater.inflate(R.layout.gamedetail_item_top, parent, false); + return new GameDetailTopViewHolder(view); + case 2: + view = mLayoutInflater.inflate(R.layout.newsdetail_item_news_more, parent, false); + return new NewsDetailNewsMoreViewHolder(view); + case 100: + view = mLayoutInflater.inflate(R.layout.news_detail_comment, parent, false); + return new NewsDetailCommentListViewHolder(view); + default: + return null; } - return null; + } @Override @@ -243,59 +246,53 @@ public class NewsDetailAdapter extends BaseRecyclerAdapter { Utils.log("url = " + url); Utils.log("url = " + uri.getScheme()); String host = uri.getHost(); - if ("article".equals(host)) { - String id = uri.getPath().substring(1); - Intent intent = new Intent(mContext, NewsDetailActivity.class); - intent.putExtra("newsId", id); - intent.putExtra(EntranceUtils.KEY_ENTRANCE, - StringUtils.buildString(mEntrance, "+(新闻详情[", mNewsDetailEntity.getTitle(), "])")); - mContext.startActivity(intent); - } else if ("game".equals(host)) { - String id = uri.getPath().substring(1); - GameDetailActivity.startGameDetailActivity(mContext, id, - StringUtils.buildString(mEntrance, "+(新闻详情[", mNewsDetailEntity.getTitle(), "])")); - } else if ("column".equals(host)) { - String id = uri.getPath().substring(1); - String name = uri.getQueryParameter("name"); - SubjectActivity.startSubjectActivity(mContext, id, name, false - , StringUtils.buildString(mEntrance, "+(新闻详情[", mNewsDetailEntity.getTitle(), "])")); - } else if ("libao".equals(host)) { - String id = uri.getPath().substring(1); - Intent intent = new Intent(mContext, LibaoDetailActivity.class); - intent.putExtra("id", id); - intent.putExtra(EntranceUtils.KEY_ENTRANCE, - StringUtils.buildString(mEntrance, "+(新闻详情[", mNewsDetailEntity.getTitle(), "])")); - mContext.startActivity(intent); - } else if ("qq".equals(host)) { - String qq = uri.getPath().substring(1); - Intent intent = new Intent(); - intent.setAction(Intent.ACTION_VIEW); - intent.setData(Uri.parse("mqqwpa://im/chat?chat_type=wpa&uin=" + qq)); - try { + String id = uri.getPath().substring(1); + Intent intent; + switch (host) { + case "article": + mContext.startActivity(NewsDetailActivity.getIntentById(mContext, id, + StringUtils.buildString(mEntrance, "+(新闻详情[", mNewsDetailEntity.getTitle(), "])"))); + case "game": + GameDetailActivity.startGameDetailActivity(mContext, id, + StringUtils.buildString(mEntrance, "+(新闻详情[", mNewsDetailEntity.getTitle(), "])")); + case "column": + String name = uri.getQueryParameter("name"); + SubjectActivity.startSubjectActivity(mContext, id, name, false + , StringUtils.buildString(mEntrance, "+(新闻详情[", mNewsDetailEntity.getTitle(), "])")); + case "libao": + mContext.startActivity(LibaoDetailActivity.getIntentById(mContext, id, + StringUtils.buildString(mEntrance, "+(新闻详情[", mNewsDetailEntity.getTitle(), "])"))); + case "qq": + String qq = id; + intent = new Intent(); + intent.setAction(Intent.ACTION_VIEW); + intent.setData(Uri.parse("mqqwpa://im/chat?chat_type=wpa&uin=" + qq)); + try { + mContext.startActivity(intent); + } catch (Exception e) { + e.printStackTrace(); + } + case "qqqun": + String key = uri.getQueryParameter("key"); + intent = new Intent(); + intent.setData(Uri.parse("mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D" + key)); + // 此Flag可根据具体产品需要自定义,如设置,则在加群界面按返回,返回手Q主界面,不设置,按返回会返回到呼起产品界面 + // intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + try { + mContext.startActivity(intent); + } catch (Exception e) { + e.printStackTrace(); + } + case "inurl": + intent = new Intent(mContext, WebActivity.class); + intent.putExtra("url", uri.getQueryParameter("url")); mContext.startActivity(intent); - } catch (Exception e) { - e.printStackTrace(); - } - } else if ("qqqun".equals(host)) { - String key = uri.getQueryParameter("key"); - Intent intent = new Intent(); - intent.setData(Uri.parse("mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D" + key)); - // 此Flag可根据具体产品需要自定义,如设置,则在加群界面按返回,返回手Q主界面,不设置,按返回会返回到呼起产品界面 - // intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - try { + case "outurl": + intent = new Intent(); + intent.setAction(Intent.ACTION_VIEW); + intent.setData(Uri.parse(uri.getQueryParameter("url"))); mContext.startActivity(intent); - } catch (Exception e) { - e.printStackTrace(); - } - } else if ("inurl".equals(host)) { - Intent intent = new Intent(mContext, WebActivity.class); - intent.putExtra("url", uri.getQueryParameter("url")); - mContext.startActivity(intent); - } else if ("outurl".equals(host)) { - Intent intent = new Intent(); - intent.setAction(Intent.ACTION_VIEW); - intent.setData(Uri.parse(uri.getQueryParameter("url"))); - mContext.startActivity(intent); + } return true; } diff --git a/app/src/main/java/com/gh/gamecenter/subject/SubjectAdapter.java b/app/src/main/java/com/gh/gamecenter/subject/SubjectAdapter.java index 776c198df2..4309124938 100644 --- a/app/src/main/java/com/gh/gamecenter/subject/SubjectAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/subject/SubjectAdapter.java @@ -10,6 +10,8 @@ import android.view.View; import android.view.ViewGroup; import android.widget.Toast; +import com.gh.base.OnRequestCallBackListener; +import com.gh.base.adapter.BaseRecyclerAdapter; import com.gh.common.constant.ItemViewType; import com.gh.common.util.ApkActiveUtils; import com.gh.common.util.DataCollectionUtils; @@ -26,14 +28,12 @@ import com.gh.gamecenter.GameDetailActivity; import com.gh.gamecenter.NewsDetailActivity; import com.gh.gamecenter.R; import com.gh.gamecenter.SubjectActivity; -import com.gh.base.adapter.BaseRecyclerAdapter; import com.gh.gamecenter.adapter.viewholder.FooterViewHolder; import com.gh.gamecenter.adapter.viewholder.GameImageViewHolder; import com.gh.gamecenter.adapter.viewholder.GameNormalViewHolder; import com.gh.gamecenter.adapter.viewholder.GameTestViewHolder; import com.gh.gamecenter.entity.ApkEntity; import com.gh.gamecenter.entity.GameEntity; -import com.gh.base.OnRequestCallBackListener; import com.gh.gamecenter.manager.GameManager; import com.gh.gamecenter.retrofit.Response; import com.gh.gamecenter.retrofit.RetrofitManager; @@ -200,20 +200,23 @@ public class SubjectAdapter extends BaseRecyclerAdapter { @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { - if (viewType == ItemViewType.LOADING) { - View view = mLayoutInflater.inflate(R.layout.refresh_footerview, viewGroup, false); - return new FooterViewHolder(view); - } else if (viewType == ItemViewType.GAME_TEST) { - View view = mLayoutInflater.inflate(R.layout.game_test_item, viewGroup, false); - return new GameTestViewHolder(view); - } else if (viewType == ItemViewType.GAME_NORMAL) { - View view = mLayoutInflater.inflate(R.layout.game_normal_item, viewGroup, false); - return new GameNormalViewHolder(view); - } else if (viewType == ItemViewType.GAME_IMAGE) { - View view = mLayoutInflater.inflate(R.layout.game_image_item, viewGroup, false); - return new GameImageViewHolder(view); + View view; + switch (viewType) { + case ItemViewType.LOADING: + view = mLayoutInflater.inflate(R.layout.refresh_footerview, viewGroup, false); + return new FooterViewHolder(view); + case ItemViewType.GAME_TEST: + view = mLayoutInflater.inflate(R.layout.game_test_item, viewGroup, false); + return new GameTestViewHolder(view); + case ItemViewType.GAME_NORMAL: + view = mLayoutInflater.inflate(R.layout.game_normal_item, viewGroup, false); + return new GameNormalViewHolder(view); + case ItemViewType.GAME_IMAGE: + view = mLayoutInflater.inflate(R.layout.game_image_item, viewGroup, false); + return new GameImageViewHolder(view); + default: + return null; } - return null; } @Override @@ -240,19 +243,23 @@ public class SubjectAdapter extends BaseRecyclerAdapter { DataCollectionUtils.uploadClick(mContext, name + "-大图", "游戏-专题"); - if ("game".equals(gameEntity.getType())) { - GameDetailActivity.startGameDetailActivity(mContext, gameEntity.getLink(), "(游戏-专题:" + name + "-大图)"); - } else if ("news".equals(gameEntity.getType())) { - // 统计阅读量 - NewsUtils.statNewsViews(gameEntity.getLink()); + switch (gameEntity.getType()) { + case "game": + GameDetailActivity.startGameDetailActivity(mContext, gameEntity.getLink(), "(游戏-专题:" + name + "-大图)"); + break; + case "news": + // 统计阅读量 + NewsUtils.statNewsViews(gameEntity.getLink()); - Intent intent = new Intent(mContext, NewsDetailActivity.class); - intent.putExtra("newsId", gameEntity.getLink()); - intent.putExtra(EntranceUtils.KEY_ENTRANCE, "(游戏-专题:" + name + "-大图)"); - mContext.startActivity(intent); - } else if ("column".equals(gameEntity.getType())) { - SubjectActivity.startSubjectActivity(mContext, gameEntity.getLink(), gameEntity.getName(), false - , "(游戏-专题:" + name + "-大图)"); + Intent intent = new Intent(mContext, NewsDetailActivity.class); + intent.putExtra("newsId", gameEntity.getLink()); + intent.putExtra(EntranceUtils.KEY_ENTRANCE, "(游戏-专题:" + name + "-大图)"); + mContext.startActivity(intent); + break; + case "column": + SubjectActivity.startSubjectActivity(mContext, gameEntity.getLink(), gameEntity.getName(), false + , "(游戏-专题:" + name + "-大图)"); + break; } } }); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cf5e901803..983eac9b98 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -251,5 +251,9 @@ 原创 正在反馈... 下载管理 + 分享跳转中... + 分享成功 + 分享取消 + 分享失败