672 lines
27 KiB
Java
672 lines
27 KiB
Java
package com.gh.gamecenter.news;
|
|
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.os.Bundle;
|
|
import android.support.v7.widget.RecyclerView;
|
|
import android.text.Html;
|
|
import android.text.TextUtils;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.Toast;
|
|
|
|
import com.gh.base.AppController;
|
|
import com.gh.common.constant.ItemViewType;
|
|
import com.gh.common.util.ConcernContentUtils;
|
|
import com.gh.common.util.DataUtils;
|
|
import com.gh.common.util.DisplayUtils;
|
|
import com.gh.common.util.MD5Utils;
|
|
import com.gh.common.util.NewsUtils;
|
|
import com.gh.common.util.TokenUtils;
|
|
import com.gh.common.view.CardLinearLayout;
|
|
import com.gh.gamecenter.MessageDetailActivity;
|
|
import com.gh.gamecenter.NewsDetailActivity;
|
|
import com.gh.gamecenter.R;
|
|
import com.gh.gamecenter.ShareCardActivity;
|
|
import com.gh.gamecenter.ShareCardPicActivity;
|
|
import com.gh.gamecenter.WebActivity;
|
|
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
|
|
import com.gh.gamecenter.adapter.viewholder.NewsDigestViewHolder;
|
|
import com.gh.gamecenter.db.info.ConcernInfo;
|
|
import com.gh.gamecenter.entity.CommentnumEntity;
|
|
import com.gh.gamecenter.entity.ConcernEntity;
|
|
import com.gh.gamecenter.entity.ViewsEntity;
|
|
import com.gh.gamecenter.listener.OnCallBackListener;
|
|
import com.gh.gamecenter.manager.CommentManager;
|
|
import com.gh.gamecenter.manager.ConcernManager;
|
|
import com.gh.gamecenter.manager.DataCollectionManager;
|
|
import com.gh.gamecenter.manager.VisitManager;
|
|
import com.gh.gamecenter.retrofit.JSONObjectResponse;
|
|
import com.gh.gamecenter.retrofit.ObservableUtil;
|
|
import com.gh.gamecenter.retrofit.Response;
|
|
import com.gh.gamecenter.retrofit.RetrofitManager;
|
|
|
|
import org.json.JSONArray;
|
|
import org.json.JSONException;
|
|
import org.json.JSONObject;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
import java.util.Comparator;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Locale;
|
|
import java.util.Map;
|
|
|
|
import okhttp3.MediaType;
|
|
import okhttp3.RequestBody;
|
|
import retrofit2.adapter.rxjava.HttpException;
|
|
import rx.Observable;
|
|
import rx.Subscriber;
|
|
import rx.android.schedulers.AndroidSchedulers;
|
|
import rx.functions.Action1;
|
|
import rx.functions.Func1;
|
|
import rx.schedulers.Schedulers;
|
|
|
|
/**
|
|
* Created by khy on 2016/8/15.
|
|
* 资讯-关注-数据适配器
|
|
*/
|
|
public class News1FragmentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
|
|
|
private News1Fragment fragment;
|
|
private Context context;
|
|
private OnCallBackListener listener;
|
|
|
|
private List<ConcernEntity> concernList;
|
|
private List<String> gameIdList;
|
|
|
|
private String key;
|
|
private String ids;
|
|
|
|
private int itemCount;
|
|
private int skipPosition;
|
|
|
|
private boolean isLoading;
|
|
private boolean isOver;
|
|
private boolean isNetworkError;
|
|
|
|
public News1FragmentAdapter(News1Fragment fragment) {
|
|
this.fragment = fragment;
|
|
this.context = fragment.getActivity();
|
|
this.listener = fragment;
|
|
|
|
concernList = new ArrayList<>();
|
|
gameIdList = new ArrayList<>();
|
|
|
|
itemCount = 0;
|
|
skipPosition = -1;
|
|
|
|
isNetworkError = false;
|
|
isOver = false;
|
|
isLoading = false;
|
|
}
|
|
|
|
// 加载数据
|
|
public void addList(final int offset) {
|
|
if (isLoading) {
|
|
return;
|
|
}
|
|
isLoading = true;
|
|
if (TextUtils.isEmpty(key) || TextUtils.isEmpty(ids)) {
|
|
ObservableUtil.computation(new Observable.OnSubscribe<String>() {
|
|
@Override
|
|
public void call(Subscriber<? super String> subscriber) {
|
|
ConcernManager concernManager = new ConcernManager(context);
|
|
List<ConcernInfo> concernList = concernManager.getConcernGame();
|
|
if (concernList == null || concernList.isEmpty()) {
|
|
subscriber.onNext(null);
|
|
} else {
|
|
for (ConcernInfo concernInfo : concernList) {
|
|
gameIdList.add(concernInfo.getId());
|
|
}
|
|
|
|
// 对数据进行排序
|
|
Collections.sort(gameIdList, new Comparator<String>() {
|
|
@Override
|
|
public int compare(String lhs, String rhs) {
|
|
return lhs.compareTo(rhs);
|
|
}
|
|
});
|
|
|
|
StringBuilder keyBuilder = new StringBuilder();
|
|
StringBuilder idsBuilder = new StringBuilder();
|
|
for (int i = 0; i < gameIdList.size(); i++) {
|
|
keyBuilder.append(gameIdList.get(i));
|
|
if (i < 5) {
|
|
idsBuilder.append(gameIdList.get(i));
|
|
idsBuilder.append("-");
|
|
}
|
|
}
|
|
key = MD5Utils.getContentMD5(keyBuilder.toString());
|
|
ids = idsBuilder.substring(0, idsBuilder.length() - 1);
|
|
subscriber.onNext("");
|
|
}
|
|
subscriber.onCompleted();
|
|
}
|
|
}, new Action1<String>() {
|
|
@Override
|
|
public void call(String s) {
|
|
if (s == null) {
|
|
listener.loadEmpty();
|
|
} else {
|
|
loadDataByKey(offset);
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
loadDataByKey(offset);
|
|
}
|
|
}
|
|
|
|
private void loadDataByKey(final int offset) {
|
|
RetrofitManager.getApi()
|
|
.getGuanZhuByKey(key, offset)
|
|
.map(new Func1<List<ConcernEntity>, List<ConcernEntity>>() {
|
|
@Override
|
|
public List<ConcernEntity> call(List<ConcernEntity> list) {
|
|
// 去除重复数据
|
|
return removeDuplicateData(concernList, list);
|
|
}
|
|
})
|
|
.subscribeOn(Schedulers.io())
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
.subscribe(new Response<List<ConcernEntity>>() {
|
|
@Override
|
|
public void onResponse(List<ConcernEntity> response) {
|
|
isLoading = false;
|
|
|
|
if (response.size() != 0) {
|
|
concernList.addAll(response);
|
|
itemCount += response.size();
|
|
if (!fragment.isHidden() && !fragment.isEverpause()) {
|
|
notifyItemRangeInserted(concernList.size() - response.size(), response.size());
|
|
} else {
|
|
notifyDataSetChanged();
|
|
}
|
|
|
|
getNewsViews(response, offset);
|
|
getNewsCommentnum(response, offset);
|
|
} else {
|
|
isOver = true;
|
|
notifyItemChanged(getItemCount() - 1);
|
|
}
|
|
|
|
if (offset == 0 && listener != null) {
|
|
if (concernList.isEmpty()) {
|
|
listener.loadEmpty();
|
|
} else {
|
|
listener.loadDone();
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void onFailure(Throwable e) {
|
|
if (e instanceof HttpException) {
|
|
HttpException exception = (HttpException) e;
|
|
if (exception.code() == 409) {
|
|
loadDataByGameId(offset);
|
|
updateConcern();
|
|
return;
|
|
}
|
|
}
|
|
|
|
isLoading = false;
|
|
|
|
// 网络错误
|
|
if (offset == 0) {
|
|
if (listener != null) {
|
|
listener.loadError();
|
|
}
|
|
} else {
|
|
Toast.makeText(context, "加载失败,请检查网络状态", Toast.LENGTH_SHORT).show();
|
|
isNetworkError = true;
|
|
notifyItemChanged(getItemCount() - 1);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
private void loadDataByGameId(final int offset) {
|
|
RetrofitManager.getApi()
|
|
.getGuanZhuById(ids, offset)
|
|
.map(new Func1<List<ConcernEntity>, List<ConcernEntity>>() {
|
|
@Override
|
|
public List<ConcernEntity> call(List<ConcernEntity> list) {
|
|
// 去除重复数据
|
|
return removeDuplicateData(concernList, list);
|
|
}
|
|
})
|
|
.subscribeOn(Schedulers.io())
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
.subscribe(new Response<List<ConcernEntity>>() {
|
|
@Override
|
|
public void onResponse(List<ConcernEntity> response) {
|
|
isLoading = false;
|
|
|
|
if (response.size() != 0) {
|
|
concernList.addAll(response);
|
|
itemCount += response.size();
|
|
if (!fragment.isHidden() && !fragment.isEverpause()) {
|
|
notifyItemRangeInserted(concernList.size() - response.size(), response.size());
|
|
} else {
|
|
notifyDataSetChanged();
|
|
}
|
|
|
|
getNewsViews(response, offset);
|
|
getNewsCommentnum(response, offset);
|
|
} else {
|
|
isOver = true;
|
|
notifyItemChanged(getItemCount() - 1);
|
|
}
|
|
|
|
if (offset == 0 && listener != null) {
|
|
if (concernList.isEmpty()) {
|
|
listener.loadEmpty();
|
|
} else {
|
|
listener.loadDone();
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void onFailure(Throwable e) {
|
|
isLoading = false;
|
|
|
|
// 网络错误
|
|
if (offset == 0) {
|
|
if (listener != null) {
|
|
listener.loadError();
|
|
}
|
|
} else {
|
|
Toast.makeText(context, "加载失败,请检查网络状态", Toast.LENGTH_SHORT).show();
|
|
isNetworkError = true;
|
|
notifyItemChanged(getItemCount() - 1);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
// 去除重复数据
|
|
private static List<ConcernEntity> removeDuplicateData(List<ConcernEntity> sourceList, List<ConcernEntity> rawList) {
|
|
if (sourceList == null || sourceList.isEmpty()
|
|
|| rawList == null || rawList.isEmpty()) {
|
|
return rawList;
|
|
}
|
|
String id;
|
|
for (int i = 0; i < rawList.size(); i++) {
|
|
id = rawList.get(i).getId();
|
|
for (ConcernEntity concernEntity : sourceList) {
|
|
if (id.equals(concernEntity.getId())) {
|
|
rawList.remove(i);
|
|
i--;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return rawList;
|
|
}
|
|
|
|
// 更新设备关注
|
|
public void updateConcern() {
|
|
RequestBody body = RequestBody.create(MediaType.parse("application/json"),
|
|
new JSONArray(gameIdList).toString());
|
|
RetrofitManager.getApi().putConcern(TokenUtils.getDeviceId(context), body);
|
|
}
|
|
|
|
// 获取新闻阅读量
|
|
private void getNewsViews(final List<ConcernEntity> list, final int start) {
|
|
if (list == null || list.isEmpty()) {
|
|
return;
|
|
}
|
|
ObservableUtil.computation(new Observable.OnSubscribe<String>() {
|
|
@Override
|
|
public void call(Subscriber<? super String> subscriber) {
|
|
StringBuilder builder = new StringBuilder();
|
|
for (int i = 0, size = list.size(); i < size; i++) {
|
|
builder.append(list.get(i).getId());
|
|
builder.append("-");
|
|
}
|
|
builder.deleteCharAt(builder.length() - 1);
|
|
String ids = builder.toString();
|
|
VisitManager.getInstance().addUrl(ids);
|
|
subscriber.onNext(ids);
|
|
subscriber.onCompleted();
|
|
}
|
|
}, new Action1<String>() {
|
|
@Override
|
|
public void call(String ids) {
|
|
RetrofitManager.getData()
|
|
.getNewsViews(ids)
|
|
.map(new Func1<List<ViewsEntity>, String>() {
|
|
@Override
|
|
public String call(List<ViewsEntity> list) {
|
|
for (ViewsEntity viewsEntity : list) {
|
|
for (ConcernEntity concernEntity : concernList) {
|
|
if (viewsEntity.getId().equals(concernEntity.getId())) {
|
|
concernEntity.setViews(viewsEntity.getViews());
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
})
|
|
.subscribeOn(Schedulers.io())
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
.subscribe(new Response<String>() {
|
|
@Override
|
|
public void onResponse(String response) {
|
|
notifyItemRangeChanged(start, list.size());
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
// 获取新闻评论数
|
|
private void getNewsCommentnum(final List<ConcernEntity> list, final int start) {
|
|
if (list == null || list.isEmpty()) {
|
|
return;
|
|
}
|
|
ObservableUtil.computation(new Observable.OnSubscribe<String>() {
|
|
@Override
|
|
public void call(Subscriber<? super String> subscriber) {
|
|
StringBuilder builder = new StringBuilder();
|
|
for (int i = 0, size = list.size(); i < size; i++) {
|
|
builder.append(list.get(i).getId());
|
|
builder.append("-");
|
|
}
|
|
builder.deleteCharAt(builder.length() - 1);
|
|
CommentManager.getInstance().addUrl(builder.toString());
|
|
subscriber.onNext(builder.toString());
|
|
subscriber.onCompleted();
|
|
}
|
|
}, new Action1<String>() {
|
|
@Override
|
|
public void call(String ids) {
|
|
RetrofitManager.getComment()
|
|
.getNewsCommentnum(ids)
|
|
.map(new Func1<List<CommentnumEntity>, String>() {
|
|
@Override
|
|
public String call(List<CommentnumEntity> list) {
|
|
for (CommentnumEntity commentnumEntity : list) {
|
|
for (ConcernEntity concernEntity : concernList) {
|
|
if (commentnumEntity.getId().equals(concernEntity.getId())) {
|
|
concernEntity.setCommentnum(commentnumEntity.getNum());
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
})
|
|
.subscribeOn(Schedulers.io())
|
|
.observeOn(AndroidSchedulers.mainThread())
|
|
.subscribe(new Response<String>() {
|
|
@Override
|
|
public void onResponse(String response) {
|
|
notifyItemRangeChanged(start, list.size());
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
// 统计新闻阅读量
|
|
private void statNewsViews(final ConcernEntity concernEntity, final int position) {
|
|
RetrofitManager.getData().postNewsViews(concernEntity.getId(), new JSONObjectResponse(){
|
|
@Override
|
|
public void onResponse(JSONObject response) {
|
|
try {
|
|
if ("success".equals(response.getString("status"))) {
|
|
concernEntity.setViews(concernEntity.getViews() + 1);
|
|
|
|
notifyItemChanged(position);
|
|
|
|
// 更新okhttp缓存数据
|
|
VisitManager.updateOkhttpCache(concernEntity.getId());
|
|
}
|
|
} catch (JSONException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
@Override
|
|
public int getItemViewType(int position) {
|
|
if (position == concernList.size()) {
|
|
return ItemViewType.LOADING;
|
|
} else {
|
|
return ItemViewType.NEWS_DIGEST;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
|
if (viewType == ItemViewType.NEWS_DIGEST) {
|
|
View view = LayoutInflater.from(parent.getContext()).
|
|
inflate(R.layout.news_digest_item, parent, false);
|
|
return new NewsDigestViewHolder(view);
|
|
} else if (viewType == ItemViewType.LOADING) {
|
|
View view = LayoutInflater.from(parent.getContext()).
|
|
inflate(R.layout.refresh_footerview, parent, false);
|
|
return new FooterViewHolder(view);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
|
if (holder instanceof NewsDigestViewHolder) {
|
|
initNewsDigestViewHolder((NewsDigestViewHolder) holder, position);
|
|
} else if (holder instanceof FooterViewHolder) {
|
|
initFooterViewHolder((FooterViewHolder) holder);
|
|
}
|
|
}
|
|
|
|
private void initNewsDigestViewHolder(final NewsDigestViewHolder viewHolder, int position) {
|
|
|
|
final ConcernEntity concernEntity = concernList.get(position);
|
|
|
|
// 第一个
|
|
if (position == 0) {
|
|
((CardLinearLayout) viewHolder.itemView).setmTop(DisplayUtils.dip2px(context, 8));
|
|
} else {
|
|
((CardLinearLayout) viewHolder.itemView).setmTop(0);
|
|
}
|
|
|
|
// 最后一个
|
|
if (position == concernList.size() - 1) {
|
|
((CardLinearLayout) viewHolder.itemView).setBottom(true);
|
|
} else {
|
|
((CardLinearLayout) viewHolder.itemView).setBottom(false);
|
|
}
|
|
|
|
viewHolder.thumb.setImageURI(concernEntity.getGameIcon());
|
|
viewHolder.title.setText(concernEntity.getGameName());
|
|
NewsUtils.setNewsPublishOn(viewHolder.time, concernEntity.getTime());
|
|
|
|
if (concernEntity.getBrief() != null) {
|
|
viewHolder.content.setText(Html.fromHtml(concernEntity.getBrief()));
|
|
viewHolder.content.setMaxLines(100);
|
|
} else {
|
|
viewHolder.content.setText(Html.fromHtml(concernEntity.getContent()));
|
|
viewHolder.content.setMaxLines(5);
|
|
}
|
|
|
|
if (concernEntity.getImg().isEmpty()) {
|
|
viewHolder.imgLayout.setVisibility(View.GONE);
|
|
viewHolder.imgLayout.removeAllViews();
|
|
} else {
|
|
viewHolder.imgLayout.setVisibility(View.VISIBLE);
|
|
viewHolder.imgLayout.removeAllViews();
|
|
ConcernContentUtils.addContentPic(context.getResources().getDisplayMetrics().widthPixels
|
|
- DisplayUtils.dip2px(context, 34), viewHolder.imgLayout, concernEntity.getImg(), context);
|
|
}
|
|
|
|
int views = concernEntity.getViews();
|
|
if (views == 0) {
|
|
viewHolder.read.setVisibility(View.GONE);
|
|
} else {
|
|
viewHolder.read.setVisibility(View.VISIBLE);
|
|
viewHolder.read.setText(String.format(Locale.getDefault(), "阅读 %d", views));
|
|
}
|
|
|
|
int commentnum = concernEntity.getCommentnum();
|
|
if (commentnum == 0) {
|
|
viewHolder.commentnum.setVisibility(View.GONE);
|
|
} else {
|
|
viewHolder.commentnum.setVisibility(View.VISIBLE);
|
|
if (commentnum > 999) {
|
|
viewHolder.commentnum.setText(R.string.thousand);
|
|
} else {
|
|
viewHolder.commentnum.setText(String.valueOf(commentnum));
|
|
}
|
|
}
|
|
|
|
if (concernEntity.getLink() != null) {
|
|
viewHolder.link.setImageResource(R.drawable.link_iv);
|
|
} else {
|
|
viewHolder.link.setImageResource(R.drawable.concern_message_icon);
|
|
}
|
|
|
|
viewHolder.comment.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
public void onClick(View v) {
|
|
skipPosition = viewHolder.getPosition();
|
|
concernEntity.setItemHeight(viewHolder.itemView.getHeight());
|
|
AppController.put("ConcernEntity", concernEntity);
|
|
Intent intent = new Intent(context, MessageDetailActivity.class);
|
|
intent.putExtra("entrance", "(资讯-关注)");
|
|
fragment.startActivityForResult(intent, 0x125);
|
|
}
|
|
});
|
|
|
|
viewHolder.share.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
public void onClick(View v) {
|
|
String shareContent;
|
|
if (concernEntity.getBrief() != null) {
|
|
shareContent = concernEntity.getBrief();
|
|
} else {
|
|
shareContent = concernEntity.getContent();
|
|
}
|
|
if (concernEntity.getImg() != null && concernEntity.getImg().size() > 0) {
|
|
Intent intent = new Intent(context, ShareCardPicActivity.class);
|
|
Bundle bundle = new Bundle();
|
|
bundle.putString("gameName", concernEntity.getGameName());
|
|
bundle.putString("gameIconUrl", concernEntity.getGameIcon());
|
|
bundle.putString("shareContent", shareContent);
|
|
bundle.putStringArrayList("shareArrImg", (ArrayList<String>) concernEntity.getImg());
|
|
intent.putExtras(bundle);
|
|
context.startActivity(intent);
|
|
} else {
|
|
Intent intent = new Intent(context, ShareCardActivity.class);
|
|
Bundle bundle = new Bundle();
|
|
bundle.putString("gameName", concernEntity.getGameName());
|
|
bundle.putString("gameIconUrl", concernEntity.getGameIcon());
|
|
bundle.putString("shareContent", shareContent);
|
|
intent.putExtras(bundle);
|
|
context.startActivity(intent);
|
|
}
|
|
}
|
|
});
|
|
|
|
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
public void onClick(View v) {
|
|
Map<String, Object> kv = new HashMap<>();
|
|
kv.put("名字", concernEntity.getTitle());
|
|
kv.put("位置", String.valueOf(viewHolder.getPosition() + 1));
|
|
DataUtils.onEvent(context, "点击", "资讯-关注", kv);
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
map.put("location", "列表");
|
|
map.put("page", "资讯-关注");
|
|
map.put("news", concernEntity.getTitle());
|
|
map.put("news_id", concernEntity.getId());
|
|
DataCollectionManager.onEvent(context, "click-item", map);
|
|
|
|
//统计阅读量
|
|
statNewsViews(concernEntity, viewHolder.getPosition());
|
|
|
|
if (concernEntity.getLink() != null){
|
|
Intent intent = new Intent(context, WebActivity.class);
|
|
intent.putExtra("url", concernEntity.getLink());
|
|
intent.putExtra("gameName", concernEntity.getGameName());
|
|
context.startActivity(intent);
|
|
}else {
|
|
Intent intent = new Intent(context, NewsDetailActivity.class);
|
|
intent.putExtra("newsId", concernEntity.getId());
|
|
intent.putExtra("entrance", "(资讯-关注)");
|
|
context.startActivity(intent);
|
|
}
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
private void initFooterViewHolder(FooterViewHolder viewHolder) {
|
|
if (isNetworkError) {
|
|
viewHolder.loading.setVisibility(View.GONE);
|
|
viewHolder.hint.setText("加载失败,点击重试");
|
|
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
public void onClick(View v) {
|
|
isNetworkError = false;
|
|
notifyItemChanged(getItemCount() - 1);
|
|
loadDataByKey(concernList.size());
|
|
}
|
|
});
|
|
} else if (isOver) {
|
|
viewHolder.loading.setVisibility(View.GONE);
|
|
viewHolder.hint.setText("加载完毕");
|
|
viewHolder.itemView.setClickable(false);
|
|
} else {
|
|
viewHolder.loading.setVisibility(View.VISIBLE);
|
|
viewHolder.hint.setText("加载中...");
|
|
viewHolder.itemView.setClickable(false);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public int getItemCount() {
|
|
if (itemCount == 0){
|
|
return 0;
|
|
}
|
|
return itemCount + 1;
|
|
}
|
|
|
|
public int getConcernListSize() {
|
|
return concernList.size();
|
|
}
|
|
|
|
public boolean isNetworkError() {
|
|
return isNetworkError;
|
|
}
|
|
|
|
public void setNetworkError(boolean networkError) {
|
|
isNetworkError = networkError;
|
|
}
|
|
|
|
public boolean isOver() {
|
|
return isOver;
|
|
}
|
|
|
|
public boolean isLoading() {
|
|
return isLoading;
|
|
}
|
|
|
|
public int getSkipPosition() {
|
|
return skipPosition;
|
|
}
|
|
|
|
public void setSkipPosition(int skipPosition) {
|
|
this.skipPosition = skipPosition;
|
|
}
|
|
}
|