Bladeren bron

fix home fragment load web fragment bug

hanjing 6 jaren geleden
bovenliggende
commit
f075149f79

+ 2 - 2
app/src/main/java/com/sheep/gamegroup/absBase/BaseActivity.java

@@ -129,8 +129,8 @@ public abstract class BaseActivity extends RxAppCompatActivity implements BackHa
                                 .scrimEndAlpha(0f)
                                 .velocityThreshold(2400)
                                 .distanceThreshold(0.25f)
-//                                .edge(true)
-//                                .edgeSize(0.18f) // The % of the screen that counts as the edge, default 18%
+                                .edge(true)
+                                .edgeSize(0.18f) // The % of the screen that counts as the edge, default 18%
                                 .listener(new SlidrListener(){
 
                                     @Override

+ 39 - 0
app/src/main/java/com/sheep/gamegroup/module/home/fragment/FgtWrapper.java

@@ -0,0 +1,39 @@
+package com.sheep.gamegroup.module.home.fragment;
+
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentTransaction;
+
+import com.sheep.gamegroup.model.entity.WebParams;
+import com.sheep.gamegroup.module.webview.fragment.FgtWeb;
+import com.sheep.gamegroup.module.webview.fragment.FgtWebX5;
+import com.sheep.jiuyan.samllsheep.Config;
+import com.sheep.jiuyan.samllsheep.R;
+import com.sheep.jiuyan.samllsheep.base.BaseFragment;
+import com.snail.antifake.jni.EmulatorDetectUtil;
+
+public class FgtWrapper extends BaseFragment {
+
+    private Fragment subFragment;
+
+    @Override
+    public int getLayoutId() {
+        return R.layout.fgt_wrapper;
+    }
+
+    @Override
+    public void onViewCreated() {
+
+    }
+
+    public void loadSubFragment() {
+        if (subFragment != null) return;
+        if (EmulatorDetectUtil.isEmulator()) {
+            subFragment = FgtWeb.newInstance(new WebParams(Config.getUrlByPath(Config.PATH_SMALL_SHEEP_INVITATION_HOME), "邀请赚钱"));
+        } else {
+            subFragment = FgtWebX5.newInstance(new WebParams(Config.getUrlByPath(Config.PATH_SMALL_SHEEP_INVITATION_HOME), "邀请赚钱"));
+        }
+        FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
+        transaction.add(R.id.fragment_container, subFragment, "fragment_sub").show(subFragment);
+        transaction.commitAllowingStateLoss();
+    }
+}

+ 7 - 5
app/src/main/java/com/sheep/gamegroup/util/MainTab.java

@@ -5,6 +5,7 @@ import android.support.v4.app.Fragment;
 import com.sheep.gamegroup.model.entity.WebParams;
 import com.sheep.gamegroup.module.game.fragment.FgtGameCenter;
 import com.sheep.gamegroup.module.home.fragment.FgtHome;
+import com.sheep.gamegroup.module.home.fragment.FgtWrapper;
 import com.sheep.gamegroup.module.webview.fragment.FgtWeb;
 import com.sheep.gamegroup.module.webview.fragment.FgtWebX5;
 import com.sheep.gamegroup.view.fragment.FgtFind;
@@ -34,12 +35,13 @@ public enum MainTab {
     FgtMainAskGetMoney(R.string.empty) {
         @Override
         public Fragment getFragment() {
+            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), "邀请赚钱"));
-            }
+//            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

+ 12 - 4
app/src/main/java/com/sheep/gamegroup/view/activity/ActMain.java

@@ -28,6 +28,7 @@ import com.sheep.gamegroup.model.entity.Container;
 import com.sheep.gamegroup.model.entity.Lp;
 import com.sheep.gamegroup.model.entity.UserEntity;
 import com.sheep.gamegroup.model.util.ShowRedDot;
+import com.sheep.gamegroup.module.home.fragment.FgtWrapper;
 import com.sheep.gamegroup.util.ActionUtil;
 import com.sheep.gamegroup.util.ChannelContent;
 import com.sheep.gamegroup.util.CommonUtil;
@@ -249,15 +250,22 @@ public class ActMain extends BaseActYmPermissionCheck {
             FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
             Fragment cFragment = getSupportFragmentManager().findFragmentByTag("fragment_" + position);
             Fragment lFragment = getSupportFragmentManager().findFragmentByTag("fragment_" + lastPosition);
-            if (lFragment != null)
+            if (lFragment != null) {
                 transaction.hide(lFragment);
-            if (cFragment != null)
+            }
+            if (cFragment != null) {
                 transaction.show(cFragment);
+            }
             transaction.commitAllowingStateLoss();
-            if (lFragment != null)
+            if (lFragment != null) {
                 lFragment.setUserVisibleHint(false);
-            if (cFragment != null)
+            }
+            if (cFragment != null) {
                 cFragment.setUserVisibleHint(true);
+            }
+            if (cFragment instanceof FgtWrapper) {
+                ((FgtWrapper) cFragment).loadSubFragment();
+            }
         }
         changeVisible(lastPosition, position);
         lastPosition = position;

+ 7 - 0
app/src/main/res/layout/fgt_wrapper.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/fragment_container"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+</FrameLayout>