Commit 2010cde5c59e88c7129d5d389711831d9c6c16ef
1 parent
ee599ef7
1 优化基类
Showing
4 changed files
with
67 additions
and
19 deletions
app/strike/src/main/java/com/cnlive/strike/EmptyFragment.java
0 → 100644
| 1 | +package com.cnlive.strike; | |
| 2 | + | |
| 3 | +import android.os.Bundle; | |
| 4 | +import android.view.LayoutInflater; | |
| 5 | +import android.view.View; | |
| 6 | +import android.view.ViewGroup; | |
| 7 | + | |
| 8 | +import androidx.annotation.NonNull; | |
| 9 | +import androidx.annotation.Nullable; | |
| 10 | + | |
| 11 | +import com.cnlive.core.libs.base.frame.fragment.BaseFragment; | |
| 12 | + | |
| 13 | +public class EmptyFragment extends BaseFragment { | |
| 14 | + @Nullable | |
| 15 | + @Override | |
| 16 | + public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | |
| 17 | + return inflater.inflate(R.layout.fragment_main1, container, false); | |
| 18 | + } | |
| 19 | +} | ... | ... |
app/strike/src/main/java/com/cnlive/strike/MyActivity.java
| 1 | 1 | package com.cnlive.strike; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | +import android.content.Intent; | |
| 4 | 5 | import android.text.TextUtils; |
| 5 | 6 | import android.view.View; |
| 6 | 7 | |
| 7 | 8 | import com.alibaba.android.arouter.facade.annotation.Route; |
| 8 | 9 | import com.cnlive.core.libs.base.frame.activity.BaseActivity; |
| 9 | 10 | import com.cnlive.core.libs.base.util.NetworkUtil; |
| 11 | +import com.cnlive.moudle.collectionTrace.ui.activity.RaceListActivity; | |
| 10 | 12 | import com.cnlive.moudle.pedometer.commonInfo.CommonInfo; |
| 13 | +import com.cnlive.moudle.pedometer.ui.activity.RunLineActivity; | |
| 14 | +import com.cnlive.moudle.pedometer.ui.fragment.RunLineFragment; | |
| 11 | 15 | import com.cnlive.strike.databinding.ActivityMyBinding; |
| 12 | 16 | import com.cnlive.strike.user.auth.UserService; |
| 13 | 17 | import com.cnlive.strike.xiaojiaspeaker.commonInfo.XiaoJIaCommInfo; |
| ... | ... | @@ -16,29 +20,29 @@ import com.cnlive.strike.xiaojiaspeaker.commonInfo.XiaoJIaCommInfo; |
| 16 | 20 | public class MyActivity extends BaseActivity { |
| 17 | 21 | public ActivityMyBinding binding; |
| 18 | 22 | |
| 19 | - @Override | |
| 20 | - protected int getBindLayoutId() { | |
| 21 | - return R.layout.activity_my; | |
| 22 | - } | |
| 23 | +// @Override | |
| 24 | +// protected int getBindLayoutId() { | |
| 25 | +// return R.layout.activity_my; | |
| 26 | +// } | |
| 23 | 27 | |
| 24 | - @Override | |
| 25 | - protected void initBindingData() { | |
| 26 | - super.initBindingData(); | |
| 27 | - binding = (ActivityMyBinding) baseBinding; | |
| 28 | - } | |
| 28 | +// @Override | |
| 29 | +// protected void initBindingData() { | |
| 30 | +// super.initBindingData(); | |
| 31 | +// binding = (ActivityMyBinding) baseBinding; | |
| 32 | +// } | |
| 29 | 33 | |
| 30 | 34 | @Override |
| 31 | 35 | protected void initView() { |
| 32 | -// getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new MyFragment()).commitAllowingStateLoss(); | |
| 36 | +// loadRootFragment(new EmptyFragment()); | |
| 33 | 37 | initXiaoJiaSoundBoxData(); |
| 34 | -// startActivity(new Intent(MyActivity.this, RunLineActivity.class)); | |
| 38 | + startActivity(new Intent(MyActivity.this, RaceListActivity.class)); | |
| 35 | 39 | // finish(); |
| 36 | - binding.btnChange.setOnClickListener(new View.OnClickListener() { | |
| 37 | - @Override | |
| 38 | - public void onClick(View v) { | |
| 39 | -// Bitmap bitmap=ImageUtils.drawable2Bitmap(getResources().getDrawable(R.mipmap.timg)); | |
| 40 | - binding.btnChange.setText(NetworkUtil.getNetWorkType(me) + ""); | |
| 41 | - binding.ivImg.setImageBitmap(screenShot()); | |
| 40 | +// binding.btnChange.setOnClickListener(new View.OnClickListener() { | |
| 41 | +// @Override | |
| 42 | +// public void onClick(View v) { | |
| 43 | +//// Bitmap bitmap=ImageUtils.drawable2Bitmap(getResources().getDrawable(R.mipmap.timg)); | |
| 44 | +// binding.btnChange.setText(NetworkUtil.getNetWorkType(me) + ""); | |
| 45 | +// binding.ivImg.setImageBitmap(screenShot()); | |
| 42 | 46 | // startActivity(new Intent(MyActivity.this, RunLineActivity.class)); |
| 43 | 47 | |
| 44 | 48 | // WjjPay.passwordIsExisting(UserService.getUid(me), new NetCallBack<BaseResult<GroupBalanceInfo>>() { |
| ... | ... | @@ -75,8 +79,8 @@ public class MyActivity extends BaseActivity { |
| 75 | 79 | // QMUITipDialogUtil.failedDialog(me, errMsg, 3); |
| 76 | 80 | // } |
| 77 | 81 | // }); |
| 78 | - } | |
| 79 | - }); | |
| 82 | +// } | |
| 83 | +// }); | |
| 80 | 84 | } |
| 81 | 85 | |
| 82 | 86 | @Override | ... | ... |
core/base/src/main/java/com/cnlive/core/libs/base/frame/fragment/BaseFragment.java
| ... | ... | @@ -27,6 +27,7 @@ import com.cnlive.core.libs.base.network.manager.SubscriptionManager; |
| 27 | 27 | import com.cnlive.core.libs.base.util.ReflectUtil; |
| 28 | 28 | import com.cnlive.core.libs.base.frame.view.BaseView; |
| 29 | 29 | import com.cnlive.core.libs.base.util.StatusBarConfig; |
| 30 | +import com.cnlive.strike.base.R; | |
| 30 | 31 | import com.me.yokeyword.fragmentation.ExtraTransaction; |
| 31 | 32 | import com.me.yokeyword.fragmentation.ISupportFragment; |
| 32 | 33 | import com.me.yokeyword.fragmentation.SupportFragmentDelegate; |
| ... | ... | @@ -89,6 +90,15 @@ public abstract class BaseFragment<V extends BaseView, P extends BasePresenter<V |
| 89 | 90 | return baseView; |
| 90 | 91 | } |
| 91 | 92 | } |
| 93 | + if (0 == getBindLayoutId() && 0 == getViewLayoutId()) { | |
| 94 | + //加载默认布局 | |
| 95 | + baseView = inflater.inflate(R.layout.base_fragment_main, container, false); | |
| 96 | + if (me.isOpenSwipBack()) { | |
| 97 | + return attachToSwipeBack(baseView); | |
| 98 | + } else { | |
| 99 | + return baseView; | |
| 100 | + } | |
| 101 | + } | |
| 92 | 102 | return super.onCreateView(inflater, container, savedInstanceState); |
| 93 | 103 | } |
| 94 | 104 | |
| ... | ... | @@ -691,6 +701,15 @@ public abstract class BaseFragment<V extends BaseView, P extends BasePresenter<V |
| 691 | 701 | /** |
| 692 | 702 | * 加载根Fragment, 即Activity内的第一个Fragment 或 Fragment内的第一个子Fragment |
| 693 | 703 | * |
| 704 | + * @param toFragment 目标Fragment | |
| 705 | + */ | |
| 706 | + public void loadRootFragment(ISupportFragment toFragment) { | |
| 707 | + mDelegate.loadRootFragment(R.id.root_container, toFragment); | |
| 708 | + } | |
| 709 | + | |
| 710 | + /** | |
| 711 | + * 加载根Fragment, 即Activity内的第一个Fragment 或 Fragment内的第一个子Fragment | |
| 712 | + * | |
| 694 | 713 | * @param containerId 容器id |
| 695 | 714 | * @param toFragment 目标Fragment |
| 696 | 715 | */ | ... | ... |
core/base/src/main/res/layout/base_fragment_main.xml
0 → 100644