Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
CsHeng
2017-04-25 18:45:28 +08:00
22 changed files with 623 additions and 104 deletions

View File

@ -21,6 +21,7 @@ import com.gh.gamecenter.db.info.LibaoInfo;
import com.gh.gamecenter.entity.LibaoEntity;
import com.gh.gamecenter.entity.LibaoStatusEntity;
import com.gh.gamecenter.eventbus.EBReuse;
import com.gh.gamecenter.eventbus.EBUISwitch;
import com.gh.gamecenter.geetest.GeetestUtils;
import com.gh.gamecenter.retrofit.JSONObjectResponse;
import com.gh.gamecenter.retrofit.Response;
@ -45,6 +46,8 @@ import rx.schedulers.Schedulers;
*/
public class LibaoUtils {
public static final String REFRESH_LIBAO_TIME = "refreshLiBaoTime";
// 礼包去重
public static List<LibaoEntity> removeDuplicateData(List<LibaoEntity> sourceList, List<LibaoEntity> rawList) {
if (sourceList == null || sourceList.isEmpty()
@ -93,7 +96,7 @@ public class LibaoUtils {
libaoDao.add(libaoInfo);
}
EventBus.getDefault().post(new EBReuse("libaoChanged"));
EventBus. getDefault().post(new EBReuse("libaoChanged"));
}
@Override
@ -402,8 +405,16 @@ public class LibaoUtils {
} else if ("fetched".equals(detail)) {
Utils.toast(libaoBtn.getContext(), "你已领过这个礼包了");
getCunHaoXiang(libaoBtn.getContext(), true);
libaoBtn.setText("复制");
libaoBtn.setBackgroundResource(R.drawable.textview_blue_style);
int[][] states2 = new int[2][];
states2[0] = new int[] { android.R.attr.state_pressed };
states2[1] = new int[] {};
int[] colors2 = new int[] { Color.WHITE,
Color.parseColor("#ffb13c") };
ColorStateList sl2 = new ColorStateList(states2, colors2);
libaoBtn.setText("已淘号");
libaoBtn.setBackgroundResource(R.drawable.libao_taoed_style);
libaoBtn.setTextColor(sl2);
} else if ("try tao".equals(detail) || "used up".equals(detail)) {
DialogUtils.showHintDialog(libaoBtn.getContext(), "礼包已领光"
, "手速不够快,礼包已经被抢光了,十分抱歉", "知道了");
@ -506,10 +517,22 @@ public class LibaoUtils {
Utils.toast(libaoBtn.getContext(), "礼包领取时间已结束");
} else if ("fetched".equals(detail)) {
Utils.toast(libaoBtn.getContext(), "你已领过这个礼包了");
getCunHaoXiang(libaoBtn.getContext(), true);
libaoBtn.setText("复制");// TODO
libaoBtn.setBackgroundResource(R.drawable.textview_blue_style);
int countdown = errorJson.getInt("countdown");
if (countdown > 0 && countdown < 60 * 10) {
EventBus.getDefault().post(new EBUISwitch(REFRESH_LIBAO_TIME, countdown));
} else {
getCunHaoXiang(libaoBtn.getContext(), true);
}
int[][] states = new int[2][];
states[0] = new int[] { android.R.attr.state_pressed };
states[1] = new int[] {};
int[] colors = new int[] { Color.WHITE,
Color.parseColor("#06D0A8") };
ColorStateList sl = new ColorStateList(states, colors);
libaoBtn.setText("已领取");
libaoBtn.setBackgroundResource(R.drawable.libao_linged_style);
libaoBtn.setTextColor(sl);
} else if ("try tao".equals(detail) || "used up".equals(detail)) {
DialogUtils.showHintDialog(libaoBtn.getContext(), "礼包已领光"
, "手速不够快,礼包已经被抢光了,十分抱歉", "知道了");

View File

@ -8,12 +8,14 @@ import android.view.View;
import com.gh.base.AppController;
import com.gh.base.BaseDetailActivity;
import com.gh.common.util.LibaoUtils;
import com.gh.common.util.TokenUtils;
import com.gh.common.util.Utils;
import com.gh.common.view.VerticalItemDecoration;
import com.gh.gamecenter.adapter.LibaoDetailAdapter;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.entity.LibaoEntity;
import com.gh.gamecenter.eventbus.EBUISwitch;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
@ -91,7 +93,7 @@ public class LibaoDetailActivity extends BaseDetailActivity implements LibaoDeta
getGameDigest();
Utils.log( mLibaoEntity.getBeforeStatus() + "===========" + mLibaoEntity.getStatus());
String status = mLibaoEntity.getStatus();
if (mLibaoEntity.isReuse() && (status.equals("linged") || status.equals("taoed"))) {
if (mLibaoEntity.getRepeat() > 0&& (status.equals("linged") || status.equals("taoed"))) {
TokenUtils.getTime(LibaoDetailActivity.this);
handler.sendEmptyMessageDelayed(0, 5000);
}
@ -177,4 +179,11 @@ public class LibaoDetailActivity extends BaseDetailActivity implements LibaoDeta
super.onDestroy();
handler.removeCallbacksAndMessages(null);
}
// 领取/淘号失败,根据返回的时间重新倒数
public void onEventMainThread(EBUISwitch swith) {
if (LibaoUtils.REFRESH_LIBAO_TIME.equals(swith.getFrom())) {
handler.sendEmptyMessageDelayed(1, swith.getPosition());
}
}
}

View File

@ -22,21 +22,40 @@ import android.widget.Toast;
import com.gc.materialdesign.views.ProgressBarCircularIndeterminate;
import com.gh.base.BaseActivity;
import com.gh.common.util.DialogUtils;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.TokenUtils;
import com.gh.common.util.Utils;
import com.gh.gamecenter.adapter.VoteAdapter;
import com.gh.gamecenter.db.VersionVoteDao;
import com.gh.gamecenter.db.info.VersionVoteInfo;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
import org.json.JSONException;
import org.json.JSONObject;
import butterknife.BindView;
import butterknife.OnClick;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.adapter.rxjava.HttpException;
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Func1;
import rx.schedulers.Schedulers;
/**
* Created by khy on 2017/4/11.
* 求版本投票页面
*/
public class VoteActivity extends BaseActivity {
public class VoteActivity extends BaseActivity implements SwipeRefreshLayout.OnRefreshListener{
@BindView(R.id.vote_rv)
RecyclerView mVoteRv;
@BindView(R.id.vote_refresh)
SwipeRefreshLayout mVoteRefresh;
SwipeRefreshLayout mVoteRefresh;
@BindView(R.id.vote_loading)
ProgressBarCircularIndeterminate mVoteLoading;
@BindView(R.id.reuse_no_connection)
@ -48,10 +67,28 @@ public class VoteActivity extends BaseActivity {
private VoteAdapter mAdapter;
private VersionVoteDao mVoteDao;
private String mGameId;
Runnable runnable = new Runnable() {
@Override
public void run() {
mAdapter = new VoteAdapter(VoteActivity.this,VoteActivity.this, mGameId, mVoteDao);
mVoteRv.setAdapter(mAdapter);
}
};
private LinearLayoutManager layoutManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String gameName = getIntent().getExtras().getString("gameName");
mGameId = getIntent().getExtras().getString("gameId");
mVoteDao = new VersionVoteDao(this);
View view = View.inflate(this, R.layout.activity_vote, null);
@ -78,10 +115,14 @@ public class VoteActivity extends BaseActivity {
});
mVoteRv.setLayoutManager(new LinearLayoutManager(this));
mAdapter = new VoteAdapter(this);
layoutManager = new LinearLayoutManager(this);
mVoteRv.setLayoutManager(layoutManager);
mAdapter = new VoteAdapter(this, this, mGameId, mVoteDao);
mVoteRv.setAdapter(mAdapter);
mVoteRefresh.setColorSchemeResources(R.color.theme);
mVoteRefresh.setOnRefreshListener(this);
mAddTv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -89,6 +130,17 @@ public class VoteActivity extends BaseActivity {
}
});
mVoteRv.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (newState == RecyclerView.SCROLL_STATE_IDLE && mAdapter.isLoaded() && !mAdapter.isRemove()
&& mAdapter.getItemCount() == layoutManager.findLastVisibleItemPosition() + 1) {
mAdapter.getVersionVote(mAdapter.getItemCount() - 1);
}
}
});
}
private void showAddVoteDialog() {
@ -139,6 +191,7 @@ public class VoteActivity extends BaseActivity {
Toast.makeText(VoteActivity.this, "请输入名字", Toast.LENGTH_SHORT).show();
return;
}
postVersionVote(nickname, true);
dialog.dismiss();
}
});
@ -169,4 +222,119 @@ public class VoteActivity extends BaseActivity {
}
}.start();
}
private void postVersionVote(final String name, final boolean isCheck) {
final Dialog waitDialog = DialogUtils.showWaitDialog(VoteActivity.this, "提交中...");
JSONObject object = new JSONObject();
try {
object.put("name", name);
} catch (JSONException e) {
e.printStackTrace();
}
Utils.log("=====object" + object.toString());
final RequestBody body = RequestBody.create(MediaType.parse("application/json"), object.toString());
TokenUtils
.getToken(VoteActivity.this, isCheck)
.flatMap(new Func1<String, Observable<ResponseBody>>() {
@Override
public Observable<ResponseBody> call(String token) {
return RetrofitManager.getApi().postVersionVote(token, body, mGameId);
}
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<ResponseBody>(){
@Override
public void onResponse(ResponseBody response) {
super.onResponse(response);
waitDialog.dismiss();
try {
String string = response.string();
Utils.log("========提交成功" + string);
JSONObject responseObject = new JSONObject(string);
boolean cast = responseObject.getBoolean("cast");
String id = responseObject.getString("_id");
if (cast) {
Utils.toast(VoteActivity.this, "投票成功");
} else {
Utils.toast(VoteActivity.this, "你已经投过了");
}
if (!TextUtils.isEmpty(id)) {
mVoteDao.add(new VersionVoteInfo(id));
mAdapter.voteCallBack(cast, id, name);
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onFailure(HttpException e) {
super.onFailure(e);
Utils.toast(VoteActivity.this, "提交失败");
waitDialog.dismiss();
if (e != null) {
if (e.code() == 401) {
postVersionVote(name, false);
return;
}
}
}
});
}
@OnClick(R.id.reuse_no_connection)
public void reconnection() { // 重新连接
mVoteRv.setVisibility(View.VISIBLE);
mVoteLoading.setVisibility(View.VISIBLE);
mNoConnection.setVisibility(View.GONE);
mVoteRefresh.postDelayed(runnable, 1000);
}
@Override
public void loadDone() {
super.loadDone();
mVoteRefresh.setRefreshing(false);
mVoteLoading.setVisibility(View.GONE);
mVoteRv.setVisibility(View.VISIBLE);
mAddTv.setVisibility(View.GONE);
}
@Override
public void loadDone(Object obj) {
super.loadDone(obj);
postVersionVote((String) obj, true);
}
@Override
public void loadError() {
super.loadError();
mVoteRefresh.setRefreshing(false);
mNoConnection.setVisibility(View.VISIBLE);
mVoteRv.setVisibility(View.GONE);
mAddTv.setVisibility(View.GONE);
}
@Override
public void loadEmpty() {
super.loadEmpty();
mVoteRefresh.setRefreshing(false);
mAddTv.setVisibility(View.VISIBLE);
mVoteLoading.setVisibility(View.GONE);
}
@Override
public void onRefresh() {
mVoteRefresh.postDelayed(runnable, 1000);
}
}

View File

@ -129,11 +129,11 @@ public class LibaoDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
@Override
public int getItemCount() {
int index = 1;
int index = 0;
if (mLibaoDetailEntity != null) {
if (mLibaoEntity != null) {
index = index + 2;
index = index + 3;
}
if (mLibaoDetailEntity.getTime() != null || mLibaoDetailEntity.getInstallRequired()) {

View File

@ -94,6 +94,7 @@ public class PlatformAdapter extends BaseRecyclerAdapter<PlatformViewHolder> {
public void onClick(View v) {
Intent intent = new Intent(mContext, VoteActivity.class);
intent.putExtra("gameName", mGameEntity.getName());
intent.putExtra("gameId", mGameEntity.getId());
mContext.startActivity(intent);
}
});

View File

@ -1,84 +1,239 @@
package com.gh.gamecenter.adapter;
import android.content.Context;
import android.view.*;
import com.gh.common.util.Utils;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
import com.gh.gamecenter.adapter.viewholder.VoteViewHolder;
import com.gh.gamecenter.db.VersionVoteDao;
import com.gh.gamecenter.entity.VersionVoteEntity;
import com.gh.gamecenter.listener.OnCallBackListener;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
import java.util.ArrayList;
import java.util.List;
import retrofit2.adapter.rxjava.HttpException;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
/**
* Created by khy on 2017/4/11.
* 求版本投票页面适配器
*/
public class VoteAdapter extends BaseRecyclerAdapter<VoteViewHolder> {
public class VoteAdapter extends BaseRecyclerAdapter<ViewHolder> {
private OnCallBackListener mCallBackListener;
private float mPbwidth; //进度条原始最大宽度
private List<Float> mVoteList;
private List<VersionVoteEntity> mVoteList;
public VoteAdapter(Context context) {
private VersionVoteDao mVoteDao;
private boolean isRemove;
private boolean isNetworkError;
private boolean isLoaded;
private String mGameId;
public VoteAdapter(Context context,OnCallBackListener onCallBackListener , String gameId, VersionVoteDao voteDao) {
super(context);
mPbwidth = (float) (context.getResources().getDisplayMetrics().widthPixels * 0.65);
this.mCallBackListener = onCallBackListener;
this.mGameId = gameId;
mPbwidth = (float) (mContext.getResources().getDisplayMetrics().widthPixels * 0.65);
mVoteList = new ArrayList<>();
mVoteDao = voteDao;
float max = 1000;
for (int i = 0; i < 50; i++) {
mVoteList.add(max);
max = max - 20;
getVersionVote(0);
}
public void getVersionVote(final int offset) {
RetrofitManager
.getApi()
.getVersionVote(mGameId, offset, 20)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Response<List<VersionVoteEntity>>(){
@Override
public void onResponse(List<VersionVoteEntity> response) {
super.onResponse(response);
if (response.size() > 0) {
if (response.size() < 20) {
isRemove = true;
}
if (offset == 0) {
mCallBackListener.loadDone();
}
mVoteList.addAll(response);
notifyItemRangeInserted(mVoteList.size() - response.size(), response.size());
} else {
isRemove = true;
if (mVoteList.size() == 0) {
mCallBackListener.loadEmpty();
}
}
isLoaded = true;
}
@Override
public void onFailure(HttpException e) {
super.onFailure(e);
isLoaded = true;
if (offset == 0) {
mCallBackListener.loadError();
} else {
isNetworkError = true;
notifyItemChanged(getItemCount() - 1);
}
}
});
}
@Override
public int getItemViewType(int position) {
if (position == getItemCount() - 1) {
return 0;
} else {
return 1;
}
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (viewType == 0) {
View view = LayoutInflater.from(mContext).inflate(R.layout.refresh_footerview, parent, false);
return new FooterViewHolder(view);
} else {
View view = LayoutInflater.from(mContext).inflate(R.layout.vote_item, parent, false);
return new VoteViewHolder(view);
}
}
@Override
public VoteViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(mContext).inflate(R.layout.vote_item, parent, false);
if (mPbwidth == -1) {
final View pb = view.findViewById(R.id.progressbar);
pb.post(new Runnable() {
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (holder instanceof VoteViewHolder) {
final VoteViewHolder viewHolder = (VoteViewHolder) holder;
viewHolder.voteBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void run() {
mPbwidth = pb.getWidth();
public void onClick(View v) {
}
});
VersionVoteEntity versionVoteEntity = mVoteList.get(position);
if (mVoteDao.isVote(versionVoteEntity.getId())) {
viewHolder.voteBtn.setBackgroundResource(R.drawable.border_suggest_bg);
viewHolder.voteBtn.setTextColor(mContext.getResources().getColor(R.color.content));
} else {
viewHolder.voteBtn.setBackgroundResource(R.drawable.comment_border_bg);
viewHolder.voteBtn.setTextColor(mContext.getResources().getColor(R.color.theme));
}
View progressbar = viewHolder.progressbar;
ViewGroup.LayoutParams layoutParams = progressbar.getLayoutParams();
if (position > 0) {
float maxSize = (float) mVoteList.get(0).getNum();
float curSize = (float) versionVoteEntity.getNum();
float f = curSize/maxSize;
layoutParams.width = (int) (mPbwidth * f);
} else {
layoutParams.width = (int) mPbwidth;
}
viewHolder.name.setText(versionVoteEntity.getName());
viewHolder.count.setText(versionVoteEntity.getNum() + "");
progressbar.setLayoutParams(layoutParams);
viewHolder.voteBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCallBackListener.loadDone(viewHolder.name.getText().toString());
}
});
} else if (holder instanceof FooterViewHolder) {
initFooterViewHolder((FooterViewHolder) holder);
}
return new VoteViewHolder(view);
}
@Override
public void onBindViewHolder(VoteViewHolder holder, int position) {
holder.voteBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
View progressbar = holder.progressbar;
ViewGroup.LayoutParams layoutParams = progressbar.getLayoutParams();
if (position > 0) {
float maxSize = mVoteList.get(0);
float curSize = mVoteList.get(position);
float f = curSize/maxSize;
Utils.log(maxSize + "======="+ curSize +"=======" + f + "====" + (int) (mPbwidth/f));
layoutParams.width = (int) (mPbwidth * f);
} else {
layoutParams.width = (int) mPbwidth;
Utils.log("==============" + mPbwidth);
}
holder.count.setText(mVoteList.get(position) + "");
progressbar.setLayoutParams(layoutParams);
private void initFooterViewHolder(FooterViewHolder viewHolder) {
if (isNetworkError) {
viewHolder.loading.setVisibility(View.GONE);
viewHolder.hint.setText("加载失败,点击重试");
viewHolder.itemView.setClickable(true);
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
isNetworkError = false;
notifyItemChanged(getItemCount() - 1);
getVersionVote(mVoteList.size());
}
});
} else if (isRemove) {
viewHolder.loading.setVisibility(View.GONE);
viewHolder.hint.setText("加载完毕");
viewHolder.itemView.setClickable(false);
viewHolder.lineLeft.setVisibility(View.VISIBLE);
viewHolder.lineRight.setVisibility(View.VISIBLE);
} else {
viewHolder.loading.setVisibility(View.VISIBLE);
viewHolder.hint.setText("加载中...");
viewHolder.itemView.setClickable(false);
}
}
@Override
public int getItemCount() {
return mVoteList.size();
if (mVoteList.size() == 0) {
return 0;
}
return mVoteList.size() + 1;
}
public void voteCallBack(boolean cast, String id, String name) {
if (cast) {
if (mVoteList.size() == 0) {
VersionVoteEntity voteEntity = new VersionVoteEntity();
voteEntity.setId(id);
voteEntity.setName(name);
voteEntity.setNum(1);
mVoteList.add(voteEntity);
mCallBackListener.loadDone();
} else {
for (VersionVoteEntity versionVoteEntity : mVoteList) {
if ((id).equals(versionVoteEntity.getId())) {
versionVoteEntity.setNum(versionVoteEntity.getNum() + 1);
}
}
}
}
notifyDataSetChanged();
}
public boolean isLoaded(){
return isLoaded;
}
public boolean isRemove(){
return isRemove;
}
}

View File

@ -17,6 +17,7 @@ import com.gh.gamecenter.db.info.MessageMarkReadInfo;
import com.gh.gamecenter.db.info.NoticeMarkReadInfo;
import com.gh.gamecenter.db.info.PackageInfo;
import com.gh.gamecenter.db.info.SearchHistoryInfo;
import com.gh.gamecenter.db.info.VersionVoteInfo;
import com.gh.gamecenter.db.info.VoteInfo;
import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
import com.j256.ormlite.dao.Dao;
@ -71,6 +72,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
TableUtils.createTable(connectionSource, MessageMarkReadInfo.class);
TableUtils.createTable(connectionSource, KeFuMarkReadInfo.class);
TableUtils.createTable(connectionSource, NoticeMarkReadInfo.class);
TableUtils.createTable(connectionSource, VersionVoteInfo.class);
} catch (SQLException e) {
e.printStackTrace();
}
@ -93,6 +95,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
TableUtils.dropTable(connectionSource, MessageMarkReadInfo.class, true);
TableUtils.dropTable(connectionSource, KeFuMarkReadInfo.class, true);
TableUtils.dropTable(connectionSource, NoticeMarkReadInfo.class, true);
TableUtils.dropTable(connectionSource, VersionVoteInfo.class, true);
onCreate(database, connectionSource);
} catch (SQLException e) {
e.printStackTrace();

View File

@ -0,0 +1,54 @@
package com.gh.gamecenter.db;
import android.content.Context;
import com.gh.gamecenter.db.info.VersionVoteInfo;
import com.j256.ormlite.dao.Dao;
import java.sql.SQLException;
/**
* Created by khy on 2017/4/25.
*/
public class VersionVoteDao {
private DatabaseHelper helper;
private Dao<VersionVoteInfo, String> dao;
public VersionVoteDao(Context context) {
try {
helper = DatabaseHelper.getHelper(context);
dao = helper.getDao(VersionVoteInfo.class);
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
* 添加一个投票
*/
public void add(VersionVoteInfo vote) {
try {
dao.create(vote);
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
* 根据commentId 查找是否投过票
*/
public boolean isVote(String id) {
try {
if (dao.queryForId(id) != null) {
return true;
}
return false;
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}
}

View File

@ -0,0 +1,30 @@
package com.gh.gamecenter.db.info;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
/**
* Created by khy on 2017/4/25.
*/
@DatabaseTable(tableName = "tb_version_vote")
public class VersionVoteInfo {
@DatabaseField(id = true, columnName = "voteId")
private String commentId;
public VersionVoteInfo() {
}
public VersionVoteInfo(String commentId) {
this.commentId = commentId;
}
public String getCommentId() {
return commentId;
}
public void setCommentId(String commentId) {
this.commentId = commentId;
}
}

View File

@ -42,9 +42,7 @@ public class LibaoEntity {
private long time;
private boolean reuse; // 是否重复领取
private int remainCount; // 剩余可领取数量
private int repeat; // 剩余可领取数量
public LibaoEntity() {
@ -170,20 +168,12 @@ public class LibaoEntity {
return platform;
}
public boolean isReuse() {
return reuse;
public int getRepeat() {
return repeat;
}
public void setReuse(boolean reuse) {
this.reuse = reuse;
}
public int getRemainCount() {
return remainCount;
}
public void setRemainCount(int remainCount) {
this.remainCount = remainCount;
public void setRepeat(int repeat) {
this.repeat = repeat;
}
public static LibaoEntity createLibaoEntity(ConcernEntity concernEntity, LibaoStatusEntity libaoStatusEntity,

View File

@ -0,0 +1,41 @@
package com.gh.gamecenter.entity;
import com.google.gson.annotations.SerializedName;
/**
* Created by khy on 2017/4/24.
*/
public class VersionVoteEntity {
@SerializedName("_id")
private String id;
private String name;
private int num;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
}

View File

@ -3,6 +3,7 @@ package com.gh.gamecenter.game;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
@ -90,6 +91,7 @@ public class GameFragment extends HomeFragment implements SwipeRefreshLayout.OnR
fm_game_swipe_refresh.setColorSchemeResources(R.color.theme);
fm_game_swipe_refresh.setOnRefreshListener(this);
((DefaultItemAnimator)fm_game_rv_list.getItemAnimator()).setSupportsChangeAnimations(false);
fm_game_rv_list.setHasFixedSize(true);
fm_game_rv_list.setLayoutManager(new LinearLayoutManager(getActivity()));
adapter = new GameFragmentAdapter(GameFragment.this, fm_game_swipe_refresh);

View File

@ -142,7 +142,7 @@ public class FuLiAdapter extends BaseRecyclerAdapter<ViewHolder> {
libaoEntity.setTotal(libaoStatusEntity.getTotal());
String beforeStatus = libaoStatusEntity.getBeforeStatus();
if (libaoEntity.isReuse() && libaoEntity.getRemainCount() > 0
if (libaoEntity.getRepeat() > 0
&& libaoDao.isCanLing(libaoEntity.getId(), mContext)
&& ("ling".equals(beforeStatus) || "tao".equals(beforeStatus))) { // 判断是否可以重复领取
libaoEntity.setStatus(libaoStatusEntity.getBeforeStatus());

View File

@ -166,7 +166,6 @@ class Libao1FragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
}
if (TextUtils.isEmpty(libaoStatusEntity.getBeforeStatus())) {
Utils.log("==========zzzz" + libaoStatusEntity.getStatus());
libaoStatusEntity.setBeforeStatus(libaoStatusEntity.getStatus());
}
@ -187,7 +186,7 @@ class Libao1FragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
libaoEntity.setTotal(libaoStatusEntity.getTotal());
String beforeStatus = libaoStatusEntity.getBeforeStatus();
if (libaoEntity.isReuse() && libaoEntity.getRemainCount() > 0
if (libaoEntity.getRepeat() > 0
&& mLibaoDao.isCanLing(libaoEntity.getId(), mContext)
&& ("ling".equals(beforeStatus) || "tao".equals(beforeStatus))) { // 判断是否可以重复领取
libaoEntity.setStatus(libaoStatusEntity.getBeforeStatus());

View File

@ -275,7 +275,7 @@ class Libao2FragmentAdapter extends BaseRecyclerAdapter<ViewHolder> {
libaoEntity.setTotal(libaoStatusEntity.getTotal());
String beforeStatus = libaoStatusEntity.getBeforeStatus();
if (libaoEntity.isReuse() && libaoEntity.getRemainCount() > 0
if (libaoEntity.getRepeat() > 0
&& mLibaoDao.isCanLing(libaoEntity.getId(), mContext)
&& ("ling".equals(beforeStatus) || "tao".equals(beforeStatus))) { // 判断是否可以重复领取
libaoEntity.setStatus(libaoStatusEntity.getBeforeStatus());

View File

@ -66,7 +66,7 @@ public class KeFuFragment extends BaseFragment implements SwipeRefreshLayout.OnR
mRecyclerview.addItemDecoration(new VerticalItemDecoration(getContext(), 8, true));
mRecyclerview.setAdapter(mAdapter);
mRecyclerview.setOnScrollListener(new RecyclerView.OnScrollListener() {
mRecyclerview.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
@ -98,6 +98,7 @@ public class KeFuFragment extends BaseFragment implements SwipeRefreshLayout.OnR
@Override
public void loadError() {
super.loadError();
mRefresh.setRefreshing(false);
mNoConnection.setVisibility(View.VISIBLE);
mRecyclerview.setVisibility(View.GONE);
}

View File

@ -1,39 +1,75 @@
package com.gh.gamecenter.newsdetail;
import android.app.Activity;
import android.content.*;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.text.TextUtils;
import android.view.*;
import android.webkit.*;
import android.widget.*;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.JavascriptInterface;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.facebook.drawee.view.SimpleDraweeView;
import com.gh.common.constant.Config;
import com.gh.common.util.*;
import com.gh.gamecenter.*;
import com.gh.common.util.CommentUtils;
import com.gh.common.util.ConcernUtils;
import com.gh.common.util.DataCollectionUtils;
import com.gh.common.util.DataUtils;
import com.gh.common.util.DialogUtils;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.GameUtils;
import com.gh.common.util.ImageUtils;
import com.gh.common.util.NewsUtils;
import com.gh.common.util.PostCommentUtils;
import com.gh.common.util.RandomUtils;
import com.gh.common.util.Utils;
import com.gh.gamecenter.MessageDetailActivity;
import com.gh.gamecenter.NewsDetailActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.ViewImageActivity;
import com.gh.gamecenter.adapter.BaseRecyclerAdapter;
import com.gh.gamecenter.adapter.viewholder.NewsDetailCommentListViewHolder;
import com.gh.gamecenter.db.VoteDao;
import com.gh.gamecenter.db.info.VoteInfo;
import com.gh.gamecenter.entity.*;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.CommentEntity;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.entity.NewsDetailEntity;
import com.gh.gamecenter.entity.NewsEntity;
import com.gh.gamecenter.gamedetail.GameDetailTopViewHolder;
import com.gh.gamecenter.listener.OnCallBackListener;
import com.gh.gamecenter.manager.ConcernManager;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
import org.json.JSONObject;
import retrofit2.adapter.rxjava.HttpException;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import retrofit2.adapter.rxjava.HttpException;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
/**
* Created by LGT on 2016/9/13.
* 新闻详情数据适配器
@ -195,8 +231,8 @@ public class NewsDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
if (mGameEntity != null) {
count++;
}
if (mGameEntity != null && mGameEntity.getId() != null &&
!mGameEntity.getId().isEmpty() && mCommentEntityList.size() != 0) {
if (mGameEntity != null && mGameEntity.getId() != null && !mGameEntity.getId().isEmpty()
&& mCommentEntityList != null &&mCommentEntityList.size() != 0) {
count++;
}
if (mNewsDetailEntity.getMore() != null && mNewsDetailEntity.getMore().size() != 0) {
@ -208,7 +244,7 @@ public class NewsDetailAdapter extends BaseRecyclerAdapter<ViewHolder> {
@Override
public int getItemViewType(int position) {
if (position == getItemCount() -1 && mGameEntity != null && mGameEntity.getId() != null
&& !mGameEntity.getId().isEmpty() && mCommentEntityList.size() != 0) {
&& !mGameEntity.getId().isEmpty() && mCommentEntityList != null && mCommentEntityList.size() != 0) {
return 100;
}
if (mGameEntity != null && position == 1) {

View File

@ -19,6 +19,7 @@ import com.gh.gamecenter.entity.SubjectDigestEntity;
import com.gh.gamecenter.entity.SubjectEntity;
import com.gh.gamecenter.entity.SuggestionTypeEntity;
import com.gh.gamecenter.entity.TagEntity;
import com.gh.gamecenter.entity.VersionVoteEntity;
import java.util.ArrayList;
import java.util.List;
@ -218,6 +219,12 @@ public interface ApiService {
@Headers({"Content-Type: application/json", "Accept: application/json"})
@POST("message/user/comment/confirm/read")
Observable<ResponseBody> postMarkCommentRead ( @Header("TOKEN") String token); //提交已读客服消息
Observable<ResponseBody> postMarkCommentRead ( @Header("TOKEN") String token); //提交已读客服消息+
@GET("game/{game_id}/version/request")
Observable<List<VersionVoteEntity>> getVersionVote(@Path("game_id") String gameId, @Query("offset") int offset, @Query("limit") int limit); //获取投票 游戏求版本列表
@Headers({"Content-Type: application/json", "Accept: application/json"})
@POST("game/{game_id}/version/request/vote")
Observable<ResponseBody> postVersionVote(@Header("TOKEN") String token, @Body RequestBody body, @Path("game_id") String gameId);
}