diff --git a/app/src/main/java/com/gh/common/util/CheckLoginUtils.java b/app/src/main/java/com/gh/common/util/CheckLoginUtils.java
new file mode 100644
index 0000000000..5a214da802
--- /dev/null
+++ b/app/src/main/java/com/gh/common/util/CheckLoginUtils.java
@@ -0,0 +1,34 @@
+package com.gh.common.util;
+
+import android.content.Context;
+import android.content.Intent;
+
+import com.gh.gamecenter.LoginActivity;
+
+/**
+ * Created by khy on 28/06/17.
+ */
+
+public class CheckLoginUtils {
+
+ public static void checkLogin(final Context context, OnLoggenInListener listener) {
+ String token = null;
+ if (token == null) {
+ DialogUtils.showWarningDialog(context, "登录提示", "需要登录才能使用该功能喔!", "取消", "快速登录",
+ new DialogUtils.ConfirmListener() {
+ @Override
+ public void onConfirm() {
+ Intent intent = LoginActivity.getIntent(context);
+ context.startActivity(intent);
+ }
+ }, null);
+ } else {
+ listener.onLoggedIn();
+ }
+ }
+
+
+ public interface OnLoggenInListener {
+ void onLoggedIn();
+ }
+}
diff --git a/app/src/main/java/com/gh/common/util/CommentUtils.java b/app/src/main/java/com/gh/common/util/CommentUtils.java
index a89b2e3275..801ca1a05a 100644
--- a/app/src/main/java/com/gh/common/util/CommentUtils.java
+++ b/app/src/main/java/com/gh/common/util/CommentUtils.java
@@ -7,6 +7,7 @@ import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.view.View;
import android.view.Window;
+import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -15,6 +16,8 @@ import com.gh.gamecenter.MessageDetailActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.OnCommentCallBackListener;
import com.gh.gamecenter.db.CommentDao;
+import com.gh.gamecenter.db.VoteDao;
+import com.gh.gamecenter.db.info.VoteInfo;
import com.gh.gamecenter.entity.CommentEntity;
import org.json.JSONException;
@@ -27,6 +30,8 @@ import java.util.Date;
import java.util.List;
import java.util.Locale;
+import retrofit2.HttpException;
+
/**
* Created by khy on 2017/3/22.
*/
@@ -107,20 +112,30 @@ public class CommentUtils {
dialog.cancel();
switch (reportTv.getText().toString()) {
case "回复":
- if (listener != null) {
- listener.onCommentCallback(commentEntity);
- } else if (!TextUtils.isEmpty(newsId)) {
- context.startActivity(MessageDetailActivity.getMessageDetailIntent(context, commentEntity, newsId));
- } else {
- Utils.toast(context, "缺少关键属性");
- }
-
+ CheckLoginUtils.checkLogin(context, new CheckLoginUtils.OnLoggenInListener() {
+ @Override
+ public void onLoggedIn() {
+ if (listener != null) {
+ listener.onCommentCallback(commentEntity);
+ } else if (!TextUtils.isEmpty(newsId)) {
+ context.startActivity(MessageDetailActivity.getMessageDetailIntent(context, commentEntity, newsId));
+ } else {
+ Utils.toast(context, "缺少关键属性");
+ }
+ }
+ });
break;
case "复制":
LibaoUtils.copyLink(commentEntity.getContent(), context);
break;
case "举报":
- showReportTypeDialog(commentEntity, context);
+ CheckLoginUtils.checkLogin(context, new CheckLoginUtils.OnLoggenInListener() {
+ @Override
+ public void onLoggedIn() {
+ showReportTypeDialog(commentEntity, context);
+ }
+ });
+
break;
case "查看对话":
context.startActivity(CommentDetailActivity.getCommentDetailIntent(context, commentEntity.getId()));
@@ -192,5 +207,66 @@ public class CommentUtils {
reportTypeDialog.show();
}
+ public static void initVote(final Context context, final CommentEntity commentEntity, final VoteDao voteDao,
+ final TextView commentLikeCountTv, final ImageView commentLikeIv, final OnVoteListener listener) {
+ CheckLoginUtils.checkLogin(context, new CheckLoginUtils.OnLoggenInListener() {
+ @Override
+ public void onLoggedIn() {
+ if (commentLikeCountTv.getCurrentTextColor() == ContextCompat.getColor(context, R.color.theme)) {
+ Utils.toast(context, "已经点过赞啦!");
+ return;
+ }
+ commentEntity.setVote(commentEntity.getVote() + 1);
+ commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.theme));
+ commentLikeIv.setImageResource(R.drawable.ic_like_select);
+ commentLikeCountTv.setText(String.valueOf(commentEntity.getVote()));
+ commentLikeCountTv.setVisibility(View.VISIBLE);
+ PostCommentUtils.addCommentVoto(context, commentEntity.getId(), true,
+ new PostCommentUtils.PostCommentListener() {
+ @Override
+ public void postSuccess(JSONObject response) {
+ voteDao.add(new VoteInfo(commentEntity.getId()));
+ if (listener != null) {
+ listener.onVote();
+ }
+ }
+
+ @Override
+ public void postFailed(Throwable e) {
+
+ commentEntity.setVote(commentEntity.getVote() - 1);
+ commentLikeCountTv.setTextColor(ContextCompat.getColor(context, R.color.hint));
+ commentLikeIv.setImageResource(R.drawable.ic_like_unselect);
+ commentLikeCountTv.setText(String.valueOf(commentEntity.getVote()));
+ if (commentEntity.getVote() == 0) {
+ commentLikeCountTv.setVisibility(View.GONE);
+ } else {
+ commentLikeCountTv.setVisibility(View.VISIBLE);
+ }
+
+ if (e instanceof HttpException) {
+ HttpException exception = (HttpException) e;
+ if (exception.code() == 403) {
+ try {
+ String detail = new JSONObject(exception.response().errorBody().string()).getString("detail");
+ if (detail.equals("voted")) {
+ Utils.toast(context, "已经点过赞啦!");
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ return;
+ }
+ }
+ Utils.toast(context, "网络异常,点赞失败");
+ }
+ });
+ }
+ });
+ }
+
+ public interface OnVoteListener {
+ void onVote();
+ }
}
diff --git a/app/src/main/java/com/gh/common/util/DialogUtils.java b/app/src/main/java/com/gh/common/util/DialogUtils.java
index 0cf8cca95d..e53507767d 100644
--- a/app/src/main/java/com/gh/common/util/DialogUtils.java
+++ b/app/src/main/java/com/gh/common/util/DialogUtils.java
@@ -328,7 +328,7 @@ public class DialogUtils {
public static void showWarningDialog(Context context, String title, CharSequence msg, String cancel, String confirm,
final ConfirmListener cmListener, final CancelListener clListener) {
- showAlertDialog(context, title, msg, cancel, confirm, cmListener, clListener);
+ showAlertDialog(context, title, msg, confirm, cancel, cmListener, clListener);
if (true) return; // TODO TEST
if (isShow) {
@@ -461,16 +461,16 @@ public class DialogUtils {
.setPositiveButton(positive, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- if (clListener != null) {
- clListener.onCancel();
+ if (cmListener != null) {
+ cmListener.onConfirm();
}
}
})
.setNegativeButton(negative, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- if (cmListener != null) {
- cmListener.onConfirm();
+ if (clListener != null) {
+ clListener.onCancel();
}
}
})
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 a41c6b55b7..e268588dd8 100644
--- a/app/src/main/java/com/gh/common/util/LibaoUtils.java
+++ b/app/src/main/java/com/gh/common/util/LibaoUtils.java
@@ -274,177 +274,182 @@ public class LibaoUtils {
libaoBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- // 领取限制
- 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()) + "版";
- }
-
- DialogUtils.showWarningDialog(context, "条件不符",
- Html.fromHtml("请先" + ""
- + "安装《" + libaoEntity.getGame().getName() + "》 "
- + platform + ""), "关闭", "立即安装"
- , new DialogUtils.ConfirmListener() {
- @Override
- public void onConfirm() {
- adapter.openDownload();
- }
- }, null);
- return;
- }
- }
-
- switch (libaoBtn.getText().toString()) {
- case "未开始":
- Utils.toast(context, "还没到开始领取时间");
- break;
- case "查看":
- Intent intent = LibaoDetailActivity.getIntent(context, libaoEntity, entrance);
- context.startActivity(intent);
- break;
- case "领取":
- libaoLing(context, libaoBtn, libaoEntity, adapter, isInstallRequired, libaoDao, null, entrance);
- break;
- case "淘号":
- postLibaoTao(context, libaoEntity.getId(), true, new PostLibaoListener() {
- @Override
- public void postSucced(Object response) {
-
- JSONObject responseBody = (JSONObject) response;
- Utils.log("postLibaoTao=====" + responseBody);
- String libaoCode = null;
- try {
- libaoCode = responseBody.getString("code");
- } catch (JSONException e) {
- e.printStackTrace();
+ CheckLoginUtils.checkLogin(context, new CheckLoginUtils.OnLoggenInListener() {
+ @Override
+ public void onLoggedIn() {
+ // 领取限制
+ 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()) + "版";
}
- 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");
-
- LibaoInfo libaoInfo = LibaoInfo.createLibaoInfo(libaoEntity);
- libaoInfo.setCode(libaoCode);
- libaoInfo.setTime(Utils.getTime(context));
- libaoDao.add(libaoInfo);
-
- EventBus.getDefault().post(new EBReuse("libaoChanged"));
-
- adapter.initLibaoDao();
- adapter.notifyDataSetChanged();
-
- final String finalLibaoCode = libaoCode;
- DialogUtils.showWarningDialog(context, "淘号成功", Html.fromHtml("礼包码:"
- + "" + libaoCode + "" +
- "
淘号礼包不保证可用,请尽快进入游戏尝试兑换")
- , "关闭", " 复制礼包码"
+ DialogUtils.showWarningDialog(context, "条件不符",
+ Html.fromHtml("请先" + ""
+ + "安装《" + libaoEntity.getGame().getName() + "》 "
+ + platform + ""), "关闭", "立即安装"
, new DialogUtils.ConfirmListener() {
@Override
public void onConfirm() {
- copyLink(finalLibaoCode, context);
-
- if (isInstallRequired) {
- libaoBtn.postDelayed(new Runnable() {
- @Override
- public void run() {
- lunningAppDialog(context
- , Html.fromHtml("礼包码:"
- + "" + finalLibaoCode + ""
- + " 复制成功"
- + "
淘号礼包不保证可用,请尽快进入游戏尝试兑换"), libaoEntity);
- }
- }, 300);
- }
+ adapter.openDownload();
}
}, null);
+ return;
}
+ }
- @Override
- public void postFailed(Throwable error) {
- Utils.log("---" + error.toString());
+ switch (libaoBtn.getText().toString()) {
+ case "未开始":
+ Utils.toast(context, "还没到开始领取时间");
+ break;
+ case "查看":
+ Intent intent = LibaoDetailActivity.getIntent(context, libaoEntity, entrance);
+ context.startActivity(intent);
+ break;
+ case "领取":
+ libaoLing(context, libaoBtn, libaoEntity, adapter, isInstallRequired, libaoDao, null, entrance);
+ break;
+ case "淘号":
+ postLibaoTao(context, libaoEntity.getId(), true, new PostLibaoListener() {
+ @Override
+ public void postSucced(Object response) {
- if (error instanceof HttpException) {
- HttpException exception = (HttpException) error;
- if (exception.code() == 403) {
+ JSONObject responseBody = (JSONObject) response;
+ Utils.log("postLibaoTao=====" + responseBody);
+ String libaoCode = null;
try {
- 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, "你已领过这个礼包了");
- 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;
-
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- Utils.toast(context, "礼包处理异常" + ex.toString());
+ libaoCode = responseBody.getString("code");
+ } catch (JSONException e) {
+ e.printStackTrace();
}
- return;
+
+ 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");
+
+ LibaoInfo libaoInfo = LibaoInfo.createLibaoInfo(libaoEntity);
+ libaoInfo.setCode(libaoCode);
+ libaoInfo.setTime(Utils.getTime(context));
+ libaoDao.add(libaoInfo);
+
+ EventBus.getDefault().post(new EBReuse("libaoChanged"));
+
+ adapter.initLibaoDao();
+ adapter.notifyDataSetChanged();
+
+ final String finalLibaoCode = libaoCode;
+ DialogUtils.showWarningDialog(context, "淘号成功", Html.fromHtml("礼包码:"
+ + "" + libaoCode + "" +
+ "
淘号礼包不保证可用,请尽快进入游戏尝试兑换")
+ , "关闭", " 复制礼包码"
+ , new DialogUtils.ConfirmListener() {
+ @Override
+ public void onConfirm() {
+ copyLink(finalLibaoCode, context);
+
+ if (isInstallRequired) {
+ libaoBtn.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ lunningAppDialog(context
+ , Html.fromHtml("礼包码:"
+ + "" + finalLibaoCode + ""
+ + " 复制成功"
+ + "
淘号礼包不保证可用,请尽快进入游戏尝试兑换"), libaoEntity);
+ }
+ }, 300);
+ }
+ }
+ }, null);
}
- }
- Utils.toast(context, "发生异常");
- }
- });
- break;
- }
+
+ @Override
+ public void postFailed(Throwable error) {
+ Utils.log("---" + error.toString());
+
+ 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");
+ Utils.toast(context, "返回::" + detail);
+ 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;
+
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ Utils.toast(context, "礼包处理异常" + ex.toString());
+ }
+ return;
+ }
+ }
+ Utils.toast(context, "发生异常");
+ }
+ });
+ break;
+ }
+ }
+ });
}
});
}
@@ -564,8 +569,8 @@ public class LibaoUtils {
case "maintaining":
Utils.toast(context, "网络状态异常,请稍后再试");
break;
- default:
- Utils.toast(context, "操作失败");
+ default:
+ Utils.toast(context, "操作失败");
break;
}
} catch (Exception ex) {
diff --git a/app/src/main/java/com/gh/common/util/LoginUtils.java b/app/src/main/java/com/gh/common/util/LoginUtils.java
index 44cb9787d0..2348b23e2c 100644
--- a/app/src/main/java/com/gh/common/util/LoginUtils.java
+++ b/app/src/main/java/com/gh/common/util/LoginUtils.java
@@ -39,6 +39,7 @@ public class LoginUtils {
private static LoginUtils instance;
private Context mContext;
+ private OnLoginListener mLoginListener;
private Tencent mTencent;
private IWXAPI mIWXAPI;
@@ -59,7 +60,7 @@ public class LoginUtils {
Utils.log(LoginUtils.class.getSimpleName(), "initLogin");
}
- public static LoginUtils getInstance(Activity context) {
+ public static LoginUtils getInstance(Context context) {
if (instance == null) {
instance = new LoginUtils(context);
}
@@ -119,7 +120,7 @@ public class LoginUtils {
};
- public void QQLogin() {
+ public void QQLogin(OnLoginListener listener) {
if (mTencent != null && !mTencent.isSessionValid()) {
Utils.log(LoginUtils.class.getSimpleName(), "QQLogin");
mTencent.login((Activity) mContext, "all", QqLoginListener);
@@ -132,7 +133,7 @@ public class LoginUtils {
}
}
- public void WCLogin() {
+ public void WCLogin(OnLoginListener listener) {
if (mIWXAPI != null) {
boolean register = mIWXAPI.registerApp("wx3ffd0785fad18396");
@@ -144,12 +145,13 @@ public class LoginUtils {
}
}
- public void WeiBoLogin() {
+ public void WeiBoLogin(OnLoginListener listener) {
mSsoHandler.authorizeClientSso(new SelfWbAuthListener());
// 第一次启动本应用,AccessToken 不可用
- mAccessToken = AccessTokenKeeper.readAccessToken(mContext);
if (mAccessToken.isSessionValid()) {
updateTokenView(true);
+ } else {
+ mAccessToken = AccessTokenKeeper.readAccessToken(mContext);
}
}
@@ -218,7 +220,7 @@ public class LoginUtils {
}
/**
- * 显示当前 Token 信息。
+ * 微博显示当前 Token 信息。
*
* @param hasExisted 配置文件中是否已存在 token 信息并且合法
*/
@@ -235,4 +237,8 @@ public class LoginUtils {
Utils.log(LoginUtils.class.getSimpleName(), "::WB_MESSAGE::" + message);
}
+ public interface OnLoginListener {
+ void onLogin();
+ }
+
}
diff --git a/app/src/main/java/com/gh/gamecenter/GameDetailActivity.java b/app/src/main/java/com/gh/gamecenter/GameDetailActivity.java
index d40386ea8e..f62171ae82 100644
--- a/app/src/main/java/com/gh/gamecenter/GameDetailActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/GameDetailActivity.java
@@ -20,6 +20,7 @@ import com.facebook.drawee.view.SimpleDraweeView;
import com.gh.base.BaseActivity;
import com.gh.base.adapter.FragmentAdapter;
import com.gh.common.util.ApkActiveUtils;
+import com.gh.common.util.CheckLoginUtils;
import com.gh.common.util.ConcernUtils;
import com.gh.common.util.DataCollectionUtils;
import com.gh.common.util.DataUtils;
@@ -290,59 +291,6 @@ public class GameDetailActivity extends BaseActivity {
ApkEntity apkEntity = mGameEntity.getApk().get(0);
mGameInfo.setText(String.format("V%s | %s", apkEntity.getVersion(), apkEntity.getSize()));
}
- mGameConcern.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- final TextView concern = (TextView) v;
- if ("关注".equals(concern.getText().toString())) {
-
- Map kv = new HashMap<>();
- kv.put("状态", "关注");
- DataUtils.onEvent(GameDetailActivity.this, "游戏关注", mGameEntity.getName(), kv);
-
- Map kv2 = new HashMap<>();
- kv2.put("点击", "关注");
- DataUtils.onEvent(GameDetailActivity.this, "插件数据", mGameEntity.getName(), kv2);
-
- DataCollectionUtils.uploadConcern(GameDetailActivity.this, mGameEntity.getName(), mGameEntity.getId(), "关注");
-
- mConcernManager.addByEntity(mGameEntity);
- concern.setText("取消关注");
- concern.setBackgroundResource(R.drawable.border_red_bg);
- concern.setTextColor(Color.parseColor("#ff4147"));
-
- Toast.makeText(GameDetailActivity.this, "关注成功", Toast.LENGTH_SHORT).show();
-
- // 添加关注
- ConcernUtils.postConcernGameId(GameDetailActivity.this, mGameEntity.getId());
- } else {
- Map kv2 = new HashMap<>();
- kv2.put("点击", "取消关注");
- DataUtils.onEvent(GameDetailActivity.this, "插件数据", mGameEntity.getName(), kv2);
-
- DialogUtils.showCancelDialog(GameDetailActivity.this, new DialogUtils.ConfirmListener() {
- @Override
- public void onConfirm() {
- Map kv = new HashMap<>();
- kv.put("状态", "取消关注");
- DataUtils.onEvent(GameDetailActivity.this, "游戏关注", mGameEntity.getName(), kv);
-
- DataCollectionUtils.uploadConcern(GameDetailActivity.this,
- mGameEntity.getName(), mGameEntity.getId(), "取消关注");
-
- mConcernManager.deleteConcern(mGameEntity.getId());
- concern.setText("关注");
- concern.setBackgroundResource(R.drawable.textview_concern_red_style);
- concern.setTextColor(0xffffffff);
-
- // 取消关注
- ConcernUtils.deleteConcernData(GameDetailActivity.this, mGameEntity.getId());
- }
- });
- }
- }
- });
-
}
// 获取游戏摘要
@@ -495,40 +443,98 @@ public class GameDetailActivity extends BaseActivity {
}
@OnClick({R.id.detail_tv_download, R.id.detail_pb_progressbar, R.id.reuse_no_connection
- , R.id.detail_tv_per, R.id.gamedetail_tabbar_xinxi_tv
+ , R.id.detail_tv_per, R.id.gamedetail_tabbar_xinxi_tv, R.id.gamedetail_tv_concern
, R.id.gamedetail_tabbar_fuli_tv, R.id.gamedetail_share})
public void onClick(View v) {
- if (v == mTanBarFuLiTv) {
- mViewPager.setCurrentItem(0);
- } else if (v == mTanBarXinXiTv) {
- mViewPager.setCurrentItem(1);
- } else if (v == mShareIv) {
- if (TextUtils.isEmpty(shareCode)) return;
- // 防抖处理
- RxView.clicks(mShareIv)
- .throttleFirst(1, TimeUnit.SECONDS)
- .subscribe(new Action1() {
- @Override
- public void call(Void aVoid) {
+ switch (v.getId()) {
+ case R.id.gamedetail_tabbar_fuli_tv:
+ mViewPager.setCurrentItem(0);
+ break;
+ case R.id.gamedetail_tabbar_xinxi_tv:
+ mViewPager.setCurrentItem(1);
+ break;
+ case R.id.gamedetail_share:
+ if (TextUtils.isEmpty(shareCode)) return;
+ // 防抖处理
+ RxView.clicks(mShareIv)
+ .throttleFirst(1, TimeUnit.SECONDS)
+ .subscribe(new Action1() {
+ @Override
+ public void call(Void aVoid) {
+ Map kv = new HashMap<>();
+ kv.put("点击", "分享");
+ DataUtils.onEvent(GameDetailActivity.this, "插件数据", mGameEntity.getName(), kv);
+
+ DataCollectionUtils.uploadClick(GameDetailActivity.this, "分享", "游戏详情", mGameEntity.getName());
+
+ String url = "http://www.ghzhushou.com/game/" + shareCode;
+ showShare(url, mGameEntity.getName(), mGameEntity.getIcon(), null, mGameEntity.getTag(), false);
+ }
+ });
+ break;
+ case R.id.reuse_no_connection:
+ mLoading.setVisibility(View.VISIBLE);
+ mNoConnection.setVisibility(View.GONE);
+
+ if (mGameEntity != null) {
+ getGameDetail();
+ } else if (mGameId != null) {
+ getGameDigest();
+ }
+ break;
+ case R.id.gamedetail_tv_concern:
+ CheckLoginUtils.checkLogin(GameDetailActivity.this, new CheckLoginUtils.OnLoggenInListener() {
+ @Override
+ public void onLoggedIn() {
+ if ("关注".equals(mGameConcern.getText().toString())) {
+
Map kv = new HashMap<>();
- kv.put("点击", "分享");
- DataUtils.onEvent(GameDetailActivity.this, "插件数据", mGameEntity.getName(), kv);
+ kv.put("状态", "关注");
+ DataUtils.onEvent(GameDetailActivity.this, "游戏关注", mGameEntity.getName(), kv);
- DataCollectionUtils.uploadClick(GameDetailActivity.this, "分享", "游戏详情", mGameEntity.getName());
+ Map kv2 = new HashMap<>();
+ kv2.put("点击", "关注");
+ DataUtils.onEvent(GameDetailActivity.this, "插件数据", mGameEntity.getName(), kv2);
- String url = "http://www.ghzhushou.com/game/" + shareCode;
- showShare(url, mGameEntity.getName(), mGameEntity.getIcon(), null, mGameEntity.getTag(), false);
+ DataCollectionUtils.uploadConcern(GameDetailActivity.this, mGameEntity.getName(), mGameEntity.getId(), "关注");
+
+ mConcernManager.addByEntity(mGameEntity);
+ mGameConcern.setText("取消关注");
+ mGameConcern.setBackgroundResource(R.drawable.border_red_bg);
+ mGameConcern.setTextColor(Color.parseColor("#ff4147"));
+
+ Toast.makeText(GameDetailActivity.this, "关注成功", Toast.LENGTH_SHORT).show();
+
+ // 添加关注
+ ConcernUtils.postConcernGameId(GameDetailActivity.this, mGameEntity.getId());
+ } else {
+ Map kv2 = new HashMap<>();
+ kv2.put("点击", "取消关注");
+ DataUtils.onEvent(GameDetailActivity.this, "插件数据", mGameEntity.getName(), kv2);
+
+ DialogUtils.showCancelDialog(GameDetailActivity.this, new DialogUtils.ConfirmListener() {
+ @Override
+ public void onConfirm() {
+ Map kv = new HashMap<>();
+ kv.put("状态", "取消关注");
+ DataUtils.onEvent(GameDetailActivity.this, "游戏关注", mGameEntity.getName(), kv);
+
+ DataCollectionUtils.uploadConcern(GameDetailActivity.this,
+ mGameEntity.getName(), mGameEntity.getId(), "取消关注");
+
+ mConcernManager.deleteConcern(mGameEntity.getId());
+ mGameConcern.setText("关注");
+ mGameConcern.setBackgroundResource(R.drawable.textview_concern_red_style);
+ mGameConcern.setTextColor(0xffffffff);
+
+ // 取消关注
+ ConcernUtils.deleteConcernData(GameDetailActivity.this, mGameEntity.getId());
+ }
+ });
}
- });
- } else if (v == mNoConnection) {
- mLoading.setVisibility(View.VISIBLE);
- mNoConnection.setVisibility(View.GONE);
-
- if (mGameEntity != null) {
- getGameDetail();
- } else if (mGameId != null) {
- getGameDigest();
- }
+ }
+ });
+ break;
}
}
diff --git a/app/src/main/java/com/gh/gamecenter/LoginActivity.java b/app/src/main/java/com/gh/gamecenter/LoginActivity.java
index 9c5149614a..1264d4c607 100644
--- a/app/src/main/java/com/gh/gamecenter/LoginActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/LoginActivity.java
@@ -15,11 +15,13 @@ import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
+import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.gh.base.BaseActivity;
import com.gh.common.util.DisplayUtils;
+import com.gh.common.util.LoginUtils;
import com.gh.common.util.PatternUtils;
import butterknife.BindView;
@@ -29,7 +31,7 @@ import butterknife.OnClick;
* Created by khy on 19/06/17.
*/
-public class LoginActivity extends BaseActivity {
+public class LoginActivity extends BaseActivity implements LoginUtils.OnLoginListener{
@BindView(R.id.login_phone_et)
@@ -40,8 +42,14 @@ public class LoginActivity extends BaseActivity {
TextView mLoginCaptcha;
@BindView(R.id.login_hint)
TextView mLoginHint;
- @BindView(R.id.login_btn)
+ @BindView(R.id.login_phone_btn)
TextView mLoginBtn;
+ @BindView(R.id.login_qq_btn)
+ LinearLayout mLoginQqBtn;
+ @BindView(R.id.login_wechat_btn)
+ LinearLayout mLoginWechatBtn;
+ @BindView(R.id.login_weibo_btn)
+ LinearLayout mLoginWeiboBtn;
Handler mHandler = new Handler() {
@Override
@@ -108,7 +116,8 @@ public class LoginActivity extends BaseActivity {
});
}
- @OnClick({R.id.login_captcha, R.id.login_hint, R.id.login_btn})
+ @OnClick({R.id.login_captcha, R.id.login_hint, R.id.login_phone_btn, R.id.login_qq_btn,
+ R.id.login_wechat_btn, R.id.login_weibo_btn})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.login_captcha:
@@ -143,7 +152,16 @@ public class LoginActivity extends BaseActivity {
});
dialog.show();
break;
- case R.id.login_btn:
+ case R.id.login_phone_btn:
+ break;
+ case R.id.login_qq_btn:
+ LoginUtils.getInstance(this).QQLogin(this);
+ break;
+ case R.id.login_weibo_btn:
+ LoginUtils.getInstance(this).WeiBoLogin(this);
+ break;
+ case R.id.login_wechat_btn:
+ break;
}
}
@@ -153,6 +171,12 @@ public class LoginActivity extends BaseActivity {
mHandler.removeCallbacksAndMessages(null);
}
+ // 登录成功返回
+ @Override
+ public void onLogin() {
+
+ }
+
private class LoginTextWatcher implements TextWatcher {
private EditText mEditText;
diff --git a/app/src/main/java/com/gh/gamecenter/MessageDetailActivity.java b/app/src/main/java/com/gh/gamecenter/MessageDetailActivity.java
index 5abe7d7be8..d0df3baa19 100644
--- a/app/src/main/java/com/gh/gamecenter/MessageDetailActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/MessageDetailActivity.java
@@ -27,6 +27,7 @@ import com.facebook.drawee.view.SimpleDraweeView;
import com.gh.base.AppController;
import com.gh.base.BaseActivity;
import com.gh.common.constant.Config;
+import com.gh.common.util.CheckLoginUtils;
import com.gh.common.util.DialogUtils;
import com.gh.common.util.ImageUtils;
import com.gh.common.util.PostCommentUtils;
@@ -330,25 +331,29 @@ public class MessageDetailActivity extends BaseActivity implements OnCommentCall
//软键盘控制
private void setSoftInput(boolean isShow) {
- InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
+ final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (isShow) {
- imm.showSoftInputFromInputMethod(mMessageDetailEt.getWindowToken(), 0);
- imm.toggleSoftInputFromWindow(mMessageDetailEt.getWindowToken(), 0, InputMethodManager.HIDE_NOT_ALWAYS);
- mMessageDetailCommentHintRl.setVisibility(View.GONE);
- mMessageDetailLine.setVisibility(View.GONE);
- mMessageDetailCommentRl.setVisibility(View.VISIBLE);
- mMessageDetailUserRl.setVisibility(View.VISIBLE);
- mMessageDetailEt.setFocusable(true);
- mMessageDetailEt.setFocusableInTouchMode(true);
- mMessageDetailEt.requestFocus();
- mColseCommentV.setVisibility(View.VISIBLE);
-
- if (mCommentEntity != null && mCommentEntity.getUser() != null) {
- mMessageDetailEt.setHint("回复" + mCommentEntity.getUser().getName() + ":");
- } else {
- mMessageDetailEt.setHint("优质评论会被优先展示");
- }
+ CheckLoginUtils.checkLogin(this, new CheckLoginUtils.OnLoggenInListener() {
+ @Override
+ public void onLoggedIn() {
+ imm.showSoftInputFromInputMethod(mMessageDetailEt.getWindowToken(), 0);
+ imm.toggleSoftInputFromWindow(mMessageDetailEt.getWindowToken(), 0, InputMethodManager.HIDE_NOT_ALWAYS);
+ mMessageDetailCommentHintRl.setVisibility(View.GONE);
+ mMessageDetailLine.setVisibility(View.GONE);
+ mMessageDetailCommentRl.setVisibility(View.VISIBLE);
+ mMessageDetailUserRl.setVisibility(View.VISIBLE);
+ mMessageDetailEt.setFocusable(true);
+ mMessageDetailEt.setFocusableInTouchMode(true);
+ mMessageDetailEt.requestFocus();
+ mColseCommentV.setVisibility(View.VISIBLE);
+ if (mCommentEntity != null && mCommentEntity.getUser() != null) {
+ mMessageDetailEt.setHint("回复" + mCommentEntity.getUser().getName() + ":");
+ } else {
+ mMessageDetailEt.setHint("优质评论会被优先展示");
+ }
+ }
+ });
} else {
imm.hideSoftInputFromWindow(getWindow().getDecorView().getWindowToken(), 0);
mMessageDetailCommentHintRl.setVisibility(View.VISIBLE);
diff --git a/app/src/main/java/com/gh/gamecenter/NewsDetailActivity.java b/app/src/main/java/com/gh/gamecenter/NewsDetailActivity.java
index 7f60fb74a1..99d81037d6 100644
--- a/app/src/main/java/com/gh/gamecenter/NewsDetailActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/NewsDetailActivity.java
@@ -25,6 +25,7 @@ import android.widget.Toast;
import com.gh.base.BaseActivity;
import com.gh.common.constant.Config;
import com.gh.common.util.ApkActiveUtils;
+import com.gh.common.util.CheckLoginUtils;
import com.gh.common.util.DataCollectionUtils;
import com.gh.common.util.DataUtils;
import com.gh.common.util.DetailDownloadUtils;
@@ -491,12 +492,17 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener
mNoConn.setVisibility(View.GONE);
handler.postDelayed(runnable, 1000);
} else if (v == mDetailCommentLl) {
- Intent intent = new Intent(this, MessageDetailActivity.class);
- intent.putExtra("commentNum", -1);
- intent.putExtra("newsId", adapter.getNewsDetailEntity().getId());
- intent.putExtra("openSoftInput", true);
- intent.putExtra(EntranceUtils.KEY_ENTRANCE, mEntrance + "(新闻详情[" + adapter.getTitle() + "])");
- startActivity(intent);
+ CheckLoginUtils.checkLogin(this, new CheckLoginUtils.OnLoggenInListener() {
+ @Override
+ public void onLoggedIn() {
+ Intent intent = new Intent(NewsDetailActivity.this, MessageDetailActivity.class);
+ intent.putExtra("commentNum", -1);
+ intent.putExtra("newsId", adapter.getNewsDetailEntity().getId());
+ intent.putExtra("openSoftInput", true);
+ intent.putExtra(EntranceUtils.KEY_ENTRANCE, mEntrance + "(新闻详情[" + adapter.getTitle() + "])");
+ startActivity(intent);
+ }
+ });
}
}
@@ -532,6 +538,7 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener
adapter.notifyItemInserted(1);
downloadOffText = gameEntity.getDownloadOffText();
+ mDetailBottomLl.setVisibility(View.VISIBLE);
DetailDownloadUtils.detailInitDownload(getDetailViewHolder(), true);
}
});
diff --git a/app/src/main/java/com/gh/gamecenter/SettingActivity.java b/app/src/main/java/com/gh/gamecenter/SettingActivity.java
index efa309db86..5739c98a33 100644
--- a/app/src/main/java/com/gh/gamecenter/SettingActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/SettingActivity.java
@@ -168,7 +168,8 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
R.id.setting_rl_cache,
R.id.setting_cv_font_size,
R.id.setting_rl_concerngame,
- R.id.setting_rl_about
+ R.id.setting_rl_about,
+ R.id.setting_logout_rl
})
@Override
public void onClick(final View v) {
@@ -218,6 +219,16 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
break;
case R.id.setting_rl_concerngame:
mSettingConcerngameSb.performClick();
+ break;
+ case R.id.setting_logout_rl:
+ DialogUtils.showAlertDialog(this, "注销登录", "退出账号即会回到游客状态,很多功能将无法使用(例如评论、客服消息),确定退出吗?",
+ "确定退出", "取消", new DialogUtils.ConfirmListener() {
+ @Override
+ public void onConfirm() {
+ finish();
+ }
+ }, null);
+ break;
default:
break;
}
diff --git a/app/src/main/java/com/gh/gamecenter/adapter/CommentDetailAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/CommentDetailAdapter.java
index 84296afdeb..c20ce6cb0b 100644
--- a/app/src/main/java/com/gh/gamecenter/adapter/CommentDetailAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/adapter/CommentDetailAdapter.java
@@ -9,24 +9,20 @@ import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.View;
import android.view.ViewGroup;
-import com.lightgame.adapter.BaseRecyclerAdapter;
import com.gh.common.constant.Config;
import com.gh.common.constant.ItemViewType;
import com.gh.common.util.CommentUtils;
import com.gh.common.util.ImageUtils;
-import com.gh.common.util.PostCommentUtils;
import com.gh.common.util.Utils;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.CommentViewHolder;
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
import com.gh.gamecenter.db.CommentDao;
import com.gh.gamecenter.db.VoteDao;
-import com.gh.gamecenter.db.info.VoteInfo;
import com.gh.gamecenter.entity.CommentEntity;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
-
-import org.json.JSONObject;
+import com.lightgame.adapter.BaseRecyclerAdapter;
import java.util.ArrayList;
import java.util.List;
@@ -182,52 +178,7 @@ public class CommentDetailAdapter extends BaseRecyclerAdapter {
holder.commentLikeIv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- if (holder.commentLikeCountTv.getCurrentTextColor() == ContextCompat.getColor(mContext, R.color.theme)) {
- Utils.toast(mContext, "已经点过赞啦!");
- return;
- }
- commentEntity.setVote(commentEntity.getVote() + 1);
- holder.commentLikeCountTv.setTextColor(ContextCompat.getColor(mContext, R.color.theme));
- holder.commentLikeIv.setImageResource(R.drawable.ic_like_select);
- holder.commentLikeCountTv.setText(String.valueOf(commentEntity.getVote()));
- holder.commentLikeCountTv.setVisibility(View.VISIBLE);
-
- PostCommentUtils.addCommentVoto(mContext, commentEntity.getId(), true,
- new PostCommentUtils.PostCommentListener() {
- @Override
- public void postSuccess(JSONObject response) {
- mVoteDao.add(new VoteInfo(commentEntity.getId()));
- }
-
- @Override
- public void postFailed(Throwable error) {
- commentEntity.setVote(commentEntity.getVote() - 1);
- holder.commentLikeCountTv.setTextColor(ContextCompat.getColor(mContext, R.color.hint));
- holder.commentLikeIv.setImageResource(R.drawable.ic_like_unselect);
- holder.commentLikeCountTv.setText(String.valueOf(commentEntity.getVote()));
- if (commentEntity.getVote() == 0) {
- holder.commentLikeCountTv.setVisibility(View.GONE);
- } else {
- holder.commentLikeCountTv.setVisibility(View.VISIBLE);
- }
- if (error instanceof HttpException) {
- HttpException exception = (HttpException) error;
- if (exception.code() == 403) {
- try {
- if (new JSONObject(exception.response().errorBody().string())
- .getString("detail").equals("voted")) {
- Utils.toast(mContext, "已经点过赞啦!");
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return;
- }
- }
- Utils.toast(mContext, "网络异常,点赞失败");
-
- }
- });
+ CommentUtils.initVote(mContext, commentEntity, mVoteDao, holder.commentLikeCountTv, holder.commentLikeIv, null);
}
});
diff --git a/app/src/main/java/com/gh/gamecenter/adapter/MessageDetailAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/MessageDetailAdapter.java
index 62b0bea8f5..d22016b399 100644
--- a/app/src/main/java/com/gh/gamecenter/adapter/MessageDetailAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/adapter/MessageDetailAdapter.java
@@ -13,7 +13,6 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
-import com.lightgame.adapter.BaseRecyclerAdapter;
import com.gh.common.constant.Config;
import com.gh.common.util.CommentUtils;
import com.gh.common.util.ConcernContentUtils;
@@ -23,10 +22,8 @@ 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;
import com.gh.common.util.StringUtils;
import com.gh.common.util.TimestampUtils;
-import com.gh.common.util.Utils;
import com.gh.gamecenter.MessageDetailActivity;
import com.gh.gamecenter.NewsDetailActivity;
import com.gh.gamecenter.R;
@@ -38,7 +35,6 @@ import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
import com.gh.gamecenter.adapter.viewholder.NewsDigestViewHolder;
import com.gh.gamecenter.db.CommentDao;
import com.gh.gamecenter.db.VoteDao;
-import com.gh.gamecenter.db.info.VoteInfo;
import com.gh.gamecenter.entity.CommentEntity;
import com.gh.gamecenter.entity.ConcernEntity;
import com.gh.gamecenter.manager.VisitManager;
@@ -46,6 +42,7 @@ import com.gh.gamecenter.retrofit.JSONObjectResponse;
import com.gh.gamecenter.retrofit.OkHttpCache;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
+import com.lightgame.adapter.BaseRecyclerAdapter;
import org.json.JSONArray;
import org.json.JSONException;
@@ -437,22 +434,10 @@ public class MessageDetailAdapter extends BaseRecyclerAdapter {
holder.commentLikeIv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- if (holder.commentLikeCountTv.getCurrentTextColor() == ContextCompat.getColor(mContext, R.color.theme)) {
- Utils.toast(mContext, "已经点过赞啦!");
- return;
- }
- finalCommentEntity.setVote(finalCommentEntity.getVote() + 1);
- holder.commentLikeCountTv.setTextColor(ContextCompat.getColor(mContext, R.color.theme));
- holder.commentLikeIv.setImageResource(R.drawable.ic_like_select);
- holder.commentLikeCountTv.setText(String.valueOf(finalCommentEntity.getVote()));
- holder.commentLikeCountTv.setVisibility(View.VISIBLE);
-
- PostCommentUtils.addCommentVoto(mContext, finalCommentEntity.getId(), true,
- new PostCommentUtils.PostCommentListener() {
+ CommentUtils.initVote(mContext, finalCommentEntity, mVoteDao, holder.commentLikeCountTv,
+ holder.commentLikeIv, new CommentUtils.OnVoteListener() {
@Override
- public void postSuccess(JSONObject response) {
- mVoteDao.add(new VoteInfo(finalCommentEntity.getId()));
-
+ public void onVote() {
int index = (finalCommentPosition / 10) * 10;
//获取需要修改缓存的链接
@@ -467,35 +452,6 @@ public class MessageDetailAdapter extends BaseRecyclerAdapter {
modifyVolleyCache(finalCommentEntity.getId(), cacheUrl); //修改缓存
}
-
- @Override
- public void postFailed(Throwable e) {
-
- finalCommentEntity.setVote(finalCommentEntity.getVote() - 1);
- holder.commentLikeCountTv.setTextColor(ContextCompat.getColor(mContext, R.color.hint));
- holder.commentLikeIv.setImageResource(R.drawable.ic_like_unselect);
- holder.commentLikeCountTv.setText(String.valueOf(finalCommentEntity.getVote()));
- if (finalCommentEntity.getVote() == 0) {
- holder.commentLikeCountTv.setVisibility(View.GONE);
- } else {
- holder.commentLikeCountTv.setVisibility(View.VISIBLE);
- }
-
- if (e instanceof HttpException) {
- HttpException exception = (HttpException) e;
- if (exception.code() == 403) {
- try {
- if (new JSONObject(exception.response().errorBody().string()).getString("detail").equals("voted")) {
- Utils.toast(mContext, "已经点过赞啦!");
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return;
- }
- }
- Utils.toast(mContext, "网络异常,点赞失败");
- }
});
}
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 609ee1c2ea..7f5b4431cd 100644
--- a/app/src/main/java/com/gh/gamecenter/newsdetail/NewsDetailAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/newsdetail/NewsDetailAdapter.java
@@ -24,8 +24,8 @@ import android.widget.Toast;
import com.facebook.drawee.view.SimpleDraweeView;
import com.gh.base.OnRequestCallBackListener;
-import com.lightgame.adapter.BaseRecyclerAdapter;
import com.gh.common.constant.Config;
+import com.gh.common.util.CheckLoginUtils;
import com.gh.common.util.CommentUtils;
import com.gh.common.util.ConcernUtils;
import com.gh.common.util.DataCollectionUtils;
@@ -34,7 +34,6 @@ import com.gh.common.util.DialogUtils;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.ImageUtils;
import com.gh.common.util.NewsUtils;
-import com.gh.common.util.PostCommentUtils;
import com.gh.common.util.RandomUtils;
import com.gh.common.util.StringUtils;
import com.gh.common.util.Utils;
@@ -49,7 +48,6 @@ import com.gh.gamecenter.WebActivity;
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;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.CommentEntity;
import com.gh.gamecenter.entity.GameEntity;
@@ -58,8 +56,7 @@ import com.gh.gamecenter.entity.NewsEntity;
import com.gh.gamecenter.manager.ConcernManager;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
-
-import org.json.JSONObject;
+import com.lightgame.adapter.BaseRecyclerAdapter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -230,7 +227,6 @@ public class NewsDetailAdapter extends BaseRecyclerAdapter {
}
if (viewHolder.newsdetail_item_wv_content.getTag() == null) {
-// viewHolder.newsdetail_item_wv_content.setBackgroundColor(0xFFEDF2F4);
viewHolder.newsdetail_item_wv_content.addJavascriptInterface(new JsInterface(mContext), "imagelistener");
mWebSettings = viewHolder.newsdetail_item_wv_content.getSettings();
mWebSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
@@ -329,7 +325,6 @@ public class NewsDetailAdapter extends BaseRecyclerAdapter {
}
private void initGameDetailTopViewHolder(GameDetailTopViewHolder viewHolder) {
-// viewHolder.gamedetailThumb.setImageURI(mGameEntity.getIcon());
ImageUtils.display(viewHolder.gamedetailThumb, mGameEntity.getIcon());
viewHolder.gamedetailName.setText(mGameEntity.getName());
if (mGameEntity.getApk() != null && mGameEntity.getApk().size() != 0) {
@@ -357,57 +352,62 @@ public class NewsDetailAdapter extends BaseRecyclerAdapter {
@Override
public void onClick(View v) {
final TextView concern = ((TextView) v);
- String str = concern.getText().toString();
- if ("关注".equals(str)) {
+ CheckLoginUtils.checkLogin(mContext, new CheckLoginUtils.OnLoggenInListener() {
+ @Override
+ public void onLoggedIn() {
+ String str = concern.getText().toString();
+ if ("关注".equals(str)) {
- Map kv = new HashMap<>();
- kv.put("状态", "关注");
- DataUtils.onEvent(mContext, "游戏关注", mGameEntity.getName(), kv);
+ Map kv = new HashMap<>();
+ kv.put("状态", "关注");
+ DataUtils.onEvent(mContext, "游戏关注", mGameEntity.getName(), kv);
- Map kv2 = new HashMap<>();
- kv2.put("点击", "关注");
- DataUtils.onEvent(mContext, "插件数据", mGameEntity.getName(), kv2);
+ Map kv2 = new HashMap<>();
+ kv2.put("点击", "关注");
+ DataUtils.onEvent(mContext, "插件数据", mGameEntity.getName(), kv2);
- DataCollectionUtils.uploadConcern(mContext, mGameEntity.getName(), mGameEntity.getId(), "关注");
+ DataCollectionUtils.uploadConcern(mContext, mGameEntity.getName(), mGameEntity.getId(), "关注");
- mConcernManager.addByEntity(mGameEntity);
- concern.setText("取消关注");
- concern.setBackgroundResource(R.drawable.border_red_bg);
- concern.setTextColor(Color.parseColor("#ff4147"));
+ mConcernManager.addByEntity(mGameEntity);
+ concern.setText("取消关注");
+ concern.setBackgroundResource(R.drawable.border_red_bg);
+ concern.setTextColor(Color.parseColor("#ff4147"));
- Toast.makeText(mContext, "关注成功", Toast.LENGTH_SHORT).show();
+ Toast.makeText(mContext, "关注成功", Toast.LENGTH_SHORT).show();
- // 添加关注
- ConcernUtils.postConcernGameId(mContext, mGameEntity.getId());
- } else {
- Map kv = new HashMap<>();
- kv.put("状态", "取消关注");
- DataUtils.onEvent(mContext, "游戏关注", mGameEntity.getName(), kv);
-
- Map kv2 = new HashMap<>();
- kv2.put("点击", "取消关注");
- DataUtils.onEvent(mContext, "插件数据", mGameEntity.getName(), kv2);
-
- DialogUtils.showCancelDialog(mContext, new DialogUtils.ConfirmListener() {
- @Override
- public void onConfirm() {
+ // 添加关注
+ ConcernUtils.postConcernGameId(mContext, mGameEntity.getId());
+ } else {
Map kv = new HashMap<>();
kv.put("状态", "取消关注");
DataUtils.onEvent(mContext, "游戏关注", mGameEntity.getName(), kv);
- DataCollectionUtils.uploadConcern(mContext,
- mGameEntity.getName(), mGameEntity.getId(), "取消关注");
+ Map kv2 = new HashMap<>();
+ kv2.put("点击", "取消关注");
+ DataUtils.onEvent(mContext, "插件数据", mGameEntity.getName(), kv2);
- mConcernManager.deleteConcern(mGameEntity.getId());
- concern.setText("关注");
- concern.setBackgroundResource(R.drawable.textview_concern_red_style);
- concern.setTextColor(Color.WHITE);
+ DialogUtils.showCancelDialog(mContext, new DialogUtils.ConfirmListener() {
+ @Override
+ public void onConfirm() {
+ Map kv = new HashMap<>();
+ kv.put("状态", "取消关注");
+ DataUtils.onEvent(mContext, "游戏关注", mGameEntity.getName(), kv);
- //取消关注
- ConcernUtils.deleteConcernData(mContext, mGameEntity.getId());
+ DataCollectionUtils.uploadConcern(mContext,
+ mGameEntity.getName(), mGameEntity.getId(), "取消关注");
+
+ mConcernManager.deleteConcern(mGameEntity.getId());
+ concern.setText("关注");
+ concern.setBackgroundResource(R.drawable.textview_concern_red_style);
+ concern.setTextColor(Color.WHITE);
+
+ //取消关注
+ ConcernUtils.deleteConcernData(mContext, mGameEntity.getId());
+ }
+ });
}
- });
- }
+ }
+ });
}
});
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@@ -533,52 +533,7 @@ public class NewsDetailAdapter extends BaseRecyclerAdapter {
like.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- if (likeCount.getCurrentTextColor() == ContextCompat.getColor(mContext, R.color.theme)) {
- Utils.toast(mContext, "已经点过赞啦!");
- return;
- }
- commentEntity.setVote(commentEntity.getVote() + 1);
- likeCount.setTextColor(ContextCompat.getColor(mContext, R.color.theme));
- like.setImageResource(R.drawable.ic_like_select);
- likeCount.setText(String.valueOf(commentEntity.getVote()));
- likeCount.setVisibility(View.VISIBLE);
-
- PostCommentUtils.addCommentVoto(mContext, commentEntity.getId(), true,
- new PostCommentUtils.PostCommentListener() {
- @Override
- public void postSuccess(JSONObject response) {
- mVoteDao.add(new VoteInfo(commentEntity.getId()));
- }
-
- @Override
- public void postFailed(Throwable error) {
- commentEntity.setVote(commentEntity.getVote() - 1);
- likeCount.setTextColor(ContextCompat.getColor(mContext, R.color.hint));
- like.setImageResource(R.drawable.ic_like_unselect);
- likeCount.setText(String.valueOf(commentEntity.getVote()));
- if (commentEntity.getVote() == 0) {
- likeCount.setVisibility(View.GONE);
- } else {
- likeCount.setVisibility(View.VISIBLE);
- }
- if (error instanceof HttpException) {
- HttpException exception = (HttpException) error;
- if (exception.code() == 403) {
- try {
- if (new JSONObject(exception.response().errorBody().string())
- .getString("detail").equals("voted")) {
- Utils.toast(mContext, "已经点过赞啦!");
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return;
- }
- }
- Utils.toast(mContext, "网络异常,点赞失败");
-
- }
- });
+ CommentUtils.initVote(mContext, commentEntity, mVoteDao, likeCount, like, null);
}
});
contentView.setOnClickListener(new View.OnClickListener() {
diff --git a/app/src/main/java/com/gh/gamecenter/personal/PersonalFragment.java b/app/src/main/java/com/gh/gamecenter/personal/PersonalFragment.java
index ecea4b73d0..f80adf9d64 100644
--- a/app/src/main/java/com/gh/gamecenter/personal/PersonalFragment.java
+++ b/app/src/main/java/com/gh/gamecenter/personal/PersonalFragment.java
@@ -35,7 +35,7 @@ import butterknife.OnClick;
* 294299195@qq.com
* 2015-8-8 我的光环页面
*/
-public class PersonalFragment extends BaseFragment {
+public class PersonalFragment extends BaseFragment implements LoginUtils.OnLoginListener{
@BindView(R.id.personal_login_qq)
@@ -97,13 +97,13 @@ public class PersonalFragment extends BaseFragment {
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.personal_login_qq:
- LoginUtils.getInstance(getActivity()).QQLogin();
+ LoginUtils.getInstance(getActivity()).QQLogin(this);
break;
case R.id.personal_login_wechat:
changeLoginState(true);
break;
case R.id.personal_login_weibo:
- LoginUtils.getInstance(getActivity()).WeiBoLogin();
+ LoginUtils.getInstance(getActivity()).WeiBoLogin(this);
break;
case R.id.personal_user_icon:
getContext().startActivity(LoginActivity.getIntent(getContext()));
@@ -156,4 +156,9 @@ public class PersonalFragment extends BaseFragment {
}
}
+ // 登录成功返回
+ @Override
+ public void onLogin() {
+
+ }
}
diff --git a/app/src/main/res/layout/activity_gamedetail.xml b/app/src/main/res/layout/activity_gamedetail.xml
index 3c12425c9d..39205543f3 100644
--- a/app/src/main/res/layout/activity_gamedetail.xml
+++ b/app/src/main/res/layout/activity_gamedetail.xml
@@ -69,19 +69,21 @@
-
-
+ android:visibility = "gone"
+ android:layout_marginTop="-7dp">
+
+
+
-
-
+ android:layout_above = "@+id/news_detail_ll_bottom" />
+ android:layout_marginTop = "-7dp"
+ android:orientation = "vertical"
+ android:visibility = "gone" >
+
+
+ android:visibility = "gone" >