mirror of
https://github.com/Tencent/QMUI_Android.git
synced 2026-10-29 03:26:44 +08:00
add a new hook method onViewCreated for QMUIFragment
This commit is contained in:
@@ -35,6 +35,7 @@ import android.widget.FrameLayout;
|
||||
import com.qmuiteam.qmui.QMUILog;
|
||||
import com.qmuiteam.qmui.util.QMUIKeyboardHelper;
|
||||
import com.qmuiteam.qmui.util.QMUIViewHelper;
|
||||
import com.qmuiteam.qmui.widget.QMUITopBar;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
@@ -275,6 +276,9 @@ public abstract class QMUIFragment extends Fragment implements QMUIFragmentLazyL
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
if(mBaseView.getTag(R.id.qmui_arch_reused_layout) == null){
|
||||
onViewCreated(mBaseView);
|
||||
}
|
||||
mLazyViewLifecycleOwner = new QMUIFragmentLazyLifecycleOwner(this);
|
||||
mLazyViewLifecycleOwner.setViewVisible(getUserVisibleHint());
|
||||
getViewLifecycleOwner().getLifecycle().addObserver(mLazyViewLifecycleOwner);
|
||||
@@ -310,6 +314,7 @@ public abstract class QMUIFragment extends Fragment implements QMUIFragmentLazyL
|
||||
if (rootView.getParent() != null) {
|
||||
((ViewGroup) rootView.getParent()).removeView(rootView);
|
||||
}
|
||||
rootView.setTag(R.id.qmui_arch_reused_layout, true);
|
||||
}
|
||||
if (translucentFull()) {
|
||||
rootView.setFitsSystemWindows(false);
|
||||
@@ -674,6 +679,7 @@ public abstract class QMUIFragment extends Fragment implements QMUIFragmentLazyL
|
||||
mCacheSwipeBackLayout = swipeBackLayout;
|
||||
} else {
|
||||
swipeBackLayout = mCacheSwipeBackLayout;
|
||||
mCacheRootView.setTag(R.id.qmui_arch_reused_layout, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -850,6 +856,19 @@ public abstract class QMUIFragment extends Fragment implements QMUIFragmentLazyL
|
||||
*/
|
||||
protected abstract View onCreateView();
|
||||
|
||||
|
||||
/**
|
||||
* Corresponding to {@link #onCreateView()}, it called only when new UI (not cached UI)
|
||||
* is created by {@link #onCreateView()}.
|
||||
* It may be used to bind views to fragment and dynamically create child views such as
|
||||
* {@link QMUITopBar#addLeftBackImageButton()}
|
||||
*
|
||||
* @param rootView the view created by {@link #onCreateView()}
|
||||
*/
|
||||
protected void onViewCreated(@NonNull View rootView){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Will be performed in onStart
|
||||
*
|
||||
|
||||
@@ -419,6 +419,18 @@ public class SwipeBackLayout extends QMUIWindowInsetLayout {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applySystemWindowInsets19(Rect insets) {
|
||||
super.applySystemWindowInsets19(insets);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applySystemWindowInsets21(Object insets) {
|
||||
super.applySystemWindowInsets21(insets);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
|
||||
final boolean drawContent = child == mContentView;
|
||||
|
||||
@@ -18,4 +18,5 @@
|
||||
<resources>
|
||||
<item name="qmui_arch_swipe_layout_in_back" type="id"/>
|
||||
<item name="qmui_arch_swipe_offset_helper" type="id"/>
|
||||
<item name="qmui_arch_reused_layout" type="id"/>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user