去卡片化, 开服表, 首页游戏-资讯改版,游戏专题增加标签(还差一个接口)

This commit is contained in:
khy
2017-03-22 15:25:05 +08:00
parent e656acec1d
commit 8ba099024e
131 changed files with 4502 additions and 1145 deletions

View File

@ -2,7 +2,6 @@ package com.gh.gamecenter;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.widget.RecyclerView;
@ -18,15 +17,13 @@ import android.widget.TextView;
import android.widget.Toast;
import com.gh.base.BaseActivity;
import com.gh.common.constant.Config;
import com.gh.common.util.DataCollectionUtils;
import com.gh.common.util.DataUtils;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.MeasureHeightLayoutManager;
import com.gh.common.util.NewsUtils;
import com.gh.common.view.CardLinearLayout;
import com.gh.common.view.VerticalItemDecoration;
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
import com.gh.gamecenter.adapter.viewholder.NewsTextViewHolder;
import com.gh.gamecenter.entity.NewsEntity;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
@ -54,7 +51,6 @@ public class NewsSearchActivity extends BaseActivity {
@BindView(R.id.et_search) EditText et_search;
@BindView(R.id.gamedetail_news_ll_loading) LinearLayout gamedetail_news_ll_loading;
@BindView(R.id.reuse_no_connection) LinearLayout reuse_no_connection;
@BindView(R.id.gamedetail_news_cardView) CardLinearLayout gamedetail_news_cardView;
private MeasureHeightLayoutManager layoutManager;
private List<NewsEntity> newsEntities;
@ -89,14 +85,6 @@ public class NewsSearchActivity extends BaseActivity {
DisplayMetrics outMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
ViewGroup.LayoutParams params = gamedetail_news_cardView.getLayoutParams();
params.height = outMetrics.heightPixels
- DisplayUtils.dip2px(this, 38 + 16 + 8 + 8)
- getSharedPreferences(Config.PREFERENCE, Context.MODE_PRIVATE).getInt("actionbar_height",
DisplayUtils.dip2px(getApplicationContext(), 48))
- DisplayUtils.getStatusBarHeight(getResources());
gamedetail_news_cardView.setLayoutParams(params);
newsEntities = new ArrayList<>();
searchAdapter = new NewsSearchAdapter();
@ -104,7 +92,7 @@ public class NewsSearchActivity extends BaseActivity {
gamedetail_news_rv.setLayoutManager(layoutManager);
gamedetail_news_rv.setAdapter(searchAdapter);
gamedetail_news_rv.addItemDecoration(new VerticalItemDecoration(NewsSearchActivity.this, 1));
gamedetail_news_rv.addItemDecoration(new VerticalItemDecoration(NewsSearchActivity.this, 1, false));
et_search.setText(searchKey);
@ -124,7 +112,6 @@ public class NewsSearchActivity extends BaseActivity {
searchAdapter.notifyDataSetChanged();
gamedetail_news_ll_loading.setVisibility(View.VISIBLE);
reuse_none_data.setVisibility(View.GONE);
gamedetail_news_cardView.setVisibility(View.GONE);
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
handler.postDelayed(new Runnable() {
@ -160,7 +147,6 @@ public class NewsSearchActivity extends BaseActivity {
public void onClick(View v) {
reuse_no_connection.setVisibility(View.GONE);
gamedetail_news_ll_loading.setVisibility(View.VISIBLE);
gamedetail_news_cardView.setVisibility(View.GONE);
handler.postDelayed(new Runnable() {
@Override
public void run() {
@ -191,7 +177,6 @@ public class NewsSearchActivity extends BaseActivity {
public void onResponse(List<NewsEntity> response) {
isLoadOver = true;
gamedetail_news_ll_loading.setVisibility(View.GONE);
gamedetail_news_cardView.setVisibility(View.VISIBLE);
reuse_none_data.setVisibility(View.GONE);
if (response.size() != 0) {
@ -199,7 +184,6 @@ public class NewsSearchActivity extends BaseActivity {
searchAdapter.notifyDataSetChanged();
} else {
if (page == 1) {
gamedetail_news_cardView.setVisibility(View.GONE);
reuse_none_data.setVisibility(View.VISIBLE);
}
@ -243,31 +227,20 @@ public class NewsSearchActivity extends BaseActivity {
R.layout.refresh_footerview, parent, false);
return new FooterViewHolder(view);
} else {
LinearLayout linearLayout = new LinearLayout(parent.getContext());
linearLayout.setOrientation(LinearLayout.HORIZONTAL);
linearLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
linearLayout.setBackgroundResource(R.drawable.cardview_item_style);
TextView textView = new TextView(parent.getContext());
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.setSingleLine();
textView.setTextSize(15);
linearLayout.addView(textView);
return new ViewHolder(linearLayout);
View view = LayoutInflater.from(parent.getContext()).inflate(
R.layout.news_text_item, parent, false);
return new NewsTextViewHolder(view);
}
}
@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
if (holder instanceof ViewHolder){
ViewHolder viewHolder = (ViewHolder) holder;
viewHolder.tvTitle.setText(Html.fromHtml(newsEntities.get(position).getTitle()));
viewHolder.linearLayout.setOnClickListener(new View.OnClickListener() {
if (holder instanceof NewsTextViewHolder){
NewsTextViewHolder viewHolder = (NewsTextViewHolder) holder;
viewHolder.title.setText(Html.fromHtml(newsEntities.get(position).getTitle()));
viewHolder.type.setVisibility(View.GONE);
viewHolder.line.setVisibility(View.GONE);
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NewsEntity newsEntity = newsEntities.get(holder.getPosition());
@ -321,14 +294,5 @@ public class NewsSearchActivity extends BaseActivity {
return newsEntities.size() + 1;
}
public class ViewHolder extends RecyclerView.ViewHolder{
LinearLayout linearLayout;
TextView tvTitle;
public ViewHolder(View itemView) {
super(itemView);
linearLayout = (LinearLayout) itemView;
tvTitle = (TextView) linearLayout.getChildAt(0);
}
}
}
}