资讯相关页面的整理

This commit is contained in:
CsHeng
2017-12-18 16:00:30 +08:00
parent 1958c6aefb
commit 9fd1855daa
54 changed files with 1030 additions and 1008 deletions

View File

@ -4,7 +4,6 @@ import android.app.Application;
import com.facebook.stetho.Stetho;
import com.facebook.stetho.okhttp3.StethoInterceptor;
import com.lightgame.utils.Utils;
import com.squareup.leakcanary.LeakCanary;
import okhttp3.OkHttpClient;
@ -56,7 +55,7 @@ public class Injection {
OkHttpClient.Builder builder = new OkHttpClient.Builder();
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BASIC);
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
builder.addNetworkInterceptor(interceptor);
builder.addNetworkInterceptor(new StethoInterceptor());
// if (BuildConfig.DEBUG) {

View File

@ -1,4 +1,4 @@
package com.gh.gamecenter.fragment;
package com.gh.base.fragment;
import android.app.Dialog;
import android.os.Bundle;

View File

@ -1,4 +1,4 @@
package com.gh.gamecenter.fragment;
package com.gh.base.fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;

View File

@ -1,23 +1,15 @@
package com.gh.common.util;
import android.content.Intent;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.view.View;
import com.gh.common.constant.Config;
import com.gh.common.view.DownloadDialog;
import com.gh.download.DownloadManager;
import com.gh.gamecenter.DataUtils;
import com.gh.gamecenter.DownloadManagerActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.DetailViewHolder;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.manager.PackageManager;
import com.lightgame.download.DownloadEntity;
import com.lightgame.download.FileUtils;
import com.lightgame.utils.Utils;
/**
* Created by khy on 27/06/17.
@ -167,94 +159,5 @@ public class DetailDownloadUtils {
}
}
public static class OnDetailDownloadClickListener implements View.OnClickListener {
private DetailViewHolder mViewHolder;
private GameEntity mGameEntity;
private DownloadEntity mDownloadEntity;
private String mEntrance;
private String mName;
private String mTitle;
public OnDetailDownloadClickListener(DetailViewHolder viewHolder, String entrance, String name, String title) {
mViewHolder = viewHolder;
mGameEntity = viewHolder.gameEntity;
mDownloadEntity = viewHolder.downloadEntity;
mEntrance = entrance;
mName = name;
mTitle = title;
}
@Override
public void onClick(View v) {
if (v == mViewHolder.downloadTv) {
if (mGameEntity != null && !mGameEntity.getApk().isEmpty()) {
if (mGameEntity.getApk().size() == 1) {
String str = mViewHolder.downloadTv.getText().toString();
if (str.contains("启动")) {
DataUtils.onGameLaunchEvent(mViewHolder.context, mGameEntity.getName(), mGameEntity.getApk().get(0).getPlatform(), mName);
PackageUtils.launchApplicationByPackageName(mViewHolder.context, mGameEntity.getApk().get(0).getPackageName());
} else if (NetworkUtils.isWifiConnected(mViewHolder.context)) {
download();
} else {
DialogUtils.showDownloadDialog(mViewHolder.context, new DialogUtils.ConfirmListener() {
@Override
public void onConfirm() {
download();
}
});
}
} else {
DownloadDialog.getInstance(mViewHolder.context)
.showPopupWindow(v, mGameEntity, StringUtils.buildString(mEntrance, "+(", mName, "[", mTitle, "])"), mName + ":" + mTitle);
}
} else {
Utils.toast(mViewHolder.context, "稍等片刻~!游戏正在上传中...");
}
} else if (v == mViewHolder.downloadPb || v == mViewHolder.downloadPer) {
String str = mViewHolder.downloadPer.getText().toString();
if ("下载中".equals(str)) {
Intent intent = DownloadManagerActivity.getDownloadMangerIntent(mViewHolder.context,
mGameEntity.getApk().get(0).getUrl(), StringUtils.buildString(mEntrance, "+(", mName, "[", mTitle, "])"));
mViewHolder.context.startActivity(intent);
} else if ("安装".equals(str)) {
if (mDownloadEntity == null) {
mDownloadEntity = DownloadManager.getInstance(mViewHolder.context).getDownloadEntityByUrl(mGameEntity.getApk().get(0).getUrl());
}
if (mDownloadEntity != null) {
PackageUtils.launchSetup(mViewHolder.context, mDownloadEntity.getPath());
}
}
}
}
private void download() {
String str = mViewHolder.downloadTv.getText().toString();
String method;
if (str.contains("更新")) {
method = "更新";
} else if (str.contains("插件化")) {
method = "插件化";
} else {
method = mViewHolder.context.getString(R.string.download);
}
ApkEntity apkEntity = mGameEntity.getApk().get(0);
String msg = FileUtils.isCanDownload(mViewHolder.context, apkEntity.getSize());
if (TextUtils.isEmpty(msg)) {
DataUtils.onGameDownloadEvent(mViewHolder.context, mGameEntity.getName(), apkEntity.getPlatform(), StringUtils.buildString(mEntrance, "+(", mName, "[", mTitle, "])"), "下载开始");
DownloadManager.createDownload(mViewHolder.context, apkEntity, mGameEntity, method, StringUtils.buildString(mEntrance, "+(", mName, "[", mTitle, "])"), mName + ":" + mTitle);
mViewHolder.downloadTv.setVisibility(View.GONE);
mViewHolder.downloadPb.setVisibility(View.VISIBLE);
mViewHolder.downloadPer.setVisibility(View.VISIBLE);
mViewHolder.downloadPb.setProgress(0);
mViewHolder.downloadPer.setText("0.0%");
// DownloadManager.getInstance(mViewHolder.context).putStatus(apkEntity.getUrl(), "downloading");
} else {
Utils.toast(mViewHolder.context, msg);
}
}
}
}

View File

@ -79,7 +79,7 @@ public class DeviceUtils {
InputStreamReader ir = new InputStreamReader(pp.getInputStream());
LineNumberReader input = new LineNumberReader(ir);
for (; null != str;) {
for (; null != str; ) {
str = input.readLine();
if (str != null) {
macSerial = str.trim();// 去空格

View File

@ -6,6 +6,7 @@ import android.content.Intent;
import android.widget.Toast;
import com.gh.common.constant.Config;
import com.gh.gamecenter.R;
import com.gh.gamecenter.login.LoginTag;
import com.lightgame.utils.RuntimeUtils;
import com.lightgame.utils.Utils;
@ -162,7 +163,7 @@ public class GetLoginDataUtils {
SendAuth.Req req = new SendAuth.Req();
req.scope = "snsapi_userinfo";
req.state = "光环助手";
req.state = mContext.getString(R.string.app_name);
boolean b = mIWXAPI.sendReq(req);
Utils.log(GetLoginDataUtils.class.getSimpleName(), "微信注册状态::" + register + "\n 发送状态::" + b);
if (!register || !b) {

View File

@ -230,7 +230,7 @@ public class MessageShareUtils {
params.putInt(QQShare.SHARE_TO_QQ_KEY_TYPE,
QQShare.SHARE_TO_QQ_TYPE_IMAGE);
params.putString(QQShare.SHARE_TO_QQ_IMAGE_LOCAL_URL, mContext.getExternalCacheDir().getPath() + "/ShareImg/" + picName);
params.putString(QQShare.SHARE_TO_QQ_APP_NAME, "光环助手");
params.putString(QQShare.SHARE_TO_QQ_APP_NAME, mContext.getString(R.string.app_name));
params.putInt(QQShare.SHARE_TO_QQ_EXT_INT,
QQShare.SHARE_TO_QQ_FLAG_QZONE_ITEM_HIDE);
mTencent.shareToQQ(
@ -246,7 +246,7 @@ public class MessageShareUtils {
params.putInt(QQShare.SHARE_TO_QQ_KEY_TYPE,
QQShare.SHARE_TO_QQ_TYPE_IMAGE);
params.putString(QQShare.SHARE_TO_QQ_IMAGE_LOCAL_URL, mContext.getExternalCacheDir().getPath() + "/ShareImg/" + picName);
params.putString(QQShare.SHARE_TO_QQ_APP_NAME, "光环助手");
params.putString(QQShare.SHARE_TO_QQ_APP_NAME, mContext.getString(R.string.app_name));
params.putInt(QQShare.SHARE_TO_QQ_EXT_INT,
QQShare.SHARE_TO_QQ_FLAG_QZONE_AUTO_OPEN);
mTencent.shareToQQ(

View File

@ -241,7 +241,7 @@ public class ShareUtils {
params.putInt(QQShare.SHARE_TO_QQ_KEY_TYPE, QQShare.SHARE_TO_QQ_TYPE_DEFAULT);
params.putString(QQShare.SHARE_TO_QQ_TARGET_URL, shareUrl);
params.putString(QQShare.SHARE_TO_QQ_IMAGE_URL, shareIcon);
params.putString(QQShare.SHARE_TO_QQ_APP_NAME, "光环助手");
params.putString(QQShare.SHARE_TO_QQ_APP_NAME, mContext.getString(R.string.app_name));
mTencent.shareToQQ(
(Activity) mContext, params, QqShareListener);
@ -400,7 +400,7 @@ public class ShareUtils {
params.putInt(QzoneShare.SHARE_TO_QZONE_KEY_TYPE, QzoneShare.SHARE_TO_QZONE_TYPE_NO_TYPE);
params.putString(QzoneShare.SHARE_TO_QQ_TARGET_URL, shareUrl);
params.putStringArrayList(QzoneShare.SHARE_TO_QQ_IMAGE_URL, imageUrls);
params.putString(QzoneShare.SHARE_TO_QQ_APP_NAME, "光环助手");
params.putString(QzoneShare.SHARE_TO_QQ_APP_NAME, mContext.getString(R.string.app_name));
mTencent.shareToQzone(
(Activity) mContext, params, QqShareListener);

View File

@ -4,12 +4,14 @@ import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
import com.gh.common.util.EntranceUtils;
import com.halo.assistant.fragment.ConcernFragment;
import com.halo.assistant.fragment.myconcern.MyConcernFragment;
import com.halo.assistant.ui.IntentFactory;
/**
* 我的关注页面
*/
@Deprecated
public class ConcernActivity extends CommonActivity {
@ -19,7 +21,7 @@ public class ConcernActivity extends CommonActivity {
args.putString(EntranceUtils.KEY_ENTRANCE, entrance);
return new IntentFactory.Builder(context)
.setActivity(ConcernActivity.class)
.setFragment(ConcernFragment.class).setArgs(args).build();
.setFragment(MyConcernFragment.class).setArgs(args).build();
}

View File

@ -146,6 +146,7 @@ public class GameDetailActivity extends BaseActivity {
private DetailViewHolder getDetailViewHolder() {
// 每次获取需要重新创建, 防止数据刷新
//TODO 更改为监听数据刷新哪有每次new对象的
return new DetailViewHolder(mContentView, mGameEntity, mDownloadEntity, downloadOffText, downloadAddWord,
false, mEntrance, getString(R.string.title_game_detail), title); // 下载按钮ViewHolder
}

View File

@ -1,5 +1,6 @@
package com.gh.gamecenter;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
@ -54,7 +55,6 @@ import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import static com.gh.gamecenter.R.id.reuse_tv_none_data;
import static com.gh.gamecenter.news.News2Fragment.NEWS2_LIBAO_REQUEST;
/**
* Created by khy on 2016/12/13.
@ -433,7 +433,7 @@ public class LibaoDetailActivity extends BaseActivity implements LibaoDetailAdap
if (obj != null) {
Intent data = new Intent();
data.putExtra(UserDataLibaoEntity.TAG, (UserDataLibaoEntity) obj);
setResult(NEWS2_LIBAO_REQUEST, data);
setResult(Activity.RESULT_OK, data);
}
}

View File

@ -51,7 +51,7 @@ import com.gh.gamecenter.eventbus.EBNetworkState;
import com.gh.gamecenter.eventbus.EBPackage;
import com.gh.gamecenter.eventbus.EBShowDialog;
import com.gh.gamecenter.eventbus.EBSkip;
import com.gh.gamecenter.fragment.MainFragment;
import com.gh.gamecenter.fragment.MainWrapperFragment;
import com.gh.gamecenter.manager.DataCollectionManager;
import com.gh.gamecenter.manager.FilterManager;
import com.gh.gamecenter.manager.GameManager;
@ -171,7 +171,7 @@ public class MainActivity extends BaseActivity {
DataLogUtils.uploadNeterrorLog(MainActivity.this, downloadEntity);
}
if (DownloadStatus.done.equals(downloadEntity.getStatus())) {
if (downloadEntity.getName().contains("光环助手")) {
if (downloadEntity.getName().contains(getString(R.string.app_name))) {
DataUtils.onEvent(MainActivity.this, "软件更新", "下载完成");
startActivity(PackageUtils.getInstallIntent(MainActivity.this, downloadEntity.getPath()));
DataLogUtils.uploadUpgradeLog(MainActivity.this, "install"); //上传更新安装数据
@ -638,7 +638,7 @@ public class MainActivity extends BaseActivity {
isSkipped = savedInstanceState.getBoolean("isSkipped");
}
replaceFragment(new MainFragment());
replaceFragment(new MainWrapperFragment());
mInstallManager = new InstallManager(getApplicationContext());

View File

@ -2,31 +2,20 @@ package com.gh.gamecenter;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.gh.base.BaseActivity;
import com.gh.gamecenter.message.MessageFragment;
import com.gh.gamecenter.message.MessageCenterFragment;
import com.halo.assistant.ui.IntentFactory;
/**
* Created by khy on 21/07/17.
*/
public class MessageActivity extends BaseActivity {
@Deprecated
public class MessageActivity extends CommonActivity {
public static Intent getIntent(Context context) {
return new Intent(context, MessageActivity.class);
return new IntentFactory.Builder(context)
.setActivity(MessageActivity.class)
.setFragment(MessageCenterFragment.class).build();
}
@Override
protected int getLayoutId() {
return R.layout.activity_message;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setNavigationTitle(getString(R.string.title_message_center));
getSupportFragmentManager().beginTransaction().replace(
R.id.layout_fragment_content, MessageFragment.newInstance(0)).commitAllowingStateLoss();
}
}

View File

@ -1,136 +1,20 @@
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.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
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.constant.Config;
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.PostCommentUtils;
import com.gh.common.util.TimestampUtils;
import com.gh.common.util.TokenUtils;
import com.gh.gamecenter.adapter.MessageDetailAdapter;
import com.gh.gamecenter.adapter.OnCommentCallBackListener;
import com.gh.gamecenter.entity.CommentEntity;
import com.gh.gamecenter.entity.CommentnumEntity;
import com.gh.gamecenter.entity.ConcernEntity;
import com.gh.gamecenter.entity.UserInfoEntity;
import com.gh.gamecenter.entity.ViewsEntity;
import com.gh.gamecenter.eventbus.EBReuse;
import com.gh.gamecenter.manager.CommentManager;
import com.gh.gamecenter.manager.UserManager;
import com.gh.gamecenter.retrofit.OkHttpCache;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
import com.google.gson.Gson;
import com.lightgame.utils.Util_System_Keyboard;
import com.lightgame.utils.Utils;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.List;
import butterknife.BindView;
import butterknife.OnClick;
import butterknife.OnTouch;
import retrofit2.HttpException;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import static com.gh.gamecenter.personal.PersonalFragment.LOGIN_TAG;
import com.gh.gamecenter.message.CommentDetailFragment;
import com.halo.assistant.ui.IntentFactory;
/**
* Created by khy on 2016/11/8.
* 消息详情界面
* 消息详情界面(评论详情)
*/
public class MessageDetailActivity extends BaseActivity implements OnCommentCallBackListener {
@BindView(R.id.message_detail_rv)
RecyclerView mMessageDetailRv;
@BindView(R.id.message_detail_user_rl)
RelativeLayout mMessageDetailUserRl;
@BindView(R.id.message_detail_comment_rl)
RelativeLayout mMessageDetailCommentRl;
@BindView(R.id.comment_user_icon)
SimpleDraweeView mMessageDetailIconDv;
@BindView(R.id.comment_user_name)
TextView mMessageDetailUserNameTv;
@BindView(R.id.comment_send)
TextView mMessageDetailCommentSend;
@BindView(R.id.message_detail_comment_et)
EditText mMessageDetailEt;
@BindView(R.id.message_detail_comment_hint_rl)
RelativeLayout mMessageDetailCommentHintRl;
@BindView(R.id.message_detail_sv)
ScrollView mMessageDetailSv;
@BindView(R.id.message_detail_hint_line)
View mMessageDetailLine;
@BindView(R.id.reuse_no_connection)
LinearLayout mNoConnection;
@BindView(R.id.message_detail_close_comment)
View mColseCommentV;
private LinearLayoutManager mLayoutManager;
private MessageDetailAdapter adapter;
private Dialog mSendingDialog;
private ConcernEntity mConcernEntity;
private CommentEntity mCommentEntity; // 回复评论的实体 用完马上清空
private UserInfoEntity mUserInfo;
private String newsId;
private int commentNum = -1; //区分来源 -1资讯关注列表 !=-1 :新闻详情
private TextWatcher watcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (s.toString().trim().length() > 0) {
mMessageDetailCommentSend.setEnabled(true);
if (s.length() > 140) {
mMessageDetailEt.setText("");
String newText = s.toString().substring(0, 140);
mMessageDetailEt.setText(newText);
Utils.toast(MessageDetailActivity.this, "评论不能多于140字");
}
} else {
mMessageDetailCommentSend.setEnabled(false);
}
}
@Override
public void afterTextChanged(Editable s) {
}
};
@Deprecated
public class MessageDetailActivity extends CommonActivity {
// 评论回复
public static Intent getMessageDetailIntent(Context context, CommentEntity entity, String newsId) {
@ -139,14 +23,22 @@ public class MessageDetailActivity extends BaseActivity implements OnCommentCall
intent.putExtra(EntranceUtils.KEY_NEWSID, newsId);
intent.putExtra("openSoftInput", true);
intent.putExtra(CommentEntity.TAG, entity);
return intent;
return new IntentFactory.Builder(context)
.setArgs(intent.getExtras())
.setActivity(MessageDetailActivity.class)
.setFragment(CommentDetailFragment.class).build();
}
public static Intent getIntentByEntity(Context context, ConcernEntity concernEntity, String entrance) {
Intent intent = new Intent(context, MessageDetailActivity.class);
intent.putExtra(ConcernEntity.TAG, concernEntity);
intent.putExtra(EntranceUtils.KEY_ENTRANCE, entrance);
return intent;
// return intent;
return new IntentFactory.Builder(context)
.setArgs(intent.getExtras())
.setActivity(MessageDetailActivity.class)
.setFragment(CommentDetailFragment.class).build();
}
public static Intent getIntentById(Context context, String newsId, Integer commentNum, Boolean openSoftInput, String entrance) {
@ -155,397 +47,11 @@ public class MessageDetailActivity extends BaseActivity implements OnCommentCall
intent.putExtra(EntranceUtils.KEY_ENTRANCE, entrance);
intent.putExtra("commentNum", commentNum);
intent.putExtra("openSoftInput", openSoftInput);
return intent;
// return intent;
return new IntentFactory.Builder(context)
.setArgs(intent.getExtras())
.setActivity(MessageDetailActivity.class)
.setFragment(CommentDetailFragment.class).build();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putParcelable(CommentEntity.TAG, adapter.getConcernEntity());
}
@Override
protected int getLayoutId() {
return R.layout.activity_messagedetail;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
mConcernEntity = intent.getParcelableExtra(ConcernEntity.TAG);
mCommentEntity = intent.getParcelableExtra(CommentEntity.TAG);
newsId = intent.getExtras().getString(EntranceUtils.KEY_NEWSID);
commentNum = intent.getExtras().getInt("commentNum", -1);
//复用问题 mConcernEntity对应的文章有可能和跳转之前的文章不一致
if (mConcernEntity != null && newsId != null && !newsId.equals(mConcernEntity.getId())) {
mConcernEntity = null;
}
setNavigationTitle(getString(R.string.title_message_detail));
adapter = new MessageDetailAdapter(this, this, mMessageDetailRv, mConcernEntity, mEntrance);
mLayoutManager = new LinearLayoutManager(this);
mMessageDetailRv.setLayoutManager(mLayoutManager);
mMessageDetailRv.setAdapter(adapter);
mMessageDetailEt.addTextChangedListener(watcher);
mMessageDetailCommentSend.setEnabled(false);
mMessageDetailRv.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_IDLE
&& !adapter.isOver() && !adapter.isLoading() && mConcernEntity != null
&& mLayoutManager.findLastVisibleItemPosition() == adapter.getItemCount() - 1) {
int offset = adapter.getItemCount() - adapter.getHotCommentListSize() - 3;
if (offset >= 10) { // 防止自动上滑时触发
adapter.addNormalComment(offset);
}
}
}
});
mUserInfo = UserManager.getInstance().getUserInfoEntity();
if (mUserInfo != null) {
ImageUtils.Companion.display(mMessageDetailIconDv, mUserInfo.getIcon());
mMessageDetailUserNameTv.setText(mUserInfo.getName());
}
if (newsId != null && mConcernEntity == null) {
getConcernDigest();
}
if (intent.getExtras().getBoolean("openSoftInput", false)) {//新闻详情的发表评论
setSoftInput(true);
}
}
public void getCommentNum() {
RetrofitManager.getInstance(this).getApi()
.getNewsCommentnum(newsId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new com.gh.gamecenter.retrofit.Response<List<CommentnumEntity>>() {
@Override
public void onResponse(List<CommentnumEntity> response) {
super.onResponse(response);
if (response.size() > 0) {
if (!TextUtils.isEmpty(mConcernEntity.getId())) {
commentNum = response.get(0).getNum();
mConcernEntity.setCommentnum(commentNum);
adapter.notifyItemChanged(0);
}
}
}
});
}
private void getConcernDigest() {
RetrofitManager.getInstance(this).getApi().getNewsRichDigest(newsId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<ConcernEntity>() {
@Override
public void onResponse(ConcernEntity response) {
mConcernEntity = response;
if (commentNum == -1) {
getCommentNum();
} else {
mConcernEntity.setCommentnum(commentNum);
}
adapter.addConcernEntity(mConcernEntity);
adapter.notifyDataSetChanged();
adapter.addHotComment(0);
getNewsViews();
if (commentNum == 0) {
setSoftInput(true);
}
}
@Override
public void onFailure(HttpException e) {
showNoConnection(true);
}
});
}
private void getNewsViews() {
RetrofitManager.getInstance(this).getData()
.getNewsViews(newsId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<List<ViewsEntity>>() {
@Override
public void onResponse(List<ViewsEntity> viewsEntities) {
if (viewsEntities.size() > 0) {
mConcernEntity.setViews(viewsEntities.get(0).getViews());
adapter.notifyItemChanged(0);
}
}
});
}
@OnClick(R.id.message_detail_comment_hint_rl)
public void OnHintClikListener() {
setSoftInput(true);
}
//软键盘控制
private void setSoftInput(boolean isShow) {
if (isShow) {
CheckLoginUtils.checkLogin(this, new CheckLoginUtils.OnLoggenInListener() {
@Override
public void onLoggedIn() {
Util_System_Keyboard.showSoftKeyboard(MessageDetailActivity.this, 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));
}
}
});
} else {
Util_System_Keyboard.hideSoftKeyboard(MessageDetailActivity.this);
mMessageDetailCommentHintRl.setVisibility(View.VISIBLE);
mMessageDetailLine.setVisibility(View.VISIBLE);
mMessageDetailCommentRl.setVisibility(View.GONE);
mMessageDetailUserRl.setVisibility(View.GONE);
mColseCommentV.setVisibility(View.GONE);
if (mCommentEntity != null) {
mCommentEntity = null; // 清空当前评论实体
mMessageDetailEt.setHint(getString(R.string.message_detail_comment_hint));
mMessageDetailEt.setText("");
}
}
}
@OnClick(R.id.actionbar_rl_back)
public void OnBackClikListener() {
if (commentNum != -1 && commentNum != adapter.getConcernEntity().getCommentnum()) {
Intent intent = new Intent();
intent.putExtra("commentNum", adapter.getConcernEntity().getCommentnum());
setResult(1001, intent);
}
finish();
}
@OnTouch(R.id.message_detail_close_comment)
public boolean OnRecyclerTouchListener() {
if (mMessageDetailCommentRl.getVisibility() == View.VISIBLE) {
setSoftInput(false);
}
return true;
}
@OnClick(R.id.comment_send)
public void OnSendCommentListener() {
final String content = mMessageDetailEt.getText().toString();
if (content.length() == 0) {
Utils.toast(MessageDetailActivity.this, "评论内容不能为空!");
return;
}
mSendingDialog = DialogUtils.showWaitDialog(this, getString(R.string.post_dialog_hint));
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("content", content);
} catch (JSONException e) {
e.printStackTrace();
}
if (newsId == null && mConcernEntity == null ||
newsId == null && mConcernEntity.getId() == null) {
Utils.toast(this, "评论异常 id null");
mSendingDialog.cancel();
return;
} else if (newsId == null) {
newsId = mConcernEntity.getId();
}
PostCommentUtils.addCommentData(MessageDetailActivity.this, newsId, jsonObject.toString(), mCommentEntity,
new PostCommentUtils.PostCommentListener() {
@Override
public void postSuccess(JSONObject response) {
mSendingDialog.dismiss();
toast("发表成功");
mMessageDetailEt.setText("");
try {
JSONObject cacheObject = new JSONObject();
JSONObject cacheUser = new JSONObject();
JSONObject userData = new JSONObject();
cacheUser.put("_id", TokenUtils.getDeviceId(MessageDetailActivity.this));
cacheUser.put("icon", mUserInfo.getIcon());
cacheUser.put("name", mUserInfo.getName());
userData.put("is_comment_own", true);
cacheObject.put("_id", response.getString("_id"));
cacheObject.put("content", content);
cacheObject.put("time", System.currentTimeMillis() / 1000);
cacheObject.put("vote", 0);
cacheObject.put("user", cacheUser);
cacheObject.put("user_data", userData);
if (mCommentEntity != null) {
JSONObject cacheParent = new JSONObject();
JSONObject cacheParentUser = new JSONObject();
cacheParentUser.put("_id", mCommentEntity.getId());
cacheParentUser.put("name", mCommentEntity.getUser().getName());
cacheParent.put("user", cacheParentUser);
cacheObject.put("parent", cacheParent);
}
CommentEntity commentEntity = new Gson().fromJson(cacheObject.toString(), CommentEntity.class);
if (mConcernEntity != null) {
adapter.addNormalComment(commentEntity);
}
modifyNewsCommentOkhttpCache(0, cacheObject, newsId);
} catch (JSONException e) {
e.printStackTrace();
}
if (mConcernEntity != null) {
// 完成评论操作,添加评论数
adapter.addCommentCount();
//修改评论缓存
CommentManager.updateOkhttpCacheForId(MessageDetailActivity.this, newsId);
CommentManager.updateOkhttpCache(MessageDetailActivity.this, newsId);
adapter.notifyItemInserted(adapter.getHotCommentListSize() + 2);
adapter.notifyItemChanged(adapter.getItemCount() - 1); //刷新脚布局高度
} else {
showNoConnection(false);
}
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(getString(R.string.comment_failed_toofrequent));
break;
case "user blocked":
toast(getString(R.string.comment_failed_userblocked));
break;
case "article blocked":
toast(getString(R.string.comment_failed_articleblocked));
setSoftInput(false);
break;
case "illegal":
toast(getString(R.string.comment_failed_illegal));
break;
default:
toast(getString(R.string.comment_failed_unknown));
break;
}
} catch (Exception ex) {
ex.printStackTrace();
toast("评论异常");
}
return;
}
}
toast(getString(R.string.post_failure_hint));
}
});
}
private void modifyNewsCommentOkhttpCache(int offset, JSONObject commentData, String id) {
String key = TimestampUtils.addTimestamp(Config.COMMENT_HOST + "article/" + id + "/comment?limit=10&offset=" + offset);
byte[] data = OkHttpCache.getCache(this, key);
if (data != null) {
try {
JSONArray jsonArray = new JSONArray(new String(data));
JSONArray newComment = new JSONArray();
newComment.put(commentData);
for (int i = 0, size = jsonArray.length() > 9 ? 9 : jsonArray.length(); i < size; i++) {
newComment.put(jsonArray.get(i));
}
OkHttpCache.updateCache(this, key, newComment.toString().getBytes());
if (jsonArray.length() == 10) {
modifyNewsCommentOkhttpCache(offset + 10, jsonArray.getJSONObject(9), id);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
private void showNoConnection(boolean isShow) {
if (isShow) {
mNoConnection.setVisibility(View.VISIBLE);
mMessageDetailRv.setVisibility(View.GONE);
} else {
mNoConnection.setVisibility(View.GONE);
mMessageDetailRv.setVisibility(View.VISIBLE);
if (newsId != null) {
getConcernDigest();
}
if (mMessageDetailCommentRl.getVisibility() == View.VISIBLE) {
setSoftInput(false);
}
}
}
// 登录事件
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(EBReuse reuse) {
if (reuse.getType().equals(LOGIN_TAG)) { // 登入
mUserInfo = UserManager.getInstance().getUserInfoEntity();
if (mUserInfo != null) {
ImageUtils.Companion.display(mMessageDetailIconDv, mUserInfo.getIcon());
mMessageDetailUserNameTv.setText(mUserInfo.getName());
}
}
}
@Override
public void onCommentCallback(CommentEntity entity) {
mCommentEntity = entity;
setSoftInput(true);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK)) {
if (commentNum != -1 && adapter.getConcernEntity() != null
&& commentNum != adapter.getConcernEntity().getCommentnum()) {
Intent intent = new Intent();
intent.putExtra("commentNum", adapter.getConcernEntity().getCommentnum());
setResult(1001, intent);
}
}
return super.onKeyDown(keyCode, event);
}
}

View File

@ -39,7 +39,7 @@ import com.gh.common.util.PatternUtils;
import com.gh.gamecenter.entity.InstallGameEntity;
import com.gh.gamecenter.entity.SuggestionTypeEntity;
import com.gh.gamecenter.entity.UserInfoEntity;
import com.gh.gamecenter.fragment.WaitingDialogFragment;
import com.gh.base.fragment.WaitingDialogFragment;
import com.gh.gamecenter.manager.UserManager;
import com.gh.gamecenter.retrofit.JSONObjectResponse;
import com.gh.gamecenter.retrofit.RetrofitManager;

View File

@ -1,5 +1,7 @@
package com.gh.gamecenter.adapter;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.ViewHolder;
@ -13,14 +15,13 @@ import com.gh.common.constant.Config;
import com.gh.common.util.CommentUtils;
import com.gh.common.util.ConcernContentUtils;
import com.gh.common.util.DataCollectionUtils;
import com.gh.gamecenter.DataUtils;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.EntranceUtils;
import com.gh.common.util.ImageUtils;
import com.gh.common.util.NewsUtils;
import com.gh.common.util.StringUtils;
import com.gh.common.util.TimestampUtils;
import com.gh.gamecenter.MessageDetailActivity;
import com.gh.gamecenter.DataUtils;
import com.gh.gamecenter.NewsDetailActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.ShareCardPicActivity;
@ -82,7 +83,7 @@ public class MessageDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
private boolean isGetRvHeight = true; // 防止评论时弹出软键盘 影响RecyclerView高度
private int rvHeight;
public MessageDetailAdapter(MessageDetailActivity context, OnCommentCallBackListener listener,
public MessageDetailAdapter(Activity context, OnCommentCallBackListener listener,
RecyclerView messageDetailRv, ConcernEntity concernEntity, String entrance) {
super(context);
mRecyclerView = messageDetailRv;

View File

@ -1,14 +1,26 @@
package com.gh.gamecenter.adapter.viewholder;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.gh.common.util.DetailDownloadUtils;
import com.lightgame.download.DownloadEntity;
import com.gh.common.util.DialogUtils;
import com.gh.common.util.NetworkUtils;
import com.gh.common.util.PackageUtils;
import com.gh.common.util.StringUtils;
import com.gh.common.view.DownloadDialog;
import com.gh.download.DownloadManager;
import com.gh.gamecenter.DataUtils;
import com.gh.gamecenter.DownloadManagerActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.GameEntity;
import com.lightgame.download.DownloadEntity;
import com.lightgame.download.FileUtils;
import com.lightgame.utils.Utils;
/**
* Created by khy on 27/06/17.
@ -47,8 +59,101 @@ public class DetailViewHolder {
this.isNewsDetail = isNewsDetail;
this.context = view.getContext();
downloadTv.setOnClickListener(new DetailDownloadUtils.OnDetailDownloadClickListener(this, entrance, name, title));
downloadPb.setOnClickListener(new DetailDownloadUtils.OnDetailDownloadClickListener(this, entrance, name, title));
downloadPer.setOnClickListener(new DetailDownloadUtils.OnDetailDownloadClickListener(this, entrance, name, title));
final OnDetailDownloadClickListener listener = new OnDetailDownloadClickListener(this, entrance, name, title);
downloadTv.setOnClickListener(listener);
downloadPb.setOnClickListener(listener);
downloadPer.setOnClickListener(listener);
}
static class OnDetailDownloadClickListener implements View.OnClickListener {
private DetailViewHolder mViewHolder;
private GameEntity mGameEntity;
private DownloadEntity mDownloadEntity;
private String mEntrance;
private String mName;
private String mTitle;
public OnDetailDownloadClickListener(DetailViewHolder viewHolder, String entrance, String name, String title) {
mViewHolder = viewHolder;
mGameEntity = viewHolder.gameEntity;
mDownloadEntity = viewHolder.downloadEntity;
mEntrance = entrance;
mName = name;
mTitle = title;
}
@Override
public void onClick(View v) {
if (v == mViewHolder.downloadTv) {
if (mGameEntity != null && !mGameEntity.getApk().isEmpty()) {
if (mGameEntity.getApk().size() == 1) {
String str = mViewHolder.downloadTv.getText().toString();
if (str.contains("启动")) {
DataUtils.onGameLaunchEvent(mViewHolder.context, mGameEntity.getName(), mGameEntity.getApk().get(0).getPlatform(), mName);
PackageUtils.launchApplicationByPackageName(mViewHolder.context, mGameEntity.getApk().get(0).getPackageName());
} else if (NetworkUtils.isWifiConnected(mViewHolder.context)) {
download();
} else {
DialogUtils.showDownloadDialog(mViewHolder.context, new DialogUtils.ConfirmListener() {
@Override
public void onConfirm() {
download();
}
});
}
} else {
DownloadDialog.getInstance(mViewHolder.context)
.showPopupWindow(v, mGameEntity, StringUtils.buildString(mEntrance, "+(", mName, "[", mTitle, "])"), mName + ":" + mTitle);
}
} else {
Utils.toast(mViewHolder.context, "稍等片刻~!游戏正在上传中...");
}
} else if (v == mViewHolder.downloadPb || v == mViewHolder.downloadPer) {
String str = mViewHolder.downloadPer.getText().toString();
if ("下载中".equals(str)) {
Intent intent = DownloadManagerActivity.getDownloadMangerIntent(mViewHolder.context,
mGameEntity.getApk().get(0).getUrl(), StringUtils.buildString(mEntrance, "+(", mName, "[", mTitle, "])"));
mViewHolder.context.startActivity(intent);
} else if ("安装".equals(str)) {
if (mDownloadEntity == null) {
mDownloadEntity = DownloadManager.getInstance(mViewHolder.context).getDownloadEntityByUrl(mGameEntity.getApk().get(0).getUrl());
}
if (mDownloadEntity != null) {
PackageUtils.launchSetup(mViewHolder.context, mDownloadEntity.getPath());
}
}
}
}
private void download() {
String str = mViewHolder.downloadTv.getText().toString();
String method;
if (str.contains("更新")) {
method = "更新";
} else if (str.contains("插件化")) {
method = "插件化";
} else {
method = mViewHolder.context.getString(R.string.download);
}
ApkEntity apkEntity = mGameEntity.getApk().get(0);
String msg = FileUtils.isCanDownload(mViewHolder.context, apkEntity.getSize());
if (TextUtils.isEmpty(msg)) {
DataUtils.onGameDownloadEvent(mViewHolder.context, mGameEntity.getName(), apkEntity.getPlatform(), StringUtils.buildString(mEntrance, "+(", mName, "[", mTitle, "])"), "下载开始");
DownloadManager.createDownload(mViewHolder.context, apkEntity, mGameEntity, method, StringUtils.buildString(mEntrance, "+(", mName, "[", mTitle, "])"), mName + ":" + mTitle);
mViewHolder.downloadTv.setVisibility(View.GONE);
mViewHolder.downloadPb.setVisibility(View.VISIBLE);
mViewHolder.downloadPer.setVisibility(View.VISIBLE);
mViewHolder.downloadPb.setProgress(0);
mViewHolder.downloadPer.setText("0.0%");
// DownloadManager.getInstance(mViewHolder.context).putStatus(apkEntity.getUrl(), "downloading");
} else {
Utils.toast(mViewHolder.context, msg);
}
}
}
}

View File

@ -21,7 +21,7 @@ import android.widget.TextView;
import com.gh.base.fragment.BaseFragment;
import com.gh.common.util.ImageUtils;
import com.gh.gamecenter.R;
import com.gh.gamecenter.fragment.WaitingDialogFragment;
import com.gh.base.fragment.WaitingDialogFragment;
import com.lightgame.utils.Utils;
import org.jetbrains.annotations.NotNull;

View File

@ -12,8 +12,8 @@ import com.gh.gamecenter.ask.AskFragment;
import com.gh.gamecenter.eventbus.EBReuse;
import com.gh.gamecenter.eventbus.EBSkip;
import com.gh.gamecenter.eventbus.EBUISwitch;
import com.gh.gamecenter.message.MessageFragment;
import com.gh.gamecenter.news.NewsWrapperFragment;
import com.gh.gamecenter.message.MessageCenterFragment;
import com.gh.gamecenter.info.InfoToolWrapperFragment;
import com.gh.gamecenter.personal.PersonalFragment;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
@ -39,8 +39,7 @@ import static com.gh.gamecenter.MainActivity.EB_SKIP_GAMEFRAGMENT;
* @Time 3:26 PM
*/
public class MainFragment extends BaseFragment_ViewPager_Checkable {
public class MainWrapperFragment extends BaseFragment_ViewPager_Checkable {
@BindView(R.id.main_iv_message_hint)
View mMessageHintIv;
@ -70,7 +69,7 @@ public class MainFragment extends BaseFragment_ViewPager_Checkable {
protected void initFragmentList(List<Fragment> fragments) {
fragments.add(new GameWrapperFragment());
fragments.add(new AskFragment());
fragments.add(new NewsWrapperFragment());
fragments.add(new InfoToolWrapperFragment());
fragments.add(new PersonalFragment());
}
@ -133,7 +132,7 @@ public class MainFragment extends BaseFragment_ViewPager_Checkable {
// 控制 我的光环消息未读红点
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(EBReuse reuse) {
if (MessageFragment.MESSAGE_READ_OVER.equals(reuse.getType())) { // 消息阅读完成
if (MessageCenterFragment.MESSAGE_READ_OVER.equals(reuse.getType())) { // 消息阅读完成
if (mMessageHintIv != null) {
mMessageHintIv.setVisibility(View.GONE);
}

View File

@ -1,4 +1,4 @@
package com.gh.gamecenter.news;
package com.gh.gamecenter.info;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
@ -56,7 +56,7 @@ import rx.schedulers.Schedulers;
* Created by khy on 2016/8/15.
* 资讯-关注-数据适配器
*/
public class News2FragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
class ConcernAdapter extends BaseRecyclerAdapter<ViewHolder> {
private OnRequestCallBackListener listener;
private OnListClickListener mListListener;
@ -72,7 +72,7 @@ public class News2FragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
private boolean isOver;
private boolean isNetworkError;
public News2FragmentAdapter(Context context, OnRequestCallBackListener listener, OnListClickListener mistListener) {
ConcernAdapter(Context context, OnRequestCallBackListener listener, OnListClickListener mistListener) {
super(context);
this.listener = listener;
this.mListListener = mistListener;

View File

@ -1,5 +1,6 @@
package com.gh.gamecenter.news;
package com.gh.gamecenter.info;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
@ -72,7 +73,7 @@ import rx.schedulers.Schedulers;
* Created by khy on 2016/8/15.
* 资讯-关注界面
*/
public class News2Fragment extends BaseFragment implements SwipeRefreshLayout.OnRefreshListener {
public class ConcernFragment extends BaseFragment implements SwipeRefreshLayout.OnRefreshListener {
@BindView(R.id.news1_srl_refresh)
SwipeRefreshLayout refreshLayout;
@ -89,30 +90,30 @@ public class News2Fragment extends BaseFragment implements SwipeRefreshLayout.On
@BindView(R.id.news1_ll_concern)
LinearLayout concernLayout;
@BindView(R.id.news1_ll_concern_list)
LinearLayout concernListLayout;
ViewGroup concernListLayout;
public final static int NEWS2_LIBAO_REQUEST = 3; // 刷新礼包状态
public final static int NEWS2_ARTICLE_REQUEST = 4; // 刷新文章评论数
public final static int NEWS_MESSAGE_LIBAO_REQUEST = 3; // 刷新礼包状态
public final static int NEWS_MESSAGE_ARTICLE_REQUEST = 4; // 刷新文章评论数
private News2FragmentAdapter adapter;
private ConcernAdapter mAdapter;
private LinearLayoutManager layoutManager;
private List<GameEntity> recommendGameList; // 推荐关注的游戏
private List<GameEntity> installGameList; // 安装的游戏
private Map<Integer, Boolean> concernMap; // 记录选择关注
private InstallManager mInstallManager;
Runnable runnable = new Runnable() {
Runnable mRunnable = new Runnable() {
@Override
public void run() {
adapter = new News2FragmentAdapter(getContext(), News2Fragment.this, News2Fragment.this);
recyclerView.setAdapter(adapter);
adapter.addList(0);
mAdapter = new ConcernAdapter(getContext(), ConcernFragment.this, ConcernFragment.this);
recyclerView.setAdapter(mAdapter);
mAdapter.addList(0);
}
};
@Override
protected int getLayoutId() {
return R.layout.fragment_news2;
return R.layout.fragment_info_concern;
}
@Override
@ -131,15 +132,15 @@ public class News2Fragment extends BaseFragment implements SwipeRefreshLayout.On
layoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(layoutManager);
recyclerView.addItemDecoration(new VerticalItemDecoration(getContext(), 8, true));
adapter = new News2FragmentAdapter(getContext(), this, this);
recyclerView.setAdapter(adapter);
mAdapter = new ConcernAdapter(getContext(), this, this);
recyclerView.setAdapter(mAdapter);
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_IDLE
&& layoutManager.findLastVisibleItemPosition() + 1 == adapter.getItemCount()) {
if (!adapter.isOver() && !adapter.isLoading() && !adapter.isNetworkError()) {
adapter.addList(adapter.getConcernListSize());
&& layoutManager.findLastVisibleItemPosition() + 1 == mAdapter.getItemCount()) {
if (!mAdapter.isOver() && !mAdapter.isLoading() && !mAdapter.isNetworkError()) {
mAdapter.addList(mAdapter.getConcernListSize());
}
}
}
@ -382,6 +383,7 @@ public class News2Fragment extends BaseFragment implements SwipeRefreshLayout.On
// 判断关注按钮是否可用
private void isConcernAvailable() {
// ???
boolean isEnabled = false;
for (int key : concernMap.keySet()) {
if (concernMap.get(key)) {
@ -389,45 +391,57 @@ public class News2Fragment extends BaseFragment implements SwipeRefreshLayout.On
break;
}
}
concern.setEnabled(isEnabled);
//TODO make selector
if (isEnabled) {
concern.setTextColor(ContextCompat.getColor(getContext(), R.color.theme));
concern.setEnabled(true);
} else {
concern.setTextColor(ContextCompat.getColor(getContext(), R.color.btn_pause));
concern.setEnabled(false);
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == NEWS2_ARTICLE_REQUEST && adapter.getSkipPosition() != -1) {
// 更新对应位置
adapter.notifyItemChanged(adapter.getSkipPosition());
adapter.setSkipPosition(-1);
} else if (requestCode == NEWS2_LIBAO_REQUEST && resultCode == NEWS2_LIBAO_REQUEST && adapter.getSkipPosition() != -1) {
UserDataLibaoEntity resultUserLibaoData = data.getParcelableExtra(UserDataLibaoEntity.TAG);
ConcernEntity skipEntity = adapter.getSkipEntity();
if (skipEntity != null) { // 插入礼包详情返回的礼包数据
UserDataEntity userData = skipEntity.getUserData();
if (userData == null) {
userData = new UserDataEntity();
ArrayList<UserDataLibaoEntity> libaoList = new ArrayList<>();
libaoList.add(resultUserLibaoData);
userData.setUserDataLibaoList(libaoList);
} else {
if (userData.getUserDataLibaoList() == null) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode != Activity.RESULT_OK || mAdapter.getSkipPosition() == -1) {
return;
}
switch (requestCode) {
case NEWS_MESSAGE_ARTICLE_REQUEST:
// 更新对应位置
mAdapter.notifyItemChanged(mAdapter.getSkipPosition());
mAdapter.setSkipPosition(-1);
break;
case NEWS_MESSAGE_LIBAO_REQUEST:
UserDataLibaoEntity resultUserLibaoData = data.getParcelableExtra(UserDataLibaoEntity.TAG);
ConcernEntity skipEntity = mAdapter.getSkipEntity();
if (skipEntity != null) { // 插入礼包详情返回的礼包数据
UserDataEntity userData = skipEntity.getUserData();
if (userData == null) {
userData = new UserDataEntity();
ArrayList<UserDataLibaoEntity> libaoList = new ArrayList<>();
libaoList.add(resultUserLibaoData);
userData.setUserDataLibaoList(libaoList);
} else {
userData.getUserDataLibaoList().add(resultUserLibaoData);
if (userData.getUserDataLibaoList() == null) {
ArrayList<UserDataLibaoEntity> libaoList = new ArrayList<>();
libaoList.add(resultUserLibaoData);
userData.setUserDataLibaoList(libaoList);
} else {
userData.getUserDataLibaoList().add(resultUserLibaoData);
}
}
skipEntity.setUserData(userData); // 要重新设回去 不然没效果 0.0
}
skipEntity.setUserData(userData); // 要重新设回去 不然没效果 0.0
}
adapter.notifyItemChanged(adapter.getSkipPosition());
adapter.setSkipPosition(-1);
mAdapter.notifyItemChanged(mAdapter.getSkipPosition());
mAdapter.setSkipPosition(-1);
break;
}
}
@OnClick(R.id.news1_tv_concern)
@ -457,10 +471,10 @@ public class News2Fragment extends BaseFragment implements SwipeRefreshLayout.On
if (busNetworkState.isNetworkConnected()) {
if (noConnectionLayout.getVisibility() == View.VISIBLE) {
reconnection();
} else if (adapter.isNetworkError()) {
adapter.setNetworkError(false);
adapter.notifyItemChanged(adapter.getItemCount() - 1);
adapter.addList(adapter.getConcernListSize());
} else if (mAdapter.isNetworkError()) {
mAdapter.setNetworkError(false);
mAdapter.notifyItemChanged(mAdapter.getItemCount() - 1);
mAdapter.addList(mAdapter.getConcernListSize());
}
}
}
@ -471,16 +485,16 @@ public class News2Fragment extends BaseFragment implements SwipeRefreshLayout.On
recyclerView.setVisibility(View.VISIBLE);
loadingLayout.setVisibility(View.VISIBLE);
noConnectionLayout.setVisibility(View.GONE);
postDelayedRunnable(runnable, 1000);
postDelayedRunnable(mRunnable, 1000);
}
// Fragment界面切换事件
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(EBUISwitch swith) {
if (NewsWrapperFragment.EB_NEWSFRAGMENT_TAG.equals(swith.getFrom())) {
if (InfoToolWrapperFragment.EB_NEWSFRAGMENT_TAG.equals(swith.getFrom())) {
if (swith.getPosition() == 1) {
if (loadingLayout.getVisibility() == View.VISIBLE) {
adapter.addList(0);
mAdapter.addList(0);
}
}
}
@ -494,14 +508,14 @@ public class News2Fragment extends BaseFragment implements SwipeRefreshLayout.On
refreshLayout.setRefreshing(true);
recyclerView.setVisibility(View.VISIBLE);
loadingLayout.setVisibility(View.VISIBLE);
adapter = new News2FragmentAdapter(getContext(), this, this);
recyclerView.setAdapter(adapter);
adapter.addList(0);
mAdapter = new ConcernAdapter(getContext(), this, this);
recyclerView.setAdapter(mAdapter);
mAdapter.addList(0);
}
@Override
public void onRefresh() {
postDelayedRunnable(runnable, 1000);
postDelayedRunnable(mRunnable, 1000);
}
@Override
@ -509,13 +523,15 @@ public class News2Fragment extends BaseFragment implements SwipeRefreshLayout.On
super.onListClick(view, position, data);
List<ConcernEntity> concernList = (List<ConcernEntity>) data;
ConcernEntity concernEntity = concernList.get(position);
final String entrance = StringUtils.buildString("(资讯:关注[" + position + "])");
Intent intent;
switch (view.getId()) {
case R.id.news_digest_comment:
adapter.setSkipPosition(position);
intent = MessageDetailActivity.getIntentByEntity(getContext(), concernEntity,
StringUtils.buildString("(资讯:关注[" + position + "])"));
startActivityForResult(intent, NEWS2_ARTICLE_REQUEST);
mAdapter.setSkipPosition(position);
intent = MessageDetailActivity.getIntentByEntity(getContext(), concernEntity, entrance);
startActivityForResult(intent, NEWS_MESSAGE_ARTICLE_REQUEST);
break;
case R.id.news_digest_share:
String shareContent;
@ -525,24 +541,22 @@ public class News2Fragment extends BaseFragment implements SwipeRefreshLayout.On
shareContent = concernEntity.getContent();
}
if (concernEntity.getImg() != null && concernEntity.getImg().size() > 0) {
ShareCardPicActivity.startShareCardPicActivity(getContext(), concernEntity,
StringUtils.buildString("(资讯:关注[" + position + "])"));
ShareCardPicActivity.startShareCardPicActivity(getContext(), concernEntity, entrance);
} else {
startActivity(ShareCardActivity.getIntent(getContext(), concernEntity, shareContent));
}
break;
default: // 默认是 viewholder item
mAdapter.setSkipPosition(position);
if ("libao".equals(concernEntity.getType())) {
LibaoEntity entity = null;
for (LibaoStatusEntity libaoStatusEntity : adapter.getLibaoStatusList()) {
for (LibaoStatusEntity libaoStatusEntity : mAdapter.getLibaoStatusList()) {
if (concernEntity.getId().equals(libaoStatusEntity.getId())) {
entity = LibaoEntity.Companion.createLibaoEntity(concernEntity, libaoStatusEntity);
}
}
adapter.setSkipPosition(position);
intent = LibaoDetailActivity.getIntent(getContext(), entity,
StringUtils.buildString("(资讯:关注[" + position + "])"));
startActivityForResult(intent, NEWS2_LIBAO_REQUEST);
intent = LibaoDetailActivity.getIntent(getContext(), entity, entrance);
startActivityForResult(intent, NEWS_MESSAGE_LIBAO_REQUEST);
} else {
Map<String, Object> kv = new HashMap<>();
kv.put("名字", concernEntity.getTitle());
@ -552,18 +566,13 @@ public class News2Fragment extends BaseFragment implements SwipeRefreshLayout.On
DataCollectionUtils.uploadClick(getContext(), "列表", "资讯-关注", concernEntity.getTitle());
//统计阅读量
adapter.statNewsViews(concernEntity, position);
//TODO ??? 这个有毛用先注释了
// HaloApp.put("ConcernEntity", concernEntity);
adapter.setSkipPosition(position);
mAdapter.statNewsViews(concernEntity, position);
if (concernEntity.getLink() != null) {
intent = WebActivity.getIntentByNews(getContext(), concernEntity,
StringUtils.buildString("(资讯:关注[" + position + "])"));
startActivityForResult(intent, NEWS2_ARTICLE_REQUEST);
intent = WebActivity.getIntentByNews(getContext(), concernEntity, entrance);
startActivityForResult(intent, NEWS_MESSAGE_ARTICLE_REQUEST);
} else {
intent = NewsDetailActivity.getIntentById(getContext(), concernEntity.getId()
, StringUtils.buildString("(资讯:关注[" + position + "])"));
startActivityForResult(intent, NEWS2_ARTICLE_REQUEST);
intent = NewsDetailActivity.getIntentById(getContext(), concernEntity.getId(), entrance);
startActivityForResult(intent, NEWS_MESSAGE_ARTICLE_REQUEST);
}
}
break;

View File

@ -1,4 +1,4 @@
package com.gh.gamecenter.news;
package com.gh.gamecenter.info;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
@ -49,7 +49,7 @@ import rx.schedulers.Schedulers;
* Created by khy on 2016/6/30.
* 资讯-资讯-数据适配器
*/
public class News1FragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
class InfoAdapter extends BaseRecyclerAdapter<ViewHolder> {
private OnRequestCallBackListener listener;
private OnListClickListener mListListener;
@ -62,7 +62,7 @@ public class News1FragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
private boolean isOver;
private boolean isNetworkError;
public News1FragmentAdapter(Context context, OnRequestCallBackListener listener, OnListClickListener listListener) {
InfoAdapter(Context context, OnRequestCallBackListener listener, OnListClickListener listListener) {
super(context);
this.mListListener = listListener;
this.listener = listener;

View File

@ -1,4 +1,4 @@
package com.gh.gamecenter.news;
package com.gh.gamecenter.info;
import android.os.Bundle;
import android.support.annotation.Nullable;
@ -34,24 +34,24 @@ import butterknife.OnClick;
* Created by LGT on 2016/6/29.
* 资讯-资讯界面
*/
public class News1Fragment extends BaseFragment implements SwipeRefreshLayout.OnRefreshListener {
public class InfoFragment extends BaseFragment implements SwipeRefreshLayout.OnRefreshListener {
@BindView(R.id.news2_srl_refresh)
@BindView(R.id.info_srl_refresh)
SwipeRefreshLayout refreshLayout;
@BindView(R.id.news2_rv_list)
@BindView(R.id.info_rv_list)
RecyclerView recyclerView;
@BindView(R.id.news2_pb_loading)
@BindView(R.id.info_pb_loading)
ProgressBarCircularIndeterminate loadingLayout;
@BindView(R.id.reuse_no_connection)
LinearLayout noConnectionLayout;
private LinearLayoutManager layoutManager;
private News1FragmentAdapter adapter;
private InfoAdapter adapter;
Runnable runnable = new Runnable() {
@Override
public void run() {
adapter = new News1FragmentAdapter(getContext(), News1Fragment.this, News1Fragment.this);
adapter = new InfoAdapter(getContext(), InfoFragment.this, InfoFragment.this);
recyclerView.setAdapter(adapter);
adapter.addList(0);
}
@ -59,7 +59,7 @@ public class News1Fragment extends BaseFragment implements SwipeRefreshLayout.On
@Override
protected int getLayoutId() {
return R.layout.fragment_news1;
return R.layout.fragment_info_info;
}
@Override
@ -73,7 +73,7 @@ public class News1Fragment extends BaseFragment implements SwipeRefreshLayout.On
layoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(layoutManager);
recyclerView.addItemDecoration(new VerticalItemDecoration(getContext(), 8, true));
adapter = new News1FragmentAdapter(getContext(), this, this);
adapter = new InfoAdapter(getContext(), this, this);
recyclerView.setAdapter(adapter);
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
@ -128,7 +128,7 @@ public class News1Fragment extends BaseFragment implements SwipeRefreshLayout.On
// 资讯Fragment界面切换事件
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(EBUISwitch busNine) {
if (NewsWrapperFragment.EB_NEWSFRAGMENT_TAG.equals(busNine.getFrom())) {
if (InfoToolWrapperFragment.EB_NEWSFRAGMENT_TAG.equals(busNine.getFrom())) {
if (busNine.getPosition() == 0) {
if (loadingLayout.getVisibility() == View.VISIBLE) {
adapter.addList(0);

View File

@ -1,4 +1,4 @@
package com.gh.gamecenter.news;
package com.gh.gamecenter.info;
import android.os.Bundle;
import android.support.annotation.Nullable;
@ -14,11 +14,11 @@ import java.util.ArrayList;
/**
* Created by khy on 2016/6/29.
* 资讯Fragment
* 资讯Infopager Fragment包裹着其他资讯类的模块
*/
public class NewsWrapperFragment extends BaseFragment implements SearchBarHint {
public class InfoToolWrapperFragment extends BaseFragment implements SearchBarHint {
public final static String EB_NEWSFRAGMENT_TAG = "NewsWrapperFragment";
public final static String EB_NEWSFRAGMENT_TAG = "InfoWrapperFragment";
private SearchToolbarFragment mSearchToolbarFragment;
@ -38,7 +38,7 @@ public class NewsWrapperFragment extends BaseFragment implements SearchBarHint {
super.onViewCreated(view, savedInstanceState);
getChildFragmentManager().beginTransaction()
.replace(R.id.wrapper_toolbar, mSearchToolbarFragment)
.replace(R.id.wrapper_main_content, new NewsFragment()).commitAllowingStateLoss();
.replace(R.id.wrapper_main_content, new InfoWrapperFragment()).commitAllowingStateLoss();
}
@Override

View File

@ -1,4 +1,4 @@
package com.gh.gamecenter.news;
package com.gh.gamecenter.info;
import android.os.Bundle;
import android.support.annotation.Nullable;
@ -24,27 +24,33 @@ import java.util.List;
import butterknife.BindView;
import static com.gh.gamecenter.news.NewsWrapperFragment.EB_NEWSFRAGMENT_TAG;
import static com.gh.gamecenter.info.InfoToolWrapperFragment.EB_NEWSFRAGMENT_TAG;
/**
* @author CsHeng
* @Date 17/06/2017
* @Time 10:30 AM
* <p>
* 包裹着各种资讯的pager fragment
*/
public class NewsFragment extends BaseFragment_ViewPager_Checkable {
public class InfoWrapperFragment extends BaseFragment_ViewPager_Checkable {
@BindView(R.id.slidebar_line)
View mNewsSlidebarLine;
@BindView(R.id.news_gonglve_tv)
CheckedTextView mGongLveTv;
public static final int INDEX_INFO = 0;
public static final int INDEX_CONCERN = 1;
public static final int INDEX_STRATEGY = 2;
public static final int INDEX_ORIGINAL = 3;
private LinearLayout.LayoutParams mLayoutParams;
private int mWidth;
@Override
protected int getLayoutId() {
return R.layout.fragment_news;
return R.layout.fragment_info_wrapper;
}
@Override
@ -64,10 +70,10 @@ public class NewsFragment extends BaseFragment_ViewPager_Checkable {
@Override
protected void initFragmentList(List<Fragment> fragments) {
fragments.add(new News1Fragment());
fragments.add(new News2Fragment());
fragments.add(new News3Fragment());
fragments.add(new News4Fragment());
fragments.add(new InfoFragment());
fragments.add(new ConcernFragment());
fragments.add(new StrategyFragment());
fragments.add(new OriginalFragment());
}
@Override

View File

@ -1,4 +1,4 @@
package com.gh.gamecenter.news;
package com.gh.gamecenter.info;
import com.gh.gamecenter.entity.GameEntity;

View File

@ -1,4 +1,4 @@
package com.gh.gamecenter.news;
package com.gh.gamecenter.info;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
@ -49,7 +49,7 @@ import rx.schedulers.Schedulers;
* Created by khy on 2016/6/30.
* 资讯-原创-数据适配器
*/
public class News4FragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
class OriginalAdapter extends BaseRecyclerAdapter<ViewHolder> {
private OnRequestCallBackListener listener;
private OnListClickListener mListListener;
@ -62,7 +62,7 @@ public class News4FragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
private boolean isOver;
private boolean isNetworkError;
public News4FragmentAdapter(Context context, OnRequestCallBackListener listener, OnListClickListener listListener) {
OriginalAdapter(Context context, OnRequestCallBackListener listener, OnListClickListener listListener) {
super(context);
this.listener = listener;
this.mListListener = listListener;

View File

@ -1,4 +1,4 @@
package com.gh.gamecenter.news;
package com.gh.gamecenter.info;
import android.os.Bundle;
import android.support.annotation.Nullable;
@ -34,24 +34,24 @@ import butterknife.OnClick;
* Created by khy on 2016/6/29.
* 资讯-原创界面
*/
public class News4Fragment extends BaseFragment implements SwipeRefreshLayout.OnRefreshListener {
public class OriginalFragment extends BaseFragment implements SwipeRefreshLayout.OnRefreshListener {
@BindView(R.id.news3_srl_refresh)
@BindView(R.id.original_srl_refresh)
SwipeRefreshLayout refreshLayout;
@BindView(R.id.news3_rv_list)
@BindView(R.id.original_rv_list)
RecyclerView recyclerView;
@BindView(R.id.news3_pb_loading)
@BindView(R.id.original_pb_loading)
ProgressBarCircularIndeterminate loadingLayout;
@BindView(R.id.reuse_no_connection)
LinearLayout noConnectionLayout;
private LinearLayoutManager layoutManager;
private News4FragmentAdapter adapter;
private OriginalAdapter adapter;
Runnable runnable = new Runnable() {
@Override
public void run() {
adapter = new News4FragmentAdapter(getContext(), News4Fragment.this, News4Fragment.this);
adapter = new OriginalAdapter(getContext(), OriginalFragment.this, OriginalFragment.this);
recyclerView.setAdapter(adapter);
adapter.addList(0);
}
@ -59,7 +59,7 @@ public class News4Fragment extends BaseFragment implements SwipeRefreshLayout.On
@Override
protected int getLayoutId() {
return R.layout.fragment_news4;
return R.layout.fragment_info_original;
}
@Override
@ -72,7 +72,7 @@ public class News4Fragment extends BaseFragment implements SwipeRefreshLayout.On
recyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(layoutManager);
adapter = new News4FragmentAdapter(getContext(), this, this);
adapter = new OriginalAdapter(getContext(), this, this);
recyclerView.addItemDecoration(new VerticalItemDecoration(getContext(), 8, true));
recyclerView.setAdapter(adapter);
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@ -128,7 +128,7 @@ public class News4Fragment extends BaseFragment implements SwipeRefreshLayout.On
// 资讯Fragment界面切换事件
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(EBUISwitch busNine) {
if (NewsWrapperFragment.EB_NEWSFRAGMENT_TAG.equals(busNine.getFrom())) {
if (InfoToolWrapperFragment.EB_NEWSFRAGMENT_TAG.equals(busNine.getFrom())) {
if (busNine.getPosition() == 3) {
if (loadingLayout.getVisibility() == View.VISIBLE) {
adapter.addList(0);

View File

@ -1,4 +1,4 @@
package com.gh.gamecenter.news;
package com.gh.gamecenter.info;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
@ -30,7 +30,7 @@ import rx.schedulers.Schedulers;
* Created by khy on 2017/4/7.
* 资讯-攻略适配器
*/
public class News3FragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
class StrategyAdapter extends BaseRecyclerAdapter<ViewHolder> {
private OnRequestCallBackListener mCallBackListener;
private OnListClickListener mListListener;
@ -41,7 +41,7 @@ public class News3FragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
private boolean isLoading;
private boolean isNetworkError;
public News3FragmentAdapter(Context context, OnRequestCallBackListener callBackListener, OnListClickListener listListener ) {
StrategyAdapter(Context context, OnRequestCallBackListener callBackListener, OnListClickListener listListener ) {
super(context);
this.mCallBackListener = callBackListener;
this.mListListener = listListener;

View File

@ -1,4 +1,4 @@
package com.gh.gamecenter.news;
package com.gh.gamecenter.info;
import android.view.View;
import android.view.ViewGroup;
@ -16,13 +16,13 @@ import java.util.List;
* Created by khy on 2016/12/5.
* 资讯-攻略关注的游戏弹窗适配器
*/
public class News3FragmentDialogAdapter extends BaseRecyclerAdapter<StrategyDialogViewHolder> {
class StrategyDialogAdapter extends BaseRecyclerAdapter<StrategyDialogViewHolder> {
private OnStrategyDialogCallBackListener callBackListener;
private List<GameEntity> mConcernGame;
public News3FragmentDialogAdapter(News3Fragment fragment, List<GameEntity> concernGame) {
StrategyDialogAdapter(StrategyFragment fragment, List<GameEntity> concernGame) {
super(fragment.getContext());
this.callBackListener = fragment;
this.mConcernGame = concernGame;

View File

@ -1,4 +1,4 @@
package com.gh.gamecenter.news;
package com.gh.gamecenter.info;
import android.app.Dialog;
import android.content.Intent;
@ -50,9 +50,9 @@ import rx.schedulers.Schedulers;
/**
* Created by khy on 2017/4/7.
* 资讯-攻略界面
* 资讯-攻略界面,guilds/strategy会比较好
*/
public class News3Fragment extends BaseFragment implements SwipeRefreshLayout.OnRefreshListener,
public class StrategyFragment extends BaseFragment implements SwipeRefreshLayout.OnRefreshListener,
OnStrategyDialogCallBackListener {
@BindView(R.id.strategy_game_name)
@ -74,14 +74,14 @@ public class News3Fragment extends BaseFragment implements SwipeRefreshLayout.On
private Dialog dialog;
private LinearLayoutManager mLayoutManager;
private News3FragmentAdapter mStrategyAdapter;
private StrategyAdapter mStrategyAdapter;
private List<GameEntity> mConcernGame;
Runnable runnable = new Runnable() {
@Override
public void run() {
mStrategyAdapter = new News3FragmentAdapter(getContext(), News3Fragment.this, News3Fragment.this);
mStrategyAdapter = new StrategyAdapter(getContext(), StrategyFragment.this, StrategyFragment.this);
mStrategyRv.setAdapter(mStrategyAdapter);
mStrategyAdapter.addList(0);
}
@ -89,7 +89,7 @@ public class News3Fragment extends BaseFragment implements SwipeRefreshLayout.On
@Override
protected int getLayoutId() {
return R.layout.fragment_news3;
return R.layout.fragment_info_strategy;
}
@Override
@ -101,7 +101,7 @@ public class News3Fragment extends BaseFragment implements SwipeRefreshLayout.On
mSwipeRefreshLayout.setColorSchemeResources(R.color.theme);
mSwipeRefreshLayout.setOnRefreshListener(this);
mStrategyAdapter = new News3FragmentAdapter(getContext(), this, this);
mStrategyAdapter = new StrategyAdapter(getContext(), this, this);
mLayoutManager = new LinearLayoutManager(getContext());
mStrategyRv.setLayoutManager(mLayoutManager);
mStrategyRv.setAdapter(mStrategyAdapter);
@ -176,7 +176,7 @@ public class News3Fragment extends BaseFragment implements SwipeRefreshLayout.On
});
selectGameRv.setLayoutManager(new LinearLayoutManager(getContext()));
selectGameRv.setAdapter(new News3FragmentDialogAdapter(News3Fragment.this, mConcernGame));
selectGameRv.setAdapter(new StrategyDialogAdapter(StrategyFragment.this, mConcernGame));
dialog = new Dialog(getContext());
@ -246,8 +246,8 @@ public class News3Fragment extends BaseFragment implements SwipeRefreshLayout.On
// 资讯Fragment界面切换事件
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(EBUISwitch busNine) {
if (NewsWrapperFragment.EB_NEWSFRAGMENT_TAG.equals(busNine.getFrom())) {
if (busNine.getPosition() == 2 && mLoading.getVisibility() == View.VISIBLE) {
if (InfoToolWrapperFragment.EB_NEWSFRAGMENT_TAG.equals(busNine.getFrom())) {
if (busNine.getPosition() == InfoWrapperFragment.INDEX_STRATEGY && mLoading.getVisibility() == View.VISIBLE) {
mStrategyAdapter.addList(0);
if (!TextUtils.isEmpty(UserManager.getInstance().getToken())) {
getConcernGame();

View File

@ -0,0 +1,516 @@
package com.gh.gamecenter.message;
import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import com.facebook.drawee.view.SimpleDraweeView;
import com.gh.base.fragment.BaseFragment;
import com.gh.common.constant.Config;
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.PostCommentUtils;
import com.gh.common.util.TimestampUtils;
import com.gh.common.util.TokenUtils;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.MessageDetailAdapter;
import com.gh.gamecenter.adapter.OnCommentCallBackListener;
import com.gh.gamecenter.entity.CommentEntity;
import com.gh.gamecenter.entity.CommentnumEntity;
import com.gh.gamecenter.entity.ConcernEntity;
import com.gh.gamecenter.entity.UserInfoEntity;
import com.gh.gamecenter.entity.ViewsEntity;
import com.gh.gamecenter.eventbus.EBReuse;
import com.gh.gamecenter.manager.CommentManager;
import com.gh.gamecenter.manager.UserManager;
import com.gh.gamecenter.retrofit.OkHttpCache;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
import com.google.gson.Gson;
import com.lightgame.listeners.OnBackPressedListener;
import com.lightgame.utils.Util_System_Keyboard;
import com.lightgame.utils.Utils;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.List;
import butterknife.BindView;
import butterknife.OnClick;
import butterknife.OnTouch;
import retrofit2.HttpException;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import static com.gh.gamecenter.personal.PersonalFragment.LOGIN_TAG;
/**
* Created by CsHeng on 18/12/2017.
* 消息详情界面--评论详情
*/
public class CommentDetailFragment extends BaseFragment implements OnCommentCallBackListener, OnBackPressedListener {
@BindView(R.id.message_detail_rv)
RecyclerView mMessageDetailRv;
@BindView(R.id.message_detail_user_rl)
RelativeLayout mMessageDetailUserRl;
@BindView(R.id.message_detail_comment_rl)
RelativeLayout mMessageDetailCommentRl;
@BindView(R.id.comment_user_icon)
SimpleDraweeView mMessageDetailIconDv;
@BindView(R.id.comment_user_name)
TextView mMessageDetailUserNameTv;
@BindView(R.id.comment_send)
TextView mMessageDetailCommentSend;
@BindView(R.id.message_detail_comment_et)
EditText mMessageDetailEt;
@BindView(R.id.message_detail_comment_hint_rl)
RelativeLayout mMessageDetailCommentHintRl;
@BindView(R.id.message_detail_sv)
ScrollView mMessageDetailSv;
@BindView(R.id.message_detail_hint_line)
View mMessageDetailLine;
@BindView(R.id.reuse_no_connection)
LinearLayout mNoConnection;
@BindView(R.id.message_detail_close_comment)
View mColseCommentV;
private LinearLayoutManager mLayoutManager;
private MessageDetailAdapter adapter;
private Dialog mSendingDialog;
private ConcernEntity mConcernEntity;
private CommentEntity mCommentEntity; // 回复评论的实体 用完马上清空
private UserInfoEntity mUserInfo;
private String newsId;
private int commentNum = -1; //区分来源 -1资讯关注列表 !=-1 :新闻详情
private TextWatcher watcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (s.toString().trim().length() > 0) {
mMessageDetailCommentSend.setEnabled(true);
if (s.length() > 140) {
mMessageDetailEt.setText("");
String newText = s.toString().substring(0, 140);
mMessageDetailEt.setText(newText);
Utils.toast(getContext(), "评论不能多于140字");
}
} else {
mMessageDetailCommentSend.setEnabled(false);
}
}
@Override
public void afterTextChanged(Editable s) {
}
};
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putParcelable(CommentEntity.TAG, adapter.getConcernEntity());
}
@Override
protected int getLayoutId() {
return R.layout.fragment_message_detail;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle args = getArguments();
mConcernEntity = args.getParcelable(ConcernEntity.TAG);
mCommentEntity = args.getParcelable(CommentEntity.TAG);
newsId = args.getString(EntranceUtils.KEY_NEWSID);
commentNum = args.getInt("commentNum", -1);
//复用问题 mConcernEntity对应的文章有可能和跳转之前的文章不一致
if (mConcernEntity != null && newsId != null && !newsId.equals(mConcernEntity.getId())) {
mConcernEntity = null;
}
setNavigationTitle(getString(R.string.title_message_detail));
adapter = new MessageDetailAdapter(getActivity(), this, mMessageDetailRv, mConcernEntity, mEntrance);
mLayoutManager = new LinearLayoutManager(getContext());
mMessageDetailRv.setLayoutManager(mLayoutManager);
mMessageDetailRv.setAdapter(adapter);
mMessageDetailEt.addTextChangedListener(watcher);
mMessageDetailCommentSend.setEnabled(false);
mMessageDetailRv.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_IDLE
&& !adapter.isOver() && !adapter.isLoading() && mConcernEntity != null
&& mLayoutManager.findLastVisibleItemPosition() == adapter.getItemCount() - 1) {
int offset = adapter.getItemCount() - adapter.getHotCommentListSize() - 3;
if (offset >= 10) { // 防止自动上滑时触发
adapter.addNormalComment(offset);
}
}
}
});
mUserInfo = UserManager.getInstance().getUserInfoEntity();
if (mUserInfo != null) {
ImageUtils.Companion.display(mMessageDetailIconDv, mUserInfo.getIcon());
mMessageDetailUserNameTv.setText(mUserInfo.getName());
}
if (newsId != null && mConcernEntity == null) {
getConcernDigest();
}
if (args.getBoolean("openSoftInput", false)) {//新闻详情的发表评论
setSoftInput(true);
}
}
public void getCommentNum() {
RetrofitManager.getInstance(getContext()).getApi()
.getNewsCommentnum(newsId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new com.gh.gamecenter.retrofit.Response<List<CommentnumEntity>>() {
@Override
public void onResponse(List<CommentnumEntity> response) {
super.onResponse(response);
if (response.size() > 0) {
if (!TextUtils.isEmpty(mConcernEntity.getId())) {
commentNum = response.get(0).getNum();
mConcernEntity.setCommentnum(commentNum);
adapter.notifyItemChanged(0);
}
}
}
});
}
private void getConcernDigest() {
RetrofitManager.getInstance(getContext()).getApi().getNewsRichDigest(newsId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<ConcernEntity>() {
@Override
public void onResponse(ConcernEntity response) {
mConcernEntity = response;
if (commentNum == -1) {
getCommentNum();
} else {
mConcernEntity.setCommentnum(commentNum);
}
adapter.addConcernEntity(mConcernEntity);
adapter.notifyDataSetChanged();
adapter.addHotComment(0);
getNewsViews();
if (commentNum == 0) {
setSoftInput(true);
}
}
@Override
public void onFailure(HttpException e) {
showNoConnection(true);
}
});
}
private void getNewsViews() {
RetrofitManager.getInstance(getContext()).getData()
.getNewsViews(newsId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<List<ViewsEntity>>() {
@Override
public void onResponse(List<ViewsEntity> viewsEntities) {
if (viewsEntities.size() > 0) {
mConcernEntity.setViews(viewsEntities.get(0).getViews());
adapter.notifyItemChanged(0);
}
}
});
}
@OnClick(R.id.message_detail_comment_hint_rl)
public void OnHintClikListener() {
setSoftInput(true);
}
//软键盘控制
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);
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 {
Util_System_Keyboard.hideSoftKeyboard(getActivity());
mMessageDetailCommentHintRl.setVisibility(View.VISIBLE);
mMessageDetailLine.setVisibility(View.VISIBLE);
mMessageDetailCommentRl.setVisibility(View.GONE);
mMessageDetailUserRl.setVisibility(View.GONE);
mColseCommentV.setVisibility(View.GONE);
if (mCommentEntity != null) {
mCommentEntity = null; // 清空当前评论实体
mMessageDetailEt.setHint(getString(R.string.message_detail_comment_hint));
mMessageDetailEt.setText("");
}
}
}
@OnTouch(R.id.message_detail_close_comment)
public boolean OnRecyclerTouchListener() {
if (mMessageDetailCommentRl.getVisibility() == View.VISIBLE) {
setSoftInput(false);
}
return true;
}
@OnClick(R.id.comment_send)
public void OnSendCommentListener() {
final String content = mMessageDetailEt.getText().toString();
if (content.length() == 0) {
Utils.toast(getContext(), "评论内容不能为空!");
return;
}
mSendingDialog = DialogUtils.showWaitDialog(getContext(), getString(R.string.post_dialog_hint));
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("content", content);
} catch (JSONException e) {
e.printStackTrace();
}
if (newsId == null && mConcernEntity == null ||
newsId == null && mConcernEntity.getId() == null) {
Utils.toast(getContext(), "评论异常 id null");
mSendingDialog.cancel();
return;
} else if (newsId == null) {
newsId = mConcernEntity.getId();
}
PostCommentUtils.addCommentData(getContext(), newsId, jsonObject.toString(), mCommentEntity,
new PostCommentUtils.PostCommentListener() {
@Override
public void postSuccess(JSONObject response) {
mSendingDialog.dismiss();
toast("发表成功");
mMessageDetailEt.setText("");
try {
JSONObject cacheObject = new JSONObject();
JSONObject cacheUser = new JSONObject();
JSONObject userData = new JSONObject();
cacheUser.put("_id", TokenUtils.getDeviceId(getContext()));
cacheUser.put("icon", mUserInfo.getIcon());
cacheUser.put("name", mUserInfo.getName());
userData.put("is_comment_own", true);
cacheObject.put("_id", response.getString("_id"));
cacheObject.put("content", content);
cacheObject.put("time", System.currentTimeMillis() / 1000);
cacheObject.put("vote", 0);
cacheObject.put("user", cacheUser);
cacheObject.put("user_data", userData);
if (mCommentEntity != null) {
JSONObject cacheParent = new JSONObject();
JSONObject cacheParentUser = new JSONObject();
cacheParentUser.put("_id", mCommentEntity.getId());
cacheParentUser.put("name", mCommentEntity.getUser().getName());
cacheParent.put("user", cacheParentUser);
cacheObject.put("parent", cacheParent);
}
CommentEntity commentEntity = new Gson().fromJson(cacheObject.toString(), CommentEntity.class);
if (mConcernEntity != null) {
adapter.addNormalComment(commentEntity);
}
modifyNewsCommentOkhttpCache(0, cacheObject, newsId);
} catch (JSONException e) {
e.printStackTrace();
}
if (mConcernEntity != null) {
// 完成评论操作,添加评论数
adapter.addCommentCount();
//修改评论缓存
CommentManager.updateOkhttpCacheForId(getContext(), newsId);
CommentManager.updateOkhttpCache(getContext(), newsId);
adapter.notifyItemInserted(adapter.getHotCommentListSize() + 2);
adapter.notifyItemChanged(adapter.getItemCount() - 1); //刷新脚布局高度
} else {
showNoConnection(false);
}
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(getString(R.string.comment_failed_toofrequent));
break;
case "user blocked":
toast(getString(R.string.comment_failed_userblocked));
break;
case "article blocked":
toast(getString(R.string.comment_failed_articleblocked));
setSoftInput(false);
break;
case "illegal":
toast(getString(R.string.comment_failed_illegal));
break;
default:
toast(getString(R.string.comment_failed_unknown));
break;
}
} catch (Exception ex) {
ex.printStackTrace();
toast("评论异常");
}
return;
}
}
toast(getString(R.string.post_failure_hint));
}
});
}
private void modifyNewsCommentOkhttpCache(int offset, JSONObject commentData, String id) {
String key = TimestampUtils.addTimestamp(Config.COMMENT_HOST + "article/" + id + "/comment?limit=10&offset=" + offset);
byte[] data = OkHttpCache.getCache(getContext(), key);
if (data != null) {
try {
JSONArray jsonArray = new JSONArray(new String(data));
JSONArray newComment = new JSONArray();
newComment.put(commentData);
for (int i = 0, size = jsonArray.length() > 9 ? 9 : jsonArray.length(); i < size; i++) {
newComment.put(jsonArray.get(i));
}
OkHttpCache.updateCache(getContext(), key, newComment.toString().getBytes());
if (jsonArray.length() == 10) {
modifyNewsCommentOkhttpCache(offset + 10, jsonArray.getJSONObject(9), id);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
private void showNoConnection(boolean isShow) {
if (isShow) {
mNoConnection.setVisibility(View.VISIBLE);
mMessageDetailRv.setVisibility(View.GONE);
} else {
mNoConnection.setVisibility(View.GONE);
mMessageDetailRv.setVisibility(View.VISIBLE);
if (newsId != null) {
getConcernDigest();
}
if (mMessageDetailCommentRl.getVisibility() == View.VISIBLE) {
setSoftInput(false);
}
}
}
// 登录事件
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(EBReuse reuse) {
if (reuse.getType().equals(LOGIN_TAG)) { // 登入
mUserInfo = UserManager.getInstance().getUserInfoEntity();
if (mUserInfo != null) {
ImageUtils.Companion.display(mMessageDetailIconDv, mUserInfo.getIcon());
mMessageDetailUserNameTv.setText(mUserInfo.getName());
}
}
}
@Override
public void onCommentCallback(CommentEntity entity) {
mCommentEntity = entity;
setSoftInput(true);
}
@Override
public boolean onHandleBackPressed() {
if (commentNum != -1 && adapter.getConcernEntity() != null
&& commentNum != adapter.getConcernEntity().getCommentnum()) {
Intent intent = new Intent();
intent.putExtra("commentNum", adapter.getConcernEntity().getCommentnum());
getActivity().setResult(Activity.RESULT_OK, intent);
return true;
}
return false;
}
}

View File

@ -23,7 +23,7 @@ import org.greenrobot.eventbus.ThreadMode;
import butterknife.BindView;
import butterknife.OnClick;
import static com.gh.gamecenter.message.MessageFragment.EB_COMMENTMARKREAD;
import static com.gh.gamecenter.message.MessageCenterFragment.EB_COMMENTMARKREAD;
/**
* Created by khy on 2017/4/5.
@ -31,7 +31,6 @@ import static com.gh.gamecenter.message.MessageFragment.EB_COMMENTMARKREAD;
*/
public class CommentFragment extends BaseFragment implements SwipeRefreshLayout.OnRefreshListener {
@BindView(R.id.recyclerview)
RecyclerView mRecyclerview;
@BindView(R.id.refresh)
@ -60,7 +59,7 @@ public class CommentFragment extends BaseFragment implements SwipeRefreshLayout.
@Override
protected int getLayoutId() {
return R.layout.fragment_normal_message;
return R.layout.fragment_comment_list;
}
@Override
@ -138,7 +137,7 @@ public class CommentFragment extends BaseFragment implements SwipeRefreshLayout.
// Fragment界面切换事件
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(EBUISwitch swith) {
if (MessageFragment.EB_MESSAGEFRAGMENT_TAG.equals(swith.getFrom()) && swith.getPosition() == 0) {
if (MessageCenterFragment.EB_MESSAGEFRAGMENT_TAG.equals(swith.getFrom()) && swith.getPosition() == 0) {
if (mLoadingPb.getVisibility() == View.VISIBLE) {
mAdapter.loadData(0);
}

View File

@ -30,7 +30,7 @@ import retrofit2.HttpException;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import static com.gh.gamecenter.message.MessageFragment.EB_COMMENTMARKREAD;
import static com.gh.gamecenter.message.MessageCenterFragment.EB_COMMENTMARKREAD;
/**
* Created by khy on 2017/4/10.

View File

@ -55,7 +55,7 @@ public class KeFuFragment extends BaseFragment implements SwipeRefreshLayout.OnR
@Override
protected int getLayoutId() {
return R.layout.fragment_normal_message;
return R.layout.fragment_comment_list;
}
@Override
@ -125,7 +125,7 @@ public class KeFuFragment extends BaseFragment implements SwipeRefreshLayout.OnR
// Fragment界面切换事件
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(EBUISwitch swith) {
if (MessageFragment.EB_MESSAGEFRAGMENT_TAG.equals(swith.getFrom()) && swith.getPosition() == 1) {
if (MessageCenterFragment.EB_MESSAGEFRAGMENT_TAG.equals(swith.getFrom()) && swith.getPosition() == 1) {
if (mLoadingPb.getVisibility() == View.VISIBLE) {
mAdapter.loadData(0);
}

View File

@ -41,7 +41,7 @@ import retrofit2.HttpException;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import static com.gh.gamecenter.message.MessageFragment.EB_KEFUMARKREADCOUNT;
import static com.gh.gamecenter.message.MessageCenterFragment.EB_KEFUMARKREADCOUNT;
/**
* Created by khy on 2017/4/10.

View File

@ -36,7 +36,7 @@ import rx.schedulers.Schedulers;
* Created by khy on 2017/4/5.
* 首页-消息
*/
public class MessageFragment extends BaseFragment_ViewPager_Checkable {
public class MessageCenterFragment extends BaseFragment_ViewPager_Checkable {
@BindView(R.id.message_comment_hint)
TextView mMessageCommentHint;
@ -51,6 +51,9 @@ public class MessageFragment extends BaseFragment_ViewPager_Checkable {
private LinearLayout.LayoutParams mLayoutParams;
public static final int INDEX_COMMENT = 0;
public static final int INDEX_KEFU = 1;
public static final String MESSAGE_READ_OVER = "messageReadOver";
public static final String EB_MESSAGEFRAGMENT_TAG = "MessageFragment";
public static final String EB_KEFUMARKREADCOUNT = "kefuMarkReadCount";
@ -59,10 +62,10 @@ public class MessageFragment extends BaseFragment_ViewPager_Checkable {
private int mWidth;
private int mKeFuUnreadCount;
public static MessageFragment newInstance(int checkedIndex) {
public static MessageCenterFragment newInstance() {
final Bundle args = new Bundle(1);
args.putInt(ARGS_INDEX, checkedIndex);
final MessageFragment fragment = new MessageFragment();
args.putInt(ARGS_INDEX, INDEX_COMMENT);
final MessageCenterFragment fragment = new MessageCenterFragment();
fragment.setArguments(args);
return fragment;
}
@ -107,6 +110,12 @@ public class MessageFragment extends BaseFragment_ViewPager_Checkable {
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setNavigationTitle(getString(R.string.title_message_center));
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);

View File

@ -43,7 +43,7 @@ import com.gh.gamecenter.login.ApiResponse;
import com.gh.gamecenter.login.LoginTag;
import com.gh.gamecenter.login.UserViewModel;
import com.gh.gamecenter.manager.UserManager;
import com.gh.gamecenter.message.MessageFragment;
import com.gh.gamecenter.message.MessageCenterFragment;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
import com.halo.assistant.HaloApp;
@ -173,7 +173,7 @@ public class PersonalFragment extends BaseFragment implements Observer<ApiRespon
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(EBReuse reuse) {
if (MessageFragment.MESSAGE_READ_OVER.equals(reuse.getType())) { // 消息阅读完成
if (MessageCenterFragment.MESSAGE_READ_OVER.equals(reuse.getType())) { // 消息阅读完成
if (mLoginMessgeHint != null) {
mLoginMessgeHint.setVisibility(View.GONE);
}

View File

@ -7,6 +7,8 @@ import com.gh.gamecenter.Injection;
import com.gh.gamecenter.retrofit.service.ApiService;
import com.gh.gamecenter.retrofit.service.DataService;
import com.gh.gamecenter.retrofit.service.UserseaService;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.File;
import java.util.concurrent.TimeUnit;

View File

@ -23,8 +23,7 @@ import com.gh.gamecenter.eventbus.EBNetworkState;
import com.gh.gamecenter.eventbus.EBPackage;
import com.gh.gamecenter.eventbus.EBReuse;
import com.gh.gamecenter.eventbus.EBUISwitch;
import com.gh.gamecenter.news.NewsWrapperFragment;
import com.lightgame.config.CommonDebug;
import com.gh.gamecenter.info.InfoToolWrapperFragment;
import com.lightgame.download.DataWatcher;
import com.lightgame.download.DownloadEntity;
@ -273,7 +272,7 @@ public class SubjectFragment extends BaseFragment {
// 资讯Fragment界面切换事件
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(EBUISwitch busNine) {
if (NewsWrapperFragment.EB_NEWSFRAGMENT_TAG.equals(busNine.getFrom())) {
if (InfoToolWrapperFragment.EB_NEWSFRAGMENT_TAG.equals(busNine.getFrom())) {
if (busNine.getPosition() == 0) {
if (subject_pb_loading.getVisibility() == View.VISIBLE) {
adapter.initList(1);

View File

@ -1,4 +1,4 @@
package com.gh.gamecenter.adapter;
package com.halo.assistant.fragment.myconcern;
import android.app.Activity;
import android.text.TextUtils;
@ -9,10 +9,9 @@ import com.gh.base.OnRequestCallBackListener;
import com.gh.common.util.CheckLoginUtils;
import com.gh.common.util.ConcernUtils;
import com.gh.common.util.DataCollectionUtils;
import com.gh.gamecenter.DataUtils;
import com.gh.common.util.DialogUtils;
import com.gh.common.util.StringUtils;
import com.gh.gamecenter.ConcernActivity;
import com.gh.gamecenter.DataUtils;
import com.gh.gamecenter.GameDetailActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.ConcernViewHolder;
@ -35,7 +34,7 @@ import rx.schedulers.Schedulers;
/**
* Created by LGT on 2016/9/20.
*/
public class ConcernAdapter extends BaseRecyclerAdapter<ConcernViewHolder> {
class MyConcernAdapter extends BaseRecyclerAdapter<ConcernViewHolder> {
private OnRequestCallBackListener mListener;
@ -44,7 +43,7 @@ public class ConcernAdapter extends BaseRecyclerAdapter<ConcernViewHolder> {
private String mEntrance;
//TODO remove activity
public ConcernAdapter(Activity context, OnRequestCallBackListener listener, String entrance) {
MyConcernAdapter(Activity context, OnRequestCallBackListener listener, String entrance) {
super(context);
mListener = listener;
mEntrance = entrance;

View File

@ -1,4 +1,4 @@
package com.halo.assistant.fragment;
package com.halo.assistant.fragment.myconcern;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
@ -14,8 +14,6 @@ import com.gh.base.fragment.BaseFragment;
import com.gh.common.view.Concern_LinearLayout;
import com.gh.gamecenter.LoginActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.ConcernAdapter;
import com.gh.gamecenter.adapter.ConcernRecommendAdapter;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.eventbus.EBConcernChanged;
import com.gh.gamecenter.eventbus.EBReuse;
@ -33,9 +31,9 @@ import static com.gh.gamecenter.personal.PersonalFragment.LOGIN_TAG;
/**
* Created by CsHeng on 14/12/2017.
* <p>
* 关注页面
* 我的关注grid页面
*/
public class ConcernFragment extends BaseFragment implements View.OnClickListener, OnRequestCallBackListener {
public class MyConcernFragment extends BaseFragment implements View.OnClickListener, OnRequestCallBackListener {
@BindView(R.id.concern_rv_show)
RecyclerView mConcernRv;
@ -50,8 +48,8 @@ public class ConcernFragment extends BaseFragment implements View.OnClickListene
@BindView(R.id.reuse_no_connection)
LinearLayout mNoConn;
private ConcernAdapter concernAdapter;
private ConcernRecommendAdapter concernRecommendAdapter;
private MyConcernAdapter concernAdapter;
private MyConcernRecommendAdapter concernRecommendAdapter;
@Override
protected int getLayoutId() {
@ -62,13 +60,13 @@ public class ConcernFragment extends BaseFragment implements View.OnClickListene
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setNavigationTitle(getString(R.string.title_concern));
setNavigationTitle(getString(R.string.title_myconcern));
mConcernTitleRl.setOnClickListener(this);
mConcernRv.setHasFixedSize(true);
mConcernRv.setLayoutManager(new GridLayoutManager(getContext(), 3));
concernAdapter = new ConcernAdapter(getActivity(), this, mEntrance);
concernAdapter = new MyConcernAdapter(getActivity(), this, mEntrance);
mConcernRv.setAdapter(concernAdapter);
mConcernRecommendRv.setHasFixedSize(true);
@ -91,7 +89,7 @@ public class ConcernFragment extends BaseFragment implements View.OnClickListene
mNoConn.setVisibility(View.GONE);
mNoneData.setVisibility(View.GONE);
concernRecommendAdapter = new ConcernRecommendAdapter(getContext(), this, (List<GameEntity>) obj, mEntrance);
concernRecommendAdapter = new MyConcernRecommendAdapter(getContext(), this, (List<GameEntity>) obj, mEntrance);
mConcernRecommendRv.setAdapter(concernRecommendAdapter);
if (obj == null) { // 未登录状态
@ -198,7 +196,7 @@ public class ConcernFragment extends BaseFragment implements View.OnClickListene
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(EBReuse reuse) {
if (reuse.getType().equals(LOGIN_TAG)) { // 登入
concernAdapter = new ConcernAdapter(getActivity(), this, mEntrance);
concernAdapter = new MyConcernAdapter(getActivity(), this, mEntrance);
mConcernRv.setAdapter(concernAdapter);
mConcernRv.setVisibility(View.VISIBLE);
}

View File

@ -1,4 +1,4 @@
package com.gh.gamecenter.adapter;
package com.halo.assistant.fragment.myconcern;
import android.content.Context;
import android.view.View;
@ -35,8 +35,10 @@ import rx.schedulers.Schedulers;
/**
* Created by LGT on 2016/9/20.
*
* 我的关注推荐关注
*/
public class ConcernRecommendAdapter extends BaseRecyclerAdapter<ConcernViewHolder> {
class MyConcernRecommendAdapter extends BaseRecyclerAdapter<ConcernViewHolder> {
private OnRequestCallBackListener mListener;
@ -49,7 +51,7 @@ public class ConcernRecommendAdapter extends BaseRecyclerAdapter<ConcernViewHold
private String mEntrance;
public ConcernRecommendAdapter(Context context, OnRequestCallBackListener listener, List<GameEntity> concernGame, String entrance) {
MyConcernRecommendAdapter(Context context, OnRequestCallBackListener listener, List<GameEntity> concernGame, String entrance) {
super(context);
mListener = listener;
mEntrance = entrance;

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:orientation = "vertical" >
<include layout = "@layout/reuse_actionbar" />
<FrameLayout
android:id = "@id/layout_fragment_content"
android:layout_width = "match_parent"
android:layout_height = "match_parent" />
</LinearLayout >

View File

@ -1,150 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android"
xmlns:fresco = "http://schemas.android.com/apk/res-auto"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:orientation = "vertical" >
<include layout = "@layout/reuse_actionbar" />
<RelativeLayout
android:layout_width = "match_parent"
android:layout_height = "match_parent" >
<android.support.v7.widget.RecyclerView
android:id = "@+id/message_detail_rv"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:layout_marginBottom = "45dp" />
<View
android:id = "@+id/message_detail_close_comment"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_above = "@+id/message_detail_sv"
android:visibility = "gone" />
<include
layout = "@layout/reuse_no_connection"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:layout_marginBottom = "45dp" />
<View
android:layout_width = "match_parent"
android:layout_height = "7dp"
android:layout_above = "@+id/message_detail_sv"
android:background = "@drawable/shadow" />
<ScrollView
android:id = "@+id/message_detail_sv"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_alignParentBottom = "true"
android:background = "@android:color/white" >
<RelativeLayout
android:id = "@+id/message_detail_comment_rl"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:paddingLeft = "18dp"
android:paddingRight = "18dp"
android:visibility = "gone" >
<EditText
android:id = "@+id/message_detail_comment_et"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:background = "@null"
android:drawableBottom = "@drawable/et_line"
android:drawablePadding = "6dp"
android:hint = "@string/message_detail_comment_hint"
android:paddingTop = "14dp"
android:textColorHint = "@color/text_b2b2b2"
android:textCursorDrawable = "@drawable/cursor_color"
android:textSize = "14sp" />
<RelativeLayout
android:id = "@+id/message_detail_user_rl"
android:layout_width = "match_parent"
android:layout_height = "70dp"
android:layout_below = "@+id/message_detail_comment_et"
android:visibility = "visible" >
<com.facebook.drawee.view.SimpleDraweeView
android:id = "@+id/comment_user_icon"
style = "@style/frescoStyle"
android:layout_width = "45dp"
android:layout_height = "45dp"
android:layout_centerVertical = "true"
android:layout_marginRight = "17dp"
fresco:roundAsCircle = "true" />
<TextView
android:id = "@+id/comment_user_name"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_centerInParent = "true"
android:layout_toLeftOf = "@+id/comment_send"
android:layout_toRightOf = "@+id/comment_user_icon"
android:textColor = "@color/title"
android:textSize = "15sp" />
<TextView
android:id = "@+id/comment_send"
android:layout_width = "60dp"
android:layout_height = "28.5dp"
android:layout_alignParentRight = "true"
android:layout_centerVertical = "true"
android:background = "@drawable/textview_comment_send_style"
android:clickable = "true"
android:gravity = "center"
android:text = "@string/message_detail_send"
android:textColor = "@android:color/white"
android:textSize = "14sp" />
</RelativeLayout >
</RelativeLayout >
</ScrollView >
<View
android:id = "@+id/message_detail_hint_line"
android:layout_width = "match_parent"
android:layout_height = "7dp"
android:layout_above = "@+id/message_detail_comment_hint_rl"
android:background = "@drawable/shadow" />
<RelativeLayout
android:id = "@+id/message_detail_comment_hint_rl"
android:layout_width = "match_parent"
android:layout_height = "44dp"
android:layout_alignParentBottom = "true"
android:background = "@android:color/white" >
<ImageView
android:id = "@+id/message_detail_comment_hint_icon"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:layout_centerVertical = "true"
android:layout_marginLeft = "14dp"
android:layout_marginRight = "10dp"
android:paddingBottom = "14dp"
android:paddingTop = "13dp"
android:src = "@drawable/ic_edit" />
<TextView
android:id = "@+id/message_detail_comment_hint"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_centerVertical = "true"
android:layout_toRightOf = "@+id/message_detail_comment_hint_icon"
android:drawablePadding = "13dp"
android:paddingRight = "18dp"
android:text = "@string/message_detail_send_hint"
android:textColor = "@color/theme"
android:visibility = "visible" />
</RelativeLayout >
</RelativeLayout >
</LinearLayout >

View File

@ -4,18 +4,18 @@
android:layout_height = "match_parent" >
<android.support.v4.widget.SwipeRefreshLayout
android:id = "@+id/news2_srl_refresh"
android:id = "@+id/info_srl_refresh"
android:layout_width = "match_parent"
android:layout_height = "match_parent" >
<android.support.v7.widget.RecyclerView
android:id = "@+id/news2_rv_list"
android:id = "@+id/info_rv_list"
android:layout_width = "match_parent"
android:layout_height = "wrap_content" />
</android.support.v4.widget.SwipeRefreshLayout >
<com.gc.materialdesign.views.ProgressBarCircularIndeterminate
android:id = "@+id/news2_pb_loading"
android:id = "@+id/info_pb_loading"
android:layout_width = "40dp"
android:layout_height = "40dp"
android:layout_centerInParent = "true"

View File

@ -4,18 +4,18 @@
android:layout_height = "match_parent" >
<android.support.v4.widget.SwipeRefreshLayout
android:id = "@+id/news3_srl_refresh"
android:id = "@+id/original_srl_refresh"
android:layout_width = "match_parent"
android:layout_height = "match_parent" >
<android.support.v7.widget.RecyclerView
android:id = "@+id/news3_rv_list"
android:id = "@+id/original_rv_list"
android:layout_width = "match_parent"
android:layout_height = "wrap_content" />
</android.support.v4.widget.SwipeRefreshLayout >
<com.gc.materialdesign.views.ProgressBarCircularIndeterminate
android:id = "@+id/news3_pb_loading"
android:id = "@+id/original_pb_loading"
android:layout_width = "40dp"
android:layout_height = "40dp"
android:layout_centerInParent = "true"

View File

@ -0,0 +1,141 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android = "http://schemas.android.com/apk/res/android"
xmlns:fresco = "http://schemas.android.com/apk/res-auto"
android:layout_width = "match_parent"
android:layout_height = "match_parent" >
<android.support.v7.widget.RecyclerView
android:id = "@+id/message_detail_rv"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:layout_marginBottom = "45dp" />
<View
android:id = "@+id/message_detail_close_comment"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_above = "@+id/message_detail_sv"
android:visibility = "gone" />
<include
layout = "@layout/reuse_no_connection"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:layout_marginBottom = "45dp" />
<View
android:layout_width = "match_parent"
android:layout_height = "7dp"
android:layout_above = "@+id/message_detail_sv"
android:background = "@drawable/shadow" />
<ScrollView
android:id = "@+id/message_detail_sv"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_alignParentBottom = "true"
android:background = "@android:color/white" >
<RelativeLayout
android:id = "@+id/message_detail_comment_rl"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:paddingLeft = "18dp"
android:paddingRight = "18dp"
android:visibility = "gone" >
<EditText
android:id = "@+id/message_detail_comment_et"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:background = "@null"
android:drawableBottom = "@drawable/et_line"
android:drawablePadding = "6dp"
android:hint = "@string/message_detail_comment_hint"
android:paddingTop = "14dp"
android:textColorHint = "@color/text_b2b2b2"
android:textCursorDrawable = "@drawable/cursor_color"
android:textSize = "14sp" />
<RelativeLayout
android:id = "@+id/message_detail_user_rl"
android:layout_width = "match_parent"
android:layout_height = "70dp"
android:layout_below = "@+id/message_detail_comment_et"
android:visibility = "visible" >
<com.facebook.drawee.view.SimpleDraweeView
android:id = "@+id/comment_user_icon"
style = "@style/frescoStyle"
android:layout_width = "45dp"
android:layout_height = "45dp"
android:layout_centerVertical = "true"
android:layout_marginRight = "17dp"
fresco:roundAsCircle = "true" />
<TextView
android:id = "@+id/comment_user_name"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_centerInParent = "true"
android:layout_toLeftOf = "@+id/comment_send"
android:layout_toRightOf = "@+id/comment_user_icon"
android:textColor = "@color/title"
android:textSize = "15sp" />
<TextView
android:id = "@+id/comment_send"
android:layout_width = "60dp"
android:layout_height = "28.5dp"
android:layout_alignParentRight = "true"
android:layout_centerVertical = "true"
android:background = "@drawable/textview_comment_send_style"
android:clickable = "true"
android:gravity = "center"
android:text = "@string/message_detail_send"
android:textColor = "@android:color/white"
android:textSize = "14sp" />
</RelativeLayout >
</RelativeLayout >
</ScrollView >
<View
android:id = "@+id/message_detail_hint_line"
android:layout_width = "match_parent"
android:layout_height = "7dp"
android:layout_above = "@+id/message_detail_comment_hint_rl"
android:background = "@drawable/shadow" />
<RelativeLayout
android:id = "@+id/message_detail_comment_hint_rl"
android:layout_width = "match_parent"
android:layout_height = "44dp"
android:layout_alignParentBottom = "true"
android:background = "@android:color/white" >
<ImageView
android:id = "@+id/message_detail_comment_hint_icon"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:layout_centerVertical = "true"
android:layout_marginLeft = "14dp"
android:layout_marginRight = "10dp"
android:paddingBottom = "14dp"
android:paddingTop = "13dp"
android:src = "@drawable/ic_edit" />
<TextView
android:id = "@+id/message_detail_comment_hint"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_centerVertical = "true"
android:layout_toRightOf = "@+id/message_detail_comment_hint_icon"
android:drawablePadding = "13dp"
android:paddingRight = "18dp"
android:text = "@string/message_detail_send_hint"
android:textColor = "@color/theme"
android:visibility = "visible" />
</RelativeLayout >
</RelativeLayout >

View File

@ -211,7 +211,7 @@
<string name = "title_choose_activity" >发送游戏</string >
<string name = "title_clean_apk" >安装包清理</string >
<string name = "title_comment_detail" >查看对话</string >
<string name = "title_concern" >我的关注</string >
<string name = "title_myconcern" >我的关注</string >
<string name = "title_crop_image" >图片裁剪</string >
<string name = "title_file_receive" >接收游戏</string >
<string name = "title_file_sender" >发送游戏</string >

View File

@ -45,19 +45,19 @@ BUGLY_APPID=d5de44c594
# usersea
DEV_USERSEA_APP_ID=3111120926
DEV_USERSEA_APP_SECRET=597aa2b463f5770013146675
DEV_USERSEA_APP_SECRET=597aa2b463f5770013146675re
USERSEA_APP_ID=2017101012
USERSEA_APP_SECRET=597aa2b463f5770013146675
# hosts
DEV_API_HOST=https\://dev.api.ghzs666.com/v3d1/
DEV_LIBAO_HOST=https\://dev.api.ghzs666.com/v3d1/
DEV_MESSAGE_HOST=https\://dev.api.ghzs666.com/v3d1/
DEV_USER_HOST=https\://dev.api.ghzs666.com/v3d1/
DEV_COMMENT_HOST=https\://dev.api.ghzs666.com/v3d1/
DEV_API_HOST=https\://dev.api.ghzs666.com/v3d0/
DEV_LIBAO_HOST=https\://dev.api.ghzs666.com/v3d0/
DEV_MESSAGE_HOST=https\://dev.api.ghzs666.com/v3d0/
DEV_USER_HOST=https\://dev.api.ghzs666.com/v3d0/
DEV_COMMENT_HOST=https\://dev.api.ghzs666.com/v3d0/
DEV_DATA_HOST=http\://data.ghzs666.com/
DEV_USERSEA_HOST=https\://dev.usersea.ghzs666.com/v1d1/
DEV_USERSEA_HOST=https\://dev.usersea.ghzs666.com/v1d0/
API_HOST=https\://api.ghzs.com/v3d0/
LIBAO_HOST=https\://api.ghzs.com/v3d0/