Explorar el Código

首页搜索修改为随着上下滑动,且风格变化;
游戏详情页面显示主背景图片或者视频,视频可以点击进入播放界面

zengjiebin hace 7 años
padre
commit
058b279034

+ 2 - 1
app/src/main/java/com/sheep/gamegroup/util/CommonUtil.java

@@ -1891,7 +1891,8 @@ public class CommonUtil {
                         View tabView = mTabStrip.getChildAt(i);
 
                         //拿到tabView的mTextView属性  tab的字数不固定一定用反射取mTextView
-                        Field mTextViewField = tabView.getClass().getDeclaredField("mTextView");
+                        Field mTextViewField = tabView.getClass().getDeclaredField("textView");//com.android.support:design:28.0.0
+//                        Field mTextViewField = tabView.getClass().getDeclaredField("mTextView");//com.android.support:design:27.1.0
                         mTextViewField.setAccessible(true);
 
                         TextView mTextView = (TextView) mTextViewField.get(tabView);

+ 1 - 1
app/src/main/java/com/sheep/gamegroup/util/SysAppUtil.java

@@ -454,7 +454,7 @@ public class SysAppUtil {
         }
         if(TestUtil.isSheep()) {
             checkUpdateNewVersion(activity, ignoreMd5, action1);
-        } else {
+        } else if(!TestUtil.isDev()) {
             TestUtil.checkUpdateFromJenkins(activity, ignoreMd5, action1);
         }
     }

+ 6 - 0
app/src/main/java/com/sheep/gamegroup/util/ViewUtil.java

@@ -257,6 +257,12 @@ public class ViewUtil {
         }
     }
 
