From d5255f91d00e5a844404e31a675a137cb3e6ffa3 Mon Sep 17 00:00:00 2001 From: kehaoyuan Date: Sun, 1 Apr 2018 10:04:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=97=AE=E9=A2=98=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=97=AA=E9=80=80=E9=97=AE=E9=A2=98=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9CheckLoginUtils?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gh/common/util/CheckLoginUtils.java | 8 +- .../java/com/gh/common/util/CommentUtils.java | 125 ++++---- .../java/com/gh/common/util/LibaoUtils.java | 295 +++++++++--------- .../com/gh/gamecenter/NewsDetailActivity.java | 96 +++--- .../com/gh/gamecenter/SuggestionActivity.java | 37 +-- .../ask/AskQuestionsHotFragment.java | 12 +- .../ask/AskQuestionsHotViewModel.java | 4 +- .../ask/AskQuestionsNewBodyFragment.java | 6 +- .../QuestionsDetailAdapter.java | 2 +- .../gamedetail/GameDetailFragment.java | 127 ++++---- .../gh/gamecenter/info/ConcernFragment.java | 25 +- .../message/MessageDetailFragment.java | 31 +- .../newsdetail/NewsDetailAdapter.java | 135 ++++---- .../halo/assistant/fragment/VoteFragment.java | 21 +- .../halo/assistant/fragment/WebFragment.java | 83 +++-- .../comment/CommentDetailFragment.java | 25 +- .../fragment/myconcern/MyConcernAdapter.java | 67 ++-- .../myconcern/MyConcernRecommendAdapter.java | 51 ++- 18 files changed, 548 insertions(+), 602 deletions(-) diff --git a/app/src/main/java/com/gh/common/util/CheckLoginUtils.java b/app/src/main/java/com/gh/common/util/CheckLoginUtils.java index 0a3ea4935f..86e311bf10 100644 --- a/app/src/main/java/com/gh/common/util/CheckLoginUtils.java +++ b/app/src/main/java/com/gh/common/util/CheckLoginUtils.java @@ -13,7 +13,7 @@ import com.gh.gamecenter.manager.UserManager; public class CheckLoginUtils { - public static void checkLogin(final Context context, OnLoggenInListener listener) { + public static void checkLogin(final Context context, OnLoginListener listener) { // String token = LoginUtils.getToken(context); if (TextUtils.isEmpty(UserManager.getInstance().getToken())) { DialogUtils.showWarningDialog(context, "登录提示", "需要登录才能使用该功能喔!", "取消", "快速登录", @@ -25,7 +25,7 @@ public class CheckLoginUtils { } }, null); } else { - listener.onLoggedIn(); + listener.onLogin(); } } @@ -33,7 +33,7 @@ public class CheckLoginUtils { return !TextUtils.isEmpty(UserManager.getInstance().getToken()); } - public interface OnLoggenInListener { - void onLoggedIn(); + public interface OnLoginListener { + void onLogin(); } } 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 b84bde8064..b93aa3bba3 100644 --- a/app/src/main/java/com/gh/common/util/CommentUtils.java +++ b/app/src/main/java/com/gh/common/util/CommentUtils.java @@ -112,16 +112,13 @@ public class CommentUtils { dialog.cancel(); switch (reportTv.getText().toString()) { case "回复": - 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, "缺少关键属性"); - } + CheckLoginUtils.checkLogin(context, () -> { + if (listener != null) { + listener.onCommentCallback(commentEntity); + } else if (!TextUtils.isEmpty(newsId)) { + context.startActivity(MessageDetailActivity.getMessageDetailIntent(context, commentEntity, newsId)); + } else { + Utils.toast(context, "缺少关键属性"); } }); break; @@ -129,12 +126,7 @@ public class CommentUtils { LibaoUtils.copyLink(commentEntity.getContent(), context); break; case "举报": - CheckLoginUtils.checkLogin(context, new CheckLoginUtils.OnLoggenInListener() { - @Override - public void onLoggedIn() { - showReportTypeDialog(commentEntity, context); - } - }); + CheckLoginUtils.checkLogin(context, () -> showReportTypeDialog(commentEntity, context)); break; case "查看对话": @@ -278,59 +270,56 @@ public class CommentUtils { public static void postVote(final Context context, final CommentEntity commentEntity, 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(), - new PostCommentUtils.PostCommentListener() { - @Override - public void postSuccess(JSONObject response) { - 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 ("voted".equals(detail)) { - Utils.toast(context, "已经点过赞啦!"); - } - } catch (Exception ex) { - ex.printStackTrace(); - } - return; - } - } - Utils.toast(context, "网络异常,点赞失败"); - } - }); + CheckLoginUtils.checkLogin(context, () -> { + 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(), + new PostCommentUtils.PostCommentListener() { + @Override + public void postSuccess(JSONObject response) { + 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 ("voted".equals(detail)) { + Utils.toast(context, "已经点过赞啦!"); + } + } catch (Exception ex) { + ex.printStackTrace(); + } + return; + } + } + Utils.toast(context, "网络异常,点赞失败"); + } + }); }); } 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 55d6d60049..c53f613ce0 100644 --- a/app/src/main/java/com/gh/common/util/LibaoUtils.java +++ b/app/src/main/java/com/gh/common/util/LibaoUtils.java @@ -232,76 +232,156 @@ public class LibaoUtils { libaoBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - 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()) + "版"; - } + 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); + 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; + } + } + + 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) { - 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(); - if (loadingDialog != null) loadingDialog.dismiss(); + JSONObject responseBody = (JSONObject) response; + String libaoCode = null; + try { + libaoCode = responseBody.getString("code"); + } catch (JSONException e) { + e.printStackTrace(); + } - JSONObject responseBody = (JSONObject) response; - String libaoCode = null; + if (TextUtils.isEmpty(libaoCode)) { try { - libaoCode = responseBody.getString("code"); + 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; + } - if (TextUtils.isEmpty(libaoCode)) { + 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 { - String detail = responseBody.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, "你今天已领过这个礼包了, 不能再淘号"); + + 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; @@ -309,104 +389,21 @@ public class LibaoUtils { Utils.toast(context, "淘号失败,稍后重试"); break; default: - Utils.toast(context, "淘号异常"); + Utils.toast(context, "操作失败"); break; + } - } catch (JSONException e) { - e.printStackTrace(); + } catch (Exception ex) { + ex.printStackTrace(); + Utils.toast(context, "礼包处理异常" + ex.toString()); } 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"); -// Utils.toast(context, "返回::" + detail); - 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; - - } - } catch (Exception ex) { - ex.printStackTrace(); - Utils.toast(context, "礼包处理异常" + ex.toString()); - } - return; - } - } - Utils.toast(context, "发生异常"); - } - }); - break; - } + Utils.toast(context, "发生异常"); + } + }); + break; } }); } diff --git a/app/src/main/java/com/gh/gamecenter/NewsDetailActivity.java b/app/src/main/java/com/gh/gamecenter/NewsDetailActivity.java index e51462971b..429a7eee73 100644 --- a/app/src/main/java/com/gh/gamecenter/NewsDetailActivity.java +++ b/app/src/main/java/com/gh/gamecenter/NewsDetailActivity.java @@ -551,65 +551,59 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener, mNoConn.setVisibility(View.GONE); handler.postDelayed(runnable, 1000); } else if (v == mDetailCommentLl) { - CheckLoginUtils.checkLogin(this, new CheckLoginUtils.OnLoggenInListener() { - @Override - public void onLoggedIn() { - Intent intent = MessageDetailActivity.getIntentById(NewsDetailActivity.this, adapter.getNewsDetailEntity().getId(), null, true - , mEntrance + "(新闻详情[" + adapter.getTitle() + "])"); - startActivity(intent); - } + CheckLoginUtils.checkLogin(this, () -> { + Intent intent = MessageDetailActivity.getIntentById(NewsDetailActivity.this, adapter.getNewsDetailEntity().getId(), null, true + , mEntrance + "(新闻详情[" + adapter.getTitle() + "])"); + startActivity(intent); }); } else if (v == mNewsCollection) { - CheckLoginUtils.checkLogin(this, new CheckLoginUtils.OnLoggenInListener() { - @Override - public void onLoggedIn() { - final NewsDetailEntity newsDetailEntity = adapter.getNewsDetailEntity(); - mNewsCollection.setEnabled(false); - if (newsDetailEntity.getUserData() != null && newsDetailEntity.getUserData().isArticleFavorite()) { - CollectionUtils.INSTANCE.deleteCollection(NewsDetailActivity.this, mNewsEntity.getId(), - CollectionUtils.CollectionType.article, - new CollectionUtils.OnCollectionListener() { - @Override - public void onSuccess() { - newsDetailEntity.getUserData().setArticleFavorite(false); - mNewsCollection.setEnabled(true); - mNewsCollection.setImageResource(R.drawable.menu_ic_collect_unselect); - toast(R.string.collection_cancel); - } + CheckLoginUtils.checkLogin(this, () -> { + final NewsDetailEntity newsDetailEntity = adapter.getNewsDetailEntity(); + mNewsCollection.setEnabled(false); + if (newsDetailEntity.getUserData() != null && newsDetailEntity.getUserData().isArticleFavorite()) { + CollectionUtils.INSTANCE.deleteCollection(NewsDetailActivity.this, mNewsEntity.getId(), + CollectionUtils.CollectionType.article, + new CollectionUtils.OnCollectionListener() { + @Override + public void onSuccess() { + newsDetailEntity.getUserData().setArticleFavorite(false); + mNewsCollection.setEnabled(true); + mNewsCollection.setImageResource(R.drawable.menu_ic_collect_unselect); + toast(R.string.collection_cancel); + } - @Override - public void onError() { - mNewsCollection.setEnabled(true); - toast(R.string.collection_cancel_failure); - } - }); + @Override + public void onError() { + mNewsCollection.setEnabled(true); + toast(R.string.collection_cancel_failure); + } + }); - } else { + } else { // Map map = new HashMap<>(); // map.put("_id", mNewsEntity.getId()); - CollectionUtils.INSTANCE.postCollection(NewsDetailActivity.this, mNewsEntity.getId(), - CollectionUtils.CollectionType.article, - new CollectionUtils.OnCollectionListener() { - @Override - public void onSuccess() { - UserDataEntity userData = newsDetailEntity.getUserData(); - if (userData == null) { - userData = new UserDataEntity(); - newsDetailEntity.setUserData(userData); - } - userData.setArticleFavorite(true); - mNewsCollection.setEnabled(true); - mNewsCollection.setImageResource(R.drawable.menu_ic_collect_select); - toast(R.string.collection_success); + CollectionUtils.INSTANCE.postCollection(NewsDetailActivity.this, mNewsEntity.getId(), + CollectionUtils.CollectionType.article, + new CollectionUtils.OnCollectionListener() { + @Override + public void onSuccess() { + UserDataEntity userData = newsDetailEntity.getUserData(); + if (userData == null) { + userData = new UserDataEntity(); + newsDetailEntity.setUserData(userData); } + userData.setArticleFavorite(true); + mNewsCollection.setEnabled(true); + mNewsCollection.setImageResource(R.drawable.menu_ic_collect_select); + toast(R.string.collection_success); + } - @Override - public void onError() { - mNewsCollection.setEnabled(true); - toast(R.string.collection_failure); - } - }); - } + @Override + public void onError() { + mNewsCollection.setEnabled(true); + toast(R.string.collection_failure); + } + }); } }); } diff --git a/app/src/main/java/com/gh/gamecenter/SuggestionActivity.java b/app/src/main/java/com/gh/gamecenter/SuggestionActivity.java index 0d8804447a..3038a5c388 100644 --- a/app/src/main/java/com/gh/gamecenter/SuggestionActivity.java +++ b/app/src/main/java/com/gh/gamecenter/SuggestionActivity.java @@ -395,29 +395,26 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt return; } - CheckLoginUtils.checkLogin(this, new CheckLoginUtils.OnLoggenInListener() { - @Override - public void onLoggedIn() { - String email = mSuggestEmailEt.getText().toString().trim(); - String url = mSuggestNewsLinkEt.getText().toString().trim(); + CheckLoginUtils.checkLogin(this, () -> { + String email = mSuggestEmailEt.getText().toString().trim(); + String url = mSuggestNewsLinkEt.getText().toString().trim(); - if (!TextUtils.isEmpty(url) && !PatternUtils.isUrlAddress(url)) { - toast(R.string.suggestion_url_error_hint); - return; - } + if (!TextUtils.isEmpty(url) && !PatternUtils.isUrlAddress(url)) { + toast(R.string.suggestion_url_error_hint); + return; + } - if (TextUtils.isEmpty(email)) { - showConfirmDialog(email); + if (TextUtils.isEmpty(email)) { + showConfirmDialog(email); + } else { + postDialog = WaitingDialogFragment.newInstance(getString(R.string.dialog_feedback_doing)); + postDialog.show(getSupportFragmentManager(), null); + + List fileList = mAdapter.getFileList(); + if (fileList != null && fileList.size() > 0) { + postPic(email); } else { - postDialog = WaitingDialogFragment.newInstance(getString(R.string.dialog_feedback_doing)); - postDialog.show(getSupportFragmentManager(), null); - - List fileList = mAdapter.getFileList(); - if (fileList != null && fileList.size() > 0) { - postPic(email); - } else { - initPostData(email, null); - } + initPostData(email, null); } } }); diff --git a/app/src/main/java/com/gh/gamecenter/ask/AskQuestionsHotFragment.java b/app/src/main/java/com/gh/gamecenter/ask/AskQuestionsHotFragment.java index 2b05bcd1e7..fc718512ff 100644 --- a/app/src/main/java/com/gh/gamecenter/ask/AskQuestionsHotFragment.java +++ b/app/src/main/java/com/gh/gamecenter/ask/AskQuestionsHotFragment.java @@ -32,12 +32,12 @@ public class AskQuestionsHotFragment extends ListFragment { + mOnLoginListener = () -> { NormalActivity.startFragment(getContext(), QuestionsEditFragment.class); }; @@ -70,7 +70,11 @@ public class AskQuestionsHotFragment extends ListFragment value = mLiveData.getValue(); - if (loadType == LoadType.REFRESH && value != null && value.size() > 0) { + if (loadType == LoadType.RETRY) { + loadData(true, null); + } else if (loadType == LoadType.REFRESH && value != null && value.size() > 0) { loadData(true, mLiveData.getValue().get(0).getSequenceId()); } else if (value != null && value.size() > 0) { loadData(false, value.get(value.size() - 1).getSequenceId()); diff --git a/app/src/main/java/com/gh/gamecenter/ask/AskQuestionsNewBodyFragment.java b/app/src/main/java/com/gh/gamecenter/ask/AskQuestionsNewBodyFragment.java index fc6a673a0f..1fc44cfe30 100644 --- a/app/src/main/java/com/gh/gamecenter/ask/AskQuestionsNewBodyFragment.java +++ b/app/src/main/java/com/gh/gamecenter/ask/AskQuestionsNewBodyFragment.java @@ -34,7 +34,7 @@ import rx.Observable; public class AskQuestionsNewBodyFragment extends ListFragment { private AskQuestionsNewBodyAdapter mAdapter; - private CheckLoginUtils.OnLoggenInListener mOnLoggenInListener; + private CheckLoginUtils.OnLoginListener mOnLoginListener; private String mType; @@ -53,7 +53,7 @@ public class AskQuestionsNewBodyFragment extends ListFragment { + mOnLoginListener = () -> { NormalActivity.startFragment(getContext(), QuestionsEditFragment.class); }; } @@ -71,7 +71,7 @@ public class AskQuestionsNewBodyFragment extends ListFragment { mIsNetworkError = false; mIsOver = false; case REFRESH: - mEntityList.clear(); + if (mEntityList != null)mEntityList.clear(); break; } 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 add0276684..0f20a9def7 100644 --- a/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailFragment.java +++ b/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailFragment.java @@ -518,80 +518,77 @@ public class GameDetailFragment extends NormalFragment { } break; case R.id.gamedetail_tv_concern: - CheckLoginUtils.checkLogin(getContext(), new CheckLoginUtils.OnLoggenInListener() { - @Override - public void onLoggedIn() { - mGameConcern.setEnabled(false); - if (getString(R.string.concern).equals(mGameConcern.getText().toString())) { - // 添加关注 - ConcernUtils.INSTANCE.postConcernGameId(getContext(), mGameEntity.getId() - , new ConcernUtils.onConcernListener() { - @Override - public void onSuccess() { - Map kv = new HashMap<>(); - kv.put("状态", R.string.concern); - DataUtils.onEvent(getContext(), "游戏关注", mGameEntity.getName(), kv); + CheckLoginUtils.checkLogin(getContext(), () -> { + mGameConcern.setEnabled(false); + if (getString(R.string.concern).equals(mGameConcern.getText().toString())) { + // 添加关注 + ConcernUtils.INSTANCE.postConcernGameId(getContext(), mGameEntity.getId() + , new ConcernUtils.onConcernListener() { + @Override + public void onSuccess() { + Map kv = new HashMap<>(); + kv.put("状态", R.string.concern); + DataUtils.onEvent(getContext(), "游戏关注", mGameEntity.getName(), kv); - Map kv2 = new HashMap<>(); - kv2.put("点击", R.string.concern); - DataUtils.onEvent(getContext(), "插件数据", mGameEntity.getName(), kv2); + Map kv2 = new HashMap<>(); + kv2.put("点击", R.string.concern); + DataUtils.onEvent(getContext(), "插件数据", mGameEntity.getName(), kv2); - DataCollectionUtils.uploadConcern(getContext(), mGameEntity.getName(), mGameEntity.getId(), "关注"); + DataCollectionUtils.uploadConcern(getContext(), mGameEntity.getName(), mGameEntity.getId(), "关注"); - mGameConcern.setText(R.string.cancel_concern); - mGameConcern.setBackgroundResource(R.drawable.button_normal_border); - mGameConcern.setTextColor(getResources().getColor(R.color.theme)); + mGameConcern.setText(R.string.cancel_concern); + mGameConcern.setBackgroundResource(R.drawable.button_normal_border); + mGameConcern.setTextColor(getResources().getColor(R.color.theme)); - toast(R.string.concern_success); - mGameConcern.setEnabled(true); - } + toast(R.string.concern_success); + mGameConcern.setEnabled(true); + } - @Override - public void onError() { - mGameConcern.setEnabled(true); - toast(R.string.concern_failure); - } - }); - } else { - Map kv2 = new HashMap<>(); - kv2.put("点击", "取消关注"); - DataUtils.onEvent(getContext(), "插件数据", mGameEntity.getName(), kv2); + @Override + public void onError() { + mGameConcern.setEnabled(true); + toast(R.string.concern_failure); + } + }); + } else { + Map kv2 = new HashMap<>(); + kv2.put("点击", "取消关注"); + DataUtils.onEvent(getContext(), "插件数据", mGameEntity.getName(), kv2); - DialogUtils.showCancelDialog(getContext(), new DialogUtils.ConfirmListener() { - @Override - public void onConfirm() { - // 取消关注 - ConcernUtils.INSTANCE.deleteConcernData(getContext(), mGameEntity.getId() - , new ConcernUtils.onConcernListener() { - @Override - public void onSuccess() { - Map kv = new HashMap<>(); - kv.put("状态", "取消关注"); - DataUtils.onEvent(getContext(), "游戏关注", mGameEntity.getName(), kv); + DialogUtils.showCancelDialog(getContext(), new DialogUtils.ConfirmListener() { + @Override + public void onConfirm() { + // 取消关注 + ConcernUtils.INSTANCE.deleteConcernData(getContext(), mGameEntity.getId() + , new ConcernUtils.onConcernListener() { + @Override + public void onSuccess() { + Map kv = new HashMap<>(); + kv.put("状态", "取消关注"); + DataUtils.onEvent(getContext(), "游戏关注", mGameEntity.getName(), kv); - DataCollectionUtils.uploadConcern(getContext(), - mGameEntity.getName(), mGameEntity.getId(), "取消关注"); + DataCollectionUtils.uploadConcern(getContext(), + mGameEntity.getName(), mGameEntity.getId(), "取消关注"); - mGameConcern.setText(getString(R.string.concern)); - mGameConcern.setBackgroundResource(R.drawable.button_normal_style); - mGameConcern.setTextColor(0xffffffff); - mGameConcern.setEnabled(true); - } + mGameConcern.setText(getString(R.string.concern)); + mGameConcern.setBackgroundResource(R.drawable.button_normal_style); + mGameConcern.setTextColor(0xffffffff); + mGameConcern.setEnabled(true); + } - @Override - public void onError() { - mGameConcern.setEnabled(true); - toast(R.string.cancel_concern_failure); - } - }); - } - }, new DialogUtils.CancelListener() { - @Override - public void onCancel() { - mGameConcern.setEnabled(true); - } - }); - } + @Override + public void onError() { + mGameConcern.setEnabled(true); + toast(R.string.cancel_concern_failure); + } + }); + } + }, new DialogUtils.CancelListener() { + @Override + public void onCancel() { + mGameConcern.setEnabled(true); + } + }); } }); break; diff --git a/app/src/main/java/com/gh/gamecenter/info/ConcernFragment.java b/app/src/main/java/com/gh/gamecenter/info/ConcernFragment.java index eb4b3813a4..54db7a0388 100644 --- a/app/src/main/java/com/gh/gamecenter/info/ConcernFragment.java +++ b/app/src/main/java/com/gh/gamecenter/info/ConcernFragment.java @@ -461,22 +461,19 @@ public class ConcernFragment extends NormalFragment implements SwipeRefreshLayou @OnClick(R.id.news1_tv_concern) public void concern() { // 关注 推荐关注的游戏 - CheckLoginUtils.checkLogin(getContext(), new CheckLoginUtils.OnLoggenInListener() { - @Override - public void onLoggedIn() { - ArrayList list = new ArrayList<>(); - for (int key : concernMap.keySet()) { - if (concernMap.get(key)) { - list.add(recommendGameList.get(key)); - } + CheckLoginUtils.checkLogin(getContext(), () -> { + ArrayList list = new ArrayList<>(); + for (int key : concernMap.keySet()) { + if (concernMap.get(key)) { + list.add(recommendGameList.get(key)); } - // 同步关注 - JSONArray data = new JSONArray(); - for (GameEntity gameEntity : list) { - data.put(gameEntity.getId()); - } - ConcernUtils.INSTANCE.updateConcernData(getContext(), data); } + // 同步关注 + JSONArray data = new JSONArray(); + for (GameEntity gameEntity : list) { + data.put(gameEntity.getId()); + } + ConcernUtils.INSTANCE.updateConcernData(getContext(), data); }); } diff --git a/app/src/main/java/com/gh/gamecenter/message/MessageDetailFragment.java b/app/src/main/java/com/gh/gamecenter/message/MessageDetailFragment.java index 37198e0865..a0ecf18764 100644 --- a/app/src/main/java/com/gh/gamecenter/message/MessageDetailFragment.java +++ b/app/src/main/java/com/gh/gamecenter/message/MessageDetailFragment.java @@ -281,24 +281,21 @@ public class MessageDetailFragment extends NormalFragment implements OnCommentCa //软键盘控制 private void setSoftInput(boolean isShow) { if (isShow) { - CheckLoginUtils.checkLogin(getContext(), new CheckLoginUtils.OnLoggenInListener() { - @Override - public void onLoggedIn() { - Util_System_Keyboard.showSoftKeyboard(getContext(), mMessageDetailEt); - 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); + CheckLoginUtils.checkLogin(getContext(), () -> { + Util_System_Keyboard.showSoftKeyboard(getContext(), mMessageDetailEt); + 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(getString(R.string.comment_repty_hint, mCommentEntity.getUser().getName())); - } else { - mMessageDetailEt.setHint(getString(R.string.message_detail_comment_hint)); - } + if (mCommentEntity != null && mCommentEntity.getUser() != null) { + mMessageDetailEt.setHint(getString(R.string.comment_repty_hint, mCommentEntity.getUser().getName())); + } else { + mMessageDetailEt.setHint(getString(R.string.message_detail_comment_hint)); } }); } else { 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 80e04f8365..4bfb8a3ec9 100644 --- a/app/src/main/java/com/gh/gamecenter/newsdetail/NewsDetailAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/newsdetail/NewsDetailAdapter.java @@ -333,85 +333,82 @@ public class NewsDetailAdapter extends BaseRecyclerAdapter { @Override public void onClick(View v) { final TextView concern = ((TextView) v); - CheckLoginUtils.checkLogin(mContext, new CheckLoginUtils.OnLoggenInListener() { - @Override - public void onLoggedIn() { - String str = concern.getText().toString(); - viewHolder.gamedetailConcern.setEnabled(false); - if (mContext.getString(R.string.concern).equals(str)) { - // 添加关注 - ConcernUtils.INSTANCE.postConcernGameId(mContext, mGameEntity.getId() - , new ConcernUtils.onConcernListener() { - @Override - public void onSuccess() { - Map kv = new HashMap<>(); - kv.put("状态", mContext.getString(R.string.concern)); - DataUtils.onEvent(mContext, "游戏关注", mGameEntity.getName(), kv); + CheckLoginUtils.checkLogin(mContext, () -> { + String str = concern.getText().toString(); + viewHolder.gamedetailConcern.setEnabled(false); + if (mContext.getString(R.string.concern).equals(str)) { + // 添加关注 + ConcernUtils.INSTANCE.postConcernGameId(mContext, mGameEntity.getId() + , new ConcernUtils.onConcernListener() { + @Override + public void onSuccess() { + Map kv = new HashMap<>(); + kv.put("状态", mContext.getString(R.string.concern)); + DataUtils.onEvent(mContext, "游戏关注", mGameEntity.getName(), kv); - Map kv2 = new HashMap<>(); - kv2.put("点击", R.string.concern); - DataUtils.onEvent(mContext, "插件数据", mGameEntity.getName(), kv2); + Map kv2 = new HashMap<>(); + kv2.put("点击", R.string.concern); + DataUtils.onEvent(mContext, "插件数据", mGameEntity.getName(), kv2); - DataCollectionUtils.uploadConcern(mContext, mGameEntity.getName(), mGameEntity.getId(), mContext.getString(R.string.concern)); + DataCollectionUtils.uploadConcern(mContext, mGameEntity.getName(), mGameEntity.getId(), mContext.getString(R.string.concern)); - concern.setText(R.string.cancel_concern); - concern.setBackgroundResource(R.drawable.button_normal_border); - concern.setTextColor(ContextCompat.getColor(mContext, R.color.theme)); + concern.setText(R.string.cancel_concern); + concern.setBackgroundResource(R.drawable.button_normal_border); + concern.setTextColor(ContextCompat.getColor(mContext, R.color.theme)); - Utils.toast(mContext, R.string.concern_success); - viewHolder.gamedetailConcern.setEnabled(true); - } + Utils.toast(mContext, R.string.concern_success); + viewHolder.gamedetailConcern.setEnabled(true); + } - @Override - public void onError() { - Utils.toast(mContext, R.string.concern_failure); - viewHolder.gamedetailConcern.setEnabled(true); - } - }); - } else { - Map kv = new HashMap<>(); - kv.put("状态", mContext.getString(R.string.cancel_concern)); - DataUtils.onEvent(mContext, "游戏关注", mGameEntity.getName(), kv); + @Override + public void onError() { + Utils.toast(mContext, R.string.concern_failure); + viewHolder.gamedetailConcern.setEnabled(true); + } + }); + } else { + Map kv = new HashMap<>(); + kv.put("状态", mContext.getString(R.string.cancel_concern)); + DataUtils.onEvent(mContext, "游戏关注", mGameEntity.getName(), kv); - Map kv2 = new HashMap<>(); - kv2.put("点击", mContext.getString(R.string.cancel_concern)); - DataUtils.onEvent(mContext, "插件数据", mGameEntity.getName(), kv2); + Map kv2 = new HashMap<>(); + kv2.put("点击", mContext.getString(R.string.cancel_concern)); + DataUtils.onEvent(mContext, "插件数据", mGameEntity.getName(), kv2); - DialogUtils.showCancelDialog(mContext, new DialogUtils.ConfirmListener() { - @Override - public void onConfirm() { - //取消关注 - ConcernUtils.INSTANCE.deleteConcernData(mContext, mGameEntity.getId() - , new ConcernUtils.onConcernListener() { - @Override - public void onSuccess() { - Map kv = new HashMap<>(); - kv.put("状态", mContext.getString(R.string.cancel_concern)); - DataUtils.onEvent(mContext, "游戏关注", mGameEntity.getName(), kv); + DialogUtils.showCancelDialog(mContext, new DialogUtils.ConfirmListener() { + @Override + public void onConfirm() { + //取消关注 + ConcernUtils.INSTANCE.deleteConcernData(mContext, mGameEntity.getId() + , new ConcernUtils.onConcernListener() { + @Override + public void onSuccess() { + Map kv = new HashMap<>(); + kv.put("状态", mContext.getString(R.string.cancel_concern)); + DataUtils.onEvent(mContext, "游戏关注", mGameEntity.getName(), kv); - DataCollectionUtils.uploadConcern(mContext, - mGameEntity.getName(), mGameEntity.getId(), mContext.getString(R.string.cancel_concern)); + DataCollectionUtils.uploadConcern(mContext, + mGameEntity.getName(), mGameEntity.getId(), mContext.getString(R.string.cancel_concern)); - concern.setText(mContext.getString(R.string.concern)); - concern.setBackgroundResource(R.drawable.button_normal_style); - concern.setTextColor(Color.WHITE); - viewHolder.gamedetailConcern.setEnabled(true); - } + concern.setText(mContext.getString(R.string.concern)); + concern.setBackgroundResource(R.drawable.button_normal_style); + concern.setTextColor(Color.WHITE); + viewHolder.gamedetailConcern.setEnabled(true); + } - @Override - public void onError() { - Utils.toast(mContext, R.string.cancel_concern_failure); - viewHolder.gamedetailConcern.setEnabled(true); - } - }); - } - }, new DialogUtils.CancelListener() { - @Override - public void onCancel() { - viewHolder.gamedetailConcern.setEnabled(true); - } - }); - } + @Override + public void onError() { + Utils.toast(mContext, R.string.cancel_concern_failure); + viewHolder.gamedetailConcern.setEnabled(true); + } + }); + } + }, new DialogUtils.CancelListener() { + @Override + public void onCancel() { + viewHolder.gamedetailConcern.setEnabled(true); + } + }); } }); } diff --git a/app/src/main/java/com/halo/assistant/fragment/VoteFragment.java b/app/src/main/java/com/halo/assistant/fragment/VoteFragment.java index be84faba32..dc6beafed6 100644 --- a/app/src/main/java/com/halo/assistant/fragment/VoteFragment.java +++ b/app/src/main/java/com/halo/assistant/fragment/VoteFragment.java @@ -99,12 +99,7 @@ public class VoteFragment extends NormalFragment implements SwipeRefreshLayout.O mAddTv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - CheckLoginUtils.checkLogin(getContext(), new CheckLoginUtils.OnLoggenInListener() { - @Override - public void onLoggedIn() { - showAddVoteDialog(); - } - }); + CheckLoginUtils.checkLogin(getContext(), () -> showAddVoteDialog()); } }); @@ -131,11 +126,8 @@ public class VoteFragment extends NormalFragment implements SwipeRefreshLayout.O @Override public void loadDone(Object obj) { - CheckLoginUtils.checkLogin(getContext(), new CheckLoginUtils.OnLoggenInListener() { - @Override - public void onLoggedIn() { - postVersionVote((String) obj, false); // 投票 - } + CheckLoginUtils.checkLogin(getContext(), () -> { + postVersionVote((String) obj, false); // 投票 }); } @@ -329,11 +321,6 @@ public class VoteFragment extends NormalFragment implements SwipeRefreshLayout.O @Override public void addVote() { - CheckLoginUtils.checkLogin(getActivity(), new CheckLoginUtils.OnLoggenInListener() { - @Override - public void onLoggedIn() { - showAddVoteDialog(); - } - }); + CheckLoginUtils.checkLogin(getActivity(), () -> showAddVoteDialog()); } } diff --git a/app/src/main/java/com/halo/assistant/fragment/WebFragment.java b/app/src/main/java/com/halo/assistant/fragment/WebFragment.java index f5ed796543..e4d7a2abad 100644 --- a/app/src/main/java/com/halo/assistant/fragment/WebFragment.java +++ b/app/src/main/java/com/halo/assistant/fragment/WebFragment.java @@ -119,55 +119,52 @@ public class WebFragment extends NormalFragment implements OnBackPressedListener } break; case R.id.menu_collect: - CheckLoginUtils.checkLogin(getActivity(), new CheckLoginUtils.OnLoggenInListener() { - @Override - public void onLoggedIn() { - mMenuCollect.setEnabled(false); - if (mToolBoxEntity.getUserData() != null && mToolBoxEntity.getUserData().isToolkitFavorite()) { - CollectionUtils.INSTANCE.deleteCollection(getContext(), mToolBoxEntity.getId(), - CollectionUtils.CollectionType.toolkit, - new CollectionUtils.OnCollectionListener() { - @Override - public void onSuccess() { - mToolBoxEntity.getUserData().setToolkitFavorite(false); - mMenuCollect.setEnabled(true); - mMenuCollect.setIcon(R.drawable.menu_ic_collect_unselect); - toast(R.string.collection_cancel); - } + CheckLoginUtils.checkLogin(getActivity(), () -> { + mMenuCollect.setEnabled(false); + if (mToolBoxEntity.getUserData() != null && mToolBoxEntity.getUserData().isToolkitFavorite()) { + CollectionUtils.INSTANCE.deleteCollection(getContext(), mToolBoxEntity.getId(), + CollectionUtils.CollectionType.toolkit, + new CollectionUtils.OnCollectionListener() { + @Override + public void onSuccess() { + mToolBoxEntity.getUserData().setToolkitFavorite(false); + mMenuCollect.setEnabled(true); + mMenuCollect.setIcon(R.drawable.menu_ic_collect_unselect); + toast(R.string.collection_cancel); + } - @Override - public void onError() { - mMenuCollect.setEnabled(true); - toast(R.string.collection_cancel_failure); - } - }); + @Override + public void onError() { + mMenuCollect.setEnabled(true); + toast(R.string.collection_cancel_failure); + } + }); - } else { + } else { // Map map = new HashMap<>(); // map.put("_id", mToolBoxEntity.getId()); - CollectionUtils.INSTANCE.postCollection(getContext(), mToolBoxEntity.getId(), - CollectionUtils.CollectionType.toolkit, - new CollectionUtils.OnCollectionListener() { - @Override - public void onSuccess() { - UserDataEntity userData = mToolBoxEntity.getUserData(); - if (userData == null) { - userData = new UserDataEntity(); - mToolBoxEntity.setUserData(userData); - } - userData.setToolkitFavorite(true); - mMenuCollect.setEnabled(true); - mMenuCollect.setIcon(R.drawable.menu_ic_collect_select); - toast(R.string.collection_success); + CollectionUtils.INSTANCE.postCollection(getContext(), mToolBoxEntity.getId(), + CollectionUtils.CollectionType.toolkit, + new CollectionUtils.OnCollectionListener() { + @Override + public void onSuccess() { + UserDataEntity userData = mToolBoxEntity.getUserData(); + if (userData == null) { + userData = new UserDataEntity(); + mToolBoxEntity.setUserData(userData); } + userData.setToolkitFavorite(true); + mMenuCollect.setEnabled(true); + mMenuCollect.setIcon(R.drawable.menu_ic_collect_select); + toast(R.string.collection_success); + } - @Override - public void onError() { - mMenuCollect.setEnabled(true); - toast(R.string.collection_failure); - } - }); - } + @Override + public void onError() { + mMenuCollect.setEnabled(true); + toast(R.string.collection_failure); + } + }); } }); break; diff --git a/app/src/main/java/com/halo/assistant/fragment/comment/CommentDetailFragment.java b/app/src/main/java/com/halo/assistant/fragment/comment/CommentDetailFragment.java index 6f64033ca8..7e1ca0d457 100644 --- a/app/src/main/java/com/halo/assistant/fragment/comment/CommentDetailFragment.java +++ b/app/src/main/java/com/halo/assistant/fragment/comment/CommentDetailFragment.java @@ -232,21 +232,18 @@ public class CommentDetailFragment extends NormalFragment implements OnCommentCa //软键盘控制 private void setSoftInput(boolean isShow) { if (isShow) { - CheckLoginUtils.checkLogin(getContext(), new CheckLoginUtils.OnLoggenInListener() { - @Override - public void onLoggedIn() { - Util_System_Keyboard.showSoftKeyboard(getContext(), mCommentDetailCommentEt); - mCommentDetailCommentRl.setVisibility(View.VISIBLE); - mCommentDetailCommentEt.setFocusable(true); - mCommentDetailCommentEt.setFocusableInTouchMode(true); - mCommentDetailCommentEt.requestFocus(); - mCommentDetailCloseComment.setVisibility(View.VISIBLE); + CheckLoginUtils.checkLogin(getContext(), () -> { + Util_System_Keyboard.showSoftKeyboard(getContext(), mCommentDetailCommentEt); + mCommentDetailCommentRl.setVisibility(View.VISIBLE); + mCommentDetailCommentEt.setFocusable(true); + mCommentDetailCommentEt.setFocusableInTouchMode(true); + mCommentDetailCommentEt.requestFocus(); + mCommentDetailCloseComment.setVisibility(View.VISIBLE); - if (mCommentEntity != null && mCommentEntity.getUser() != null) { - mCommentDetailCommentEt.setHint(getString(R.string.comment_repty_hint, mCommentEntity.getUser().getName())); - } else { - mCommentDetailCommentEt.setHint(getString(R.string.message_detail_comment_hint)); - } + if (mCommentEntity != null && mCommentEntity.getUser() != null) { + mCommentDetailCommentEt.setHint(getString(R.string.comment_repty_hint, mCommentEntity.getUser().getName())); + } else { + mCommentDetailCommentEt.setHint(getString(R.string.message_detail_comment_hint)); } }); } else { diff --git a/app/src/main/java/com/halo/assistant/fragment/myconcern/MyConcernAdapter.java b/app/src/main/java/com/halo/assistant/fragment/myconcern/MyConcernAdapter.java index 4d2860bde2..76f05da05b 100644 --- a/app/src/main/java/com/halo/assistant/fragment/myconcern/MyConcernAdapter.java +++ b/app/src/main/java/com/halo/assistant/fragment/myconcern/MyConcernAdapter.java @@ -110,46 +110,43 @@ class MyConcernAdapter extends BaseRecyclerAdapter { public void onClick(View v) { holder.concern_item_concern.setClickable(false); holder.itemView.setClickable(false); - CheckLoginUtils.checkLogin(mContext, new CheckLoginUtils.OnLoggenInListener() { - @Override - public void onLoggedIn() { - holder.concern_item_concern.setClickable(false); - holder.itemView.setClickable(false); - // 删除关注表中的数据,并更新界面 - DialogUtils.showCancelDialog(mContext, new DialogUtils.ConfirmListener() { - @Override - public void onConfirm() { + CheckLoginUtils.checkLogin(mContext, () -> { + holder.concern_item_concern.setClickable(false); + holder.itemView.setClickable(false); + // 删除关注表中的数据,并更新界面 + DialogUtils.showCancelDialog(mContext, new DialogUtils.ConfirmListener() { + @Override + public void onConfirm() { - ConcernUtils.INSTANCE.deleteConcernData(mContext, gameEntity.getId(), new ConcernUtils.onConcernListener() { - @Override - public void onSuccess() { - // 更新界面->cancelConcern() + ConcernUtils.INSTANCE.deleteConcernData(mContext, gameEntity.getId(), new ConcernUtils.onConcernListener() { + @Override + public void onSuccess() { + // 更新界面->cancelConcern() - Map kv = new HashMap<>(); - kv.put("状态", R.string.cancel_concern); - DataUtils.onEvent(mContext, "游戏关注", gameEntity.getName(), kv); + Map kv = new HashMap<>(); + kv.put("状态", R.string.cancel_concern); + DataUtils.onEvent(mContext, "游戏关注", gameEntity.getName(), kv); - DataCollectionUtils.uploadConcern(mContext, - gameEntity.getName(), gameEntity.getId(), mContext.getString(R.string.cancel_concern)); + DataCollectionUtils.uploadConcern(mContext, + gameEntity.getName(), gameEntity.getId(), mContext.getString(R.string.cancel_concern)); - } + } - @Override - public void onError() { - Utils.toast(mContext, R.string.concern_cancel_failure); - holder.concern_item_concern.setClickable(true); - holder.itemView.setClickable(true); - } - }); - } - }, new DialogUtils.CancelListener() { - @Override - public void onCancel() { - holder.concern_item_concern.setClickable(true); - holder.itemView.setClickable(true); - } - }); - } + @Override + public void onError() { + Utils.toast(mContext, R.string.concern_cancel_failure); + holder.concern_item_concern.setClickable(true); + holder.itemView.setClickable(true); + } + }); + } + }, new DialogUtils.CancelListener() { + @Override + public void onCancel() { + holder.concern_item_concern.setClickable(true); + holder.itemView.setClickable(true); + } + }); }); } }); diff --git a/app/src/main/java/com/halo/assistant/fragment/myconcern/MyConcernRecommendAdapter.java b/app/src/main/java/com/halo/assistant/fragment/myconcern/MyConcernRecommendAdapter.java index 4a481f7a05..62cce3bf1c 100644 --- a/app/src/main/java/com/halo/assistant/fragment/myconcern/MyConcernRecommendAdapter.java +++ b/app/src/main/java/com/halo/assistant/fragment/myconcern/MyConcernRecommendAdapter.java @@ -156,39 +156,36 @@ class MyConcernRecommendAdapter extends BaseRecyclerAdapter { @Override public void onClick(View v) { - CheckLoginUtils.checkLogin(mContext, new CheckLoginUtils.OnLoggenInListener() { - @Override - public void onLoggedIn() { - holder.concern_item_concern.setClickable(false); - holder.itemView.setClickable(false); - ConcernUtils.INSTANCE.postConcernGameId(mContext, gameEntity.getId(), new ConcernUtils.onConcernListener() { - @Override - public void onSuccess() { - // 更新界面->concernGame() + CheckLoginUtils.checkLogin(mContext, () -> { + holder.concern_item_concern.setClickable(false); + holder.itemView.setClickable(false); + ConcernUtils.INSTANCE.postConcernGameId(mContext, gameEntity.getId(), new ConcernUtils.onConcernListener() { + @Override + public void onSuccess() { + // 更新界面->concernGame() - Map kv = new HashMap<>(); - kv.put("状态", R.string.concern); - DataUtils.onEvent(mContext, "游戏关注", gameEntity.getName(), kv); + Map kv = new HashMap<>(); + kv.put("状态", R.string.concern); + DataUtils.onEvent(mContext, "游戏关注", gameEntity.getName(), kv); - DataCollectionUtils.uploadConcern(mContext, - gameEntity.getName(), gameEntity.getId(), mContext.getString(R.string.concern)); + DataCollectionUtils.uploadConcern(mContext, + gameEntity.getName(), gameEntity.getId(), mContext.getString(R.string.concern)); - if (mToast != null) { - mToast.cancel(); - } - mToast = Toast.makeText(mContext, R.string.concern_success, Toast.LENGTH_SHORT); - mToast.show(); + if (mToast != null) { + mToast.cancel(); } + mToast = Toast.makeText(mContext, R.string.concern_success, Toast.LENGTH_SHORT); + mToast.show(); + } - @Override - public void onError() { - Utils.toast(mContext, R.string.concern_failure); - holder.concern_item_concern.setClickable(true); - holder.itemView.setClickable(true); - } - }); + @Override + public void onError() { + Utils.toast(mContext, R.string.concern_failure); + holder.concern_item_concern.setClickable(true); + holder.itemView.setClickable(true); + } + }); - } }); } });