diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 8131e1bb6c..fa5ed9b5ce 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -63,7 +63,7 @@
android:value="81DB144D555386A38A70B833537EC256" />
+ android:value="GH_202"/>
@@ -194,6 +194,12 @@
+
+
diff --git a/app/src/main/java/com/gh/base/BaseActivity.java b/app/src/main/java/com/gh/base/BaseActivity.java
index 49b893069e..052fe40093 100644
--- a/app/src/main/java/com/gh/base/BaseActivity.java
+++ b/app/src/main/java/com/gh/base/BaseActivity.java
@@ -3,6 +3,7 @@ package com.gh.base;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
+import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
@@ -68,7 +69,7 @@ public class BaseActivity extends Activity implements OnCallBackListener {
setTranslucentStatus(true);
tintManager = new SystemBarTintManager(this);
tintManager.setStatusBarTintEnabled(true);
- tintManager.setStatusBarTintResource(R.color.theme);
+ tintManager.setStatusBarTintColor(Color.BLACK);
SystemBarConfig config = tintManager.getConfig();
contentView.setPadding(0, config.getPixelInsetTop(false), 0,
config.getPixelInsetBottom());
@@ -80,7 +81,7 @@ public class BaseActivity extends Activity implements OnCallBackListener {
int actionbar_height = getSharedPreferences(Config.PREFERENCE,
Context.MODE_PRIVATE).getInt("actionbar_height",
- DisplayUtils.dip2px(getApplicationContext(), 48));
+ DisplayUtils.dip2px(getApplicationContext(), 55));
RelativeLayout reuse_actionbar = (RelativeLayout) findViewById(R.id.reuse_actionbar);
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
diff --git a/app/src/main/java/com/gh/base/BaseFragmentActivity.java b/app/src/main/java/com/gh/base/BaseFragmentActivity.java
index 002fc2dc42..6b8aa4ae89 100644
--- a/app/src/main/java/com/gh/base/BaseFragmentActivity.java
+++ b/app/src/main/java/com/gh/base/BaseFragmentActivity.java
@@ -2,6 +2,7 @@ package com.gh.base;
import android.annotation.TargetApi;
import android.content.Context;
+import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
@@ -65,7 +66,7 @@ public class BaseFragmentActivity extends FragmentActivity {
setTranslucentStatus(true);
SystemBarTintManager tintManager = new SystemBarTintManager(this);
tintManager.setStatusBarTintEnabled(true);
- tintManager.setStatusBarTintResource(R.color.theme);
+ tintManager.setStatusBarTintColor(Color.BLACK);
SystemBarConfig config = tintManager.getConfig();
contentView.setPadding(0, config.getPixelInsetTop(false), 0,
config.getPixelInsetBottom());
diff --git a/app/src/main/java/com/gh/base/HomeFragment.java b/app/src/main/java/com/gh/base/HomeFragment.java
index 3b2b1c05a5..93747b4eeb 100644
--- a/app/src/main/java/com/gh/base/HomeFragment.java
+++ b/app/src/main/java/com/gh/base/HomeFragment.java
@@ -8,10 +8,12 @@ import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
-import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.view.animation.AlphaAnimation;
+import android.view.animation.Animation;
+import android.view.animation.ScaleAnimation;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -28,6 +30,8 @@ import com.gh.gamecenter.eventbus.EBDownloadStatus;
import com.gh.gamecenter.eventbus.EBReuse;
import com.gh.gamecenter.manager.PackageManager;
+import java.util.ArrayList;
+
import de.greenrobot.event.EventBus;
/**
@@ -43,13 +47,16 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
private TextView downloadHint;
private TextView searchHint;
- private String hint;
+ private AlphaAnimation mAlphaAnimation;
+
+ private ArrayList hintList;
+ private int hintIndex;
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
- if (!TextUtils.isEmpty(hint)) {
- outState.putString("hint", hint);
+ if (!hintList.isEmpty()) {
+ outState.putStringArrayList("hint", hintList);
}
}
@@ -58,17 +65,18 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
super.onCreate(savedInstanceState);
if (savedInstanceState != null) {
- hint = savedInstanceState.getString("hint");
+ hintList = savedInstanceState.getStringArrayList("hint");
}
+ hintIndex = 0;
+
view = View.inflate(getActivity(), R.layout.fragment_home, null);
SharedPreferences sp = getActivity().getSharedPreferences(
Config.PREFERENCE, Context.MODE_PRIVATE);
LinearLayout home_actionbar = (LinearLayout) view.findViewById(R.id.home_actionbar);
LinearLayout.LayoutParams lparams = new LinearLayout.LayoutParams(
- LinearLayout.LayoutParams.MATCH_PARENT, sp.getInt("actionbar_height",
- DisplayUtils.dip2px(getActivity(), 48)));
+ LinearLayout.LayoutParams.MATCH_PARENT,DisplayUtils.dip2px(getActivity(), 55));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
int top = DisplayUtils.getStatusBarHeight(getResources());
@@ -79,6 +87,70 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
initActionBar();
+ final ScaleAnimation scaleAnimation = new ScaleAnimation(0.4f, 1.0f, 0.4f, 1.0f
+ , Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
+ scaleAnimation.setDuration(500);
+
+ mAlphaAnimation = new AlphaAnimation(1f, 0.2f);
+ mAlphaAnimation.setDuration(300);
+ mAlphaAnimation.setStartOffset(5000);
+
+ scaleAnimation.setAnimationListener(new Animation.AnimationListener() {
+ @Override
+ public void onAnimationStart(Animation animation) {
+
+ }
+
+ @Override
+ public void onAnimationEnd(Animation animation) {
+ if (mAlphaAnimation != null) {
+ searchHint.setAnimation(mAlphaAnimation);
+ mAlphaAnimation.start();
+ }
+ }
+
+ @Override
+ public void onAnimationRepeat(Animation animation) {
+
+ }
+ });
+
+ mAlphaAnimation.setAnimationListener(new Animation.AnimationListener() {
+ @Override
+ public void onAnimationStart(Animation animation) {
+
+ }
+
+ @Override
+ public void onAnimationEnd(Animation animation) {
+ // 切换数据
+ if (hintIndex > hintList.size() - 1) {
+ hintIndex = 0;
+ }
+ searchHint.setHint(hintList.get(hintIndex));
+ hintIndex ++;
+
+ if (scaleAnimation != null) {
+ searchHint.setAnimation(scaleAnimation);
+ scaleAnimation.start();
+ }
+ }
+
+ @Override
+ public void onAnimationRepeat(Animation animation) {
+
+ }
+ });
+
+ if (hintList != null && hintList.size() > 0) {
+ if (hintList.size() > 1) {
+ searchHint.setAnimation(mAlphaAnimation);
+ } else {
+ String hint = hintList.get(0);
+ searchHint.setHint(hint);
+ }
+ }
+
EventBus.getDefault().register(this);
}
@@ -96,6 +168,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
view.findViewById(R.id.actionbar_rl_download).setOnClickListener(this);
view.findViewById(R.id.actionbar_iv_search).setOnClickListener(this);
view.findViewById(R.id.actionbar_notification).setOnClickListener(this);
+ view.findViewById(R.id.actionbar_search_rl).setOnClickListener(this);
if (Config.isShow(getActivity())) {
view.findViewById(R.id.actionbar_rl_download).setVisibility(View.VISIBLE);
@@ -118,9 +191,6 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
searchHint = (TextView) view.findViewById(R.id.actionbar_search_input);
searchHint.setOnClickListener(this);
- if (!TextUtils.isEmpty(hint)) {
- searchHint.setHint(hint);
- }
}
@Override
@@ -140,16 +210,16 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
Intent intent = new Intent(getActivity(), SearchActivity.class);
intent.putExtra("clicked", true);
- intent.putExtra("hint", hint);
+ intent.putExtra("hint", searchHint.getHint().toString());
intent.putExtra("entrance", "(工具栏)");
startActivity(intent);
- } else if (id == R.id.actionbar_search_input) {
+ } else if (id == R.id.actionbar_search_input || id == R.id.actionbar_search_rl) {
DataUtils.onEvent(getActivity(), "主页", "搜索框");
DataCollectionUtils.uploadClick(getActivity(), "搜索框", "主页");
Intent intent = new Intent(getActivity(), SearchActivity.class);
intent.putExtra("clicked", false);
- intent.putExtra("hint", hint);
+ intent.putExtra("hint", searchHint.getHint().toString());
intent.putExtra("entrance", "(工具栏)");
startActivity(intent);
} else if (id == R.id.actionbar_notification) {
@@ -173,11 +243,13 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
}
}
- public void setHint(String hint) {
- if (!TextUtils.isEmpty(hint)) {
- this.hint = hint;
- if (searchHint != null) {
- searchHint.setHint(hint);
+ public void setHint(ArrayList hint) {
+ if (hint != null && hint.size() > 0) {
+ hintList = hint;
+ if (hint.size() == 1 && searchHint != null) {
+ searchHint.setHint(hintList.get(0));
+ } else if (mAlphaAnimation != null && searchHint != null) {
+ searchHint.setAnimation(mAlphaAnimation);
}
}
}
diff --git a/app/src/main/java/com/gh/common/constant/Config.java b/app/src/main/java/com/gh/common/constant/Config.java
index d78270181f..390a837162 100644
--- a/app/src/main/java/com/gh/common/constant/Config.java
+++ b/app/src/main/java/com/gh/common/constant/Config.java
@@ -6,7 +6,7 @@ import android.content.SharedPreferences;
public class Config {
- public static final String HOST = "http://api.ghzhushou.com/v2d4/";
+ public static final String HOST = "http://api.ghzhushou.com/v2d5/";
public static final String USER_HOST = "http://user.ghzhushou.com/v1d2/";
public static final String COMMENT_HOST = "http://comment.ghzhushou.com/v1d1/";
public static final String DATA_HOST = "http://data.ghzhushou.com/";
diff --git a/app/src/main/java/com/gh/common/constant/ItemViewType.java b/app/src/main/java/com/gh/common/constant/ItemViewType.java
index 19e3ef3699..c23a6390f0 100644
--- a/app/src/main/java/com/gh/common/constant/ItemViewType.java
+++ b/app/src/main/java/com/gh/common/constant/ItemViewType.java
@@ -23,5 +23,6 @@ public class ItemViewType {
public static final int LIBAO_NORMAL = 15; // 礼包正常布局
public static final int LIBAO_SKIP_CONCERN = 16; // 跳转关注管理页面布局
public static final int KC_HINT = 16;
+ public static final int ZIXUNTOP_TOP = 7; // 有料顶部布局
}
diff --git a/app/src/main/java/com/gh/common/util/GameViewUtils.java b/app/src/main/java/com/gh/common/util/GameViewUtils.java
index 255f538d78..00fda1fac1 100644
--- a/app/src/main/java/com/gh/common/util/GameViewUtils.java
+++ b/app/src/main/java/com/gh/common/util/GameViewUtils.java
@@ -39,7 +39,7 @@ public class GameViewUtils {
if (i == size - 1) {
view = getGameTagView(context, tag.get(i), 0);
} else {
- view = getGameTagView(context, tag.get(i), DisplayUtils.dip2px(context, 5));
+ view = getGameTagView(context, tag.get(i), DisplayUtils.dip2px(context, 6));
}
if (view != null) {
labelLayout.addView(view);
diff --git a/app/src/main/java/com/gh/common/util/KaiFuUtils.java b/app/src/main/java/com/gh/common/util/KaiFuUtils.java
new file mode 100644
index 0000000000..329d468625
--- /dev/null
+++ b/app/src/main/java/com/gh/common/util/KaiFuUtils.java
@@ -0,0 +1,78 @@
+package com.gh.common.util;
+
+import android.graphics.Color;
+import android.widget.TextView;
+
+import com.gh.gamecenter.R;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+/**
+ * Created by khy on 2017/3/19.
+ */
+public class KaiFuUtils {
+
+ public static void setKaiFuTime(TextView textView, long time) {
+ time = time * 1000;
+ SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd", Locale.getDefault());
+ try {
+ long today = format.parse(format.format(new Date())).getTime();
+ if (time >= today && time < today + 86400 * 1000) {
+ format.applyPattern("HH:mm");
+ textView.setText(String.format("今天 %s", format.format(time)));
+ textView.setBackgroundResource(R.drawable.border_white_bg);
+ textView.setTextColor(Color.parseColor("#ffb13c"));
+ } else if (time >= today - 86400 * 1000 && time < today) {
+ format.applyPattern("HH:mm");
+ textView.setText(String.format("昨天 %s", format.format(time)));
+ textView.setBackgroundResource(R.drawable.kaifu_time_tag_gray);
+ textView.setTextColor(Color.parseColor("#c7c7c7"));
+ } else if (time > today && time < today + 86400 * 1000 * 2){
+ format.applyPattern("HH:mm");
+ textView.setText(String.format("明天 %s", format.format(time)));
+ textView.setBackgroundResource(R.drawable.border_white_bg);
+ textView.setTextColor(Color.parseColor("#ffb13c"));
+ } else if (time >= today - 86400 * 1000 * 2 && time < today){
+ format.applyPattern("HH:mm");
+ textView.setText(String.format("前天 %s", format.format(time)));
+ textView.setBackgroundResource(R.drawable.kaifu_time_tag_gray);
+ textView.setTextColor(Color.parseColor("#c7c7c7"));
+ } else if (time > today && time < today + 86400 * 1000 * 3){
+ format.applyPattern("HH:mm");
+ textView.setText(String.format("后天 %s", format.format(time)));
+ textView.setBackgroundResource(R.drawable.kaifu_time_tag_gray);
+ textView.setTextColor(Color.parseColor("#c7c7c7"));
+ } else {
+ format.applyPattern("MM-dd HH:mm");
+ textView.setText(format.format(time));
+ textView.setBackgroundResource(R.drawable.kaifu_time_tag_gray);
+ textView.setTextColor(Color.parseColor("#c7c7c7"));
+ }
+ } catch (ParseException e) {
+ e.printStackTrace();
+ format.applyPattern("yyyy年MM月dd日 HH:mm");
+ textView.setText(format.format(time));
+ }
+ }
+
+ public static void setKaiFuType(TextView textView, String type) {
+ textView.setText(type);
+ switch (type) {
+ case "不删档内测":
+ textView.setBackgroundColor(Color.parseColor("#c7c7c7"));
+ break;
+ case "删档内测":
+ textView.setBackgroundColor(Color.parseColor("#c7c7c7"));
+ break;
+ case "公测":
+ textView.setBackgroundColor(Color.parseColor("#06d0a8"));
+ break;
+ default:
+ textView.setBackgroundColor(Color.parseColor("#06d0a8"));
+ break;
+ }
+ }
+}
diff --git a/app/src/main/java/com/gh/common/view/VerticalItemDecoration.java b/app/src/main/java/com/gh/common/view/VerticalItemDecoration.java
index f04471d28c..68b080df50 100644
--- a/app/src/main/java/com/gh/common/view/VerticalItemDecoration.java
+++ b/app/src/main/java/com/gh/common/view/VerticalItemDecoration.java
@@ -14,30 +14,42 @@ public class VerticalItemDecoration extends RecyclerView.ItemDecoration {
private Paint paint;
private int mInterval = 0;
+ private boolean isShowIntervalTop;
- public VerticalItemDecoration(Context context, int interval) {
+ public VerticalItemDecoration(Context context, int interval, boolean isShowIntervalTop) {
paint = new Paint();
- paint.setColor(context.getResources().getColor(R.color.background));
+ paint.setColor(context.getResources().getColor(R.color.background ));
mInterval = DisplayUtils.dip2px(context, interval);
+ this.isShowIntervalTop = isShowIntervalTop;
}
@Override
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
int left = parent.getPaddingLeft();
int right = parent.getMeasuredWidth() - parent.getPaddingRight();
- for (int i = 0, size = parent.getChildCount() - 1; i < size; i++) {
+ for (int i = 0, size = parent.getChildCount(); i < size; i++) {
View child = parent.getChildAt(i);
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child
.getLayoutParams();
int top = child.getBottom() + layoutParams.bottomMargin;
int bottom = top + mInterval;
- c.drawRect(left, top, right, bottom, paint);
+
+ if (i == 0 && isShowIntervalTop) {
+ c.drawRect(left, 0, right, bottom, paint);
+ } else {
+ c.drawRect(left, top, right, bottom, paint);
+ }
}
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent,
RecyclerView.State state) {
- outRect.set(0, 0, 0, mInterval);
+ int position = parent.getChildPosition(view);
+ if (position == 0 && isShowIntervalTop) {
+ outRect.set(0, mInterval, 0, mInterval);
+ } else {
+ outRect.set(0, 0, 0, mInterval);
+ }
}
}
diff --git a/app/src/main/java/com/gh/gamecenter/CleanApkActivity.java b/app/src/main/java/com/gh/gamecenter/CleanApkActivity.java
index 2ae0ad9f25..57f824cf12 100644
--- a/app/src/main/java/com/gh/gamecenter/CleanApkActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/CleanApkActivity.java
@@ -17,6 +17,7 @@ import android.widget.TextView;
import com.gh.base.BaseActivity;
import com.gh.common.util.DialogUtils;
import com.gh.common.util.Utils;
+import com.gh.common.view.VerticalItemDecoration;
import com.gh.gamecenter.adapter.CleanApkAdapter;
import com.gh.gamecenter.entity.InstallGameEntity;
import com.gh.gamecenter.eventbus.EBSkip;
@@ -57,6 +58,7 @@ public class CleanApkActivity extends BaseActivity implements CleanApkAdapter.On
mAdapter = new CleanApkAdapter(this, mApkDeleteBtn, mApkSelectAll);
mApkRv.setLayoutManager(new LinearLayoutManager(this));
+ mApkRv.addItemDecoration(new VerticalItemDecoration(this, 8, true));
mApkRv.setAdapter(mAdapter);
mApkSelectAll.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
diff --git a/app/src/main/java/com/gh/gamecenter/GameDetailActivity.java b/app/src/main/java/com/gh/gamecenter/GameDetailActivity.java
index 247c0ffaf3..1362b45632 100644
--- a/app/src/main/java/com/gh/gamecenter/GameDetailActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/GameDetailActivity.java
@@ -12,6 +12,7 @@ import com.gh.base.BaseDetailActivity;
import com.gh.common.util.DataCollectionUtils;
import com.gh.common.util.DataUtils;
import com.gh.common.util.DialogUtils;
+import com.gh.common.view.VerticalItemDecoration;
import com.gh.gamecenter.changeskin.ChangeSkinUtils;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.eventbus.EBConcernChanged;
@@ -75,6 +76,7 @@ public class GameDetailActivity extends BaseDetailActivity implements View.OnCli
adapter = new GameDetailAdapter(this, entrance);
detail_rv_show.setLayoutManager(new LinearLayoutManager(this));
+ detail_rv_show.addItemDecoration(new VerticalItemDecoration(this, 8, true));
detail_rv_show.setAdapter(adapter);
detail_ll_bottom.setOnClickListener(this);
diff --git a/app/src/main/java/com/gh/gamecenter/KaiFuActivity.java b/app/src/main/java/com/gh/gamecenter/KaiFuActivity.java
new file mode 100644
index 0000000000..bcfddc27a1
--- /dev/null
+++ b/app/src/main/java/com/gh/gamecenter/KaiFuActivity.java
@@ -0,0 +1,401 @@
+package com.gh.gamecenter;
+
+import android.animation.Animator;
+import android.os.Bundle;
+import android.support.v4.widget.SwipeRefreshLayout;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.text.TextUtils;
+import android.view.KeyEvent;
+import android.view.View;
+import android.widget.LinearLayout;
+import android.widget.PopupWindow;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import com.gc.materialdesign.views.ProgressBarCircularIndeterminate;
+import com.gh.base.BaseActivity;
+import com.gh.common.util.DownloadItemUtils;
+import com.gh.common.util.MeasureHeightLayoutManager;
+import com.gh.common.view.VerticalItemDecoration;
+import com.gh.download.DataWatcher;
+import com.gh.download.DownloadEntity;
+import com.gh.download.DownloadManager;
+import com.gh.gamecenter.adapter.KaiFuAdapter;
+import com.gh.gamecenter.adapter.KaiFuDialogAdapter;
+import com.gh.gamecenter.entity.ApkEntity;
+import com.gh.gamecenter.entity.GameEntity;
+import com.gh.gamecenter.eventbus.EBDownloadStatus;
+import com.gh.gamecenter.eventbus.EBNetworkState;
+import com.gh.gamecenter.eventbus.EBPackage;
+import com.jakewharton.rxbinding.view.RxView;
+
+import java.util.ArrayList;
+import java.util.concurrent.TimeUnit;
+
+import butterknife.BindView;
+import rx.functions.Action1;
+
+/**
+ * Created by khy on 2017/3/16.
+ */
+public class KaiFuActivity extends BaseActivity implements KaiFuDialogAdapter.OnKaiFuDialogCallBackListener
+ , KaiFuAdapter.OnScrollToKaiFuIndex, SwipeRefreshLayout.OnRefreshListener{
+
+ @BindView(R.id.kaifu_rv) RecyclerView mRecyclerView;
+ @BindView(R.id.kaifu_pb) ProgressBarCircularIndeterminate mPbLoading;
+ @BindView(R.id.kaifu_refresh) SwipeRefreshLayout mRefreshLayout;
+ @BindView(R.id.kaifu_game_name) TextView mGameName;
+ @BindView(R.id.popup_bg) View mPopupBg;
+ @BindView(R.id.kaifu_select_game_rl) RelativeLayout mSelectGameRl;
+ @BindView(R.id.reuse_no_connection) LinearLayout mNoConnection;
+
+ private PopupWindow mPopupWindow;
+
+ private KaiFuAdapter mAdapter;
+
+ private LinearLayoutManager layoutManager;
+
+ private boolean isEverpause = false;
+
+ private String kaifuType;
+
+ private int mDialogGamePosition; // 顶部弹窗过滤位置
+ private int kaifuOffset = 0;
+
+ private DataWatcher dataWatcher = new DataWatcher() {
+ @Override
+ public void onDataChanged(DownloadEntity downloadEntity) {
+ ArrayList locationList = mAdapter.getLocationMap().get(downloadEntity.getPackageName());
+ if (locationList != null) {
+ GameEntity gameEntity;
+ for (int location : locationList) {
+ gameEntity = mAdapter.getSubjectList().get(location - getGameEntityIndex());
+ if (gameEntity != null) {
+ DownloadItemUtils.processDate(KaiFuActivity.this, gameEntity, downloadEntity,
+ mAdapter, location);
+ }
+ }
+ }
+ }
+ };
+
+ private int getGameEntityIndex() {
+ if (kaifuOffset != 0) {
+ return 1;
+ }
+ return 0;
+ }
+
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ mAdapter = new KaiFuAdapter(KaiFuActivity.this, kaifuType);
+ mRecyclerView.setAdapter(mAdapter);
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ View view = View.inflate(this, R.layout.activity_kaifu, null);
+ init(view, "开服表");
+
+ kaifuType = "全部";
+
+ mRefreshLayout.setColorSchemeResources(R.color.theme);
+ mRefreshLayout.setOnRefreshListener(this);
+ mRefreshLayout.setEnabled(false);
+
+ mAdapter = new KaiFuAdapter(this, kaifuType);
+ layoutManager = new LinearLayoutManager(this);
+ mRecyclerView.addItemDecoration(new VerticalItemDecoration(this, 8, false));
+ mRecyclerView.setLayoutManager(layoutManager);
+ mRecyclerView.setAdapter(mAdapter);
+
+ mRecyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
+ @Override
+ public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
+ super.onScrollStateChanged(recyclerView, newState);
+ //上拉加载
+ if (mAdapter.isLoadedBottom() && newState == RecyclerView.SCROLL_STATE_IDLE
+ && mAdapter.getItemCount() == layoutManager.findLastVisibleItemPosition() + 1){
+ mAdapter.initListBottom(kaifuOffset + mAdapter.loadCountBottom());
+ }
+ //下拉加载
+ if (kaifuOffset >0 && mAdapter.isLoadedTop() && newState == RecyclerView.SCROLL_STATE_IDLE
+ && layoutManager.findFirstVisibleItemPosition() == 0) {
+ int countTop = mAdapter.loadCountTop();
+ if (countTop%20 == 0) { // 不是20的倍数 证明加载完毕
+ int offset = kaifuOffset - countTop;
+ int limit = 20;
+ if (offset < 0) {
+ limit = limit + offset;
+ offset = 0;
+ }
+
+ if (limit == 0) return;
+
+ mAdapter.initListTop(offset, limit);
+ }
+ }
+ }
+ });
+
+
+ // 防抖处理
+ RxView.clicks(mSelectGameRl)
+ .throttleFirst(1, TimeUnit.SECONDS)
+ .subscribe(new Action1() {
+ @Override
+ public void call(Void aVoid) {
+ initSelectGameDialog();
+ }
+ });
+
+ }
+
+ private void initSelectGameDialog() {
+ isShowPopupBg(true);
+
+ View contentView = View.inflate(this, R.layout.dialog_kaifu_select_game, null);
+ RecyclerView selectGameRv = (RecyclerView) contentView.findViewById(R.id.dialog_kaifu_select_game_rv);
+ final TextView selectGameTitle = (TextView) contentView.findViewById(R.id.dialog_kaifu_title);
+
+ final MeasureHeightLayoutManager layout = new MeasureHeightLayoutManager(this);
+ selectGameRv.setLayoutManager(layout);
+ selectGameRv.setAdapter(new KaiFuDialogAdapter(this, mDialogGamePosition));
+
+
+ mPopupWindow = new PopupWindow(contentView, LinearLayout.LayoutParams.MATCH_PARENT
+ , LinearLayout.LayoutParams.MATCH_PARENT, true);
+ mPopupWindow.setAnimationStyle(R.style.scale_popwindow_anim_style);
+ mPopupWindow.showAtLocation(mSelectGameRl, 0, 0, 0);
+
+ selectGameRv.setOnScrollListener(new RecyclerView.OnScrollListener() {
+ @Override
+ public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
+ super.onScrolled(recyclerView, dx, dy);
+
+ if (layout.findFirstVisibleItemPosition() >= 5) {
+ selectGameTitle.setVisibility(View.VISIBLE);
+ } else {
+ selectGameTitle.setVisibility(View.GONE);
+ }
+
+ }
+ });
+
+ selectGameRv.setOnKeyListener(new View.OnKeyListener() {
+ @Override
+ public boolean onKey(View v, int keyCode, KeyEvent event) {
+ if (keyCode == KeyEvent.KEYCODE_BACK
+ && event.getRepeatCount() == 0
+ && mPopupWindow != null
+ && mPopupWindow.isShowing()) {
+ isShowPopupBg(false);
+ }
+ return false;
+ }
+ });
+
+ contentView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ isShowPopupBg(false);
+ }
+ });
+ }
+
+ @Override
+ public void selectPosition(int position, String tag, String gameName) {
+ mDialogGamePosition = position;
+ if (!TextUtils.isEmpty(gameName)) {
+ mGameName.setText(gameName);
+ } else {
+ mGameName.setText(tag);
+ }
+ isShowPopupBg(false);
+
+ kaifuOffset = 0;
+ kaifuType = tag;
+
+ mRecyclerView.setVisibility(View.VISIBLE);
+ mPbLoading.setVisibility(View.VISIBLE);
+ mNoConnection.setVisibility(View.GONE);
+
+ mAdapter = new KaiFuAdapter(this, kaifuType);
+ mRecyclerView.setAdapter(mAdapter);
+ }
+
+ public void isShowPopupBg(boolean isShow) {
+ if(isShow) {
+ mPopupBg.setVisibility(View.VISIBLE);
+ mPopupBg.animate()
+ .alpha(1f)
+ .setDuration(300)
+ .setListener(null);
+ } else {
+ mPopupWindow.dismiss();
+ mPopupBg.animate()
+ .alpha(0f)
+ .setDuration(300)
+ .setListener(new Animator.AnimatorListener() {
+ @Override
+ public void onAnimationStart(Animator animation) {
+
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mPopupBg.setVisibility(View.GONE);
+ }
+
+ @Override
+ public void onAnimationCancel(Animator animation) {
+
+ }
+
+ @Override
+ public void onAnimationRepeat(Animator animation) {
+
+ }
+
+ });
+ }
+
+ }
+
+ @Override
+ public void loadError() {
+ if (mPbLoading != null && mPbLoading.getVisibility() == View.VISIBLE) {
+ mPbLoading.setVisibility(View.GONE);
+ }
+ toast("加载失败,请检查网络状态");
+ mPbLoading.setVisibility(View.GONE);
+ mNoConnection.setVisibility(View.VISIBLE);
+ }
+
+ @Override
+ public void loadDone() {
+ if (mPbLoading != null && mPbLoading.getVisibility() == View.VISIBLE) {
+ mPbLoading.setVisibility(View.GONE);
+ }
+
+ if (mRefreshLayout.isRefreshing()) {
+ mRefreshLayout.setRefreshing(false);
+ }
+ }
+
+ @Override
+ public void loadDone(Object obj) {
+ super.loadDone(obj);
+
+ kaifuOffset = (int) obj;
+
+ if (kaifuOffset == 0) {
+ mRefreshLayout.setEnabled(true);
+ } else {
+ mRefreshLayout.setEnabled(false);
+ }
+ }
+
+ // 下载被删除事件
+ public void onEventMainThread(EBDownloadStatus status) {
+ if ("delete".equals(status.getStatus())) {
+ DownloadManager.getInstance(this).removePlatform(status.getName(), status.getPlatform());
+
+ ArrayList locationList = mAdapter.getLocationMap().get(status.getPackageName());
+ if (locationList != null) {
+ GameEntity gameEntity;
+ for (int location : locationList) {
+
+ gameEntity = mAdapter.getSubjectList().get(location - getGameEntityIndex());
+ if (gameEntity != null && gameEntity.getEntryMap() != null) {
+ gameEntity.getEntryMap().remove(status.getPlatform());
+ }
+ mAdapter.notifyItemChanged(location);
+ }
+ }
+ }
+ }
+
+ public void onEventMainThread(EBPackage busFour) {
+ ArrayList locationList = mAdapter.getLocationMap().get(busFour.getPackageName());
+ if (locationList != null) {
+ GameEntity gameEntity;
+ for (int location : locationList) {
+ if ("安装".equals(busFour.getType())) {
+ gameEntity = mAdapter.getSubjectList().get(location - getGameEntityIndex());
+ for (ApkEntity apkEntity : gameEntity.getApk()) {
+ if (apkEntity.getPackageName().equals(busFour.getPackageName())) {
+ if (gameEntity.getEntryMap() != null) {
+ gameEntity.getEntryMap().remove(apkEntity.getPlatform());
+ }
+ mAdapter.notifyItemChanged(location + getGameEntityIndex());
+ break;
+ }
+ }
+ } else if ("卸载".equals(busFour.getType())) {
+ mAdapter.notifyItemChanged(location + getGameEntityIndex());
+ }
+ }
+ }
+ }
+
+ //连接上网络事件
+ public void onEventMainThread(EBNetworkState busNetworkState) {
+ if (busNetworkState.isNetworkConnected()) {
+ if (mNoConnection.getVisibility() == View.VISIBLE) {
+ mRecyclerView.setVisibility(View.VISIBLE);
+ mPbLoading.setVisibility(View.VISIBLE);
+ mNoConnection.setVisibility(View.GONE);
+ mAdapter = new KaiFuAdapter(KaiFuActivity.this, kaifuType);
+ mRecyclerView.setAdapter(mAdapter);
+ }
+ }
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ if (isEverpause) {
+ for (GameEntity entity : mAdapter.getSubjectList()) {
+ entity.setEntryMap(DownloadManager.getInstance(this).getEntryMap(entity.getName()));
+ }
+ }
+ isEverpause = false;
+ DownloadManager.getInstance(getApplicationContext()).addObserver(dataWatcher);
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ isEverpause = true;
+ DownloadManager.getInstance(getApplicationContext()).removeObserver(dataWatcher);
+ }
+
+ private void moveToPosition(int n) {
+ int firstItem = layoutManager.findFirstVisibleItemPosition();
+ int lastItem = layoutManager.findLastVisibleItemPosition();
+ if (n <= firstItem ){
+ mRecyclerView.scrollToPosition(n);
+ }else if ( n <= lastItem ){
+ int top = mRecyclerView.getChildAt(n - firstItem).getTop();
+ mRecyclerView.scrollBy(0, top);
+ }else{
+ mRecyclerView.scrollToPosition(n);
+ }
+
+ }
+
+ @Override
+ public void onScroll(int scrollPosition) {
+ moveToPosition(scrollPosition + getGameEntityIndex());
+ }
+
+ @Override
+ public void onRefresh() {
+ mRecyclerView.postDelayed(runnable, 1000);
+ }
+}
diff --git a/app/src/main/java/com/gh/gamecenter/KcSelectGameActivity.java b/app/src/main/java/com/gh/gamecenter/KcSelectGameActivity.java
index b8bc117bd9..525024d9c7 100644
--- a/app/src/main/java/com/gh/gamecenter/KcSelectGameActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/KcSelectGameActivity.java
@@ -16,6 +16,7 @@ import com.gh.base.AppController;
import com.gh.base.BaseActivity;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.Utils;
+import com.gh.common.view.VerticalItemDecoration;
import com.gh.gamecenter.adapter.KcSelectGameAdapter;
import com.gh.gamecenter.kuaichuan.FileInfo;
@@ -70,6 +71,7 @@ public class KcSelectGameActivity extends BaseActivity {
mAdapter = new KcSelectGameAdapter(this, mSelectSend, installCount, installRl, mSelectPb);
layoutManager = new LinearLayoutManager(this);
mSelectRv.setLayoutManager(layoutManager);
+ mSelectRv.addItemDecoration(new VerticalItemDecoration(this, 8, false));
mSelectRv.setAdapter(mAdapter);
rparams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
diff --git a/app/src/main/java/com/gh/gamecenter/LibaoDetailActivity.java b/app/src/main/java/com/gh/gamecenter/LibaoDetailActivity.java
index ef10e19894..c68fb4ad20 100644
--- a/app/src/main/java/com/gh/gamecenter/LibaoDetailActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/LibaoDetailActivity.java
@@ -6,6 +6,7 @@ import android.view.View;
import com.gh.base.AppController;
import com.gh.base.BaseDetailActivity;
+import com.gh.common.view.VerticalItemDecoration;
import com.gh.gamecenter.adapter.LibaoDetailAdapter;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.entity.LibaoEntity;
@@ -44,9 +45,11 @@ public class LibaoDetailActivity extends BaseDetailActivity {
mAdapter = new LibaoDetailAdapter(this, mLibaoEntity, detail_tv_download);
detail_rv_show.setLayoutManager(new LinearLayoutManager(this));
+ detail_rv_show.addItemDecoration(new VerticalItemDecoration(this, 8, true));
detail_rv_show.setAdapter(mAdapter);
- if (mLibaoEntity.getGame().getId() != null) {
+ if (mLibaoEntity!= null && mLibaoEntity.getGame() != null
+ && mLibaoEntity.getGame().getId() != null) {
title = mLibaoEntity.getName();
getGameDigest();
}
diff --git a/app/src/main/java/com/gh/gamecenter/MainActivity.java b/app/src/main/java/com/gh/gamecenter/MainActivity.java
index 91d7461dd4..35168ea80c 100644
--- a/app/src/main/java/com/gh/gamecenter/MainActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/MainActivity.java
@@ -38,7 +38,6 @@ import com.gh.common.util.GameUtils;
import com.gh.common.util.LibaoUtils;
import com.gh.common.util.PackageUtils;
import com.gh.common.util.PlatformUtils;
-import com.gh.common.util.RandomUtils;
import com.gh.common.util.TokenUtils;
import com.gh.common.util.TrafficUtils;
import com.gh.download.DataWatcher;
@@ -69,6 +68,7 @@ import com.gh.gamecenter.retrofit.JSONObjectResponse;
import com.gh.gamecenter.retrofit.ObservableUtil;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
+import com.gh.gamecenter.zixun.ZiXunFragment;
import org.json.JSONArray;
import org.json.JSONObject;
@@ -99,7 +99,8 @@ import rx.schedulers.Schedulers;
*/
public class MainActivity extends BaseFragmentActivity implements OnClickListener {
- private NewsFragment newsFragment;
+ // private NewsFragment newsFragment;
+ private ZiXunFragment ziXunFragment;
private PersonalFragment personalFragment;
private GameFragment gameFragment;
private ImageView ivGame;
@@ -112,7 +113,7 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
private SharedPreferences sp;
private ConcernManager concernManager;
- private String searchHint;
+ private ArrayList searchHint;
private int currentTab;
@@ -880,20 +881,22 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
RetrofitManager.getApi().getSearchHints()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
- .subscribe(new Response>() {
+ .subscribe(new Response>() {
@Override
- public void onResponse(List response) {
+ public void onResponse(ArrayList response) {
if (response.size() != 0) {
- if (response.size() == 1) {
- searchHint = response.get(0);
- } else {
- searchHint = response.get(RandomUtils.nextInt(response.size()));
- }
+// if (response.size() == 1) {
+// searchHint = response.get(0);
+// } else {
+// searchHint = response.get(RandomUtils.nextInt(response.size()));
+// }
+
+ searchHint = response;
if (gameFragment != null) {
gameFragment.setHint(searchHint);
}
- if (newsFragment != null) {
- newsFragment.setHint(searchHint);
+ if (ziXunFragment != null) {
+ ziXunFragment.setHint(searchHint);
}
}
}
@@ -970,7 +973,7 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
}
if (gameFragment == null) {
gameFragment = new GameFragment();
- if (!TextUtils.isEmpty(searchHint)) {
+ if (searchHint != null && searchHint.size() > 0) {
gameFragment.setHint(searchHint);
}
transaction.add(R.id.main_content, gameFragment);
@@ -983,26 +986,26 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
case 1:
ivNews.setImageResource(R.drawable.ic_news_select);
tvNews.setTextColor(getResources().getColor(R.color.theme));
- if (newsFragment == null) {
+ if (ziXunFragment == null) {
List list = getSupportFragmentManager().getFragments();
if (list != null) {
for (Fragment fragment : list) {
if (fragment.getClass().equals(NewsFragment.class)) {
- newsFragment = (NewsFragment) fragment;
- transaction.show(newsFragment);
+ ziXunFragment = (ZiXunFragment) fragment;
+ transaction.show(ziXunFragment);
break;
}
}
}
- if (newsFragment == null) {
- newsFragment = new NewsFragment();
- if (!TextUtils.isEmpty(searchHint)) {
- newsFragment.setHint(searchHint);
+ if (ziXunFragment == null) {
+ ziXunFragment = new ZiXunFragment();
+ if (searchHint != null && searchHint.size() > 0) {
+ ziXunFragment.setHint(searchHint);
}
- transaction.add(R.id.main_content, newsFragment);
+ transaction.add(R.id.main_content, ziXunFragment);
}
} else {
- transaction.show(newsFragment);
+ transaction.show(ziXunFragment);
}
currentTab = 1;
break;
@@ -1053,8 +1056,8 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
if (gameFragment != null) {
transaction.hide(gameFragment);
}
- if (newsFragment != null) {
- transaction.hide(newsFragment);
+ if (ziXunFragment != null) {
+ transaction.hide(ziXunFragment);
}
List list = getSupportFragmentManager().getFragments();
diff --git a/app/src/main/java/com/gh/gamecenter/MessageDetailActivity.java b/app/src/main/java/com/gh/gamecenter/MessageDetailActivity.java
index 3502b2e2f3..f3eb98ad94 100644
--- a/app/src/main/java/com/gh/gamecenter/MessageDetailActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/MessageDetailActivity.java
@@ -57,7 +57,6 @@ import butterknife.OnClick;
import butterknife.OnTouch;
import retrofit2.adapter.rxjava.HttpException;
import rx.android.schedulers.AndroidSchedulers;
-import rx.functions.Action1;
import rx.schedulers.Schedulers;
/**
@@ -211,8 +210,8 @@ public class MessageDetailActivity extends BaseActivity implements MessageDetail
.subscribe(new com.gh.gamecenter.retrofit.Response>(){
@Override
- public void onNext(List response) {
- super.onNext(response);
+ public void onResponse(List response) {
+ super.onResponse(response);
if (response.size() > 0) {
if (!TextUtils.isEmpty(mConcernEntity.getId())){
commentNum = response.get(0).getNum();
@@ -260,9 +259,9 @@ public class MessageDetailActivity extends BaseActivity implements MessageDetail
.getNewsViews(newsId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
- .subscribe(new Action1>() {
+ .subscribe(new Response>(){
@Override
- public void call(List viewsEntities) {
+ public void onResponse(List viewsEntities) {
if (viewsEntities.size() > 0) {
mConcernEntity.setViews(viewsEntities.get(0).getViews());
adapter.notifyItemChanged(0);
diff --git a/app/src/main/java/com/gh/gamecenter/NewsNormalActivity.java b/app/src/main/java/com/gh/gamecenter/NewsNormalActivity.java
new file mode 100644
index 0000000000..9bc2e55b43
--- /dev/null
+++ b/app/src/main/java/com/gh/gamecenter/NewsNormalActivity.java
@@ -0,0 +1,123 @@
+package com.gh.gamecenter;
+
+import android.os.Bundle;
+import android.support.v4.widget.SwipeRefreshLayout;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.view.View;
+import android.widget.LinearLayout;
+
+import com.gc.materialdesign.views.ProgressBarCircularIndeterminate;
+import com.gh.base.BaseActivity;
+import com.gh.common.view.VerticalItemDecoration;
+import com.gh.gamecenter.adapter.NewsNormalAdapter;
+import com.gh.gamecenter.eventbus.EBNetworkState;
+
+import butterknife.BindView;
+import butterknife.OnClick;
+
+/**
+ * Created by khy on 2017/3/15.
+ *
+ * 原创 + 资讯
+ */
+public class NewsNormalActivity extends BaseActivity implements SwipeRefreshLayout.OnRefreshListener{
+
+ @BindView(R.id.newsnormal_srl)
+ SwipeRefreshLayout mRefreshLayout;
+ @BindView(R.id.newsnormal_rv)
+ RecyclerView mRecyclerView;
+ @BindView(R.id.newsnormal_pb)
+ ProgressBarCircularIndeterminate loadingLayout;
+ @BindView(R.id.reuse_no_connection) LinearLayout mNoConnectionLayout;
+
+ private LinearLayoutManager layoutManager;
+ private NewsNormalAdapter mAdapter;
+
+ private String mNewsType;
+
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ mAdapter = new NewsNormalAdapter(NewsNormalActivity.this, mNewsType);
+ mRecyclerView.setAdapter(mAdapter);
+ }
+ };
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ mNewsType = getIntent().getExtras().getString("newsType");
+
+ View view = View.inflate(this, R.layout.activity_newsnormal, null);
+
+ if ("yuanchuang".equals(mNewsType)) {
+ init(view, "原创");
+ } else {
+ init(view, "资讯");
+ }
+
+ mRefreshLayout.setColorSchemeResources(R.color.theme);
+ mRefreshLayout.setOnRefreshListener(this);
+
+ mRecyclerView.setHasFixedSize(true);
+ layoutManager = new LinearLayoutManager(this);
+ mRecyclerView.setLayoutManager(layoutManager);
+ mAdapter = new NewsNormalAdapter(NewsNormalActivity.this, mNewsType);
+ mRecyclerView.addItemDecoration(new VerticalItemDecoration(this, 8, true));
+ mRecyclerView.setAdapter(mAdapter);
+ mRecyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
+ @Override
+ public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
+ if (newState == RecyclerView.SCROLL_STATE_IDLE
+ && layoutManager.findLastVisibleItemPosition() + 1 == mAdapter.getItemCount()) {
+ if (!mAdapter.isOver() && !mAdapter.isLoading() && !mAdapter.isNetworkError()) {
+ mAdapter.addList(mAdapter.getNewsListSize());
+ }
+ }
+ }
+ });
+
+ }
+
+ @OnClick(R.id.reuse_no_connection)
+ public void reconnection() { // 重新连接
+ mRefreshLayout.setRefreshing(true);
+ mRecyclerView.setVisibility(View.VISIBLE);
+ loadingLayout.setVisibility(View.VISIBLE);
+ mNoConnectionLayout.setVisibility(View.GONE);
+ mRecyclerView.postDelayed(runnable, 1000);
+ }
+
+ @Override
+ public void loadDone() { // 数据加载成功回调
+ mRefreshLayout.setRefreshing(false);
+ loadingLayout.setVisibility(View.GONE);
+ }
+
+ @Override
+ public void loadError() { // 数据加载失败回调
+ mRefreshLayout.setRefreshing(false);
+ loadingLayout.setVisibility(View.GONE);
+ mRecyclerView.setVisibility(View.GONE);
+ mNoConnectionLayout.setVisibility(View.VISIBLE);
+ }
+
+ // 连接上网络事件
+ public void onEventMainThread(EBNetworkState busNetworkState) {
+ if (busNetworkState.isNetworkConnected()) {
+ if (mNoConnectionLayout.getVisibility() == View.VISIBLE) {
+ reconnection();
+ } else if (mAdapter.isNetworkError()) {
+ mAdapter.setNetworkError(false);
+ mAdapter.notifyItemChanged(mAdapter.getItemCount() - 1);
+ mAdapter.addList(mAdapter.getNewsListSize());
+ }
+ }
+ }
+
+ @Override
+ public void onRefresh() {
+ mRecyclerView.postDelayed(runnable, 1000);
+ }
+}
diff --git a/app/src/main/java/com/gh/gamecenter/NewsSearchActivity.java b/app/src/main/java/com/gh/gamecenter/NewsSearchActivity.java
index a9b7ec01e5..1f358fdb3b 100644
--- a/app/src/main/java/com/gh/gamecenter/NewsSearchActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/NewsSearchActivity.java
@@ -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 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 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);
- }
- }
}
}
diff --git a/app/src/main/java/com/gh/gamecenter/SearchActivity.java b/app/src/main/java/com/gh/gamecenter/SearchActivity.java
index c42fe2fcee..0d50135e24 100644
--- a/app/src/main/java/com/gh/gamecenter/SearchActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/SearchActivity.java
@@ -75,7 +75,7 @@ public class SearchActivity extends BaseFragmentActivity {
setTranslucentStatus(true);
SystemBarTintManager tintManager = new SystemBarTintManager(this);
tintManager.setStatusBarTintEnabled(true);
- tintManager.setStatusBarTintResource(R.color.theme);
+ tintManager.setStatusBarTintResource(R.color.back);
SystemBarConfig config = tintManager.getConfig();
contentView.setPadding(0, config.getPixelInsetTop(false), 0,
config.getPixelInsetBottom());
diff --git a/app/src/main/java/com/gh/gamecenter/SplashScreenActivity.java b/app/src/main/java/com/gh/gamecenter/SplashScreenActivity.java
index 4050381265..b425c18f9a 100644
--- a/app/src/main/java/com/gh/gamecenter/SplashScreenActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/SplashScreenActivity.java
@@ -325,11 +325,6 @@ public class SplashScreenActivity extends BaseActivity {
bundle = getIntent().getBundleExtra("data");
}
- if (sp.getBoolean("isNewFirstLaunchV" + PackageUtils.getVersionName(getApplicationContext()), true)) {
- bundle = new Bundle();
- bundle.putString("to", "DownloadManagerActivity");
- }
-
Intent intent = new Intent(SplashScreenActivity.this, MainActivity.class);
intent.putExtra("data", bundle);
startActivity(intent);
diff --git a/app/src/main/java/com/gh/gamecenter/SubjectActivity.java b/app/src/main/java/com/gh/gamecenter/SubjectActivity.java
index 4647ad4247..14a02e08aa 100644
--- a/app/src/main/java/com/gh/gamecenter/SubjectActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/SubjectActivity.java
@@ -1,20 +1,25 @@
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.text.TextUtils;
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.base.BaseActivity;
+import com.gh.common.util.DisplayUtils;
import com.gh.common.util.DownloadItemUtils;
+import com.gh.common.view.VerticalItemDecoration;
import com.gh.download.DataWatcher;
import com.gh.download.DownloadEntity;
import com.gh.download.DownloadManager;
import com.gh.gamecenter.adapter.SubjectAdapter;
+import com.gh.gamecenter.adapter.SubjectTypeAdapter;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.GameEntity;
import com.gh.gamecenter.eventbus.EBDownloadStatus;
@@ -32,9 +37,10 @@ import butterknife.BindView;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
-public class SubjectActivity extends BaseActivity {
+public class SubjectActivity extends BaseActivity implements SubjectTypeAdapter.OnSelectTypeListener {
@BindView(R.id.subject_list) RecyclerView subject_list;
+ @BindView(R.id.subject_type_list) RecyclerView subject_type_list;
@BindView(R.id.subject_pb_loading) ProgressBarCircularIndeterminate subject_pb_loading;
@BindView(R.id.reuse_no_connection) LinearLayout reuse_no_connection;
@@ -89,6 +95,7 @@ public class SubjectActivity extends BaseActivity {
layoutManager = new LinearLayoutManager(this);
+ subject_list.addItemDecoration(new VerticalItemDecoration(this, 8, true));
subject_list.setHasFixedSize(true);
subject_list.setLayoutManager(layoutManager);
adapter = new SubjectAdapter(this);
@@ -106,10 +113,20 @@ public class SubjectActivity extends BaseActivity {
}
});
+ GridLayoutManager layout = new GridLayoutManager(this, 4){
+ @Override
+ public boolean canScrollVertically() {
+ return false;
+ }
+ };
+ subject_type_list.setLayoutManager(layout);
+
if (TextUtils.isEmpty(name) && !TextUtils.isEmpty(id)) {
getSubjectName(id);
}
+
+
}
private void getSubjectName(String id) {
@@ -147,6 +164,18 @@ public class SubjectActivity extends BaseActivity {
}
}
+ @Override
+ public void loadDone(Object obj) {
+ super.loadDone(obj);
+ ArrayList gameType = (ArrayList) obj;
+ gameType.add(0, "全部");
+ ViewGroup.LayoutParams params = subject_type_list.getLayoutParams();
+ params.height = (int) Math.ceil(gameType.size() / 4f) * DisplayUtils.dip2px(this, 37);
+ subject_type_list.setLayoutParams(params);
+ SubjectTypeAdapter adapter = new SubjectTypeAdapter(SubjectActivity.this, gameType);
+ subject_type_list.setAdapter(adapter);
+ }
+
// 下载被删除事件
public void onEventMainThread(EBDownloadStatus status) {
if ("delete".equals(status.getStatus())) {
@@ -221,4 +250,8 @@ public class SubjectActivity extends BaseActivity {
DownloadManager.getInstance(getApplicationContext()).removeObserver(dataWatcher);
}
+ @Override
+ public void onSelectType(String type) {
+
+ }
}
diff --git a/app/src/main/java/com/gh/gamecenter/SuggestionActivity.java b/app/src/main/java/com/gh/gamecenter/SuggestionActivity.java
index 6a36973930..3998031a4b 100644
--- a/app/src/main/java/com/gh/gamecenter/SuggestionActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/SuggestionActivity.java
@@ -12,12 +12,12 @@ import android.view.View.OnClickListener;
import android.view.Window;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
+import android.widget.LinearLayout;
import android.widget.TextView;
import com.gh.base.BaseActivity;
import com.gh.common.util.DialogUtils;
import com.gh.common.util.PackageUtils;
-import com.gh.common.view.CardLinearLayout;
import com.gh.gamecenter.retrofit.JSONObjectResponse;
import com.gh.gamecenter.retrofit.RetrofitManager;
@@ -47,7 +47,7 @@ public class SuggestionActivity extends BaseActivity implements OnClickListener
@BindView(R.id.tv_suggest_connectway) TextView tv_suggest_connectway;
@BindView(R.id.et_suggest_content) EditText et_suggest_content;
@BindView(R.id.et_suggest_connectway) EditText et_suggest_connectway;
- @BindView(R.id.btn_suggest_post) CardLinearLayout btn_suggest_post;
+ @BindView(R.id.btn_suggest_post) LinearLayout btn_suggest_post;
@Override
protected void onCreate(Bundle savedInstanceState) {
diff --git a/app/src/main/java/com/gh/gamecenter/adapter/CleanApkAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/CleanApkAdapter.java
index 4e20022acc..aea79fe6c7 100644
--- a/app/src/main/java/com/gh/gamecenter/adapter/CleanApkAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/adapter/CleanApkAdapter.java
@@ -18,7 +18,6 @@ import android.widget.TextView;
import com.gh.common.util.BitmapUtils;
import com.gh.common.util.PackageUtils;
-import com.gh.common.view.CardLinearLayout;
import com.gh.gamecenter.CleanApkActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.KcSelectGameViewHolder;
@@ -205,19 +204,19 @@ public class CleanApkAdapter extends RecyclerView.Adapter {
+ private Context context;
+ private OnCallBackListener listener;
+ private OnScrollToKaiFuIndex scrollToKaiFuIndex;
+
+ private List subjectList;
+
+ private ArrayMap> locationMap;
+
+ private String kaifuType;
+
+ private int kaifuIndex = 0; // 开服零界点
+ private int initOffset;
+ private int loadCountTop; // 记录加载数量 上
+ private int loadCountBottom;// 记录加载数量 下
+
+ private boolean isRemoveBottom;
+ private boolean isRemoveTop;
+ private boolean isNetworkError;
+ private boolean isLoadedBottom;
+ private boolean isLoadedTop;
+
+ public KaiFuAdapter(KaiFuActivity activity, String kaifuType) {
+
+ this.context = activity;
+ this.listener = activity;
+ this.kaifuType = kaifuType;
+ this.scrollToKaiFuIndex = activity;
+
+ locationMap = new ArrayMap<>();
+
+ subjectList = new ArrayList<>();
+ isLoadedTop = false;
+ isLoadedBottom = false;
+ isNetworkError = false;
+
+ kaifuIndex = 0;
+ loadCountBottom = 0;
+ loadCountTop = 0;
+
+ if ("全部".equals(kaifuType)) {
+ this.kaifuType = "all";
+ }
+
+ initKaiFuOffset();
+ }
+
+ public void initKaiFuOffset() {
+ RetrofitManager.getApi()
+ .getKaiFuOffset(kaifuType)
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(new JSONObjectResponse(){
+ @Override
+ public void onResponse(JSONObject response) {
+ super.onResponse(response);
+ JSONObject jsonObject = response;
+ int offset = 0;
+ try {
+ offset = jsonObject.getInt("offset");
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ initOffset = offset;
+ listener.loadDone(offset);
+ initListBottom(offset);
+ }
+
+ @Override
+ public void onFailure(HttpException e) {
+ super.onFailure(e);
+ listener.loadError();
+ }
+ });
+
+ }
+
+ public void initListBottom(final int offset) {
+
+ isLoadedBottom = false;
+ RetrofitManager.getApi().getKaiFuData(kaifuType, offset, 20)
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(new Response>() {
+ @Override
+ public void onResponse(List response) {
+
+ GameManager manager = new GameManager(context);
+ if (response.size() != 0) {
+
+ if (offset == initOffset) {
+ long curTime = System.currentTimeMillis()/1000;
+ for (int i = 0; i < response.size(); i++) {
+ long time = response.get(i).getServerEntity().getTime();
+ long l = time - curTime;
+ if (l > 0) {
+ kaifuIndex = i + 1;
+ }
+ }
+ }
+
+ for (GameEntity entity : response) {
+ // 黄壮华 初始化游戏状态 修改2015/8/15
+ entity.setEntryMap(DownloadManager.getInstance(context).getEntryMap(entity.getName()));
+ manager.addOrUpdate(entity.getApk(), entity.getId(), entity.getName());
+ }
+
+ subjectList.addAll(response);
+ notifyItemRangeInserted(getItemCount() - 1 - response.size(), response.size());
+
+ if (offset == initOffset) {
+ isLoadedTop = true; //首次加载 手动设置下拉加载完成
+ loadCountTop = response.size();//首次加载 下拉加载减去初始加载值 获取正确偏移量
+
+ subjectList.add(kaifuIndex, new GameEntity()); // 添加一个空的实体当做 零界点ITEM
+ }
+
+ if (response.size() < 20) {
+ isRemoveBottom = true;
+ notifyItemChanged(getItemCount() - 1);
+ }
+
+ loadCountBottom = loadCountBottom + response.size();
+ } else {
+ isRemoveBottom = true;
+ notifyDataSetChanged();
+ }
+
+ initLocationMap();
+
+ if (listener != null) {
+ listener.loadDone();
+ }
+
+ isLoadedBottom = true;
+
+ if (offset == initOffset) { //定位到开服零界点
+ scrollToKaiFuIndex.onScroll(kaifuIndex);
+ }
+ }
+
+ @Override
+ public void onFailure(HttpException e) {
+ if (offset == initOffset){
+ if (listener != null) {
+ listener.loadError();
+ }
+ }else {
+ Toast.makeText(context, "加载失败,请检查网络状态", Toast.LENGTH_SHORT).show();
+
+ isNetworkError = true;
+ notifyDataSetChanged();
+ }
+ }
+ });
+ }
+
+ public void initListTop(final int offset, int limit) {
+
+ isLoadedTop = false;
+ RetrofitManager.getApi().getKaiFuData(kaifuType, offset, limit)
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(new Response>() {
+ @Override
+ public void onResponse(List response) {
+
+ GameManager manager = new GameManager(context);
+ if (response.size() != 0) {
+ for (GameEntity entity : response) {
+ // 黄壮华 初始化游戏状态 修改2015/8/15
+ entity.setEntryMap(DownloadManager.getInstance(context).getEntryMap(entity.getName()));
+ manager.addOrUpdate(entity.getApk(), entity.getId(), entity.getName());
+ }
+
+ subjectList.addAll(0, response);
+ notifyItemRangeInserted(0, response.size());
+
+ if (response.size() < 20 || offset == 0) {
+ isRemoveTop = true;
+ notifyItemChanged(getItemCount() - 1);
+ }
+
+ loadCountTop = loadCountTop + response.size();
+ } else {
+ isRemoveTop = true;
+ notifyDataSetChanged();
+ }
+
+ initLocationMap();
+ isLoadedTop = true;
+ }
+
+ @Override
+ public void onFailure(HttpException e) {
+ if (offset == initOffset){
+ if (listener != null) {
+ listener.loadError();
+ }
+ }else {
+ Toast.makeText(context, "加载失败,请检查网络状态", Toast.LENGTH_SHORT).show();
+
+ isNetworkError = true;
+ notifyDataSetChanged();
+ }
+ }
+ });
+ }
+
+
+ private void initLocationMap() {
+
+ ArrayList list;
+ GameEntity gameEntity;
+ for (int i = 0, size = subjectList.size(); i < size; i++) {
+
+ int index = 0;
+ if (initOffset != 0) {
+ index ++;
+ }
+
+ gameEntity = subjectList.get(i);
+ if (gameEntity.getApk() != null && gameEntity.getApk().size() != 0) {
+ for (ApkEntity apkEntity : gameEntity.getApk()) {
+ list = locationMap.get(apkEntity.getPackageName());
+ if (list == null) {
+ list = new ArrayList<>();
+ locationMap.put(apkEntity.getPackageName(), list);
+ }
+ list.add(i + index);
+ }
+ }
+
+ }
+ }
+
+ @Override
+ public int getItemCount() {
+ if (subjectList.size() < 1) {
+ return 0;
+ }
+ if (initOffset != 0) {
+ return subjectList.size() + 2;
+ }
+ return subjectList.size() + 1;
+ }
+
+ @Override
+ public int getItemViewType(int position) {
+ int index = 0;
+ if (initOffset != 0) {
+ index ++;
+ }
+
+ if (position == getItemCount() - 1 || (position == 0 && initOffset != 0)) {
+ return ItemViewType.LOADING;
+ }
+ if (TextUtils.isEmpty(subjectList.get(position- index).getId())) {
+ return 100;
+ } else {
+ return ItemViewType.GAME_TEST;
+ }
+ }
+
+ @Override
+ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
+ if (viewType == ItemViewType.LOADING){
+ View view = LayoutInflater.from(viewGroup.getContext()).inflate(
+ R.layout.refresh_footerview, viewGroup, false);
+ return new FooterViewHolder(view);
+ } else if (viewType == ItemViewType.GAME_TEST) {
+ View view = LayoutInflater.from(viewGroup.getContext()).inflate(
+ R.layout.game_test_item, viewGroup, false);
+ return new GameTestViewHolder(view);
+ } else if (viewType == ItemViewType.GAME_NORMAL) {
+ View view = LayoutInflater.from(viewGroup.getContext()).inflate(
+ R.layout.game_normal_item, viewGroup, false);
+ return new GameNormalViewHolder(view);
+ } else if (viewType == 100) {
+ TextView textView = new TextView(context);
+ textView.setText("↓当前开服 · 即将开服↑");
+ textView.setTextColor(context.getResources().getColor(R.color.hint));
+ textView.setTextSize(13);
+ textView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT
+ , DisplayUtils.dip2px(context, 42)));
+ textView.setGravity(Gravity.CENTER);
+ return new KaiFuIndexViewHolder(textView);
+ }
+ return null;
+ }
+
+ @Override
+ public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
+ int index = 0;
+ if (initOffset != 0) {
+ index ++;
+ }
+
+ if (viewHolder instanceof GameTestViewHolder) {
+ initGameTestViewHolder((GameTestViewHolder) viewHolder, position - index);
+ } else if (viewHolder instanceof FooterViewHolder) {
+ initFooterViewHolder((FooterViewHolder) viewHolder, position);
+ }
+ }
+
+ private void initFooterViewHolder(FooterViewHolder viewHolder, final int position) {
+ if (isNetworkError) {
+ viewHolder.loading.setVisibility(View.GONE);
+ viewHolder.hint.setText("加载失败,点击重试");
+ viewHolder.itemView.setClickable(true);
+ viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ isNetworkError = false;
+ notifyDataSetChanged();
+ if (position == getItemCount() - 1) {
+ initListBottom(kaifuIndex + loadCountBottom);
+ } else {
+ int offset = kaifuIndex - loadCountTop;
+ int limit = 20;
+ if (offset < 0) {
+ limit = limit + offset;
+ offset = 0;
+ }
+ initListTop(offset, limit);
+ }
+ }
+ });
+ } else if ((isRemoveBottom && position == getItemCount() - 1)
+ || (isRemoveTop && position == 0)) {
+ viewHolder.loading.setVisibility(View.GONE);
+ viewHolder.hint.setText("加载完毕");
+ viewHolder.itemView.setClickable(false);
+ viewHolder.lineLeft.setVisibility(View.VISIBLE);
+ viewHolder.lineRight.setVisibility(View.VISIBLE);
+ } else {
+ viewHolder.loading.setVisibility(View.VISIBLE);
+ viewHolder.hint.setText("加载中...");
+ viewHolder.itemView.setClickable(false);
+ }
+ }
+
+ private void initGameTestViewHolder(final GameTestViewHolder holder, int position) {
+
+ holder.gameOrder.setVisibility(View.GONE);
+
+ final GameEntity gameEntity = subjectList.get(position);
+
+ ImageUtils.display(holder.gameThumb, gameEntity.getIcon());
+ holder.gameName.setText(gameEntity.getName());
+ if (gameEntity.getApk() == null || gameEntity.getApk().isEmpty()) {
+ holder.gameDes.setText(gameEntity.getBrief());
+ } else {
+ holder.gameDes.setText(String.format("%s %s", gameEntity.getApk().get(0).getSize(), gameEntity.getBrief()));
+ }
+
+ KaiFuUtils.setKaiFuTime( holder.gameTestType, gameEntity.getServerEntity().getTime());
+ String type = gameEntity.getServerEntity().getType();
+ if ("不删档内测".equals(type) || "删档内测".equals(type)) {
+ KaiFuUtils.setKaiFuType(holder.gameTestTime, gameEntity.getServerEntity().getType());
+ } else if ("公测".equals(type)){
+ String note = gameEntity.getServerEntity().getNote();
+ if (TextUtils.isEmpty(note)) {
+ KaiFuUtils.setKaiFuType(holder.gameTestTime, gameEntity.getServerEntity().getType());
+ } else {
+ KaiFuUtils.setKaiFuType(holder.gameTestTime, gameEntity.getServerEntity().getType() + ":" + note);
+ }
+ } else {
+ KaiFuUtils.setKaiFuType(holder.gameTestTime, gameEntity.getServerEntity().getNote());
+ }
+
+ holder.itemView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Map kv = new HashMap<>();
+ kv.put("名字", gameEntity.getName());
+ kv.put("位置", String.valueOf(holder.getPosition() + 1));
+ DataUtils.onEvent(context, "点击", "开服表", kv);
+
+ DataCollectionUtils.uploadClick(context, "列表", "开服表", gameEntity.getName());
+
+ GameUtils.startGameDetailActivity(context, gameEntity, "主页-游戏" + "+(" + "开服表" + "[" + (holder.getPosition()) + "])");
+ }
+ });
+
+ DownloadItemUtils.setOnClickListener(context,
+ holder.gameDownloadBtn, gameEntity, position,
+ KaiFuAdapter.this, "主页游戏" + "+(" + "开服表" + "[" + (holder.getPosition()) + "])", "开服表 :" + gameEntity.getName(), false);
+
+ DownloadItemUtils.updateItem(context, gameEntity, holder, true);
+ }
+
+ public List getSubjectList() {
+ return subjectList;
+ }
+
+ public ArrayMap> getLocationMap() {
+ return locationMap;
+ }
+
+ public boolean isLoadedBottom(){
+ return isLoadedBottom;
+ }
+
+ public boolean isLoadedTop(){
+ return isLoadedTop;
+ }
+
+ public int loadCountTop() {
+ return loadCountTop;
+ }
+
+ public int loadCountBottom() {
+ return loadCountBottom;
+ }
+
+ public class KaiFuIndexViewHolder extends RecyclerView.ViewHolder {
+
+ public KaiFuIndexViewHolder(View itemView) {
+ super(itemView);
+ }
+ }
+
+ public interface OnScrollToKaiFuIndex {
+ void onScroll(int scrollPosition);
+ }
+}
diff --git a/app/src/main/java/com/gh/gamecenter/adapter/KaiFuDialogAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/KaiFuDialogAdapter.java
new file mode 100644
index 0000000000..2374f19e6d
--- /dev/null
+++ b/app/src/main/java/com/gh/gamecenter/adapter/KaiFuDialogAdapter.java
@@ -0,0 +1,130 @@
+package com.gh.gamecenter.adapter;
+
+import android.content.Context;
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
+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.LinearLayout;
+import android.widget.TextView;
+
+import com.gh.common.util.DisplayUtils;
+import com.gh.gamecenter.KaiFuActivity;
+import com.gh.gamecenter.R;
+import com.gh.gamecenter.adapter.viewholder.StrategyDialogViewHolder;
+import com.gh.gamecenter.db.info.ConcernInfo;
+import com.gh.gamecenter.manager.ConcernManager;
+
+import java.util.List;
+
+/**
+ * Created by khy on 2016/12/5.
+ */
+public class KaiFuDialogAdapter extends RecyclerView.Adapter {
+
+ private Context mContext;
+
+ private OnKaiFuDialogCallBackListener callBackListener;
+
+ private List mConcernGame;
+
+ private int mSelectPosition;
+
+ private String[] arrKaiFuTag = {"全部", "删档内测", "不删档内测" , "公测", "新服"};
+
+ public KaiFuDialogAdapter(KaiFuActivity kaiFuActivity, int selectPosition) {
+ this.mContext = kaiFuActivity;
+ this.mSelectPosition = selectPosition;
+ this.callBackListener = kaiFuActivity;
+
+ ConcernManager concernManager = new ConcernManager(kaiFuActivity);
+ List concernGame = concernManager.getConcernGame();
+ for (int i = 0; i < concernGame.size(); i++) {
+ if ("5618b86e8ab49e17088b4575".equals(concernGame.get(i).getId())) {
+ concernGame.remove(i);
+ }
+ }
+ mConcernGame = concernGame;
+ }
+
+ @Override
+ public int getItemViewType(int position) {
+ if (!mConcernGame.isEmpty() && position == 5) {
+ return 0;
+ }
+ return 1;
+ }
+
+ @Override
+ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ if (viewType == 0) {
+ TextView textView = new TextView(mContext);
+ textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT
+ , DisplayUtils.dip2px(mContext, 25)));
+ textView.setText("以下是已关注的游戏");
+ textView.setBackgroundColor(Color.parseColor("#ededed"));
+ textView.setGravity(Gravity.CENTER);
+ return new TitleViewHolder(textView);
+ } else {
+ View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_strategy_item, parent, false);
+ return new StrategyDialogViewHolder(view);
+ }
+ }
+
+ @Override
+ public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
+ if (holder instanceof StrategyDialogViewHolder) {
+ StrategyDialogViewHolder viewHolder = ((StrategyDialogViewHolder) holder);
+
+ if (position <= 5) {
+ viewHolder.gameName.setText(arrKaiFuTag[position]);
+ } else {
+ viewHolder.gameName.setText(mConcernGame.get(position - 6).getGameName());
+ }
+
+ if (position == mSelectPosition) {
+ viewHolder.selectIcon.setImageResource(R.drawable.strategy_game_select);
+ } else {
+ viewHolder.selectIcon.setImageDrawable(new ColorDrawable(0));
+ }
+
+ viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ String tag;
+ String gameName = null;
+ if (position <= 5) {
+ tag = arrKaiFuTag[position];
+ } else {
+ tag = mConcernGame.get(position - 6).getId();
+ gameName = mConcernGame.get(position - 6).getGameName();
+ }
+
+ callBackListener.selectPosition(position, tag, gameName);
+ }
+ });
+ }
+ }
+
+ @Override
+ public int getItemCount() {
+ if (mConcernGame.isEmpty()) {
+ return 5;
+ }
+ return mConcernGame.size() + 6;
+ }
+
+ public class TitleViewHolder extends RecyclerView.ViewHolder {
+
+ public TitleViewHolder(View itemView) {
+ super(itemView);
+ }
+ }
+
+ public interface OnKaiFuDialogCallBackListener{
+ void selectPosition(int position, String tag, String gameName);
+ }
+}
diff --git a/app/src/main/java/com/gh/gamecenter/adapter/KcSelectGameAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/KcSelectGameAdapter.java
index 44413b93d4..1256208fdb 100644
--- a/app/src/main/java/com/gh/gamecenter/adapter/KcSelectGameAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/adapter/KcSelectGameAdapter.java
@@ -24,7 +24,6 @@ import com.gh.common.constant.ItemViewType;
import com.gh.common.util.BitmapUtils;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.Utils;
-import com.gh.common.view.CardLinearLayout;
import com.gh.gamecenter.KcSelectGameActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
@@ -271,23 +270,23 @@ public class KcSelectGameAdapter extends RecyclerView.Adapter position - mHotCommentList.size() - index) {
commentPosition = position - mHotCommentList.size() - index;
commentEntity = mNormalCommentList.get(position - mHotCommentList.size() - index);
isHotComment = false;
- if ( mNormalCommentList.size() == position - mHotCommentList.size() - index + 1) {
- ((CardLinearLayout) holder.itemView).setmBottom(DisplayUtils.dip2px(mContext, 4));
- } else {
- ((CardLinearLayout) holder.itemView).setmBottom(0);
- }
+// if ( mNormalCommentList.size() == position - mHotCommentList.size() - index + 1) {
+// ((CardLinearLayout) holder.itemView).setmBottom(DisplayUtils.dip2px(mContext, 4));
+// } else {
+// ((CardLinearLayout) holder.itemView).setmBottom(0);
+// }
}
if (commentEntity == null) {
diff --git a/app/src/main/java/com/gh/gamecenter/adapter/NewsNormalAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/NewsNormalAdapter.java
new file mode 100644
index 0000000000..e582b8f04f
--- /dev/null
+++ b/app/src/main/java/com/gh/gamecenter/adapter/NewsNormalAdapter.java
@@ -0,0 +1,445 @@
+package com.gh.gamecenter.adapter;
+
+import android.content.Context;
+import android.support.v7.widget.RecyclerView;
+import android.util.DisplayMetrics;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.LinearLayout;
+import android.widget.Toast;
+
+import com.gh.common.constant.ItemViewType;
+import com.gh.common.util.DataCollectionUtils;
+import com.gh.common.util.DataUtils;
+import com.gh.common.util.DisplayUtils;
+import com.gh.common.util.ImageUtils;
+import com.gh.common.util.NewsUtils;
+import com.gh.gamecenter.NewsNormalActivity;
+import com.gh.gamecenter.R;
+import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
+import com.gh.gamecenter.adapter.viewholder.NewsImage1ViewHolder;
+import com.gh.gamecenter.adapter.viewholder.NewsImage2ViewHolder;
+import com.gh.gamecenter.adapter.viewholder.NewsImage3ViewHolder;
+import com.gh.gamecenter.entity.NewsEntity;
+import com.gh.gamecenter.entity.ViewsEntity;
+import com.gh.gamecenter.listener.OnCallBackListener;
+import com.gh.gamecenter.manager.VisitManager;
+import com.gh.gamecenter.retrofit.JSONObjectResponse;
+import com.gh.gamecenter.retrofit.ObservableUtil;
+import com.gh.gamecenter.retrofit.Response;
+import com.gh.gamecenter.retrofit.RetrofitManager;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import retrofit2.adapter.rxjava.HttpException;
+import rx.Observable;
+import rx.Subscriber;
+import rx.android.schedulers.AndroidSchedulers;
+import rx.functions.Action1;
+import rx.functions.Func1;
+import rx.schedulers.Schedulers;
+
+/**
+ * Created by khy on 2017/3/15.
+ */
+public class NewsNormalAdapter extends RecyclerView.Adapter {
+
+ private NewsNormalActivity activity;
+ private Context context;
+ private OnCallBackListener listener;
+
+ private List newsList;
+
+ private String mNewsType;
+
+ private int itemCount;
+ private int cardMargin;
+
+ private boolean isLoading;
+ private boolean isOver;
+ private boolean isNetworkError;
+
+ public NewsNormalAdapter(NewsNormalActivity activity, String newsType) {
+
+ this.activity = activity;
+ this.context = activity;
+ this.listener = activity;
+ this.mNewsType = newsType;
+
+ newsList = new ArrayList<>();
+
+ itemCount = 0;
+
+ isLoading = false;
+ isOver = false;
+ isNetworkError = false;
+
+ cardMargin = (int)context.getResources().getDimension(R.dimen.cardview_margin);
+
+ addList(0);
+ }
+
+ // 加载数据
+ public void addList(final int offset) {
+ if (isLoading) {
+ return;
+ }
+ isLoading = true;
+ Observable> observable;
+
+ if ("yuanchuang".equals(mNewsType)) {
+ observable = RetrofitManager.getApi().getYuanChuang(offset);
+ } else {
+ observable = RetrofitManager.getApi().getZiXun(offset);
+ }
+
+ observable.map(new Func1, List>() {
+ @Override
+ public List call(List list) {
+ // 去掉重复数据
+ return NewsUtils.removeDuplicateData(newsList, list);
+ }
+ })
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(new Response>(){
+ @Override
+ public void onResponse(List response) {
+ isLoading = false;
+
+ if (response.size() != 0) {
+ newsList.addAll(response);
+ itemCount += response.size();
+ notifyItemRangeInserted(newsList.size() - response.size(), response.size());
+ } else {
+ isOver = true;
+ notifyItemChanged(getItemCount() - 1);
+ }
+
+ if (offset == 0 && listener != null) {
+ listener.loadDone();
+ }
+
+ // 获取新闻阅读量
+ getNewsViews(response, offset);
+ }
+
+ @Override
+ public void onFailure(HttpException e) {
+ isLoading = false;
+ // 网络错误
+ if (offset == 0) {
+ if (listener != null) {
+ listener.loadError();
+ }
+ } else {
+ Toast.makeText(context, "加载失败,请检查网络状态", Toast.LENGTH_SHORT).show();
+ isNetworkError = true;
+ notifyItemChanged(getItemCount() - 1);
+ }
+ }
+ });
+ }
+
+ // 获取新闻阅读量
+ private void getNewsViews(final List list, final int start) {
+ if (list == null || list.isEmpty()) {
+ return;
+ }
+ ObservableUtil.computation(new Observable.OnSubscribe() {
+ @Override
+ public void call(Subscriber super String> subscriber) {
+ StringBuilder builder = new StringBuilder();
+ for (int i = 0, size = list.size(); i < size; i++) {
+ builder.append(list.get(i).getId());
+ builder.append("-");
+ }
+ builder.deleteCharAt(builder.length() - 1);
+ String ids = builder.toString();
+ VisitManager.getInstance().addUrl(ids);
+ subscriber.onNext(ids);
+ subscriber.onCompleted();
+ }
+ }, new Action1() {
+ @Override
+ public void call(String ids) {
+ RetrofitManager.getData()
+ .getNewsViews(ids)
+ .map(new Func1, String>() {
+ @Override
+ public String call(List list) {
+ for (ViewsEntity viewsEntity : list) {
+ for (NewsEntity newsEntity : newsList) {
+ if (viewsEntity.getId().equals(newsEntity.getId())) {
+ newsEntity.setViews(viewsEntity.getViews());
+ break;
+ }
+ }
+ }
+ return null;
+ }
+ })
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(new Response() {
+ @Override
+ public void onResponse(String response) {
+ notifyItemRangeChanged(start, list.size());
+ }
+ });
+ }
+ });
+ }
+
+ @Override
+ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ if (viewType == ItemViewType.NEWS_IMAGE1) {
+ View view = LayoutInflater.from(parent.getContext()).inflate(
+ R.layout.news_image1_item, parent, false);
+ return new NewsImage1ViewHolder(view);
+ } else if (viewType == ItemViewType.NEWS_IMAGE2) {
+ View view = LayoutInflater.from(parent.getContext()).inflate(
+ R.layout.news_image2_item, parent, false);
+ return new NewsImage2ViewHolder(view);
+ } else if (viewType == ItemViewType.NEWS_IMAGE3) {
+ View view = LayoutInflater.from(parent.getContext()).inflate(
+ R.layout.news_image3_item, parent, false);
+ return new NewsImage3ViewHolder(view);
+ } else if (viewType == ItemViewType.LOADING) {
+ View view = LayoutInflater.from(parent.getContext()).inflate(
+ R.layout.refresh_footerview, parent, false);
+ return new FooterViewHolder(view);
+ }
+ return null;
+ }
+
+ @Override
+ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
+ if (holder instanceof NewsImage1ViewHolder) {
+ initNewsImage1ViewHolder((NewsImage1ViewHolder) holder, position);
+ } else if (holder instanceof NewsImage2ViewHolder) {
+ initNewsImage2ViewHolder((NewsImage2ViewHolder) holder, position);
+ } else if (holder instanceof NewsImage3ViewHolder) {
+ initNewsImage3ViewHolder((NewsImage3ViewHolder) holder, position);
+ } else if (holder instanceof FooterViewHolder) {
+ initFooterViewHolder((FooterViewHolder) holder);
+ }
+ }
+
+ private void initNewsImage1ViewHolder(final NewsImage1ViewHolder viewHolder, int position) {
+
+ final NewsEntity newsEntity = newsList.get(position);
+
+ viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Map kv = new HashMap<>();
+ kv.put("名字", newsEntity.getTitle());
+ kv.put("位置", String.valueOf(viewHolder.getPosition() + 1));
+ DataUtils.onEvent(context, "点击", "资讯-资讯", kv);
+
+ DataCollectionUtils.uploadClick(context, "列表", "资讯-资讯", newsEntity.getTitle());
+
+ //统计阅读量
+ statNewsViews(newsEntity, viewHolder.getPosition());
+ NewsUtils.startNewsDetailActivity(context, newsEntity, "(资讯-资讯)");
+ }
+ });
+// viewHolder.thumb.setImageURI(newsEntity.getThumbnail().getUrl().get(0));
+ ImageUtils.display(viewHolder.thumb, newsEntity.getThumbnail().getUrl().get(0));
+ viewHolder.title.setText(newsEntity.getTitle());
+ int views = newsEntity.getViews();
+ if (views == 0) {
+ viewHolder.read.setVisibility(View.GONE);
+ } else {
+ viewHolder.read.setVisibility(View.VISIBLE);
+ viewHolder.read.setText(String.format(Locale.getDefault(), "阅读 %d", views));
+ }
+ NewsUtils.setNewsType(viewHolder.type, newsEntity.getType());
+ }
+
+ private void initNewsImage2ViewHolder(final NewsImage2ViewHolder viewHolder, int position) {
+
+ final NewsEntity newsEntity = newsList.get(position);
+
+ DisplayMetrics outMetrics = new DisplayMetrics();
+ activity.getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
+ int width = (outMetrics.widthPixels - DisplayUtils.dip2px(context, 56)) / 3;
+ int height = (int) (width * 3 / 4f);
+
+ LinearLayout.LayoutParams lparams1 = new LinearLayout.LayoutParams(width, height);
+ viewHolder.thumb1.setLayoutParams(lparams1);
+
+ LinearLayout.LayoutParams lparams2 = new LinearLayout.LayoutParams(width, height);
+ lparams2.leftMargin = DisplayUtils.dip2px(context, 8);
+ viewHolder.thumb2.setLayoutParams(lparams2);
+
+ LinearLayout.LayoutParams lparams3 = new LinearLayout.LayoutParams(width, height);
+ lparams3.leftMargin = DisplayUtils.dip2px(context, 8);
+ viewHolder.thumb3.setLayoutParams(lparams3);
+
+ viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Map kv = new HashMap<>();
+ kv.put("名字", newsEntity.getTitle());
+ kv.put("位置", String.valueOf(viewHolder.getPosition() + 1));
+ DataUtils.onEvent(context, "点击", "资讯-资讯", kv);
+
+ DataCollectionUtils.uploadClick(context, "列表", "资讯-资讯", newsEntity.getTitle());
+
+ //统计阅读量
+ statNewsViews(newsEntity, viewHolder.getPosition());
+ NewsUtils.startNewsDetailActivity(context, newsEntity, "(资讯-资讯)");
+ }
+ });
+ viewHolder.title.setText(newsEntity.getTitle());
+// viewHolder.thumb1.setImageURI(newsEntity.getThumbnail().getUrl().get(0));
+// viewHolder.thumb2.setImageURI(newsEntity.getThumbnail().getUrl().get(1));
+// viewHolder.thumb3.setImageURI(newsEntity.getThumbnail().getUrl().get(2));
+ ImageUtils.display(viewHolder.thumb1, newsEntity.getThumbnail().getUrl().get(0));
+ ImageUtils.display(viewHolder.thumb2, newsEntity.getThumbnail().getUrl().get(1));
+ ImageUtils.display(viewHolder.thumb3, newsEntity.getThumbnail().getUrl().get(2));
+ int views = newsEntity.getViews();
+ if (views == 0) {
+ viewHolder.read.setVisibility(View.GONE);
+ } else {
+ viewHolder.read.setVisibility(View.VISIBLE);
+ viewHolder.read.setText(String.format(Locale.getDefault(), "阅读 %d", views));
+ }
+ NewsUtils.setNewsType(viewHolder.type, newsEntity.getType());
+ }
+
+ private void initNewsImage3ViewHolder(final NewsImage3ViewHolder viewHolder, int position) {
+
+ final NewsEntity newsEntity = newsList.get(position);
+
+ viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Map kv = new HashMap<>();
+ kv.put("名字", newsEntity.getTitle());
+ kv.put("位置", String.valueOf(viewHolder.getPosition() + 1));
+ DataUtils.onEvent(context, "点击", "资讯-资讯", kv);
+
+ DataCollectionUtils.uploadClick(context, "列表", "资讯-资讯", newsEntity.getTitle());
+
+ //统计阅读量
+ statNewsViews(newsEntity, viewHolder.getPosition());
+ NewsUtils.startNewsDetailActivity(context, newsEntity, "(资讯-资讯)");
+ }
+ });
+ viewHolder.title.setText(newsEntity.getTitle());
+ ImageUtils.getInstance().display(viewHolder.thumb, newsEntity.getThumbnail().getUrl().get(0),
+ context.getResources().getDisplayMetrics().widthPixels - DisplayUtils.dip2px(context, 40));
+ int views = newsEntity.getViews();
+ if (views == 0) {
+ viewHolder.read.setVisibility(View.GONE);
+ } else {
+ viewHolder.read.setVisibility(View.VISIBLE);
+ viewHolder.read.setText(String.format(Locale.getDefault(), "阅读 %d", views));
+ }
+ NewsUtils.setNewsType(viewHolder.type, newsEntity.getType());
+ }
+
+ private void initFooterViewHolder(FooterViewHolder viewHolder) {
+ if (isNetworkError) {
+ viewHolder.loading.setVisibility(View.GONE);
+ viewHolder.hint.setText("加载失败,点击重试");
+ viewHolder.itemView.setClickable(true);
+ viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ isNetworkError = false;
+ notifyItemChanged(getItemCount() - 1);
+ addList(newsList.size());
+ }
+ });
+ } else if (isOver) {
+ viewHolder.loading.setVisibility(View.GONE);
+ viewHolder.hint.setText("加载完毕");
+ viewHolder.itemView.setClickable(false);
+ } else {
+ viewHolder.loading.setVisibility(View.VISIBLE);
+ viewHolder.hint.setText("加载中...");
+ viewHolder.itemView.setClickable(false);
+ }
+ }
+
+ @Override
+ public int getItemCount() {
+ if (itemCount == 0) {
+ return 0;
+ }
+ return itemCount + 1;
+ }
+
+ @Override
+ public int getItemViewType(int position) {
+ if (position == newsList.size()) {
+ return ItemViewType.LOADING;
+ }
+ NewsEntity newsEntity = newsList.get(position);
+ if ("4x3".equals(newsEntity.getThumbnail().getType()) && newsEntity.getThumbnail().getUrl().size() == 3){
+ return ItemViewType.NEWS_IMAGE2;
+ }
+ if ("3x1".equals(newsEntity.getThumbnail().getType())) {
+ return ItemViewType.NEWS_IMAGE3;
+ }
+ return ItemViewType.NEWS_IMAGE1;
+ }
+
+ // 统计新闻阅读量
+ private void statNewsViews(final NewsEntity newsEntity, final int position) {
+ RetrofitManager.getData().postNewsViews(newsEntity.getId())
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(new JSONObjectResponse(){
+ @Override
+ public void onResponse(JSONObject response) {
+ if (response.length() != 0) {
+ try {
+ if ("success".equals(response.getString("status"))) {
+ newsEntity.setViews(newsEntity.getViews() + 1);
+
+ notifyItemChanged(position);
+
+ // 更新okhttp缓存数据
+ VisitManager.updateOkhttpCache(newsEntity.getId());
+ }
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ });
+ }
+
+ public boolean isOver() {
+ return isOver;
+ }
+
+ public boolean isLoading() {
+ return isLoading;
+ }
+
+ public boolean isNetworkError() {
+ return isNetworkError;
+ }
+
+ public void setNetworkError(boolean networkError) {
+ isNetworkError = networkError;
+ }
+
+ public int getNewsListSize() {
+ return newsList.size();
+ }
+}
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 e3273d4543..806b7171ee 100644
--- a/app/src/main/java/com/gh/gamecenter/adapter/PluginAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/adapter/PluginAdapter.java
@@ -9,13 +9,11 @@ import android.view.ViewGroup;
import com.gh.common.util.DataCollectionUtils;
import com.gh.common.util.DataUtils;
-import com.gh.common.util.DisplayUtils;
import com.gh.common.util.DownloadItemUtils;
import com.gh.common.util.GameUtils;
import com.gh.common.util.GameViewUtils;
import com.gh.common.util.ImageUtils;
import com.gh.common.util.PlatformUtils;
-import com.gh.common.view.CardLinearLayout;
import com.gh.download.DownloadManager;
import com.gh.gamecenter.PluginActivity;
import com.gh.gamecenter.R;
@@ -139,19 +137,6 @@ public class PluginAdapter extends RecyclerView.Adapter
if (holder instanceof GameNormalViewHolder) {
final GameNormalViewHolder viewHolder = (GameNormalViewHolder) holder;
- // 第一个
- if (position == 0) {
- ((CardLinearLayout) viewHolder.itemView).setmTop(DisplayUtils.dip2px(context, 8));
- } else {
- ((CardLinearLayout) viewHolder.itemView).setmTop(0);
- }
-
- // 最后一个
- if (position == pluginList.size() - 1) {
- ((CardLinearLayout) viewHolder.itemView).setBottom(true);
- } else {
- ((CardLinearLayout) viewHolder.itemView).setBottom(false);
- }
final GameEntity gameEntity = pluginList.get(position);
diff --git a/app/src/main/java/com/gh/gamecenter/adapter/StrategyAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/StrategyAdapter.java
index 8b19be6055..30eefa76c0 100644
--- a/app/src/main/java/com/gh/gamecenter/adapter/StrategyAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/adapter/StrategyAdapter.java
@@ -7,9 +7,7 @@ import android.view.ViewGroup;
import android.widget.LinearLayout;
import com.gh.common.util.DataUtils;
-import com.gh.common.util.DisplayUtils;
import com.gh.common.util.NewsUtils;
-import com.gh.common.view.CardLinearLayout;
import com.gh.gamecenter.R;
import com.gh.gamecenter.StrategyActivity;
import com.gh.gamecenter.adapter.viewholder.NewsFooterViewHolder;
@@ -149,27 +147,6 @@ public class StrategyAdapter extends RecyclerView.Adapter();
isLoaded = false;
isNetworkError = false;
+ isRemove = false;
initList(1);
}
public void initList(final int page) {
-// if (isLoaded) { //TODO 无法分页
-// return;
-// }
+
isLoaded = false;
RetrofitManager.getApi().getColumn(id, page)
.map(new Func1, List>() {
@@ -111,10 +109,21 @@ public class SubjectAdapter extends RecyclerView.Adapter {
+
+ private Context mContext;
+ private OnSelectTypeListener listener;
+ private ArrayList mGameType;
+ private String mCurType;
+
+
+ public SubjectTypeAdapter(SubjectActivity subjectActivity, ArrayList gameType) {
+ this.mContext = subjectActivity;
+ this.listener = subjectActivity;
+
+ mGameType = gameType;
+ mCurType = "全部";
+ }
+
+ public StateListDrawable selectorBg(){
+
+ StateListDrawable bg_install = new StateListDrawable();
+
+ bg_install.addState(new int[] { android.R.attr.state_pressed, android.R.attr.state_enabled },
+ new ColorDrawable(Color.parseColor("#59d3ff")));
+ bg_install.addState(new int[] { android.R.attr.state_selected, android.R.attr.state_enabled },
+ new ColorDrawable(Color.parseColor("#00B7FA")));
+ bg_install.addState(new int[] {}, new ColorDrawable(Color.WHITE));
+
+ return bg_install;
+ }
+
+ @Override
+ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ RelativeLayout relativeLayout = new RelativeLayout(mContext);
+ relativeLayout.setBackgroundColor(Color.parseColor("#ededed"));
+ TextView textView = new TextView(mContext);
+ textView.setTextSize(13);
+ textView.setBackgroundDrawable(selectorBg());
+ textView.setTextColor(mContext.getResources().getColor(R.color.title));
+ textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT
+ , DisplayUtils.dip2px(mContext, 36)));
+ textView.setGravity(Gravity.CENTER);
+// textView.setBackgroundColor(Color.WHITE);
+ relativeLayout.addView(textView);
+ RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) textView.getLayoutParams();
+ int dp = DisplayUtils.dip2px(mContext, 1);
+ int dp2 = DisplayUtils.dip2px(mContext, 0.5f);
+ layoutParams.setMargins(dp2, dp, dp2, 0);
+ return new GameTypeViewHolder(relativeLayout);
+ }
+
+ @Override
+ public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {
+ if (holder instanceof GameTypeViewHolder) {
+ final GameTypeViewHolder viewHolder = (GameTypeViewHolder) holder;
+ viewHolder.type.setText(mGameType.get(position));
+
+ if (!TextUtils.isEmpty(mCurType) && mCurType.equals(mGameType.get(position))) {
+ viewHolder.type.setSelected(true);
+ viewHolder.type.setTextColor(Color.WHITE);
+
+ } else {
+ viewHolder.type.setSelected(false);
+ viewHolder.type.setTextColor(mContext.getResources().getColor(R.color.title));
+ }
+
+ ((GameTypeViewHolder) holder).type.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Utils.toast(mContext, mGameType.get(position));
+ viewHolder.type.setSelected(true);
+ listener.onSelectType(mGameType.get(position));
+ mCurType = mGameType.get(position);
+ notifyItemRangeChanged(0, getItemCount());
+ }
+ });
+ }
+ }
+
+ @Override
+ public int getItemCount() {
+ return mGameType.size();
+ }
+
+ public class GameTypeViewHolder extends RecyclerView.ViewHolder {
+ private TextView type;
+
+ public GameTypeViewHolder(View itemView) {
+ super(itemView);
+ type = (TextView) ((RelativeLayout)itemView).getChildAt(0);
+ }
+ }
+
+ public interface OnSelectTypeListener {
+ void onSelectType(String type);
+ }
+}
diff --git a/app/src/main/java/com/gh/gamecenter/adapter/viewholder/GameDownloadViewHolder.java b/app/src/main/java/com/gh/gamecenter/adapter/viewholder/GameDownloadViewHolder.java
index 7631396664..95824b8b31 100644
--- a/app/src/main/java/com/gh/gamecenter/adapter/viewholder/GameDownloadViewHolder.java
+++ b/app/src/main/java/com/gh/gamecenter/adapter/viewholder/GameDownloadViewHolder.java
@@ -21,6 +21,7 @@ public class GameDownloadViewHolder extends RecyclerView.ViewHolder {
public TextView dm_item_tv_speed;
public ProgressBar dm_item_progressbar;
public TextView dm_item_tv_startorpause;
+ public View dm_item_line;
public GameDownloadViewHolder(View itemView) {
super(itemView);
@@ -32,6 +33,7 @@ public class GameDownloadViewHolder extends RecyclerView.ViewHolder {
dm_item_tv_speed = (TextView) itemView.findViewById(R.id.dm_item_tv_speed);
dm_item_progressbar = (ProgressBar) itemView.findViewById(R.id.dm_item_progressbar);
dm_item_tv_startorpause = (TextView) itemView.findViewById(R.id.dm_item_tv_startorpause);
+ dm_item_line = itemView.findViewById(R.id.dm_item_line);
}
diff --git a/app/src/main/java/com/gh/gamecenter/adapter/viewholder/GameHeadViewHolder.java b/app/src/main/java/com/gh/gamecenter/adapter/viewholder/GameHeadViewHolder.java
index 4a0c915ac7..62fd5d44b4 100644
--- a/app/src/main/java/com/gh/gamecenter/adapter/viewholder/GameHeadViewHolder.java
+++ b/app/src/main/java/com/gh/gamecenter/adapter/viewholder/GameHeadViewHolder.java
@@ -3,7 +3,6 @@ package com.gh.gamecenter.adapter.viewholder;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
-import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
@@ -16,22 +15,20 @@ public class GameHeadViewHolder extends RecyclerView.ViewHolder {
public ImageView thumb;
public TextView title;
- public LinearLayout link;
public TextView more;
public ProgressBar progressBar;
- public ImageView moreIcon;
public View line;
+ public View lineTop;
public GameHeadViewHolder(View itemView) {
super(itemView);
this.thumb = (ImageView) itemView.findViewById(R.id.head_thumb);
this.title = (TextView) itemView.findViewById(R.id.head_title);
- this.link = (LinearLayout) itemView.findViewById(R.id.head_link);
this.more = (TextView) itemView.findViewById(R.id.head_more);
this.progressBar = (ProgressBar) itemView.findViewById(R.id.head_pb);
- this.moreIcon = (ImageView) itemView.findViewById(R.id.head_more_icon);
this.line = itemView.findViewById(R.id.head_line);
+ this.lineTop = itemView.findViewById(R.id.head_line_top);
}
}
diff --git a/app/src/main/java/com/gh/gamecenter/adapter/viewholder/GameNormalSwipeViewHolder.java b/app/src/main/java/com/gh/gamecenter/adapter/viewholder/GameNormalSwipeViewHolder.java
index afe2397acf..c14d5cfb11 100644
--- a/app/src/main/java/com/gh/gamecenter/adapter/viewholder/GameNormalSwipeViewHolder.java
+++ b/app/src/main/java/com/gh/gamecenter/adapter/viewholder/GameNormalSwipeViewHolder.java
@@ -7,7 +7,6 @@ import android.widget.ProgressBar;
import android.widget.TextView;
import com.facebook.drawee.view.SimpleDraweeView;
-import com.gh.common.view.CardLinearLayout;
import com.gh.common.view.SwipeLayout;
import com.gh.gamecenter.R;
@@ -18,7 +17,7 @@ import static com.gh.gamecenter.R.id.home1_game_order;
*/
public class GameNormalSwipeViewHolder extends GameViewHolder {
- public CardLinearLayout cardView;
+ public LinearLayout cardView;
public SwipeLayout swipeLayout;
public TextView swipeText;
public TextView swipeShareText;
@@ -37,7 +36,7 @@ public class GameNormalSwipeViewHolder extends GameViewHolder {
gameProgressbar = (ProgressBar) itemView.findViewById(R.id.home1_game_progressbar);
gameDownloadSpeed = (TextView) itemView.findViewById(R.id.home1_download_speed);
gameDownloadPercentage = (TextView) itemView.findViewById(R.id.home1_download_percentage);
- cardView = (CardLinearLayout) itemView.findViewById(R.id.home1_game_card);
+ cardView = (LinearLayout) itemView.findViewById(R.id.home1_game_card);
swipeLayout = (SwipeLayout) itemView.findViewById(R.id.swipeLayout);
swipeText = (TextView) itemView.findViewById(R.id.swipe_text);
swipeShareText = (TextView) itemView.findViewById(R.id.swipe_share_text);
diff --git a/app/src/main/java/com/gh/gamecenter/download/GameDownloadFragmentAdapter.java b/app/src/main/java/com/gh/gamecenter/download/GameDownloadFragmentAdapter.java
index dbaac06ec7..74e442a9a4 100644
--- a/app/src/main/java/com/gh/gamecenter/download/GameDownloadFragmentAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/download/GameDownloadFragmentAdapter.java
@@ -20,15 +20,12 @@ import com.gh.common.constant.Constants;
import com.gh.common.util.BitmapUtils;
import com.gh.common.util.DataUtils;
import com.gh.common.util.DialogUtils;
-import com.gh.common.util.DisplayUtils;
import com.gh.common.util.FileUtils;
import com.gh.common.util.ImageUtils;
import com.gh.common.util.NetworkUtils;
import com.gh.common.util.PackageUtils;
import com.gh.common.util.PlatformUtils;
import com.gh.common.util.SpeedUtils;
-import com.gh.common.view.CardLinearLayout;
-import com.gh.common.view.CardRelativeLayout;
import com.gh.download.DownloadEntity;
import com.gh.download.DownloadManager;
import com.gh.download.DownloadStatus;
@@ -112,58 +109,22 @@ class GameDownloadFragmentAdapter extends RecyclerView.Adapter 0 && position <= doneList.size()) {
downloadEntity = doneList.get(position - 1);
-// // 第一个
-// if (position == 1) {
-// ((CardLinearLayout) holder.itemView).setmTop(DisplayUtils.dip2px(context, 8));
-// } else {
-// ((CardLinearLayout) holder.itemView).setmTop(0);
-// }
-
// 最后一个
if (position == doneList.size() && downloadingList.size() != 0) {
- ((CardLinearLayout) holder.itemView).setBottom(false);
- ((CardLinearLayout) holder.itemView).setmBottom(0);
+ viewHolder.dm_item_line.setVisibility(View.GONE);
} else {
- ((CardLinearLayout) holder.itemView).setBottom(true);
- ((CardLinearLayout) holder.itemView).setmBottom(cardMargin);
+ viewHolder.dm_item_line.setVisibility(View.VISIBLE);
}
} else if (doneList.isEmpty()) {
downloadEntity = downloadingList.get(position - 1);
-// // 第一个
-// if (position == 1) {
-// ((CardLinearLayout) holder.itemView).setmTop(DisplayUtils.dip2px(context, 8));
-// } else {
-// ((CardLinearLayout) holder.itemView).setmTop(0);
-// }
-
- // 最后一个
- if (position == downloadingList.size()) {
- ((CardLinearLayout) holder.itemView).setBottom(true);
- } else {
- ((CardLinearLayout) holder.itemView).setBottom(false);
- }
- ((CardLinearLayout) holder.itemView).setmBottom(cardMargin);
+ viewHolder.dm_item_line.setVisibility(View.VISIBLE);
} else {
downloadEntity = downloadingList.get(position - doneList.size() - 2);
-
-// // 第一个
-// if (position - doneList.size() - 2 == 0) {
-// ((CardLinearLayout) holder.itemView).setmTop(DisplayUtils.dip2px(context, 8));
-// } else {
-// ((CardLinearLayout) holder.itemView).setmTop(0);
-// }
-
- // 最后一个
- if (position - doneList.size() - 1 == downloadingList.size()) {
- ((CardLinearLayout) holder.itemView).setBottom(true);
- } else {
- ((CardLinearLayout) holder.itemView).setBottom(false);
- }
- ((CardLinearLayout) holder.itemView).setmBottom(cardMargin);
+ viewHolder.dm_item_line.setVisibility(View.VISIBLE);
}
String icon = downloadEntity.getIcon();
- if (icon.contains("KuaiChuanIcon")) { // 来自快传的apk
+ if (!TextUtils.isEmpty(icon) && icon.contains("KuaiChuanIcon")) { // 来自快传的apk
try {
JSONObject jsonObject = new JSONObject(icon);
String apkPath = jsonObject.getString("KuaiChuanIcon");
@@ -398,18 +359,18 @@ class GameDownloadFragmentAdapter extends RecyclerView.Adapter
private boolean isInitPlugin;
private boolean isAutoScroll;
private int topHeight;
- private int topHeightOld;
GameFragmentAdapter(GameFragment fragment, SwipeRefreshLayout refreshLayout) {
@@ -141,10 +138,8 @@ class GameFragmentAdapter extends RecyclerView.Adapter
DisplayMetrics outMetrics = new DisplayMetrics();
fragment.getActivity().getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
-// topHeight = (int) (outMetrics.widthPixels / 16f * 10f); //TODO 盖住轮播图比例
- topHeightOld = (int) (outMetrics.widthPixels / 16f * 10f); // 盖住轮播图比例时,记录初始大小
- topHeight = (int) (outMetrics.widthPixels / 16f * 11.4f); //TODO 不盖住轮播图比例
+ topHeight = (int) (outMetrics.widthPixels / 16f * 10.5f);
cardMargin = (int) context.getResources().getDimension(R.dimen.cardview_margin);
@@ -521,7 +516,6 @@ class GameFragmentAdapter extends RecyclerView.Adapter
R.layout.game_viewpager_item, parent, false);
DisplayMetrics outMetrics = new DisplayMetrics();
fragment.getActivity().getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
-// topHeight = (int) (outMetrics.widthPixels / 16f * 10f);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT, topHeight); //整个头部大小16:10 viewpager大小16:7
view.setLayoutParams(params);
@@ -531,17 +525,16 @@ class GameFragmentAdapter extends RecyclerView.Adapter
ViewGroup.LayoutParams.MATCH_PARENT, (int) (outMetrics.widthPixels / 16f * 7f));
viewPager.setLayoutParams(vpParams);
- CardRelativeLayout subjectRl = (CardRelativeLayout) view.findViewById(R.id.home_subject_rl);
+ RelativeLayout subjectRl = (RelativeLayout) view.findViewById(R.id.home_subject_rl);
RelativeLayout.LayoutParams subjectParams = new RelativeLayout.LayoutParams(
- ViewGroup.LayoutParams.MATCH_PARENT, (int) (outMetrics.widthPixels / 16f * 4.4f));
+ ViewGroup.LayoutParams.MATCH_PARENT, (int) (outMetrics.widthPixels / 16f * 3.5f));
subjectParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
subjectRl.setLayoutParams(subjectParams);
LinearLayout hint = (LinearLayout) view.findViewById(R.id.viewpager_ll_hint);
RelativeLayout.LayoutParams hintParams = new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
-// hintParams.setMargins(0, (int) (outMetrics.widthPixels / 16f * 5.3f), 0, 0); // TODO 盖住轮播图点 比例
- hintParams.setMargins(0, (int) (outMetrics.widthPixels / 16f * 6.5f), DisplayUtils.dip2px(context, 010), 0);
+ hintParams.setMargins(0, (int) (outMetrics.widthPixels / 16f * 6.5f), DisplayUtils.dip2px(context, 10), 0);
hintParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
hint.setLayoutParams(hintParams);
@@ -685,7 +678,7 @@ class GameFragmentAdapter extends RecyclerView.Adapter
//初始化专题入口
viewHolder.subjectLl.removeAllViews();
- for (int i = 0; i < 5; i++) {
+ for (int i = 0; i < 6; i++) {
final SharedPreferences sp = context.getSharedPreferences(Config.PREFERENCE, Context.MODE_PRIVATE);
View contentView = View.inflate(context, R.layout.home_subject_entrance_item, null);
TextView subjectName = (TextView) contentView.findViewById(R.id.home_subject_name);
@@ -696,12 +689,15 @@ class GameFragmentAdapter extends RecyclerView.Adapter
viewHolder.subjectLl.addView(contentView);
if (subjectDigestList.size() == 3 && i < 3) {
-// subjectIcon.setImageURI(subjectDigestList.get(i).getIcon());
ImageUtils.display(subjectIcon, subjectDigestList.get(i).getIcon());
subjectName.setText(subjectDigestList.get(i).getName());
}
if (i == 3) {
+
+ }
+
+ if (i == 4) {
subjectName.setText("礼包");
subjectIcon.setImageURI(Uri.parse("res:///" + R.drawable.home_entrance_libao));
if (sp.getBoolean("showGiftNewIcon", true)) {
@@ -709,31 +705,31 @@ class GameFragmentAdapter extends RecyclerView.Adapter
}
}
- if (i == 4) {
- subjectName.setText("攻略");
- subjectIcon.setImageURI(Uri.parse("res:///" + R.drawable.home_entrance_strategy));
+ if (i == 5) {
+ subjectName.setText("开服表");
+ subjectIcon.setImageURI(Uri.parse("res:///" + R.drawable.home_entrance_kaifu));
}
final int finalI = i;
contentView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- if (finalI < 3 && !isSubjectDigestError) {
+ if (finalI < 4 && !isSubjectDigestError) {
Intent intent = new Intent(context, SubjectActivity.class);
intent.putExtra("id", subjectDigestList.get(finalI).getColumnId());
intent.putExtra("name", subjectDigestList.get(finalI).getColumnName());
intent.putExtra("order", subjectDigestList.get(finalI).getOrder());
intent.putExtra("entrance", "(游戏-专题:" + subjectDigestList.get(finalI).getName() + ")");
context.startActivity(intent);
- } else if (finalI == 3) {
+ } else if (finalI == 4) {
subjectNewIcon.setVisibility(View.GONE);
sp.edit().putBoolean("showGiftNewIcon", false).apply();
Intent intent = new Intent(context, LibaoActivity.class);
intent.putExtra("entrance", "(游戏-专题:礼包)");
context.startActivity(intent);
- } else if (finalI == 4){
- Intent intent = new Intent(context, StrategyActivity.class);
- intent.putExtra("entrance", "(游戏-专题:攻略)");
+ } else if (finalI == 5){
+ Intent intent = new Intent(context, KaiFuActivity.class);
+ intent.putExtra("entrance", "(游戏-专题:开服表)");
context.startActivity(intent);
} else {
Utils.toast(context, "数据异常");
@@ -757,7 +753,7 @@ class GameFragmentAdapter extends RecyclerView.Adapter
if (subjectList.get(i).getData().get(0).getImage() != null) {
order--;
}
- initGameTest(holder, gameEntity, order, subjectList.get(i), i + 1 == size);
+ initGameTest(holder, gameEntity, order, subjectList.get(i));
break;
}
}
@@ -766,23 +762,7 @@ class GameFragmentAdapter extends RecyclerView.Adapter
}
private void initGameTest(GameTestViewHolder holder, final GameEntity gameEntity,
- final int i, final SubjectEntity subjectEntity, boolean isBottom) {
-
- // 最后一个
- ((CardLinearLayout) holder.itemView).setBottom(isBottom);
- if (TextUtils.isEmpty(subjectEntity.getData().get(0).getImage())) {
- if (i + 1 == subjectEntity.getData().size()) {
- ((CardLinearLayout) holder.itemView).setmBottom(cardMargin);
- } else {
- ((CardLinearLayout) holder.itemView).setmBottom(0);
- }
- } else {
- if (i + 2 == subjectEntity.getData().size()) {
- ((CardLinearLayout) holder.itemView).setmBottom(cardMargin);
- } else {
- ((CardLinearLayout) holder.itemView).setmBottom(0);
- }
- }
+ final int i, final SubjectEntity subjectEntity) {
if (subjectEntity.isOrder()) {
holder.gameOrder.setVisibility(View.VISIBLE);
@@ -791,7 +771,6 @@ class GameFragmentAdapter extends RecyclerView.Adapter
holder.gameOrder.setVisibility(View.GONE);
}
-// holder.gameThumb.setImageURI(gameEntity.getIcon());
ImageUtils.display(holder.gameThumb, gameEntity.getIcon());
holder.gameName.setText(gameEntity.getName());
if (gameEntity.getApk() == null || gameEntity.getApk().isEmpty()) {
@@ -846,7 +825,7 @@ class GameFragmentAdapter extends RecyclerView.Adapter
subjectEntity.setOrder(false);
subjectEntity.setName("插件化");
subjectEntity.setData(pluginList);
- initGameNormal(holder, gameEntity, position - 2, subjectEntity, false);
+ initGameNormal(holder, gameEntity, position - 2, subjectEntity);
return;
}
@@ -866,7 +845,7 @@ class GameFragmentAdapter extends RecyclerView.Adapter
if (subjectList.get(i).getData().get(0).getImage() != null) {
order--;
}
- initGameNormal(holder, gameEntity, order, subjectList.get(i), i + 1 == size);
+ initGameNormal(holder, gameEntity, order, subjectList.get(i));
break;
}
}
@@ -875,23 +854,7 @@ class GameFragmentAdapter extends RecyclerView.Adapter
}
private void initGameNormal(GameNormalViewHolder holder, final GameEntity gameEntity,
- final int i, final SubjectEntity subjectEntity, boolean isBottom) {
-
- // 最后一个
- ((CardLinearLayout) holder.itemView).setBottom(isBottom);
- if (TextUtils.isEmpty(subjectEntity.getData().get(0).getImage())) {
- if (i + 1 == subjectEntity.getData().size()) {
- ((CardLinearLayout) holder.itemView).setmBottom(cardMargin);
- } else {
- ((CardLinearLayout) holder.itemView).setmBottom(0);
- }
- } else {
- if (i + 2 == subjectEntity.getData().size()) {
- ((CardLinearLayout) holder.itemView).setmBottom(cardMargin);
- } else {
- ((CardLinearLayout) holder.itemView).setmBottom(0);
- }
- }
+ final int i, final SubjectEntity subjectEntity) {
if (subjectEntity.isOrder()) {
holder.gameOrder.setVisibility(View.VISIBLE);
@@ -899,7 +862,7 @@ class GameFragmentAdapter extends RecyclerView.Adapter
} else {
holder.gameOrder.setVisibility(View.GONE);
}
-// holder.gameThumb.setImageURI(gameEntity.getIcon());
+
ImageUtils.display(holder.gameThumb, gameEntity.getIcon());
if (gameEntity.isPluggable()) {
holder.gameName.setText(String.format("%s - %s", gameEntity.getName(),
@@ -954,11 +917,6 @@ class GameFragmentAdapter extends RecyclerView.Adapter
}
gameEntity = subjectList.get(i).getData().get(index);
if (position == offset && !TextUtils.isEmpty(gameEntity.getImage())) {
- if (i == 0 && position != 1 && pluginList.isEmpty()) {
- ((CardLinearLayout) holder.itemView).setmTop(cardMargin);
- } else {
- ((CardLinearLayout) holder.itemView).setmTop(0);
- }
final GameEntity entity = gameEntity;
final String name = subjectList.get(i).getName();
@@ -1004,17 +962,16 @@ class GameFragmentAdapter extends RecyclerView.Adapter
private void initGameHeadViewHolder(final GameHeadViewHolder holder, int position) {
if (!pluginList.isEmpty() && position == 1) {
-// ((CardLinearLayout) holder.itemView).setmTop(cardMargin);
holder.title.setTextColor(context.getResources().getColor(R.color.theme));
holder.thumb.setVisibility(View.VISIBLE);
holder.line.setVisibility(View.GONE);
holder.thumb.setImageResource(R.drawable.home_plug_upgrade);
holder.title.setText(String.format(Locale.getDefault(), "你有%d个游戏可以升级插件版", pluginSize));
if (pluginSize <= 2) {
- holder.link.setVisibility(View.GONE);
+ holder.more.setVisibility(View.GONE);
} else {
- holder.link.setVisibility(View.VISIBLE);
- holder.link.setOnClickListener(new View.OnClickListener() {
+ holder.more.setVisibility(View.VISIBLE);
+ holder.more.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(context, PluginActivity.class);
@@ -1037,36 +994,35 @@ class GameFragmentAdapter extends RecyclerView.Adapter
if (index < 0){
index = 0;
}
+
+ if (TextUtils.isEmpty(subjectList.get(i).getData().get(0).getImage())) {
+ holder.lineTop.setVisibility(View.VISIBLE);
+ } else {
+ holder.lineTop.setVisibility(View.GONE);
+ }
+
gameEntity = subjectList.get(i).getData().get(index);
if (position == offset && TextUtils.isEmpty(gameEntity.getImage()) || position == offset + 1
&& !TextUtils.isEmpty(subjectList.get(i).getData().get(0).getImage())) {
- if (TextUtils.isEmpty(subjectList.get(i).getData().get(0).getImage())
- && pluginList.isEmpty() && i == 0 && position != 1) {
- ((CardLinearLayout) holder.itemView).setmTop(cardMargin);
- } else {
- ((CardLinearLayout) holder.itemView).setmTop(0);
- }
holder.thumb.setVisibility(View.GONE);
holder.line.setVisibility(View.VISIBLE);
holder.title.setText(subjectList.get(i).getName());
holder.title.setTextColor(Color.BLACK);
final int ii = i;
if (subjectList.get(i).getData().size() >= Integer.parseInt(subjectList.get(i).getMore())){
- holder.link.setVisibility(View.GONE);
+ holder.more.setVisibility(View.GONE);
}else {
- holder.link.setVisibility(View.VISIBLE);
+ holder.more.setVisibility(View.VISIBLE);
if (subjectList.get(i).getHome().equals("change")) {
holder.more.setText("换一批");
holder.more.setTextColor(context.getResources().getColor(R.color.theme));
- holder.moreIcon.setVisibility(View.GONE);
} else {
holder.more.setText("全部");
holder.more.setTextColor(Color.parseColor("#676767"));
- holder.moreIcon.setVisibility(View.VISIBLE);
}
}
- holder.link.setOnClickListener(new View.OnClickListener() {
+ holder.more.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SubjectEntity subjectEntity = subjectList.get(ii);
@@ -1184,34 +1140,6 @@ class GameFragmentAdapter extends RecyclerView.Adapter
}
}
- //轮播图和入口刷新
- void stretchTop(int offset, boolean isInit) {
- if (isInit) {
- while (true) {
- if (topHeight > topHeightOld) {
- topHeight = topHeight - 2;
- notifyItemChanged(0);
- } else {
- return;
- }
- }
- }
-
- topHeight = topHeight + offset;
- if (topHeight > topHeightOld) {
- notifyItemChanged(0);
- } else {
- topHeight = topHeight - offset;
- }
-
- }
-
- float getDragPercent() {
- int offset = topHeight - topHeightOld;
- float distance = (float) (offset * 3) / (float) topHeightOld;
- return (float) (1.0 - distance);
- }
-
void startAutoScroll() {
isAutoScroll = true;
notifyItemChanged(0);
diff --git a/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailAdapter.java b/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailAdapter.java
index 616ef0f633..e89f6f99b9 100644
--- a/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailAdapter.java
@@ -62,7 +62,6 @@ import java.util.Map;
import okhttp3.ResponseBody;
import retrofit2.adapter.rxjava.HttpException;
import rx.android.schedulers.AndroidSchedulers;
-import rx.functions.Action1;
import rx.functions.Func1;
import rx.schedulers.Schedulers;
@@ -210,9 +209,10 @@ public class GameDetailAdapter extends RecyclerView.Adapter {
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
- .subscribe(new Action1