+    //刷新RecyclerView的adapter
+    public static void notifyDataSetChanged(RecyclerView recyclerView) {
+        if(recyclerView != null && recyclerView.getAdapter() != null)
+            recyclerView.getAdapter().notifyDataSetChanged();
+    }
+
     /**
      * 主页抢任务,更换任务时,获取新的任务
      *

+ 25 - 3
app/src/main/java/com/sheep/gamegroup/view/activity/ActGcGameAppDetail.java

@@ -83,6 +83,10 @@ public class ActGcGameAppDetail extends BaseActivity {
     ViewPager viewPager;
     @BindView(R.id.gc_game_app_detail_iv)
     ImageView gc_game_app_detail_iv;
+    @BindView(R.id.gc_game_app_detail_iv2)
+    ImageView gc_game_app_detail_iv2;
+    @BindView(R.id.gc_game_app_detail_play_iv)
+    ImageView gc_game_app_detail_play_iv;
     @BindView(R.id.gc_game_app_detail_icon)
     ImageView gc_game_app_detail_icon;
     @BindView(R.id.gc_game_app_detail_bt1)
@@ -159,7 +163,7 @@ public class ActGcGameAppDetail extends BaseActivity {
             gc_game_app_detail_bt1.setText(gameEntity.isIs_focus_game() ? R.string.has_focus : R.string.focus);
     }
     //加载游戏数据
-    private void loadData(GameEntity gameEntity) {
+    private void loadData(final GameEntity gameEntity) {
         this.gameEntity = gameEntity;
         //更新关注状态
         updateFocusTv();
@@ -172,7 +176,24 @@ public class ActGcGameAppDetail extends BaseActivity {
             CommonUtil.getInstance().reflex(tabLayout, this, true);
         }
         //加载游戏背景
-        ViewUtil.setImage(gc_game_app_detail_iv, gameEntity.getApp().getPictures());
+        if(TextUtils.isEmpty(gameEntity.getApp().getMain_publicize())){
+            ViewUtil.setImage(gc_game_app_detail_iv, gameEntity.getApp().getPictures());
+            ViewUtil.setVisibility(gc_game_app_detail_iv, true);
+            ViewUtil.setVisibility(gc_game_app_detail_iv2, false);
+        } else {
+            ViewUtil.setImage(gc_game_app_detail_iv2, gameEntity.getApp().getMain_publicize());
+            ViewUtil.setVisibility(gc_game_app_detail_iv, false);
+            ViewUtil.setVisibility(gc_game_app_detail_iv2, true);
+            if(gameEntity.getApp().getMain_publicize().endsWith(".mp4")) {
+                gc_game_app_detail_play_iv.setVisibility(View.VISIBLE);
+                gc_game_app_detail_play_iv.setOnClickListener(new View.OnClickListener() {
+                    @Override
+                    public void onClick(View view) {
+                        Jump2View.getInstance().goActPlayVideo(gameEntity.getApp().getMain_publicize(), true);
+                    }
+                });
+            }
+        }
         //加载游戏图标
         ViewUtil.setGameImage(gc_game_app_detail_icon, gameEntity.getApp().getIcon());
         //加载游戏名字
@@ -181,7 +202,8 @@ public class ActGcGameAppDetail extends BaseActivity {
         if(gameEntity.getApp().getTags() != null) {
             tagList.addAll(gameEntity.getApp().getTags());
             ListUtil.removeNull(tagList);
-            recyclerView.getAdapter().notifyDataSetChanged();
+            if(recyclerView.getAdapter() != null)
+                recyclerView.getAdapter().notifyDataSetChanged();
         }
         //下载按钮
         CommonUtil.getInstance().palyGameDetailBtnValue(this, gameEntity, gc_game_app_detail_bt2, 0);

+ 2 - 0
app/src/main/java/com/sheep/gamegroup/view/activity/ActPlayVideo.java

@@ -1,5 +1,6 @@
 package com.sheep.gamegroup.view.activity;
 
+import android.annotation.SuppressLint;
 import android.content.Context;
 import android.media.AudioManager;
 import android.media.MediaPlayer;
@@ -59,6 +60,7 @@ public class ActPlayVideo extends BaseActivity implements MediaPlayer.OnInfoList
         videoView.setVideoURI(uri);
     }
 
+    @SuppressLint("ClickableViewAccessibility")
     @Override
     public void initListener() {
         mGestureDetector = new GestureDetector(getApplicationContext(), mGestureListener);

+ 6 - 6
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtGcGameAppDetail.java

@@ -113,10 +113,10 @@ public class FgtGcGameAppDetail extends BaseRefreshLoadMoreFragment implements A
             pictureList.clear();
             ListUtil.addAll(pictureList, pictures.split(";"));
             ListUtil.removeNull(pictureList);
-            gc_game_app_detail_pic_list.setVisibility(View.VISIBLE);
-            gc_game_app_detail_pic_list.getAdapter().notifyDataSetChanged();
+            ViewUtil.setVisibility(gc_game_app_detail_pic_list, true);
+            ViewUtil.notifyDataSetChanged(gc_game_app_detail_pic_list);
         } else {
-            gc_game_app_detail_pic_list.setVisibility(View.GONE);
+            ViewUtil.setVisibility(gc_game_app_detail_pic_list, false);
         }
         String intro = gameApp.getIntro();
         if (!TextUtils.isEmpty(intro)) {
@@ -167,7 +167,7 @@ public class FgtGcGameAppDetail extends BaseRefreshLoadMoreFragment implements A
             }
         }).setSort(SORT_GAME_INFO));
         Collections.sort(gameInfoListArrayList);
-        recyclerView.getAdapter().notifyDataSetChanged();
+        ViewUtil.notifyDataSetChanged(recyclerView);
     }
 
     //加载相关游戏与热门试玩数据列表
@@ -181,7 +181,7 @@ public class FgtGcGameAppDetail extends BaseRefreshLoadMoreFragment implements A
                         if (!ListUtil.isEmpty(newList)) {
                             gameInfoListArrayList.add(new GameInfoList(name, new AdpGcGameAppList(SheepApp.getInstance(), R.layout.item_gc_game_app_63, newList)).setHorizontal().setSort(sort));
                             Collections.sort(gameInfoListArrayList);
-                            recyclerView.getAdapter().notifyDataSetChanged();
+                            ViewUtil.notifyDataSetChanged(recyclerView);
                         }
                         refreshOrLoadMoreComplete();
                     }
@@ -240,7 +240,7 @@ public class FgtGcGameAppDetail extends BaseRefreshLoadMoreFragment implements A
             gameInfoListArrayList.add(new GameInfoList("用户评价", new AdpGcGameAppComment(userCommentList)).setSort(SORT_USER_COMMENT));
             Collections.sort(gameInfoListArrayList);
         }
-        recyclerView.getAdapter().notifyDataSetChanged();
+        ViewUtil.notifyDataSetChanged(recyclerView);
     }
 
     //游戏介绍

+ 33 - 3
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtSmallSheep.java

@@ -9,6 +9,8 @@ import android.content.Context;
 import android.content.DialogInterface;
 import android.graphics.Color;
 import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.GradientDrawable;
 import android.os.Build;
 import android.os.Handler;
 import android.os.Looper;
@@ -77,6 +79,7 @@ import com.sheep.gamegroup.util.DataUtil;
 import com.sheep.gamegroup.util.GlideImageLoader;
 import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.gamegroup.util.ListUtil;
+import com.sheep.gamegroup.util.LogUtil;
 import com.sheep.gamegroup.util.MyGridview;
 import com.sheep.gamegroup.util.MyListview;
 import com.sheep.gamegroup.util.RefreshUtil;
@@ -199,6 +202,10 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
     TextView test_change_user;
     @BindView(R.id.list_title)
     LinearLayout listTitle;
+    @BindView(R.id.to_search_but_rl)
+    View to_search_but_rl;
+    @BindView(R.id.to_search_but)
+    LinearLayout to_search_but;
     @BindView(R.id.title_car)
     LinearLayout titleCardLayout;
     /* 记录滑动坐标的数组 */
