diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index fa5ed9b5ce..e739391af3 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -111,7 +111,7 @@
+ android:configChanges="keyboardHidden" />
@@ -195,11 +195,21 @@
android:name="com.gh.gamecenter.AboutActivity"
android:screenOrientation="portrait"/>
+
+
+
+
diff --git a/app/src/main/java/com/gh/base/HomeFragment.java b/app/src/main/java/com/gh/base/HomeFragment.java
index 93747b4eeb..669ec7fbbf 100644
--- a/app/src/main/java/com/gh/base/HomeFragment.java
+++ b/app/src/main/java/com/gh/base/HomeFragment.java
@@ -22,7 +22,6 @@ import com.gh.common.util.DataCollectionUtils;
import com.gh.common.util.DataUtils;
import com.gh.common.util.DisplayUtils;
import com.gh.download.DownloadManager;
-import com.gh.gamecenter.ConcernActivity;
import com.gh.gamecenter.DownloadManagerActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.SearchActivity;
@@ -55,7 +54,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
- if (!hintList.isEmpty()) {
+ if (hintList != null && !hintList.isEmpty()) {
outState.putStringArrayList("hint", hintList);
}
}
@@ -223,12 +222,9 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
intent.putExtra("entrance", "(工具栏)");
startActivity(intent);
} else if (id == R.id.actionbar_notification) {
- DataUtils.onEvent(getActivity(), "主页", "关注图标");
- DataCollectionUtils.uploadClick(getActivity(), "关注图标", "主页");
- Intent intent = new Intent(getActivity(), ConcernActivity.class);
- intent.putExtra("entrance", "(工具栏)");
- startActivity(intent);
+// Intent intent = new Intent(getContext(), NewGameDetailActivity.class);
+// getActivity().startActivity(intent);
}
}
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 390a837162..f53114a951 100644
--- a/app/src/main/java/com/gh/common/constant/Config.java
+++ b/app/src/main/java/com/gh/common/constant/Config.java
@@ -8,7 +8,7 @@ public class Config {
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 COMMENT_HOST = "http://comment2.ghzhushou.com/v1d2/";
public static final String DATA_HOST = "http://data.ghzhushou.com/";
public static final String LIBAO_HOST = "http://libao.ghzhushou.com/v1d1/";
public static final String PREFERENCE = "ghzhushou";
diff --git a/app/src/main/java/com/gh/common/util/CommentUtils.java b/app/src/main/java/com/gh/common/util/CommentUtils.java
new file mode 100644
index 0000000000..245570b5a4
--- /dev/null
+++ b/app/src/main/java/com/gh/common/util/CommentUtils.java
@@ -0,0 +1,45 @@
+package com.gh.common.util;
+
+import android.widget.TextView;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+/**
+ * Created by khy on 2017/3/22.
+ */
+public class CommentUtils {
+
+ public static void setCommentTime(TextView textView, long time) {
+ SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd", Locale.getDefault());
+ try {
+ long today = format.parse(format.format(new Date())).getTime();
+ long day = time * 1000;
+ if (day >= today && day < today + 86400 * 1000) {
+ long min = new Date().getTime()/1000 - day/1000;
+ int hour = (int) (min/ (60 * 60));
+ if (hour == 0) {
+ if (min < 60) {
+ textView.setText("刚刚");
+ } else {
+ textView.setText(String.format(Locale.getDefault(), "%d分钟前", (int) (min / 60)));
+ }
+ } else {
+ textView.setText(String.format(Locale.getDefault(), "%d小时前", hour));
+ }
+ } else if (day >= today - 86400 * 1000 && day < today) {
+ format.applyPattern("HH:mm");
+ textView.setText("昨天 ");
+ } else {
+ format.applyPattern("yyyy-MM-dd");
+ textView.setText(format.format(day));
+ }
+ } catch (ParseException e) {
+ e.printStackTrace();
+ format.applyPattern("yyyy-MM-dd");
+ textView.setText(format.format(time * 1000));
+ }
+ }
+}
diff --git a/app/src/main/java/com/gh/common/util/GameUtils.java b/app/src/main/java/com/gh/common/util/GameUtils.java
index 7853aefdfa..7d932bbeba 100644
--- a/app/src/main/java/com/gh/common/util/GameUtils.java
+++ b/app/src/main/java/com/gh/common/util/GameUtils.java
@@ -9,7 +9,7 @@ import com.gh.base.AppController;
import com.gh.download.DownloadEntity;
import com.gh.download.DownloadManager;
import com.gh.download.DownloadStatus;
-import com.gh.gamecenter.GameDetailActivity;
+import com.gh.gamecenter.NewGameDetailActivity;
import com.gh.gamecenter.R;
import com.gh.gamecenter.entity.ApkEntity;
import com.gh.gamecenter.entity.GameEntity;
@@ -48,7 +48,7 @@ public class GameUtils {
*/
public static void startGameDetailActivity(Context context, GameEntity gameEntity, String entrance) {
AppController.put("GameEntity", gameEntity);
- Intent intent = new Intent(context, GameDetailActivity.class);
+ Intent intent = new Intent(context, NewGameDetailActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("entrance", entrance);
context.startActivity(intent);
@@ -58,7 +58,7 @@ public class GameUtils {
* 启动游戏详情页面
*/
public static void startGameDetailActivity(Context context, String gameId, String entrance) {
- Intent intent = new Intent(context, GameDetailActivity.class);
+ Intent intent = new Intent(context, NewGameDetailActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("gameId", gameId);
intent.putExtra("entrance", entrance);
diff --git a/app/src/main/java/com/gh/common/util/LibaoUtils.java b/app/src/main/java/com/gh/common/util/LibaoUtils.java
index c93f5276ea..13b3ee8c46 100644
--- a/app/src/main/java/com/gh/common/util/LibaoUtils.java
+++ b/app/src/main/java/com/gh/common/util/LibaoUtils.java
@@ -80,6 +80,13 @@ public class LibaoUtils {
public void onResponse(List response) {
LibaoDao libaoDao = new LibaoDao(context);
for (LibaoEntity libaoEntity : response) {
+
+ if ("ling".equals(libaoEntity.getStatus())) {
+ libaoEntity.setStatus("linged");
+ } else {
+ libaoEntity.setStatus("taoed");
+ }
+
LibaoInfo libaoInfo = LibaoInfo.createLibaoInfo(libaoEntity);
libaoInfo.setActive(libaoEntity.isActive());
libaoDao.add(libaoInfo);
@@ -327,6 +334,8 @@ public class LibaoUtils {
Utils.toast(libaoBtn.getContext(), "淘号成功");
+ libaoEntity.setStatus("taoed");
+
LibaoInfo libaoInfo = LibaoInfo.createLibaoInfo(libaoEntity);
libaoInfo.setCode(libaoCode);
// libaoInfo.setTime(String.valueOf(new Date().getTime()));
@@ -334,7 +343,6 @@ public class LibaoUtils {
EventBus.getDefault().post(new EBReuse("libaoChanged"));
- libaoEntity.setStatus("taoed");
adapter.initLibaoDao();
adapter.notifyDataSetChanged();
@@ -432,13 +440,14 @@ public class LibaoUtils {
}
libaoEntity.setAvailable(libaoEntity.getAvailable() - 1);
+ libaoEntity.setStatus("linged");
+
LibaoInfo libaoInfo = LibaoInfo.createLibaoInfo(libaoEntity);
libaoInfo.setCode(libaoCode);
libaoDao.add(libaoInfo);
EventBus.getDefault().post(new EBReuse("libaoChanged"));
- libaoEntity.setStatus("linged");
adapter.initLibaoDao();
adapter.notifyDataSetChanged();
diff --git a/app/src/main/java/com/gh/common/util/PostCommentUtils.java b/app/src/main/java/com/gh/common/util/PostCommentUtils.java
index b3711d7bc3..29c4ec3232 100644
--- a/app/src/main/java/com/gh/common/util/PostCommentUtils.java
+++ b/app/src/main/java/com/gh/common/util/PostCommentUtils.java
@@ -2,6 +2,7 @@ package com.gh.common.util;
import android.content.Context;
+import com.gh.gamecenter.entity.CommentEntity;
import com.gh.gamecenter.retrofit.JSONObjectResponse;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
@@ -24,13 +25,19 @@ import rx.schedulers.Schedulers;
public class PostCommentUtils {
public static void addCommentData(final Context context, final String newsId, final String content,
- final boolean isCheck, final PostCommentListener listener) {
+ final boolean isCheck, final CommentEntity commentEntity,
+ final PostCommentListener listener) {
TokenUtils.getToken(context, isCheck)
.flatMap(new Func1>() {
@Override
public Observable call(String token) {
RequestBody body = RequestBody.create(MediaType.parse("application/json"), content);
- return RetrofitManager.getComment().postNewsComment(token, newsId, body);
+
+ if (commentEntity != null) {
+ return RetrofitManager.getComment().postReplyComment(token, commentEntity.getId(), body);
+ } else {
+ return RetrofitManager.getComment().postNewsComment(token, newsId, body);
+ }
}
})
.subscribeOn(Schedulers.io())
@@ -47,10 +54,16 @@ public class PostCommentUtils {
}
}
+ @Override
+ public void onError(Throwable e) {
+ super.onError(e);
+ Utils.log("======" + e.toString());
+ }
+
@Override
public void onFailure(HttpException e) {
if (e != null && e.code() == 401) {
- addCommentData(context, newsId, content, false, listener);
+ addCommentData(context, newsId, content, false, commentEntity, listener);
return;
}
if (listener != null){
diff --git a/app/src/main/java/com/gh/common/util/QQUtils.java b/app/src/main/java/com/gh/common/util/QQUtils.java
new file mode 100644
index 0000000000..f047c12481
--- /dev/null
+++ b/app/src/main/java/com/gh/common/util/QQUtils.java
@@ -0,0 +1,38 @@
+package com.gh.common.util;
+
+import android.content.ClipboardManager;
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+
+/**
+ * Created by khy on 2017/3/30.
+ */
+public class QQUtils {
+
+ public static void startQQSession(Context context, String qq) {
+ if (ShareUtils.isQQClientAvailable(context)) {
+ //安装了QQ会直接调用QQ,打开手机QQ进行会话 QQ号:2586716223
+ String str = "mqqwpa://im/chat?chat_type=wpa&uin=" + qq + "&version=1&src_type=web&web_src=oicqzone.com";
+ context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(str)));
+ } else {
+ //没有安装QQ 复制账号
+ ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
+ cmb.setText(qq);
+ Utils.toast(context, "已复制" + qq);
+ }
+ }
+
+ public static boolean joinQQGroup(Context context, String key) {
+ Intent intent = new Intent();
+ intent.setData(Uri.parse("mqqopensdkapi://bizAgent/qm/qr?url=http%3A%2F%2Fqm.qq.com%2Fcgi-bin%2Fqm%2Fqr%3Ffrom%3Dapp%26p%3Dandroid%26k%3D" + key));
+ // 此Flag可根据具体产品需要自定义,如设置,则在加群界面按返回,返回手Q主界面,不设置,按返回会返回到呼起产品界面 //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+ try {
+ context. startActivity(intent);
+ return true;
+ } catch (Exception e) {
+ // 未安装手Q或安装的版本不支持
+ return false;
+ }
+ }
+}
diff --git a/app/src/main/java/com/gh/common/view/GridDivider.java b/app/src/main/java/com/gh/common/view/GridDivider.java
new file mode 100644
index 0000000000..56c26889b8
--- /dev/null
+++ b/app/src/main/java/com/gh/common/view/GridDivider.java
@@ -0,0 +1,134 @@
+package com.gh.common.view;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.drawable.Drawable;
+import android.support.v7.widget.RecyclerView;
+import android.view.View;
+
+/**
+ * Created by khy on 2017/3/28.
+ */
+public class GridDivider extends RecyclerView.ItemDecoration {
+ private Drawable mDividerDarwable;
+ private int mDividerHight = 1;
+ private Paint mColorPaint;
+
+
+ public final int[] ATRRS = new int[]{android.R.attr.listDivider};
+
+ public GridDivider(Context context) {
+ final TypedArray ta = context.obtainStyledAttributes(ATRRS);
+ this.mDividerDarwable = ta.getDrawable(0);
+ ta.recycle();
+ }
+
+ /*
+ int dividerHight 分割线的线宽
+ int dividerColor 分割线的颜色
+ */
+ public GridDivider(Context context, int dividerHight, int dividerColor) {
+ this(context);
+ mDividerHight = dividerHight;
+ mColorPaint = new Paint();
+ mColorPaint.setColor(dividerColor);
+ }
+
+ /*
+ int dividerHight 分割线的线宽
+ Drawable dividerDrawable 图片分割线
+ */
+ public GridDivider(Context context, int dividerHight, Drawable dividerDrawable) {
+ this(context);
+ mDividerHight = dividerHight;
+ mDividerDarwable = dividerDrawable;
+ }
+
+ @Override
+ public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
+ super.onDraw(c, parent, state);
+ //画水平和垂直分割线
+ drawHorizontalDivider(c, parent);
+ drawVerticalDivider(c, parent);
+ }
+
+ public void drawVerticalDivider(Canvas c, RecyclerView parent) {
+ final int childCount = parent.getChildCount();
+ for (int i = 0; i < childCount; i++) {
+ final View child = parent.getChildAt(i);
+ final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
+
+ final int top = child.getTop() - params.topMargin;
+ final int bottom = child.getBottom() + params.bottomMargin;
+
+ int left = 0;
+ int right = 0;
+
+ //左边第一列
+ if ((i % 7) == 0) {
+ //item左边分割线
+ left = child.getLeft();
+ right = left + mDividerHight;
+ mDividerDarwable.setBounds(left, top, right, bottom);
+ mDividerDarwable.draw(c);
+ if (mColorPaint != null) {
+ c.drawRect(left, top, right, bottom, mColorPaint);
+ }
+ //item右边分割线
+ left = child.getRight() + params.rightMargin - mDividerHight;
+ right = left + mDividerHight;
+ } else {
+ //非左边第一列
+ left = child.getRight() + params.rightMargin - mDividerHight;
+ right = left + mDividerHight;
+ }
+ //画分割线
+ mDividerDarwable.setBounds(left, top, right, bottom);
+ mDividerDarwable.draw(c);
+ if (mColorPaint != null) {
+ c.drawRect(left, top, right, bottom, mColorPaint);
+ }
+
+ }
+ }
+
+ public void drawHorizontalDivider(Canvas c, RecyclerView parent) {
+
+ final int childCount = parent.getChildCount();
+ for (int i = 0; i < childCount; i++) {
+ final View child = parent.getChildAt(i);
+ RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
+
+ final int left = child.getLeft() - params.leftMargin - mDividerHight;
+ final int right = child.getRight() + params.rightMargin;
+ int top = 0;
+ int bottom = 0;
+
+ // 最上面一行
+ if ((i / 7) == 0) {
+ //当前item最上面的分割线
+ top = child.getTop();
+ //当前item下面的分割线
+ bottom = top + mDividerHight;
+ mDividerDarwable.setBounds(left, top, right, bottom);
+ mDividerDarwable.draw(c);
+ if (mColorPaint != null) {
+ c.drawRect(left, top, right, bottom, mColorPaint);
+ }
+ top = child.getBottom() + params.bottomMargin;
+ bottom = top + mDividerHight;
+ } else {
+ top = child.getBottom() + params.bottomMargin;
+ bottom = top + mDividerHight;
+ }
+ //画分割线
+ mDividerDarwable.setBounds(left, top, right, bottom);
+ mDividerDarwable.draw(c);
+ if (mColorPaint != null) {
+ c.drawRect(left, top, right, bottom, mColorPaint);
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/com/gh/common/view/MarqueeView.java b/app/src/main/java/com/gh/common/view/MarqueeView.java
new file mode 100644
index 0000000000..c5bdca21a3
--- /dev/null
+++ b/app/src/main/java/com/gh/common/view/MarqueeView.java
@@ -0,0 +1,138 @@
+package com.gh.common.view;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.text.TextUtils;
+import android.util.AttributeSet;
+import android.view.Gravity;
+import android.view.ViewTreeObserver;
+import android.view.animation.Animation;
+import android.view.animation.AnimationUtils;
+import android.widget.TextView;
+import android.widget.ViewFlipper;
+
+import com.gh.common.util.DisplayUtils;
+import com.gh.gamecenter.R;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by khy on 2017/3/29.
+ */
+public class MarqueeView extends ViewFlipper {
+
+ private Context mContext;
+ private List notices;
+ private boolean isSetAnimDuration = false;
+
+ private int interval = 2000;
+ private int animDuration = 500;
+ private int textSize = 14;
+ private int textColor = 0xffffffff;
+
+ public MarqueeView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ init(context, attrs, 0);
+ }
+
+ private void init(Context context, AttributeSet attrs, int defStyleAttr) {
+ this.mContext = context;
+ if (notices == null) {
+ notices = new ArrayList<>();
+ }
+
+ TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.MarqueeViewStyle, defStyleAttr, 0);
+ interval = typedArray.getInteger(R.styleable.MarqueeViewStyle_mvInterval, interval);
+ isSetAnimDuration = typedArray.hasValue(R.styleable.MarqueeViewStyle_mvAnimDuration);
+ animDuration = typedArray.getInteger(R.styleable.MarqueeViewStyle_mvAnimDuration, animDuration);
+ if (typedArray.hasValue(R.styleable.MarqueeViewStyle_mvTextSize)) {
+ textSize = (int) typedArray.getDimension(R.styleable.MarqueeViewStyle_mvTextSize, textSize);
+ textSize = DisplayUtils.px2sp(mContext, textSize);
+ }
+ textColor = typedArray.getColor(R.styleable.MarqueeViewStyle_mvTextColor, textColor);
+ typedArray.recycle();
+
+ setFlipInterval(interval);
+
+ Animation animIn = AnimationUtils.loadAnimation(mContext, R.anim.anim_marquee_in);
+ if (isSetAnimDuration) animIn.setDuration(animDuration);
+ setInAnimation(animIn);
+
+ Animation animOut = AnimationUtils.loadAnimation(mContext, R.anim.anim_marquee_out);
+ if (isSetAnimDuration) animOut.setDuration(animDuration);
+ setOutAnimation(animOut);
+ }
+
+ // 根据公告字符串启动轮播
+ public void startWithText(final String notice) {
+ if (TextUtils.isEmpty(notice)) return;
+ getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
+ @Override
+ public void onGlobalLayout() {
+ getViewTreeObserver().removeGlobalOnLayoutListener(this);
+ startWithFixedWidth(notice, getWidth());
+ }
+ });
+ }
+
+ // 根据公告字符串列表启动轮播
+ public void startWithList(List notices) {
+ setNotices(notices);
+ start();
+ }
+
+ // 根据宽度和公告字符串启动轮播
+ private void startWithFixedWidth(String notice, int width) {
+ int noticeLength = notice.length();
+ int dpW = DisplayUtils.px2dip(mContext, width);
+ int limit = dpW/textSize;
+ if (dpW == 0) {
+ throw new RuntimeException("Please set MarqueeView width !");
+ }
+
+ if (noticeLength <= limit) {
+ notices.add(notice);
+ } else {
+ int size = noticeLength/limit + (noticeLength%limit != 0? 1:0);
+ for (int i=0; i= noticeLength? noticeLength:(i+1)*limit);
+ notices.add(notice.substring(startIndex, endIndex));
+ }
+ }
+ start();
+ }
+
+ // 启动轮播
+ public boolean start() {
+ if (notices == null || notices.size() == 0) return false;
+ removeAllViews();
+ for (String notice:notices) {
+ addView(createTextView(notice));
+ }
+ if (notices.size() > 1) {
+ startFlipping();
+ }
+ return true;
+ }
+
+ // 创建ViewFlipper下的TextView
+ private TextView createTextView(String text) {
+ TextView tv = new TextView(mContext);
+ tv.setGravity(Gravity.LEFT|Gravity.CENTER_VERTICAL);
+ tv.setText(text);
+ tv.setTextColor(textColor);
+ tv.setTextSize(textSize);
+ return tv;
+ }
+
+ public List getNotices() {
+ return notices;
+ }
+
+ public void setNotices(List notices) {
+ this.notices = notices;
+ }
+
+}
diff --git a/app/src/main/java/com/gh/common/view/MeasureLinearLayoutManager.java b/app/src/main/java/com/gh/common/view/MeasureLinearLayoutManager.java
new file mode 100644
index 0000000000..2b14240984
--- /dev/null
+++ b/app/src/main/java/com/gh/common/view/MeasureLinearLayoutManager.java
@@ -0,0 +1,63 @@
+package com.gh.common.view;
+
+import android.content.Context;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.view.View;
+import android.view.ViewGroup;
+
+/**
+ * Created by khy on 2017/3/30.
+ */
+public class MeasureLinearLayoutManager extends LinearLayoutManager {
+ int height;
+
+ public MeasureLinearLayoutManager(Context context) {
+ super(context);
+ }
+
+ private int[] mMeasuredDimension = new int[1];
+
+ @Override
+ public void onMeasure(RecyclerView.Recycler recycler, RecyclerView.State state,
+ int widthSpec, int heightSpec) {
+ super.onMeasure(recycler, state, widthSpec, heightSpec);
+ height = 0;
+
+ try {
+ for (int i = 0; i < getItemCount(); i++) {
+ measureScrapChild(recycler, i,
+ View.MeasureSpec.makeMeasureSpec(i, View.MeasureSpec.UNSPECIFIED),
+ View.MeasureSpec.makeMeasureSpec(i, View.MeasureSpec.UNSPECIFIED),
+ mMeasuredDimension);
+ height = height + mMeasuredDimension[0];
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ private void measureScrapChild(RecyclerView.Recycler recycler, int position, int widthSpec,
+ int heightSpec, int[] measuredDimension) throws Exception {
+ View view = recycler.getViewForPosition(position);
+ if (view.getVisibility() == View.GONE) {
+ measuredDimension[0] = 0;
+ return;
+ }
+ super.measureChildWithMargins(view, 0, 0);
+ RecyclerView.LayoutParams p = (RecyclerView.LayoutParams) view.getLayoutParams();
+ int childHeightSpec = ViewGroup.getChildMeasureSpec(
+ heightSpec,
+ getPaddingTop() + getPaddingBottom() + getDecoratedTop(view) + getDecoratedBottom(view),
+ p.height);
+
+ view.measure(0, childHeightSpec);
+ measuredDimension[0] = getDecoratedMeasuredHeight(view) + p.bottomMargin + p.topMargin;
+ recycler.recycleView(view);
+ }
+
+ public int getRvHeight() {
+ return height;
+ }
+}
diff --git a/app/src/main/java/com/gh/gamecenter/CommentDetailActivity.java b/app/src/main/java/com/gh/gamecenter/CommentDetailActivity.java
new file mode 100644
index 0000000000..e187184170
--- /dev/null
+++ b/app/src/main/java/com/gh/gamecenter/CommentDetailActivity.java
@@ -0,0 +1,46 @@
+package com.gh.gamecenter;
+
+import android.os.Bundle;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.view.View;
+
+import com.gh.base.BaseActivity;
+import com.gh.gamecenter.adapter.CommentDetailAdapter;
+
+import butterknife.BindView;
+
+/**
+ * Created by khy on 2017/3/22.
+ */
+public class CommentDetailActivity extends BaseActivity {
+
+ @BindView(R.id.comment_detail_rv) RecyclerView mRecyclerView;
+
+ private CommentDetailAdapter mAdapter;
+ private LinearLayoutManager mLayoutManager;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ View view = View.inflate(this, R.layout.activity_comment_detail, null);
+ init(view, "查看对话");
+
+ String commentId = getIntent().getExtras().getString("commentId");
+
+ mAdapter = new CommentDetailAdapter(this, commentId);
+ mLayoutManager = new LinearLayoutManager(this);
+ mRecyclerView.setLayoutManager(mLayoutManager);
+ mRecyclerView.setAdapter(mAdapter);
+
+ mRecyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
+ @Override
+ public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
+ super.onScrollStateChanged(recyclerView, newState);
+ if (newState == RecyclerView.SCROLL_STATE_IDLE && !mAdapter.isOver() && !mAdapter.isLoading()) {
+ mAdapter.loadData(mAdapter.getItemCount());
+ }
+ }
+ });
+ }
+}
diff --git a/app/src/main/java/com/gh/gamecenter/LibaoDetailActivity.java b/app/src/main/java/com/gh/gamecenter/LibaoDetailActivity.java
index c68fb4ad20..7d8f4e59b0 100644
--- a/app/src/main/java/com/gh/gamecenter/LibaoDetailActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/LibaoDetailActivity.java
@@ -21,12 +21,14 @@ import rx.schedulers.Schedulers;
* Created by khy on 2016/12/13.
*
*/
-public class LibaoDetailActivity extends BaseDetailActivity {
+public class LibaoDetailActivity extends BaseDetailActivity implements LibaoDetailAdapter.OnCodeScrollListener{
private LibaoDetailAdapter mAdapter;
private LibaoEntity mLibaoEntity;
+ private boolean mIsScroll;
+
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
@@ -43,8 +45,15 @@ public class LibaoDetailActivity extends BaseDetailActivity {
iv_share.setVisibility(View.GONE);
+ mIsScroll = true;
+
mAdapter = new LibaoDetailAdapter(this, mLibaoEntity, detail_tv_download);
- detail_rv_show.setLayoutManager(new LinearLayoutManager(this));
+ detail_rv_show.setLayoutManager(new LinearLayoutManager(this){
+ @Override
+ public boolean canScrollVertically() {
+ return mIsScroll;
+ }
+ });
detail_rv_show.addItemDecoration(new VerticalItemDecoration(this, 8, true));
detail_rv_show.setAdapter(mAdapter);
@@ -123,4 +132,9 @@ public class LibaoDetailActivity extends BaseDetailActivity {
reuse_tv_none_data.setText("天了噜~页面不见了");
reuse_none_data.setVisibility(View.VISIBLE);
}
+
+ @Override
+ public void isScroll(boolean isScroll) {
+ mIsScroll = isScroll;
+ }
}
diff --git a/app/src/main/java/com/gh/gamecenter/MessageDetailActivity.java b/app/src/main/java/com/gh/gamecenter/MessageDetailActivity.java
index f3eb98ad94..3b7c51cb3f 100644
--- a/app/src/main/java/com/gh/gamecenter/MessageDetailActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/MessageDetailActivity.java
@@ -89,6 +89,7 @@ public class MessageDetailActivity extends BaseActivity implements MessageDetail
private CommentDao mCommentDao;
private ConcernEntity mConcernEntity;
+ private CommentEntity mCommentEntity; // 回复评论的实体 用完马上清空
private String newsId;
@@ -346,14 +347,13 @@ public class MessageDetailActivity extends BaseActivity implements MessageDetail
newsId = mConcernEntity.getId();
}
- PostCommentUtils.addCommentData(MessageDetailActivity.this, newsId, jsonObject.toString(), true,
+ PostCommentUtils.addCommentData(MessageDetailActivity.this, newsId, jsonObject.toString(), true, mCommentEntity,
new PostCommentUtils.PostCommentListener() {
@Override
public void postSucced(JSONObject response) {
mSendingDialog.dismiss();
toast("发表成功");
mMessageDetailEt.setText("");
- setSoftInput(false);
try {
mCommentDao.add(new CommentInfo(response.getString("_id")));//添加评论id到数据库, 后续判断是否是自身评论
@@ -368,6 +368,15 @@ public class MessageDetailActivity extends BaseActivity implements MessageDetail
cacheObject.put("vote", 0);
cacheObject.put("user", cacheUser);
+ if (mCommentEntity != null) {
+ JSONObject cacheParent = new JSONObject();
+ JSONObject cacheParentUser = new JSONObject();
+ cacheParentUser.put("_id", mCommentEntity.getId());
+ cacheParentUser.put("name", mCommentEntity.getUser().getName());
+ cacheParent.put("user", cacheParentUser);
+ cacheObject.put("parent", cacheParent);
+ }
+
CommentEntity commentEntity = new Gson().fromJson(cacheObject.toString(), CommentEntity.class);
if (mConcernEntity != null) {
adapter.addNormalComment(commentEntity);
@@ -390,6 +399,8 @@ public class MessageDetailActivity extends BaseActivity implements MessageDetail
showNoConnection(false);
}
+ setSoftInput(false);
+
}
@Override
@@ -480,6 +491,12 @@ public class MessageDetailActivity extends BaseActivity implements MessageDetail
mMessageDetailEt.requestFocus();
mColseCommentV.setVisibility(View.VISIBLE);
+ if (mCommentEntity != null && mCommentEntity.getUser() != null) {
+ mMessageDetailEt.setHint("回复 " + mCommentEntity.getUser().getName() + ":");
+ } else {
+ mMessageDetailEt.setHint("优质评论会被优先展示");
+ }
+
} else {
imm.hideSoftInputFromWindow(getWindow().getDecorView().getWindowToken(), 0);
mMessageDetailCommentHintRl.setVisibility(View.VISIBLE);
@@ -487,11 +504,18 @@ public class MessageDetailActivity extends BaseActivity implements MessageDetail
mMessageDetailCommentRl.setVisibility(View.GONE);
mMessageDetailUserRl.setVisibility(View.GONE);
mColseCommentV.setVisibility(View.GONE);
+
+ if (mCommentEntity != null) {
+ mCommentEntity = null; // 清空当前评论实体
+ mMessageDetailEt.setHint("优质评论会被优先展示");
+ mMessageDetailEt.setText("");
+ }
}
}
@Override
- public void showSoftInput() {
+ public void showSoftInput(CommentEntity entity) {
+ mCommentEntity = entity;
setSoftInput(true);
}
diff --git a/app/src/main/java/com/gh/gamecenter/NewGameDetailActivity.java b/app/src/main/java/com/gh/gamecenter/NewGameDetailActivity.java
new file mode 100644
index 0000000000..023ebcc7ea
--- /dev/null
+++ b/app/src/main/java/com/gh/gamecenter/NewGameDetailActivity.java
@@ -0,0 +1,651 @@
+package com.gh.gamecenter;
+
+import android.content.Intent;
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.text.TextUtils;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.ProgressBar;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.facebook.drawee.view.SimpleDraweeView;
+import com.gh.base.AppController;
+import com.gh.base.BaseFragmentActivity;
+import com.gh.common.constant.Config;
+import com.gh.common.util.ConcernUtils;
+import com.gh.common.util.DataCollectionUtils;
+import com.gh.common.util.DataUtils;
+import com.gh.common.util.DialogUtils;
+import com.gh.common.util.FileUtils;
+import com.gh.common.util.GameUtils;
+import com.gh.common.util.ImageUtils;
+import com.gh.common.util.NetworkUtils;
+import com.gh.common.util.PackageUtils;
+import com.gh.common.util.ShareUtils;
+import com.gh.common.view.DownloadDialog;
+import com.gh.common.view.NoScrollableViewPager;
+import com.gh.download.DataWatcher;
+import com.gh.download.DownloadEntity;
+import com.gh.download.DownloadManager;
+import com.gh.gamecenter.adapter.FragmentAdapter;
+import com.gh.gamecenter.entity.ApkEntity;
+import com.gh.gamecenter.entity.GameDetailEntity;
+import com.gh.gamecenter.entity.GameEntity;
+import com.gh.gamecenter.eventbus.EBDownloadStatus;
+import com.gh.gamecenter.eventbus.EBMoveTop;
+import com.gh.gamecenter.eventbus.EBPackage;
+import com.gh.gamecenter.gamedetail.FuLiFragment;
+import com.gh.gamecenter.gamedetail.XinXiFragment;
+import com.gh.gamecenter.manager.ConcernManager;
+import com.gh.gamecenter.manager.PackageManager;
+import com.gh.gamecenter.retrofit.Response;
+import com.gh.gamecenter.retrofit.RetrofitManager;
+import com.jakewharton.rxbinding.view.RxView;
+import com.tencent.tauth.Tencent;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import butterknife.BindView;
+import butterknife.OnClick;
+import retrofit2.adapter.rxjava.HttpException;
+import rx.android.schedulers.AndroidSchedulers;
+import rx.functions.Action1;
+import rx.schedulers.Schedulers;
+
+/**
+ * Created by khy on 2017/3/24.
+ */
+public class NewGameDetailActivity extends BaseFragmentActivity {
+
+ @BindView(R.id.gamedetail_vp) NoScrollableViewPager mViewPager;
+ @BindView(R.id.gamedetail_top) RelativeLayout mTopLl;
+ @BindView(R.id.gamedetail_tabbar_rl) RelativeLayout mTabBarRl;
+ @BindView(R.id.reuse_ll_loading) LinearLayout mLoading;
+ @BindView(R.id.reuse_no_connection) LinearLayout mNoConnection;
+ @BindView(R.id.actionbar_tv_title) TextView mTitle;
+ @BindView(R.id.gamedetail_iv_thumb) SimpleDraweeView mGameIcon;
+ @BindView(R.id.gamedetail_tv_name) TextView mGameName;
+ @BindView(R.id.gamedetail_tv_info) TextView mGameInfo;
+ @BindView(R.id.gamedetail_tv_concern) TextView mGameConcern;
+ @BindView(R.id.gamedetail_tabbar) LinearLayout mTabBar;
+ @BindView(R.id.gamedetail_tabbar_fuli) TextView mTanBarFuLi;
+ @BindView(R.id.gamedetail_tabbar_xinxi) TextView mTanBarXinXi;
+ @BindView(R.id.gamedetail_tabbar_fuli_tv) TextView mTanBarFuLiTv;
+ @BindView(R.id.gamedetail_tabbar_xinxi_tv) TextView mTanBarXinXiTv;
+ @BindView(R.id.gamedetail_suggest) ImageView mSuggestIv;
+ @BindView(R.id.gamedetail_share) ImageView mShareIv;
+
+ @BindView(R.id.detail_ll_bottom) LinearLayout mDownloadBottom;
+ @BindView(R.id.detail_tv_download) TextView mDownloadTv;
+ @BindView(R.id.detail_tv_per) TextView mDownloadPer;
+ @BindView(R.id.detail_pb_progressbar) ProgressBar mDownloadPb;
+
+ private RelativeLayout.LayoutParams top_rparams;
+
+ private ConcernManager mConcernManager;
+
+ private String mGameId;
+
+ private GameEntity mGameEntity;
+ private DownloadEntity mDownloadEntity;
+
+ private String downloadAddWord;
+ private String downloadOffText;
+
+ private String name;
+ private String title;
+ private String shareCode;
+
+ private DataWatcher dataWatcher = new DataWatcher() {
+ @Override
+ public void onDataChanged(DownloadEntity downloadEntity) {
+ if (mGameEntity != null && mGameEntity.getApk().size() == 1) {
+ String url = mGameEntity.getApk().get(0).getUrl();
+ if (url.equals(downloadEntity.getUrl())) {
+ if (!"pause".equals(DownloadManager.getInstance(NewGameDetailActivity.this).
+ getStatus(downloadEntity.getUrl()))) {
+ mDownloadEntity = downloadEntity;
+ invalidate();
+ }
+ }
+ }
+ }
+ };
+
+ //接收QQ或者QQ空间分享回调
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+
+ if (requestCode == com.tencent.connect.common.Constants.REQUEST_QQ_SHARE
+ || requestCode == com.tencent.connect.common.Constants.REQUEST_QZONE_SHARE) {
+ Tencent.onActivityResultData(requestCode, resultCode, data, ShareUtils.getInstance(this).QqShareListener);
+ }
+
+ }
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ View view = View.inflate(NewGameDetailActivity.this, R.layout.activity_game_detail, null);
+ init(view);
+
+ mViewPager.setScrollable(false);
+
+ mConcernManager = new ConcernManager(NewGameDetailActivity.this);
+
+ name = "游戏详情";
+
+ mGameId = getIntent().getStringExtra("gameId");
+ if (getIntent().getBundleExtra("data") != null) {
+ mGameId = getIntent().getBundleExtra("data").getString("gameId");
+ }
+
+ if (mGameId == null) {
+ mGameEntity = (GameEntity) AppController.get("GameEntity", false);
+ if (mGameEntity != null) {
+ mGameId = mGameEntity.getId();
+ mTitle.setText(mGameEntity.getName());
+ name = mGameEntity.getName();
+ }
+ }
+ if (mGameEntity != null) {
+ getGameDetail();
+ } else if (mGameId != null) {
+ getGameDigest();
+ } else {
+ mLoading.setVisibility(View.GONE);
+ mNoConnection.setVisibility(View.VISIBLE);
+ }
+
+ }
+
+ private void initGameDetailTop() {
+
+ mLoading.setVisibility(View.GONE);
+ mTopLl.setVisibility(View.VISIBLE);
+
+ top_rparams = (RelativeLayout.LayoutParams) mTopLl.getLayoutParams();
+
+ if (mConcernManager.isConcern(mGameEntity.getId())) {
+ mGameConcern.setText("取消关注");
+ mGameConcern.setBackgroundResource(R.drawable.border_red_bg);
+ mGameConcern.setTextColor(Color.parseColor("#ff4147"));
+ } else {
+ mGameConcern.setText("关注");
+ mGameConcern.setBackgroundResource(R.drawable.textview_concern_red_style);
+ mGameConcern.setTextColor(0xffffffff);
+ }
+
+ mGameName.setText(mGameEntity.getName());
+ ImageUtils.display(mGameIcon, mGameEntity.getIcon());
+ if (mGameEntity.getApk() == null || mGameEntity.getApk().isEmpty()) {
+ mGameInfo.setText("");
+ } else {
+ ApkEntity apkEntity = mGameEntity.getApk().get(0);
+ mGameInfo.setText(String.format("V%s | %s", apkEntity.getVersion(), apkEntity.getSize()));
+ }
+ mGameConcern.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ final TextView concern = (TextView) v;
+ if ("关注".equals(concern.getText().toString())) {
+
+ Map kv = new HashMap<>();
+ kv.put("状态", "关注");
+ DataUtils.onEvent(NewGameDetailActivity.this, "游戏关注", mGameEntity.getName(), kv);
+
+ Map kv2 = new HashMap<>();
+ kv2.put("点击", "关注");
+ DataUtils.onEvent(NewGameDetailActivity.this, "插件数据", mGameEntity.getName(), kv2);
+
+ DataCollectionUtils.uploadConcern(NewGameDetailActivity.this, mGameEntity.getName(), mGameEntity.getId(), "关注");
+
+ mConcernManager.addByEntity(mGameEntity);
+ concern.setText("取消关注");
+ concern.setBackgroundResource(R.drawable.border_red_bg);
+ concern.setTextColor(Color.parseColor("#ff4147"));
+
+ Toast.makeText(NewGameDetailActivity.this, "关注成功", Toast.LENGTH_SHORT).show();
+
+ // 添加关注
+ ConcernUtils.postConcernGameId(NewGameDetailActivity.this, mGameEntity.getId());
+ } else {
+ Map kv2 = new HashMap<>();
+ kv2.put("点击", "取消关注");
+ DataUtils.onEvent(NewGameDetailActivity.this, "插件数据", mGameEntity.getName(), kv2);
+
+ DialogUtils.showCancelDialog(NewGameDetailActivity.this, new DialogUtils.ConfiremListener() {
+ @Override
+ public void onConfirem() {
+ Map kv = new HashMap<>();
+ kv.put("状态", "取消关注");
+ DataUtils.onEvent(NewGameDetailActivity.this, "游戏关注", mGameEntity.getName(), kv);
+
+ DataCollectionUtils.uploadConcern(NewGameDetailActivity.this,
+ mGameEntity.getName(), mGameEntity.getId(), "取消关注");
+
+ mConcernManager.deleteConcern(mGameEntity.getId());
+ concern.setText("关注");
+ concern.setBackgroundResource(R.drawable.textview_concern_red_style);
+ concern.setTextColor(0xffffffff);
+
+ // 取消关注
+ ConcernUtils.deleteConcernData(NewGameDetailActivity.this, mGameEntity.getId());
+ }
+ });
+ }
+ }
+ });
+
+ }
+
+ // 获取游戏摘要
+ private void getGameDigest() {
+ RetrofitManager.getApi().getGameDigest(mGameId)
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(new Response() {
+ @Override
+ public void onResponse(GameEntity response) {
+ mGameEntity = response;
+ AppController.put("GameEntity", response);
+
+ mTitle.setText(mGameEntity.getName());
+ mGameId = response.getId();
+ name = mGameEntity.getName();
+ getGameDetail();
+ }
+
+ @Override
+ public void onFailure(HttpException e) {
+ mLoading.setVisibility(View.GONE);
+ mNoConnection.setVisibility(View.VISIBLE);
+ }
+ });
+ }
+
+ // 获取游戏详情
+ public void getGameDetail() {
+ RetrofitManager.getApi().getGameDetail(mGameId)
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(new Response() {
+ @Override
+ public void onResponse(GameDetailEntity response) {
+ // 过滤过期公告
+ if (response.getNotice() != null && response.getNotice().size() > 0) {
+ long l = System.currentTimeMillis();
+ for (int i = 0; i < response.getNotice().size(); i++) {
+ if (l > (response.getNotice().get(i).getOvertime()*1000)) {
+ response.getNotice().remove(i);
+ i --;
+ }
+ }
+ }
+
+ AppController.put("GameDetailEntity", response);
+
+ downloadAddWord = response.getDownloadAddWord();
+ downloadOffText = response.getDownloadOffText();
+ shareCode = response.getShareCode();
+
+ List list = new ArrayList<>();
+ if (mGameEntity != null && !mGameEntity.isLibaoExists()
+ && TextUtils.isEmpty(response.getFulishuoming())
+ && (response.getKaiFuServer() == null
+ || (response.getKaiFuServer() != null
+ && response.getKaiFuServer().size() == 0))) {
+ XinXiFragment xinXiFragment = new XinXiFragment();
+ xinXiFragment.setIsTabBar(true);
+ list.add(xinXiFragment);
+ mTabBar.setVisibility(View.GONE);
+ } else {
+ list.add(new FuLiFragment());
+ list.add(new XinXiFragment());
+ }
+
+ mViewPager.setAdapter(new FragmentAdapter(getSupportFragmentManager(), list));
+ initGameDetailTop();
+
+ initDownload(true);
+ }
+
+ @Override
+ public void onError(Throwable e) {
+ super.onError(e);
+ }
+
+ @Override
+ public void onFailure(HttpException e) {
+
+ }
+ });
+ }
+
+ public void onEventMainThread(EBMoveTop moveTop) {
+ if (moveTop.getType().equals("top")) {
+ if (moveTop.getVisibility() == View.VISIBLE && mTabBar.getVisibility() == View.VISIBLE) {
+ mTabBarRl.setVisibility(View.VISIBLE);
+ } else {
+ mTabBarRl.setVisibility( View.GONE);
+ }
+ int topMargin = moveTop.getTopMargin();
+ if (top_rparams != null && top_rparams.topMargin != topMargin) {
+ if (topMargin > -120) {
+ mTitle.setVisibility(View.GONE);
+ } else {
+ mTitle.setVisibility(View.VISIBLE);
+ }
+ top_rparams.topMargin = moveTop.getTopMargin();
+ mTopLl.setLayoutParams(top_rparams);
+ }
+ }
+ }
+
+ // 接收下载被删除消息
+ public void onEvent(EBDownloadStatus status) {
+ if ("delete".equals(status.getStatus())
+ && mGameEntity != null
+ && mGameEntity.getApk() != null
+ && mGameEntity.getApk().size() == 1) {
+ String url = mGameEntity.getApk().get(0).getUrl();
+ if (url.equals(status.getUrl())) {
+ initDownload(false);
+ }
+ }
+ }
+
+ // 接受安装、卸载消息
+ public void onEventMainThread(EBPackage busFour) {
+ if (mGameEntity != null
+ && mGameEntity.getApk() != null
+ && mGameEntity.getApk().size() == 1) {
+ String packageName = mGameEntity.getApk().get(0).getPackageName();
+ if (packageName.equals(busFour.getPackageName())) {
+ initDownload(false);
+ }
+ }
+ }
+
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ if (mGameEntity != null
+ && mGameEntity.getApk() != null
+ && mGameEntity.getApk().size() == 1) {
+ initDownload(true);
+ }
+ DownloadManager.getInstance(this).addObserver(dataWatcher);
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ DownloadManager.getInstance(this).removeObserver(dataWatcher);
+ }
+
+
+ @OnClick({R.id.detail_tv_download, R.id.detail_pb_progressbar, R.id.gamedetail_suggest
+ , R.id.detail_tv_per, R.id.gamedetail_tabbar_xinxi, R.id.gamedetail_tabbar_xinxi_tv
+ , R.id.gamedetail_tabbar_fuli, R.id.gamedetail_tabbar_fuli_tv, R.id.gamedetail_share})
+ public void onClick(View v) {
+ if (v == mDownloadTv) {
+ if (mGameEntity != null && !mGameEntity.getApk().isEmpty()) {
+ if (mGameEntity.getApk().size() == 1) {
+ if (NetworkUtils.isWifiConnected(this)) {
+ download();
+ } else {
+ DialogUtils.showDownloadDialog(this, new DialogUtils.ConfiremListener() {
+ @Override
+ public void onConfirem() {
+ download();
+ }
+ });
+ }
+ } else {
+ DownloadDialog.getInstance(this).showPopupWindow(v, mGameEntity, entrance, name + ":" + title);
+ }
+ } else {
+ toast("稍等片刻~!游戏正在上传中...");
+ }
+ } else if (v == mDownloadPb || v == mDownloadPer) {
+ String str = mDownloadPer.getText().toString();
+ if ("下载中".equals(str)) {
+ Intent intent = new Intent(this, DownloadManagerActivity.class);
+ intent.putExtra("currentItem", 1);
+ intent.putExtra("url", mGameEntity.getApk().get(0).getUrl());
+ intent.putExtra("entrance", entrance + "+(" + name + "[" + title + "])");
+ startActivity(intent);
+ } else if ("安装".equals(str)) {
+ PackageUtils.launchSetup(this, mDownloadEntity.getPath());
+ }
+ } else if (v == mTanBarFuLi || v == mTanBarFuLiTv) {
+ mTanBarFuLi.setTextColor(Color.WHITE);
+ mTanBarFuLiTv.setTextColor(Color.WHITE);
+ mTanBarFuLi.setBackgroundResource(R.drawable.gamedetail_tag_select_bg);
+ mTanBarFuLiTv.setBackgroundResource(R.drawable.gamedetail_tag_select_bg);
+ mTanBarXinXi.setTextColor(Color.BLACK);
+ mTanBarXinXiTv.setTextColor(Color.BLACK);
+ mTanBarXinXi.setBackgroundDrawable(new ColorDrawable(0));
+ mTanBarXinXiTv.setBackgroundDrawable(new ColorDrawable(0));
+ mViewPager.setCurrentItem(0);
+
+ } else if (v == mTanBarXinXi || v == mTanBarXinXiTv) {
+ mTanBarXinXiTv.setTextColor(Color.WHITE);
+ mTanBarXinXi.setTextColor(Color.WHITE);
+ mTanBarXinXiTv.setBackgroundResource(R.drawable.gamedetail_tag_unselect_bg);
+ mTanBarXinXi.setBackgroundResource(R.drawable.gamedetail_tag_unselect_bg);
+ mTanBarFuLi.setTextColor(Color.BLACK);
+ mTanBarFuLiTv.setTextColor(Color.BLACK);
+ mTanBarFuLi.setBackgroundDrawable(new ColorDrawable(0));
+ mTanBarFuLiTv.setBackgroundDrawable(new ColorDrawable(0));
+ mViewPager.setCurrentItem(1);
+ } else if (v == mShareIv) {
+ if (TextUtils.isEmpty(shareCode)) return;
+ // 防抖处理
+ RxView.clicks(mShareIv)
+ .throttleFirst(1, TimeUnit.SECONDS)
+ .subscribe(new Action1() {
+ @Override
+ public void call(Void aVoid) {
+ Map kv = new HashMap<>();
+ kv.put("点击", "分享");
+ DataUtils.onEvent(NewGameDetailActivity.this, "插件数据", mGameEntity.getName(), kv);
+
+ DataCollectionUtils.uploadClick(NewGameDetailActivity.this, "分享", "游戏详情", mGameEntity.getName());
+
+ String url = "http://www.ghzhushou.com/game/" + shareCode;
+ showShare(url, mGameEntity.getName(), mGameEntity.getIcon(), null, mGameEntity.getTag());
+ }
+ });
+ } else if (v == mSuggestIv) {
+ Intent intent = new Intent(this, NewSuggestActivity.class);
+ intent.putExtra("suggestType", 1);
+ startActivity(intent);
+ }
+ }
+
+ private void download() {
+ String str = mDownloadTv.getText().toString();
+ if (str.contains("启动")) {
+ DataUtils.onGameLaunchEvent(this, mGameEntity.getName(), mGameEntity.getApk().get(0).getPlatform(), name);
+
+ PackageUtils.launchApplicationByPackageName(this, mGameEntity.getApk().get(0).getPackageName());
+ } else {
+ String method;
+ if (str.contains("更新")) {
+ method = "更新";
+ } else if (str.contains("插件化")) {
+ method = "插件化";
+ } else {
+ method = "下载";
+ }
+ ApkEntity apkEntity = mGameEntity.getApk().get(0);
+ String msg = FileUtils.isCanDownload(this, apkEntity.getSize());
+ if (TextUtils.isEmpty(msg)) {
+ DataUtils.onGameDownloadEvent(this, mGameEntity.getName(), apkEntity.getPlatform(), entrance, "下载开始");
+
+ DownloadManager.createDownload(this, apkEntity, mGameEntity, method, entrance, name + ":" + title);
+
+ mDownloadTv.setVisibility(View.GONE);
+ mDownloadPb.setVisibility(View.VISIBLE);
+ mDownloadPer.setVisibility(View.VISIBLE);
+ mDownloadPb.setProgress(0);
+ mDownloadPer.setText("0.0%");
+
+ DownloadManager.getInstance(NewGameDetailActivity.this).putStatus(apkEntity.getUrl(), "downloading");
+ } else {
+ toast(msg);
+ }
+ }
+ }
+
+ private void invalidate() {
+ mDownloadPb.setProgress((int) (mDownloadEntity.getPercent() * 10));
+ mDownloadPer.setTextColor(0xFFFFFFFF);
+ switch (mDownloadEntity.getStatus()) {
+ case downloading:
+ case pause:
+ case timeout:
+ case neterror:
+ case waiting:
+ mDownloadPer.setText("下载中");
+ break;
+ case done:
+ mDownloadPer.setText("安装");
+ if (mDownloadEntity.isPluggable()
+ && PackageManager.isInstalled(mDownloadEntity.getPackageName())) {
+ mDownloadPb.setProgressDrawable(getResources().getDrawable(R.drawable.progressbar_plugin_radius_style));
+ } else {
+ mDownloadPb.setProgressDrawable(getResources().getDrawable(R.drawable.progressbar_normal_radius_style));
+ }
+ break;
+ case cancel:
+ case hijack:
+ case notfound:
+ initDownload(false);
+ break;
+ default:
+ break;
+ }
+ }
+
+ protected void initDownload(boolean isCheck) {
+ if (Config.isShow(this)) {
+ mDownloadBottom.setVisibility(View.VISIBLE);
+ } else {
+ mDownloadBottom.setVisibility(View.GONE);
+ }
+ if (mGameEntity != null && "光环助手".equals(mGameEntity.getName())) {
+ mDownloadBottom.setVisibility(View.GONE);
+ } else if (mGameEntity == null || mGameEntity.getApk().isEmpty()) {
+ mDownloadTv.setVisibility(View.VISIBLE);
+ mDownloadPb.setVisibility(View.GONE);
+ mDownloadPer.setVisibility(View.GONE);
+ if (TextUtils.isEmpty(downloadOffText)) {
+ mDownloadTv.setText("暂无下载");
+ } else {
+ mDownloadTv.setText(downloadOffText);
+ }
+ mDownloadTv.setBackgroundResource(R.drawable.game_item_btn_pause_style);
+ mDownloadTv.setTextColor(0xFF999999);
+ mDownloadTv.setClickable(false);
+ } else {
+ mDownloadTv.setVisibility(View.VISIBLE);
+ mDownloadPb.setVisibility(View.GONE);
+ mDownloadPer.setVisibility(View.GONE);
+ boolean isInstalled = false;
+ if (mGameEntity.getApk() != null && mGameEntity.getApk().size() == 1
+ && PackageManager.isInstalled(mGameEntity.getApk().get(0).getPackageName())) {
+ isInstalled = true;
+ }
+ if (isInstalled) {
+ if (PackageManager.isCanUpdate(mGameEntity.getId(), mGameEntity.getApk().get(0).getPackageName())) {
+ if (TextUtils.isEmpty(downloadAddWord)) {
+ mDownloadTv.setBackgroundResource(
+ R.drawable.game_item_btn_download_style);
+ mDownloadTv.setText(String.format("更新《%s》",
+ mGameEntity.getName()));
+ } else {
+ mDownloadTv.setBackgroundResource(
+ R.drawable.game_item_btn_download_style);
+ mDownloadTv.setText(String.format("更新《%s》%s",
+ mGameEntity.getName(), downloadAddWord));
+ }
+ } else {
+ if (mGameEntity.getTag() != null && mGameEntity.getTag().size() != 0
+ && !TextUtils.isEmpty(mGameEntity.getApk().get(0).getGhVersion())
+ && !PackageUtils.isSignature(this, mGameEntity.getApk().get(0).getPackageName())) {
+ if (TextUtils.isEmpty(downloadAddWord)) {
+ mDownloadTv.setBackgroundResource(
+ R.drawable.game_item_btn_plugin_style);
+ mDownloadTv.setText(String.format("插件化《%s》",
+ mGameEntity.getName()));
+ } else {
+ mDownloadTv.setBackgroundResource(
+ R.drawable.game_item_btn_plugin_style);
+ mDownloadTv.setText(String.format("插件化《%s》%s",
+ mGameEntity.getName(), downloadAddWord));
+ }
+ } else {
+ if (TextUtils.isEmpty(downloadAddWord)) {
+ mDownloadTv.setBackgroundResource(
+ R.drawable.game_item_btn_launch_style);
+ mDownloadTv.setText(String.format("启动《%s》",
+ mGameEntity.getName()));
+ } else {
+ mDownloadTv.setBackgroundResource(
+ R.drawable.game_item_btn_launch_style);
+ mDownloadTv.setText(String.format("启动《%s》%s",
+ mGameEntity.getName(), downloadAddWord));
+ }
+ }
+ }
+ } else {
+ String status = GameUtils.getDownloadBtnText(this, mGameEntity);
+ if ("插件化".equals(status)) {
+ mDownloadTv.setBackgroundResource(R.drawable.game_item_btn_plugin_style);
+ } else if ("打开".equals(status)) {
+ mDownloadTv.setBackgroundResource(R.drawable.game_item_btn_launch_style);
+ } else {
+ mDownloadTv.setBackgroundResource(R.drawable.game_item_btn_download_style);
+ }
+
+ if (TextUtils.isEmpty(downloadAddWord)) {
+ mDownloadTv.setText(String.format(status + "《%s》",
+ mGameEntity.getName()));
+ } else {
+ mDownloadTv.setText(String.format(status + "《%s》%s",
+ mGameEntity.getName(), downloadAddWord));
+ }
+ }
+ }
+ if (isCheck && mGameEntity != null
+ && mGameEntity.getApk() != null
+ && mGameEntity.getApk().size() == 1) {
+ String url = mGameEntity.getApk().get(0).getUrl();
+ DownloadEntity downloadEntity = DownloadManager.getInstance(getApplicationContext()).get(url);
+ if (downloadEntity != null) {
+ mDownloadEntity = downloadEntity;
+ mDownloadTv.setVisibility(View.GONE);
+ mDownloadPb.setVisibility(View.VISIBLE);
+ mDownloadPer.setVisibility(View.VISIBLE);
+ invalidate();
+ }
+ }
+ }
+
+}
diff --git a/app/src/main/java/com/gh/gamecenter/NewSuggestActivity.java b/app/src/main/java/com/gh/gamecenter/NewSuggestActivity.java
new file mode 100644
index 0000000000..a1fc27c2f7
--- /dev/null
+++ b/app/src/main/java/com/gh/gamecenter/NewSuggestActivity.java
@@ -0,0 +1,301 @@
+package com.gh.gamecenter;
+
+import android.app.Dialog;
+import android.content.Intent;
+import android.database.Cursor;
+import android.graphics.Rect;
+import android.net.Uri;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Environment;
+import android.provider.MediaStore;
+import android.support.v7.widget.GridLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.text.TextUtils;
+import android.view.View;
+import android.view.ViewTreeObserver;
+import android.view.Window;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+import android.widget.ProgressBar;
+import android.widget.RelativeLayout;
+import android.widget.ScrollView;
+import android.widget.TextView;
+
+import com.gh.base.BaseActivity;
+import com.gh.common.util.Utils;
+import com.gh.gamecenter.entity.InstallGameEntity;
+import com.gh.gamecenter.suggest.SuggestPicAdapter;
+import com.gh.gamecenter.suggest.SuggestSelectGameAdapter;
+import com.gh.gamecenter.suggest.SuggestTypeAdapter;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import butterknife.BindView;
+import butterknife.OnClick;
+
+/**
+ * Created by khy on 2017/3/31.
+ */
+public class NewSuggestActivity extends BaseActivity implements SuggestTypeAdapter.OnSelectTypeListener {
+
+ @BindView(R.id.suggest_content_et)
+ EditText mSuggestContentEt;
+ @BindView(R.id.suggest_pic_rv)
+ RecyclerView mSuggestPicRv;
+ @BindView(R.id.suggest_news_link_et)
+ EditText mSuggestNewsLinkEt;
+ @BindView(R.id.suggest_news_link_ll)
+ LinearLayout mSuggestNewsLinkLl;
+ @BindView(R.id.suggest_email_et)
+ EditText mSuggestEmailEt;
+ @BindView(R.id.suggest_post_btn)
+ TextView mSuggestPostBtn;
+ @BindView(R.id.suggest_post_ll)
+ LinearLayout suggestPostLl;
+ @BindView(R.id.suggest_type_rv)
+ RecyclerView mTypeRv;
+ @BindView(R.id.suggest_select_game)
+ TextView mSuggestSelectGame;
+ @BindView(R.id.suggest_game_text)
+ TextView mSuggestGameText;
+ @BindView(R.id.suggest_game_ll)
+ LinearLayout mSuggestGameLl;
+ @BindView(R.id.suggest_scrollview)
+ ScrollView mScrollView;
+
+ private SuggestPicAdapter mAdapter;
+
+ private int curType = -1;
+
+ private Dialog dialog;
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ if (data != null && requestCode == 0x233) {
+ Uri selectedImage = data.getData();
+ if (selectedImage == null) {
+ return;
+ }
+ String[] filePathColumn = { MediaStore.Images.Media.DATA };
+
+ Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
+ if (cursor == null) {
+ return;
+ }
+ cursor.moveToFirst();
+
+ int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
+ String picturePath = cursor.getString(columnIndex);
+ cursor.close();
+
+ Utils.log("picturePath = " + picturePath);
+
+ mAdapter.addFileList(picturePath);
+
+ }
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ View view = View.inflate(this, R.layout.activity_suggest_new, null);
+ init(view, "意见反馈");
+ curType = getIntent().getExtras().getInt("suggestType");
+ String suggestContent = getIntent().getExtras().getString("suggestContent");
+
+ mTypeRv.setLayoutManager(new GridLayoutManager(this, 2){
+ @Override
+ public boolean canScrollVertically() {
+ return false;
+ }
+ });
+ mTypeRv.setAdapter(new SuggestTypeAdapter(this, curType));
+
+ mSuggestPicRv.setLayoutManager(new GridLayoutManager(this, 5){
+ @Override
+ public boolean canScrollVertically() {
+ return false;
+ }
+ });
+ mAdapter = new SuggestPicAdapter(this);
+ mSuggestPicRv.setAdapter(mAdapter);
+
+ if (Build.VERSION.SDK_INT >= 19) {
+ //解决透明沉浸栏和软键盘冲突(重置ScrollView高度)
+ final View decorView=getWindow().getDecorView();
+ decorView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
+ @Override
+ public void onGlobalLayout() {
+ Rect rect=new Rect();
+ decorView.getWindowVisibleDisplayFrame(rect);
+ int screenHeight = decorView.getRootView().getHeight();
+ int heightDifference = screenHeight-rect.bottom;//计算软键盘占有的高度 = 屏幕高度 - 视图可见高度
+ RelativeLayout.LayoutParams layoutParams= (RelativeLayout.LayoutParams) mScrollView.getLayoutParams();
+ layoutParams.setMargins(0,0,0,heightDifference);//设置ScrollView的marginBottom的值为软键盘占有的高度即可
+ mScrollView.requestLayout();
+ }
+ });
+ }
+
+ if (!TextUtils.isEmpty(suggestContent)) {
+ mSuggestContentEt.setText(suggestContent);
+ }
+
+ if (curType == 5) {
+ mSuggestGameLl.setVisibility(View.GONE);
+ mSuggestContentEt.setVisibility(View.VISIBLE);
+ } else {
+ initSuggest(curType);
+ }
+ }
+
+ @OnClick({ R.id.suggest_post_btn, R.id.suggest_select_game, R.id.suggest_game_text})
+ public void onViewClicked(View view) {
+ switch (view.getId()) {
+ case R.id.suggest_post_btn:
+ Utils.log("=====" + readFromFile());
+
+ break;
+ case R.id.suggest_select_game:
+ showSelectDialog();
+ break;
+ case R.id.suggest_game_text:
+ mSuggestGameLl.setVisibility(View.GONE);
+ mSuggestContentEt.setVisibility(View.VISIBLE);
+ break;
+ }
+ }
+
+ private void showSelectDialog() {
+ View view = View.inflate(this, R.layout.dialog_suggest_select_game, null);
+ RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.dialog_suggest_game_rv);
+ TextView back = (TextView) view.findViewById(R.id.dialog_suggest_game_back);
+ ProgressBar pb = (ProgressBar) view.findViewById(R.id.dialog_suggest_game_load);
+ recyclerView.setLayoutManager(new GridLayoutManager(this, 4));
+ recyclerView.setAdapter(new SuggestSelectGameAdapter(this, pb));
+
+ dialog = new Dialog(this);
+ dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
+ dialog.setCanceledOnTouchOutside(false);
+ dialog.setContentView(view);
+ dialog.show();
+
+ back.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ dialog.cancel();
+ }
+ });
+ }
+
+
+ @Override
+ public void onType(int type) {
+ curType = type;
+
+ mSuggestPicRv.postDelayed(new Runnable() {
+
+ @Override
+ public void run() {
+ //将ScrollView滚动到底
+ mScrollView.fullScroll(View.FOCUS_DOWN);
+ }
+ }, 100);
+ initSuggest(type);
+ }
+
+ private void initSuggest(int type) {
+ switch (type) {
+ case 1:
+ mSuggestContentEt.setHint("请详细描述你遇到的问题... \n ↓↓你还可以上传截图");
+ mSuggestNewsLinkLl.setVisibility(View.GONE);
+ mSuggestContentEt.setVisibility(View.VISIBLE);
+ mSuggestGameLl.setVisibility(View.GONE);
+ break;
+ case 2:
+ mSuggestContentEt.setHint("请详细描述你的建议... \n ↓↓你还可以上传截图");
+ mSuggestNewsLinkLl.setVisibility(View.GONE);
+ mSuggestContentEt.setVisibility(View.VISIBLE);
+ mSuggestGameLl.setVisibility(View.GONE);
+ break;
+ case 3:
+ mSuggestContentEt.setHint("请详细描述闪退之前你所进行的操作... \n ↓↓你还可以上传截图");
+ mSuggestNewsLinkLl.setVisibility(View.GONE);
+ mSuggestContentEt.setVisibility(View.VISIBLE);
+ mSuggestGameLl.setVisibility(View.GONE);
+ break;
+ case 4:
+ mSuggestContentEt.setHint("请写上游戏名字,以及具体遇到的问题... \n ↓↓你还可以上传截图");
+ mSuggestNewsLinkLl.setVisibility(View.GONE);
+ mSuggestContentEt.setVisibility(View.VISIBLE);
+ mSuggestGameLl.setVisibility(View.GONE);
+ break;
+ case 5:
+ mSuggestNewsLinkLl.setVisibility(View.GONE);
+ mSuggestGameLl.setVisibility(View.VISIBLE);
+ mSuggestContentEt.setVisibility(View.GONE);
+ break;
+ case 6:
+ mSuggestContentEt.setHint("简单介绍文章内容,然后在下面填写文章链接... \n ↓↓你还可以上传截图");
+ mSuggestNewsLinkLl.setVisibility(View.VISIBLE);
+ mSuggestContentEt.setVisibility(View.VISIBLE);
+ mSuggestGameLl.setVisibility(View.GONE);
+ break;
+ }
+ }
+
+ @Override
+ public void loadDone(Object obj) {
+ super.loadDone(obj);
+ if (dialog != null) {
+ dialog.cancel();
+ }
+
+ mSuggestGameLl.setVisibility(View.GONE);
+ mSuggestContentEt.setVisibility(View.VISIBLE);
+ InstallGameEntity entity = (InstallGameEntity) obj;
+ mSuggestContentEt.setText("推荐收录:" + entity.getGameName() + "(" + entity.getPackageName() + ", " + entity.getGameVersion() + ")");
+ }
+
+ public String readFromFile(){
+
+ if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
+
+ File file = new File(getExternalFilesDir(null).getPath() + "/log");
+ if (file.isFile()) return "检测log文件夹是文件";
+
+ File[] files = file.listFiles();
+ if (files == null || files.length == 0) return "log文件夹为空" + file.getPath();
+ File targetFile = files[files.length - 1];
+
+ try{
+ if(!targetFile.exists()){
+ targetFile.createNewFile();
+ return "No File error ";
+ }else{
+ InputStream in = new BufferedInputStream(new FileInputStream(targetFile));
+ BufferedReader br= new BufferedReader(new InputStreamReader(in, "UTF-8"));
+ String tmp;
+ StringBuffer string = new StringBuffer();
+ while((tmp=br.readLine())!=null){
+ string.append(tmp);
+ }
+ br.close();
+ in.close();
+ return string.toString();
+ }
+ } catch (Exception e) {
+ return e.toString();
+ }
+ }else{
+ return "SD Card error";
+ }
+ }
+}
diff --git a/app/src/main/java/com/gh/gamecenter/SettingActivity.java b/app/src/main/java/com/gh/gamecenter/SettingActivity.java
index fd0edd837e..8a92be828d 100644
--- a/app/src/main/java/com/gh/gamecenter/SettingActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/SettingActivity.java
@@ -71,7 +71,7 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
findViewById(R.id.setting_rl_autoinstall).setOnClickListener(this);
findViewById(R.id.setting_rl_autodelete).setOnClickListener(this);
findViewById(R.id.setting_rl_deletedata).setOnClickListener(this);
- findViewById(R.id.setting_rl_feedback).setOnClickListener(this);
+// findViewById(R.id.setting_rl_feedback).setOnClickListener(this);
findViewById(R.id.setting_rl_cache).setOnClickListener(this);
findViewById(R.id.setting_cv_font_size).setOnClickListener(this);
findViewById(R.id.setting_rl_concerngame).setOnClickListener(this);
@@ -189,11 +189,11 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
}
});
break;
- case R.id.setting_rl_feedback:
- Intent intent = new Intent(SettingActivity.this, SuggestionActivity.class);
- intent.putExtra("entrance", "(设置)");
- startActivity(intent);
- break;
+// case R.id.setting_rl_feedback:
+// Intent intent = new Intent(SettingActivity.this, SuggestionActivity.class);
+// intent.putExtra("entrance", "(设置)");
+// startActivity(intent);
+// break;
case R.id.setting_cv_font_size:
fontSize();
break;
diff --git a/app/src/main/java/com/gh/gamecenter/SubjectActivity.java b/app/src/main/java/com/gh/gamecenter/SubjectActivity.java
index 14a02e08aa..c3655d2374 100644
--- a/app/src/main/java/com/gh/gamecenter/SubjectActivity.java
+++ b/app/src/main/java/com/gh/gamecenter/SubjectActivity.java
@@ -14,6 +14,7 @@ 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.util.Utils;
import com.gh.common.view.VerticalItemDecoration;
import com.gh.download.DataWatcher;
import com.gh.download.DownloadEntity;
@@ -49,6 +50,8 @@ public class SubjectActivity extends BaseActivity implements SubjectTypeAdapter
private int page = 1;
+ private String type;
+
private boolean isEverpause = false;
// 黄壮华 添加观察者 修改2015/8/15
@@ -82,13 +85,15 @@ public class SubjectActivity extends BaseActivity implements SubjectTypeAdapter
}
init(contentView, name);
+ type = "全部";
+
reuse_no_connection.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
subject_pb_loading.setVisibility(View.VISIBLE);
subject_list.setVisibility(View.VISIBLE);
reuse_no_connection.setVisibility(View.GONE);
- adapter = new SubjectAdapter(SubjectActivity.this);
+ adapter = new SubjectAdapter(SubjectActivity.this, type);
subject_list.setAdapter(adapter);
}
});
@@ -98,17 +103,16 @@ public class SubjectActivity extends BaseActivity implements SubjectTypeAdapter
subject_list.addItemDecoration(new VerticalItemDecoration(this, 8, true));
subject_list.setHasFixedSize(true);
subject_list.setLayoutManager(layoutManager);
- adapter = new SubjectAdapter(this);
+ adapter = new SubjectAdapter(this, type);
subject_list.setAdapter(adapter);
subject_list.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
- if (adapter.isLoaded() && newState == RecyclerView.SCROLL_STATE_IDLE
+ if (!adapter.isRemove() && adapter.isLoaded() && newState == RecyclerView.SCROLL_STATE_IDLE
&& adapter.getItemCount() == layoutManager.findLastVisibleItemPosition() + 1){
- page++;
- adapter.initList(page);
+ adapter.initList(page, type);
}
}
});
@@ -162,6 +166,7 @@ public class SubjectActivity extends BaseActivity implements SubjectTypeAdapter
if (subject_pb_loading != null && subject_pb_loading.getVisibility() == View.VISIBLE) {
subject_pb_loading.setVisibility(View.GONE);
}
+ page ++;
}
@Override
@@ -225,7 +230,7 @@ public class SubjectActivity extends BaseActivity implements SubjectTypeAdapter
subject_list.setVisibility(View.VISIBLE);
subject_pb_loading.setVisibility(View.VISIBLE);
reuse_no_connection.setVisibility(View.GONE);
- adapter = new SubjectAdapter(SubjectActivity.this);
+ adapter = new SubjectAdapter(SubjectActivity.this, type);
subject_list.setAdapter(adapter);
}
}
@@ -252,6 +257,13 @@ public class SubjectActivity extends BaseActivity implements SubjectTypeAdapter
@Override
public void onSelectType(String type) {
-
+ Utils.toast(this, type);
+ page = 1;
+ this.type = type;
+ subject_list.setVisibility(View.VISIBLE);
+ subject_pb_loading.setVisibility(View.VISIBLE);
+ reuse_no_connection.setVisibility(View.GONE);
+ adapter = new SubjectAdapter(this, type);
+ subject_list.setAdapter(adapter);
}
}
diff --git a/app/src/main/java/com/gh/gamecenter/SuggestSelectActivity.java b/app/src/main/java/com/gh/gamecenter/SuggestSelectActivity.java
new file mode 100644
index 0000000000..eba69ca6d1
--- /dev/null
+++ b/app/src/main/java/com/gh/gamecenter/SuggestSelectActivity.java
@@ -0,0 +1,61 @@
+package com.gh.gamecenter;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.RelativeLayout;
+
+import com.gh.base.BaseActivity;
+
+import butterknife.BindView;
+import butterknife.OnClick;
+
+/**
+ * Created by khy on 2017/3/31.
+ */
+public class SuggestSelectActivity extends BaseActivity {
+ @BindView(R.id.suggest_type1) RelativeLayout mType1;
+ @BindView(R.id.suggest_type2) RelativeLayout mType2;
+ @BindView(R.id.suggest_type3) RelativeLayout mType3;
+ @BindView(R.id.suggest_type4) RelativeLayout mType4;
+ @BindView(R.id.suggest_type5) RelativeLayout mType5;
+ @BindView(R.id.suggest_type6) RelativeLayout mType6;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ View view = View.inflate(this, R.layout.activity_suggest_select, null);
+ init(view, "意见反馈");
+ }
+
+ @OnClick({R.id.suggest_type1, R.id.suggest_type2, R.id.suggest_type3
+ , R.id.suggest_type4, R.id.suggest_type5, R.id.suggest_type6})
+ public void OnClick(View view){
+ int type = 1;
+ switch (view.getId()) {
+ case R.id.suggest_type1:
+ type = 1;
+ break;
+ case R.id.suggest_type2:
+ type = 2;
+ break;
+ case R.id.suggest_type3:
+ type = 3;
+ break;
+ case R.id.suggest_type4:
+ type = 4;
+ break;
+ case R.id.suggest_type5:
+ type = 5;
+ break;
+ case R.id.suggest_type6:
+ type = 6;
+ break;
+ }
+
+ Intent intent = new Intent(this, NewSuggestActivity.class);
+ intent.putExtra("suggestType", type);
+ startActivity(intent);
+
+ }
+}
diff --git a/app/src/main/java/com/gh/gamecenter/adapter/CommentDetailAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/CommentDetailAdapter.java
new file mode 100644
index 0000000000..56ddbe7e1b
--- /dev/null
+++ b/app/src/main/java/com/gh/gamecenter/adapter/CommentDetailAdapter.java
@@ -0,0 +1,259 @@
+package com.gh.gamecenter.adapter;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.net.Uri;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import com.gh.common.constant.Config;
+import com.gh.common.constant.ItemViewType;
+import com.gh.common.util.CommentUtils;
+import com.gh.common.util.ImageUtils;
+import com.gh.common.util.PostCommentUtils;
+import com.gh.common.util.Utils;
+import com.gh.gamecenter.R;
+import com.gh.gamecenter.adapter.viewholder.CommentViewHolder;
+import com.gh.gamecenter.adapter.viewholder.FooterViewHolder;
+import com.gh.gamecenter.db.CommentDao;
+import com.gh.gamecenter.db.VoteDao;
+import com.gh.gamecenter.db.info.VoteInfo;
+import com.gh.gamecenter.entity.CommentEntity;
+import com.gh.gamecenter.retrofit.Response;
+import com.gh.gamecenter.retrofit.RetrofitManager;
+
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import retrofit2.adapter.rxjava.HttpException;
+import rx.android.schedulers.AndroidSchedulers;
+import rx.schedulers.Schedulers;
+
+/**
+ * Created by khy on 2017/3/22.
+ */
+public class CommentDetailAdapter extends RecyclerView.Adapter {
+
+ private Context mContext;
+
+ private SharedPreferences sp;
+
+ private List mCommentList;
+
+ private VoteDao mVoteDao;
+ private CommentDao mCommentDao;
+
+ private String userName; //用户名
+ private String userIcon; //用户icon
+
+ private String commentId;
+
+ private boolean isOver;
+ private boolean isLoading;
+ private boolean isNetworkError;
+
+ public CommentDetailAdapter(Context context, String commentId) {
+ this.mContext = context;
+ this.commentId = commentId;
+
+ mVoteDao = new VoteDao(context);
+ mCommentDao = new CommentDao(context);
+
+ sp = context.getSharedPreferences(Config.PREFERENCE, Context.MODE_PRIVATE);
+
+ userName = sp.getString("user_name", null);
+ userIcon = sp.getString("user_icon", null);
+
+ mCommentList = new ArrayList<>();
+
+ loadData(0);
+ }
+
+ public void loadData(int offset) {
+ isLoading = true;
+ RetrofitManager.getComment()
+ .getCommentTrace(commentId, 20, offset)
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(new Response>(){
+ @Override
+ public void onResponse(List response) {
+ super.onResponse(response);
+ mCommentList.addAll(response);
+
+ if (response.size() < 20) {
+ isOver = true;
+ }
+
+ isLoading = false;
+ notifyItemRangeChanged(0, getItemCount() - 1);
+ }
+
+ @Override
+ public void onFailure(HttpException e) {
+ super.onFailure(e);
+ Utils.toast(mContext, "评论加载失败, 请检查网络设置");
+ isNetworkError = true;
+ isLoading = false;
+ notifyItemChanged(getItemCount() - 1);
+ }
+ });
+ }
+
+ @Override
+ public int getItemViewType(int position) {
+ if (position == getItemCount() - 1) {
+ return ItemViewType.LOADING;
+ }
+
+ return 100;
+ }
+
+ @Override
+ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ if (viewType == ItemViewType.LOADING) {
+ View view = LayoutInflater.from(mContext).inflate(R.layout.refresh_footerview, parent, false);
+ return new FooterViewHolder(view);
+ } else {
+ View view = LayoutInflater.from(mContext).inflate(R.layout.comment_item, parent, false);
+ return new CommentViewHolder(view);
+ }
+ }
+
+ @Override
+ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
+ if (holder instanceof CommentViewHolder) {
+ initCommentViewHolder((CommentViewHolder) holder, position);
+ } else if (holder instanceof FooterViewHolder) {
+ initFooterViewHolder((FooterViewHolder) holder);
+ }
+ }
+
+ private void initFooterViewHolder(FooterViewHolder holder) {
+ if(isNetworkError) {
+ holder.loading.setVisibility(View.GONE);
+ holder.hint.setText("网络错误,点击重试!");
+ }else if (!isOver) {
+ holder.hint.setText("加载中...");
+ holder.loading.setVisibility(View.VISIBLE);
+ } else if (mCommentList.size() == 0) {
+ holder.loading.setVisibility(View.GONE);
+ holder.hint.setText("目前还没有评论");
+ } else {
+ holder.hint.setText("没有更多评论啦");
+ holder.loading.setVisibility(View.GONE);
+ }
+
+ }
+
+ private void initCommentViewHolder(final CommentViewHolder holder, int position) {
+ final CommentEntity commentEntity = mCommentList.get(position);
+
+ ImageUtils.display(holder.commentUserIconDv, commentEntity.getUser().getIcon());
+
+ holder.commentLikeCountTv.setTextColor(mContext.getResources().getColor(R.color.hint));
+ holder.commentLikeIv.setImageResource(R.drawable.ic_like_unselect);
+
+ if (commentEntity.getVote() == 0) {
+ holder.commentLikeCountTv.setVisibility(View.GONE);
+ } else { // 检查是否已点赞
+ if (mVoteDao.isVote(commentEntity.getId()) && commentEntity.getVote() >= 1) {
+ holder.commentLikeCountTv.setTextColor(mContext.getResources().getColor(R.color.theme));
+ holder.commentLikeIv.setImageResource(R.drawable.ic_like_select);
+ }
+ holder.commentLikeCountTv.setVisibility(View.VISIBLE);
+ holder.commentLikeCountTv.setText(String.valueOf(commentEntity.getVote()));
+ }
+
+ //检查是否是自身评论
+ if (userName != null && userIcon != null && !userIcon.isEmpty()&&
+ !userIcon.isEmpty() && mCommentDao.isMyComment(commentEntity.getId())){
+ holder.commentUserNameTv.setText(sp.getString("user_name", null));
+ ImageUtils.display(holder.commentUserIconDv, sp.getString("user_icon", null));
+ } else {
+ holder.commentUserNameTv.setText(commentEntity.getUser().getName());
+ if(commentEntity.getUser().getIcon().isEmpty()) {
+ holder.commentUserIconDv.setImageURI(Uri.parse("res:///" + R.drawable.user_default_icon_comment));
+ } else {
+ ImageUtils.display(holder.commentUserIconDv, commentEntity.getUser().getIcon());
+ }
+ }
+
+ CommentUtils.setCommentTime(holder.commentTimeTv, commentEntity.getTime());
+ if (commentEntity.getParent() != null) {
+ holder.commentContentTv.setText("@"+ commentEntity.getParent().getUser().getName() + ": " + commentEntity.getContent());
+ } else {
+ holder.commentContentTv.setText(commentEntity.getContent());
+ }
+
+ holder.commentLikeIv.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (holder.commentLikeCountTv.getCurrentTextColor() == mContext.getResources().getColor(R.color.theme)) {
+ Utils.toast(mContext, "已经点过赞啦!");
+ return;
+ }
+ commentEntity.setVote(commentEntity.getVote() + 1);
+ holder.commentLikeCountTv.setTextColor(mContext.getResources().getColor(R.color.theme));
+ holder.commentLikeIv.setImageResource(R.drawable.ic_like_select);
+ holder.commentLikeCountTv.setText(String.valueOf(commentEntity.getVote()));
+ holder.commentLikeCountTv.setVisibility(View.VISIBLE);
+
+ PostCommentUtils.addCommentVoto(mContext, commentEntity.getId(), true,
+ new PostCommentUtils.PostCommentListener() {
+ @Override
+ public void postSucced(JSONObject response) {
+ mVoteDao.add(new VoteInfo(commentEntity.getId()));
+ }
+
+ @Override
+ public void postFailed(Throwable error) {
+ commentEntity.setVote(commentEntity.getVote() - 1);
+ holder.commentLikeCountTv.setTextColor(mContext.getResources().getColor(R.color.hint));
+ holder.commentLikeIv.setImageResource(R.drawable.ic_like_unselect);
+ holder.commentLikeCountTv.setText(String.valueOf(commentEntity.getVote()));
+ if (commentEntity.getVote() == 0) {
+ holder.commentLikeCountTv.setVisibility(View.GONE);
+ } else {
+ holder.commentLikeCountTv.setVisibility(View.VISIBLE);
+ }
+ if (error instanceof HttpException) {
+ HttpException exception = (HttpException) error;
+ if (exception.code() == 403) {
+ try {
+ if (new JSONObject(exception.response().errorBody().string())
+ .getString("detail").equals("voted")) {
+ Utils.toast(mContext, "已经点过赞啦!");
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ return;
+ }
+ }
+ Utils.toast(mContext, "网络异常,点赞失败");
+
+ }
+ });
+ }
+ });
+
+ }
+
+ @Override
+ public int getItemCount() {
+ return mCommentList.size() + 1;
+ }
+
+ public boolean isOver() {
+ return isOver;
+ }
+
+ public boolean isLoading() {
+ return isLoading;
+ }
+}
diff --git a/app/src/main/java/com/gh/gamecenter/adapter/LiBaoCodeAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/LiBaoCodeAdapter.java
new file mode 100644
index 0000000000..09511640bf
--- /dev/null
+++ b/app/src/main/java/com/gh/gamecenter/adapter/LiBaoCodeAdapter.java
@@ -0,0 +1,63 @@
+package com.gh.gamecenter.adapter;
+
+import android.content.Context;
+import android.support.v7.widget.RecyclerView;
+import android.text.Html;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import com.gh.common.util.LibaoUtils;
+import com.gh.gamecenter.R;
+import com.gh.gamecenter.adapter.viewholder.LiBaoCodeViewHolder;
+import com.gh.gamecenter.db.info.LibaoInfo;
+
+import java.util.List;
+
+/**
+ * Created by khy on 2017/3/23.
+ */
+public class LiBaoCodeAdapter extends RecyclerView.Adapter {
+
+ private Context mContext;
+
+ private List mCodeMap;
+
+ public LiBaoCodeAdapter(Context context, List codes) {
+ this.mContext = context;
+
+ mCodeMap = codes;
+ }
+
+
+ @Override
+ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
+ View view = LayoutInflater.from(mContext).inflate(R.layout.libao_code_item, parent, false);
+ return new LiBaoCodeViewHolder(view);
+ }
+
+ @Override
+ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
+ final LibaoInfo libaoInfo = mCodeMap.get(position);
+ if (holder instanceof LiBaoCodeViewHolder) {
+ LiBaoCodeViewHolder viewHolder = (LiBaoCodeViewHolder) holder;
+ if ("ling".equals(libaoInfo.getStatus()) || "linged".equals(libaoInfo.getStatus())) {
+ viewHolder.code.setText(Html.fromHtml(" "+ position +"   已领取:" + "" +libaoInfo.getCode()+ ""));
+ } else {
+ viewHolder.code.setText(Html.fromHtml(" "+ position +"   已淘号:" + "" +libaoInfo.getCode()+ ""));
+ }
+
+ viewHolder.copy.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ LibaoUtils.copyLink(libaoInfo.getCode(), mContext);
+ }
+ });
+ }
+ }
+
+ @Override
+ public int getItemCount() {
+ return mCodeMap.size();
+ }
+}
diff --git a/app/src/main/java/com/gh/gamecenter/adapter/LibaoDetailAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/LibaoDetailAdapter.java
index a74b79de9d..0eb26e67e6 100644
--- a/app/src/main/java/com/gh/gamecenter/adapter/LibaoDetailAdapter.java
+++ b/app/src/main/java/com/gh/gamecenter/adapter/LibaoDetailAdapter.java
@@ -2,11 +2,13 @@ package com.gh.gamecenter.adapter;
import android.content.Context;
import android.graphics.Color;
+import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.text.Spanned;
import android.text.TextUtils;
import android.view.LayoutInflater;
+import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
@@ -43,6 +45,7 @@ public class LibaoDetailAdapter extends RecyclerView.Adapter" + libaoInfo.getCode() + "" + " 复制成功" +
- "
请尽快进入游戏兑换");
- } else {
- msg = Html.fromHtml("礼包码:" +"" + libaoInfo.getCode() + "" + " 复制成功" +
- "
淘号礼包不保证可用,请尽快进入游戏尝试兑换");
- }
+ LibaoUtils.initLibaoBtn(holder.libaoCopyBtn, mLibaoEntity, mLibaoDao,
+ mLibaoDetailEntity.getInstallRequired(), this, entrance + "+(礼包详情[" + mLibaoEntity.getName() + "])");
- LibaoUtils.lunningAppDialog(mContext, msg, mLibaoEntity);
+// holder.libaoCopyBtn.setBackgroundResource(R.drawable.textview_blue_style);
+// holder.libaoCopyBtn.setTextColor(Color.WHITE);
+// holder.libaoCopyBtn.setText("复制");
+// holder.libaoCopyBtn.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View v) {
+// if (mLibaoDetailEntity != null && mLibaoDetailEntity.getInstallRequired()) {
+// Spanned msg;
+// if ("ling".equals(libaoInfo.getStatus())) {
+// msg = Html.fromHtml("礼包码:" + "" + libaoInfo.getCode() + "" + " 复制成功" +
+// "
请尽快进入游戏兑换");
+// } else {
+// msg = Html.fromHtml("礼包码:" +"" + libaoInfo.getCode() + "" + " 复制成功" +
+// "
淘号礼包不保证可用,请尽快进入游戏尝试兑换");
+// }
+//
+// LibaoUtils.lunningAppDialog(mContext, msg, mLibaoEntity);
+// }
+// LibaoUtils.copyLink(libaoInfo.getCode(), mContext);
+// }
+// });
+
+// Spanned libaoCode;
+// if ("ling".equals(libaoInfo.getStatus())) {
+// libaoCode = Html.fromHtml("已领取:" + "" +libaoInfo.getCode()+ "");
+// if (count == 0) {
+// content = Html.fromHtml("剩余:" + count + "%");
+// } else {
+// content = Html.fromHtml("剩余:" + "" + count + "%" + "");
+// }
+// } else {
+// libaoCode = Html.fromHtml("已淘号:" + "" +libaoInfo.getCode()+ "");
+// content = Html.fromHtml("剩余:" + count + "%" );
+// }
+// holder.libaoCode.setVisibility(View.VISIBLE);
+// holder.libaoCode.setText(libaoCode);
+ holder.libaoDes.setText(content);
+
+ final List codes = mLibaoDao.findCodes(mLibaoEntity.getId());
+
+ if (codes == null && codes.isEmpty()) return;
+
+ holder.libaoCodeRv.setVisibility(View.VISIBLE);
+ holder.libaoCodeRv.setAdapter(new LiBaoCodeAdapter(mContext, codes));
+ ViewGroup.LayoutParams params = holder.libaoCodeRv.getLayoutParams();
+ if (codes.size() <= 3) {
+ params.height = codes.size() * DisplayUtils.dip2px(mContext, 40);
+ } else {
+ params.height = 3 * DisplayUtils.dip2px(mContext, 40);
+ }
+ holder.libaoCodeRv.setLayoutParams(params);
+
+ holder.libaoCodeRv.setOnTouchListener(new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+
+ if (event.getAction() == MotionEvent.ACTION_DOWN) {
+ scrollListener.isScroll(false);
+ } else if (event.getAction() == MotionEvent.ACTION_UP) {
+ scrollListener.isScroll(true);
}
- LibaoUtils.copyLink(libaoInfo.getCode(), mContext);
+ return false;
}
});
-
- Spanned libaoCode;
- if ("ling".equals(libaoInfo.getStatus())) {
- libaoCode = Html.fromHtml("已领取:" + "" +libaoInfo.getCode()+ "");
- if (count == 0) {
- content = Html.fromHtml("剩余:" + count + "%");
- } else {
- content = Html.fromHtml("剩余:" + "" + count + "%" + "");
- }
- } else {
- libaoCode = Html.fromHtml("已淘号:" + "" +libaoInfo.getCode()+ "");
- content = Html.fromHtml("剩余:" + count + "%" );
- }
- holder.libaoCode.setVisibility(View.VISIBLE);
- holder.libaoCode.setText(libaoCode);
- holder.libaoDes.setText(content);
return;
}
}
@@ -299,4 +335,8 @@ public class LibaoDetailAdapter 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 (commentEntity == null) {
return;
}
- holder.commentContentTv.setText(commentEntity.getContent());
+ if (commentEntity.getParent() != null) {
+ holder.commentContentTv.setText("回复"+ commentEntity.getParent().getUser().getName() + ": " + commentEntity.getContent());
+ } else {
+ holder.commentContentTv.setText(commentEntity.getContent());
+ }
+
holder.commentLikeCountTv.setTextColor(mContext.getResources().getColor(R.color.hint));
holder.commentLikeIv.setImageResource(R.drawable.ic_like_unselect);
@@ -534,34 +529,7 @@ public class MessageDetailAdapter extends RecyclerView.Adapter= today && day < today + 86400 * 1000) {
- long min = new Date().getTime()/1000 - day/1000;
- int hour = (int) (min/ (60 * 60));
- if (hour == 0) {
- if (min < 60) {
- holder.commentTimeTv.setText("刚刚");
- } else {
- holder.commentTimeTv.setText(String.format(Locale.getDefault(), "%d分钟前", (int) (min / 60)));
- }
- } else {
- holder.commentTimeTv.setText(String.format(Locale.getDefault(), "%d小时前", hour));
- }
- } else if (day >= today - 86400 * 1000 && day < today) {
- format.applyPattern("HH:mm");
- holder.commentTimeTv.setText("昨天 ");
- } else {
- format.applyPattern("yyyy-MM-dd");
- holder.commentTimeTv.setText(format.format(day));
- }
- } catch (ParseException e) {
- e.printStackTrace();
- format.applyPattern("yyyy-MM-dd");
- holder.commentTimeTv.setText(format.format(commentEntity.getTime() * 1000));
- }
+ CommentUtils.setCommentTime(holder.commentTimeTv, commentEntity.getTime());
final CommentEntity finalCommentEntity = commentEntity;
final boolean finalIsHotComment = isHotComment;
@@ -636,42 +604,74 @@ public class MessageDetailAdapter extends RecyclerView.Adapter dialogType = new ArrayList<>();
+ dialogType.add("回复");
+ dialogType.add("复制");
+ dialogType.add("举报");
+
+ if (commentEntity.getParent() != null) {
+ dialogType.add("查看对话");
+ }
+
+ for (String s : dialogType) {
+ final TextView reportTv = new TextView(mContext);
+ reportTv.setPadding(DisplayUtils.dip2px(mContext, 20), DisplayUtils.dip2px(mContext, 12),
+ 0, DisplayUtils.dip2px(mContext, 12));
+ reportTv.setText(s);
+ reportTv.setTextSize(17);
+ reportTv.setTextColor(mContext.getResources().getColor(R.color.title));
+ reportTv.setBackgroundResource(R.drawable.textview_white_style);
+ int widthPixels = mContext.getResources().getDisplayMetrics().widthPixels;
+ reportTv.setLayoutParams(new LinearLayout.LayoutParams((widthPixels * 9)/10,
+ LinearLayout.LayoutParams.WRAP_CONTENT));
+ container.addView(reportTv);
+
+ reportTv.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ dialog.cancel();
+ switch (reportTv.getText().toString()) {
+ case "回复":
+ mCallBackListener.showSoftInput(commentEntity);
+ break;
+ case "复制":
+ LibaoUtils.copyLink(commentEntity.getContent(), mContext);
+ break;
+ case "举报":
+ showReportTypeDialog(commentEntity);
+ break;
+ case "查看对话":
+ Intent intent = new Intent(mContext, CommentDetailActivity.class);
+ intent.putExtra("commentId", commentEntity.getId());
+ mContext.startActivity(intent);
+ break;
+ }
+
+
+ }
+ });
+ }
+
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(container);
dialog.show();
- reportTv.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- dialog.cancel();
- showReportTypeDialog(commentId);
-
- }
- });
-
}
- private void showReportTypeDialog(final String commentId) {
+ private void showReportTypeDialog(final CommentEntity commentEntity) {
final String[] arrReportType = new String[]{"垃圾广告营销", "恶意攻击谩骂", "淫秽色情信息",
"违法有害信息", "其它"};
int widthPixels = mContext.getResources().getDisplayMetrics().widthPixels;
@@ -699,7 +699,7 @@ public class MessageDetailAdapter extends RecyclerView.Adapter, List>() {
@Override
public List call(List list) {
@@ -143,6 +148,8 @@ public class SubjectAdapter extends RecyclerView.Adapter findCodes(String libaoId) {
+ List list = new ArrayList<>();
+ try {
+ list.addAll(dao.queryBuilder().where().eq("libaoId", libaoId).query());
+ return list;
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ return list;
+ }
}
diff --git a/app/src/main/java/com/gh/gamecenter/db/info/LibaoInfo.java b/app/src/main/java/com/gh/gamecenter/db/info/LibaoInfo.java
index 498b5e14db..bb6509c113 100644
--- a/app/src/main/java/com/gh/gamecenter/db/info/LibaoInfo.java
+++ b/app/src/main/java/com/gh/gamecenter/db/info/LibaoInfo.java
@@ -7,6 +7,7 @@ import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import java.io.Serializable;
+import java.util.UUID;
/**
* Created by khy on 2016/12/18.
@@ -15,7 +16,10 @@ import java.io.Serializable;
@DatabaseTable(tableName = "tb_libao")
public class LibaoInfo implements Serializable {
- @DatabaseField(id = true, columnName = "libaoId")
+ @DatabaseField(id = true, columnName = "id")
+ private String id;
+
+ @DatabaseField(columnName = "libaoId")
private String libaoId;
@DatabaseField(columnName = "content")
@@ -58,6 +62,14 @@ public class LibaoInfo implements Serializable {
}
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
public String getPackName() {
return packName;
}
@@ -169,6 +181,7 @@ public class LibaoInfo implements Serializable {
} else {
libaoInfo.setLibaoId(libaoEntity.getId());
}
+ libaoInfo.setId(UUID.randomUUID().toString().replaceAll("-", ""));
libaoInfo.setContent(libaoEntity.getContent());
libaoInfo.setIcon(libaoEntity.getIcon());
libaoInfo.setName(libaoEntity.getName());
diff --git a/app/src/main/java/com/gh/gamecenter/entity/CalendarEntity.java b/app/src/main/java/com/gh/gamecenter/entity/CalendarEntity.java
new file mode 100644
index 0000000000..abc2806238
--- /dev/null
+++ b/app/src/main/java/com/gh/gamecenter/entity/CalendarEntity.java
@@ -0,0 +1,29 @@
+package com.gh.gamecenter.entity;
+
+import java.util.List;
+
+/**
+ * Created by khy on 2017/3/28.
+ */
+public class CalendarEntity {
+
+ private int day;
+
+ private List server;
+
+ public int getDay() {
+ return day;
+ }
+
+ public void setDay(int day) {
+ this.day = day;
+ }
+
+ public List getServer() {
+ return server;
+ }
+
+ public void setServer(List server) {
+ this.server = server;
+ }
+}
diff --git a/app/src/main/java/com/gh/gamecenter/entity/CommentEntity.java b/app/src/main/java/com/gh/gamecenter/entity/CommentEntity.java
index 5b4fd13b2e..692ab463e9 100644
--- a/app/src/main/java/com/gh/gamecenter/entity/CommentEntity.java
+++ b/app/src/main/java/com/gh/gamecenter/entity/CommentEntity.java
@@ -12,6 +12,8 @@ public class CommentEntity {
private UserEntity user;
+ private ParentEntity parent;
+
private String content;
private int vote;
@@ -57,4 +59,24 @@ public class CommentEntity {
public void setTime(long time) {
this.time = time;
}
+
+ public ParentEntity getParent() {
+ return parent;
+ }
+
+ public void setParent(ParentEntity parent) {
+ this.parent = parent;
+ }
+
+ public class ParentEntity {
+ private UserEntity user;
+
+ public UserEntity getUser() {
+ return user;
+ }
+
+ public void setUser(UserEntity user) {
+ this.user = user;
+ }
+ }
}
diff --git a/app/src/main/java/com/gh/gamecenter/entity/GameDetailEntity.java b/app/src/main/java/com/gh/gamecenter/entity/GameDetailEntity.java
index 1fa355808e..f5fd778dd4 100644
--- a/app/src/main/java/com/gh/gamecenter/entity/GameDetailEntity.java
+++ b/app/src/main/java/com/gh/gamecenter/entity/GameDetailEntity.java
@@ -8,22 +8,44 @@ import java.util.List;
public class GameDetailEntity {
private List serverInfo;
+
private ArrayList tag;
+
private TipsEntity tips;
+
private List news;
+
private ArrayList gallery;
+
private String des;
+
@SerializedName("d_button_add_word")
private String downloadAddWord;
+
@SerializedName("article_types")
private ArrayList articleTypes;
+
@SerializedName("share_code")
private String shareCode;
+
@SerializedName("download_off_text")
private String downloadOffText;
+
@SerializedName("skin_test")
private boolean isSkinTest;
+ private Contact contact;
+
+ private List notice;
+
+ @SerializedName("type_tag")
+ private List gameTag;
+
+ @SerializedName("server")
+ private List kaiFuServer;
+
+ private String fulishuoming;
+
public boolean isSkinTest() {
return isSkinTest;
}
@@ -111,4 +133,139 @@ public class GameDetailEntity {
public void setTips(TipsEntity tips) {
this.tips = tips;
}
+
+ public List getNotice() {
+ return notice;
+ }
+
+ public void setNotice(List notice) {
+ this.notice = notice;
+ }
+
+ public String getFulishuoming() {
+ return fulishuoming;
+ }
+
+ public void setFulishuoming(String fulishuoming) {
+ this.fulishuoming = fulishuoming;
+ }
+
+ public Contact getContact() {
+ return contact;
+ }
+
+ public void setContact(Contact contact) {
+ this.contact = contact;
+ }
+
+ public List getGameTag() {
+ return gameTag;
+ }
+
+ public void setGameTag(List gameTag) {
+ this.gameTag = gameTag;
+ }
+
+ public List getKaiFuServer() {
+ return kaiFuServer;
+ }
+
+ public void setKaiFuServer(List kaiFuServer) {
+ this.kaiFuServer = kaiFuServer;
+ }
+
+ public class Contact {
+
+ private Service service;
+
+ private Player player;
+
+ public void setService(Service service) {
+ this.service = service;
+ }
+
+ public Service getService() {
+ return service;
+ }
+
+ public void setPlayer(Player player) {
+ this.player = player;
+ }
+
+ public Player getPlayer() {
+ return player;
+ }
+
+ }
+
+ public class Service {
+
+ private String des;
+
+ private String qq;
+
+ public void setDes(String des) {
+ this.des = des;
+ }
+
+ public String getDes() {
+ return des;
+ }
+
+ public void setQq(String qq) {
+ this.qq = qq;
+ }
+
+ public String getQq() {
+ return qq;
+ }
+
+ }
+
+ public class Player {
+
+ private String des;
+
+ private String qq;
+
+ public void setDes(String des) {
+ this.des = des;
+ }
+
+ public String getDes() {
+ return des;
+ }
+
+ public void setQq(String qq) {
+ this.qq = qq;
+ }
+
+ public String getQq() {
+ return qq;
+ }
+ }
+
+ public class Notice {
+
+ @SerializedName("article_id")
+ private String articleId;
+
+ private String title;
+
+ public String getArticleId() {
+ return articleId;
+ }
+
+ public void setArticleId(String articleId) {
+ this.articleId = articleId;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+ }
}
diff --git a/app/src/main/java/com/gh/gamecenter/entity/KaiFuServerEntity.java b/app/src/main/java/com/gh/gamecenter/entity/KaiFuServerEntity.java
index f370ea9876..33e5431877 100644
--- a/app/src/main/java/com/gh/gamecenter/entity/KaiFuServerEntity.java
+++ b/app/src/main/java/com/gh/gamecenter/entity/KaiFuServerEntity.java
@@ -7,7 +7,7 @@ public class KaiFuServerEntity {
private String note;
- private int time;
+ private long time;
private String type;
@@ -19,11 +19,11 @@ public class KaiFuServerEntity {
return note;
}
- public void setTime(int time) {
+ public void setTime(long time) {
this.time = time;
}
- public int getTime() {
+ public long getTime() {
return time;
}
diff --git a/app/src/main/java/com/gh/gamecenter/entity/NewsEntity.java b/app/src/main/java/com/gh/gamecenter/entity/NewsEntity.java
index 74a1ced460..6b34952af2 100644
--- a/app/src/main/java/com/gh/gamecenter/entity/NewsEntity.java
+++ b/app/src/main/java/com/gh/gamecenter/entity/NewsEntity.java
@@ -4,7 +4,7 @@ import com.google.gson.annotations.SerializedName;
public class NewsEntity {
- @SerializedName("_id")
+ @SerializedName(value = "_id", alternate = "article_id")
private String id;
private String type;
@@ -27,6 +27,8 @@ public class NewsEntity {
@SerializedName("game_name")
private String gameName;
+ private long overtime;
+
public int getViews() {
return views;
}
@@ -106,4 +108,12 @@ public class NewsEntity {
public void setGameName(String gameName) {
this.gameName = gameName;
}
+
+ public long getOvertime() {
+ return overtime;
+ }
+
+ public void setOvertime(long overtime) {
+ this.overtime = overtime;
+ }
}
diff --git a/app/src/main/java/com/gh/gamecenter/entity/UserEntity.java b/app/src/main/java/com/gh/gamecenter/entity/UserEntity.java
index f76e97664b..5922e40c57 100644
--- a/app/src/main/java/com/gh/gamecenter/entity/UserEntity.java
+++ b/app/src/main/java/com/gh/gamecenter/entity/UserEntity.java
@@ -1,5 +1,7 @@
package com.gh.gamecenter.entity;
+import com.google.gson.annotations.SerializedName;
+
/**
* Created by khy on 2016/11/8.
*/
@@ -9,6 +11,9 @@ public class UserEntity {
private String name;
+ @SerializedName("_id")
+ private String id; // 用于parent的user
+
public void setIcon(String icon) {
this.icon = icon;
}
@@ -24,4 +29,12 @@ public class UserEntity {
public String getName() {
return name;
}
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
}
diff --git a/app/src/main/java/com/gh/gamecenter/eventbus/EBMoveTop.java b/app/src/main/java/com/gh/gamecenter/eventbus/EBMoveTop.java
new file mode 100644
index 0000000000..c4335777b0
--- /dev/null
+++ b/app/src/main/java/com/gh/gamecenter/eventbus/EBMoveTop.java
@@ -0,0 +1,43 @@
+package com.gh.gamecenter.eventbus;
+
+/**
+ * Created by khy on 2017/3/24.
+ */
+public class EBMoveTop {
+
+ private String type;
+ private int visibility;
+ private int topMargin;
+
+ public EBMoveTop(String type, int visibility, int topMargin) {
+ super();
+ this.type = type;
+ this.visibility = visibility;
+ this.topMargin = topMargin;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public int getVisibility() {
+ return visibility;
+ }
+
+ public void setVisibility(int visibility) {
+ this.visibility = visibility;
+ }
+
+ public int getTopMargin() {
+ return topMargin;
+ }
+
+ public void setTopMargin(int topMargin) {
+ this.topMargin = topMargin;
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/gh/gamecenter/eventbus/EBSlide.java b/app/src/main/java/com/gh/gamecenter/eventbus/EBSlide.java
new file mode 100644
index 0000000000..e99a5a85e2
--- /dev/null
+++ b/app/src/main/java/com/gh/gamecenter/eventbus/EBSlide.java
@@ -0,0 +1,39 @@
+package com.gh.gamecenter.eventbus;
+
+public class EBSlide {
+ private int distance;
+ private int position;
+ private boolean isReset;
+
+ public EBSlide(int distance, int position, boolean isReset) {
+ super();
+ this.distance = distance;
+ this.position = position;
+ this.isReset = isReset;
+ }
+
+ public int getDistance() {
+ return distance;
+ }
+
+ public void setDistance(int distance) {
+ this.distance = distance;
+ }
+
+ public int getPosition() {
+ return position;
+ }
+
+ public void setPosition(int position) {
+ this.position = position;
+ }
+
+ public boolean isReset() {
+ return isReset;
+ }
+
+ public void setReset(boolean isReset) {
+ this.isReset = isReset;
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/gh/gamecenter/gamedetail/FuLiAdapter.java b/app/src/main/java/com/gh/gamecenter/gamedetail/FuLiAdapter.java
new file mode 100644
index 0000000000..7a323d1e28
--- /dev/null
+++ b/app/src/main/java/com/gh/gamecenter/gamedetail/FuLiAdapter.java
@@ -0,0 +1,522 @@
+package com.gh.gamecenter.gamedetail;
+
+import android.content.Context;
+import android.graphics.Color;
+import android.support.v7.widget.GridLayoutManager;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.text.Html;
+import android.text.TextUtils;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import com.facebook.drawee.view.SimpleDraweeView;
+import com.gh.base.AppController;
+import com.gh.common.util.DisplayUtils;
+import com.gh.common.util.ImageUtils;
+import com.gh.common.util.NewsUtils;
+import com.gh.common.util.QQUtils;
+import com.gh.common.util.Utils;
+import com.gh.common.view.GridDivider;
+import com.gh.common.view.MarqueeView;
+import com.gh.gamecenter.R;
+import com.gh.gamecenter.adapter.viewholder.ReuseViewHolder;
+import com.gh.gamecenter.db.LibaoDao;
+import com.gh.gamecenter.db.info.LibaoInfo;
+import com.gh.gamecenter.entity.GameDetailEntity;
+import com.gh.gamecenter.entity.GameEntity;
+import com.gh.gamecenter.entity.LibaoEntity;
+import com.gh.gamecenter.entity.LibaoStatusEntity;
+import com.gh.gamecenter.entity.NewsEntity;
+import com.gh.gamecenter.entity.TagEntity;
+import com.gh.gamecenter.retrofit.Response;
+import com.gh.gamecenter.retrofit.RetrofitManager;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import rx.android.schedulers.AndroidSchedulers;
+import rx.functions.Func1;
+import rx.schedulers.Schedulers;
+
+/**
+ * Created by khy on 2017/3/27.
+ */
+public class FuLiAdapter extends RecyclerView.Adapter{
+
+ private Context mContext;
+
+ private RecyclerView mRecyclerView;
+
+ private FuLiFragment fuLiFragment;
+
+ private GameDetailEntity mGameDetailEntity;
+ private GameEntity mGameEntity;
+
+ private List mLibaoList;
+
+ private int position_plugin = -1;
+ private int position_fuli = -1;
+ private int position_libao = -1;
+ private int position_kaifu = -1;
+ private int position_notice = -1;
+
+ private boolean isOpenLibaoList;
+
+ public FuLiAdapter(Context context, RecyclerView recyclerView, FuLiFragment fuLiFragment) {
+ this.mContext = context;
+ this.mRecyclerView = recyclerView;
+ this.fuLiFragment = fuLiFragment;
+
+ isOpenLibaoList = false;
+
+ mGameDetailEntity = (GameDetailEntity) AppController.get("GameDetailEntity", false);
+ mGameEntity = (GameEntity) AppController.get("GameEntity", false);
+ initPosition();
+ addLibaoList();
+ }
+
+ private void addLibaoList(){
+ if (mGameEntity == null) return;
+
+ RetrofitManager.getLibao().getLibaoByGame(mGameEntity.getId(), 0 , 128)
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(new Response>(){
+ @Override
+ public void onResponse(List response) {
+ getLibaoStatus(response);
+ }
+
+ @Override
+ public void onError(Throwable e) {
+ super.onError(e);
+ }
+ });
+ }
+
+ //获取礼包状态
+ private void getLibaoStatus(final List response) {
+ StringBuilder builder = new StringBuilder();
+ for (int i = 0, size = response.size(); i < size; i++) {
+ builder.append(response.get(i).getId());
+ builder.append("-");
+ }
+ if (builder.length() == 0) {
+ return;
+ }
+
+ builder.deleteCharAt(builder.length() - 1);
+ String ids = builder.toString();
+
+ RetrofitManager.getLibao().getLibaoStatus(ids)
+ .map(new Func1, Object>() {
+ @Override
+ public Object call(List list) {
+ LibaoDao libaoDao = new LibaoDao(mContext);
+ for (LibaoInfo libaoInfo : libaoDao.getAll()) {
+ for (int i = 0; i < list.size(); i++) {
+ if (libaoInfo.getLibaoId().equals(list.get(i).getId())) {
+ if ("ling".equals(libaoInfo.getStatus()) || "linged".equals(libaoInfo.getStatus())) {
+ list.get(i).setStatus("linged");
+ } else {
+ list.get(i).setStatus("taoed");
+ }
+ }
+ }
+ }
+ for (int i = 0; i < response.size(); i++) {
+ LibaoEntity libaoEntity = response.get(i);
+ for (LibaoStatusEntity libaoStatusEntity : list) {
+ if (libaoStatusEntity.getId().equals(libaoEntity.getId())) {
+ if ("finish".equals(libaoStatusEntity.getStatus())) {
+ response.remove(i);
+ i--;
+ break;
+ }
+ if (libaoEntity.getId().equals(libaoStatusEntity.getId())) {
+ libaoEntity.setStatus(libaoStatusEntity.getStatus());
+ libaoEntity.setAvailable(libaoStatusEntity.getAvailable());
+ libaoEntity.setTotal(libaoStatusEntity.getTotal());
+ }
+ }
+ }
+ }
+ if (response.size() != 0) {
+ mLibaoList = response;
+ initPosition();
+ }
+ return null;
+ }
+ })
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(new Response