billyyoyo лет назад: 6
Родитель
Сommit
7a09500581

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

@@ -36,12 +36,6 @@ public enum MainTab {
         @Override
         @Override
         public Fragment getFragment() {
         public Fragment getFragment() {
             return new FgtWrapper();
             return new FgtWrapper();
-//            return SkinUtil.isLoadNewYearSkin() ? new FgtAskGetMoneyNewYear() : new FgtAskGetMoney();
-//            if (EmulatorDetectUtil.isEmulator()) {
-//                return FgtWeb.newInstance(new WebParams(Config.getUrlByPath(Config.PATH_SMALL_SHEEP_INVITATION_HOME), "邀请赚钱"));
-//            } else {
-//                return FgtWebX5.newInstance(new WebParams(Config.getUrlByPath(Config.PATH_SMALL_SHEEP_INVITATION_HOME), "邀请赚钱"));
-//            }
         }
         }
 
 
         @Override
         @Override

+ 19 - 20
app/src/main/java/com/sheep/gamegroup/view/activity/ActMain.java

@@ -52,6 +52,7 @@ import com.sheep.gamegroup.util.UMConfigUtils;
 import com.sheep.gamegroup.util.ViewUtil;
 import com.sheep.gamegroup.util.ViewUtil;
 import com.sheep.gamegroup.util.upfile.UpFileListener;
 import com.sheep.gamegroup.util.upfile.UpFileListener;
 import com.sheep.gamegroup.util.upfile.UpFileUtils;
 import com.sheep.gamegroup.util.upfile.UpFileUtils;
+import com.sheep.gamegroup.view.customview.TouchFrameLayout;
 import com.sheep.gamegroup.view.dialog.DialogGameOrTaskOrGift;
 import com.sheep.gamegroup.view.dialog.DialogGameOrTaskOrGift;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.SheepApp;
@@ -90,6 +91,18 @@ public class ActMain extends BaseActYmPermissionCheck {
 
 
     public static WeakReference<View> tabBtn1, tabBtn2;
     public static WeakReference<View> tabBtn1, tabBtn2;
 
 
+    public static final String FIRST_SHOW_MAIN = "first_show_main";//是否是第一次显示主页
+
+    @BindView(R.id.frame_container)
+    TouchFrameLayout frame_container;
+    @BindView(R.id.tab_container)
+    LinearLayout tab_container;
+    @BindView(R.id.main_layout)
+    RelativeLayout main_layout;
+    @BindView(R.id.main_header)
+    View main_header;
+
+
     @Override
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         StatusBarUtils.setTranslucent(this);
         StatusBarUtils.setTranslucent(this);
@@ -151,17 +164,6 @@ public class ActMain extends BaseActYmPermissionCheck {
         return false;
         return false;
     }
     }
 
 
-    public static final String FIRST_SHOW_MAIN = "first_show_main";//是否是第一次显示主页
-
-    @BindView(R.id.frame_container)
-    FrameLayout frame_container;
-    @BindView(R.id.tab_container)
-    LinearLayout tab_container;
-    @BindView(R.id.main_layout)
-    RelativeLayout main_layout;
-    @BindView(R.id.main_header)
-    View main_header;
-
     @Override
     @Override
     protected int getLayoutId() {
     protected int getLayoutId() {
         return R.layout.act_bottom_bar;
         return R.layout.act_bottom_bar;
@@ -171,15 +173,12 @@ public class ActMain extends BaseActYmPermissionCheck {
     public void initView() {
     public void initView() {
         EventBus.getDefault().register(this);
         EventBus.getDefault().register(this);
         initFragments();
         initFragments();
-//        initFind();
-//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && G.checkDeviceHasNavigationBar(this)) {
-//            main_layout.setPadding(0, 0, 0, G.getHasVirtualKey(this) - G.getNoHasVirtualKey(this));
-//        }
         if (!TestUtil.isDev())
         if (!TestUtil.isDev())
             CommonUtil.getInstance().initMiDong(this, DataUtil.getInstance().getUserId());
             CommonUtil.getInstance().initMiDong(this, DataUtil.getInstance().getUserId());
 
 
         tabBtn1 = new WeakReference<>(findViewById(R.id.tab_1));
         tabBtn1 = new WeakReference<>(findViewById(R.id.tab_1));
         tabBtn2 = new WeakReference<>(findViewById(R.id.tab_3));
         tabBtn2 = new WeakReference<>(findViewById(R.id.tab_3));
+        frame_container.setHookView(main_header);
     }
     }
 
 
     @Override
     @Override
@@ -263,7 +262,7 @@ public class ActMain extends BaseActYmPermissionCheck {
     }
     }
 
 
     public void switchFragment(int position) {
     public void switchFragment(int position) {
-        ViewUtil.setVisibility(main_header, position != 1);
+        frame_container.moveHook(position == 1 ? -1 : 1);
         View lastTab = ListUtil.getItem(tabs, lastPosition);
         View lastTab = ListUtil.getItem(tabs, lastPosition);
         View curTab = ListUtil.getItem(tabs, position);
         View curTab = ListUtil.getItem(tabs, position);
         if (lastTab != null) {
         if (lastTab != null) {
@@ -551,9 +550,9 @@ public class ActMain extends BaseActYmPermissionCheck {
     public void onActivityResult(int requestCode, int resultCode, Intent intent) {
     public void onActivityResult(int requestCode, int resultCode, Intent intent) {
         super.onActivityResult(requestCode, resultCode, intent);
         super.onActivityResult(requestCode, resultCode, intent);
         if (resultCode == RESULT_OK) {
         if (resultCode == RESULT_OK) {
-            if(requestCode == Constant.INTENT_CAPTURE_QRCODE){
+            if (requestCode == Constant.INTENT_CAPTURE_QRCODE) {
                 QRCodeCaptureHelper.handle(this, intent.getStringExtra(CodeUtils.RESULT_STRING));
                 QRCodeCaptureHelper.handle(this, intent.getStringExtra(CodeUtils.RESULT_STRING));
-            } else if(requestCode == Constant.INTENT_DETECT_FACE) {
+            } else if (requestCode == Constant.INTENT_DETECT_FACE) {
                 UpFileUtils.upImage(new File(intent.getStringExtra("bestPath")), new UpFileListener() {
                 UpFileUtils.upImage(new File(intent.getStringExtra("bestPath")), new UpFileListener() {
                     @Override
                     @Override
                     public void Success(String msg, int index) {
                     public void Success(String msg, int index) {
@@ -577,11 +576,11 @@ public class ActMain extends BaseActYmPermissionCheck {
         }
         }
     }
     }
 
 
-    public Fragment getMainFragment1(){
+    public Fragment getMainFragment1() {
         return getSupportFragmentManager().findFragmentByTag("fragment_0");
         return getSupportFragmentManager().findFragmentByTag("fragment_0");
     }
     }
 
 
-    public Fragment getMainFragment3(){
+    public Fragment getMainFragment3() {
         return getSupportFragmentManager().findFragmentByTag("fragment_2");
         return getSupportFragmentManager().findFragmentByTag("fragment_2");
     }
     }
 
 

+ 102 - 0
app/src/main/java/com/sheep/gamegroup/view/customview/TouchFrameLayout.java

@@ -0,0 +1,102 @@
+package com.sheep.gamegroup.view.customview;
+
+import android.content.Context;
+import android.support.v4.view.MotionEventCompat;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewConfiguration;
+import android.widget.FrameLayout;
+import android.widget.RelativeLayout;
+
+import com.kfzs.duanduan.cardview.ScreenUtil;
+import com.sheep.jiuyan.samllsheep.R;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+public class TouchFrameLayout extends FrameLayout {
+
+    private View hookView;
+
+    private float startX, startY;
+
+    private int max, min;
+
+    private int touchSlop;
+
+    public TouchFrameLayout(@NonNull Context context) {
+        super(context);
+        init(context);
+    }
+
+    public TouchFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
+        super(context, attrs);
+        init(context);
+    }
+
+    public TouchFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
+        super(context, attrs, defStyleAttr);
+        init(context);
+    }
+
+    private void init(Context ctx) {
+        max = ScreenUtil.dip2px(ctx, 72);
+        min = ScreenUtil.dip2px(ctx, 32);
+        ViewConfiguration viewConfiguration = ViewConfiguration.get(ctx);
+        touchSlop = viewConfiguration.getScaledTouchSlop();
+    }
+
+    public void setHookView(View hv) {
+        hookView = hv;
+    }
+
+    public void moveHook(float distance) {
+        if (hookView != null) {
+            if (distance > 0) {
+                ((RelativeLayout.LayoutParams) getLayoutParams()).topMargin = max;
+                hookView.setVisibility(VISIBLE);
+            } else {
+                hookView.setVisibility(GONE);
+                ((RelativeLayout.LayoutParams) getLayoutParams()).topMargin = min;
+            }
+        }
+    }
+
+    @Override
+    public boolean onInterceptTouchEvent(MotionEvent ev) {
+        if (hookView == null) {
+            return super.onInterceptTouchEvent(ev);
+        }
+        final int action = MotionEventCompat.getActionMasked(ev);
+        switch (action) {
+            case MotionEvent.ACTION_DOWN:
+                startX = ev.getRawX();
+                startY = ev.getRawY();
+                break;
+            case MotionEvent.ACTION_MOVE:
+                float distance = ev.getRawY() - startY;
+                if (distance > 0) {
+                    if (((RelativeLayout.LayoutParams) getLayoutParams()).topMargin == max) {
+                        break;
+                    } else {
+                        if (Math.abs(startX - ev.getRawX()) < Math.abs(startY - ev.getRawY())) {
+                            moveHook(distance);
+                        }
+                        break;
+                    }
+                } else {
+                    if (((RelativeLayout.LayoutParams) getLayoutParams()).topMargin == min) {
+                        break;
+                    } else {
+                        if (Math.abs(startX - ev.getRawX()) < Math.abs(startY - ev.getRawY())) {
+                            moveHook(distance);
+                        }
+                        break;
+                    }
+                }
+        }
+        return super.onInterceptTouchEvent(ev);
+    }
+}

+ 1 - 1
app/src/main/java/com/sheep/gamegroup/view/customview/WindowInsetsFrameLayout.java

@@ -8,7 +8,7 @@ import android.view.View;
 import android.view.WindowInsets;
 import android.view.WindowInsets;
 import android.widget.FrameLayout;
 import android.widget.FrameLayout;
 
 
-public class WindowInsetsFrameLayout extends FrameLayout {
+public class WindowInsetsFrameLayout extends TouchFrameLayout {
     public WindowInsetsFrameLayout(Context context) {
     public WindowInsetsFrameLayout(Context context) {
         this(context, null);
         this(context, null);
     }
     }

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

@@ -484,7 +484,7 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
      * 每日必做按钮事件回调
      * 每日必做按钮事件回调
      */
      */
     private void toDayClick() {
     private void toDayClick() {
-        doIt.setTextColor(0x2ebef2);
+        doIt.setTextColor(getResources().getColor(R.color.tab_blue_2ebef2));
         willStart.setTextColor(getResources().getColor(R.color.black_444444));
         willStart.setTextColor(getResources().getColor(R.color.black_444444));
         promote_goods_tv.setTextColor(getResources().getColor(R.color.black_444444));
         promote_goods_tv.setTextColor(getResources().getColor(R.color.black_444444));
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
@@ -498,7 +498,7 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
      */
      */
     private void willStartClick() {
     private void willStartClick() {
         doIt.setTextColor(getResources().getColor(R.color.black_444444));
         doIt.setTextColor(getResources().getColor(R.color.black_444444));
-        willStart.setTextColor(0x2ebef2);
+        willStart.setTextColor(getResources().getColor(R.color.tab_blue_2ebef2));
         promote_goods_tv.setTextColor(getResources().getColor(R.color.black_444444));
         promote_goods_tv.setTextColor(getResources().getColor(R.color.black_444444));
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
             TransitionManager.beginDelayedTransition(titleCardLayout, new ChangeBounds());
             TransitionManager.beginDelayedTransition(titleCardLayout, new ChangeBounds());
@@ -512,7 +512,7 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
     private void clickPromoteGoods() {
     private void clickPromoteGoods() {
         doIt.setTextColor(getResources().getColor(R.color.black_444444));
         doIt.setTextColor(getResources().getColor(R.color.black_444444));
         willStart.setTextColor(getResources().getColor(R.color.black_444444));
         willStart.setTextColor(getResources().getColor(R.color.black_444444));
-        promote_goods_tv.setTextColor(0x2ebef2);
+        promote_goods_tv.setTextColor(getResources().getColor(R.color.tab_blue_2ebef2));
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
             TransitionManager.beginDelayedTransition(titleCardLayout, new ChangeBounds());
             TransitionManager.beginDelayedTransition(titleCardLayout, new ChangeBounds());
         }
         }

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

@@ -21,7 +21,7 @@
         layout="@layout/main_frame_layout"
         layout="@layout/main_frame_layout"
         android:layout_width="match_parent"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:layout_height="match_parent"
-        android:layout_below="@+id/main_header"
+        android:layout_marginTop="72dp"
         android:layout_marginBottom="@dimen/bottom_height" />
         android:layout_marginBottom="@dimen/bottom_height" />
 
 
 
 

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

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <?xml version="1.0" encoding="utf-8"?>
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<com.sheep.gamegroup.view.customview.TouchFrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/frame_container"
     android:id="@+id/frame_container"
     android:layout_width="match_parent"
     android:layout_width="match_parent"
     android:layout_height="match_parent" />
     android:layout_height="match_parent" />

+ 1 - 0
app/src/main/res/values/gamegroup_color.xml

@@ -22,6 +22,7 @@
     <color name="txt_black_cc444444">#cc444444</color>
     <color name="txt_black_cc444444">#cc444444</color>
     <color name="txt_black_565656">#565656</color>
     <color name="txt_black_565656">#565656</color>
     <color name="txt_red_ff4a5f">#ff4a5f</color>
     <color name="txt_red_ff4a5f">#ff4a5f</color>
+    <color name="tab_blue_2ebef2">#2ebef2</color>
 
 
     <color name="yellow2_start">#FCD586</color>
     <color name="yellow2_start">#FCD586</color>
     <color name="yellow2_end">#FDB812</color>
     <color name="yellow2_end">#FDB812</color>