diff --git a/app/src/main/assets/rich_editor.js b/app/src/main/assets/rich_editor.js
index 06c3b1e7d4..574dfb6a5c 100644
--- a/app/src/main/assets/rich_editor.js
+++ b/app/src/main/assets/rich_editor.js
@@ -193,7 +193,7 @@ RE.setBlockquote = function() {
}
RE.insertImage = function(url) {
- var html = "

"
+ var html = "
"
RE.insertHTML(html);
}
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 b93aa3bba3..1d6ae56d5d 100644
--- a/app/src/main/java/com/gh/common/util/CommentUtils.java
+++ b/app/src/main/java/com/gh/common/util/CommentUtils.java
@@ -70,7 +70,7 @@ public class CommentUtils {
}
}
- public static void showReportDialog(final CommentEntity commentEntity, final Context context,
+ public static void showReportDialog(final CommentEntity commentEntity, final Context context, final boolean showConversation,
final OnCommentCallBackListener listener, final String newsId) {
final Dialog dialog = new Dialog(context);
@@ -89,7 +89,7 @@ public class CommentUtils {
dialogType.add("复制");
dialogType.add("举报");
- if (commentEntity.getParent() != null) {
+ if (commentEntity.getParent() != null && showConversation) {
dialogType.add("查看对话");
}
diff --git a/app/src/main/java/com/gh/common/util/EntranceUtils.java b/app/src/main/java/com/gh/common/util/EntranceUtils.java
index 5b02b61ebf..75652a4ee7 100644
--- a/app/src/main/java/com/gh/common/util/EntranceUtils.java
+++ b/app/src/main/java/com/gh/common/util/EntranceUtils.java
@@ -69,6 +69,7 @@ public class EntranceUtils {
public static final String KEY_MESSAGE_TYPE = "messageType";
public static final String KEY_QUESTIONS_SEARCH_KEY = "questionsSearchKey";
public static final String KEY_SHOW_ANSWER_COMMENT = "showAnswerComment";
+ public static final String KEY_VERSION_UPDATE = "versionUpdate";
public static void jumpActivity(Context context, Bundle bundle) {
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 ea775c2d5a..46d9816255 100644
--- a/app/src/main/java/com/gh/common/util/LoginUtils.java
+++ b/app/src/main/java/com/gh/common/util/LoginUtils.java
@@ -2,6 +2,7 @@ package com.gh.common.util;
import android.content.Context;
+import com.gh.gamecenter.R;
import com.gh.gamecenter.retrofit.JSONObjectResponse;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
@@ -142,58 +143,94 @@ public class LoginUtils {
});
}
- public static void outputErrorHint(Context context, int code) {
+ public static boolean userPostErrorToast(Throwable throwable, Context context) {
+ if (throwable instanceof HttpException) {
+ HttpException exception = (HttpException) throwable;
+ if (exception.code() == 403) {
+ try {
+ JSONObject errorJson = new JSONObject(exception.response().errorBody().string());
+ String detail = errorJson.getString("detail");
+ switch (detail) {
+ case "too frequent":
+ Utils.toast(context, R.string.comment_failed_toofrequent);
+ break;
+ case "user blocked":
+ Utils.toast(context, R.string.comment_failed_userblocked);
+ break;
+ case "user banned":
+ Utils.toast(context, R.string.comment_failed_userbanned);
+ break;
+ case "article blocked":
+ Utils.toast(context, R.string.comment_failed_articleblocked);
+ break;
+ case "illegal":
+ Utils.toast(context, R.string.comment_failed_illegal);
+ break;
+ default:
+ Utils.toast(context, R.string.comment_failed_unknown);
+ break;
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ Utils.toast(context, "无法识别错误类型");
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+ public static void outputErrorHint(Context context, int code) {
switch (code) {
case 40000:
Utils.toast(context, "参数不全");
break;
- case 40001:
+ case 400001:
Utils.toast(context, "验证码获取过快,请稍后重试");// 已经发送过短信
break;
- case 40002:
+ case 400002:
Utils.toast(context, "请求第三方开放平台时发生错误");
break;
- case 40003:
+ case 400003:
Utils.toast(context, "上传用户头像时发生错误");
break;
- case 40101:
+ case 400101:
Utils.toast(context, "缺少参数 app_id");
break;
- case 40102:
+ case 400102:
Utils.toast(context, "缺少签名验证的头信息");
break;
- case 40104:
+ case 400104:
Utils.toast(context, "缺少token");
break;
- case 40105:
+ case 400105:
Utils.toast(context, "缺少手机号码");
break;
- case 40106:
+ case 400106:
Utils.toast(context, "缺少用户名");
break;
- case 40107:
+ case 400107:
Utils.toast(context, "缺少密码参数");
break;
- case 40202:
+ case 400202:
Utils.toast(context, "无效的手机号码");
break;
- case 40203:
+ case 400203:
Utils.toast(context, "无效的用户名");
break;
- case 40204:
+ case 400204:
Utils.toast(context, "无效的头像地址");
break;
- case 40205:
+ case 400205:
Utils.toast(context, "无效的性别参数");
break;
- case 40206:
+ case 400206:
Utils.toast(context, "无效的地区参数");
break;
- case 40208:
+ case 400208:
Utils.toast(context, "无效的密码");
break;
- case 40209:
+ case 400209:
Utils.toast(context, "无效的URL 地址");
break;
case 42000:
@@ -211,61 +248,61 @@ public class LoginUtils {
case 42004:
Utils.toast(context, "无效的请求");
break;
- case 40301:
+ case 400301:
Utils.toast(context, "签名验证失败");
break;
- case 40302:
+ case 400302:
Utils.toast(context, "验证码错误");
break;
- case 40303:
+ case 400303:
Utils.toast(context, "密码错误");
break;
- case 40304:
+ case 400304:
Utils.toast(context, "不支持该种方式登录");
break;
- case 40305:
+ case 400305:
Utils.toast(context, "错误的状态值(应用只有两种状态: working / stop)");
break;
- case 40306:
+ case 400306:
Utils.toast(context, "传递了无法识别的参数");
break;
- case 40401:
+ case 400401:
Utils.toast(context, "token过期");
break;
- case 40402:
+ case 400402:
Utils.toast(context, "Service_id过期,主要原因是:收到手机短信验证码后长时间没有进行登录操作");
break;
- case 40403:
+ case 400403:
Utils.toast(context, "验证码已过期");
break;
- case 40501:
+ case 400501:
Utils.toast(context, "同名应用已经存在");
break;
- case 40502:
- Utils.toast(context, "用户名已存在");
+ case 400502:
+ Utils.toast(context, "昵称已存在");
break;
- case 40503:
+ case 400503:
Utils.toast(context, "名称已经存在");
break;
- case 40601:
+ case 400601:
Utils.toast(context, "应用不存在");
break;
- case 40602:
+ case 400602:
Utils.toast(context, "用户不存在");
break;
- case 40603:
+ case 400603:
Utils.toast(context, "用户系统不存在");
break;
- case 40604:
+ case 400604:
Utils.toast(context, "用户已被冻结");
break;
- case 40605:
+ case 400605:
Utils.toast(context, "用户没有冻结");
break;
- case 40606:
+ case 400606:
Utils.toast(context, "该应用被停止运行了");
break;
- case 40801:
+ case 400801:
Utils.toast(context, "访问过于频繁");
break;
case 403001:
@@ -277,8 +314,14 @@ public class LoginUtils {
case 400213:
Utils.toast(context, "昵称违规");
break;
+ case 403801:
+ Utils.toast(context, "获取验证码已超过次数,请稍后再试");
+ break;
+ case 403204:
+ Utils.toast(context, "获取验证码已超过次数,请稍后再试");
+ break;
default:
- Utils.toast(context, "未知错误");
+ Utils.toast(context, code + "");
break;
}
diff --git a/app/src/main/java/com/gh/common/view/EditorView.java b/app/src/main/java/com/gh/common/view/EditorView.java
deleted file mode 100644
index c2c8091f8c..0000000000
--- a/app/src/main/java/com/gh/common/view/EditorView.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package com.gh.common.view;
-
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.text.Editable;
-import android.text.Spannable;
-import android.text.SpannableString;
-import android.text.style.ImageSpan;
-import android.util.AttributeSet;
-
-import java.io.FileOutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Created by khy on 14/12/17.
- */
-
-public class EditorView extends android.support.v7.widget.AppCompatEditText {
-
- int mEditorWidth;
-
- List mImgArr = new ArrayList<>();
-
- public EditorView(Context context) {
- super(context);
- }
-
- public EditorView(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public EditorView(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, defStyleAttr);
- }
-
- private void insertPicToEt(String picturePath) {
- Bitmap bitmap = compressPicture(picturePath);
- if (bitmap == null) return;
- mImgArr.add(picturePath);
-
- ImageSpan imageSpan = new ImageSpan(getContext(), bitmap);
- int index = getSelectionStart();
- String tempUrl = "
";
- SpannableString spannableString = new SpannableString(tempUrl);
- spannableString.setSpan(imageSpan, 0, tempUrl.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
- Editable editableText = getEditableText();
- if (index < 0 || index >= editableText.length()) {
- editableText.append(spannableString);
- } else {
- editableText.insert(index, spannableString);
- }
- if (bitmap.getWidth() >= mEditorWidth)
- editableText.insert(index + spannableString.length(), "\n");
- }
-
- /**
- * 压缩图片
- * 规则:
- * 1.如果图片大于当前EditText的最大宽度则按比例缩放,使图片宽度和EditText的宽度保持一致 (高度不处理)
- * 2.如果图片小于当前EditText 由于比例限制 将不处理
- *
- * @param srcPath 图片路径
- * @return
- */
- public Bitmap compressPicture(String srcPath) {
-
- FileOutputStream fos = null;
- BitmapFactory.Options op = new BitmapFactory.Options();
-
- // 开始读入图片,此时把options.inJustDecodeBounds 设回true了
- op.inJustDecodeBounds = true;
- Bitmap bitmap = BitmapFactory.decodeFile(srcPath, op);
- op.inJustDecodeBounds = false;
-
- // 缩放图片的尺寸
- float w = op.outWidth;
- float h = op.outHeight;
- float index = w / h;
- int width = mEditorWidth;
- float hh = width / index;
- float ww = width;
-
- float be = 1.0f;
- if (w > h && w > ww / 2) {
- be = w / ww;
- } else if (w < h && h > hh/2) {
- be = h / hh;
- }
- if (be <= 0) {
- be = 1.0f;
- }
- op.inSampleSize = (int) be;// 设置缩放比例,这个数字越大,图片大小越小.
- // 重新读入图片,注意此时已经把options.inJustDecodeBounds 设回false了
- bitmap = BitmapFactory.decodeFile(srcPath, op);
- int desWidth = (int) (w / be);
- int desHeight = (int) (h / be);
- return Bitmap.createScaledBitmap(bitmap, desWidth, desHeight, true);
-
- }
-
- public List getImgArr() {
- return mImgArr;
- }
-}
diff --git a/app/src/main/java/com/gh/gamecenter/NewsDetailActivity.java b/app/src/main/java/com/gh/gamecenter/NewsDetailActivity.java
index 429a7eee73..2d18fc2643 100644
--- a/app/src/main/java/com/gh/gamecenter/NewsDetailActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/NewsDetailActivity.java
@@ -46,7 +46,6 @@ import com.gh.gamecenter.eventbus.EBPackage;
import com.gh.gamecenter.newsdetail.NewsDetailAdapter;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
-import com.google.gson.Gson;
import com.jakewharton.rxbinding.view.RxView;
import com.lightgame.download.DataWatcher;
import com.lightgame.download.DownloadEntity;
@@ -445,17 +444,17 @@ public class NewsDetailActivity extends BaseActivity implements OnClickListener,
@Override
public void onResponse(NewsEntity response) {
if (mIsCollectionNews && mNewsEntity != null && response != null) { // 对比查看收藏文章是否修改
- Gson gson = new Gson();
+// Gson gson = new Gson();
- String newEntity = gson.toJson(response.getThumbnail());
- String entity = gson.toJson(mNewsEntity.getThumbnail());
- if (!newEntity.equals(entity) || !response.getType().equals(mNewsEntity.getType())
- || !response.getTitle().equals(mNewsEntity.getTitle())) {
- CollectionUtils.INSTANCE.patchCollection(NewsDetailActivity.this, response.getId(), CollectionUtils.CollectionType.article);
- } else {
- Utils.log("========相同");
- }
+// String newEntity = gson.toJson(response.getThumbnail());
+// String entity = gson.toJson(mNewsEntity.getThumbnail());
+// if (!newEntity.equals(entity) || !response.getType().equals(mNewsEntity.getType())
+// || !response.getTitle().equals(mNewsEntity.getTitle())) {
+// CollectionUtils.INSTANCE.patchCollection(NewsDetailActivity.this, response.getId(), CollectionUtils.CollectionType.article);
+// } else {
+// Utils.log("========相同");
+// }
return;
}
diff --git a/app/src/main/java/com/gh/gamecenter/SettingActivity.java b/app/src/main/java/com/gh/gamecenter/SettingActivity.java
index b4de920d0d..5536ca7015 100644
--- a/app/src/main/java/com/gh/gamecenter/SettingActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/SettingActivity.java
@@ -18,7 +18,7 @@ import com.halo.assistant.fragment.SettingsFragment;
public class SettingActivity extends NormalActivity {
@NonNull
- public static Intent getIntent(Context context, String entrance) {
+ public static Intent getIntent(Context context, boolean isUpdate, String entrance) {
// Intent intent = new Intent(context, SettingActivity.class);
// intent.putExtra(EntranceUtils.KEY_ENTRANCE, entrance);
// return intent;
@@ -28,7 +28,8 @@ public class SettingActivity extends NormalActivity {
// .setFragment(SettingsFragment.class).build();
Bundle args = new Bundle();
args.putString(EntranceUtils.KEY_ENTRANCE, entrance);
- return getIntent(context, SettingsFragment.class);
+ args.putBoolean(EntranceUtils.KEY_VERSION_UPDATE, isUpdate);
+ return getIntent(context, SettingsFragment.class, args);
}
}
diff --git a/app/src/main/java/com/gh/gamecenter/SplashScreenActivity.java b/app/src/main/java/com/gh/gamecenter/SplashScreenActivity.java
index d399b6435d..5d10c4d1ff 100644
--- a/app/src/main/java/com/gh/gamecenter/SplashScreenActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/SplashScreenActivity.java
@@ -19,7 +19,6 @@ import android.widget.ImageView;
import android.widget.TextView;
import com.gh.base.BaseActivity;
-import com.gh.base.fragment.BaseFragment_ViewPager;
import com.gh.common.util.DialogUtils;
import com.gh.common.util.PackageUtils;
import com.gh.common.util.PlatformUtils;
@@ -27,7 +26,6 @@ import com.gh.common.util.TagUtils;
import com.gh.common.util.TimestampUtils;
import com.gh.common.util.TokenUtils;
import com.gh.download.DownloadManager;
-import com.gh.gamecenter.fragment.MainWrapperFragment;
import com.gh.gamecenter.manager.FilterManager;
import com.lightgame.download.FileUtils;
import com.lightgame.utils.AppManager;
@@ -157,10 +155,6 @@ public class SplashScreenActivity extends BaseActivity {
private void launch() {
Bundle bundle = getIntent().getExtras();
Intent intent = new Intent(SplashScreenActivity.this, MainActivity.class);
- if (isNewFirstLaunch) {
- if (bundle == null) bundle = new Bundle();
- intent.putExtra(BaseFragment_ViewPager.ARGS_INDEX, MainWrapperFragment.INDEX_ASK);
- }
if (bundle != null) intent.putExtras(bundle);
startActivity(intent);
finish();
diff --git a/app/src/main/java/com/gh/gamecenter/ToolBoxActivity.java b/app/src/main/java/com/gh/gamecenter/ToolBoxActivity.java
index 902e4f7d39..4ea5cd5607 100644
--- a/app/src/main/java/com/gh/gamecenter/ToolBoxActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/ToolBoxActivity.java
@@ -93,7 +93,7 @@ public class ToolBoxActivity extends BaseActivity implements SwipeRefreshLayout.
if (newState == RecyclerView.SCROLL_STATE_IDLE
&& mLayoutManager.findLastVisibleItemPosition() + 1 == mRvAdapter.getItemCount()) {
if (!mRvAdapter.isOver() && !mRvAdapter.isLoading() && !mRvAdapter.isNetworkError()) {
- mRvAdapter.loadData(mIsSearch);
+ mRvAdapter.loadData();
}
}
}
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 6b81f6acea..edc389ac3a 100644
--- a/app/src/main/java/com/gh/gamecenter/adapter/CommentDetailAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/adapter/CommentDetailAdapter.java
@@ -164,7 +164,7 @@ public class CommentDetailAdapter extends BaseRecyclerAdapter {
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- CommentUtils.showReportDialog(commentEntity, mContext, mOnCommentCallBackListener, null);
+ CommentUtils.showReportDialog(commentEntity, mContext, false, mOnCommentCallBackListener, 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 f93ff22c54..f92d397ad7 100644
--- a/app/src/main/java/com/gh/gamecenter/adapter/MessageDetailAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/adapter/MessageDetailAdapter.java
@@ -416,7 +416,7 @@ public class MessageDetailAdapter extends BaseRecyclerAdapter {
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- CommentUtils.showReportDialog(finalCommentEntity, mContext, mOnCommentCallBackListener, null);
+ CommentUtils.showReportDialog(finalCommentEntity, mContext, true, mOnCommentCallBackListener, null);
}
});
}
diff --git a/app/src/main/java/com/gh/gamecenter/adapter/ToolBoxRvAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/ToolBoxRvAdapter.java
index 435841596f..a072586d20 100644
--- a/app/src/main/java/com/gh/gamecenter/adapter/ToolBoxRvAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/adapter/ToolBoxRvAdapter.java
@@ -52,13 +52,11 @@ public class ToolBoxRvAdapter extends BaseRecyclerAdapter {
private String mSearchKey;
private String mToken;
- private boolean mLoadConcernDataOver;
+ // private boolean mLoadConcernDataOver;
private boolean mIsSearch;
private boolean mIsLoading;
private boolean mIsOver;
private boolean mIsNetworkError;
-
- private int mConcernPage;
private int mPage;
public ToolBoxRvAdapter(Context context, OnRequestCallBackListener listener, OnSearchCallBackListener searchListener,
@@ -66,35 +64,22 @@ public class ToolBoxRvAdapter extends BaseRecyclerAdapter {
super(context);
this.mIsSearch = isSearch;
this.mSearchKey = key;
- mConcernPage = 1;
mPage = 1;
mToken = UserManager.getInstance().getToken();
mSearchListener = searchListener;
mCallBackListener = listener;
mEntityList = new ArrayList<>();
- loadData(mIsSearch);
+ loadData();
}
- public void loadData(boolean isSearch) {
- int normalPage;
+ public void loadData() {
if (mIsLoading) {
return;
}
mIsLoading = true;
-
- if (!isSearch && mLoadConcernDataOver) {
- normalPage = mPage;
- } else {
- normalPage = mConcernPage;
- }
-
Observable> api;
- if (!TextUtils.isEmpty(mToken) && !mLoadConcernDataOver) {
- api = RetrofitManager.getInstance(mContext).getApi().getConcernToolKitData(UserManager.getInstance().getUserId(), normalPage, mSearchKey);
- } else {
- api = RetrofitManager.getInstance(mContext).getApi().getToolKitData(normalPage, mSearchKey);
- }
+ api = RetrofitManager.getInstance(mContext).getApi().getToolKitData(mPage, mSearchKey);
api
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
@@ -102,32 +87,22 @@ public class ToolBoxRvAdapter extends BaseRecyclerAdapter {
@Override
public void onResponse(List response) {
super.onResponse(response);
- if (!mLoadConcernDataOver && response.size() < 20) {
+ if (response.size() > 0) {
mEntityList.addAll(response);
- mLoadConcernDataOver = true;
- mIsLoading = false;
- mConcernPage++;
- loadData(mIsSearch);
- } else {
- if (response.size() >= 0) {
- removeDuplicateData(mEntityList, response);
- if (response.size() > 0) {
- mEntityList.addAll(response);
- }
- mCallBackListener.loadDone();
+ }
+ mCallBackListener.loadDone();
- if (response.size() < 20) {
- mIsOver = true;
- }
+ if (response.size() < 20) {
+ mIsOver = true;
+ }
- notifyDataSetChanged();
- }
- mPage++;
- mIsLoading = false;
+ notifyDataSetChanged();
- if (mEntityList.size() == 0) {
- mCallBackListener.loadEmpty();
- }
+ mPage++;
+ mIsLoading = false;
+
+ if (mEntityList.size() == 0) {
+ mCallBackListener.loadEmpty();
}
}
@@ -295,7 +270,7 @@ public class ToolBoxRvAdapter extends BaseRecyclerAdapter {
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- loadData(mIsSearch);
+ loadData();
}
});
} else if (mIsOver) {
diff --git a/app/src/main/java/com/gh/gamecenter/ask/AnswerCommentFragment.java b/app/src/main/java/com/gh/gamecenter/ask/AnswerCommentFragment.java
index b8b9743735..20a937b563 100644
--- a/app/src/main/java/com/gh/gamecenter/ask/AnswerCommentFragment.java
+++ b/app/src/main/java/com/gh/gamecenter/ask/AnswerCommentFragment.java
@@ -86,7 +86,7 @@ public class AnswerCommentFragment extends ListFragment {
}
public void setSubjectEntity(List subjectEntity) {
- mSubjectEntity = subjectEntity;
+ mSubjectEntity = new ArrayList<>(subjectEntity);
notifyDataSetChanged();
}
@@ -114,7 +114,8 @@ public class AskQuestionsRecommendsAdapter extends ListAdapter {
}
break;
case ItemViewType.ITEM_BODY:
- int index = mSubjectEntity == null ? position : position - TOP_ITEM_COUNT;
+ int index = mSubjectEntity == null || mSubjectEntity.isEmpty() ? position : position - TOP_ITEM_COUNT;
+ if (index == -1) index = 0;
((AskQuestionsRecommendsViewHolder) holder).initQuestionsHotViewHolder(mEntityList.get(index));
break;
case ItemViewType.ITEM_FOOTER:
diff --git a/app/src/main/java/com/gh/gamecenter/ask/AskQuestionsRecommendsViewModel.java b/app/src/main/java/com/gh/gamecenter/ask/AskQuestionsRecommendsViewModel.java
index 924f71a7a5..35dd593b54 100644
--- a/app/src/main/java/com/gh/gamecenter/ask/AskQuestionsRecommendsViewModel.java
+++ b/app/src/main/java/com/gh/gamecenter/ask/AskQuestionsRecommendsViewModel.java
@@ -63,6 +63,7 @@ public class AskQuestionsRecommendsViewModel extends ListViewModel {
- List mEntityList = (List) data;
- if (position < mEntityList.size()) {
- AskGameSelectEntity askGameSelectEntity = mEntityList.get(position);
- MeEntity me = askGameSelectEntity.getMe();
- if (me == null || !me.isCommunityVoted())
- vote(askGameSelectEntity.getId());
- }
+ AskGameSelectEntity askGameSelectEntity = (AskGameSelectEntity) data;
+ MeEntity me = askGameSelectEntity.getMe();
+ if (me == null || !me.isCommunityVoted())
+ vote(askGameSelectEntity.getId());
+
});
break;
diff --git a/app/src/main/java/com/gh/gamecenter/ask/myask/MyDraftAdapter.java b/app/src/main/java/com/gh/gamecenter/ask/myask/MyDraftAdapter.java
index cb12d0ec33..310873e7c2 100644
--- a/app/src/main/java/com/gh/gamecenter/ask/myask/MyDraftAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/ask/myask/MyDraftAdapter.java
@@ -2,6 +2,7 @@ package com.gh.gamecenter.ask.myask;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
+import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
@@ -20,10 +21,17 @@ import com.gh.gamecenter.baselist.ListAdapter;
class MyDraftAdapter extends ListAdapter {
private OnListClickListener mListClickListener;
+ private OnItemLongClickListener mLongClickListener;
- MyDraftAdapter(Context context, OnListClickListener listClickListener) {
+ MyDraftAdapter(Context context, OnListClickListener listClickListener, OnItemLongClickListener longClickListener) {
super(context);
mListClickListener = listClickListener;
+ mLongClickListener = longClickListener;
+ }
+
+ @Override
+ protected boolean areItemsTheSame(AnswerEntity oldItem, AnswerEntity newItem) {
+ return !TextUtils.isEmpty(oldItem.getId()) && oldItem.getId().equals(newItem.getId());
}
@Override
@@ -51,7 +59,12 @@ class MyDraftAdapter extends ListAdapter {
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
switch (getItemViewType(position)) {
case ItemViewType.ITEM_BODY:
- ((AnswerViewHolder) holder).initMyDraftViewHolder(mEntityList.get(position));
+ AnswerEntity answerEntity = mEntityList.get(position);
+ ((AnswerViewHolder) holder).initMyDraftViewHolder(answerEntity);
+ holder.itemView.setOnLongClickListener(v -> {
+ mLongClickListener.onLongClick(answerEntity);
+ return false;
+ });
break;
case ItemViewType.ITEM_FOOTER:
FooterViewHolder footerViewHolder = (FooterViewHolder) holder;
@@ -70,4 +83,8 @@ class MyDraftAdapter extends ListAdapter {
mEntityList.remove(draftPosition);
notifyDataSetChanged();
}
+
+ interface OnItemLongClickListener {
+ void onLongClick(AnswerEntity entity);
+ }
}
diff --git a/app/src/main/java/com/gh/gamecenter/ask/myask/MyDraftFragment.java b/app/src/main/java/com/gh/gamecenter/ask/myask/MyDraftFragment.java
index fbfcc4a18c..1c40122e86 100644
--- a/app/src/main/java/com/gh/gamecenter/ask/myask/MyDraftFragment.java
+++ b/app/src/main/java/com/gh/gamecenter/ask/myask/MyDraftFragment.java
@@ -6,6 +6,7 @@ import android.os.Bundle;
import android.view.View;
import com.gh.common.util.AskLogUtils;
+import com.gh.common.util.DialogUtils;
import com.gh.common.util.EntranceUtils;
import com.gh.gamecenter.NormalActivity;
import com.gh.gamecenter.R;
@@ -18,17 +19,22 @@ import com.gh.gamecenter.baselist.ListFragment;
import com.gh.gamecenter.baselist.LoadType;
import com.gh.gamecenter.baselist.NormalListViewModel;
import com.gh.gamecenter.manager.UserManager;
+import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
import java.util.List;
+import okhttp3.ResponseBody;
+import retrofit2.HttpException;
import rx.Observable;
+import rx.android.schedulers.AndroidSchedulers;
+import rx.schedulers.Schedulers;
/**
* Created by khy on 20/12/17.
*/
-public class MyDraftFragment extends ListFragment {
+public class MyDraftFragment extends ListFragment implements MyDraftAdapter.OnItemLongClickListener {
private static final int ANSWER_DRAFT_REQUEST = 101;
@@ -60,7 +66,7 @@ public class MyDraftFragment extends ListFragment deleteAnswerDraft(entity), null);
+ }
+
+ void deleteAnswerDraft(AnswerEntity entity) {
+ RetrofitManager.getInstance(getContext()).getApi()
+ .deleteAnswerDrafts(UserManager.getInstance().getUserId(), entity.getId())
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(new Response() {
+ @Override
+ public void onResponse(ResponseBody response) {
+ mListViewModel.load(LoadType.REFRESH);
+ }
+
+ @Override
+ public void onFailure(HttpException e) {
+ toast(R.string.loading_network_error);
+ }
+ });
+ }
}
diff --git a/app/src/main/java/com/gh/gamecenter/ask/questionsdetail/AnswerEditFragment.java b/app/src/main/java/com/gh/gamecenter/ask/questionsdetail/AnswerEditFragment.java
index 440bb8735e..1bb9a928a6 100644
--- a/app/src/main/java/com/gh/gamecenter/ask/questionsdetail/AnswerEditFragment.java
+++ b/app/src/main/java/com/gh/gamecenter/ask/questionsdetail/AnswerEditFragment.java
@@ -23,7 +23,7 @@ import com.gh.common.util.CheckLoginUtils;
import com.gh.common.util.DialogUtils;
import com.gh.common.util.EntranceUtils;
import com.gh.common.util.ImageUtils;
-import com.gh.common.util.UrlFilterUtils;
+import com.gh.common.util.LoginUtils;
import com.gh.common.view.RichEditor;
import com.gh.gamecenter.R;
import com.gh.gamecenter.manager.UserManager;
@@ -297,6 +297,7 @@ public class AnswerEditFragment extends NormalFragment {
public void onFailure(HttpException e) {
super.onFailure(e);
if (postDialog != null) postDialog.dismissAllowingStateLoss();
+ if (LoginUtils.userPostErrorToast(e, getContext())) return;
toast("提交失败");
AskErrorResponseUtils.errorResponseControl(getContext(), e);
}
@@ -394,8 +395,7 @@ public class AnswerEditFragment extends NormalFragment {
private void getUserAnswerDrafts() {
RetrofitManager.getInstance(getContext()).getApi()
- .getUserAnswerDrafts(UserManager.getInstance().getUserId()
- , UrlFilterUtils.getFilterQuery("question_id", mQuestionsId), Utils.getTime(getContext()))
+ .getUserAnswerDrafts(mQuestionsId, Utils.getTime(getContext()))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response() {
diff --git a/app/src/main/java/com/gh/gamecenter/ask/questionsdetail/QuestionsDetailAdapter.java b/app/src/main/java/com/gh/gamecenter/ask/questionsdetail/QuestionsDetailAdapter.java
index 3a80743048..be7c99b60e 100644
--- a/app/src/main/java/com/gh/gamecenter/ask/questionsdetail/QuestionsDetailAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/ask/questionsdetail/QuestionsDetailAdapter.java
@@ -88,7 +88,7 @@ public class QuestionsDetailAdapter extends ListAdapter {
mIsNetworkError = false;
mIsOver = false;
case REFRESH:
- if (mEntityList != null)mEntityList.clear();
+ if (mEntityList != null) mEntityList.clear();
break;
}
diff --git a/app/src/main/java/com/gh/gamecenter/ask/questionsdetail/QuestionsDetailFragment.java b/app/src/main/java/com/gh/gamecenter/ask/questionsdetail/QuestionsDetailFragment.java
index bde0f12813..18a0eed278 100644
--- a/app/src/main/java/com/gh/gamecenter/ask/questionsdetail/QuestionsDetailFragment.java
+++ b/app/src/main/java/com/gh/gamecenter/ask/questionsdetail/QuestionsDetailFragment.java
@@ -25,7 +25,6 @@ import com.gh.common.util.ConcernUtils;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.EntranceUtils;
import com.gh.common.util.ShareUtils;
-import com.gh.common.util.UrlFilterUtils;
import com.gh.common.view.VerticalItemDecoration;
import com.gh.gamecenter.NormalActivity;
import com.gh.gamecenter.R;
@@ -41,7 +40,6 @@ import com.gh.gamecenter.baselist.ListFragment;
import com.gh.gamecenter.baselist.LoadStatus;
import com.gh.gamecenter.baselist.LoadType;
import com.gh.gamecenter.baselist.NormalListViewModel;
-import com.gh.gamecenter.manager.UserManager;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
import com.lightgame.utils.Utils;
@@ -407,8 +405,7 @@ public class QuestionsDetailFragment extends ListFragment() {
diff --git a/app/src/main/java/com/gh/gamecenter/ask/viewmodel/AnswerCommentConversationFragment.java b/app/src/main/java/com/gh/gamecenter/ask/viewmodel/AnswerCommentConversationFragment.java
index 00fdd6a805..7db4b17adf 100644
--- a/app/src/main/java/com/gh/gamecenter/ask/viewmodel/AnswerCommentConversationFragment.java
+++ b/app/src/main/java/com/gh/gamecenter/ask/viewmodel/AnswerCommentConversationFragment.java
@@ -10,10 +10,13 @@ import android.view.View;
import com.gh.common.util.EntranceUtils;
import com.gh.gamecenter.R;
+import com.gh.gamecenter.ask.AnswerCommentAdapter;
import com.gh.gamecenter.ask.AnswerCommentFragment;
+import com.gh.gamecenter.baselist.ListAdapter;
import com.gh.gamecenter.entity.CommentEntity;
import butterknife.BindView;
+
// 评论详情-查看对话
public class AnswerCommentConversationFragment extends AnswerCommentFragment {
@@ -22,6 +25,11 @@ public class AnswerCommentConversationFragment extends AnswerCommentFragment {
private String mCommentId;
+ @Override
+ protected ListAdapter provideListAdapter() {
+ return mAdapter == null ? mAdapter = new AnswerCommentAdapter(getContext(), mAnswerId, true, this) : mAdapter;
+ }
+
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
mCommentId = getArguments().getString(EntranceUtils.KEY_COMMENTID);
diff --git a/app/src/main/java/com/gh/gamecenter/collection/ArticleAdapter.java b/app/src/main/java/com/gh/gamecenter/collection/ArticleAdapter.java
index 425dfa2f67..3968ede255 100644
--- a/app/src/main/java/com/gh/gamecenter/collection/ArticleAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/collection/ArticleAdapter.java
@@ -129,7 +129,7 @@ public class ArticleAdapter extends ListAdapter {
if (newsEntity.getThumbnail() != null && newsEntity.getThumbnail().getUrl() != null) {
ImageUtils.Companion.display(viewHolder.thumb, newsEntity.getThumbnail().getUrl().get(0));
} else {
- ImageUtils.Companion.display(viewHolder.thumb, R.drawable.collection_default_icon);
+ ImageUtils.Companion.display(viewHolder.thumb, R.drawable.message_image_placeholder);
}
viewHolder.title.setText(newsEntity.getTitle());
int views = newsEntity.getViews();
diff --git a/app/src/main/java/com/gh/gamecenter/fragment/MainWrapperFragment.java b/app/src/main/java/com/gh/gamecenter/fragment/MainWrapperFragment.java
index 64f19b9c00..cbb164d322 100644
--- a/app/src/main/java/com/gh/gamecenter/fragment/MainWrapperFragment.java
+++ b/app/src/main/java/com/gh/gamecenter/fragment/MainWrapperFragment.java
@@ -1,14 +1,18 @@
package com.gh.gamecenter.fragment;
+import android.content.SharedPreferences;
import android.os.Bundle;
+import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.View;
import com.gh.base.fragment.BaseFragment_ViewPager_Checkable;
import com.gh.common.util.CheckLoginUtils;
+import com.gh.gamecenter.NormalActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.ask.AskFragment;
+import com.gh.gamecenter.ask.SelectGameFragment;
import com.gh.gamecenter.db.GameTrendsDao;
import com.gh.gamecenter.db.info.GameTrendsInfo;
import com.gh.gamecenter.discover.DiscoverFragment;
@@ -34,6 +38,7 @@ import rx.schedulers.Schedulers;
import static com.gh.gamecenter.MainActivity.EB_MAINACTIVITY_TAG;
import static com.gh.gamecenter.MainActivity.EB_SKIP_GAMEFRAGMENT;
+import static com.gh.gamecenter.ask.AskFragment.COMMUNITIES_SELECT_REQUEST;
/**
* @author CsHeng
@@ -58,6 +63,9 @@ public class MainWrapperFragment extends BaseFragment_ViewPager_Checkable {
private GameTrendsDao mGameTrendsDao;
+ private SharedPreferences sp;
+
+ private boolean mIsEnterSelectCommunities;
private long mLastRequestDiscoveryTime;
@Override
@@ -87,6 +95,8 @@ public class MainWrapperFragment extends BaseFragment_ViewPager_Checkable {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mGameTrendsDao = new GameTrendsDao(getContext());
+ sp = PreferenceManager.getDefaultSharedPreferences(getContext());
+ mIsEnterSelectCommunities = sp.getBoolean("isEnterSelectCommunities", true);
}
@Override
@@ -113,6 +123,11 @@ public class MainWrapperFragment extends BaseFragment_ViewPager_Checkable {
@Override
protected void onPageChanged(int index) {
super.onPageChanged(index);
+ if (index == INDEX_ASK && mIsEnterSelectCommunities) {
+ sp.edit().putBoolean("isEnterSelectCommunities", false).apply();
+ mIsEnterSelectCommunities = false;
+ NormalActivity.startFragmentForResult(getContext(), SelectGameFragment.class, COMMUNITIES_SELECT_REQUEST);
+ }
}
@Subscribe(threadMode = ThreadMode.MAIN)
diff --git a/app/src/main/java/com/gh/gamecenter/login/UserRepository.java b/app/src/main/java/com/gh/gamecenter/login/UserRepository.java
index 67c999e5fb..cae5e1a267 100644
--- a/app/src/main/java/com/gh/gamecenter/login/UserRepository.java
+++ b/app/src/main/java/com/gh/gamecenter/login/UserRepository.java
@@ -355,8 +355,6 @@ class UserRepository {
value.setHttpException(httpException);
mEditObsResponseUserInfo.postValue(value);
- Utils.toast(mContext, "修改失败");
-
if (httpException == null || httpException.code() == Constants.NOT_NETWORK_CODE) {
Utils.toast(mContext, "请检查网络是否可用");
return;
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 a0ecf18764..aadaaf4622 100644
--- a/app/src/main/java/com/gh/gamecenter/message/MessageDetailFragment.java
+++ b/app/src/main/java/com/gh/gamecenter/message/MessageDetailFragment.java
@@ -22,6 +22,7 @@ import com.gh.common.util.CheckLoginUtils;
import com.gh.common.util.DialogUtils;
import com.gh.common.util.EntranceUtils;
import com.gh.common.util.ImageUtils;
+import com.gh.common.util.LoginUtils;
import com.gh.common.util.PostCommentUtils;
import com.gh.common.util.TimestampUtils;
import com.gh.common.util.TokenUtils;
@@ -409,39 +410,7 @@ public class MessageDetailFragment extends NormalFragment implements OnCommentCa
@Override
public void postFailed(Throwable e) {
mSendingDialog.dismiss();
-
- if (e instanceof HttpException) {
- HttpException exception = (HttpException) e;
- if (exception.code() == 403) {
- try {
- JSONObject errorJson = new JSONObject(exception.response().errorBody().string());
- String detail = errorJson.getString("detail");
- switch (detail) {
- case "too frequent":
- toast(R.string.comment_failed_toofrequent);
- break;
- case "user blocked":
- toast(R.string.comment_failed_userblocked);
- break;
- case "article blocked":
- toast(R.string.comment_failed_articleblocked);
- setSoftInput(false);
- break;
- case "illegal":
- toast(R.string.comment_failed_illegal);
- break;
- default:
- toast(R.string.comment_failed_unknown);
- break;
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- toast("评论异常");
- }
- return;
- }
- }
-
+ if (LoginUtils.userPostErrorToast(e, getContext())) return;
toast(R.string.post_failure_hint);
}
});
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 4bfb8a3ec9..46727c249c 100644
--- a/app/src/main/java/com/gh/gamecenter/newsdetail/NewsDetailAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/newsdetail/NewsDetailAdapter.java
@@ -526,7 +526,7 @@ public class NewsDetailAdapter extends BaseRecyclerAdapter {
contentView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- CommentUtils.showReportDialog(commentEntity, mContext, null, mNewsDetailEntity.getId());
+ CommentUtils.showReportDialog(commentEntity, mContext, true, null, mNewsDetailEntity.getId());
}
});
}
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 7b695ce03e..2e2db87536 100644
--- a/app/src/main/java/com/gh/gamecenter/personal/PersonalFragment.java
+++ b/app/src/main/java/com/gh/gamecenter/personal/PersonalFragment.java
@@ -252,7 +252,8 @@ public class PersonalFragment extends BaseFragment implements Observer {
diff --git a/app/src/main/java/com/gh/gamecenter/retrofit/OkHttpNetworkInterceptor.java b/app/src/main/java/com/gh/gamecenter/retrofit/OkHttpNetworkInterceptor.java
index 82401e7916..3e31543f37 100644
--- a/app/src/main/java/com/gh/gamecenter/retrofit/OkHttpNetworkInterceptor.java
+++ b/app/src/main/java/com/gh/gamecenter/retrofit/OkHttpNetworkInterceptor.java
@@ -2,8 +2,10 @@ package com.gh.gamecenter.retrofit;
import android.content.Context;
+import com.gh.common.util.GzipUtils;
import com.gh.common.util.NetworkUtils;
import com.gh.common.util.TimestampUtils;
+import com.lightgame.utils.Utils;
import java.io.IOException;
@@ -38,8 +40,8 @@ class OkHttpNetworkInterceptor implements Interceptor {
@Override
public BufferedSource source() {
Buffer buffer = new Buffer();
-// buffer.write(GzipUtils.compressBytes("[]".getBytes())); 某些接口不适配 弃用
- buffer.write("[]".getBytes());
+ buffer.write(GzipUtils.compressBytes("[]".getBytes())); //某些接口不适配 弃用
+// buffer.write("[]".getBytes());
return buffer;
}
};
@@ -71,8 +73,9 @@ class OkHttpNetworkInterceptor implements Interceptor {
Response response = chain.proceed(request);
+ Utils.log("========contentLength::" + response.body().contentLength() + "===" + request.url());
// 404 Not Found
- if (response.code() == 404 && response.body().contentLength() == 0) {
+ if (response.code() == 404) {
response = response.newBuilder()
.code(200)
.message("OK")
diff --git a/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java b/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java
index 3aca84a3de..e0ceaf3555 100644
--- a/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java
+++ b/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java
@@ -193,7 +193,7 @@ public interface ApiService {
/**
* 获取游戏平台信息
*/
- @GET("platform")
+ @GET("platforms")
Observable> getGamePlatform();
/**
@@ -880,8 +880,8 @@ public interface ApiService {
/**
* 保存单个用户回答的草稿
*/
- @GET("users/{user_id}/answer_drafts")
- Observable getUserAnswerDrafts(@Path("user_id") String user_id, @Query("filter") String filter, @Query("timestamp") long timestamp);
+ @GET("questions/{question_id}/answer_drafts")
+ Observable getUserAnswerDrafts(@Path("question_id") String questionId, @Query("timestamp") long timestamp);
/**
* 保存用户回答的草稿
@@ -889,6 +889,12 @@ public interface ApiService {
@POST("users/{user_id}/answer_drafts")
Observable postAnswerDrafts(@Body RequestBody body, @Path("user_id") String user_id);
+ /**
+ * 删除用户草稿
+ */
+ @DELETE("users/{user_id}/answer_drafts/{draft_id}")
+ Observable deleteAnswerDrafts(@Path("user_id")String userId, @Path("draft_id")String draftId);
+
/**
* 获取用户收藏的回答列表
*/
diff --git a/app/src/main/java/com/halo/assistant/fragment/SettingsFragment.java b/app/src/main/java/com/halo/assistant/fragment/SettingsFragment.java
index 3afda3083f..bd3be54e67 100644
--- a/app/src/main/java/com/halo/assistant/fragment/SettingsFragment.java
+++ b/app/src/main/java/com/halo/assistant/fragment/SettingsFragment.java
@@ -1,9 +1,9 @@
package com.halo.assistant.fragment;
import android.app.Dialog;
-import android.arch.lifecycle.ViewModelProviders;
import android.content.DialogInterface;
import android.content.SharedPreferences;
+import android.graphics.Color;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.content.ContextCompat;
@@ -17,6 +17,7 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import com.gh.common.util.DialogUtils;
+import com.gh.common.util.EntranceUtils;
import com.gh.common.util.LoginUtils;
import com.gh.common.util.StringUtils;
import com.gh.gamecenter.AboutActivity;
@@ -26,7 +27,6 @@ import com.gh.gamecenter.R;
import com.gh.gamecenter.entity.LoginTokenEntity;
import com.gh.gamecenter.eventbus.EBReuse;
import com.gh.gamecenter.eventbus.EBSkip;
-import com.gh.gamecenter.login.UserViewModel;
import com.gh.gamecenter.manager.UserManager;
import com.gh.gamecenter.normal.NormalFragment;
import com.gh.gamecenter.personal.PersonalFragment;
@@ -57,8 +57,6 @@ public class SettingsFragment extends NormalFragment {
@BindView(R.id.setting_sb_autoinstall)
SwitchButton mSettingAutoinstallSb;
-// @BindView(R.id.setting_sb_autodelete)
-// SwitchButton mSettingAutodeleteSb;
@BindView(R.id.setting_sb_concerngame)
SwitchButton mSettingConcerngameSb;
@BindView(R.id.setting_tv_cache)
@@ -69,13 +67,13 @@ public class SettingsFragment extends NormalFragment {
TextView mSettingLoginType;
@BindView(R.id.setting_logout_rl)
RelativeLayout mSettingLoginRl;
+ @BindView(R.id.setting_rl_about_version)
+ TextView mVersionName;
private SharedPreferences sp;
private Dialog loadingDialog = null;
- private UserViewModel mUserViewModel;
-
private int checkSizeIndex;
@Override
@@ -95,20 +93,26 @@ public class SettingsFragment extends NormalFragment {
setNavigationTitle(getString(R.string.title_settings));
- mSettingCacheTv.setText(getCacheSize());
+ if (getArguments() != null) {
+ boolean isUpdate = getArguments().getBoolean(EntranceUtils.KEY_VERSION_UPDATE, false);
+ if (isUpdate) {
+ mVersionName.setText(getString(R.string.personal_update_hint));
+ mVersionName.setTextColor(Color.WHITE);
+ mVersionName.setBackgroundResource(R.drawable.setting_update_hint);
+ } else {
+ mVersionName.setText("V" + BuildConfig.PATCH_VERSION_NAME);
+ }
+ }
sp = PreferenceManager.getDefaultSharedPreferences(getContext());
- final UserViewModel.Factory factory = new UserViewModel.Factory(getActivity().getApplication());
- mUserViewModel = ViewModelProviders.of(this, factory).get(UserViewModel.class);
-
// 未打开下载按钮,显示修复下载按钮
if (!sp.getBoolean("isShow", true)) {
mCachedView.findViewById(R.id.setting_cv_fix_download).setVisibility(View.VISIBLE);
}
+ mSettingCacheTv.setText(getCacheSize());
mSettingAutoinstallSb.setChecked(sp.getBoolean("autoinstall", true));
-// mSettingAutodeleteSb.setChecked(sp.getBoolean("autodelete", true));
mSettingConcerngameSb.setChecked(sp.getBoolean("concerngame", true));
checkSizeIndex = sp.getInt("fontsize", 1);
@@ -121,7 +125,6 @@ public class SettingsFragment extends NormalFragment {
}
private void initLoginStatus() {
-// LoginResponseEntity loginToken = LoginUtils.getLoginToken(getContext());
LoginTokenEntity loginToken = UserManager.getInstance().getLoginTokenEntity();
if (loginToken != null) {
if (!TextUtils.isEmpty(loginToken.getLoginType())) {
@@ -239,17 +242,11 @@ public class SettingsFragment extends NormalFragment {
case R.id.setting_rl_autoinstall:
mSettingAutoinstallSb.performClick();
break;
-// case R.id.setting_rl_autodelete:
-// mSettingAutodeleteSb.performClick();
-// break;
case R.id.setting_rl_cache:
DialogUtils.showWarningDialog(getContext(), "清除缓存", "清空缓存后未安装的游戏可能需要重新下载,确定清空?",
- new DialogUtils.ConfirmListener() {
- @Override
- public void onConfirm() {
- loadingDialog = DialogUtils.showWaitDialog(getContext(), "清除缓存中...");
- clearCache();
- }
+ () -> {
+ loadingDialog = DialogUtils.showWaitDialog(getContext(), "清除缓存中...");
+ clearCache();
});
break;
case R.id.setting_cv_font_size:
@@ -266,19 +263,13 @@ public class SettingsFragment extends NormalFragment {
break;
case R.id.setting_logout_rl:
DialogUtils.showForceDialog(getContext(), "注销登录", "退出账号即会回到游客状态,很多功能将无法使用(例如评论、客服消息),确定退出吗?",
- "确定退出", "取消", new DialogUtils.ConfirmListener() {
- @Override
- public void onConfirm() {
- loadingDialog = DialogUtils.showWaitDialog(getContext(), "退出登录中...");
- LoginUtils.logout(getContext(), new LoginUtils.OnLogoutListener() {
- @Override
- public void onCompleted() {
- EventBus.getDefault().post(new EBReuse(PersonalFragment.LOGOUT_TAG));
- if (loadingDialog != null) loadingDialog.dismiss();
- if (getActivity() != null) getActivity().finish();
- }
- });
- }
+ "确定退出", "取消", () -> {
+ loadingDialog = DialogUtils.showWaitDialog(getContext(), "退出登录中...");
+ LoginUtils.logout(getContext(), () -> {
+ EventBus.getDefault().post(new EBReuse(PersonalFragment.LOGOUT_TAG));
+ if (loadingDialog != null) loadingDialog.dismiss();
+ if (getActivity() != null) getActivity().finish();
+ });
}, null);
break;
default:
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 e4d7a2abad..d80a6e3e1a 100644
--- a/app/src/main/java/com/halo/assistant/fragment/WebFragment.java
+++ b/app/src/main/java/com/halo/assistant/fragment/WebFragment.java
@@ -30,7 +30,6 @@ import com.gh.gamecenter.message.MessageDetailFragment;
import com.gh.gamecenter.normal.NormalFragment;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
-import com.google.gson.Gson;
import com.lightgame.listeners.OnBackPressedListener;
import java.util.List;
@@ -266,37 +265,9 @@ public class WebFragment extends NormalFragment implements OnBackPressedListener
getNewsCommentNum();
}
- if (mIsCollectionTools && mToolBoxEntity != null) {
- getToolsById(); // 对比查看是否修改
- }
-
initMenu();
}
- private void getToolsById() {
- RetrofitManager.getInstance(getContext())
- .getApi()
- .getToolBoxById(mToolBoxEntity.getId())
- .subscribeOn(Schedulers.io())
- .observeOn(AndroidSchedulers.mainThread())
- .subscribe(new Response>() {
- @Override
- public void onResponse(List response) {
- super.onResponse(response);
- if (response.size() == 0) return;
-
- ToolBoxEntity toolBoxEntity = response.get(0);
- Gson gson = new Gson();
-
- String newEntity = gson.toJson(toolBoxEntity);
- String entity = gson.toJson(mToolBoxEntity);
- if (!newEntity.equals(entity)) {
- CollectionUtils.INSTANCE.patchCollection(getContext(), toolBoxEntity.getId(), CollectionUtils.CollectionType.toolkit);
- }
- }
- });
- }
-
public void getNewsCommentNum() {
RetrofitManager.getInstance(getContext()).getApi()
.getNewsCommentnum(newsId)
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 7e1ca0d457..e7a3cf7382 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
@@ -17,6 +17,7 @@ import com.gh.common.util.CheckLoginUtils;
import com.gh.common.util.DialogUtils;
import com.gh.common.util.EntranceUtils;
import com.gh.common.util.ImageUtils;
+import com.gh.common.util.LoginUtils;
import com.gh.common.util.PostCommentUtils;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.CommentDetailAdapter;
@@ -34,7 +35,6 @@ import org.json.JSONObject;
import butterknife.BindView;
import butterknife.OnClick;
import butterknife.OnTouch;
-import retrofit2.HttpException;
/**
* Created by CsHeng on 14/12/2017.
@@ -191,39 +191,7 @@ public class CommentDetailFragment extends NormalFragment implements OnCommentCa
@Override
public void postFailed(Throwable e) {
mSendingDialog.dismiss();
-
- if (e instanceof HttpException) {
- HttpException exception = (HttpException) e;
- if (exception.code() == 403) {
- try {
- JSONObject errorJson = new JSONObject(exception.response().errorBody().string());
- String detail = errorJson.getString("detail");
- switch (detail) {
- case "too frequent":
- toast(R.string.comment_failed_toofrequent);
- break;
- case "user blocked":
- toast(R.string.comment_failed_userblocked);
- break;
- case "article blocked":
- toast(R.string.comment_failed_articleblocked);
- setSoftInput(false);
- break;
- case "illegal":
- toast(R.string.comment_failed_illegal);
- break;
- default:
- toast(R.string.comment_failed_unknown);
- break;
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- toast("评论异常");
- }
- return;
- }
- }
-
+ if (LoginUtils.userPostErrorToast(e, getContext())) return;
toast(R.string.post_failure_hint);
}
});
diff --git a/app/src/main/java/com/halo/assistant/fragment/user/SelectPortraitFragment.java b/app/src/main/java/com/halo/assistant/fragment/user/SelectPortraitFragment.java
index e857765922..0d9a6e6b99 100644
--- a/app/src/main/java/com/halo/assistant/fragment/user/SelectPortraitFragment.java
+++ b/app/src/main/java/com/halo/assistant/fragment/user/SelectPortraitFragment.java
@@ -60,7 +60,7 @@ public class SelectPortraitFragment extends NormalFragment {
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
- if (data == null && getActivity() == null) {
+ if (data == null || getActivity() == null) {
return;
}
diff --git a/app/src/main/java/com/halo/assistant/fragment/user/UserInfoEditFragment.java b/app/src/main/java/com/halo/assistant/fragment/user/UserInfoEditFragment.java
index 7c7fc7fbbf..f79351f499 100644
--- a/app/src/main/java/com/halo/assistant/fragment/user/UserInfoEditFragment.java
+++ b/app/src/main/java/com/halo/assistant/fragment/user/UserInfoEditFragment.java
@@ -104,12 +104,6 @@ public class UserInfoEditFragment extends NormalFragment {
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
- if (mSaveMenuItem == null) {
- initMenu(R.menu.menu_button);
- mSaveMenuItem = getItemMenu(R.id.menu_button);
- TextView menuView = mSaveMenuItem.getActionView().findViewById(R.id.tv_menu_button);
- menuView.setText(R.string.menu_text_save);
- }
if (mUserInfoEntity != null) {
initView();
}
diff --git a/app/src/main/res/layout/activity_news_detail.xml b/app/src/main/res/layout/activity_news_detail.xml
index 0b01307b39..569794aad8 100644
--- a/app/src/main/res/layout/activity_news_detail.xml
+++ b/app/src/main/res/layout/activity_news_detail.xml
@@ -15,6 +15,7 @@
android:id = "@+id/news_detail_rv_show"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
+ android:scrollbars="vertical"
android:layout_above = "@+id/news_detail_ll_bottom" />
@@ -115,32 +115,6 @@
android:layout_centerVertical = "true" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -188,6 +162,19 @@
android:text = "@string/setting_about"
android:textColor = "@color/title"
android:textSize = "15sp" />
+
+
+ android:textSize = "12sp" />
@@ -103,7 +104,7 @@
android:layout_height = "wrap_content"
android:layout_marginLeft = "15dp"
android:layout_marginTop = "12dp"
- android:textColor = "@color/black"
+ android:textColor = "@color/hint"
android:textSize = "11sp"
app:layout_constraintLeft_toRightOf = "@id/message_user_icon"
app:layout_constraintTop_toBottomOf = "@id/message_original" />
diff --git a/app/src/main/res/menu/menu_web.xml b/app/src/main/res/menu/menu_web.xml
index b2f2710e79..20d0f5abf3 100644
--- a/app/src/main/res/menu/menu_web.xml
+++ b/app/src/main/res/menu/menu_web.xml
@@ -2,18 +2,18 @@
别话痨哦~休息一会再来评论吧~
账号状态异常,暂时无法发表评论
+ 账号异常,暂时无法发表内容
文章异常,无法发表评论
评论内容可能包括敏感信息,请修改后再发表
评论失败,未知原因
diff --git a/dependencies.gradle b/dependencies.gradle
index 4a60927e79..ac351c1cf8 100644
--- a/dependencies.gradle
+++ b/dependencies.gradle
@@ -28,7 +28,7 @@ ext {
rxJava2 = "2.0.9"
rxAndroid2 = "2.0.1"
retrofit = "2.2.0"
- okHttp = "3.10.0"
+ okHttp = "3.7.0"
gson = "2.8.0"
zxing = "3.2.1"
fresco = "1.5.0"