游戏新闻界面,去除无用import
This commit is contained in:
88
app/src/main/java/com/gh/gamecenter/GameNewsActivity.java
Normal file
88
app/src/main/java/com/gh/gamecenter/GameNewsActivity.java
Normal file
@ -0,0 +1,88 @@
|
||||
package com.gh.gamecenter;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.gamecenter.adapter.GameNewsAdapter;
|
||||
import com.gh.gamecenter.adapter.GameNewsTypeListAdapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by LGT on 2016/8/29.
|
||||
*/
|
||||
public class GameNewsActivity extends BaseActivity {
|
||||
|
||||
private RecyclerView game_news_list;
|
||||
private GameNewsAdapter adapter;
|
||||
private LinearLayoutManager layoutManager;
|
||||
private RecyclerView game_news_top_type_list;
|
||||
|
||||
private boolean isDestroy;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
isDestroy = false;
|
||||
|
||||
View contentView = View.inflate(this, R.layout.activity_game_news, null);
|
||||
|
||||
String gameName = getIntent().getStringExtra("gameName");
|
||||
init(contentView, gameName);
|
||||
|
||||
ArrayList<String> typeList = getIntent().getStringArrayListExtra("articleTypes");
|
||||
typeList.add(0, "全部");
|
||||
|
||||
String gameId = getIntent().getStringExtra("gameId");
|
||||
|
||||
game_news_list.setHasFixedSize(true);
|
||||
layoutManager = new LinearLayoutManager(this);
|
||||
game_news_list.setLayoutManager(layoutManager);
|
||||
adapter = new GameNewsAdapter(this, typeList, gameId);
|
||||
game_news_list.setAdapter(adapter);
|
||||
game_news_list.setOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
||||
super.onScrolled(recyclerView, dx, dy);
|
||||
|
||||
if (layoutManager.findFirstVisibleItemPosition() >= 1) {
|
||||
game_news_top_type_list.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
game_news_top_type_list.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
|
||||
super.onScrollStateChanged(recyclerView, newState);
|
||||
if (!isDestroy && newState == RecyclerView.SCROLL_STATE_IDLE
|
||||
&& layoutManager.findLastVisibleItemPosition() == 3) {
|
||||
if (!adapter.isRemove() && !adapter.isLoading() && !adapter.isNetworkError()) {
|
||||
adapter.addList(adapter.getNewsList().size());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
game_news_top_type_list.setHasFixedSize(true);
|
||||
game_news_top_type_list.setLayoutManager(new GridLayoutManager(this, 5));
|
||||
game_news_top_type_list.setAdapter(new GameNewsTypeListAdapter(this, typeList));
|
||||
ViewGroup.LayoutParams params = game_news_top_type_list.getLayoutParams();
|
||||
params.height = (int) Math.ceil(typeList.size() / 5f) * DisplayUtils.dip2px(this, 40);
|
||||
game_news_top_type_list.setLayoutParams(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
isDestroy = true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user