@@ -355,7 +362,7 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
         });
     }
 
-    @OnClick(R.id.to_search_but)
+    @OnClick(R.id.to_search_but_rl)
     public void toSearchActivity() {
         Jump2View.getInstance().goAppTaskSearch(activity, null);
     }
@@ -609,6 +616,8 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
     }
 
 
+    //banner的高度
+    private int bannerHeight = G.WIDTH * 17 / 40;
     public void initView() {
         try {
             EventBus.getDefault().register(this);
@@ -623,7 +632,8 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
                 .inject(this);
         recyclerInitView();
         ViewGroup.LayoutParams bannerLayoutParams = banner.getLayoutParams();
-        bannerLayoutParams.height = G.WIDTH * 17 / 40;//图片比例发生变化 :306*720
+        bannerHeight = G.WIDTH * 17 / 40;
+        bannerLayoutParams.height = bannerHeight;//图片比例发生变化 :306*720
 //        bannerLayoutParams.height = G.WIDTH * 25 / 72;
         banner.setLayoutParams(bannerLayoutParams);
 
@@ -730,13 +740,33 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
     public void initListener() {
         scrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
             @Override
-            public void onScrollChange(NestedScrollView nestedScrollView, int i, int i1, int i2, int i3) {
+            public void onScrollChange(NestedScrollView nestedScrollView, int x, int y, int oldX, int oldY) {
                 listTitle.getLocationInWindow(locate);
                 if (locate[1] < 0 && titleCardLayout.getVisibility() == View.GONE) {
                     titleCardLayout.setVisibility(View.VISIBLE);
                 } else if (locate[1] > 20 && titleCardLayout.getVisibility() == View.VISIBLE) {
                     titleCardLayout.setVisibility(View.GONE);
                 }
+                //设置搜索框颜色变化
+                float ratio = Math.min(bannerHeight, y) * 1.0f / bannerHeight;
+                to_search_but_rl.setBackgroundColor(Color.argb((int) (ratio * 255), 255, 255, 255));
+                float colorRatio = 1 - ratio * 0.26f;
+                Drawable bg = to_search_but.getBackground();
+                if(bg instanceof GradientDrawable){
+                    GradientDrawable drawable = (GradientDrawable) bg;
+                    drawable.setColor(Color.argb(216, (int) (colorRatio * 255), (int) (colorRatio * 255), (int) (colorRatio * 255)));
+                }
+                int[] minPerS = {102, 153};
+                for (int i = 0; i < to_search_but.getChildCount(); i++) {
+                    int minPer = minPerS[i % minPerS.length];
+                    int per = (int) ((255 - minPer) * ratio + minPer);
+                    int textColor = Color.argb(255, per, per, per);
+                    View childView = to_search_but.getChildAt(i);
+                    if(childView instanceof TextView){
+                        ((TextView) childView).setTextColor(textColor);
+                    }
+                }
+//                LogUtil.println("FgtSmallSheep", "onScrollChange", x, y, oldX, oldY, locate[0], locate[1]);
             }
         });
         scrollView.setOnTouchListener(new View.OnTouchListener() {

+ 18 - 3
app/src/main/res/layout/act_gc_game_app_detail.xml

@@ -29,14 +29,22 @@
 
                 <RelativeLayout
                     android:layout_width="match_parent"
-                    android:layout_height="216dp">
+                    android:layout_height="wrap_content">
 
                     <ImageView
                         android:id="@+id/gc_game_app_detail_iv"
                         android:layout_width="match_parent"
-                        android:layout_height="match_parent"
+                        android:layout_height="216dp"
                         android:scaleType="centerCrop"
-                        android:src="@drawable/icon" />
+                        android:src="@drawable/loading_01" />
+                    <ImageView
+                        android:id="@+id/gc_game_app_detail_iv2"
+                        android:layout_width="match_parent"
+                        android:layout_height="wrap_content"
+                        android:adjustViewBounds="true"
+                        android:visibility="gone"
+                        android:scaleType="fitXY"
+                        android:src="@drawable/loading_01" />
 
                     <ImageView
                         android:layout_width="?attr/actionBarSize"
@@ -56,6 +64,13 @@
                         android:onClick="onClickShareImg"
                         android:scaleType="centerInside"
                         android:src="@mipmap/share" />
+                    <ImageView
+                        android:id="@+id/gc_game_app_detail_play_iv"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_centerInParent="true"
+                        android:visibility="gone"
+                        android:src="@drawable/ic_play_but_image"/>
 
                 </RelativeLayout>
 

+ 1 - 1
app/src/main/res/layout/fgt_game_center.xml

@@ -6,11 +6,11 @@
     android:orientation="vertical"
     tools:context="com.sheep.gamegroup.view.activity.ActGameCenter">
 
-    <include layout="@layout/title" />
     <View
         android:id="@+id/fgt_game_center_top"
         android:layout_width="match_parent"
         android:layout_height="20dp" />
+    <include layout="@layout/title" />
     <android.support.v4.view.ViewPager
         android:id="@+id/act_game_center_vp"
         android:layout_width="match_parent"

+ 38 - 36
app/src/main/res/layout/homepage_act_layout.xml

@@ -32,42 +32,8 @@
                     android:visibility="gone" />
 
                 <include layout="@layout/check_net_view" />
-                <RelativeLayout
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content">
-
-                    <include layout="@layout/homepage_item_banner" />
-
-                    <LinearLayout
-                        android:id="@+id/to_search_but"
-                        android:layout_width="match_parent"
-                        android:layout_height="30dp"
-                        android:layout_alignParentTop="true"
-                        android:layout_marginStart="16dp"
-                        android:layout_marginTop="25dp"
-                        android:layout_marginEnd="16dp"
-                        android:paddingStart="16dp"
-                        android:paddingEnd="13dp"
-                        android:background="@drawable/shape_main_search_bar_radius"
-                        android:gravity="center"
-                        android:orientation="horizontal">
-
-                        <TextView
-                            android:layout_width="0dp"
-                            android:layout_height="wrap_content"
-                            android:layout_weight="1"
-                            android:text="@string/search_hint_txt"
-                            android:textColor="#999"
-                            android:textSize="14sp" />
-
-                        <TextView
-                            android:layout_width="wrap_content"
-                            android:layout_height="wrap_content"
-                            android:text="@string/search_but_text"
-                            android:textColor="#666666"
-                            android:textSize="14sp" />
-                    </LinearLayout>
-                </RelativeLayout>
+
+                <include layout="@layout/homepage_item_banner" />
 
                 <include
                     layout="@layout/homepage_item_gridview_listview"
@@ -211,4 +177,40 @@
         layout="@layout/view_float_title_card"
         android:visibility="visible" />
 
+    <RelativeLayout
+        android:id="@+id/to_search_but_rl"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:paddingBottom="10dp">
+
+        <LinearLayout
+            android:id="@+id/to_search_but"
+            android:layout_width="match_parent"
+            android:layout_height="30dp"
+            android:layout_alignParentTop="true"
+            android:layout_marginStart="16dp"
+            android:layout_marginTop="25dp"
+            android:layout_marginEnd="16dp"
+            android:background="@drawable/shape_main_search_bar_radius"
+            android:gravity="center"
+            android:orientation="horizontal"
+            android:paddingStart="16dp"
+            android:paddingEnd="13dp">
+
+            <TextView
+                android:layout_width="0dp"
+                android:layout_height="wrap_content"
+                android:layout_weight="1"
+                android:text="@string/search_hint_txt"
+                android:textColor="#999999"
+                android:textSize="13sp" />
+
+            <TextView
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="@string/search_but_text"
+                android:textColor="#666666"
+                android:textSize="14sp" />
+        </LinearLayout>
+    </RelativeLayout>
 </RelativeLayout>

+ 2 - 3
app/src/main/res/layout/view_float_title_card.xml

@@ -4,15 +4,14 @@
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="vertical"
-    android:background="@color/white"
     android:visibility="visible">
 
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:background="#ffffff"
         android:orientation="vertical"
-        android:paddingTop="30dp"
+        android:layout_marginTop="60dp"
+        android:background="@color/white"
         android:paddingBottom="10dp">
 
         <LinearLayout