diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 8eeb157448..26887809f5 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -363,6 +363,7 @@
{
- // 领取限制
- if ("领取".equals(libaoBtn.getText().toString()) || "淘号".equals(libaoBtn.getText().toString())) {
- if (isInstallRequired && !isAppInstalled(context, libaoEntity.getPackageName())) {
- String platform;
- if (TextUtils.isEmpty(libaoEntity.getPlatform())) {
- platform = "";
- } else {
- platform = PlatformUtils.getInstance(context)
- .getPlatformName(libaoEntity.getPlatform()) + "版";
- }
+ libaoBtn.setOnClickListener(v -> CheckLoginUtils.checkLogin(context, () -> {
+ // 领取限制
+ if ("领取".equals(libaoBtn.getText().toString()) || "淘号".equals(libaoBtn.getText().toString())) {
+ if (isInstallRequired && !isAppInstalled(context, libaoEntity.getPackageName())) {
+ String platform;
+ if (TextUtils.isEmpty(libaoEntity.getPlatform())) {
+ platform = "";
+ } else {
+ platform = PlatformUtils.getInstance(context)
+ .getPlatformName(libaoEntity.getPlatform());
+ }
- String dialogContent = context.getString(R.string.ling_rules_dialog, libaoEntity.getGame().getName(), platform);
- DialogUtils.showWarningDialog(context, "条件不符",
- Html.fromHtml(dialogContent), "关闭", "立即安装"
- , new DialogUtils.ConfirmListener() {
- @Override
- public void onConfirm() {
- adapter.openDownload();
- }
- }, null);
- return;
+ boolean isExistPlatform = false;
+ ArrayList apk = adapter.getGameEntity().getApk();
+ for (ApkEntity apkEntity : apk) {
+ if (TextUtils.isEmpty(libaoEntity.getPlatform())) break;
+ if (libaoEntity.getPlatform().equals(apkEntity.getPlatform())) {
+ isExistPlatform = true;
+ break;
}
}
- switch (libaoBtn.getText().toString()) {
- case "未开始":
- Utils.toast(context, "还没到开始领取时间");
- break;
- case "查看":
- Intent intent = LibaoDetailActivity.getIntent(context, libaoEntity, entrance);
- context.startActivity(intent);
- break;
- case "再领一个":
- case "领取":
- if ("repeatLing".equals(status)) {
- DialogUtils.showWarningDialog(context, "礼包刷新提醒"
- , "礼包每天0点刷新,换新区或者换新角色需要继续领取礼包的童鞋,请于明天0点之后回来即可[再领一个]"
- , null, "知道了", null, null);
- } else {
- libaoLing(context, libaoBtn, libaoEntity, adapter, isInstallRequired, null, entrance);
+ String dialogContent = context.getString(R.string.ling_rules_dialog, libaoEntity.getGame().getName(), platform);
+ boolean finalIsExistPlatform = isExistPlatform;
+ DialogUtils.showWarningDialog(context, "条件不符",
+ Html.fromHtml(dialogContent), isExistPlatform ? "关闭" : null,
+ isExistPlatform ? "立即安装" : "关闭",
+ () -> {
+ if (finalIsExistPlatform) {
+ adapter.openDownload(libaoEntity.getPlatform());
+ }
+ }, null);
+ return;
+ }
+ }
+
+ switch (libaoBtn.getText().toString()) {
+ case "未开始":
+ Utils.toast(context, "还没到开始领取时间");
+ break;
+ case "查看":
+ Intent intent = LibaoDetailActivity.getIntent(context, libaoEntity, entrance);
+ context.startActivity(intent);
+ break;
+ case "再领一个":
+ case "领取":
+ if ("repeatLing".equals(status)) {
+ DialogUtils.showWarningDialog(context, "礼包刷新提醒"
+ , "礼包每天0点刷新,换新区或者换新角色需要继续领取礼包的童鞋,请于明天0点之后回来即可[再领一个]"
+ , null, "知道了", null, null);
+ } else {
+ libaoLing(context, libaoBtn, libaoEntity, adapter, isInstallRequired, null, entrance);
+ }
+ break;
+ case "再淘一个":
+ case "淘号":
+ if ("repeatTao".equals(status)) {
+ Utils.toast(context, "没到重复淘号时间, 礼包每天0点刷新");
+ return;
+ }
+ final Dialog loadingDialog = DialogUtils.showWaitDialog(context, "淘号中...");
+ postLibaoTao(context, libaoEntity.getId(), new PostLibaoListener() {
+ @Override
+ public void postSucced(Object response) {
+
+ if (loadingDialog != null) loadingDialog.dismiss();
+
+ JSONObject responseBody = (JSONObject) response;
+ String libaoCode = null;
+ try {
+ libaoCode = responseBody.getString("code");
+ } catch (JSONException e) {
+ e.printStackTrace();
}
- break;
- case "再淘一个":
- case "淘号":
- if ("repeatTao".equals(status)) {
- Utils.toast(context, "没到重复淘号时间, 礼包每天0点刷新");
+
+ if (TextUtils.isEmpty(libaoCode)) {
+ try {
+ String detail = responseBody.getString("detail");
+ 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();
+ }
return;
}
- final Dialog loadingDialog = DialogUtils.showWaitDialog(context, "淘号中...");
- postLibaoTao(context, libaoEntity.getId(), new PostLibaoListener() {
- @Override
- public void postSucced(Object response) {
- if (loadingDialog != null) loadingDialog.dismiss();
+ Utils.toast(context, "淘号成功");
- JSONObject responseBody = (JSONObject) response;
- String libaoCode = null;
+ libaoEntity.setStatus("taoed");
+
+ EventBus.getDefault().post(new EBReuse("libaoChanged"));
+
+ adapter.initLibaoCode(new UserDataLibaoEntity(libaoCode, "tao", Utils.getTime(context)));
+
+ final String finalLibaoCode = libaoCode;
+
+ DialogUtils.showWarningDialog(context, "淘号成功"
+ , Html.fromHtml(context.getString(R.string.taoed_dialog, libaoCode))
+ , "关闭", " 复制礼包码"
+ , () -> {
+ copyLink(finalLibaoCode, context);
+ if (isInstallRequired) {
+ libaoBtn.postDelayed(() -> {
+ Spanned msg = Html.fromHtml(
+ context.getString(R.string.taoed_copy_dialog
+ , finalLibaoCode));
+ lunningAppDialog(context
+ , msg, libaoEntity);
+ }, 300);
+ }
+ }, null);
+ }
+
+ @Override
+ public void postFailed(Throwable error) {
+ Utils.log("---" + error.toString());
+
+ if (loadingDialog != null) loadingDialog.dismiss();
+
+ if (error instanceof HttpException) {
+ HttpException exception = (HttpException) error;
+ if (exception.code() == 403) {
try {
- libaoCode = responseBody.getString("code");
- } catch (JSONException e) {
- e.printStackTrace();
- }
-
- if (TextUtils.isEmpty(libaoCode)) {
- try {
- String detail = responseBody.getString("detail");
- 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();
- }
- return;
- }
-
- Utils.toast(context, "淘号成功");
-
- libaoEntity.setStatus("taoed");
-
- EventBus.getDefault().post(new EBReuse("libaoChanged"));
-
- adapter.initLibaoCode(new UserDataLibaoEntity(libaoCode, "tao", Utils.getTime(context)));
-
- final String finalLibaoCode = libaoCode;
-
- DialogUtils.showWarningDialog(context, "淘号成功"
- , Html.fromHtml(context.getString(R.string.taoed_dialog, libaoCode))
- , "关闭", " 复制礼包码"
- , new DialogUtils.ConfirmListener() {
- @Override
- public void onConfirm() {
- copyLink(finalLibaoCode, context);
- if (isInstallRequired) {
- libaoBtn.postDelayed(new Runnable() {
- @Override
- public void run() {
- Spanned msg = Html.fromHtml(
- context.getString(R.string.taoed_copy_dialog
- , finalLibaoCode));
- lunningAppDialog(context
- , msg, libaoEntity);
- }
- }, 300);
- }
- }
- }, null);
- }
-
- @Override
- public void postFailed(Throwable error) {
- Utils.log("---" + error.toString());
-
- if (loadingDialog != null) loadingDialog.dismiss();
-
- if (error instanceof HttpException) {
- HttpException exception = (HttpException) error;
- if (exception.code() == 403) {
- try {
- JSONObject errorJson = new JSONObject(exception.response().errorBody().string());
- String detail = errorJson.getString("detail");
+ JSONObject errorJson = new JSONObject(exception.response().errorBody().string());
+ String detail = errorJson.getString("detail");
// Utils.toast(context, "返回::" + detail);
- switch (detail) {
- case "coming":
- Utils.toast(context, "礼包领取时间未开始");
- break;
- case "finish":
- Utils.toast(context, "礼包领取时间已结束");
- break;
- case "fetched":
- Utils.toast(context, "你今天已领过这个礼包了, 不能再淘号");
+ switch (detail) {
+ case "coming":
+ Utils.toast(context, "礼包领取时间未开始");
+ break;
+ case "finish":
+ Utils.toast(context, "礼包领取时间已结束");
+ break;
+ case "fetched":
+ Utils.toast(context, "你今天已领过这个礼包了, 不能再淘号");
- libaoBtn.setText("已淘号");
- libaoBtn.setBackgroundResource(R.drawable.libao_taoed_style);
- libaoBtn.setTextColor(ContextCompat.getColorStateList(context, R.color.libao_taoed_selector));
- 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;
+ libaoBtn.setText("已淘号");
+ libaoBtn.setBackgroundResource(R.drawable.libao_taoed_style);
+ libaoBtn.setTextColor(ContextCompat.getColorStateList(context, R.color.libao_taoed_selector));
+ 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;
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- Utils.toast(context, "礼包处理异常" + ex.toString());
- }
- return;
- } else if (exception.code() == 401) {
- return;
}
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ Utils.toast(context, "礼包处理异常" + ex.toString());
}
- Utils.toast(context, "发生异常");
+ return;
+ } else if (exception.code() == 401) {
+ return;
}
- });
- break;
- }
- });
+ }
+ Utils.toast(context, "发生异常");
+ }
+ });
+ break;
}
- });
+ }));
}
private static void libaoLing(final Context context, final TextView libaoBtn, final LibaoEntity libaoEntity, final LibaoDetailAdapter adapter,
@@ -450,20 +450,14 @@ public class LibaoUtils {
final String finalLibaoCode = libaoCode;
DialogUtils.showWarningDialog(context, "领取成功", Html.fromHtml(context.getString(R.string.linged_dialog, libaoCode))
, "关闭", " 复制礼包码"
- , new DialogUtils.ConfirmListener() {
- @Override
- public void onConfirm() {
- copyLink(finalLibaoCode, context);
- if (isInstallRequired) {
- libaoBtn.postDelayed(new Runnable() {
- @Override
- public void run() {
- Spanned msg = Html.fromHtml(context.getString(R.string.linged_copy_dialog, finalLibaoCode));
- lunningAppDialog(context
- , msg, libaoEntity);
- }
- }, 300);
- }
+ , () -> {
+ copyLink(finalLibaoCode, context);
+ if (isInstallRequired) {
+ libaoBtn.postDelayed(() -> {
+ Spanned msg = Html.fromHtml(context.getString(R.string.linged_copy_dialog, finalLibaoCode));
+ lunningAppDialog(context
+ , msg, libaoEntity);
+ }, 300);
}
}, null);
}
@@ -524,12 +518,8 @@ public class LibaoUtils {
return;
} else if (exception.code() == 412) {
// 需要验证
- GeetestUtils.getInstance().showDialog(context, new GeetestListener() {
- @Override
- public void onVerified(String captcha) {
- libaoLing(context, libaoBtn, libaoEntity, adapter, isInstallRequired, captcha, entrance);
- }
- });
+ GeetestUtils.getInstance().showDialog(context, captcha ->
+ libaoLing(context, libaoBtn, libaoEntity, adapter, isInstallRequired, captcha, entrance));
return;
} else if (exception.code() == 401) {
return;
@@ -557,17 +547,14 @@ public class LibaoUtils {
public static void lunningAppDialog(final Context context, Spanned msg, final LibaoEntity libaoEntity) {
DialogUtils.showWarningDialog(context, "复制成功", msg
, "关闭", "启动游戏"
- , new DialogUtils.ConfirmListener() {
- @Override
- public void onConfirm() {
- if (LibaoUtils.isAppInstalled(context, libaoEntity.getPackageName())) {
- PackageUtils.launchApplicationByPackageName(context, libaoEntity.getPackageName());
- } else {
- Utils.toast(context, "请安装游戏:" + libaoEntity.getGame().getName()
- + PlatformUtils.getInstance(context).getPlatformName(libaoEntity.getPlatform()) + "版");
- }
-
+ , () -> {
+ if (LibaoUtils.isAppInstalled(context, libaoEntity.getPackageName())) {
+ PackageUtils.launchApplicationByPackageName(context, libaoEntity.getPackageName());
+ } else {
+ Utils.toast(context, "请安装游戏:" + libaoEntity.getGame().getName()
+ + PlatformUtils.getInstance(context).getPlatformName(libaoEntity.getPlatform()) + "版");
}
+
}, null);
}
diff --git a/app/src/main/java/com/gh/common/view/DownloadDialog.java b/app/src/main/java/com/gh/common/view/DownloadDialog.java
index a9d6ea8959..c3047f098c 100644
--- a/app/src/main/java/com/gh/common/view/DownloadDialog.java
+++ b/app/src/main/java/com/gh/common/view/DownloadDialog.java
@@ -89,6 +89,7 @@ public class DownloadDialog implements OnCollectionCallBackListener {
private String entrance;
private String location;
private ExposureEvent traceEvent;
+ private String mAutoDownloadPlatform;
private final int row = 3;
private final int column = 3;
private boolean isLoadPlatform;
@@ -105,12 +106,19 @@ public class DownloadDialog implements OnCollectionCallBackListener {
return instance;
}
+ // 自动下载并翻到相应页面
+ public void showPopupWindowAutoDownload(View view, GameEntity gameEntity, String autoDownloadPlatform,
+ String entrance, String location, ExposureEvent traceEvent) {
+ mAutoDownloadPlatform = autoDownloadPlatform;
+ showPopupWindow(view, gameEntity, entrance, location, traceEvent);
+ }
+
public void showPopupWindow(View view, GameEntity gameEntity, String entrance, String location) {
showPopupWindow(view, gameEntity, entrance, location, null);
}
- public void showPopupWindow(View view, GameEntity gameEntity, String entrance, String location, @Nullable ExposureEvent traceEvent) {
-
+ public void showPopupWindow(View view, GameEntity gameEntity, String entrance, String location,
+ @Nullable ExposureEvent traceEvent) {
if (isShow && (popupWindow == null || !popupWindow.isShowing())) {
isShow = false;
}
@@ -397,10 +405,34 @@ public class DownloadDialog implements OnCollectionCallBackListener {
if (viewPager != null) {
currentItem = viewPager.getCurrentItem();
}
+ if (!TextUtils.isEmpty(mAutoDownloadPlatform)) {
+ for (int i = 0; i < apkList.size(); i++) {
+ ApkEntity apkEntity = apkList.get(i);
+ if (mAutoDownloadPlatform.equals(apkEntity.getPlatform())) {
+ currentItem = (i / 9);
+ break;
+ }
+ GameCollectionEntity apkCollection = apkEntity.getApkCollection();
+ if (apkCollection != null) {
+ List saveApkEntity = apkCollection.getSaveApkEntity();
+ if (saveApkEntity != null) {
+ for (ApkEntity entity : saveApkEntity) {
+ if (mAutoDownloadPlatform.equals(entity.getPlatform())) {
+ currentItem = (i / 9);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
Utils.log("currentItem = " + currentItem);
- adapter = new PlatformPagerAdapter(mContext, this, gameEntity, apkList, entrance, location, traceEvent);
+ adapter = new PlatformPagerAdapter(mContext, this,
+ gameEntity, apkList, mAutoDownloadPlatform, entrance, location, traceEvent);
viewPager.setAdapter(adapter);
viewPager.setCurrentItem(currentItem);
+ if (currentItem != 0) setDownloadOvalHint(dialog_ll_hint, currentItem);
}
private void addHintPoint(LinearLayout linearLayout, int size) {
@@ -467,7 +499,8 @@ public class DownloadDialog implements OnCollectionCallBackListener {
public void showCollection(GameCollectionEntity gameCollectionEntity) {
dialog_ll_collection.setVisibility(View.VISIBLE);
- int count = gameCollectionEntity.getSaveApkEntity().size();
+ List saveApkList = gameCollectionEntity.getSaveApkEntity();
+ int count = saveApkList.size();
int vpHeight;
if (count <= 3) {
vpHeight = 82;
@@ -482,14 +515,31 @@ public class DownloadDialog implements OnCollectionCallBackListener {
collectionViewPager.setLayoutParams(layoutParams);
dialog_ll_collection_hint.removeAllViews();
- int size = (int) Math.ceil(gameCollectionEntity.getSaveApkEntity().size() / (double) (row * column));
+ int size = (int) Math.ceil(count / (double) (row * column));
addHintPoint(dialog_ll_collection_hint, size);
collectionAdapter = new PlatformPagerAdapter(
- mContext, null, gameEntity, gameCollectionEntity.getSaveApkEntity(), entrance, location, traceEvent);
+ mContext, null, gameEntity, saveApkList,
+ mAutoDownloadPlatform, entrance, location, traceEvent);
collectionViewPager.setAdapter(collectionAdapter);
collectionViewPager.addOnPageChangeListener(new MyPageChangeListener(dialog_ll_collection_hint));
+
+ int currentItem = 0;
+ if (!TextUtils.isEmpty(mAutoDownloadPlatform)) {
+ for (int i = 0; i < saveApkList.size(); i++) {
+ ApkEntity apkEntity = saveApkList.get(i);
+ if (mAutoDownloadPlatform.equals(apkEntity.getPlatform())) {
+ currentItem = (i / 9);
+ break;
+ }
+ }
+ }
+ if (currentItem != 0) {
+ collectionViewPager.setCurrentItem(currentItem);
+ setDownloadOvalHint(dialog_ll_collection_hint, currentItem);
+ }
+ mAutoDownloadPlatform = null;
}
// 隐藏合集
@@ -514,15 +564,7 @@ public class DownloadDialog implements OnCollectionCallBackListener {
@Override
public void onPageSelected(int position) {
- for (int i = 0, size = linearLayout.getChildCount(); i < size; i++) {
- if (i == position % size) {
- ((ImageView) linearLayout.getChildAt(i))
- .setImageResource(R.drawable.download_oval_hint_up);
- } else {
- ((ImageView) linearLayout.getChildAt(i))
- .setImageResource(R.drawable.oval_hint_gray_bg);
- }
- }
+ setDownloadOvalHint(linearLayout, position);
}
@Override
@@ -531,4 +573,16 @@ public class DownloadDialog implements OnCollectionCallBackListener {
}
}
+ private void setDownloadOvalHint(LinearLayout linearLayout, int position) {
+ for (int i = 0, size = linearLayout.getChildCount(); i < size; i++) {
+ if (i == position % size) {
+ ((ImageView) linearLayout.getChildAt(i))
+ .setImageResource(R.drawable.download_oval_hint_up);
+ } else {
+ ((ImageView) linearLayout.getChildAt(i))
+ .setImageResource(R.drawable.oval_hint_gray_bg);
+ }
+ }
+ }
+
}
diff --git a/app/src/main/java/com/gh/gamecenter/adapter/LibaoDetailAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/LibaoDetailAdapter.java
index d36675e2e1..0a8a364f74 100644
--- a/app/src/main/java/com/gh/gamecenter/adapter/LibaoDetailAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/adapter/LibaoDetailAdapter.java
@@ -1,5 +1,6 @@
package com.gh.gamecenter.adapter;
+import android.annotation.SuppressLint;
import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
@@ -77,6 +78,10 @@ public class LibaoDetailAdapter extends BaseRecyclerAdapter {
mGameEntity = gameEntity;
}
+ public GameEntity getGameEntity() {
+ return mGameEntity;
+ }
+
public void addLibaoDetail(Context context, boolean isExistGameData) {
RetrofitManager.getInstance(context).getApi().getLibaoDetail(mLibaoEntity.getId())
.subscribeOn(Schedulers.io())
@@ -137,13 +142,11 @@ public class LibaoDetailAdapter extends BaseRecyclerAdapter {
viewHolder.loading.setVisibility(View.GONE);
viewHolder.hint.setText(R.string.libao_suggestion_hint);
- viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- SuggestionActivity.startSuggestionActivity(mContext, SuggestType.normal, "libao"
- , StringUtils.buildString(mLibaoEntity.getGame().getName(), ",", mLibaoEntity.getName(), "有问题:"));
- }
- });
+ viewHolder.itemView.setOnClickListener(v ->
+ SuggestionActivity.startSuggestionActivity(mContext,
+ SuggestType.normal, "libao",
+ StringUtils.buildString(mLibaoEntity.getGame().getName(), ",",
+ mLibaoEntity.getName(), "有问题:")));
}
}
@@ -161,6 +164,7 @@ public class LibaoDetailAdapter extends BaseRecyclerAdapter {
return 0;
}
+ @SuppressLint("ClickableViewAccessibility")
private void initLibaoDetailTop(LibaoDetailTopViewHolder holder) {
holder.itemView.setOnClickListener(v -> {
@@ -174,8 +178,8 @@ public class LibaoDetailAdapter extends BaseRecyclerAdapter {
if (TextUtils.isEmpty(mLibaoEntity.getPlatform())) {
holder.libaoGameName.setText(mLibaoEntity.getGame().getName());
} else {
- holder.libaoGameName.setText(mLibaoEntity.getGame().getName() + " - " + PlatformUtils.getInstance(mContext)
- .getPlatformName(mLibaoEntity.getPlatform()));
+ holder.libaoGameName.setText((mLibaoEntity.getGame().getName() + " - " +
+ PlatformUtils.getInstance(mContext).getPlatformName(mLibaoEntity.getPlatform())));
}
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
@@ -214,17 +218,13 @@ public class LibaoDetailAdapter extends BaseRecyclerAdapter {
}
holder.libaoCodeRv.setLayoutParams(params);
- holder.libaoCodeRv.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
-
- if (event.getAction() == MotionEvent.ACTION_DOWN) {
- mOnCodeScrollListener.isScroll(false);
- } else if (event.getAction() == MotionEvent.ACTION_UP) {
- mOnCodeScrollListener.isScroll(true);
- }
- return false;
+ holder.libaoCodeRv.setOnTouchListener((v, event) -> {
+ if (event.getAction() == MotionEvent.ACTION_DOWN) {
+ mOnCodeScrollListener.isScroll(false);
+ } else if (event.getAction() == MotionEvent.ACTION_UP) {
+ mOnCodeScrollListener.isScroll(true);
}
+ return false;
});
return;
}
@@ -325,7 +325,8 @@ public class LibaoDetailAdapter extends BaseRecyclerAdapter {
}
// 点击立即安装打开下载页面,如果只有一个包 直接下载
- public void openDownload() {
+ public void openDownload(String platform) {
+ mDownloadPb.setTag(platform);
mDownloadPb.performClick();
}
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 86e196c1f5..2f37bcf912 100644
--- a/app/src/main/java/com/gh/gamecenter/adapter/PlatformAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/adapter/PlatformAdapter.java
@@ -36,6 +36,7 @@ import com.gh.gamecenter.adapter.viewholder.PlatformViewHolder;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.ApkLink;
import com.gh.gamecenter.entity.CollectionCloseEntity;
+import com.gh.gamecenter.entity.GameCollectionEntity;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.entity.PluginLocation;
import com.gh.gamecenter.manager.PackagesManager;
@@ -65,6 +66,7 @@ public class PlatformAdapter extends BaseRecyclerAdapter {
private GameEntity mGameEntity;
private CollectionCloseEntity mCloseEntity;
+ private String mAutoDownloadPlatform;
private String mEntrance;
private String mLocation;
private ExposureEvent mTraceEvent;
@@ -77,7 +79,7 @@ public class PlatformAdapter extends BaseRecyclerAdapter {
public PlatformAdapter(Context context, OnCollectionCallBackListener listener, GameEntity gameEntity,
CollectionCloseEntity closeEntity, ArrayMap eMap,
SparseArray aMap, List list, String entrance, String location,
- int position, ExposureEvent traceEvent) {
+ int position, ExposureEvent traceEvent, String autoDownloadPlatform) {
super(context);
mOnCollectionCallBackListener = listener;
@@ -90,6 +92,7 @@ public class PlatformAdapter extends BaseRecyclerAdapter {
mLocation = location;
mAdapterPosition = position;
mTraceEvent = traceEvent;
+ mAutoDownloadPlatform = autoDownloadPlatform;
if (mPlatformList.size() <= (mRow * mColumn)) {
mCount = mPlatformList.size();
} else if (mPlatformList.size() - (mRow * mColumn) * mAdapterPosition >= (mRow * mColumn)) {
@@ -144,8 +147,11 @@ public class PlatformAdapter extends BaseRecyclerAdapter {
String status = viewHolder.mDownloadItemTvStatus.getText().toString();
switch (status) {
case "下载中":
+ case "等待中":
case "插件化下载中":
case "更新下载中":
+ case "插件化等待中":
+ case "更新等待中":
// 打开下载管理界面
mContext.startActivity(DownloadManagerActivity.getDownloadMangerIntent(mContext, apkEntity.getUrl()
, mEntrance + "(" + mLocation.split(":")[0] + ")"));
@@ -238,12 +244,16 @@ public class PlatformAdapter extends BaseRecyclerAdapter {
if (downloadEntity.isPluggable()) {
if (downloadEntity.getStatus().equals(DownloadStatus.done)) {
viewHolder.mDownloadItemTvStatus.setText("安装插件");
+ } else if (downloadEntity.getStatus().equals(DownloadStatus.subscribe)) {
+ viewHolder.mDownloadItemTvStatus.setText("插件化等待中");
} else {
viewHolder.mDownloadItemTvStatus.setText("插件化下载中");
}
} else if (downloadEntity.isUpdate()) {
if (downloadEntity.getStatus().equals(DownloadStatus.done)) {
viewHolder.mDownloadItemTvStatus.setText("安装更新");
+ } else if (downloadEntity.getStatus().equals(DownloadStatus.subscribe)) {
+ viewHolder.mDownloadItemTvStatus.setText("更新等待中");
} else {
viewHolder.mDownloadItemTvStatus.setText("更新下载中");
}
@@ -302,10 +312,18 @@ public class PlatformAdapter extends BaseRecyclerAdapter {
viewHolder.mDownloadItemTvStatus.setText(R.string.downloading);
} else if (status.equals(DownloadStatus.done)) {
viewHolder.mDownloadItemTvStatus.setText(R.string.install);
+ } else if (status.equals(DownloadStatus.subscribe)) {
+ viewHolder.mDownloadItemTvStatus.setText(R.string.waiting);
}
}
}
}
+
+ if (!TextUtils.isEmpty(mAutoDownloadPlatform) && mAutoDownloadPlatform.equals(apkEntity.getPlatform())) {
+ mAutoDownloadPlatform = null;
+ DialogUtils.checkDownload(mContext, apkEntity.getSize(),
+ isSubscribe -> download(apkEntity, viewHolder.mDownloadItemTvStatus, "下载", isSubscribe));
+ }
} else {
// 合集
viewHolder.mDownloadItemIvPic.setVisibility(View.VISIBLE);
@@ -352,6 +370,18 @@ public class PlatformAdapter extends BaseRecyclerAdapter {
}
}
});
+
+ GameCollectionEntity apkCollection = apkEntity.getApkCollection();
+ if (!TextUtils.isEmpty(mAutoDownloadPlatform) && apkCollection != null &&
+ apkCollection.getSaveApkEntity() != null) {
+ for (ApkEntity entity : apkCollection.getSaveApkEntity()) {
+ if (mAutoDownloadPlatform.equals(entity.getPlatform())) {
+ viewHolder.itemView.performClick();
+ mAutoDownloadPlatform = null;
+ break;
+ }
+ }
+ }
}
}
@@ -403,7 +433,11 @@ public class PlatformAdapter extends BaseRecyclerAdapter {
DownloadManager.createDownload(mContext, apkEntity, mGameEntity, method, mEntrance, mLocation, isSubscribe, downloadExposureEvent);
// DownloadManager.getInstance(mContext).putStatus(apkEntity.getUrl(), "downloading");
- mDownloadItemTvStatus.setText("0.0%");
+ if (isSubscribe) {
+ mDownloadItemTvStatus.setText(R.string.waiting);
+ } else {
+ mDownloadItemTvStatus.setText(R.string.downloading);
+ }
} else {
Utils.toast(mContext, msg);
}
diff --git a/app/src/main/java/com/gh/gamecenter/adapter/PlatformPagerAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/PlatformPagerAdapter.java
index 4bdd60ca2a..4d155a2b22 100644
--- a/app/src/main/java/com/gh/gamecenter/adapter/PlatformPagerAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/adapter/PlatformPagerAdapter.java
@@ -38,6 +38,7 @@ public class PlatformPagerAdapter extends PagerAdapter {
private GameEntity mGameEntity;
private CollectionCloseEntity mColseEntity;
+ private String mAutoDownloadPlatform;
private String mEntrance;
private String mLocation;
private ExposureEvent mTraceEvent;
@@ -47,7 +48,8 @@ public class PlatformPagerAdapter extends PagerAdapter {
private final int mColumn = 3;
public PlatformPagerAdapter(Context context, OnCollectionCallBackListener listener, GameEntity gameEntity,
- List list, String entrance, String location, ExposureEvent traceEvent) {
+ List list, String autoDownloadPlatform, String entrance,
+ String location, ExposureEvent traceEvent) {
mContext = context;
mOnCollectionCallBackListener = listener;
mGameEntity = gameEntity;
@@ -55,8 +57,9 @@ public class PlatformPagerAdapter extends PagerAdapter {
mPlatformAdapterSparseArray = new SparseArray<>();
mEntrance = entrance;
mLocation = location;
- mTraceEvent= traceEvent;
-
+ mAutoDownloadPlatform = autoDownloadPlatform;
+ mTraceEvent = traceEvent;
+
mColseEntity = new CollectionCloseEntity();
mEntryMap = new ArrayMap<>();
@@ -106,7 +109,9 @@ public class PlatformPagerAdapter extends PagerAdapter {
recyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
PlatformAdapter adapter = new PlatformAdapter(
- mContext, mOnCollectionCallBackListener, mGameEntity, mColseEntity, mEntryMap, mPlatformAdapterSparseArray, mPlatformList, mEntrance, mLocation, position, mTraceEvent);
+ mContext, mOnCollectionCallBackListener, mGameEntity,
+ mColseEntity, mEntryMap, mPlatformAdapterSparseArray, mPlatformList,
+ mEntrance, mLocation, position, mTraceEvent, mAutoDownloadPlatform);
mPlatformAdapterSparseArray.put(position, adapter);
recyclerView.setAdapter(adapter);
diff --git a/app/src/main/java/com/gh/gamecenter/adapter/viewholder/DetailViewHolder.java b/app/src/main/java/com/gh/gamecenter/adapter/viewholder/DetailViewHolder.java
index b8efe02927..5f57c43b3d 100644
--- a/app/src/main/java/com/gh/gamecenter/adapter/viewholder/DetailViewHolder.java
+++ b/app/src/main/java/com/gh/gamecenter/adapter/viewholder/DetailViewHolder.java
@@ -117,6 +117,8 @@ public class DetailViewHolder {
DataUtils.onMtaEvent(HaloApp.getInstance().getApplication(), "游戏详情", "更新", mGameEntity.getName());
}
+ String autoDownloadPlatform = v.getTag() instanceof String ? (String) v.getTag() : "";
+ v.setTag(null);
switch (mViewHolder.mDownloadPb.getDownloadType()) {
case DOWNLOADING_PLUGIN:
case DOWNLOADING_NORMAL:
@@ -133,8 +135,12 @@ public class DetailViewHolder {
if (mGameEntity.getApk().size() == 1) {
DialogUtils.checkDownload(mViewHolder.context, mGameEntity.getApk().get(0).getSize(), this::download);
} else {
- DownloadDialog.getInstance(mViewHolder.context).showPopupWindow(v, mGameEntity,
- StringUtils.buildString(mEntrance, "+(", mName, "[", mTitle, "])"), mName + ":" + mTitle, mTraceEvent);
+ DownloadDialog.getInstance(mViewHolder.context).showPopupWindowAutoDownload(v,
+ mGameEntity,
+ autoDownloadPlatform,
+ StringUtils.buildString(mEntrance, "+(", mName, "[", mTitle, "])"),
+ mName + ":" + mTitle,
+ mTraceEvent);
}
break;
case LAUNCH_OR_OPEN:
@@ -142,8 +148,11 @@ public class DetailViewHolder {
DataUtils.onGameLaunchEvent(mViewHolder.context, mGameEntity.getName(), mGameEntity.getApk().get(0).getPlatform(), mName);
PackageUtils.launchApplicationByPackageName(mViewHolder.context, mGameEntity.getApk().get(0).getPackageName());
} else {
- DownloadDialog.getInstance(mViewHolder.context).showPopupWindow(v, mGameEntity,
- StringUtils.buildString(mEntrance, "+(", mName, "[", mTitle, "])"), mName + ":" + mTitle);
+ DownloadDialog.getInstance(mViewHolder.context).showPopupWindowAutoDownload(v,
+ mGameEntity,
+ autoDownloadPlatform,
+ StringUtils.buildString(mEntrance, "+(", mName, "[", mTitle, "])"),
+ mName + ":" + mTitle, null);
}
break;
case INSTALL_PLUGIN:
diff --git a/app/src/main/java/com/gh/gamecenter/game/GameViewModel.kt b/app/src/main/java/com/gh/gamecenter/game/GameViewModel.kt
index 5b0b7d893f..be810378f2 100644
--- a/app/src/main/java/com/gh/gamecenter/game/GameViewModel.kt
+++ b/app/src/main/java/com/gh/gamecenter/game/GameViewModel.kt
@@ -171,6 +171,17 @@ class GameViewModel(application: Application, blockData: SubjectRecommendEntity?
}
val observable = if (blockData == null) mApi.getColumn(mSubjectPage) else mApi.getBlockColumns(blockData?.link, mSubjectPage)
observable.subscribeOn(Schedulers.io())
+ .map {
+ for (subjectEntity in it) {
+ val gameList = subjectEntity.data
+ if (gameList != null) {
+ for (game in gameList) {
+ ApkActiveUtils.filterHideApk(game)
+ }
+ }
+ }
+ it
+ }
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Response>() {
override fun onResponse(response: List?) {
@@ -345,7 +356,6 @@ class GameViewModel(application: Application, blockData: SubjectRecommendEntity?
itemDataSubject.horizontalColumn = subjectEntity
itemDataListCache.add(itemDataSubject)
for (game in subjectEntity.data!!) {
- if (!game.image.isNullOrEmpty() || game.getApk().size > 1) continue // 横向多平台无需更新
addGamePositionAndPackage(game)
}
continue
diff --git a/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailFragment.java b/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailFragment.java
index dc7ada5efe..2661ed0954 100644
--- a/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailFragment.java
+++ b/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailFragment.java
@@ -44,6 +44,7 @@ import com.gh.gamecenter.gamedetail.desc.DescFragment;
import com.gh.gamecenter.gamedetail.fuli.FuLiFragment;
import com.gh.gamecenter.gamedetail.rating.RatingFragment;
import com.gh.gamecenter.manager.PackagesManager;
+import com.gh.gamecenter.mvvm.Status;
import com.gh.gamecenter.normal.NormalFragment;
import com.halo.assistant.HaloApp;
import com.lightgame.adapter.BaseFragmentPagerAdapter;
@@ -64,6 +65,7 @@ import butterknife.BindView;
import butterknife.OnClick;
import cn.jzvd.JZMediaManager;
import cn.jzvd.JzvdMgr;
+import retrofit2.HttpException;
/**
* Created by CsHeng on 19/12/2017.
@@ -116,6 +118,10 @@ public class GameDetailFragment extends NormalFragment {
View mLibaoIcon;
@BindView(R.id.gamedetail_game_server_type)
TextView mServerType;
+ @BindView(R.id.reuse_none_data)
+ View mNoneDataView;
+ @BindView(R.id.reuse_tv_none_data)
+ TextView mNoneDataTv;
private GameDetailViewModel mViewModel;
@@ -125,6 +131,7 @@ public class GameDetailFragment extends NormalFragment {
private ExposureEvent mTraceEvent;
private MenuItem mConcernMenuItem;
+ private MenuItem mShareMenuItem;
private String downloadAddWord;
private String downloadOffText;
@@ -176,11 +183,15 @@ public class GameDetailFragment extends NormalFragment {
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
initMenu(R.menu.menu_game_detail);
+ mConcernMenuItem = getItemMenu(R.id.menu_concern);
+ mShareMenuItem = getItemMenu(R.id.menu_share);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ mNoneDataTv.setText("页面不见了");
+
mViewPager.setScrollable(true);
mViewPager.setOffscreenPageLimit(3);
@@ -260,27 +271,31 @@ public class GameDetailFragment extends NormalFragment {
}
});
- mViewModel.getGameLiveData().observe(this, gameEntity -> {
- if (gameEntity != null) {
- mGameEntity = gameEntity;
- setNavigationTitle(mGameEntity.getName());
- } else {
- mLoading.setVisibility(View.GONE);
- mNoConnection.setVisibility(View.VISIBLE);
+ mViewModel.getGameLiveData().observe(this, gameResource -> {
+ if (gameResource == null) return;
+ if (gameResource.status == Status.SUCCESS) {
+ mGameEntity = gameResource.data;
+ setNavigationTitle(mGameEntity != null ? mGameEntity.getName() : "");
+ } else if (gameResource.status == Status.ERROR) {
+ loadErrorControl(gameResource.exception);
}
});
- mViewModel.getGameDetailLiveData().observe(this, detailEntity -> {
- if (detailEntity != null) {
- detailEntity.setId(mGameEntity.getId());
- mGameDetailEntity = detailEntity;
- downloadAddWord = detailEntity.getDownloadAddWord();
- downloadOffText = detailEntity.getDownloadOffText();
+ mViewModel.getGameDetailLiveData().observe(this, detailResource -> {
+ if (detailResource == null) return;
+ if (detailResource.status == Status.SUCCESS) {
+ GameDetailEntity data = detailResource.data;
+ if (data == null) return;
+
+ data.setId(mGameEntity.getId());
+ mGameDetailEntity = data;
+ downloadAddWord = data.getDownloadAddWord();
+ downloadOffText = data.getDownloadOffText();
Bundle bundle = new Bundle();
bundle.putParcelable(GameEntity.TAG, mGameEntity);
bundle.putString(EntranceUtils.KEY_ENTRANCE, mEntrance);
- bundle.putParcelable(GameDetailEntity.TAG, detailEntity);
+ bundle.putParcelable(GameDetailEntity.TAG, data);
List list = new ArrayList<>();
FuLiFragment fuliFragment = new FuLiFragment();
@@ -291,7 +306,7 @@ public class GameDetailFragment extends NormalFragment {
descFragment.setArguments(bundle);
list.add(descFragment);
- if (detailEntity.getShowComment()) {
+ if (data.getShowComment()) {
RatingFragment ratingFragment = new RatingFragment();
ratingFragment.setArguments(bundle);
list.add(ratingFragment);
@@ -316,9 +331,9 @@ public class GameDetailFragment extends NormalFragment {
}
if (mSwitchToFirstTabInStartup) mViewPager.setCurrentItem(0);
- } else {
- mLoading.setVisibility(View.GONE);
- mNoConnection.setVisibility(View.VISIBLE);
+
+ } else if (detailResource.status == Status.ERROR) {
+ loadErrorControl(detailResource.exception);
}
});
@@ -355,6 +370,20 @@ public class GameDetailFragment extends NormalFragment {
});
}
+ private void loadErrorControl(HttpException exception) {
+ if (exception != null && exception.code() == 404) {
+ mLoading.setVisibility(View.GONE);
+ mNoConnection.setVisibility(View.GONE);
+ mNoneDataView.setVisibility(View.VISIBLE);
+ mShareMenuItem.setVisible(false);
+ mConcernMenuItem.setVisible(false);
+ } else {
+ mLoading.setVisibility(View.GONE);
+ mNoConnection.setVisibility(View.VISIBLE);
+ mNoneDataView.setVisibility(View.GONE);
+ }
+ }
+
private void pauseVideo() {
try {
JZMediaManager.pause();
@@ -377,11 +406,10 @@ public class GameDetailFragment extends NormalFragment {
});
break;
case R.id.menu_share:
- GameDetailEntity detailEntity = mViewModel.getGameDetailLiveData().getValue();
- if (detailEntity != null) {
+ if (mGameDetailEntity != null) {
DataCollectionUtils.uploadClick(getContext(), "分享", "游戏详情", mGameEntity.getName());
- String url = "http://www.ghzs666.com/game/" + detailEntity.getShareCode();
+ String url = "http://www.ghzs666.com/game/" + mGameDetailEntity.getShareCode();
if (getActivity() instanceof BaseActivity) {
ShareUtils.ShareType shareType = ShareUtils.ShareType.game;
@@ -418,7 +446,6 @@ public class GameDetailFragment extends NormalFragment {
}
private void initGameDetailTop() {
- mConcernMenuItem = getItemMenu(R.id.menu_concern);
mLoading.setVisibility(View.GONE);
mAppBarLayout.setVisibility(View.VISIBLE);
diff --git a/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailViewModel.kt b/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailViewModel.kt
index 5c6bb38645..c70538d561 100644
--- a/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailViewModel.kt
+++ b/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailViewModel.kt
@@ -10,6 +10,7 @@ import com.gh.common.util.ConcernUtils
import com.gh.common.util.DataUtils
import com.gh.gamecenter.entity.GameDetailEntity
import com.gh.gamecenter.entity.GameEntity
+import com.gh.gamecenter.mvvm.Resource
import com.gh.gamecenter.retrofit.Response
import com.gh.gamecenter.retrofit.RetrofitManager
import io.reactivex.android.schedulers.AndroidSchedulers
@@ -22,8 +23,8 @@ class GameDetailViewModel(application: Application,
private val mApi = RetrofitManager.getInstance(getApplication()).api
- val gameLiveData = MutableLiveData()
- val gameDetailLiveData = MutableLiveData()
+ val gameLiveData = MutableLiveData>()
+ val gameDetailLiveData = MutableLiveData>()
val concernLiveData = MutableLiveData()
init {
@@ -32,7 +33,7 @@ class GameDetailViewModel(application: Application,
fun loadData() {
if (game != null) {
- gameLiveData.value = game
+ gameLiveData.value = Resource.success(game)
getGameDetail()
} else if (gameId != null) {
getGameDigest()
@@ -53,12 +54,12 @@ class GameDetailViewModel(application: Application,
DataUtils.onMtaEvent(getApplication(), "详情页面", "游戏详情", name)
game = response
- gameLiveData.postValue(response)
+ gameLiveData.postValue(Resource.success(response))
getGameDetail()
}
override fun onFailure(e: HttpException?) {
- gameLiveData.postValue(null)
+ gameLiveData.postValue(Resource.error(e))
}
})
}
@@ -83,11 +84,11 @@ class GameDetailViewModel(application: Application,
}
}
- gameDetailLiveData.postValue(response)
+ gameDetailLiveData.postValue(Resource.success(response))
}
override fun onFailure(e: HttpException?) {
- gameDetailLiveData.postValue(null)
+ gameDetailLiveData.postValue(Resource.error(e))
}
})
}
diff --git a/app/src/main/java/com/gh/gamecenter/gamedetail/desc/GameDetailBasicInfoAdapter.java b/app/src/main/java/com/gh/gamecenter/gamedetail/desc/GameDetailBasicInfoAdapter.java
index 4e6f3d14e9..5abea0439e 100644
--- a/app/src/main/java/com/gh/gamecenter/gamedetail/desc/GameDetailBasicInfoAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/gamedetail/desc/GameDetailBasicInfoAdapter.java
@@ -74,6 +74,12 @@ public class GameDetailBasicInfoAdapter extends BaseRecyclerAdapter(context) {
diff --git a/app/src/main/java/com/gh/gamecenter/personalhome/FollowersOrFansFragment.kt b/app/src/main/java/com/gh/gamecenter/personalhome/FollowersOrFansFragment.kt
index a21582f821..b7c5acc2bc 100644
--- a/app/src/main/java/com/gh/gamecenter/personalhome/FollowersOrFansFragment.kt
+++ b/app/src/main/java/com/gh/gamecenter/personalhome/FollowersOrFansFragment.kt
@@ -1,4 +1,4 @@
-package com.gh.gamecenter.personalhome.followers
+package com.gh.gamecenter.personalhome
import android.arch.lifecycle.Observer
import android.arch.lifecycle.ViewModelProviders
@@ -8,9 +8,7 @@ import com.gh.gamecenter.baselist.ListFragment
import com.gh.gamecenter.entity.FollowersOrFansEntity
import com.gh.gamecenter.manager.UserManager
import com.gh.gamecenter.message.MessageUnreadViewModel
-import com.gh.gamecenter.personalhome.FollowersOrFansViewModel
import com.gh.gamecenter.personalhome.fans.FansActivity
-import com.gh.gamecenter.personalhome.fans.FollowersOrFansAdapter
import com.halo.assistant.HaloApp
class FollowersOrFansFragment : ListFragment() {
diff --git a/app/src/main/java/com/gh/gamecenter/personalhome/fans/FansActivity.kt b/app/src/main/java/com/gh/gamecenter/personalhome/fans/FansActivity.kt
index 36de46f394..eb91ea0c1d 100644
--- a/app/src/main/java/com/gh/gamecenter/personalhome/fans/FansActivity.kt
+++ b/app/src/main/java/com/gh/gamecenter/personalhome/fans/FansActivity.kt
@@ -5,7 +5,7 @@ import android.content.Intent
import android.os.Bundle
import com.gh.common.util.EntranceUtils
import com.gh.gamecenter.NormalActivity
-import com.gh.gamecenter.personalhome.followers.FollowersOrFansFragment
+import com.gh.gamecenter.personalhome.FollowersOrFansFragment
class FansActivity : NormalActivity() {
diff --git a/app/src/main/java/com/gh/gamecenter/personalhome/followers/FollowersActivity.kt b/app/src/main/java/com/gh/gamecenter/personalhome/followers/FollowersActivity.kt
index 1c97d65e71..4b48b6e447 100644
--- a/app/src/main/java/com/gh/gamecenter/personalhome/followers/FollowersActivity.kt
+++ b/app/src/main/java/com/gh/gamecenter/personalhome/followers/FollowersActivity.kt
@@ -5,6 +5,7 @@ import android.content.Intent
import android.os.Bundle
import com.gh.common.util.EntranceUtils
import com.gh.gamecenter.NormalActivity
+import com.gh.gamecenter.personalhome.FollowersOrFansFragment
class FollowersActivity : NormalActivity() {
diff --git a/app/src/main/java/com/gh/gamecenter/qa/recommends/AskRecommendWrapperFragment.kt b/app/src/main/java/com/gh/gamecenter/qa/recommends/AskRecommendWrapperFragment.kt
index ae5e4a16b5..be1669c172 100644
--- a/app/src/main/java/com/gh/gamecenter/qa/recommends/AskRecommendWrapperFragment.kt
+++ b/app/src/main/java/com/gh/gamecenter/qa/recommends/AskRecommendWrapperFragment.kt
@@ -7,14 +7,15 @@ import android.arch.lifecycle.ViewModelProviders
import android.content.Intent
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
+import android.os.Message
import android.support.design.widget.AppBarLayout
import android.support.v4.app.Fragment
import android.support.v4.app.FragmentTransaction
+import android.support.v4.view.ViewPager
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.widget.TextView
-import cn.trinea.android.view.autoscrollviewpager.AutoScrollViewPager
import com.gh.base.fragment.BaseFragment
import com.gh.common.util.DisplayUtils
import com.gh.common.view.DumbRefreshLayout
@@ -28,7 +29,7 @@ import kotterknife.bindView
class AskRecommendWrapperFragment : BaseFragment() {
private val mAppBar by bindView(R.id.recommend_subject_bar)
- private val mSubjectViewPager by bindView(R.id.ask_recommends_subject_vp)
+ private val mSubjectViewPager by bindView(R.id.ask_recommends_subject_vp)
private val mChangeBtn by bindView(R.id.ask_recommend_change)
val refreshLayout by bindView(R.id.refresh_layout)
@@ -39,6 +40,38 @@ class AskRecommendWrapperFragment : BaseFragment() {
var mNewestFragment: RecommendNewestFragment? = null
var mRecommendsFragment: AskQuestionsRecommendsFragment? = null
+ override fun handleMessage(msg: Message) {
+ if (msg.what == VIEWPAGER_HANDLE_KEY) {
+ var lastPosition = mSubjectViewPager.currentItem
+ val itemCount = mSubjectViewPager.childCount
+ var isPositivePatch: Boolean = if (mSubjectViewPager.tag is Boolean) {
+ mSubjectViewPager.tag as Boolean
+ } else {
+ true
+ }
+ val position = if (isPositivePatch) {
+ if (lastPosition == itemCount - 1) {
+ isPositivePatch = !isPositivePatch
+ --lastPosition
+ } else {
+ ++lastPosition
+ }
+ } else {
+ if (lastPosition == 0) {
+ isPositivePatch = !isPositivePatch
+ ++lastPosition
+ } else {
+ --lastPosition
+ }
+ }
+
+ mSubjectViewPager.setCurrentItem(position, true)
+ mSubjectViewPager.tag = isPositivePatch
+ sendScrollMessage()
+ }
+ }
+
+
override fun getLayoutId(): Int {
return R.layout.fragment_ask_recommends_wrapper
}
@@ -135,19 +168,23 @@ class AskRecommendWrapperFragment : BaseFragment() {
mSubjectViewPager.pageMargin = DisplayUtils.dip2px(10f)
mSubjectViewPager.offscreenPageLimit = 3
mSubjectViewPager.adapter = AskRecommendsSubjectPageAdapter(context, slide)
- mSubjectViewPager.interval = 3000
- mSubjectViewPager.startAutoScroll()
+ sendScrollMessage()
}
override fun onResume() {
super.onResume()
- mSubjectViewPager.startAutoScroll()
+ sendScrollMessage()
}
override fun onPause() {
super.onPause()
- mSubjectViewPager.stopAutoScroll()
+ mBaseHandler.removeMessages(VIEWPAGER_HANDLE_KEY)
+ }
+
+ private fun sendScrollMessage() {
+ mBaseHandler.removeMessages(VIEWPAGER_HANDLE_KEY)
+ mBaseHandler.sendEmptyMessageDelayed(VIEWPAGER_HANDLE_KEY, VIEWPAGER_INTERVAL)
}
private fun changeFragment(isNewest: Boolean) {
@@ -182,6 +219,12 @@ class AskRecommendWrapperFragment : BaseFragment() {
}
fun openAppBar() {
- mAppBar?.setExpanded(true)
+ mAppBar.setExpanded(true)
+ }
+
+ companion object {
+ private const val VIEWPAGER_INTERVAL: Long = 3000
+ private const val VIEWPAGER_HANDLE_KEY = 0
+
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/gh/gamecenter/qa/recommends/AskRecommendsSubjectPageAdapter.java b/app/src/main/java/com/gh/gamecenter/qa/recommends/AskRecommendsSubjectPageAdapter.java
index 20b1bfed36..c4560ffd2c 100644
--- a/app/src/main/java/com/gh/gamecenter/qa/recommends/AskRecommendsSubjectPageAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/qa/recommends/AskRecommendsSubjectPageAdapter.java
@@ -47,10 +47,6 @@ public class AskRecommendsSubjectPageAdapter extends RecyclingPagerAdapter {
@Override
public int getCount() {
if (mEntityList == null) return 0;
- return mEntityList.size() > 1 ? Integer.MAX_VALUE : mEntityList.size();
- }
-
- public int getDataSize() {
- return mEntityList == null ? 0 : mEntityList.size();
+ return mEntityList.size();
}
}
diff --git a/app/src/main/res/layout/activity_rating_edit.xml b/app/src/main/res/layout/activity_rating_edit.xml
index c9ef4cd4dd..a951783b9f 100644
--- a/app/src/main/res/layout/activity_rating_edit.xml
+++ b/app/src/main/res/layout/activity_rating_edit.xml
@@ -18,8 +18,8 @@
+ android:paddingTop = "12dp"
+ android:paddingBottom = "15dp" >
+ android:button = "@drawable/rating_checkbox_style"
+ android:checked = "true" />
@@ -86,14 +86,13 @@
-
@@ -29,11 +29,11 @@
android:layout_width = "wrap_content"
android:layout_height = "35dp"
android:layout_marginLeft = "20dp"
- android:drawablePadding = "7dp"
android:drawableRight = "@drawable/ask_recommend_change"
+ android:drawablePadding = "7dp"
android:gravity = "center"
- android:paddingBottom = "9dp"
android:paddingTop = "9dp"
+ android:paddingBottom = "9dp"
android:text = "按精选排序"
android:textColor = "@color/title"
android:textSize = "12sp" />