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

# Conflicts:
#	app/src/main/java/com/gh/gamecenter/adapter/viewholder/FooterViewHolder.java
#	app/src/main/java/com/gh/gamecenter/news/News1FragmentAdapter.java
This commit is contained in:
khy
2016-11-11 18:25:23 +08:00
40 changed files with 1072 additions and 985 deletions

View File

@ -2,6 +2,8 @@ package com.gh.common.util;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.widget.TextView;
import com.android.volley.Request;
import com.gh.base.AppController;
@ -13,13 +15,12 @@ import com.gh.gamecenter.entity.ConcernEntity;
import com.gh.gamecenter.entity.NewsEntity;
import com.gh.gamecenter.volley.extended.JsonObjectExtendedRequest;
import java.util.List;
public class NewsUtils {
/**
* 根据新闻类型获取标签背景资源
*
* @param type
* @return
*/
public static int getDrawableIdByType(String type) {
if ("活动".equals(type) || "高阶".equals(type)) {
@ -35,11 +36,6 @@ public class NewsUtils {
/**
* 启动新闻详情页面
*
* @param context
* @param newsEntity
* @param entrance
* @return
*/
public static void startNewsActivity(Context context, NewsEntity newsEntity, String entrance) {
Intent intent = new Intent(context, NewsDetailActivity.class);
@ -67,7 +63,6 @@ public class NewsUtils {
/**
* 统计阅读量
* @param news_id
*/
public static void statNewsViews(String news_id) {
String url = Config.DATA_HOST + "news/stat?news_id=" + news_id;
@ -77,4 +72,47 @@ public class NewsUtils {
AppController.addToRequestQueue(request);
}
/**
* 去除与重复sourceList相同的数据
*/
public static List<NewsEntity> removeDuplicateData(List<NewsEntity> sourceList, List<NewsEntity> 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 (NewsEntity newsEntity : sourceList) {
if (id.equals(newsEntity.getId())) {
rawList.remove(i);
i--;
break;
}
}
}
return rawList;
}
/**
* 设置新闻类型
*/
public static void setNewsType(TextView textView, String type) {
textView.setText(type);
textView.setTextColor(Color.WHITE);
if ("活动".equals(type)) {
textView.setBackgroundResource(R.drawable.textview_orange_style);
} else if ("公告".equals(type)) {
textView.setBackgroundResource(R.drawable.textview_red_style);
} else if ("评测".equals(type)) {
textView.setBackgroundResource(R.drawable.textview_red_style);
} else if ("杂谈".equals(type)) {
textView.setBackgroundResource(R.drawable.textview_orange_style);
} else if ("专题".equals(type)) {
textView.setBackgroundResource(R.drawable.textview_blue_style);
} else {
textView.setBackgroundResource(R.drawable.textview_blue_style);
}
}
}