提交项目
This commit is contained in:
53
app/src/main/java/com/gh/common/util/NewsUtils.java
Normal file
53
app/src/main/java/com/gh/common/util/NewsUtils.java
Normal file
@ -0,0 +1,53 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.gh.gamecenter.NewsActivity;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.entity.NewsDetailsEntity;
|
||||
import com.gh.gamecenter.entity.NewsEntity;
|
||||
|
||||
public class NewsUtils {
|
||||
|
||||
/**
|
||||
* 根据新闻类型获取标签背景资源
|
||||
*
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public static int getDrawableIdByType(String type) {
|
||||
if ("活动".equals(type) || "高阶".equals(type)) {
|
||||
return R.drawable.textview_red_up;
|
||||
} else if ("公告".equals(type) || "中期".equals(type)) {
|
||||
return R.drawable.textview_orange_up;
|
||||
} else if ("新游".equals(type)) {
|
||||
return R.drawable.textview_green_up;
|
||||
} else {
|
||||
return R.drawable.textview_blue_up;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动新闻详情页面
|
||||
*
|
||||
* @param context
|
||||
* @param newsEntity
|
||||
* @param entrance
|
||||
* @return
|
||||
*/
|
||||
public static void startNewsActivity(Context context,
|
||||
NewsEntity newsEntity, String entrance) {
|
||||
Intent intent = new Intent(context, NewsActivity.class);
|
||||
NewsDetailsEntity entity = new NewsDetailsEntity();
|
||||
entity.setId(newsEntity.getId());
|
||||
entity.setTitle(newsEntity.getTitle());
|
||||
entity.setType(newsEntity.getType());
|
||||
entity.setTime(newsEntity.getPublishOn());
|
||||
intent.putExtra("entity", entity);
|
||||
intent.putExtra("entrance", entrance);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user