浏览代码

ActMain refact

hanjing 7 年之前
父节点
当前提交
be26edb107

+ 0 - 1
app/src/main/AndroidManifest.xml

@@ -679,7 +679,6 @@
             android:screenOrientation="portrait" />
         <activity
             android:name="com.sheep.gamegroup.view.activity.ActGameCenter"
-            android:theme="@style/AppActionTheme"
             android:screenOrientation="portrait" />
         <activity
             android:name="com.sheep.gamegroup.view.activity.ActDownloadWelfareList"

+ 15 - 15
app/src/main/java/com/sheep/gamegroup/greendao/download/DaoMaster.java

@@ -21,26 +21,26 @@ public class DaoMaster extends AbstractDaoMaster {
 
     /** Creates underlying database table using DAOs. */
     public static void createAllTables(Database db, boolean ifNotExists) {
-        AcceptTaskRecordDao.createTable(db, ifNotExists);
-        AccountDao.createTable(db, ifNotExists);
-        AppdownloadBeanDao.createTable(db, ifNotExists);
-        DownLoadInfoDao.createTable(db, ifNotExists);
         ProcessRecordDao.createTable(db, ifNotExists);
-        ScreenShotRecordDao.createTable(db, ifNotExists);
+        AppdownloadBeanDao.createTable(db, ifNotExists);
         SdkLoginUserDao.createTable(db, ifNotExists);
+        ScreenShotRecordDao.createTable(db, ifNotExists);
+        AcceptTaskRecordDao.createTable(db, ifNotExists);
+        AccountDao.createTable(db, ifNotExists);
         SearchRecordDao.createTable(db, ifNotExists);
+        DownLoadInfoDao.createTable(db, ifNotExists);
     }
 
     /** Drops underlying database table using DAOs. */
     public static void dropAllTables(Database db, boolean ifExists) {
-        AcceptTaskRecordDao.dropTable(db, ifExists);
-        AccountDao.dropTable(db, ifExists);
-        AppdownloadBeanDao.dropTable(db, ifExists);
-        DownLoadInfoDao.dropTable(db, ifExists);
         ProcessRecordDao.dropTable(db, ifExists);
-        ScreenShotRecordDao.dropTable(db, ifExists);
+        AppdownloadBeanDao.dropTable(db, ifExists);
         SdkLoginUserDao.dropTable(db, ifExists);
+        ScreenShotRecordDao.dropTable(db, ifExists);
+        AcceptTaskRecordDao.dropTable(db, ifExists);
+        AccountDao.dropTable(db, ifExists);
         SearchRecordDao.dropTable(db, ifExists);
+        DownLoadInfoDao.dropTable(db, ifExists);
     }
 
     /**
@@ -59,14 +59,14 @@ public class DaoMaster extends AbstractDaoMaster {
 
     public DaoMaster(Database db) {
         super(db, SCHEMA_VERSION);
-        registerDaoClass(AcceptTaskRecordDao.class);
-        registerDaoClass(AccountDao.class);
-        registerDaoClass(AppdownloadBeanDao.class);
-        registerDaoClass(DownLoadInfoDao.class);
         registerDaoClass(ProcessRecordDao.class);
-        registerDaoClass(ScreenShotRecordDao.class);
+        registerDaoClass(AppdownloadBeanDao.class);
         registerDaoClass(SdkLoginUserDao.class);
+        registerDaoClass(ScreenShotRecordDao.class);
+        registerDaoClass(AcceptTaskRecordDao.class);
+        registerDaoClass(AccountDao.class);
         registerDaoClass(SearchRecordDao.class);
+        registerDaoClass(DownLoadInfoDao.class);
     }
 
     public DaoSession newSession() {

+ 61 - 61
app/src/main/java/com/sheep/gamegroup/greendao/download/DaoSession.java

@@ -8,23 +8,23 @@ import org.greenrobot.greendao.database.Database;
 import org.greenrobot.greendao.identityscope.IdentityScopeType;
 import org.greenrobot.greendao.internal.DaoConfig;
 
-import com.sheep.gamegroup.greendao.download.AcceptTaskRecord;
-import com.sheep.gamegroup.greendao.download.Account;
-import com.sheep.gamegroup.greendao.download.AppdownloadBean;
-import com.sheep.gamegroup.greendao.download.DownLoadInfo;
 import com.sheep.gamegroup.greendao.download.ProcessRecord;
-import com.sheep.gamegroup.greendao.download.ScreenShotRecord;
+import com.sheep.gamegroup.greendao.download.AppdownloadBean;
 import com.sheep.gamegroup.greendao.download.SdkLoginUser;
+import com.sheep.gamegroup.greendao.download.ScreenShotRecord;
+import com.sheep.gamegroup.greendao.download.AcceptTaskRecord;
+import com.sheep.gamegroup.greendao.download.Account;
 import com.sheep.gamegroup.greendao.download.SearchRecord;
+import com.sheep.gamegroup.greendao.download.DownLoadInfo;
 
-import com.sheep.gamegroup.greendao.download.AcceptTaskRecordDao;
-import com.sheep.gamegroup.greendao.download.AccountDao;
-import com.sheep.gamegroup.greendao.download.AppdownloadBeanDao;
-import com.sheep.gamegroup.greendao.download.DownLoadInfoDao;
 import com.sheep.gamegroup.greendao.download.ProcessRecordDao;
-import com.sheep.gamegroup.greendao.download.ScreenShotRecordDao;
+import com.sheep.gamegroup.greendao.download.AppdownloadBeanDao;
 import com.sheep.gamegroup.greendao.download.SdkLoginUserDao;
+import com.sheep.gamegroup.greendao.download.ScreenShotRecordDao;
+import com.sheep.gamegroup.greendao.download.AcceptTaskRecordDao;
+import com.sheep.gamegroup.greendao.download.AccountDao;
 import com.sheep.gamegroup.greendao.download.SearchRecordDao;
+import com.sheep.gamegroup.greendao.download.DownLoadInfoDao;
 
 // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
 
@@ -35,112 +35,112 @@ import com.sheep.gamegroup.greendao.download.SearchRecordDao;
  */
 public class DaoSession extends AbstractDaoSession {
 
-    private final DaoConfig acceptTaskRecordDaoConfig;
-    private final DaoConfig accountDaoConfig;
-    private final DaoConfig appdownloadBeanDaoConfig;
-    private final DaoConfig downLoadInfoDaoConfig;
     private final DaoConfig processRecordDaoConfig;
-    private final DaoConfig screenShotRecordDaoConfig;
+    private final DaoConfig appdownloadBeanDaoConfig;
     private final DaoConfig sdkLoginUserDaoConfig;
+    private final DaoConfig screenShotRecordDaoConfig;
+    private final DaoConfig acceptTaskRecordDaoConfig;
+    private final DaoConfig accountDaoConfig;
     private final DaoConfig searchRecordDaoConfig;
+    private final DaoConfig downLoadInfoDaoConfig;
 
-    private final AcceptTaskRecordDao acceptTaskRecordDao;
-    private final AccountDao accountDao;
-    private final AppdownloadBeanDao appdownloadBeanDao;
-    private final DownLoadInfoDao downLoadInfoDao;
     private final ProcessRecordDao processRecordDao;
-    private final ScreenShotRecordDao screenShotRecordDao;
+    private final AppdownloadBeanDao appdownloadBeanDao;
     private final SdkLoginUserDao sdkLoginUserDao;
+    private final ScreenShotRecordDao screenShotRecordDao;
+    private final AcceptTaskRecordDao acceptTaskRecordDao;
+    private final AccountDao accountDao;
     private final SearchRecordDao searchRecordDao;
+    private final DownLoadInfoDao downLoadInfoDao;
 
     public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig>
             daoConfigMap) {
         super(db);
 
-        acceptTaskRecordDaoConfig = daoConfigMap.get(AcceptTaskRecordDao.class).clone();
-        acceptTaskRecordDaoConfig.initIdentityScope(type);
-
-        accountDaoConfig = daoConfigMap.get(AccountDao.class).clone();
-        accountDaoConfig.initIdentityScope(type);
+        processRecordDaoConfig = daoConfigMap.get(ProcessRecordDao.class).clone();
+        processRecordDaoConfig.initIdentityScope(type);
 
         appdownloadBeanDaoConfig = daoConfigMap.get(AppdownloadBeanDao.class).clone();
         appdownloadBeanDaoConfig.initIdentityScope(type);
 
-        downLoadInfoDaoConfig = daoConfigMap.get(DownLoadInfoDao.class).clone();
-        downLoadInfoDaoConfig.initIdentityScope(type);
-
-        processRecordDaoConfig = daoConfigMap.get(ProcessRecordDao.class).clone();
-        processRecordDaoConfig.initIdentityScope(type);
+        sdkLoginUserDaoConfig = daoConfigMap.get(SdkLoginUserDao.class).clone();
+        sdkLoginUserDaoConfig.initIdentityScope(type);
 
         screenShotRecordDaoConfig = daoConfigMap.get(ScreenShotRecordDao.class).clone();
         screenShotRecordDaoConfig.initIdentityScope(type);
 
-        sdkLoginUserDaoConfig = daoConfigMap.get(SdkLoginUserDao.class).clone();
-        sdkLoginUserDaoConfig.initIdentityScope(type);
+        acceptTaskRecordDaoConfig = daoConfigMap.get(AcceptTaskRecordDao.class).clone();
+        acceptTaskRecordDaoConfig.initIdentityScope(type);
+
+        accountDaoConfig = daoConfigMap.get(AccountDao.class).clone();
+        accountDaoConfig.initIdentityScope(type);
 
         searchRecordDaoConfig = daoConfigMap.get(SearchRecordDao.class).clone();
         searchRecordDaoConfig.initIdentityScope(type);
 
-        acceptTaskRecordDao = new AcceptTaskRecordDao(acceptTaskRecordDaoConfig, this);
-        accountDao = new AccountDao(accountDaoConfig, this);
-        appdownloadBeanDao = new AppdownloadBeanDao(appdownloadBeanDaoConfig, this);
-        downLoadInfoDao = new DownLoadInfoDao(downLoadInfoDaoConfig, this);
+        downLoadInfoDaoConfig = daoConfigMap.get(DownLoadInfoDao.class).clone();
+        downLoadInfoDaoConfig.initIdentityScope(type);
+
         processRecordDao = new ProcessRecordDao(processRecordDaoConfig, this);
-        screenShotRecordDao = new ScreenShotRecordDao(screenShotRecordDaoConfig, this);
+        appdownloadBeanDao = new AppdownloadBeanDao(appdownloadBeanDaoConfig, this);
         sdkLoginUserDao = new SdkLoginUserDao(sdkLoginUserDaoConfig, this);
+        screenShotRecordDao = new ScreenShotRecordDao(screenShotRecordDaoConfig, this);
+        acceptTaskRecordDao = new AcceptTaskRecordDao(acceptTaskRecordDaoConfig, this);
+        accountDao = new AccountDao(accountDaoConfig, this);
         searchRecordDao = new SearchRecordDao(searchRecordDaoConfig, this);
+        downLoadInfoDao = new DownLoadInfoDao(downLoadInfoDaoConfig, this);
 
-        registerDao(AcceptTaskRecord.class, acceptTaskRecordDao);
-        registerDao(Account.class, accountDao);
-        registerDao(AppdownloadBean.class, appdownloadBeanDao);
-        registerDao(DownLoadInfo.class, downLoadInfoDao);
         registerDao(ProcessRecord.class, processRecordDao);
-        registerDao(ScreenShotRecord.class, screenShotRecordDao);
+        registerDao(AppdownloadBean.class, appdownloadBeanDao);
         registerDao(SdkLoginUser.class, sdkLoginUserDao);
+        registerDao(ScreenShotRecord.class, screenShotRecordDao);
+        registerDao(AcceptTaskRecord.class, acceptTaskRecordDao);
+        registerDao(Account.class, accountDao);
         registerDao(SearchRecord.class, searchRecordDao);
+        registerDao(DownLoadInfo.class, downLoadInfoDao);
     }
     
     public void clear() {
-        acceptTaskRecordDaoConfig.clearIdentityScope();
-        accountDaoConfig.clearIdentityScope();
-        appdownloadBeanDaoConfig.clearIdentityScope();
-        downLoadInfoDaoConfig.clearIdentityScope();
         processRecordDaoConfig.clearIdentityScope();
-        screenShotRecordDaoConfig.clearIdentityScope();
+        appdownloadBeanDaoConfig.clearIdentityScope();
         sdkLoginUserDaoConfig.clearIdentityScope();
+        screenShotRecordDaoConfig.clearIdentityScope();
+        acceptTaskRecordDaoConfig.clearIdentityScope();
+        accountDaoConfig.clearIdentityScope();
         searchRecordDaoConfig.clearIdentityScope();
+        downLoadInfoDaoConfig.clearIdentityScope();
     }
 
-    public AcceptTaskRecordDao getAcceptTaskRecordDao() {
-        return acceptTaskRecordDao;
-    }
-
-    public AccountDao getAccountDao() {
-        return accountDao;
+    public ProcessRecordDao getProcessRecordDao() {
+        return processRecordDao;
     }
 
     public AppdownloadBeanDao getAppdownloadBeanDao() {
         return appdownloadBeanDao;
     }
 
-    public DownLoadInfoDao getDownLoadInfoDao() {
-        return downLoadInfoDao;
-    }
-
-    public ProcessRecordDao getProcessRecordDao() {
-        return processRecordDao;
+    public SdkLoginUserDao getSdkLoginUserDao() {
+        return sdkLoginUserDao;
     }
 
     public ScreenShotRecordDao getScreenShotRecordDao() {
         return screenShotRecordDao;
     }
 
-    public SdkLoginUserDao getSdkLoginUserDao() {
-        return sdkLoginUserDao;
+    public AcceptTaskRecordDao getAcceptTaskRecordDao() {
+        return acceptTaskRecordDao;
+    }
+
+    public AccountDao getAccountDao() {
+        return accountDao;
     }
 
     public SearchRecordDao getSearchRecordDao() {
         return searchRecordDao;
     }
 
+    public DownLoadInfoDao getDownLoadInfoDao() {
+        return downLoadInfoDao;
+    }
+
 }

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

@@ -3,6 +3,7 @@ package com.sheep.gamegroup.util;
 import android.support.v4.app.Fragment;
 
 import com.sheep.gamegroup.view.fragment.FgtAskGetMoney;
+import com.sheep.gamegroup.view.fragment.FgtFind;
 import com.sheep.gamegroup.view.fragment.FgtGameCenter;
 import com.sheep.gamegroup.view.fragment.FgtNull;
 import com.sheep.gamegroup.view.fragment.FgtPersonalCenter;
@@ -62,7 +63,7 @@ public enum MainTab {
     Fgt_Find(R.string.main_tab_find) {
         @Override
         public Fragment getFragment() {
-            return new FgtNull();
+            return new FgtFind();
         }
 
         @Override

+ 7 - 78
app/src/main/java/com/sheep/gamegroup/view/activity/ActGameCenter.java

@@ -1,13 +1,17 @@
 package com.sheep.gamegroup.view.activity;
 
 import android.content.Intent;
+import android.support.v4.app.Fragment;
 import android.support.v4.view.ViewPager;
 import android.view.View;
 import android.widget.ImageButton;
 
 import com.sheep.gamegroup.absBase.BaseActivity;
+import com.sheep.gamegroup.absBase.BaseContainerActivity;
 import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.gamegroup.util.UMConfigUtils;
+import com.sheep.gamegroup.view.fragment.FgtFootprint;
+import com.sheep.gamegroup.view.fragment.FgtGameCenter;
 import com.sheep.gamegroup.view.fragment.FgtPlayGame;
 import com.sheep.gamegroup.view.fragment.FgtWelfareCenter;
 import com.sheep.jiuyan.samllsheep.R;
@@ -19,85 +23,10 @@ import butterknife.BindView;
  * Created by realicing on 2018/8/29.
  * realicing@sina.com
  */
-public class ActGameCenter extends BaseActivity {
-    @BindView(R.id.act_game_center_vp)
-    ViewPager act_game_center_vp;
+public class ActGameCenter extends BaseContainerActivity {
 
     @Override
-    protected int getLayoutId() {
-        return R.layout.act_game_center;
-    }
-
-    private ActGameCenter activity;
-
-    @Override
-    public void initView() {
-        activity = this;
-        final TitleBarUtils titleBarUtils = TitleBarUtils.getInstance().setTitleFinish(activity);
-        titleBarUtils.setShowOrHide(this, true);
-        titleBarUtils.addTabs(activity, act_game_center_vp, "玩转游戏", new FgtPlayGame(), "福利中心", new FgtWelfareCenter(),
-                        new ViewPager.OnPageChangeListener() {
-                            @Override
-                            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
-
-                            }
-
-                            @Override
-                            public void onPageSelected(int position) {
-                                ActGameCenter.this.onPageSelected(titleBarUtils, position);
-
-                            }
-
-                            @Override
-                            public void onPageScrollStateChanged(int state) {
-
-                            }
-                        });
-        onPageSelected(titleBarUtils, 0);
-
-    }
-
-    private void onPageSelected(TitleBarUtils titleBarUtils, int position) {
-        switch (position) {
-            case 0:
-                titleBarUtils.setRightSecondBtn(activity, R.mipmap.search_black_img, new View.OnClickListener() {
-                    @Override
-                    public void onClick(View view) {
-                        Jump2View.getInstance().goAppSearch(activity, null);
-                    }
-                })
-                        .setRightImgBotton(activity, R.drawable.index_download, new View.OnClickListener() {
-                            @Override
-                            public void onClick(View view) {
-                                TitleBarUtils.getInstance()
-                                        .setRightRedPoint(activity, View.GONE);
-                                startActivity(new Intent(activity, ActDownloadMgr.class));
-                                UMConfigUtils.onEvent(UMConfigUtils.Event.GAME_DOWNLOAD_MANAGER);
-                            }
-                        });
-                break;
-            case 1:
-                ImageButton secondImageButton = activity.findViewById(R.id.ibtn_two_right);
-
-                secondImageButton.setVisibility(View.GONE);
-                titleBarUtils.setRightBtn(activity, "我的福利", 0, new View.OnClickListener() {
-                    @Override
-                    public void onClick(View v) {
-                        // 进入我的福利界面
-                        Jump2View.getInstance().goMyWelfare(activity);
-                    }
-                });
-                break;
-        }
-    }
-
-    @Override
-    public void initListener() {
-
-    }
-
-    @Override
-    public void initData() {
-
+    protected Fragment initFragment() {
+        return new FgtGameCenter();
     }
 }

+ 49 - 90
app/src/main/java/com/sheep/gamegroup/view/activity/ActMain.java

@@ -6,7 +6,6 @@ import android.os.Bundle;
 import android.support.annotation.Nullable;
 import android.support.v4.app.Fragment;
 import android.support.v4.app.FragmentTransaction;
-import android.support.v4.view.ViewPager;
 import android.text.TextUtils;
 import android.view.MotionEvent;
 import android.view.View;
@@ -34,10 +33,8 @@ import com.sheep.gamegroup.util.MainTab;
 import com.sheep.gamegroup.util.SysAppUtil;
 import com.sheep.gamegroup.util.TestUtil;
 import com.sheep.gamegroup.util.UMConfigUtils;
-import com.sheep.gamegroup.view.adapter.ViewPagerFragmentAdapter;
 import com.sheep.gamegroup.view.dialog.DialogGameOrTaskOrGift;
 import com.sheep.gamegroup.view.fragment.FgtFind;
-import com.sheep.gamegroup.view.fragment.FgtSmallSheep;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.utils.G;
@@ -80,14 +77,13 @@ public class ActMain extends BaseActYmPermissionCheck {
             if (game_id != null) {
                 ActionUtil.getInstance().addNextAction(MiddleSchemeAct.SHOW_DIALOG_GAME_OR_GIFT_TASK, game_id);
             }
-        }  //获取顶层视图
-        decorView = getWindow().getDecorView();
+        }
     }
 
     @Override
-    public void onNewIntent(Intent intent){
+    public void onNewIntent(Intent intent) {
         super.onNewIntent(intent);
-        if("LOGOUT".equals(intent.getStringExtra("INTENT_ACTION"))) {
+        if ("LOGOUT".equals(intent.getStringExtra("INTENT_ACTION"))) {
             Jump2View.getInstance().goLoginView(this, "");
             finish();
         }
@@ -112,7 +108,7 @@ public class ActMain extends BaseActYmPermissionCheck {
 //                    View.SYSTEM_UI_FLAG_FULLSCREEN | // hide status bar
                             View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
             // 获取属性
-            decorView.setSystemUiVisibility(flag);
+            getWindow().getDecorView().setSystemUiVisibility(flag);
         }
     }
 
@@ -121,12 +117,8 @@ public class ActMain extends BaseActYmPermissionCheck {
         return false;
     }
 
-    private View decorView;
-
     public static final String FIRST_SHOW_MAIN = "first_show_main";//是否是第一次显示主页
 
-    @BindView(R.id.view_pager_container)
-    ViewPager view_pager_container;
     @BindView(R.id.frame_container)
     FrameLayout frame_container;
     @BindView(R.id.tab_container)
@@ -142,8 +134,8 @@ public class ActMain extends BaseActYmPermissionCheck {
     @Override
     public void initView() {
         EventBus.getDefault().register(this);
-        initViewPager();
-        initFind();
+        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));
 //        }
@@ -169,13 +161,22 @@ public class ActMain extends BaseActYmPermissionCheck {
     public static final int MIN_CLICK_DELAY_TIME = 200;
     private long lastClickTime = 0;
 
-    private void initViewPager() {
-
+    private void initFragments() {
+        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
         MainTab[] mainTabs = MainTab.values();
         int index = 0;
         for (MainTab mainTab : mainTabs) {
-            fragmentList.add(mainTab.getFragment());
-
+            Fragment fragment = getSupportFragmentManager().findFragmentByTag("fragment_" + index);
+            if (fragment == null) {
+                fragment = mainTabs[index].getFragment();
+            }
+            fragmentList.add(fragment);
+            transaction.add(R.id.frame_container, fragment, "fragment_"+index);
+            if(index==0) {
+                transaction.show(fragment);
+            }else{
+                transaction.hide(fragment);
+            }
             View view = tab_container.getChildAt(index * 2 + 1);
             if (view instanceof TextView) {
                 ((TextView) view).setText(mainTab.getStringId());
@@ -183,62 +184,46 @@ public class ActMain extends BaseActYmPermissionCheck {
             }
             tabs.add(view);
             final int position = index;
-            view.setOnClickListener(new View.OnClickListener() {
-                @Override
-                public void onClick(View view) {
-                    long currentTime = System.currentTimeMillis();
-                    if (currentTime - lastClickTime > MIN_CLICK_DELAY_TIME) {
-                        lastClickTime = currentTime;
-                        view_pager_container.setCurrentItem(position, false);
-                        checkWhichPage(position);
-                    }
-
-
+            view.setOnClickListener(v -> {
+                long currentTime = System.currentTimeMillis();
+                if (currentTime - lastClickTime > MIN_CLICK_DELAY_TIME) {
+                    lastClickTime = currentTime;
+                    switchFragment(position);
+                    checkWhichPage(position);
                 }
             });
             index++;
         }
+        transaction.commitAllowingStateLoss();
         //隐藏不显示的控件
         for (int i = index * 2; i < tab_container.getChildCount() - 1; i++) {
             tab_container.getChildAt(i).setVisibility(View.GONE);
         }
-        ViewPagerFragmentAdapter mViewPagerFragmentAdapter = new ViewPagerFragmentAdapter(getSupportFragmentManager(), fragmentList);
-        view_pager_container.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
-
-            @Override
-            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
-
-            }
-
-            @Override
-            public void onPageSelected(int position) {
-                //设置tab选择状态
-                View lastTab = ListUtil.getItem(tabs, lastPosition);
-                View curTab = ListUtil.getItem(tabs, position);
-                if (lastTab != null)
-                    lastTab.setActivated(false);
-                if (curTab != null)
-                    curTab.setActivated(true);
-                if (lastPosition == MainTab.FgtSmallSheep.ordinal() && position != MainTab.FgtSmallSheep.ordinal()) {
-                    ((FgtSmallSheep) MainTab.FgtSmallSheep.getFragment()).onPause();
-                }
-                showFind(position == MainTab.Fgt_Find.ordinal());
-                //更新position
-                lastPosition = position;
-            }
-
-            @Override
-            public void onPageScrollStateChanged(int state) {
-
-            }
-        });
-        view_pager_container.setAdapter(mViewPagerFragmentAdapter);
-        view_pager_container.setCurrentItem(lastPosition, false);
-        //添加viewpager 缓存个数,解决邀请赚钱好友切换问题
-        view_pager_container.setOffscreenPageLimit(mViewPagerFragmentAdapter.getCount());
         tabs.get(lastPosition).setActivated(true);
     }
 
+    private void switchFragment(int position) {
+        View lastTab = ListUtil.getItem(tabs, lastPosition);
+        View curTab = ListUtil.getItem(tabs, position);
+        if (lastTab != null) {
+            lastTab.setActivated(false);
+        }
+        if (curTab != null) {
+            curTab.setActivated(true);
+        }
+        if (lastPosition != position) {
+            FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
+            Fragment cFragment = getSupportFragmentManager().findFragmentByTag("fragment_" + position);
+            Fragment lFragment = getSupportFragmentManager().findFragmentByTag("fragment_" + lastPosition);
+            transaction.hide(lFragment);
+            transaction.show(cFragment);
+            transaction.commitAllowingStateLoss();
+            lFragment.setUserVisibleHint(false);
+            cFragment.setUserVisibleHint(true);
+        }
+        lastPosition = position;
+    }
+
     /**
      * 统计
      *
@@ -254,32 +239,6 @@ public class ActMain extends BaseActYmPermissionCheck {
         }
     }
 
-    private void showFind(boolean isFind) {
-        if (isFind) {
-            fgtFind.setUserVisibleHint(true);
-            frame_container.bringToFront();
-        } else {
-            fgtFind.setUserVisibleHint(false);
-            view_pager_container.bringToFront();
-        }
-    }
-
-    private Fragment fgtFind;
-
-    public void initFind() {
-        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
-        Fragment fragment = getSupportFragmentManager().findFragmentByTag("tag");
-        if (fragment == null) {
-            fragment = new FgtFind();
-            transaction.add(R.id.frame_container, fragment, "tag");
-            transaction.commitAllowingStateLoss();
-        } else {
-            transaction.replace(R.id.frame_container, fragment);
-            transaction.commitAllowingStateLoss();
-        }
-        fgtFind = fragment;
-    }
-
     private long mLastBackTime = 0;//上次按退出按钮的时间
 
     /**
@@ -366,7 +325,7 @@ public class ActMain extends BaseActYmPermissionCheck {
                 new DialogGameOrTaskOrGift(this, game_id).showDialog();
             }
         } else if (action instanceof MainTab) {
-            view_pager_container.setCurrentItem(((MainTab) action).ordinal(), false);
+            switchFragment(((MainTab) action).ordinal());
         }
     }
 

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

@@ -365,7 +365,8 @@ public class FgtSmallSheep extends BaseFragment implements SmallSheepContract.Vi
 
     @OnClick(R.id.to_search_but)
     public void toSearchActivity() {
-        Jump2View.getInstance().goAppTaskSearch(activity, null);
+//        Jump2View.getInstance().goAppTaskSearch(activity, null);
+        Jump2View.getInstance().goMainGame(getContext());
     }
 
     @OnClick(R.id.home_search_msg_iv)

+ 1 - 7
app/src/main/res/layout/act_main.xml

@@ -4,18 +4,12 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent">
 
-    <FrameLayout
+    <com.sheep.gamegroup.view.customview.WindowInsetsFrameLayout
         android:id="@+id/frame_container"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:layout_marginBottom="@dimen/bottom_height" />
 
-    <com.kfzs.duanduan.view.NoScrollViewPager
-        android:id="@+id/view_pager_container"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:layout_marginBottom="@dimen/bottom_height" />
-
     <RelativeLayout
         android:layout_width="match_parent"
         android:layout_height="@dimen/bottom_height"

+ 1 - 0
app/src/main/res/layout/check_net_view.xml

@@ -4,6 +4,7 @@
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:background="#33ff0000"
+    android:visibility="gone"
     android:orientation="horizontal">
     <TextView
         android:layout_width="24dp"

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

@@ -3,7 +3,6 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:background="@color/white"
-    android:paddingTop="20dp"
     android:fitsSystemWindows="true">
 
     <RelativeLayout

+ 1 - 0
app/src/main/res/layout/homepage_act_layout.xml

@@ -4,6 +4,7 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:background="@color/white"
+    android:fitsSystemWindows="true"
     android:clipChildren="true">
 
     <include

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

@@ -9,7 +9,6 @@
         android:layout_height="44dp"
         android:layout_alignParentEnd="true"
         android:layout_marginStart="4dp"
-        android:layout_marginTop="20dp"
         android:layout_marginEnd="4dp"
         android:padding="12dp"
         android:src="@mipmap/ic_msg" />
@@ -18,7 +17,7 @@
         android:id="@+id/home_search_msg_tv"
         android:layout_width="wrap_content"
         android:layout_height="14dp"
-        android:layout_marginTop="30dp"
+        android:layout_marginTop="10dp"
         android:layout_marginEnd="8dp"
         android:paddingStart="4dp"
         android:paddingEnd="4dp"
@@ -34,7 +33,7 @@
         android:layout_width="match_parent"
         android:layout_height="30dp"
         android:layout_marginStart="27dp"
-        android:layout_marginTop="27dp"
+        android:layout_marginTop="7dp"
         android:layout_marginEnd="22dp"
         android:layout_marginBottom="7dp"
         android:layout_toStartOf="@id/home_search_msg_iv"