diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index c59f647585..2bcd2eb8ba 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -38,8 +38,6 @@
-
-
+
+
+
diff --git a/app/src/main/java/com/gh/common/util/ConcernUtils.java b/app/src/main/java/com/gh/common/util/ConcernUtils.java
index f52bd2a07d..bb8fcfb24c 100644
--- a/app/src/main/java/com/gh/common/util/ConcernUtils.java
+++ b/app/src/main/java/com/gh/common/util/ConcernUtils.java
@@ -94,9 +94,6 @@ public class ConcernUtils {
}
public static void UpdateConcernData(final String url,String updateData,final DownJsonListener listener){
- if (updateData.length()<3){
- updateData = "";
- }
JSONArray jsonArray = null;
try {
jsonArray = new JSONArray(updateData);
diff --git a/app/src/main/java/com/gh/common/util/DownloadItemUtils.java b/app/src/main/java/com/gh/common/util/DownloadItemUtils.java
index 6b6b006eab..5aa8a8cc07 100644
--- a/app/src/main/java/com/gh/common/util/DownloadItemUtils.java
+++ b/app/src/main/java/com/gh/common/util/DownloadItemUtils.java
@@ -107,7 +107,7 @@ public class DownloadItemUtils {
}
}
- public static void updateItem(Context context, LinearLayout labelList,
+ public static void updateItem(Context context, TextView gameDes,
ProgressBar game_progressbar, LinearLayout game_ll_info,
TextView download_speed, TextView download_percentage,
TextView downloadBtn, GameEntity entity,
@@ -124,7 +124,7 @@ public class DownloadItemUtils {
&& entity.getApk().size() == 1
&& PackageManager.isInstalled(entity.getApk().get(0).getPackageName())
&& entity.getPluginPlatform() == null) {
- labelList.setVisibility(View.VISIBLE);
+ gameDes.setVisibility(View.VISIBLE);
game_progressbar.setVisibility(View.GONE);
game_ll_info.setVisibility(View.GONE);
downloadBtn.setText("启动");
@@ -151,7 +151,7 @@ public class DownloadItemUtils {
|| pluginPlatform.equals(PlatformUtils.getInstance(context)
.getPlatformName(downloadEntry.getMeta().get("platform"))))) {
- labelList.setVisibility(View.GONE);
+ gameDes.setVisibility(View.GONE);
game_progressbar.setVisibility(View.VISIBLE);
game_ll_info.setVisibility(View.VISIBLE);
@@ -258,7 +258,7 @@ public class DownloadItemUtils {
downloadBtn.setBackgroundResource(R.drawable.textview_blue_style);
downloadBtn.setTextColor(0xFFFFFFFF);
} else {
- labelList.setVisibility(View.VISIBLE);
+ gameDes.setVisibility(View.VISIBLE);
game_progressbar.setVisibility(View.GONE);
game_ll_info.setVisibility(View.GONE);
downloadBtn.setText("下载");
@@ -291,7 +291,7 @@ public class DownloadItemUtils {
break;
case cancel:
case hijack:
- labelList.setVisibility(View.VISIBLE);
+ gameDes.setVisibility(View.VISIBLE);
game_progressbar.setVisibility(View.GONE);
game_ll_info.setVisibility(View.GONE);
if (entity.getPluginPlatform() != null) {
@@ -308,7 +308,7 @@ public class DownloadItemUtils {
game_progressbar.setProgress((int) (downloadEntry
.getPercent() * 10));
} else {
- labelList.setVisibility(View.VISIBLE);
+ gameDes.setVisibility(View.VISIBLE);
game_progressbar.setVisibility(View.GONE);
game_ll_info.setVisibility(View.GONE);
if (entity.getApk() != null) {
@@ -322,7 +322,7 @@ public class DownloadItemUtils {
}
}
} else {
- labelList.setVisibility(View.VISIBLE);
+ gameDes.setVisibility(View.VISIBLE);
game_progressbar.setVisibility(View.GONE);
game_ll_info.setVisibility(View.GONE);
if (entity.getApk() != null) {
@@ -338,13 +338,13 @@ public class DownloadItemUtils {
}
}
- public static void updateItem(Context context, LinearLayout labelList,
+ public static void updateItem(Context context, TextView gameDes,
ProgressBar game_progressbar, LinearLayout game_ll_info,
TextView download_speed, TextView download_percentage,
TextView downloadBtn, GameEntity entity,
ArrayMap> platformMap,
ArrayMap statusMap) {
- updateItem(context, labelList, game_progressbar, game_ll_info,
+ updateItem(context, gameDes, game_progressbar, game_ll_info,
download_speed, download_percentage, downloadBtn, entity,
platformMap, statusMap, true);
}
diff --git a/app/src/main/java/com/gh/common/util/ImageUtils.java b/app/src/main/java/com/gh/common/util/ImageUtils.java
index bd1bbb0bf4..e591621a75 100644
--- a/app/src/main/java/com/gh/common/util/ImageUtils.java
+++ b/app/src/main/java/com/gh/common/util/ImageUtils.java
@@ -153,13 +153,16 @@ public class ImageUtils {
int width = loadedImage.getWidth();
int height = loadedImage.getHeight();
int widthPixels = context.getResources().getDisplayMetrics().widthPixels;
+ widthPixels = widthPixels -(int)(context.getResources().getDisplayMetrics().density*10);
float index = (float) height/(float) width;
int newHeight = (int)(index*widthPixels);
ViewGroup.LayoutParams layoutParams = imageView.getLayoutParams();
- layoutParams.height = newHeight;
- layoutParams.width = widthPixels;
- imageView.setLayoutParams(layoutParams);
+ if (layoutParams!=null){
+ layoutParams.height = newHeight;
+ layoutParams.width = widthPixels;
+ imageView.setLayoutParams(layoutParams);
+ }
if (imageView instanceof CircleImageView) {
imageView.setScaleType(ScaleType.CENTER_CROP);
diff --git a/app/src/main/java/com/gh/common/util/MeasureHeightLayoutManager.java b/app/src/main/java/com/gh/common/util/MeasureHeightLayoutManager.java
new file mode 100644
index 0000000000..07c1009582
--- /dev/null
+++ b/app/src/main/java/com/gh/common/util/MeasureHeightLayoutManager.java
@@ -0,0 +1,62 @@
+package com.gh.common.util;
+
+import android.content.Context;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.view.View;
+import android.view.ViewGroup;
+
+/**
+ * Created by khy on 2016/8/22.
+ * RecyclerView 自适应高度
+ */
+public class MeasureHeightLayoutManager extends LinearLayoutManager {
+
+ public MeasureHeightLayoutManager(Context context) {
+ super(context);
+ }
+
+ private int[] mMeasuredDimension = new int[1];
+ @Override
+ public void onMeasure(RecyclerView.Recycler recycler, RecyclerView.State state,
+ int widthSpec, int heightSpec) {
+
+ final int heightSize = View.MeasureSpec.getSize(heightSpec);
+
+ int height = 0;
+ for (int i = 0; i < getItemCount(); i++) {
+ measureScrapChild(recycler, i,
+ View.MeasureSpec.makeMeasureSpec(i, View.MeasureSpec.UNSPECIFIED),
+ View.MeasureSpec.makeMeasureSpec(i, View.MeasureSpec.UNSPECIFIED),
+ mMeasuredDimension);
+ height = height + mMeasuredDimension[0];
+
+ }
+ if (height>heightSize){
+ super.onMeasure(recycler, state, widthSpec, heightSpec);
+ }else {
+ setMeasuredDimension(View.MeasureSpec.getSize(widthSpec), height);
+ }
+
+ }
+
+
+ private void measureScrapChild(RecyclerView.Recycler recycler, int position, int widthSpec,
+ int heightSpec, int[] measuredDimension) {
+ View view = recycler.getViewForPosition(position);
+ if (view.getVisibility() == View.GONE) {
+ measuredDimension[0] = 0;
+ return;
+ }
+ super.measureChildWithMargins(view, 0, 0);
+ RecyclerView.LayoutParams p = (RecyclerView.LayoutParams) view.getLayoutParams();
+ int childHeightSpec = ViewGroup.getChildMeasureSpec(
+ heightSpec,
+ getPaddingTop() + getPaddingBottom() + getDecoratedTop(view) + getDecoratedBottom(view),
+ p.height);
+
+ view.measure(0, childHeightSpec);
+ measuredDimension[0] = getDecoratedMeasuredHeight(view) + p.bottomMargin + p.topMargin;
+ recycler.recycleView(view);
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/gh/common/view/ChildLinearLayoutManager.java b/app/src/main/java/com/gh/common/view/ChildLinearLayoutManager.java
new file mode 100644
index 0000000000..d1fd68b4bf
--- /dev/null
+++ b/app/src/main/java/com/gh/common/view/ChildLinearLayoutManager.java
@@ -0,0 +1,67 @@
+package com.gh.common.view;
+
+import android.content.Context;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.view.View;
+import android.view.ViewGroup;
+
+/**
+ * Created by khy on 2016/8/9.
+ */
+public class ChildLinearLayoutManager extends LinearLayoutManager {
+
+ public ChildLinearLayoutManager(Context context) {
+ super(context);
+ }
+
+ public ChildLinearLayoutManager(Context context, int orientation, boolean reverseLayout) {
+ super(context, orientation, reverseLayout);
+ }
+ @Override
+ public boolean canScrollVertically() {
+ return false;
+ }
+ private int[] mMeasuredDimension = new int[1];
+
+ @Override
+ public void onMeasure(RecyclerView.Recycler recycler, RecyclerView.State state,
+ int widthSpec, int heightSpec) {
+
+ final int heightMode = View.MeasureSpec.getMode(heightSpec);
+ final int heightSize = View.MeasureSpec.getSize(heightSpec);
+
+ int height = 0;
+ for (int i = 0; i < getItemCount(); i++) {
+ measureScrapChild(recycler, i,
+ View.MeasureSpec.makeMeasureSpec(i, View.MeasureSpec.UNSPECIFIED),
+ View.MeasureSpec.makeMeasureSpec(i, View.MeasureSpec.UNSPECIFIED),
+ mMeasuredDimension);
+ height = height + mMeasuredDimension[0];
+
+ }
+ if (heightMode == View.MeasureSpec.EXACTLY){
+ height = heightSize;
+ }
+
+ setMeasuredDimension(View.MeasureSpec.getSize(widthSpec), height);
+ }
+
+ private void measureScrapChild(RecyclerView.Recycler recycler, int position, int widthSpec,
+ int heightSpec, int[] measuredDimension) {
+ View view = recycler.getViewForPosition(position);
+ if (view.getVisibility() == View.GONE) {
+ measuredDimension[0] = 0;
+ return;
+ }
+ super.measureChildWithMargins(view, 0, 0);
+ RecyclerView.LayoutParams p = (RecyclerView.LayoutParams) view.getLayoutParams();
+ int childHeightSpec = ViewGroup.getChildMeasureSpec(
+ heightSpec,
+ getPaddingTop() + getPaddingBottom() + getDecoratedTop(view) + getDecoratedBottom(view),
+ p.height);
+ view.measure(0, childHeightSpec);
+ measuredDimension[0] = getDecoratedMeasuredHeight(view) + p.bottomMargin + p.topMargin;
+ recycler.recycleView(view);
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/gh/gamecenter/ConcernActivity.java b/app/src/main/java/com/gh/gamecenter/ConcernActivity.java
index ad5b27a862..82def40c44 100644
--- a/app/src/main/java/com/gh/gamecenter/ConcernActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/ConcernActivity.java
@@ -19,6 +19,7 @@ import com.gh.base.AppController;
import com.gh.base.BaseActivity;
import com.gh.common.constant.Config;
import com.gh.common.constant.Constants;
+import com.gh.common.util.ConcernUtils;
import com.gh.common.util.DataUtils;
import com.gh.common.util.ImageUtils;
import com.gh.common.util.TimestampUtils;
@@ -462,6 +463,22 @@ public class ConcernActivity extends BaseActivity implements OnClickListener {
@Override
protected void onDestroy() {
super.onDestroy();
+ String uuid = ConcernUtils.UUID(this);
+ JSONArray jsonArray = new JSONArray();
+ for (ConcernInfo concernInfo : manager.getConcernGame()) {
+ jsonArray.put(concernInfo.getId());
+ }
+ ConcernUtils.UpdateConcernData(Config.HOST + "v2d0/device/" + uuid + "/concern", jsonArray.toString(), new ConcernUtils.DownJsonListener() {
+ @Override
+ public void downSucced(String str) {
+ Utils.log("更新设备关注游戏成功");
+ }
+
+ @Override
+ public void downFailed() {
+ Utils.log("更新设备关注游戏失败");
+ }
+ });
view = null;
concern_rv_show = null;
concern_rv_recommend = null;
diff --git a/app/src/main/java/com/gh/gamecenter/GameDeatilsNewsActivity.java b/app/src/main/java/com/gh/gamecenter/GameDeatilsNewsActivity.java
new file mode 100644
index 0000000000..015566f5d8
--- /dev/null
+++ b/app/src/main/java/com/gh/gamecenter/GameDeatilsNewsActivity.java
@@ -0,0 +1,390 @@
+package com.gh.gamecenter;
+
+import android.content.Intent;
+import android.graphics.Color;
+import android.graphics.drawable.GradientDrawable;
+import android.graphics.drawable.StateListDrawable;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Handler;
+import android.support.v7.widget.CardView;
+import android.support.v7.widget.RecyclerView;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+import android.widget.RadioButton;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.android.volley.Response;
+import com.android.volley.VolleyError;
+import com.gh.base.AppController;
+import com.gh.base.BaseActivity;
+import com.gh.common.constant.Config;
+import com.gh.common.util.DisplayUtils;
+import com.gh.common.util.MeasureHeightLayoutManager;
+import com.gh.common.view.VerticalItemDecoration;
+import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
+import com.gh.gamecenter.entity.NewsEntity;
+import com.gh.gamecenter.volley.extended.JsonArrayExtendedRequest;
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+
+import org.json.JSONArray;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by khy on 2016/8/19.
+ */
+public class GameDeatilsNewsActivity extends BaseActivity{
+
+ private LinearLayout mNewsTypeLl;
+ private LinearLayout llLoading;
+ private LinearLayout noConnection;
+ private RecyclerView mNewsRecyclerView;
+ private TextView tvSearch;
+ private EditText edSearch;
+ private MeasureHeightLayoutManager layoutManager;
+ private CardView cardView;
+
+ private ArrayList listType = new ArrayList<>();
+ private List newsEntities;
+
+ private int selectI = 0;
+ private int selectJ = 0;
+ private String gameId ;
+
+ private GameDeatilsNewsAdapter newsAdapter;
+ private String newsType = null;
+ private int page = 1;
+
+
+ private boolean isLoadOver = true;
+ private boolean isRemove = false;
+ private boolean isNetworkError = false;
+
+ private Handler handler = new Handler();
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ final Intent intent = getIntent();
+ final String gameName = intent.getExtras().getString("gameName");
+ gameId = intent.getExtras().getString("gameId");
+
+ ArrayList articleTypes = intent.getExtras().getStringArrayList("articleTypes");
+ View view = View.inflate(this, R.layout.activity_gamedetails_news, null);
+ init(view,gameName);
+
+ newsEntities = new ArrayList<>();
+ mNewsTypeLl = (LinearLayout) findViewById(R.id.gamedetails_news_type_ll);
+ listType.add("全部");
+ listType.addAll(articleTypes);
+ initNewsType();
+
+ mNewsRecyclerView = (RecyclerView) findViewById(R.id.gamedetails_news_rv);
+ noConnection = (LinearLayout) findViewById(R.id.reuse_no_connection);
+ llLoading = (LinearLayout) findViewById(R.id.gamedetails_news_ll_loading);
+ cardView = (CardView) findViewById(R.id.gamedetails_news_cardView);
+ layoutManager = new MeasureHeightLayoutManager(this);
+ mNewsRecyclerView.setLayoutManager(layoutManager);
+ newsAdapter = new GameDeatilsNewsAdapter();
+ mNewsRecyclerView.setAdapter(newsAdapter);
+ mNewsRecyclerView.addItemDecoration(new VerticalItemDecoration(GameDeatilsNewsActivity.this, 1));
+
+ tvSearch = (TextView) findViewById(R.id.tv_search);
+ edSearch = (EditText) findViewById(R.id.et_search);
+
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ LoadNewsData(page);
+ }
+ }).start();
+
+ tvSearch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ String searchKey = edSearch.getText().toString().trim();
+ if (searchKey.length()>=1){
+ Intent intent1 = new Intent(getApplicationContext(),NewsSearchActivity.class);
+ intent1.putExtra("gameName",gameName);
+ intent1.putExtra("searchKey",searchKey);
+ intent1.putExtra("gameId",gameId);
+ startActivity(intent1);
+ }else {
+ Toast.makeText(getApplicationContext(),"请输入关键字",Toast.LENGTH_SHORT).show();
+ }
+ }
+ });
+ mNewsRecyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
+ @Override
+ public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
+ super.onScrollStateChanged(recyclerView, newState);
+ if (newState == RecyclerView.SCROLL_STATE_IDLE &&layoutManager.findLastVisibleItemPosition() + 1 == newsAdapter.getItemCount()&&isLoadOver&&!isRemove){
+ isLoadOver = false;
+ page++;
+ LoadNewsData(page);
+ }
+ }
+ });
+ noConnection.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+
+ noConnection.setVisibility(View.GONE);
+ llLoading.setVisibility(View.VISIBLE);
+ cardView.setVisibility(View.GONE);
+ handler.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ LoadNewsData(1);
+ }
+ },1000);
+ }
+ });
+
+ }
+ public StateListDrawable selectorBg(){
+
+ GradientDrawable roundCornerShape1 = createRoundCornerShape(2, 50, Color.parseColor("#b3b3b3"), Color.parseColor("#ffffff"));
+ GradientDrawable roundCornerShape2 = createRoundCornerShape(0, 50, Color.TRANSPARENT, Color.parseColor("#00b7fa"));
+ GradientDrawable roundCornerShape3 = createRoundCornerShape(0, 50, Color.TRANSPARENT, Color.parseColor("#59d3ff"));
+ StateListDrawable bg_install = new StateListDrawable();
+
+ bg_install.addState(new int[] { android.R.attr.state_pressed,android.R.attr.state_enabled},
+ roundCornerShape3);
+ bg_install.addState(new int[] { android.R.attr.state_selected,android.R.attr.state_enabled },
+ roundCornerShape2);
+ bg_install.addState(new int[] {}, roundCornerShape1);
+
+ return bg_install;
+ }
+
+ private void initNewsType() {
+
+ int width = (getResources().getDisplayMetrics().widthPixels - DisplayUtils.dip2px(this,30+10*4))/5;
+ int index = 0;
+ int typeCount =listType.size();
+ int size;
+
+ mNewsTypeLl.removeAllViews();
+
+ for (int i = 0;i=0){
+ size = 5;
+ }else {
+ size = typeCount;
+ }
+ for (int j = 0;j() {
+ @Override
+ public void onResponse(JSONArray response) {
+ Gson gson = new Gson();
+ ArrayList news = gson.fromJson(
+ response.toString(),
+ new TypeToken>() {
+ }.getType());
+ newsEntities.addAll(news);
+ newsAdapter.notifyDataSetChanged();
+ isLoadOver = true;
+ llLoading.setVisibility(View.GONE);
+ cardView.setVisibility(View.VISIBLE);
+ if (news.isEmpty() || (news.size() < 20)) {
+ isRemove = true;
+ newsAdapter.notifyItemChanged(newsAdapter.getItemCount() - 1);
+ }
+ }
+ }, new Response.ErrorListener() {
+ @Override
+ public void onErrorResponse(VolleyError error) {
+ if (page ==1){
+ noConnection.setVisibility(View.VISIBLE);
+ llLoading.setVisibility(View.GONE);
+ }
+ isLoadOver = true;
+ Toast.makeText(GameDeatilsNewsActivity.this, "网络错误", Toast.LENGTH_SHORT).show();
+ isNetworkError = true;
+ newsAdapter.notifyItemChanged(newsAdapter.getItemCount() - 1);
+ }
+ });
+ AppController.addToRequestQueue(request,GameDeatilsNewsActivity.class);
+ }
+
+ // 绘图圆角带填充色
+ public GradientDrawable createRoundCornerShape(int strokeWidth,int roundRadius, int strokeColor, int fillColor) {
+ GradientDrawable gd = new GradientDrawable();
+ gd.setColor(fillColor);
+ gd.setCornerRadius(roundRadius);
+ gd.setStroke(strokeWidth, strokeColor);
+ return gd;
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mNewsTypeLl = null;
+ mNewsRecyclerView = null;
+ listType = null;
+ gameId = null;
+ newsEntities = null;
+ newsAdapter = null;
+ newsType = null;
+ tvSearch = null;
+ edSearch = null;
+ layoutManager = null;
+ llLoading = null;
+ noConnection = null;
+ cardView = null;
+
+ }
+
+ public class GameDeatilsNewsAdapter extends RecyclerView.Adapter{
+ @Override
+ public int getItemViewType(int position) {
+ if (position == newsEntities.size()) {
+ return 0;
+ }else {
+ return 1;
+ }
+ }
+
+ @Override
+ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ if (viewType == 0){
+ View view = LayoutInflater.from(parent.getContext()).inflate(
+ R.layout.refresh_footerview, parent, false);
+ return new FooterViewHolder(view);
+ }else {
+ TextView textView = new TextView(getApplicationContext());
+ textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
+ textView.setPadding(DisplayUtils.dip2px(GameDeatilsNewsActivity.this,10),DisplayUtils.dip2px(GameDeatilsNewsActivity.this,10),0,DisplayUtils.dip2px(GameDeatilsNewsActivity.this,10));
+ textView.setTextColor(Color.parseColor("#3a3a3a"));
+ textView.setBackgroundResource(R.drawable.cardview_item_style);
+ textView.setSingleLine();
+ return new ViewHolder(textView);
+ }
+ }
+
+ @Override
+ public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
+ if (holder instanceof ViewHolder){
+ ((ViewHolder) holder).textView.setText(newsEntities.get(position).getTitle());
+ holder.itemView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intent = new Intent(getApplicationContext(),NewsActivity.class);
+ intent.putExtra("newsId",newsEntities.get(position).getId());
+ intent.putExtra("entrance","游戏详情-全部资讯");
+ startActivity(intent);
+ }
+ });
+ }else if (holder instanceof FooterViewHolder){
+ FooterViewHolder viewHolder = (FooterViewHolder) holder;
+ if (isNetworkError) {
+ viewHolder.footerview_progressbar.setVisibility(View.GONE);
+ viewHolder.footerview_tv_loading.setText("加载失败,点击重试");
+ viewHolder.itemView.setClickable(true);
+ viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ isNetworkError = false;
+ notifyItemChanged(getItemCount() - 1);
+ LoadNewsData(page);
+ }
+ });
+ } else if (isRemove) {
+ viewHolder.footerview_progressbar.setVisibility(View.GONE);
+ viewHolder.footerview_tv_loading.setText("加载完毕");
+ viewHolder.itemView.setClickable(false);
+ } else {
+ viewHolder.footerview_progressbar.setVisibility(View.VISIBLE);
+ viewHolder.footerview_tv_loading.setText("加载中...");
+ viewHolder.itemView.setClickable(false);
+ }
+ }
+
+ }
+
+ @Override
+ public int getItemCount() {
+ if (newsEntities.isEmpty()){
+ return 0;
+ }
+ return newsEntities.size()+1;
+ }
+
+ public class ViewHolder extends RecyclerView.ViewHolder{
+ TextView textView;
+ public ViewHolder(View itemView) {
+ super(itemView);
+ textView = (TextView) itemView;
+ }
+ }
+ }
+
+}
diff --git a/app/src/main/java/com/gh/gamecenter/NewGameDetailsActivity.java b/app/src/main/java/com/gh/gamecenter/NewGameDetailsActivity.java
index 887f45954b..3e0a52bb6c 100644
--- a/app/src/main/java/com/gh/gamecenter/NewGameDetailsActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/NewGameDetailsActivity.java
@@ -77,16 +77,19 @@ import de.greenrobot.event.EventBus;
* Created by khy on 2016/8/12.
*/
public class NewGameDetailsActivity extends BaseActivity implements View.OnClickListener{
+
+ private Context context = this;
+
private String gameId ;
private String entrance;
private GameDetailsAdapter detailsAdapter;
- private Context context = this;
private RecyclerView detailsRecyclerView;
private LinearLayout llLoading;
private LinearLayout noConnection;
private GameDetailsEntity entity = new GameDetailsEntity();
private GameEntity gameEntity;
private TextView tvDowload,tvPer;
+ private ImageView iv_share;
private ProgressBar progressBar;
private ArrayMap statusMap;
private DismissEntity dismissEntity;
@@ -117,10 +120,20 @@ public class NewGameDetailsActivity extends BaseActivity implements View.OnClick
}
}
};
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View contentView = View.inflate(this, R.layout.activity_new_gamedetails, null);
+ RelativeLayout reuse_actionbar = (RelativeLayout) contentView.findViewById(R.id.reuse_actionbar);
+ iv_share = new ImageView(this);
+ iv_share.setImageResource(R.drawable.share_icon);
+ float dp = getResources().getDisplayMetrics().density;
+ RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams((int)(dp*20),(int)(dp*20));
+ params.addRule( RelativeLayout.CENTER_VERTICAL);
+ params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT );
+ params.setMargins(0,0,(int)(dp*10),0);
+ reuse_actionbar.addView(iv_share,params);
gameId = getIntent().getStringExtra("gameId");
entrance = getIntent().getStringExtra("entrance");
if (gameId != null) {
@@ -159,6 +172,7 @@ public class NewGameDetailsActivity extends BaseActivity implements View.OnClick
tvDowload.setOnClickListener(this);
tvPer.setOnClickListener(this);
noConnection.setOnClickListener(this);
+ iv_share.setOnClickListener(this);
}
@Override
@@ -235,6 +249,23 @@ public class NewGameDetailsActivity extends BaseActivity implements View.OnClick
getGameDetail();
}
},1000);
+ break;
+ }
+ if (v == iv_share){
+ Map kv = new HashMap();
+ kv.put("点击", "分享");
+ DataUtils.onEvent(this, "插件数据", gameEntity.getName(), kv);
+
+ Map map = new HashMap();
+ map.put("location", "分享");
+ map.put("createOn", System.currentTimeMillis() / 1000);
+ map.put("news", gameEntity.getName());
+ map.put("page", "游戏详情");
+ DataCollectionManager.onEvent(this, "click-item", map);
+
+ String url = "http://112.124.59.31/game_center/static/game_"
+ + gameEntity.getId() + ".html";
+ showShare(url, gameEntity.getName(), gameEntity.getIcon(), entrance, "游戏");
}
}
private void invalidate() {
@@ -680,6 +711,7 @@ public class NewGameDetailsActivity extends BaseActivity implements View.OnClick
RelativeLayout rlChild = (RelativeLayout) LayoutInflater.from(context).inflate(R.layout.gamedetails_zixun_item,null);
TextView tv_tag = (TextView) rlChild.findViewById(R.id.gamedetails_rv_item_zixun_tag);
TextView tv_title = (TextView) rlChild.findViewById(R.id.gamedetails_rv_item_zixun_title);
+ rlChild.setBackgroundResource(R.drawable.cardview_item_style);
tv_tag.setText(entity.getNews().get(i).getType());
tv_title.setText(entity.getNews().get(i).getTitle());
llContainer.addView(rlChild);
diff --git a/app/src/main/java/com/gh/gamecenter/NewsActivity.java b/app/src/main/java/com/gh/gamecenter/NewsActivity.java
index 97c2c5108a..1bc7f0545c 100644
--- a/app/src/main/java/com/gh/gamecenter/NewsActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/NewsActivity.java
@@ -12,6 +12,7 @@ import android.os.Message;
import android.os.SystemClock;
import android.support.v4.util.ArrayMap;
import android.support.v4.view.MotionEventCompat;
+import android.support.v7.widget.CardView;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
@@ -45,6 +46,7 @@ import com.gh.base.AppController;
import com.gh.base.BaseActivity;
import com.gh.common.constant.Config;
import com.gh.common.constant.Constants;
+import com.gh.common.util.ConcernUtils;
import com.gh.common.util.DataUtils;
import com.gh.common.util.DialogUtils;
import com.gh.common.util.DisplayUtils;
@@ -143,6 +145,8 @@ public class NewsActivity extends BaseActivity implements OnClickListener {
private int scrollSize = 300;//滑动距离超过300触发事件(放大缩小字体)
private SharedPreferences sp;
private int fontsize;
+ private boolean isConcern = false;
+ private int concernCode = 0;//0关注不做操作,1添加关注,2删除关注
private DataWatcher dataWatcher = new DataWatcher() {
@Override
@@ -169,11 +173,10 @@ public class NewsActivity extends BaseActivity implements OnClickListener {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
View contentView = View.inflate(this, R.layout.activity_essaydetails, null);
RelativeLayout reuse_actionbar = (RelativeLayout) contentView.findViewById(R.id.reuse_actionbar);
iv_share = new ImageView(this);
- iv_share.setImageResource(R.drawable.news_details_more);
+ iv_share.setImageResource(R.drawable.share_icon);
float dp = getResources().getDisplayMetrics().density;
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams((int)(dp*20),(int)(dp*20));
params.addRule( RelativeLayout.CENTER_VERTICAL);
@@ -420,8 +423,13 @@ public class NewsActivity extends BaseActivity implements OnClickListener {
String url = "http://news.ghzhushou.com/" + entity.getId()
+ ".html";
- showShare(url, entity.getTitle(), gameEntity.getIcon(), entrance,
- "新闻");
+ if (gameEntity == null){
+ showShare(url, entity.getTitle(), "http://image.ghzhushou.com/pic/56976f928ab49edc6e8b45f1.png", entrance,
+ "新闻");
+ }else {
+ showShare(url, entity.getTitle(), gameEntity.getIcon(), entrance,
+ "新闻");
+ }
} else if (v == essaydetails_progressbar || v == essaydetails_tv_per) {
String str = essaydetails_tv_per.getText().toString();
if ("继续".equals(str)) {
@@ -792,49 +800,52 @@ public class NewsActivity extends BaseActivity implements OnClickListener {
}
private void showSuccessDialog() {
- final Dialog dialog = new Dialog(this);
- View view = View.inflate(this, R.layout.gamedetails_attention_dialog,
- null);
- TextView title = (TextView) view.findViewById(R.id.dialog_title);
- title.setText("关注成功");
- TextView confirm = (TextView) view.findViewById(R.id.dialog_confirm);
- confirm.setText("我知道了");
- confirm.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- dialog.dismiss();
- }
- });
- TextView message = (TextView) view.findViewById(R.id.dialog_message);
- message.setText("游戏的最新动态消息会优先提醒您,包括攻略、资讯、开服信息、开测信息以及最新的插件。");
- view.findViewById(R.id.dialog_rl_cancel).setVisibility(View.GONE);
- dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
- dialog.setContentView(view);
- dialog.show();
+// final Dialog dialog = new Dialog(this);
+// View view = View.inflate(this, R.layout.gamedetails_attention_dialog,
+// null);
+// TextView title = (TextView) view.findViewById(R.id.dialog_title);
+// title.setText("关注成功");
+// TextView confirm = (TextView) view.findViewById(R.id.dialog_confirm);
+// confirm.setText("我知道了");
+// confirm.setOnClickListener(new OnClickListener() {
+// @Override
+// public void onClick(View v) {
+// dialog.dismiss();
+// }
+// });
+// TextView message = (TextView) view.findViewById(R.id.dialog_message);
+// message.setText("游戏的最新动态消息会优先提醒您,包括攻略、资讯、开服信息、开测信息以及最新的插件。");
+// view.findViewById(R.id.dialog_rl_cancel).setVisibility(View.GONE);
+// dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
+// dialog.setContentView(view);
+// dialog.show();
+ Toast.makeText(this,"关注成功",Toast.LENGTH_SHORT).show();
}
private void showCancelDialog(final TextView attention) {
final Dialog dialog = new Dialog(this);
- View view = View.inflate(this, R.layout.gamedetails_attention_dialog,
+ View view = View.inflate(this, R.layout.common_alertdialog,
null);
- TextView title = (TextView) view.findViewById(R.id.dialog_title);
+ TextView title = (TextView) view.findViewById(R.id.alertdialog_title);
title.setText("取消关注");
- TextView cancel = (TextView) view.findViewById(R.id.dialog_cancel);
- cancel.setText("取消");
+ TextView cancel = (TextView) view.findViewById(R.id.alertdialog_cannel);
+ cancel.setText("暂不取消");
+ TextView confirm = (TextView) view.findViewById(R.id.alertdialog_confirm);
+ confirm.setText("确定取消");
cancel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
- TextView message = (TextView) view.findViewById(R.id.dialog_message);
+ TextView message = (TextView) view.findViewById(R.id.alertdialog_content);
Spanned content = Html
.fromHtml("取消关注游戏后,您将无法及时收到游戏的攻略、资讯等最新动态提醒,您确定取消吗?");
message.setText(content);
- view.findViewById(R.id.dialog_rl_confirm).setVisibility(View.VISIBLE);
- view.findViewById(R.id.dialog_confirm).setOnClickListener(
+// view.findViewById(R.id.dialog_rl_confirm).setVisibility(View.VISIBLE);
+ view.findViewById(R.id.alertdialog_confirm).setOnClickListener(
new OnClickListener() {
@Override
public void onClick(View v) {
@@ -852,6 +863,7 @@ public class NewsActivity extends BaseActivity implements OnClickListener {
"concern", map);
concernManager.deleteConcern(gameEntity.getId());
+ concernCode = 2;
dialog.dismiss();
attention.setText("关注");
attention
@@ -926,6 +938,7 @@ public class NewsActivity extends BaseActivity implements OnClickListener {
private LinearLayout news_item_ll;
private TextView news_type, news_title;
+ private CardView cardView;
public NewsViewHolder(View view, int viewType) {
super(view);
@@ -943,6 +956,7 @@ public class NewsActivity extends BaseActivity implements OnClickListener {
essaydetails_author = (TextView) view.findViewById(R.id.essaydetails_author);
essaydetails_wv_content = (WebView) view.findViewById(R.id.essaydetails_wv_content);
essaydetails_wv_content.setBackgroundColor(0);
+ cardView = (CardView) view.findViewById(R.id.essaydetails_cv);
} else if (viewType == 1) {
news_item_ll = (LinearLayout) view.findViewById(R.id.essaydetails_more_news_item_ll);
}
@@ -974,6 +988,7 @@ public class NewsActivity extends BaseActivity implements OnClickListener {
DataCollectionManager.onEvent(NewsActivity.this, "concern", map);
concernManager.addByEntity(gameEntity);
+ concernCode = 1;
essaydetails_attention.setText("取消关注");
essaydetails_attention.setBackgroundResource(R.drawable.border_red_bg);
essaydetails_attention.setTextColor(0xffbc2132);
@@ -1016,9 +1031,14 @@ public class NewsActivity extends BaseActivity implements OnClickListener {
if (position == 0) {
if (gameEntity != null && !gameEntity.getName().contains("光环助手")) {
holder.essaydetails_ll_top.setVisibility(View.VISIBLE);
+ holder.cardView.setVisibility(View.VISIBLE);
ImageUtils.getInstance(getApplicationContext()).displayFile(gameEntity.getIcon(), holder.essaydetails_icon);
- holder.essaydetails_name.setText(gameEntity.getName());
- if (concernManager.isConcern(gameEntity.getId())) {
+ for (int i = 0; i < concernManager.getAllConcern().size(); i++) {
+ if (concernManager.getAllConcern().get(i).getId().equals(gameEntity.getId())){
+ isConcern = true;
+ }
+ }
+ if (isConcern) {
holder.essaydetails_attention.setText("取消关注");
holder.essaydetails_attention.setBackgroundResource(R.drawable.border_red_bg);
holder.essaydetails_attention.setTextColor(0xffbc2132);
@@ -1041,6 +1061,7 @@ public class NewsActivity extends BaseActivity implements OnClickListener {
}
} else {
holder.essaydetails_ll_top.setVisibility(View.GONE);
+ holder.cardView.setVisibility(View.GONE);
}
holder.essaydetails_title.setText(entity.getTitle());
@@ -1341,6 +1362,37 @@ public class NewsActivity extends BaseActivity implements OnClickListener {
@Override
protected void onDestroy() {
super.onDestroy();
+ String uuid = ConcernUtils.UUID(this);
+ if (isConcern == true&&concernCode ==2 && gameEntity.getId()!=null){
+ //取消关注
+ ConcernUtils.DeleteConcernData(Config.HOST + "v2d0/device/" + uuid + "/concern/" + gameEntity.getId(), new ConcernUtils.DownJsonListener() {
+ @Override
+ public void downSucced(String str) {
+ Utils.log("删除提交成功==游戏详情");
+ }
+
+ @Override
+ public void downFailed() {
+ Utils.log("删除提交失败==游戏详情");
+ }
+ });
+
+ }else if (isConcern == false&& concernCode == 1&& gameEntity.getId()!=null){
+ //添加关注
+ ConcernUtils.PostConcernGameId("[" + gameEntity.getId() + "]", Config.HOST + "v2d0/device/" + uuid + "/concern", new ConcernUtils.DownJsonListener() {
+ @Override
+ public void downSucced(String str) {
+ Utils.log("关注提交成功==游戏详情");
+ }
+
+ @Override
+ public void downFailed() {
+ Utils.log("关注提交失败==游戏详情");
+ }
+ });
+ }else {
+ Utils.log("无关注操作==游戏详情");
+ }
isDestroy = true;
AppController.canclePendingRequests(NewsActivity.class);
essaydetails_ll_loading = null;
diff --git a/app/src/main/java/com/gh/gamecenter/NewsSearchActivity.java b/app/src/main/java/com/gh/gamecenter/NewsSearchActivity.java
new file mode 100644
index 0000000000..47644cd3e8
--- /dev/null
+++ b/app/src/main/java/com/gh/gamecenter/NewsSearchActivity.java
@@ -0,0 +1,299 @@
+package com.gh.gamecenter;
+
+import android.content.Intent;
+import android.graphics.Color;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Handler;
+import android.support.v7.widget.CardView;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.android.volley.Response;
+import com.android.volley.VolleyError;
+import com.gh.base.AppController;
+import com.gh.base.BaseActivity;
+import com.gh.common.constant.Config;
+import com.gh.common.util.DisplayUtils;
+import com.gh.common.util.MeasureHeightLayoutManager;
+import com.gh.common.view.VerticalItemDecoration;
+import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
+import com.gh.gamecenter.entity.NewsEntity;
+import com.gh.gamecenter.volley.extended.JsonArrayExtendedRequest;
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+
+import org.json.JSONArray;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by khy on 2016/8/22.
+ */
+public class NewsSearchActivity extends BaseActivity {
+
+ private RecyclerView mNewsRecyclerView;
+ private List newsEntities;
+ private NewsSearchAdapter searchAdapter;
+ private TextView tvSearch, searchNonews;
+ private EditText edSearch;
+ private LinearLayout llLoading;
+ private LinearLayout noConnection;
+ private CardView cardView;
+
+ private MeasureHeightLayoutManager layoutManager;
+
+ private boolean isLoadOver = true;
+ private boolean isRemove = false;
+ private boolean isNetworkError = false;
+
+ private String gameName;
+ private String searchKey;
+ private String gameId;
+
+ private Handler handler = new Handler();
+
+ private int page = 1;
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ Intent intent = getIntent();
+ gameName = intent.getExtras().getString("gameName");
+ searchKey = intent.getExtras().getString("searchKey");
+ gameId = intent.getExtras().getString("gameId");
+
+ View view = View.inflate(this, R.layout.activity_gamedetails_news, null);
+ init(view,gameName);
+
+ newsEntities = new ArrayList<>();
+ searchAdapter = new NewsSearchAdapter();
+
+ findViewById(R.id.gamedetails_news_type_ll).setVisibility(View.GONE);
+ findViewById(R.id.ll_search).setVisibility(View.VISIBLE);
+
+ mNewsRecyclerView = (RecyclerView) findViewById(R.id.gamedetails_news_rv);
+ noConnection = (LinearLayout) findViewById(R.id.reuse_no_connection);
+ llLoading = (LinearLayout) findViewById(R.id.gamedetails_news_ll_loading);
+ cardView = (CardView) findViewById(R.id.gamedetails_news_cardView);
+ searchNonews = (TextView) findViewById(R.id.search_nonews);
+
+ layoutManager = new MeasureHeightLayoutManager(this);
+
+ mNewsRecyclerView.setLayoutManager(layoutManager);
+ mNewsRecyclerView.setAdapter(searchAdapter);
+ mNewsRecyclerView.addItemDecoration(new VerticalItemDecoration(NewsSearchActivity.this, 1));
+
+ edSearch = (EditText) findViewById(R.id.et_search);
+ tvSearch = (TextView) findViewById(R.id.tv_search);
+ edSearch.setText(searchKey);
+
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ LoadNewsData(page);
+ }
+ }).start();
+
+ tvSearch.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ searchKey = edSearch.getText().toString().trim();
+ if (searchKey.length()>=1){
+ newsEntities.clear();
+ page = 1;
+ LoadNewsData(page);
+ }else {
+ Toast.makeText(getApplicationContext(),"请输入关键字",Toast.LENGTH_SHORT).show();
+ }
+
+ }
+ });
+
+ mNewsRecyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
+ @Override
+ public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
+ super.onScrollStateChanged(recyclerView, newState);
+ if (newState == RecyclerView.SCROLL_STATE_IDLE &&layoutManager.findLastVisibleItemPosition() + 1 == searchAdapter.getItemCount()
+ &&isLoadOver&&!isRemove&& !isNetworkError){
+ isLoadOver = false;
+ page++;
+ LoadNewsData(page);
+ }
+ }
+ });
+
+ noConnection.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ noConnection.setVisibility(View.GONE);
+ llLoading.setVisibility(View.VISIBLE);
+ cardView.setVisibility(View.GONE);
+ handler.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ LoadNewsData(1);
+ }
+ },1000);
+ }
+ });
+
+ }
+
+ private void LoadNewsData(final int page) {
+ String url = Config.HOST+"v1d45/search/news?game_id="+ gameId+ "&keyword="+ Uri.encode(searchKey)+ "&page="+ page+ "&limit=20";
+ final JsonArrayExtendedRequest request = new JsonArrayExtendedRequest(url,
+ new Response.Listener() {
+ @Override
+ public void onResponse(JSONArray response) {
+ Gson gson = new Gson();
+ ArrayList news = gson.fromJson(
+ response.toString(),
+ new TypeToken>() {
+ }.getType());
+ newsEntities.addAll(news);
+ searchAdapter.notifyDataSetChanged();
+ isLoadOver = true;
+ llLoading.setVisibility(View.GONE);
+ cardView.setVisibility(View.VISIBLE);
+ if (newsEntities.size() == 0){
+ cardView.setVisibility(View.GONE);
+ searchNonews.setVisibility(View.VISIBLE);
+ }else {
+ cardView.setVisibility(View.VISIBLE);
+ searchNonews.setVisibility(View.GONE);
+ }
+ if (news.isEmpty() || (news.size() < 20)) {
+ isRemove = true;
+ searchAdapter.notifyItemChanged(searchAdapter.getItemCount() - 1);
+ }
+ }
+ }, new Response.ErrorListener() {
+ @Override
+ public void onErrorResponse(VolleyError error) {
+ if (page ==1){
+ noConnection.setVisibility(View.VISIBLE);
+ llLoading.setVisibility(View.GONE);
+ }
+ isLoadOver = true;
+ Toast.makeText(NewsSearchActivity.this, "网络错误", Toast.LENGTH_SHORT).show();
+ isNetworkError = true;
+ searchAdapter.notifyItemChanged(searchAdapter.getItemCount() - 1);
+ }
+ });
+ AppController.addToRequestQueue(request,GameDeatilsNewsActivity.class);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ gameName = null;
+ searchKey = null;
+ gameId = null;
+ mNewsRecyclerView = null;
+ newsEntities = null;
+ searchAdapter = null;
+ tvSearch = null;
+ searchNonews = null;
+ edSearch = null;
+ llLoading = null;
+ noConnection = null;
+ cardView = null;
+ layoutManager = null;
+ handler = null;
+ }
+
+ public class NewsSearchAdapter extends RecyclerView.Adapter{
+ @Override
+ public int getItemViewType(int position) {
+ if (position == newsEntities.size()) {
+ return 0;
+ }else {
+ return 1;
+ }
+ }
+
+ @Override
+ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ if (viewType == 0){
+ View view = LayoutInflater.from(parent.getContext()).inflate(
+ R.layout.refresh_footerview, parent, false);
+ return new FooterViewHolder(view);
+ }else {
+ TextView textView = new TextView(getApplicationContext());
+ textView.setPadding(DisplayUtils.dip2px(NewsSearchActivity.this,10),DisplayUtils.dip2px(NewsSearchActivity.this,10)
+ ,0,DisplayUtils.dip2px(NewsSearchActivity.this,10));
+ textView.setTextColor(Color.parseColor("#3a3a3a"));
+ textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
+ textView.setBackgroundResource(R.drawable.cardview_item_style);
+ textView.setSingleLine();
+ return new ViewHolder(textView);
+ }
+ }
+
+ @Override
+ public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
+ if (holder instanceof ViewHolder){
+ ((ViewHolder) holder).textView.setText(newsEntities.get(position).getTitle());
+ ((ViewHolder) holder).textView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intent = new Intent(getApplicationContext(),NewsActivity.class);
+ intent.putExtra("newsId",newsEntities.get(position).getId());
+ intent.putExtra("entrance","游戏详情-全部资讯");
+ startActivity(intent);
+ }
+ });
+ }else if (holder instanceof FooterViewHolder){
+ FooterViewHolder viewHolder = (FooterViewHolder) holder;
+ if (isNetworkError) {
+ viewHolder.footerview_progressbar.setVisibility(View.GONE);
+ viewHolder.footerview_tv_loading.setText("加载失败,点击重试");
+ viewHolder.itemView.setClickable(true);
+ viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ isNetworkError = false;
+ notifyItemChanged(getItemCount() - 1);
+ LoadNewsData(page);
+ }
+ });
+ } else if (isRemove) {
+ viewHolder.footerview_progressbar.setVisibility(View.GONE);
+ viewHolder.footerview_tv_loading.setText("加载完毕");
+ viewHolder.itemView.setClickable(false);
+ } else {
+ viewHolder.footerview_progressbar.setVisibility(View.VISIBLE);
+ viewHolder.footerview_tv_loading.setText("加载中...");
+ viewHolder.itemView.setClickable(false);
+ }
+ }
+
+ }
+
+ @Override
+ public int getItemCount() {
+ if (newsEntities.isEmpty()){
+ return 0;
+ }
+ return newsEntities.size()+1;
+ }
+
+ public class ViewHolder extends RecyclerView.ViewHolder{
+ TextView textView;
+ public ViewHolder(View itemView) {
+ super(itemView);
+ textView = (TextView) itemView;
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/gh/gamecenter/adapter/PluginAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/PluginAdapter.java
index 303202c340..6694afc7ae 100644
--- a/app/src/main/java/com/gh/gamecenter/adapter/PluginAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/adapter/PluginAdapter.java
@@ -247,7 +247,7 @@ public class PluginAdapter extends RecyclerView.Adapter
statusMap, platformMap, "游戏-插件",
dismissEntity, "主页:" + entity.getName());
- DownloadItemUtils.updateItem(context, viewHolder.labelList,
+ DownloadItemUtils.updateItem(context, viewHolder.gameDes,
viewHolder.game_progressbar, viewHolder.game_ll_info, viewHolder.download_speed,
viewHolder.download_percentage, viewHolder.downloadBtn, entity, platformMap,
statusMap);
diff --git a/app/src/main/java/com/gh/gamecenter/adapter/SubjectAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/SubjectAdapter.java
index eb89a27ee4..03fc6f37e4 100644
--- a/app/src/main/java/com/gh/gamecenter/adapter/SubjectAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/adapter/SubjectAdapter.java
@@ -221,7 +221,7 @@ public class SubjectAdapter extends RecyclerView.Adapter img;
+ public void setId(String id) {
+ this.id = id;
+ }
+ public String getId() {
+ return id;
+ }
+
+ public void setGameName(String gameName) {
+ this.gameName = gameName;
+ }
+ public String getGameName() {
+ return gameName;
+ }
+
+ public void setGameIcon(String gameIcon) {
+ this.gameIcon = gameIcon;
+ }
+ public String getGameIcon() {
+ return gameIcon;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+ public String getTitle() {
+ return title;
+ }
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+ public String getContent() {
+ return content;
+ }
+
+ public void setTime(int time) {
+ this.time = time;
+ }
+ public int getTime() {
+ return time;
+ }
+
+ public void setImg(List img) {
+ this.img = img;
+ }
+ public List getImg() {
+ return img;
+ }
+}
diff --git a/app/src/main/java/com/gh/gamecenter/entity/GameDetailsEntity.java b/app/src/main/java/com/gh/gamecenter/entity/GameDetailsEntity.java
index 8d5fee9681..6d2865c785 100644
--- a/app/src/main/java/com/gh/gamecenter/entity/GameDetailsEntity.java
+++ b/app/src/main/java/com/gh/gamecenter/entity/GameDetailsEntity.java
@@ -1,5 +1,7 @@
package com.gh.gamecenter.entity;
+import com.google.gson.annotations.SerializedName;
+
import java.util.ArrayList;
public class GameDetailsEntity {
@@ -11,6 +13,16 @@ public class GameDetailsEntity {
private ArrayList gallery;
private String des;
private String downloadAddWord;
+ @SerializedName("article_types")
+ private ArrayList articleTypes;
+
+ public ArrayList getArticleTypes() {
+ return articleTypes;
+ }
+
+ public void setArticleTypes(ArrayList articleTypes) {
+ this.articleTypes = articleTypes;
+ }
public ArrayList getServerInfo() {
return serverInfo;
diff --git a/app/src/main/java/com/gh/gamecenter/game/Game1FragmentAdapter.java b/app/src/main/java/com/gh/gamecenter/game/Game1FragmentAdapter.java
index 96c7ae750a..cd589ace41 100644
--- a/app/src/main/java/com/gh/gamecenter/game/Game1FragmentAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/game/Game1FragmentAdapter.java
@@ -32,9 +32,11 @@ import com.gh.common.util.GameViewUtils;
import com.gh.common.util.ImageUtils;
import com.gh.common.util.PlatformUtils;
import com.gh.common.util.TimestampUtils;
+import com.gh.common.util.Utils;
import com.gh.common.view.AutoScrollViewPager;
import com.gh.download.DownloadEntry;
import com.gh.gamecenter.GameDetailsActivity;
+import com.gh.gamecenter.NewGameDetailsActivity;
import com.gh.gamecenter.NewsActivity;
import com.gh.gamecenter.PluginActivity;
import com.gh.gamecenter.R;
@@ -438,6 +440,7 @@ public class Game1FragmentAdapter extends RecyclerView.Adapter locationMap;
+ private ArrayMap> gameMap;
+ private ArrayMap> platformMap;
+ private ArrayMap nameMap;
+ private ArrayMap pluginNameMap;
+ private ArrayMap statusMap;
+
+
+ private DismissEntity dismissEntity;
+ private boolean isDestroy = false;
+ private int gamePosition = -1;
+
+ private Handler handler = new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+ if (!isDestroy) {
+ if (msg.what == Constants.DOWNLOAD_ROLL) {
+ String name = (String) msg.obj;
+ if (platformMap != null) {
+ LinkedBlockingQueue queue = platformMap.get(name);
+ if (queue.size() > 1) {
+ queue.offer(queue.poll());
+ Message msg2 = Message.obtain();
+ msg2.obj = name;
+ msg2.what = Constants.DOWNLOAD_ROLL;
+ sendMessageDelayed(msg2, 3000);
+ }
+ }
+ }
+ }
+ }
+ };
+ private GameEntity getEntityByLocation(int position) {
+ List list = adapter.getSubjectList();
+ SubjectEntity subjectEntity;
+ GameEntity gameEntity;
+ int offset = 0;
+ for (int i = 0; i < list.size(); i++) {
+ offset++;
+ subjectEntity = list.get(i);
+ for (int i1 = 0; i1 < subjectEntity.getData().size(); i1++) {
+ gameEntity = subjectEntity.getData().get(i1);
+ if (offset == position){
+ gamePosition = i;
+ return gameEntity;
+ }
+ offset++;
+ }
+ }
+ return null;
+ }
+
+
+ private DataWatcher dataWatcher = new DataWatcher() {
+
+ @Override
+ public void onDataChanged(
+ HashMap downloadingEntries) {
+ if (!mSwipeRefresh.isRefreshing()) {
+ for (Map.Entry entry : downloadingEntries.entrySet()) {
+ DownloadEntry downloadEntry = entry.getValue();
+ Integer location = locationMap.get(downloadEntry.getName());
+ if (location != null) {
+ int index = location;
+ GameEntity detailedEntity = getEntityByLocation(index);
+
+ if (detailedEntity != null&&gamePosition != -1) {
+ DownloadItemUtils.processDate(detailedEntity,
+ downloadEntry, platformMap, handler,adapter , gamePosition, statusMap);
+ }
+ }
+ }
+ }
+ }
+ };
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ locationMap = new ArrayMap<>();
+ gameMap = new ArrayMap<>();
+ platformMap = new ArrayMap<>();
+ nameMap = new ArrayMap<>();
+ pluginNameMap = new ArrayMap<>();
+ statusMap = new ArrayMap<>();
+
+ dismissEntity = new DismissEntity(false);
+ DownloadItemUtils.initializeGameMap(getActivity(), gameMap);
+
+ mView = View.inflate(getActivity(), R.layout.plugin1_fragment, null);
+ mGame2Rv = (RecyclerView) mView.findViewById(R.id.game_list);
+ llLoading = (ProgressBarCircularIndeterminate) mView.findViewById(R.id.game_pb_loading);
+ mSwipeRefresh = (SwipeRefreshLayout) mView.findViewById(R.id.game_swipe_refresh);
+ mLayoutManager = new LinearLayoutManager(getActivity());
+ mGame2Rv.setLayoutManager(mLayoutManager);
+ adapter = new NewGame2FragmentAdapter(getActivity(),locationMap,gameMap
+ ,platformMap,nameMap,pluginNameMap,statusMap,dismissEntity,llLoading,mSwipeRefresh);
+ mGame2Rv.setHasFixedSize(true);
+ mGame2Rv.setAdapter(adapter);
+
+ mSwipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
+ @Override
+ public void onRefresh() {
+ handler.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ llLoading.setVisibility(View.VISIBLE);
+ adapter = new NewGame2FragmentAdapter(getActivity(),locationMap,gameMap
+ ,platformMap,nameMap,pluginNameMap,statusMap,dismissEntity,llLoading,mSwipeRefresh);
+ mGame2Rv.setAdapter(adapter);
+ }
+ },1000);
+ }
+ });
+
+ EventBus.getDefault().register(this);
+ }
+
+ @Nullable
+ @Override
+ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ if (container != null){
+ container.removeView(mView);
+ }
+ return mView;
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ DownloadItemUtils.initializeGameMap(getActivity(), gameMap);
+ for (SubjectEntity subjectEntity : adapter.getSubjectList()) {
+ for (GameEntity entity :subjectEntity.getData()) {
+ entity.setEntryMap(gameMap.get(entity.getName()));
+ }
+ }
+ adapter.notifyDataSetChanged();
+ DownloadManager.getInstance(getActivity()).addObserver(dataWatcher);
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ DownloadManager.getInstance(getActivity()).removeObserver(dataWatcher);
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ EventBus.getDefault().unregister(this);
+ }
+
+ //版本选择框消失事件
+ public void onEventMainThread(EBPWDismiss dismiss) {
+ if (dismissEntity != null) {
+ dismissEntity.setShow(false);
+ }
+ }
+
+ //下载被删除事件
+ public void onEventMainThread(EBDownloadDelete busThree) {
+ LinkedBlockingQueue queue = platformMap.get(busThree.getName());
+ if (queue != null) {
+ queue.remove(busThree.getPlatform());
+ platformMap.put(busThree.getName(), queue);
+ }
+ Integer location = locationMap.get(busThree.getName());
+ if (location != null) {
+ int index = location;
+ GameEntity detailedEntity = getEntityByLocation(index);
+ if (detailedEntity != null) {
+ if (TextUtils.isEmpty(busThree.getPlatform())) {
+ detailedEntity.getEntryMap().remove("官方版");
+ } else {
+ detailedEntity.getEntryMap().remove(busThree.getPlatform());
+ }
+ }
+ if (gamePosition != -1){
+ adapter.notifyItemChanged(gamePosition);
+ }else {
+ adapter.notifyDataSetChanged();
+ }
+
+ }
+ }
+ //安装、卸载事件
+ public void onEventMainThread(EBPackage busFour) {
+ String name = nameMap.get(busFour.getPackageName());
+ if (name != null) {
+ Integer location = locationMap.get(name);
+ if (location != null) {
+ if ("安装".equals(busFour.getType())) {
+ GameEntity detailedEntity = getEntityByLocation(location);
+ for (ApkEntity apkEntity : detailedEntity.getApk()) {
+ if (apkEntity.getPackageName().equals(
+ busFour.getPackageName())) {
+ detailedEntity.getEntryMap().remove(
+ apkEntity.getPlatform());
+ if (gamePosition != -1){
+ adapter.notifyItemChanged(gamePosition);
+ }else {
+ adapter.notifyDataSetChanged();
+ }
+ break;
+ }
+ }
+ } else if ("卸载".equals(busFour.getType())) {
+ if (gamePosition != -1){
+ adapter.notifyItemChanged(gamePosition);
+ }else {
+ adapter.notifyDataSetChanged();
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/gh/gamecenter/game/NewGame2FragmentAdapter.java b/app/src/main/java/com/gh/gamecenter/game/NewGame2FragmentAdapter.java
new file mode 100644
index 0000000000..a84d6a7282
--- /dev/null
+++ b/app/src/main/java/com/gh/gamecenter/game/NewGame2FragmentAdapter.java
@@ -0,0 +1,346 @@
+package com.gh.gamecenter.game;
+
+import android.content.Context;
+import android.content.Intent;
+import android.support.v4.util.ArrayMap;
+import android.support.v4.widget.SwipeRefreshLayout;
+import android.support.v7.widget.RecyclerView;
+import android.text.TextUtils;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.ProgressBar;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.android.volley.Response;
+import com.android.volley.VolleyError;
+import com.gc.materialdesign.views.ProgressBarCircularIndeterminate;
+import com.gh.base.AppController;
+import com.gh.common.constant.Config;
+import com.gh.common.constant.Constants;
+import com.gh.common.util.DataUtils;
+import com.gh.common.util.DisplayUtils;
+import com.gh.common.util.DownloadItemUtils;
+import com.gh.common.util.GameViewUtils;
+import com.gh.common.util.ImageUtils;
+import com.gh.common.util.TimestampUtils;
+import com.gh.common.util.Utils;
+import com.gh.download.DownloadEntry;
+import com.gh.gamecenter.GameDetailsActivity;
+import com.gh.gamecenter.NewGameDetailsActivity;
+import com.gh.gamecenter.NewsActivity;
+import com.gh.gamecenter.R;
+import com.gh.gamecenter.SubjectActivity;
+import com.gh.gamecenter.entity.ApkEntity;
+import com.gh.gamecenter.entity.DismissEntity;
+import com.gh.gamecenter.entity.GameEntity;
+import com.gh.gamecenter.entity.SubjectEntity;
+import com.gh.gamecenter.volley.extended.JsonArrayExtendedRequest;
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+
+import org.json.JSONArray;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.LinkedBlockingQueue;
+
+/**
+ * Created by khy on 2016/8/18.
+ */
+public class NewGame2FragmentAdapter extends RecyclerView.Adapter {
+ private Context mContext;
+ private List subjectList;
+
+ private ArrayMap locationMap;
+ private ArrayMap> gameMap;
+ private ArrayMap> platformMap;
+ private ArrayMap nameMap;
+ private ArrayMap statusMap;
+
+ private ProgressBarCircularIndeterminate llLoading;
+ private SwipeRefreshLayout mSwipeRefresh;
+
+ private DismissEntity dismissEntity;
+
+ public NewGame2FragmentAdapter(Context mContext, ArrayMap locationMap
+ , ArrayMap> gameMap, ArrayMap> platformMap
+ , ArrayMap nameMap, ArrayMap pluginNameMap, ArrayMap statusMap
+ , DismissEntity dismissEntity, ProgressBarCircularIndeterminate llLoading, SwipeRefreshLayout mSwipeRefresh) {
+ this.mContext = mContext;
+ this.locationMap = locationMap;
+ this.gameMap = gameMap;
+ this.platformMap = platformMap;
+ this.nameMap = nameMap;
+ this.statusMap = statusMap;
+ this.dismissEntity = dismissEntity;
+ this.mSwipeRefresh = mSwipeRefresh;
+ this.llLoading = llLoading;
+ subjectList = new ArrayList<>();
+ initSubjectList();
+
+ }
+ public void initSubjectList() {
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ JsonArrayExtendedRequest request = new JsonArrayExtendedRequest(
+ TimestampUtils.addTimestamp(Config.HOST + "v1d50/game/tuijian",
+ Constants.GAME_CD),
+ new Response.Listener() {
+ @Override
+ public void onResponse(JSONArray response) {
+
+ Type listType = new TypeToken>() {}.getType();
+ Gson gson = new Gson();
+ List list = gson.fromJson(response.toString(), listType);
+ subjectList.addAll(list);
+ llLoading.setVisibility(View.GONE);
+ notifyDataSetChanged();
+ initLocationMap();
+ if (mSwipeRefresh.isRefreshing()){
+ mSwipeRefresh.setRefreshing(false);
+ }
+
+ }
+ },
+ new Response.ErrorListener() {
+ @Override
+ public void onErrorResponse(VolleyError error) {
+ if (mSwipeRefresh.isRefreshing()){
+ mSwipeRefresh.setRefreshing(false);
+ }
+ llLoading.setVisibility(View.GONE);
+ // 无网络连接和访问超时
+ }
+ });
+ AppController.addToRequestQueue(request, Game1Fragment.class);
+ }
+ }).start();
+
+ }
+
+ private void initLocationMap() {
+ locationMap.clear();
+
+ if (!subjectList.isEmpty()) {
+ int count = getItemCount();
+ int offset = 0;
+ SubjectEntity subjectEntity;
+ GameEntity gameEntity;
+ for (int position = 0; position < count; position++) {
+ offset++;
+ subjectEntity = subjectList.get(position);
+ for (int i = 0; i < subjectEntity.getData().size(); i++) {
+ gameEntity = subjectEntity.getData().get(i);
+ if (gameEntity.getApk() != null && !gameEntity.getApk().isEmpty()){
+ locationMap.put(gameEntity.getName(), offset);
+ for (ApkEntity apkEntity : gameEntity.getApk()) {
+ nameMap.put(apkEntity.getPackageName(), gameEntity.getName());
+ }
+ }
+ offset++;
+ }
+
+ }
+ }
+ Utils.log(locationMap.toString());
+ }
+
+
+ @Override
+ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ return new ViewHolder(LayoutInflater.from(mContext).inflate(R.layout.game_item_rv,parent,false));
+ }
+
+ @Override
+ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
+ initItem(subjectList.get(position), ((ViewHolder) holder).item_ll,position);
+ }
+
+ private void initItem(final SubjectEntity subjectEntity, LinearLayout item_ll, final int position) {
+ item_ll.removeAllViews();
+ GameEntity entity = null;
+ List data = subjectEntity.getData();
+ int index = 0;
+ for (int i = 0; i < subjectEntity.getData().size()+1; i++) {
+ index = i-1;
+ if (index<0){
+ index = 0;
+ }
+ entity = data.get(index);
+ if (i == 0 && entity.getImage() != null){
+ ImageView imageView = new ImageView(mContext);
+ ImageUtils.getInstance(mContext).display(data.get(index).getImage(),imageView,-1,mContext);
+ item_ll.addView(imageView);
+ final GameEntity finalEntity1 = entity;
+ item_ll.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+
+ Map kv = new HashMap();
+ kv.put("名字", finalEntity1.getName());
+ kv.put("位置", position + 1);
+ DataUtils.onEvent(mContext, "点击", "游戏-推荐-" + subjectEntity.getName(), kv);
+
+ if (TextUtils.isEmpty(finalEntity1.getLink())){
+ Toast.makeText(mContext, "数据缺失", Toast.LENGTH_SHORT).show();
+ return;
+ }
+ if ("game".equals(finalEntity1.getType())) {
+ Intent intent = new Intent(mContext, GameDetailsActivity.class);
+ intent.putExtra("gameId", finalEntity1.getLink());
+ intent.putExtra("entrance", "游戏-推荐-" + subjectEntity.getName());
+ mContext.startActivity(intent);
+ } else if ("news".equals(finalEntity1.getType())) {
+ Intent intent = new Intent(mContext, NewsActivity.class);
+ intent.putExtra("newsId", finalEntity1.getLink());
+ intent.putExtra("entrance", "游戏-推荐-" + subjectEntity.getName());
+ mContext.startActivity(intent);
+ } else if ("column".equals(finalEntity1.getType())) {
+ Intent intent = new Intent(mContext, SubjectActivity.class);
+ intent.putExtra("id", finalEntity1.getLink());
+ intent.putExtra("name", finalEntity1.getName());
+ mContext.startActivity(intent);
+ }
+
+ }
+ });
+ } else if (i == 1 &&entity.getImage()!=null || i == 0 && entity.getImage() == null){
+ View view = View.inflate(mContext,R.layout.home_game_head_item, null);
+ TextView tvTitle = (TextView) view.findViewById(R.id.head_title);
+ LinearLayout llLink = (LinearLayout) view.findViewById(R.id.head_link);
+ if (subjectEntity.getData().size()>=Integer.parseInt(subjectList.get(i).getMore())){
+ llLink.setVisibility(View.GONE);
+ }else {
+ llLink.setVisibility(View.VISIBLE);
+ }
+ tvTitle.setText(subjectEntity.getName());
+ item_ll.addView(view);
+ llLink.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intent = new Intent(mContext, SubjectActivity.class);
+ intent.putExtra("id", subjectEntity.getId());
+ intent.putExtra("name", subjectEntity.getName());
+ intent.putExtra("order",subjectEntity.getOrder());
+ mContext.startActivity(intent);
+ }
+ });
+ } else {
+ View view = View.inflate(mContext,R.layout.home_game_normal_item, null);
+ LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT);
+ params.setMargins(DisplayUtils.dip2px(mContext,10),DisplayUtils.dip2px(mContext,10),DisplayUtils.dip2px(mContext,12),DisplayUtils.dip2px(mContext,10));
+ view.setLayoutParams(params);
+ ImageView gameIcon = (ImageView) view.findViewById(R.id.home1_game_thumb);
+ TextView gameName = (TextView) view.findViewById(R.id.home1_game_nameAndsize);
+ TextView gameDes = (TextView) view.findViewById(R.id.home1_game_des);
+
+ TextView home1_game_order = (TextView) view.findViewById(R.id.home1_game_order);
+ TextView downloadBtn = (TextView) view.findViewById(R.id.home1_download_btn);
+ LinearLayout game_ll_info = (LinearLayout) view.findViewById(R.id.home1_game_ll_info);
+ ProgressBar game_progressbar = (ProgressBar) view.findViewById(R.id.home1_game_progressbar);
+ TextView download_speed = (TextView) view.findViewById(R.id.home1_download_speed);
+ TextView download_percentage = (TextView) view.findViewById(R.id.home1_download_percentage);
+
+ ImageUtils.getInstance(mContext).display(data.get(index).getIcon(),gameIcon);
+
+ item_ll.addView(view);
+ gameDes.setText(entity.getApk().get(0).getSize() +" "+data.get(index).getBrief());
+ gameName.setText(data.get(index).getName());
+ LinearLayout labelListTest = (LinearLayout) view.findViewById(R.id.home2_label_list);
+ LinearLayout labelList = (LinearLayout) view.findViewById(R.id.home1_label_list);
+ if (entity.getTest() != null) {
+ labelListTest.setVisibility(View.VISIBLE);
+ labelList.setVisibility(View.GONE);
+ TextView tvTestType = (TextView) view.findViewById(R.id.home2_test_type);
+ TextView tvTestTime = (TextView) view.findViewById(R.id.home2_test_time);
+ tvTestType.setText(entity.getTest().getType());
+ if (entity.getTest().getStart() == 0) {
+ tvTestTime.setVisibility(View.GONE);
+ } else {
+ tvTestTime.setText(GameViewUtils.getGameTestDate(entity.getTest().getStart()));
+ }
+ }else {
+ labelList.setVisibility(View.VISIBLE);
+ labelListTest.setVisibility(View.GONE);
+ GameViewUtils.setLabelList(mContext, labelList, entity.getTag());
+ }
+
+
+ if (subjectEntity.getOrder()) {
+ home1_game_order.setVisibility(View.VISIBLE);
+ if (data.get(0).getImage() != null){
+ home1_game_order.setText((i-1) + "");
+ }else {
+ home1_game_order.setText((i) + "");
+ }
+ } else {
+ home1_game_order.setVisibility(View.GONE);
+ }
+
+ final GameEntity finalEntity = entity;
+ view.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Map kv = new HashMap();
+ kv.put("名字", finalEntity.getName());
+ kv.put("位置", position);
+ DataUtils.onEvent(mContext, "点击", "游戏-插件-" + subjectEntity.getName(), kv);
+
+ if (finalEntity.getPluginPlatform() != null) {
+ Intent intent = new Intent(mContext, NewGameDetailsActivity.class);
+ intent.putExtra("gameId", finalEntity.getId());
+ intent.putExtra("entrance", "游戏-插件-" + subjectEntity.getName());
+ mContext.startActivity(intent);
+ } else {
+ AppController.put("GameEntity", finalEntity);
+ Intent intent = new Intent(mContext, NewGameDetailsActivity.class);
+ intent.putExtra("entrance", "游戏-插件-" + subjectEntity.getName());
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ mContext.startActivity(intent);
+ }
+ }
+ });
+
+ DownloadItemUtils.setOnClickListener(mContext, downloadBtn,
+ download_speed, download_percentage, entity, position,
+ NewGame2FragmentAdapter.this,
+ statusMap, platformMap, "游戏-推荐-" + subjectEntity.getName(),
+ dismissEntity, "游戏-推荐-" + subjectEntity.getName() + ":" + entity.getName());
+
+ DownloadItemUtils.updateItem(mContext, gameDes,
+ game_progressbar, game_ll_info, download_speed,
+ download_percentage, downloadBtn, entity, platformMap,
+ statusMap);
+ }
+ }
+ }
+
+ @Override
+ public int getItemCount() {
+ return subjectList.size();
+ }
+
+ public class ViewHolder extends RecyclerView.ViewHolder{
+ View view;
+ LinearLayout item_ll;
+ public ViewHolder(View itemView) {
+ super(itemView);
+ view = itemView;
+ item_ll = (LinearLayout) view.findViewById(R.id.game_item_ll);
+
+ }
+ }
+ public List getSubjectList() {
+ return subjectList;
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/gh/gamecenter/news/NewNews4Fragment.java b/app/src/main/java/com/gh/gamecenter/news/NewNews4Fragment.java
new file mode 100644
index 0000000000..8dccc8837e
--- /dev/null
+++ b/app/src/main/java/com/gh/gamecenter/news/NewNews4Fragment.java
@@ -0,0 +1,233 @@
+package com.gh.gamecenter.news;
+
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.support.annotation.Nullable;
+import android.support.v4.app.Fragment;
+import android.support.v4.widget.SwipeRefreshLayout;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.gc.materialdesign.views.ProgressBarCircularIndeterminate;
+import com.gh.common.constant.Config;
+import com.gh.common.util.ConcernUtils;
+import com.gh.common.util.MD5Utils;
+import com.gh.common.util.Utils;
+import com.gh.gamecenter.R;
+import com.gh.gamecenter.db.info.ConcernInfo;
+import com.gh.gamecenter.manager.ConcernManager;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * Created by khy on 2016/8/15.
+ */
+public class NewNews4Fragment extends Fragment implements NewNews4FragmentAdapter.OnCallBackListener{
+
+ private View mView;
+ private RecyclerView mRecyclerView;
+ private NewNews4FragmentAdapter mNews4FragmentAdapter;
+ private LinearLayoutManager mLayoutManager;
+ private LinearLayout noConnection;
+ private TextView noConcern;
+ private SwipeRefreshLayout mSwipeRefreshLayout;
+ private ProgressBarCircularIndeterminate mProgressBar;
+
+ private boolean isLoadOver = true;
+ private boolean isRemove = false;
+ private boolean isNetworkError = false;
+
+ private NewNews4Fragment news4Fragment = this;
+
+ private int page = 1;
+
+ private String updateGameId;
+
+ private List listGameId;
+
+ private ConcernManager manager;
+
+ private Handler handler = new Handler(){
+ @Override
+ public void handleMessage(Message msg) {
+ super.handleMessage(msg);
+ if (msg.what == 0){
+ String concernID = (String) msg.obj;
+ StringBuffer concernKey = new StringBuffer();
+ concernKey.setLength(0);
+ StringBuffer gameIdPostData = new StringBuffer();
+ listGameId.clear();
+ try {
+ JSONArray jsonArray = new JSONArray(concernID);
+ for (int i= 0; i< jsonArray.length(); i++){
+ String gameId = (String) jsonArray.get(i);
+ listGameId.add(gameId);
+ if (i< 5){
+ gameIdPostData.append(gameId + "-");
+ }
+ }
+ //数据进行排序后进行MD5操作
+ Collections.sort(listGameId, new Comparator() {
+ @Override
+ public int compare(String lhs, String rhs) {
+ return lhs.compareTo(rhs);
+ }
+ });
+ for (int i= 0; i< listGameId.size(); i++) {
+ concernKey.append(listGameId.get(i));
+ }
+ String contentMD5 = MD5Utils.getContentMD5(concernKey.toString());
+
+ if (gameIdPostData.length()>0){
+ gameIdPostData.deleteCharAt(gameIdPostData.length()-1);
+ }
+ mNews4FragmentAdapter = new NewNews4FragmentAdapter(getActivity(), news4Fragment, contentMD5,gameIdPostData.toString(),page);
+ mRecyclerView.setAdapter(mNews4FragmentAdapter);
+
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+
+ }
+ }
+ };
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ mView = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_news4,null);
+ mRecyclerView = (RecyclerView) mView.findViewById(R.id.news4_rv);
+ mSwipeRefreshLayout = (SwipeRefreshLayout) mView.findViewById(R.id.news4_swipe_refresh);
+ mProgressBar = (ProgressBarCircularIndeterminate) mView.findViewById(R.id.news4_pb_loading);
+ noConnection = (LinearLayout) mView.findViewById(R.id.reuse_no_connection);
+ noConcern = (TextView) mView.findViewById(R.id.concern_tv_none);
+ mLayoutManager = new LinearLayoutManager(getActivity());
+ mRecyclerView.setLayoutManager(mLayoutManager);
+
+ manager = new ConcernManager(getActivity());
+
+ listGameId = new ArrayList<>();
+
+ LoadConcernGameId();
+
+ mRecyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
+ @Override
+ public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
+ super.onScrollStateChanged(recyclerView, newState);
+ if (mNews4FragmentAdapter != null &&newState == RecyclerView.SCROLL_STATE_IDLE
+ &&mLayoutManager.findLastVisibleItemPosition() + 1 == mNews4FragmentAdapter.getItemCount()
+ &&isLoadOver &&!isRemove &&!isNetworkError){
+ isLoadOver = false;
+ page++;
+ mNews4FragmentAdapter.LoadJosnData(page);
+ }
+ }
+ });
+
+ mSwipeRefreshLayout.setColorSchemeResources(R.color.theme_colors);
+ mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
+ @Override
+ public void onRefresh() {
+ LoadConcernGameId();
+ }
+ });
+ noConnection.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ noConnection.setVisibility(View.GONE);
+ mProgressBar.setVisibility(View.VISIBLE);
+ LoadConcernGameId();
+ }
+ });
+ }
+
+ private void LoadConcernGameId() {
+ JSONArray jsonArray = new JSONArray();
+ List concernGame = manager.getConcernGame();
+
+ for (ConcernInfo concernInfo : concernGame) {
+ jsonArray.put(concernInfo.getId());
+ }
+
+ updateGameId = jsonArray.toString();
+ if (jsonArray.toString().length()> 3){
+ Message message = new Message();
+ message.obj = jsonArray.toString();
+ message.what = 0;
+ handler.sendMessage(message);
+ noConcern.setVisibility(View.GONE);
+ }else {
+ mNews4FragmentAdapter.LoadJosnData(999);
+ if (mSwipeRefreshLayout.isRefreshing()){
+ mSwipeRefreshLayout.setRefreshing(false);
+ }
+ noConcern.setVisibility(View.VISIBLE);
+ }
+ }
+
+ @Nullable
+ @Override
+ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ if (container != null) {
+ container.removeView(mView);
+ }
+ return mView;
+ }
+
+ @Override
+ public void isLoadOver(boolean loadOver) {
+ isLoadOver = loadOver;
+
+ if (mSwipeRefreshLayout != null && mSwipeRefreshLayout.isRefreshing()){
+ mSwipeRefreshLayout.setRefreshing(false);
+ }
+ if (mProgressBar != null && mProgressBar.getVisibility() == View.VISIBLE){
+ mProgressBar.setVisibility(View.GONE);
+ }
+ }
+
+ @Override
+ public void isRemove(boolean remove) {
+ isRemove = remove;
+ }
+
+ @Override
+ public void isNetworkError(boolean netWorkError) {
+ isNetworkError = netWorkError;
+ if (isNetworkError == true){
+ noConnection.setVisibility(View.VISIBLE);
+ }else {
+ noConnection.setVisibility(View.GONE);
+ }
+ }
+
+ @Override
+ public void updateconcern() {
+ String uuid = ConcernUtils.UUID(getActivity());
+
+ ConcernUtils.UpdateConcernData(Config.HOST + "v2d0/device/" + uuid + "/concern", updateGameId, new ConcernUtils.DownJsonListener() {
+ @Override
+ public void downSucced(String str) {
+ Utils.log("更新设备游戏成功");
+ }
+
+ @Override
+ public void downFailed() {
+ Utils.log("更新设备游戏失败");
+ }
+ });
+ }
+
+}
diff --git a/app/src/main/java/com/gh/gamecenter/news/NewNews4FragmentAdapter.java b/app/src/main/java/com/gh/gamecenter/news/NewNews4FragmentAdapter.java
new file mode 100644
index 0000000000..4d8622dce7
--- /dev/null
+++ b/app/src/main/java/com/gh/gamecenter/news/NewNews4FragmentAdapter.java
@@ -0,0 +1,322 @@
+package com.gh.gamecenter.news;
+
+import android.content.Context;
+import android.content.Intent;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.android.volley.Response;
+import com.android.volley.VolleyError;
+import com.gh.base.AppController;
+import com.gh.common.constant.Config;
+import com.gh.common.util.ImageUtils;
+import com.gh.common.util.Utils;
+import com.gh.gamecenter.NewsActivity;
+import com.gh.gamecenter.R;
+import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
+import com.gh.gamecenter.entity.ConcernEntity;
+import com.gh.gamecenter.volley.extended.JsonArrayExtendedRequest;
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+
+import org.json.JSONArray;
+
+import java.lang.reflect.Type;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * Created by khy on 2016/8/15.
+ */
+public class NewNews4FragmentAdapter extends RecyclerView.Adapter {
+
+ private Context mContext;
+ private List concernList;
+ public OnCallBackListener callBackListener;
+
+ private String concernKey ;
+ private String gameIdPostData;
+
+ private boolean keyRequestError = false;
+ private boolean isKeyGetData = false;
+ private boolean isNetworkError = false;
+ private boolean isRemove = false;
+
+ private int page ;
+
+ public NewNews4FragmentAdapter(Context context, NewNews4Fragment newNews4Fragment, String concernKey, String gameIdPostData, int page) {
+ this.mContext = context;
+ this.concernKey = concernKey;
+ this.gameIdPostData = gameIdPostData;
+ this.page = page;
+ concernList = new ArrayList<>();
+ callBackListener = (OnCallBackListener) newNews4Fragment;
+ LoadJosnData(page);
+ }
+
+ public void LoadJosnData(final int p) {
+ page = p;
+ String url;
+
+ if (keyRequestError){
+ url= Config.HOST+ "v2d0/zixun/guanzhu?"+ "game_id="+ gameIdPostData+ "&limit=10&page="+ page+ "×tamp="+ System.currentTimeMillis();
+ isKeyGetData = false;
+ }else {
+ url= Config.HOST+ "v2d0/zixun/guanzhu?"+ "key="+ concernKey+ "&limit=10&page="+ page+ "×tamp="+ System.currentTimeMillis();
+ isKeyGetData= true;
+ }
+ if (page == 1){
+ concernList.clear();
+ notifyDataSetChanged();
+ }
+ if (page == 999){
+ concernList.clear();
+ notifyDataSetChanged();
+ }
+ final JsonArrayExtendedRequest request= new JsonArrayExtendedRequest(url
+ , new Response.Listener() {
+ @Override
+ public void onResponse(JSONArray response) {
+
+ Type listType = new TypeToken>() {
+ }.getType();
+ Gson gson = new Gson();
+ List list = gson.fromJson(response.toString(), listType);
+
+ concernList.addAll(list);
+ notifyDataSetChanged();
+ callBackListener.isLoadOver(true);
+
+ if (list.isEmpty() || (list.size() < 10)) {
+ notifyItemChanged(getItemCount() - 1);
+ callBackListener.isRemove(true);
+ isRemove = true;
+ }
+ }
+ }, new Response.ErrorListener() {
+ @Override
+ public void onErrorResponse(VolleyError error) {
+ int statusCode = 0;
+ try {
+ statusCode = error.networkResponse.statusCode;
+ } catch (NullPointerException e) {
+ e.printStackTrace();
+ Utils.log("资讯-关注页面出现异常"+e.toString());
+ }
+
+ if (statusCode == 409 && isKeyGetData){
+ keyRequestError = true;
+ LoadJosnData(page);
+ callBackListener.updateconcern();
+ }else {
+ callBackListener.isLoadOver(true);
+ callBackListener.isNetworkError(true);
+ isNetworkError = true;
+ }
+ }
+ });
+ AppController.addToRequestQueue(request, NewsFragment.class);
+ }
+
+ @Override
+ public int getItemViewType(int position) {
+ if (position == concernList.size()) {
+ return 0;
+ }else {
+ return 1;
+ }
+ }
+
+ @Override
+ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ if (viewType == 0){
+ View view = LayoutInflater.from(parent.getContext()).inflate(
+ R.layout.refresh_footerview, parent, false);
+ return new FooterViewHolder(view);
+ }
+ return new ViewHolder(LayoutInflater.from(mContext).inflate(R.layout.concern_rv_item, parent, false));
+ }
+
+ @Override
+ public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {
+
+ if (holder instanceof ViewHolder){
+
+ ViewHolder viewHolder = ((ViewHolder) holder);
+ ConcernEntity concernEntity = concernList.get(position);
+
+ if (concernEntity.getImg().size() == 0) {
+ viewHolder.contentPicLl.setVisibility(View.GONE);
+ } else {
+ viewHolder.contentPicLl.setVisibility(View.VISIBLE);
+ addContentPic(mContext.getResources().getDisplayMetrics().widthPixels
+ - (int) (mContext.getResources().getDisplayMetrics().density * 34), viewHolder.contentPicLl, concernEntity.getImg());
+ }
+
+ ImageUtils.getInstance(mContext).display(concernEntity.getGameIcon(), viewHolder.concernThumb);
+ viewHolder.concernContent.setText(concernEntity.getContent());
+ viewHolder.concernTitle.setText(concernEntity.getGameName());
+ SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd", Locale.getDefault());
+
+ try {
+ long today = format.parse(format.format(new Date())).getTime();
+ long day = Long.valueOf(concernEntity.getTime() + "000");
+ if (day >= today && day < today + 86400 * 1000) {
+ format.applyPattern("HH:mm");
+ viewHolder.concerntTime.setText("今天 " + format.format(day));
+ } else if (day >= today - 86400 * 1000 && day < today) {
+ format.applyPattern("HH:mm");
+ viewHolder.concerntTime.setText("昨天 " + format.format(day));
+ } else {
+ format.applyPattern("yyyy年MM月dd日 HH:mm");
+ viewHolder.concerntTime.setText(format.format(day));
+ }
+ } catch (ParseException e) {
+ e.printStackTrace();
+ format.applyPattern("yyyy年MM月dd日 HH:mm");
+ viewHolder.concerntTime.setText(format.format(Long.valueOf(concernEntity.getTime() + "000")));
+ }
+
+ viewHolder.view.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Intent intent = new Intent(mContext, NewsActivity.class);
+ intent.putExtra("newsId", concernList.get(position).getId());
+ intent.putExtra("entrance", "资讯-关注");
+ mContext.startActivity(intent);
+ }
+ });
+
+ }else if (holder instanceof FooterViewHolder){
+
+ FooterViewHolder viewHolder = ((FooterViewHolder) holder);
+ if (isNetworkError) {
+ viewHolder.footerview_progressbar.setVisibility(View.GONE);
+ viewHolder.footerview_tv_loading.setText("加载失败,点击重试");
+ viewHolder.itemView.setClickable(true);
+ viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ isNetworkError = false;
+ notifyItemChanged(getItemCount() - 1);
+ LoadJosnData(page);
+ }
+ });
+
+ } else if (isRemove) {
+ viewHolder.footerview_progressbar.setVisibility(View.GONE);
+ viewHolder.footerview_tv_loading.setText("加载完毕");
+ viewHolder.itemView.setClickable(false);
+ } else {
+ viewHolder.footerview_progressbar.setVisibility(View.VISIBLE);
+ viewHolder.footerview_tv_loading.setText("加载中...");
+ viewHolder.itemView.setClickable(false);
+ }
+ }
+
+ }
+
+ @Override
+ public int getItemCount() {
+ if (concernList.isEmpty()){
+ return 0;
+ }
+ return concernList.size()+ 1;
+ }
+
+ public class ViewHolder extends RecyclerView.ViewHolder {
+ View view;
+ ImageView concernThumb;
+ LinearLayout contentPicLl;
+ TextView concernTitle, concerntTime, concernContent, concernRead;
+
+ public ViewHolder(View itemView) {
+ super(itemView);
+ view = itemView;
+ concernContent = (TextView) view.findViewById(R.id.concern_rv_item_content);
+ concernRead = (TextView) view.findViewById(R.id.concern_rv_item_read);
+ concernThumb = (ImageView) view.findViewById(R.id.concern_rv_item_thumb);
+ concerntTime = (TextView) view.findViewById(R.id.concern_rv_item_time);
+ concernTitle = (TextView) view.findViewById(R.id.concern_rv_item_title);
+ contentPicLl = (LinearLayout) view.findViewById(R.id.concern_rv_item_iv_ll);
+ }
+ }
+
+ private void addContentPic(int width, LinearLayout linearLayout, List list) {
+ float dp = mContext.getResources().getDisplayMetrics().density;
+ int allSize = list.size();
+ LinearLayout ll;
+ ImageView imageView;
+ int index = 0;
+ linearLayout.removeAllViews();
+ for (int i = 0; i < Math.ceil(list.size()/ 3.0); i++) {
+ switch (allSize% 3) {
+ case 1:
+ ll = new LinearLayout(mContext);
+ ll.setOrientation(LinearLayout.HORIZONTAL);
+ ll.removeAllViews();
+ imageView = new ImageView(mContext);
+ imageView.setLayoutParams(new ViewGroup.LayoutParams(width, width / 2));
+ ImageUtils.getInstance(mContext).display(list.get(index), imageView, ImageView.ScaleType.CENTER_CROP);
+ ll.addView(imageView);
+ ll.setPadding((int)dp * 2, 0, (int)dp * 2, (int)dp * 4);
+ linearLayout.addView(ll);
+ allSize = allSize - 1;
+ index = index + 1;
+ break;
+ case 2:
+ ll = new LinearLayout(mContext);
+ ll.setOrientation(LinearLayout.HORIZONTAL);
+ ll.removeAllViews();
+ for (int j = 0; j < list.size() % 3; j++) {
+ imageView = new ImageView(mContext);
+ LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(0, width / 2 - (int) dp * 4);
+ layoutParams.setMargins((int) dp * 2, 0, (int) dp * 2, (int) dp * 4);
+ layoutParams.weight = 1;
+ imageView.setLayoutParams(layoutParams);
+ ImageUtils.getInstance(mContext).display(list.get(index), imageView, ImageView.ScaleType.CENTER_CROP);
+ ll.addView(imageView);
+ index = index + 1;
+ }
+ linearLayout.addView(ll);
+ allSize = allSize - 2;
+
+ break;
+ case 0:
+ ll = new LinearLayout(mContext);
+ ll.setOrientation(LinearLayout.HORIZONTAL);
+ ll.removeAllViews();
+ for (int j = 0; j < 3; j++) {
+ imageView = new ImageView(mContext);
+ LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(0, width / 3 - (int) dp * 4);
+ layoutParams.setMargins((int) dp * 2, 0, (int) dp * 2, (int) dp * 4);
+ layoutParams.weight = 1;
+ imageView.setLayoutParams(layoutParams);
+ ImageUtils.getInstance(mContext).display(list.get(index), imageView, ImageView.ScaleType.CENTER_CROP);
+ ll.addView(imageView);
+ index = index + 1;
+ }
+ linearLayout.addView(ll);
+ allSize = allSize - 3;
+ break;
+ }
+ }
+
+ }
+ public interface OnCallBackListener{
+ void isLoadOver(boolean loadOver);
+ void isRemove(boolean remove);
+ void isNetworkError(boolean netWorkError);
+ void updateconcern();
+ }
+
+}
diff --git a/app/src/main/java/com/gh/gamecenter/news/News4FragmentAdapter.java b/app/src/main/java/com/gh/gamecenter/news/News4FragmentAdapter.java
index 6a101beff1..511c6c11bc 100644
--- a/app/src/main/java/com/gh/gamecenter/news/News4FragmentAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/news/News4FragmentAdapter.java
@@ -118,7 +118,7 @@ public class News4FragmentAdapter extends
} else {
news_list.setVisibility(View.GONE);
news_pb_loading.setVisibility(View.GONE);
- news_tv_none.setVisibility(View.VISIBLE);
+ news_tv_none.setVisibility(View.VISIBLE);//空指针
}
}
diff --git a/app/src/main/java/com/gh/gamecenter/news/NewsFragment.java b/app/src/main/java/com/gh/gamecenter/news/NewsFragment.java
index c003d275e3..f72fbcd315 100644
--- a/app/src/main/java/com/gh/gamecenter/news/NewsFragment.java
+++ b/app/src/main/java/com/gh/gamecenter/news/NewsFragment.java
@@ -244,7 +244,8 @@ public class NewsFragment extends Fragment implements View.OnClickListener, View
} else if (i == 2) {
return new News3Fragment();
} else {
- return new News4Fragment();
+// return new News4Fragment();
+ return new NewNews4Fragment();
}
}
diff --git a/app/src/main/java/com/gh/gamecenter/search/Search3HistoryFragmentAdapter.java b/app/src/main/java/com/gh/gamecenter/search/Search3HistoryFragmentAdapter.java
index b1c6cf694f..ca8e1e2c4e 100644
--- a/app/src/main/java/com/gh/gamecenter/search/Search3HistoryFragmentAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/search/Search3HistoryFragmentAdapter.java
@@ -88,9 +88,12 @@ public class Search3HistoryFragmentAdapter extends RecyclerView.Adapter
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/news_search_bg.xml b/app/src/main/res/drawable/news_search_bg.xml
new file mode 100644
index 0000000000..e833c4e722
--- /dev/null
+++ b/app/src/main/res/drawable/news_search_bg.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/news_search_btn.xml b/app/src/main/res/drawable/news_search_btn.xml
new file mode 100644
index 0000000000..4733e6b7b5
--- /dev/null
+++ b/app/src/main/res/drawable/news_search_btn.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_gamedetails_news.xml b/app/src/main/res/layout/activity_gamedetails_news.xml
new file mode 100644
index 0000000000..d4410c7429
--- /dev/null
+++ b/app/src/main/res/layout/activity_gamedetails_news.xml
@@ -0,0 +1,113 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/concern_rv_item.xml b/app/src/main/res/layout/concern_rv_item.xml
new file mode 100644
index 0000000000..eb1cba5537
--- /dev/null
+++ b/app/src/main/res/layout/concern_rv_item.xml
@@ -0,0 +1,93 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/downloadmanager_rv_item.xml b/app/src/main/res/layout/downloadmanager_rv_item.xml
new file mode 100644
index 0000000000..730d678772
--- /dev/null
+++ b/app/src/main/res/layout/downloadmanager_rv_item.xml
@@ -0,0 +1,130 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/essaydetails_item_top.xml b/app/src/main/res/layout/essaydetails_item_top.xml
index 79a12dabc4..b44f07f8d5 100644
--- a/app/src/main/res/layout/essaydetails_item_top.xml
+++ b/app/src/main/res/layout/essaydetails_item_top.xml
@@ -54,6 +54,7 @@
android:scrollbars="none" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_original.xml b/app/src/main/res/layout/fragment_original.xml
index ed9323f6e9..396dde9fb5 100644
--- a/app/src/main/res/layout/fragment_original.xml
+++ b/app/src/main/res/layout/fragment_original.xml
@@ -14,7 +14,8 @@
+ android:layout_height="wrap_content"
+ android:background="@color/bg_color">
diff --git a/app/src/main/res/layout/game_item_rv.xml b/app/src/main/res/layout/game_item_rv.xml
new file mode 100644
index 0000000000..aa30602e8f
--- /dev/null
+++ b/app/src/main/res/layout/game_item_rv.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/gamedetails_rv_item_zixun.xml b/app/src/main/res/layout/gamedetails_rv_item_zixun.xml
index 2c2f0dbd2f..82e38bd1d1 100644
--- a/app/src/main/res/layout/gamedetails_rv_item_zixun.xml
+++ b/app/src/main/res/layout/gamedetails_rv_item_zixun.xml
@@ -10,7 +10,8 @@
app:cardUseCompatPadding="true"
app:contentPaddingLeft="12dp"
app:contentPaddingRight="12dp"
- app:contentPaddingTop="15dp">
+ app:contentPaddingTop="15dp"
+ app:contentPaddingBottom="3dp">
+
+
+ android:layout_marginRight="11dp"
+ android:layout_toRightOf="@+id/home1_game_order"/>
+ android:layout_marginRight="5dp">
-
-
+ android:paddingLeft="12dp">
+ android:layout_centerInParent="true"
+ android:visibility="gone"/>
+ android:textColor="#3a3a3a"
+ android:textSize="16sp"
+ android:paddingTop="15dp"
+ android:paddingBottom="15dp"/>
+ android:paddingRight="12dp">
+ android:src="@drawable/userinfo_right" />
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/home_game_image_item.xml b/app/src/main/res/layout/home_game_image_item.xml
index 2472a4aebb..8ebe7116cb 100644
--- a/app/src/main/res/layout/home_game_image_item.xml
+++ b/app/src/main/res/layout/home_game_image_item.xml
@@ -2,12 +2,13 @@
+ android:layout_height="wrap_content">
+ android:background="@color/bg_color"
+ android:visibility="gone"/>
-
+
+ android:visibility="gone" />
-
-
+ android:layout_toRightOf="@id/home1_game_order" />
+ android:layout_toLeftOf="@+id/home1_download_btn"
+ android:layout_marginRight="5dp">
+
-
-
-
-
-
+
-
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="5dp"
+ android:layout_marginTop="10dp"
+ android:ellipsize="end"
+ android:singleLine="true"
+ android:textColor="#9a9a9a"
+ android:textSize="12sp"
+ android:lineSpacingMultiplier="0.9"
+ android:includeFontPadding="false"/>
+ android:visibility="gone"
+ android:layout_marginTop="3dp"
+ android:layout_marginBottom="2.5dp">
+ android:textColor="#9a9a9a"
+ android:textSize="10sp" />
+ android:textSize="10sp" />
+
+
+
-
+
+
+
+
-
-
+ android:id="@+id/home1_download_btn"
+ android:layout_width="60dp"
+ android:layout_height="28.5dp"
+ android:background="@drawable/textview_blue_style"
+ android:gravity="center"
+ android:text="下载"
+ android:textColor="#ffffff"
+ android:layout_alignParentRight="true"
+ android:layout_centerVertical="true"
+ android:textSize="14sp" />
\ No newline at end of file
diff --git a/app/src/main/res/layout/home_game_test_item.xml b/app/src/main/res/layout/home_game_test_item.xml
index 620a5f2137..5a0967f721 100644
--- a/app/src/main/res/layout/home_game_test_item.xml
+++ b/app/src/main/res/layout/home_game_test_item.xml
@@ -1,164 +1,163 @@
+ android:id="@+id/home1_item_layout"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="15dp">
+ android:visibility="gone" />
+ android:layout_marginRight="11dp"
+ android:layout_toRightOf="@id/home2_game_order" />
+ android:text="少年三国志"
+ android:textColor="#3a3a3a"
+ android:textSize="16sp" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:layout_below="@+id/home2_game_nameAndsize"
+ android:layout_marginBottom="2.5dp"
+ android:layout_marginTop="3dp"
+ android:layout_toLeftOf="@+id/home2_download_btn"
+ android:layout_toRightOf="@+id/home2_game_thumb"
+ android:orientation="horizontal"
+ android:visibility="gone">
+ android:id="@+id/home2_download_speed"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="4"
+ android:ellipsize="end"
+ android:singleLine="true"
+ android:text="九游版 1.2MB/s(剩3分30秒)"
+ android:textColor="#666666"
+ android:textSize="12sp" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ android:layout_below="@+id/home2_game_des"
+ android:layout_marginRight="5dp"
+ android:layout_toRightOf="@+id/home2_game_thumb"
+ android:background="@drawable/border_white_bg"
+ android:paddingBottom="2dp"
+ android:paddingLeft="4dp"
+ android:paddingRight="4dp"
+ android:paddingTop="2dp"
+ android:text="null"
+ android:textColor="#333333"
+ android:textSize="12sp" />
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index fa30605e1a..1faa47847f 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -4,7 +4,7 @@
#6633B5E5
#1BA4FC
#F5F5F5
- #E6EBEF
+ #edf2f4
#ffffff
#f1f1f1
#ffffff