瀏覽代碼

invitation page fixed

billyyoyo 5 年之前
父節點
當前提交
a3529a8284

+ 14 - 8
app/src/main/java/com/sheep/gamegroup/module/home/fragment/FgtWrapper.java

@@ -3,6 +3,7 @@ package com.sheep.gamegroup.module.home.fragment;
 import android.support.v4.app.Fragment;
 import android.support.v4.app.FragmentTransaction;
 
+import com.kfzs.duanduan.cardview.ScreenUtil;
 import com.sheep.gamegroup.model.entity.WebParams;
 import com.sheep.gamegroup.module.webview.fragment.FgtWeb;
 import com.sheep.gamegroup.module.webview.fragment.FgtWebX5;
@@ -14,7 +15,7 @@ import com.snail.antifake.jni.EmulatorDetectUtil;
 
 public class FgtWrapper extends BaseFragment {
 
-    private Fragment subFragment;
+    private BaseFragment subFragment;
 
     @Override
     public int getLayoutId() {
@@ -23,14 +24,19 @@ public class FgtWrapper extends BaseFragment {
 
     @Override
     public void onViewCreated() {
-
-    }
-
-    public void loadSubFragment() {
-        if (subFragment != null) return;
-        subFragment = ViewUtil.newWebFragment(new WebParams(Config.getUrlByPath(Config.PATH_SMALL_SHEEP_INVITATION_HOME), "邀请赚钱"));
+        subFragment = (BaseFragment) getChildFragmentManager().findFragmentByTag("fragment_sub");
         FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
-        transaction.add(R.id.fragment_container, subFragment, "fragment_sub").show(subFragment);
+        if (subFragment == null) {
+            subFragment = ViewUtil.newWebFragment(new WebParams(Config.getUrlByPath(Config.PATH_SMALL_SHEEP_INVITATION_HOME),"邀请赚钱").hideProgress());
+            transaction.add(R.id.fragment_container, subFragment, "fragment_sub").show(subFragment);
+        } else {
+            transaction.show(subFragment);
+        }
         transaction.commitAllowingStateLoss();
     }
+
+    @Override
+    public void initDataOnVisibleToUser() {
+        if (subFragment != null) subFragment.initDataOnVisibleToUser();
+    }
 }

+ 0 - 3
app/src/main/java/com/sheep/gamegroup/view/activity/ActMain.java

@@ -319,9 +319,6 @@ public class ActMain extends BaseActYmPermissionCheck {
             if (cFragment != null) {
                 cFragment.setUserVisibleHint(true);
             }
-            if (cFragment instanceof FgtWrapper) {
-                ((FgtWrapper) cFragment).loadSubFragment();
-            }
         }
         changeVisible(lastPosition, position);
         lastPosition = position;

+ 4 - 0
build.gradle

@@ -5,6 +5,8 @@ buildscript {
         supportLibVersion = "28.0.0"
     }
     repositories {
+        maven { url 'https://maven.aliyun.com/repository/jcenter' }
+        maven { url 'https://maven.aliyun.com/repository/google' }
         jcenter()
         google()
     }
@@ -32,6 +34,8 @@ def isReleaseBuild() {
 
 allprojects {
     repositories {
+        maven { url 'https://maven.aliyun.com/repository/jcenter' }
+        maven { url 'https://maven.aliyun.com/repository/google' }
         maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
         maven {
             url 'https://raw.githubusercontent.com/MDL-Sinlov/MDL-Android-Repo/master/mvn-repo/'