diff --git a/app/src/main/java/com/gh/gamecenter/CommentDetailActivity.java b/app/src/main/java/com/gh/gamecenter/CommentDetailActivity.java index 310a9336ae..4c4e2a1319 100644 --- a/app/src/main/java/com/gh/gamecenter/CommentDetailActivity.java +++ b/app/src/main/java/com/gh/gamecenter/CommentDetailActivity.java @@ -1,24 +1,70 @@ package com.gh.gamecenter; +import android.app.Dialog; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; +import android.view.View; +import android.view.inputmethod.InputMethodManager; +import android.widget.EditText; +import android.widget.RelativeLayout; +import android.widget.ScrollView; +import android.widget.TextView; +import com.facebook.drawee.view.SimpleDraweeView; import com.gh.base.BaseActivity; +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.adapter.CommentDetailAdapter; +import com.gh.gamecenter.adapter.OnCommentCallBackListener; +import com.gh.gamecenter.entity.CommentEntity; +import com.gh.gamecenter.entity.UserInfoEntity; +import com.lightgame.utils.Utils; + +import org.json.JSONException; +import org.json.JSONObject; import butterknife.BindView; +import butterknife.OnClick; +import butterknife.OnTouch; +import retrofit2.HttpException; /** * Created by khy on 2017/3/22. */ -public class CommentDetailActivity extends BaseActivity { + +// TODO: 16/11/17 时间比较紧 先暂时这么做 最好发表评论那块和评论详情整合 +public class CommentDetailActivity extends BaseActivity implements OnCommentCallBackListener { @BindView(R.id.comment_detail_rv) RecyclerView mRecyclerView; + @BindView(R.id.comment_detail_close_comment) + View mCommentDetailCloseComment; + @BindView(R.id.comment_detail_comment_et) + EditText mCommentDetailCommentEt; + @BindView(R.id.comment_user_icon) + SimpleDraweeView mCommentUserIcon; + @BindView(R.id.comment_user_name) + TextView mCommentUserName; + @BindView(R.id.comment_send) + TextView mCommentSend; + @BindView(R.id.comment_detail_user_rl) + RelativeLayout mCommentDetailUserRl; + @BindView(R.id.comment_detail_comment_rl) + RelativeLayout mCommentDetailCommentRl; + @BindView(R.id.comment_detail_sv) + ScrollView mCommentDetailSv; + + private Dialog mSendingDialog; + + private UserInfoEntity mUserInfo; + private CommentEntity mCommentEntity; // 回复评论的实体 用完马上清空 private CommentDetailAdapter mAdapter; private LinearLayoutManager mLayoutManager; @@ -42,7 +88,7 @@ public class CommentDetailActivity extends BaseActivity { String commentId = getIntent().getStringExtra(EntranceUtils.KEY_COMMENTID); - mAdapter = new CommentDetailAdapter(this, commentId); + mAdapter = new CommentDetailAdapter(this, commentId, this); mLayoutManager = new LinearLayoutManager(this); mRecyclerView.setLayoutManager(mLayoutManager); mRecyclerView.setAdapter(mAdapter); @@ -56,5 +102,138 @@ public class CommentDetailActivity extends BaseActivity { } } }); + + mUserInfo = LoginUtils.getUserInfo(this); + if (mUserInfo != null) { + ImageUtils.Companion.display(mCommentUserIcon, mUserInfo.getIcon()); + mCommentUserName.setText(mUserInfo.getName()); + } } + + @Override + public void onCommentCallback(CommentEntity entity) { + mCommentEntity = entity; + setSoftInput(true); + } + + @OnTouch(R.id.comment_detail_close_comment) + public boolean OnRecyclerTouchListener() { + if (mCommentDetailCloseComment.getVisibility() == View.VISIBLE) { + setSoftInput(false); + } + return true; + } + + @OnClick(R.id.comment_send) + public void OnSendCommentListener() { + final String content = mCommentDetailCommentEt.getText().toString(); + + if (content.length() == 0) { + Utils.toast(this, "评论内容不能为空!"); + return; + } + + mSendingDialog = DialogUtils.showWaitDialog(this, "正在提交"); + + JSONObject jsonObject = new JSONObject(); + try { + jsonObject.put("content", content); + } catch (JSONException e) { + e.printStackTrace(); + } + if (mCommentEntity != null && mCommentEntity.getId() == null) { + Utils.toast(this, "评论异常 id null"); + mSendingDialog.cancel(); + return; + } + + PostCommentUtils.addCommentData(CommentDetailActivity.this, null, jsonObject.toString(), mCommentEntity, + new PostCommentUtils.PostCommentListener() { + @Override + public void postSuccess(JSONObject response) { + mSendingDialog.dismiss(); + toast("发表成功"); + mCommentDetailCommentEt.setText(""); + + setSoftInput(false); + + } + + @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("别话痨哦~休息一会再来评论吧~"); + break; + case "user blocked": + toast("账号状态异常,暂时无法发表评论"); + break; + case "article blocked": + toast("文章异常,无法发表评论"); + setSoftInput(false); + break; + case "illegal": + toast("评论内容可能包括敏感信息,请修改后再发表"); + break; + default: + toast("评论失败,未知原因"); + break; + } + } catch (Exception ex) { + ex.printStackTrace(); + toast("评论异常"); + } + return; + } + } + + toast("提交失败,请检查网络设置"); + } + }); + } + + //软键盘控制 + private void setSoftInput(boolean isShow) { + final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + if (isShow) { + CheckLoginUtils.checkLogin(this, new CheckLoginUtils.OnLoggenInListener() { + @Override + public void onLoggedIn() { + imm.showSoftInputFromInputMethod(mCommentDetailCommentEt.getWindowToken(), 0); + imm.toggleSoftInputFromWindow(mCommentDetailCommentEt.getWindowToken(), 0, InputMethodManager.HIDE_NOT_ALWAYS); + mCommentDetailCommentRl.setVisibility(View.VISIBLE); + mCommentDetailCommentEt.setFocusable(true); + mCommentDetailCommentEt.setFocusableInTouchMode(true); + mCommentDetailCommentEt.requestFocus(); + mCommentDetailCloseComment.setVisibility(View.VISIBLE); + + if (mCommentEntity != null && mCommentEntity.getUser() != null) { + mCommentDetailCommentEt.setHint("回复" + mCommentEntity.getUser().getName() + ":"); + } else { + mCommentDetailCommentEt.setHint("优质评论会被优先展示"); + } + } + }); + } else { + imm.hideSoftInputFromWindow(getWindow().getDecorView().getWindowToken(), 0); + + mCommentDetailCloseComment.setVisibility(View.GONE); + + mCommentDetailCommentRl.setVisibility(View.GONE); + if (mCommentEntity != null) { + mCommentEntity = null; // 清空当前评论实体 + mCommentDetailCommentEt.setHint("优质评论会被优先展示"); + mCommentDetailCommentEt.setText(""); + } + } + } + } diff --git a/app/src/main/java/com/gh/gamecenter/MainActivity.java b/app/src/main/java/com/gh/gamecenter/MainActivity.java index e688b168fb..704b9212ca 100644 --- a/app/src/main/java/com/gh/gamecenter/MainActivity.java +++ b/app/src/main/java/com/gh/gamecenter/MainActivity.java @@ -37,6 +37,7 @@ import com.gh.common.util.DialogUtils; import com.gh.common.util.EntranceUtils; import com.gh.common.util.GameUtils; import com.gh.common.util.LoginUtils; +import com.gh.common.util.NetworkUtils; import com.gh.common.util.PackageUtils; import com.gh.common.util.PlatformUtils; import com.gh.common.util.TrafficUtils; @@ -47,8 +48,8 @@ import com.gh.gamecenter.entity.ApkEntity; import com.gh.gamecenter.entity.GameDigestEntity; import com.gh.gamecenter.entity.GameEntity; import com.gh.gamecenter.entity.GameUpdateEntity; -import com.gh.gamecenter.entity.LoginResponseEntity; import com.gh.gamecenter.eventbus.EBDownloadStatus; +import com.gh.gamecenter.eventbus.EBNetworkState; import com.gh.gamecenter.eventbus.EBPackage; import com.gh.gamecenter.eventbus.EBShowDialog; import com.gh.gamecenter.eventbus.EBSkip; @@ -679,10 +680,24 @@ public class MainActivity extends BaseActivity { checkTinkerPath(); + checkRetryDownload(); + // 执行跳转事件 handler.postDelayed(skipRun, 500); } + private void checkRetryDownload() { + if (!NetworkUtils.isWifiConnected(this)) return; + + for (DownloadEntity downloadEntity : DownloadManager.getInstance(this).getAll()) { + if (DownloadStatus.neterror.equals(downloadEntity.getStatus()) || + DownloadStatus.timeout.equals(downloadEntity.getStatus())) { + DownloadManager.getInstance(this).add(downloadEntity); + } + Utils.log("checkRetryDownload::" + downloadEntity.getStatus()); + } + } + private void checkTinkerPath() { CommonDebug.logMethodWithParams(this, TinkerManager.getTinkerId(), TinkerManager.getNewTinkerId()); CommonDebug.logMethodWithParams(this, CrashReport.getAppVer(), CrashReport.getAppID(), CrashReport.getAppChannel(), CrashReport.getSdkExtraData()); @@ -892,6 +907,14 @@ public class MainActivity extends BaseActivity { } } + // 连接上网络事件 + @Subscribe(threadMode = ThreadMode.MAIN) + public void onEventMainThread(EBNetworkState busNetworkState) { + if (busNetworkState.isNetworkConnected()) { + checkRetryDownload(); + } + } + @Subscribe(threadMode = ThreadMode.MAIN) public void onEventMainThread(EBPackage busFour) { final String packageName = busFour.getPackageName(); diff --git a/app/src/main/java/com/gh/gamecenter/UserInfoEditActivity.java b/app/src/main/java/com/gh/gamecenter/UserInfoEditActivity.java index b4c3a81fcc..b710223d1a 100644 --- a/app/src/main/java/com/gh/gamecenter/UserInfoEditActivity.java +++ b/app/src/main/java/com/gh/gamecenter/UserInfoEditActivity.java @@ -149,7 +149,7 @@ public class UserInfoEditActivity extends BaseActivity implements LoginUtils.onC private void saveData() { if ("name".equals(mEditType)) { - String value = mUserinfoNicknameEt.getText().toString(); + String value = mUserinfoNicknameEt.getText().toString().trim(); if (!TextUtils.isEmpty(value)) { if (value.equals(mUserInfoEntity.getName())) { finish(); diff --git a/app/src/main/java/com/gh/gamecenter/VoteActivity.java b/app/src/main/java/com/gh/gamecenter/VoteActivity.java index 2bca97f25b..e89a0b9057 100644 --- a/app/src/main/java/com/gh/gamecenter/VoteActivity.java +++ b/app/src/main/java/com/gh/gamecenter/VoteActivity.java @@ -279,7 +279,6 @@ public class VoteActivity extends BaseActivity implements SwipeRefreshLayout.OnR JSONObject responseObject = new JSONObject(string); boolean cast = responseObject.getBoolean("cast"); String id = responseObject.getString("_id"); - if (cast) { Utils.toast(VoteActivity.this, getString(R.string.vote_success)); } else { @@ -307,7 +306,21 @@ public class VoteActivity extends BaseActivity implements SwipeRefreshLayout.OnR @Override public void onFailure(HttpException e) { super.onFailure(e); - Utils.toast(VoteActivity.this, "提交失败"); + if (e != null && e.code() == 403) { + try { + String string = e.response().errorBody().string(); + JSONObject errorJson = new JSONObject(string); + String detail = errorJson.getString("detail"); + if ("illegal".equals(detail)) { + Utils.toast(VoteActivity.this, "包含非法内容,请修改后重试"); + } + } catch (Exception e1) { + e1.printStackTrace(); + } + } else { + Utils.toast(VoteActivity.this, "提交失败"); + } + waitDialog.dismiss(); } }); 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 a3c2208b90..9d6ed599fb 100644 --- a/app/src/main/java/com/gh/gamecenter/adapter/CommentDetailAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/adapter/CommentDetailAdapter.java @@ -29,6 +29,8 @@ import rx.schedulers.Schedulers; */ public class CommentDetailAdapter extends BaseRecyclerAdapter { + private OnCommentCallBackListener mOnCommentCallBackListener; + private List mCommentList; private String mCommentId; @@ -37,10 +39,10 @@ public class CommentDetailAdapter extends BaseRecyclerAdapter { private boolean mIsLoading; private boolean mIsNetworkError; - public CommentDetailAdapter(Context context, String commentId) { + public CommentDetailAdapter(Context context, String commentId, OnCommentCallBackListener commentCallBackListener) { super(context); mCommentId = commentId; - + mOnCommentCallBackListener = commentCallBackListener; mCommentList = new ArrayList<>(); loadData(0); @@ -133,6 +135,13 @@ public class CommentDetailAdapter extends BaseRecyclerAdapter { } }); + holder.itemView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + CommentUtils.showReportDialog(commentEntity, mContext, mOnCommentCallBackListener, null); + } + }); + } private void initFooterViewHolder(FooterViewHolder holder) { diff --git a/app/src/main/java/com/gh/gamecenter/adapter/VoteAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/VoteAdapter.java index cf4734288c..00dabf01d7 100644 --- a/app/src/main/java/com/gh/gamecenter/adapter/VoteAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/adapter/VoteAdapter.java @@ -5,6 +5,8 @@ import android.graphics.drawable.ColorDrawable; import android.support.v4.content.ContextCompat; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView.ViewHolder; +import android.text.Html; +import android.text.TextUtils; import android.view.View; import android.view.ViewGroup; @@ -157,8 +159,14 @@ public class VoteAdapter extends BaseRecyclerAdapter { layoutParams.width = (int) mPbwidth; } + if (!TextUtils.isEmpty(versionVoteEntity.getReply())) { + viewHolder.voteReply.setText(Html.fromHtml(mContext.getString(R.string.vote_reply, versionVoteEntity.getReply()))); + viewHolder.voteReply.setVisibility(View.VISIBLE); + } else { + viewHolder.voteReply.setVisibility(View.GONE); + } viewHolder.name.setText(versionVoteEntity.getName()); - viewHolder.count.setText(versionVoteEntity.getNum() + "票"); + viewHolder.count.setText(mContext.getString(R.string.vote_count, versionVoteEntity.getNum())); progressbar.setLayoutParams(layoutParams); viewHolder.voteBtn.setOnClickListener(new View.OnClickListener() { diff --git a/app/src/main/java/com/gh/gamecenter/adapter/viewholder/VoteViewHolder.java b/app/src/main/java/com/gh/gamecenter/adapter/viewholder/VoteViewHolder.java index 5d7c552fab..870ae85559 100644 --- a/app/src/main/java/com/gh/gamecenter/adapter/viewholder/VoteViewHolder.java +++ b/app/src/main/java/com/gh/gamecenter/adapter/viewholder/VoteViewHolder.java @@ -22,6 +22,8 @@ public class VoteViewHolder extends BaseRecyclerViewHolder { public View progressbar; @BindView(R.id.vote_item_count) public TextView count; + @BindView(R.id.vote_item_reply) + public TextView voteReply; public VoteViewHolder(View itemView) { super(itemView); diff --git a/app/src/main/java/com/gh/gamecenter/download/GameDownloadFragment.java b/app/src/main/java/com/gh/gamecenter/download/GameDownloadFragment.java index d6134e0073..6bf064da3c 100644 --- a/app/src/main/java/com/gh/gamecenter/download/GameDownloadFragment.java +++ b/app/src/main/java/com/gh/gamecenter/download/GameDownloadFragment.java @@ -2,6 +2,8 @@ package com.gh.gamecenter.download; import android.app.NotificationManager; import android.content.Context; +import android.content.Intent; +import android.os.Message; import android.support.v4.content.ContextCompat; import android.support.v7.widget.DefaultItemAnimator; import android.support.v7.widget.LinearLayoutManager; @@ -21,12 +23,15 @@ import com.gh.common.util.PackageUtils; import com.gh.common.view.RecyclerViewExtended; import com.gh.download.DownloadManager; import com.gh.gamecenter.DownloadManagerActivity; +import com.gh.gamecenter.MainActivity; import com.gh.gamecenter.R; import com.gh.gamecenter.eventbus.EBDownloadChanged; import com.gh.gamecenter.eventbus.EBMiPush; import com.gh.gamecenter.eventbus.EBPackage; +import com.gh.gamecenter.eventbus.EBSkip; import com.gh.gamecenter.eventbus.EBUISwitch; import com.lightgame.download.DataWatcher; +import com.lightgame.download.DownloadConfig; import com.lightgame.download.DownloadEntity; import com.lightgame.download.DownloadStatus; @@ -199,18 +204,16 @@ public class GameDownloadFragment extends BaseFragment implements View.OnClickLi mNoDataSkipBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { -// Intent intent = new Intent(getActivity(), MainActivity.class); -// intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); -// getActivity().startActivity(intent); -// -// mNoDataSkipBtn.postDelayed(new Runnable() { -// @Override -// public void run() { -// EventBus.getDefault().post(new EBSkip(MainActivity.EB_SKIP_GAMEFRAGMENT, 0)); -// } -// }, 300); + Intent intent = new Intent(getActivity(), MainActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + getActivity().startActivity(intent); - DownloadManagerActivity.startDownloadManagerActivity(getActivity(), null, ""); + mNoDataSkipBtn.postDelayed(new Runnable() { + @Override + public void run() { + EventBus.getDefault().post(new EBSkip(MainActivity.EB_SKIP_GAMEFRAGMENT, 0)); + } + }, 300); } }); @@ -399,15 +402,15 @@ public class GameDownloadFragment extends BaseFragment implements View.OnClickLi } public void pauseAll() { -// for (DownloadEntity downloadEntity : adapter.getDownloadingList()) { -//// DownloadManager.getInstance(getActivity()).put(downloadEntity.getUrl(), -//// System.currentTimeMillis()); -//// Message msg = Message.obtain(); -//// msg.what = DownloadConfig.PAUSE_DOWNLOAD_TASK; -//// msg.obj = downloadEntity.getUrl(); -//// DownloadManager.getInstance(getActivity()).sendMessageDelayed(msg, 1000); + for (DownloadEntity downloadEntity : adapter.getDownloadingList()) { + DownloadManager.getInstance(getActivity()).put(downloadEntity.getUrl(), + System.currentTimeMillis()); + Message msg = Message.obtain(); + msg.what = DownloadConfig.PAUSE_DOWNLOAD_TASK; + msg.obj = downloadEntity.getUrl(); + DownloadManager.getInstance(getActivity()).sendMessageDelayed(msg, 1000); // DownloadManager.getInstance(getContext()).pause(downloadEntity); -// } + } DownloadManager.getInstance(getContext()).pauseAll(); mDownloadmanagerAllstartTv.setText("全部开始"); mDownloadmanagerAllstartTv.setTextColor(ContextCompat.getColor(getContext(), R.color.theme)); @@ -415,8 +418,15 @@ public class GameDownloadFragment extends BaseFragment implements View.OnClickLi private void startAll() { for (DownloadEntity downloadEntity : adapter.getDownloadingList()) { - DownloadManager.getInstance(getContext()).add(downloadEntity); - adapter.getStatusMap().put(downloadEntity.getUrl(), "downloading"); +// DownloadManager.getInstance(getContext()).add(downloadEntity); +// adapter.getStatusMap().put(downloadEntity.getUrl(), "downloading"); + + DownloadManager.getInstance(getActivity()).put(downloadEntity.getUrl(), + System.currentTimeMillis()); + Message msg = Message.obtain(); + msg.what = DownloadConfig.CONTINUE_DOWNLOAD_TASK; + msg.obj = downloadEntity.getUrl(); + DownloadManager.getInstance(getActivity()).sendMessageDelayed(msg, 1000); } // DownloadManager.getInstance(getContext()).startAll(); mDownloadmanagerAllstartTv.setText("全部暂停"); diff --git a/app/src/main/java/com/gh/gamecenter/download/GameDownloadFragmentAdapter.java b/app/src/main/java/com/gh/gamecenter/download/GameDownloadFragmentAdapter.java index 6e2b60a1e0..8a987609d8 100644 --- a/app/src/main/java/com/gh/gamecenter/download/GameDownloadFragmentAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/download/GameDownloadFragmentAdapter.java @@ -4,6 +4,7 @@ import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.graphics.Bitmap; +import android.os.Message; import android.support.v4.content.ContextCompat; import android.support.v4.util.ArrayMap; import android.support.v7.widget.RecyclerView; @@ -29,6 +30,7 @@ import com.gh.gamecenter.adapter.viewholder.GameDownloadViewHolder; import com.gh.gamecenter.eventbus.EBDownloadChanged; import com.gh.gamecenter.manager.PackageManager; import com.lightgame.adapter.BaseRecyclerAdapter; +import com.lightgame.download.DownloadConfig; import com.lightgame.download.DownloadEntity; import com.lightgame.download.DownloadStatus; import com.lightgame.download.FileUtils; @@ -246,11 +248,11 @@ class GameDownloadFragmentAdapter extends BaseRecyclerAdapter { statusMap.put(url, "downloading"); notifyItemChanged(doneList.isEmpty() ? 0 : 1 + doneList.size()); -// Message msg = Message.obtain(); -// msg.what = DownloadConfig.CONTINUE_DOWNLOAD_TASK; -// msg.obj = url; -// DownloadManager.getInstance(mContext).sendMessageDelayed(msg, 1000); - DownloadManager.getInstance(mContext).add(downloadEntity); + Message msg = Message.obtain(); + msg.what = DownloadConfig.CONTINUE_DOWNLOAD_TASK; + msg.obj = url; + DownloadManager.getInstance(mContext).sendMessageDelayed(msg, 1000); +// DownloadManager.getInstance(mContext).add(downloadEntity); } else { DialogUtils.showDownloadDialog(mContext, new DialogUtils.ConfirmListener() { @Override @@ -272,12 +274,12 @@ class GameDownloadFragmentAdapter extends BaseRecyclerAdapter { statusMap.put(url, "downloading"); notifyItemChanged(doneList.isEmpty() ? 0 : 1 + doneList.size()); -// Message msg = Message.obtain(); -// msg.what = DownloadConfig.CONTINUE_DOWNLOAD_TASK; -// msg.obj = url; -// DownloadManager.getInstance(mContext).sendMessageDelayed(msg, 1000); + Message msg = Message.obtain(); + msg.what = DownloadConfig.CONTINUE_DOWNLOAD_TASK; + msg.obj = url; + DownloadManager.getInstance(mContext).sendMessageDelayed(msg, 1000); - DownloadManager.getInstance(mContext).add(downloadEntity); +// DownloadManager.getInstance(mContext).add(downloadEntity); } }); } @@ -311,12 +313,12 @@ class GameDownloadFragmentAdapter extends BaseRecyclerAdapter { viewHolder.dmDelete.setVisibility(View.VISIBLE); statusMap.put(url, "pause"); notifyItemChanged(doneList.isEmpty() ? 0 : 1 + doneList.size()); -// Message msg = Message.obtain(); -// msg.what = DownloadConfig.PAUSE_DOWNLOAD_TASK; -// msg.obj = url; -// DownloadManager.getInstance(mContext).sendMessageDelayed(msg, 1000); + Message msg = Message.obtain(); + msg.what = DownloadConfig.PAUSE_DOWNLOAD_TASK; + msg.obj = url; + DownloadManager.getInstance(mContext).sendMessageDelayed(msg, 1000); - DownloadManager.getInstance(mContext).pause(downloadEntity); +// DownloadManager.getInstance(mContext).pause(downloadEntity); break; case "等待": Utils.toast(mContext, "最多只能同时启动3个下载任务"); @@ -408,15 +410,15 @@ class GameDownloadFragmentAdapter extends BaseRecyclerAdapter { }); } } else { -// for (DownloadEntity downloadEntity : downloadingList) { -//// DownloadManager.getInstance(mContext).put(downloadEntity.getUrl(), -//// System.currentTimeMillis()); -//// Message msg = Message.obtain(); -//// msg.what = DownloadConfig.PAUSE_DOWNLOAD_TASK; -//// msg.obj = downloadEntity.getUrl(); -//// DownloadManager.getInstance(mContext).sendMessageDelayed(msg, 1000); + for (DownloadEntity downloadEntity : downloadingList) { + DownloadManager.getInstance(mContext).put(downloadEntity.getUrl(), + System.currentTimeMillis()); + Message msg = Message.obtain(); + msg.what = DownloadConfig.PAUSE_DOWNLOAD_TASK; + msg.obj = downloadEntity.getUrl(); + DownloadManager.getInstance(mContext).sendMessageDelayed(msg, 1000); // DownloadManager.getInstance(mContext).pause(downloadEntity); -// } + } DownloadManager.getInstance(mContext).pauseAll(); viewHolder.dm_item_head_tv_allstart.setText(R.string.download_all_start); viewHolder.dm_item_head_tv_allstart.setTextColor(ContextCompat.getColor(mContext, R.color.theme)); diff --git a/app/src/main/java/com/gh/gamecenter/entity/MessageKeFuEntity.kt b/app/src/main/java/com/gh/gamecenter/entity/MessageKeFuEntity.kt index 657f5d21cc..c2f1558e6a 100644 --- a/app/src/main/java/com/gh/gamecenter/entity/MessageKeFuEntity.kt +++ b/app/src/main/java/com/gh/gamecenter/entity/MessageKeFuEntity.kt @@ -24,4 +24,11 @@ class MessageKeFuEntity { var link: MessageLinkEntity? = null + @SerializedName("service") + var serviceEntity: ServiceEntity? = null + + class ServiceEntity { + var name: String? = null + var icon: String? = null + } } diff --git a/app/src/main/java/com/gh/gamecenter/entity/VersionVoteEntity.kt b/app/src/main/java/com/gh/gamecenter/entity/VersionVoteEntity.kt index 97d5b96cfd..4c299f2c3a 100644 --- a/app/src/main/java/com/gh/gamecenter/entity/VersionVoteEntity.kt +++ b/app/src/main/java/com/gh/gamecenter/entity/VersionVoteEntity.kt @@ -17,4 +17,6 @@ class VersionVoteEntity { @SerializedName("user_data") var userData: UserDataEntity? = null + + var reply: String? = null } diff --git a/app/src/main/java/com/gh/gamecenter/gamedetail/XinXiAdapter.java b/app/src/main/java/com/gh/gamecenter/gamedetail/XinXiAdapter.java index 2fd3f4984e..8f13886eb2 100644 --- a/app/src/main/java/com/gh/gamecenter/gamedetail/XinXiAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/gamedetail/XinXiAdapter.java @@ -92,8 +92,6 @@ public class XinXiAdapter extends BaseRecyclerAdapter { if (mGameEntity != null) { initPosition(); - - getGameNews(); initGameIds(); } @@ -152,27 +150,6 @@ public class XinXiAdapter extends BaseRecyclerAdapter { } } - // 获取游戏新闻 - private void getGameNews() { - RetrofitManager.getInstance(mContext).getApi().getGameNews(mGameEntity.getId(), 3) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new Response>() { - @Override - public void onResponse(List response) { - mGameDetailEntity.setNews(response); - initPosition(); - notifyDataSetChanged(); - } - - @Override - public void onFailure(HttpException e) { - initPosition(); - notifyDataSetChanged(); - } - }); - } - public void initGameIds() { if (mGameDetailEntity.getRelatedGames() == null || mGameDetailEntity.getRelatedGames() != null diff --git a/app/src/main/java/com/gh/gamecenter/message/KeFuFragment.java b/app/src/main/java/com/gh/gamecenter/message/KeFuFragment.java index b5e028e52e..fcbf4431c2 100644 --- a/app/src/main/java/com/gh/gamecenter/message/KeFuFragment.java +++ b/app/src/main/java/com/gh/gamecenter/message/KeFuFragment.java @@ -70,7 +70,7 @@ public class KeFuFragment extends BaseFragment implements SwipeRefreshLayout.OnR mAdapter = new KeFuFragmentAdapter(getContext(), this); layoutManager = new LinearLayoutManager(getContext()); mRecyclerview.setLayoutManager(layoutManager); - mRecyclerview.addItemDecoration(new VerticalItemDecoration(getContext(), 8, true)); + mRecyclerview.addItemDecoration(new VerticalItemDecoration(getContext(), 1, true)); mRecyclerview.setAdapter(mAdapter); mRecyclerview.addOnScrollListener(new RecyclerView.OnScrollListener() { diff --git a/app/src/main/java/com/gh/gamecenter/message/KeFuFragmentAdapter.java b/app/src/main/java/com/gh/gamecenter/message/KeFuFragmentAdapter.java index 84145d9472..5f5d21c382 100644 --- a/app/src/main/java/com/gh/gamecenter/message/KeFuFragmentAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/message/KeFuFragmentAdapter.java @@ -12,6 +12,7 @@ import android.view.ViewGroup; import com.gh.base.OnRequestCallBackListener; import com.gh.common.util.CommentUtils; import com.gh.common.util.EntranceUtils; +import com.gh.common.util.ImageUtils; import com.gh.common.util.QQUtils; import com.gh.gamecenter.GameDetailActivity; import com.gh.gamecenter.NewsDetailActivity; @@ -245,6 +246,15 @@ public class KeFuFragmentAdapter extends BaseRecyclerAdapter { viewHolder.skip.setVisibility(View.GONE); } + MessageKeFuEntity.ServiceEntity serviceEntity = keFuEntity.getServiceEntity(); + viewHolder.kefuName.setText(R.string.kefu_default_name); + if (serviceEntity != null) { + String name = serviceEntity.getName(); + if (!TextUtils.isEmpty(name)) { + viewHolder.kefuName.setText(name); + } + ImageUtils.Companion.display(viewHolder.kefuIcon, serviceEntity.getIcon()); + } CommentUtils.setCommentTime(viewHolder.time, keFuEntity.getTime()); diff --git a/app/src/main/java/com/gh/gamecenter/message/KeFuViewHolder.java b/app/src/main/java/com/gh/gamecenter/message/KeFuViewHolder.java index 0e0b6c6115..631e2c9a63 100644 --- a/app/src/main/java/com/gh/gamecenter/message/KeFuViewHolder.java +++ b/app/src/main/java/com/gh/gamecenter/message/KeFuViewHolder.java @@ -3,6 +3,7 @@ package com.gh.gamecenter.message; import android.view.View; import android.widget.TextView; +import com.facebook.drawee.view.SimpleDraweeView; import com.gh.base.BaseRecyclerViewHolder; import com.gh.gamecenter.R; @@ -23,6 +24,10 @@ public class KeFuViewHolder extends BaseRecyclerViewHolder { public TextView suggestion; @BindView(R.id.message_kefu_skip) public TextView skip; + @BindView(R.id.message_kefu_icon) + public SimpleDraweeView kefuIcon; + @BindView(R.id.message_kefu_name) + TextView kefuName; public KeFuViewHolder(View itemView) { super(itemView); 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 3aac43df6d..19791783ba 100644 --- a/app/src/main/java/com/gh/gamecenter/retrofit/OkHttpNetworkInterceptor.java +++ b/app/src/main/java/com/gh/gamecenter/retrofit/OkHttpNetworkInterceptor.java @@ -2,7 +2,6 @@ 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; @@ -39,7 +38,8 @@ class OkHttpNetworkInterceptor implements Interceptor { @Override public BufferedSource source() { Buffer buffer = new Buffer(); - buffer.write(GzipUtils.compressBytes("[]".getBytes())); +// buffer.write(GzipUtils.compressBytes("[]".getBytes())); 某些接口不适配 弃用 + buffer.write("[]".getBytes()); return buffer; } }; diff --git a/app/src/main/java/com/gh/gamecenter/search/SearchGameDetailFragment.java b/app/src/main/java/com/gh/gamecenter/search/SearchGameDetailFragment.java index 3178446dae..3bdaf9497d 100644 --- a/app/src/main/java/com/gh/gamecenter/search/SearchGameDetailFragment.java +++ b/app/src/main/java/com/gh/gamecenter/search/SearchGameDetailFragment.java @@ -33,6 +33,7 @@ import org.greenrobot.eventbus.ThreadMode; import java.util.ArrayList; import butterknife.BindView; +import butterknife.OnClick; public class SearchGameDetailFragment extends BaseFragment implements OnRequestCallBackListener { @@ -50,6 +51,14 @@ public class SearchGameDetailFragment extends BaseFragment implements OnRequestC private SearchGameDetailFragmentAdapter adapter; + Runnable runnable = new Runnable() { + @Override + public void run() { + adapter = new SearchGameDetailFragmentAdapter(SearchGameDetailFragment.this, key, type, mEntrance); + search_detail.setAdapter(adapter); + } + }; + DataWatcher dataWatcher = new DataWatcher() { @Override public void onDataChanged(DownloadEntity downloadEntity) { @@ -127,6 +136,15 @@ public class SearchGameDetailFragment extends BaseFragment implements OnRequestC }); } + @OnClick(R.id.reuse_no_connection) + public void onClick(View view) { + search_loading.setVisibility(View.VISIBLE); + search_detail.setVisibility(View.GONE); + reuse_none_date.setVisibility(View.GONE); + reuse_no_connection.setVisibility(View.GONE); + postDelayedRunnable(runnable, 1000); + } + @Override public void onResume() { if (isEverPause && adapter != null) { diff --git a/app/src/main/java/com/gh/gamecenter/search/SearchGameListFragment.java b/app/src/main/java/com/gh/gamecenter/search/SearchGameListFragment.java index e98e12b557..483a10b823 100644 --- a/app/src/main/java/com/gh/gamecenter/search/SearchGameListFragment.java +++ b/app/src/main/java/com/gh/gamecenter/search/SearchGameListFragment.java @@ -33,6 +33,7 @@ import org.greenrobot.eventbus.ThreadMode; import java.util.ArrayList; import butterknife.BindView; +import butterknife.OnClick; public class SearchGameListFragment extends BaseFragment implements OnRequestCallBackListener { @@ -50,6 +51,14 @@ public class SearchGameListFragment extends BaseFragment implements OnRequestCal private SearchGameListFragmentAdapter adapter; + Runnable runnable = new Runnable() { + @Override + public void run() { + adapter = new SearchGameListFragmentAdapter(SearchGameListFragment.this, key, type, mEntrance); + search_detail.setAdapter(adapter); + } + }; + DataWatcher dataWatcher = new DataWatcher() { @Override public void onDataChanged(DownloadEntity downloadEntity) { @@ -124,6 +133,16 @@ public class SearchGameListFragment extends BaseFragment implements OnRequestCal }); } + @OnClick(R.id.reuse_no_connection) + public void onClick(View view) { + search_loading.setVisibility(View.VISIBLE); + search_detail.setVisibility(View.GONE); + reuse_none_date.setVisibility(View.GONE); + reuse_no_connection.setVisibility(View.GONE); + postDelayedRunnable(runnable, 1000); + } + + @Override public void onResume() { if (isEverPause && adapter != null) { diff --git a/app/src/main/res/drawable-xhdpi/message_kefu_icon.png b/app/src/main/res/drawable-xhdpi/message_kefu_icon.png new file mode 100644 index 0000000000..1936944eed Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/message_kefu_icon.png differ diff --git a/app/src/main/res/layout/activity_comment_detail.xml b/app/src/main/res/layout/activity_comment_detail.xml index 2b448fc619..f668efeb25 100644 --- a/app/src/main/res/layout/activity_comment_detail.xml +++ b/app/src/main/res/layout/activity_comment_detail.xml @@ -1,14 +1,103 @@ - - + android:layout_height = "match_parent" > + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/message_comment_item_normal.xml b/app/src/main/res/layout/message_comment_item_normal.xml index 59ba550402..372323d9b1 100644 --- a/app/src/main/res/layout/message_comment_item_normal.xml +++ b/app/src/main/res/layout/message_comment_item_normal.xml @@ -12,6 +12,8 @@ @@ -19,9 +21,7 @@ android:id = "@+id/message_comment_user_icon" android:layout_width = "45dp" android:layout_height = "45dp" - android:layout_marginBottom = "15dp" android:layout_marginRight = "20dp" - android:layout_marginTop = "15dp" fresco:placeholderImage = "@drawable/user_default_icon_comment" fresco:placeholderImageScaleType = "fitXY" fresco:roundAsCircle = "true" /> @@ -45,7 +45,7 @@ android:id = "@+id/message_comment_request_control" android:layout_width = "match_parent" android:layout_height = "wrap_content" - android:layout_marginTop = "11dp" + android:layout_marginTop = "5dp" android:textColor = "@color/hint" android:textSize = "11sp" /> @@ -78,7 +78,7 @@ android:layout_width = "wrap_content" android:layout_height = "wrap_content" android:layout_marginLeft = "65dp" - android:layout_marginTop = "11dp" + android:layout_marginTop = "10dp" android:textColor = "@color/hint" android:textSize = "12sp" /> diff --git a/app/src/main/res/layout/message_kefu_item.xml b/app/src/main/res/layout/message_kefu_item.xml index 3498f0f710..6a4628f5e8 100644 --- a/app/src/main/res/layout/message_kefu_item.xml +++ b/app/src/main/res/layout/message_kefu_item.xml @@ -1,5 +1,6 @@ + android:paddingTop = "10dp" > + + + + @@ -25,7 +46,6 @@ android:layout_width = "10dp" android:layout_height = "10dp" android:layout_alignParentRight = "true" - android:layout_centerVertical = "true" android:background = "@drawable/oval_message_hint_bg" android:visibility = "visible" /> @@ -34,7 +54,7 @@ android:id = "@+id/message_kefu_content" android:layout_width = "match_parent" android:layout_height = "wrap_content" - android:layout_marginTop = "11dp" + android:layout_marginTop = "15dp" android:textColor = "@color/title" android:textSize = "14sp" /> @@ -57,5 +77,4 @@ android:text = "@string/message_contact_kefu" android:textColor = "@color/theme" /> - \ No newline at end of file diff --git a/app/src/main/res/layout/vote_item.xml b/app/src/main/res/layout/vote_item.xml index 2db4002780..173d0f976e 100644 --- a/app/src/main/res/layout/vote_item.xml +++ b/app/src/main/res/layout/vote_item.xml @@ -73,6 +73,14 @@ + + 已结束 已领取 已淘号 - 已下架 - 再领一个 - 再淘一个 + 已下架 + 再领一个 + 再淘一个 - 已安装 - 未安装 - 回复了你的评论 - 暂无评论消息 - 暂无客服消息 - 工具箱 - 告诉小编 - 搜索结果为空 - 置顶 - 热门 + 已安装 + 未安装 + 回复了你的评论 + 暂无评论消息 + 暂无客服消息 + 工具箱 + 告诉小编 + 搜索结果为空 + 置顶 + 热门 已安装的游戏(%1$d) + 收到%1$d个赞 + 已是最新版本 + 小编回复:%1$s]]> + %1$d票 + 光环客服 + 已安装的应用(%1$d) 收到%1$d个赞 已是最新版本 @@ -410,5 +416,4 @@ http://www.ghzs.com/link?source=appshare300 http://image.ghzs666.com/pic/57d604808ab49e467d8b4568.png - diff --git a/build.gradle b/build.gradle index 4f527ab0aa..f8f7f6d46a 100644 --- a/build.gradle +++ b/build.gradle @@ -31,6 +31,7 @@ allprojects { maven { url "https://maven.google.com" } maven { url "https://dl.bintray.com/thelasterstar/maven/" }//weiboSDK maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + maven { url 'http://maven.aliyun.com/nexus/content/repositories/releases/' } jcenter() } } @@ -52,8 +53,8 @@ subprojects { // for those defined in AndroidManifest.xml manifestPlaceholders = [ - manifestApplicationId : "${applicationId}", - tencentAppId : "${TENCENT_APPID}", + manifestApplicationId: "${applicationId}", + tencentAppId : "${TENCENT_APPID}", ] } lintOptions.abortOnError false diff --git a/dependencies.gradle b/dependencies.gradle index 3e77a2a15e..c8be8e356a 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -56,4 +56,6 @@ ext { // 权限申请库 easypermissions = "1.0.0" + +// httpdns = "1.1.3"; } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index bb99869e69..ac1ffc7672 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,7 +20,7 @@ org.gradle.parallel=true channel_file=channel.txt # tinker patch version_name -PATCH_VERSION_NAME=3.0.1 +PATCH_VERSION_NAME=3.0.2 # Third-party keys DEBUG_UMENG_APPKEY=58e5b0b9c62dca35a00005e6 @@ -67,5 +67,5 @@ USERSEA_HOST=https\://usersea.ghzs.com/v1d0/ # 请不要手动改动下面的值,除非你明确需要以某个apk作为基准包,需要打包请以scripts/tinker*.sh为准 TINKER_ENABLE= -TINKER_ID=1d544ff5 -TINKER_BASE_APK_DIR=app-1108-20-13-16_1d544ff5 \ No newline at end of file +TINKER_ID=82fea044 +TINKER_BASE_APK_DIR=app-1114-14-55-39_82fea044 \ No newline at end of file diff --git a/libraries/LGLibrary b/libraries/LGLibrary index a5134fe7df..236d5837f7 160000 --- a/libraries/LGLibrary +++ b/libraries/LGLibrary @@ -1 +1 @@ -Subproject commit a5134fe7df9e183d8944df62a0f4f44148c61d49 +Subproject commit 236d5837f7e2641f4d72e7d4b1deaddd215b60e1 diff --git a/scripts/apk_channel.sh b/scripts/apk_channel.sh new file mode 100755 index 0000000000..38481bbdd8 --- /dev/null +++ b/scripts/apk_channel.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +CWD=$(cd "$(dirname "$0")"; pwd) + +# ***************************************************************************** +# @author khy +# @2017.11.15 +# +# 打渠道包 +# 将目标apk放到scripts/apk-channel文件夹中即可 +# +# ***************************************************************************** + + +source ${CWD}/tinker_env.sh + +echo ${APK_CHANNEL_PATH} +if [ ! -d ${APK_CHANNEL_PATH} ]; +then + echo "存放apk包的文件夹不存在" + exit 0 +fi + +for apkFile in ${APK_CHANNEL_PATH}/* +do +echo ${apkFile} +if [ -f "$apkFile" ]; +then +if [[ $apkFile == *.apk ]]; +then +APK_COUNT+=($apkFile) +fi +fi +done + +if [ ${#APK_COUNT[*]} != 1 ] +then +echo "确保apk_channel文件夹内只有一个apk包, 否则无法确定以哪个包为渠道基础包" +exit 0 +fi + +if [ ! -d ${APK_CHANNEL_PATH}/channel ]; then + mkdir -p ${APK_CHANNEL_PATH}/channel +fi + +java -jar ${CWD}/ApkChannelPackage.jar put -mtc ${PROJECT_BASE}/channel.txt ${APK_COUNT[0]} ${APK_CHANNEL_PATH}/channel + + diff --git a/scripts/tinker_env.sh b/scripts/tinker_env.sh index 75e1465d9d..8611466d2b 100755 --- a/scripts/tinker_env.sh +++ b/scripts/tinker_env.sh @@ -16,6 +16,8 @@ PROJECT_BASE=${CWD}/../ GRADLE_FILE=${PROJECT_BASE}/gradle.properties +APK_CHANNEL_PATH=${CWD}/apk-channel + OS=`uname` case ${OS} in Darwin) VERSION_CODE=`grep -r versionCode ${PROJECT_BASE}/dependencies.gradle | awk '{print $4}'`;;