From 4b3d056306289978f2de663dbf76816cdc9dd061 Mon Sep 17 00:00:00 2001 From: lh <1209405678@qq.com> Date: Fri, 22 Dec 2017 14:37:00 +0800 Subject: [PATCH] no message --- .../com/qhclh/ytzh/home/MainActivity.java | 44 ++++++++++++++++--- .../ytzh/index/fumudai/FumudaiFragment.java | 30 +++++++++++++ .../ytzh/index/shangpin/ShangpinFragment.java | 30 +++++++++++++ .../res/layout/fragment_index_fumudai.xml | 11 +++++ .../res/layout/fragment_index_shangpin.xml | 11 +++++ 5 files changed, 120 insertions(+), 6 deletions(-) create mode 100644 app/src/main/java/com/qhclh/ytzh/index/fumudai/FumudaiFragment.java create mode 100644 app/src/main/java/com/qhclh/ytzh/index/shangpin/ShangpinFragment.java create mode 100644 app/src/main/res/layout/fragment_index_fumudai.xml create mode 100644 app/src/main/res/layout/fragment_index_shangpin.xml diff --git a/app/src/main/java/com/qhclh/ytzh/home/MainActivity.java b/app/src/main/java/com/qhclh/ytzh/home/MainActivity.java index bec9ae5..c9451af 100644 --- a/app/src/main/java/com/qhclh/ytzh/home/MainActivity.java +++ b/app/src/main/java/com/qhclh/ytzh/home/MainActivity.java @@ -15,6 +15,8 @@ import com.qhclh.ytzh.R; import com.qhclh.ytzh.base.BaseActivity; import com.qhclh.ytzh.bean.DownLoadBean; import com.qhclh.ytzh.index.IndexFragment; +import com.qhclh.ytzh.index.fumudai.FumudaiFragment; +import com.qhclh.ytzh.index.shangpin.ShangpinFragment; import com.qhclh.ytzh.me.MeFragment; import com.qhclh.ytzh.utils.ApkUtils; import com.qhclh.ytzh.utils.Urltool; @@ -60,6 +62,11 @@ public class MainActivity extends BaseActivity { private WorkFragment workFragment; private MeFragment meFragment; + private ShangpinFragment shangpinFragment; + private FumudaiFragment fumudaiFragment; + ///< 0 商品鸡 其他父母代 + private int indexFlag = 0; + private String versionName, downloadUrl; private DownLoadBean downLoadBean; @@ -163,12 +170,28 @@ public class MainActivity extends BaseActivity { hideFragment(transaction); switch (tabPosition) { case TAB_POSITION_INDEX: { - if (indexFragment == null) { - indexFragment = new IndexFragment(); - transaction.add(R.id.main_container, indexFragment); + if (indexFlag == 0) { + if (shangpinFragment == null) { + shangpinFragment = new ShangpinFragment(); + transaction.add(R.id.main_container, shangpinFragment); + } else { + transaction.show(shangpinFragment); + } } else { - transaction.show(indexFragment); + if (fumudaiFragment == null) { + fumudaiFragment = new FumudaiFragment(); + transaction.add(R.id.main_container, fumudaiFragment); + } else { + transaction.show(fumudaiFragment); + } } +// if (indexFragment == null) { +// indexFragment = new IndexFragment(); +// transaction.add(R.id.main_container, indexFragment); + +// } else { +// transaction.show(indexFragment); +// } break; } @@ -196,10 +219,19 @@ public class MainActivity extends BaseActivity { } private void hideFragment(FragmentTransaction transaction) { - if (indexFragment != null) { - transaction.hide(indexFragment); +// if (indexFragment != null) { +// transaction.hide(indexFragment); +// } + + if (shangpinFragment != null) { + transaction.hide(shangpinFragment); } + if (fumudaiFragment != null) { + transaction.hide(fumudaiFragment); + } + + if (workFragment != null) { transaction.hide(workFragment); } diff --git a/app/src/main/java/com/qhclh/ytzh/index/fumudai/FumudaiFragment.java b/app/src/main/java/com/qhclh/ytzh/index/fumudai/FumudaiFragment.java new file mode 100644 index 0000000..499b93f --- /dev/null +++ b/app/src/main/java/com/qhclh/ytzh/index/fumudai/FumudaiFragment.java @@ -0,0 +1,30 @@ +package com.qhclh.ytzh.index.fumudai; + +import com.qhclh.ytzh.R; +import com.qhclh.ytzh.base.BaseFragment; + +/** + * Created by 青花瓷 on 2017/12/22. + */ + +public class FumudaiFragment extends BaseFragment { + @Override + protected int setLayout() { + return R.layout.fragment_index_fumudai; + } + + @Override + protected void initView() { + + } + + @Override + protected void initData() { + + } + + @Override + protected void initOper() { + + } +} diff --git a/app/src/main/java/com/qhclh/ytzh/index/shangpin/ShangpinFragment.java b/app/src/main/java/com/qhclh/ytzh/index/shangpin/ShangpinFragment.java new file mode 100644 index 0000000..f8508fe --- /dev/null +++ b/app/src/main/java/com/qhclh/ytzh/index/shangpin/ShangpinFragment.java @@ -0,0 +1,30 @@ +package com.qhclh.ytzh.index.shangpin; + +import com.qhclh.ytzh.R; +import com.qhclh.ytzh.base.BaseFragment; + +/** + * Created by 青花瓷 on 2017/12/22. + */ + +public class ShangpinFragment extends BaseFragment { + @Override + protected int setLayout() { + return R.layout.fragment_index_shangpin; + } + + @Override + protected void initView() { + + } + + @Override + protected void initData() { + + } + + @Override + protected void initOper() { + + } +} diff --git a/app/src/main/res/layout/fragment_index_fumudai.xml b/app/src/main/res/layout/fragment_index_fumudai.xml new file mode 100644 index 0000000..989831e --- /dev/null +++ b/app/src/main/res/layout/fragment_index_fumudai.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_index_shangpin.xml b/app/src/main/res/layout/fragment_index_shangpin.xml new file mode 100644 index 0000000..95b130f --- /dev/null +++ b/app/src/main/res/layout/fragment_index_shangpin.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file