CommonFragment.java
2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package com.wd.display.ui.fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.people.common.constant.IntentConstants;
import com.people.component.R;
import com.people.component.comp.page.ItemNoTitleLayoutManager;
import com.people.entity.custom.MenuBean;
import com.wd.base.log.Logger;
import com.wd.foundation.wdkit.base.BaseLazyFragment;
import com.wondertek.wheat.ability.tools.SafeBundleUtil;
/**
* 常见碎片
*
* @version 1.0.0
* @description:
* @author: liyubing
* @date :2023/2/3 15:25
*/
public class CommonFragment extends BaseLazyFragment {// channelFragment
private static final String TAG = "CommonFragment";
private String mPageId;
private MenuBean pageObj;
private FrameLayout mRootView;
private ItemNoTitleLayoutManager mLayoutManager;
private View pageView;
/**
* 获取Fragment实例对象
*
* @param bean 数据id
* @return Fragment实例
*/
public static CommonFragment newInstance(MenuBean bean) {
CommonFragment fragment = new CommonFragment();
Bundle bundle = new Bundle();
bundle.putSerializable(IntentConstants.PARAM_PAGE_OBJ, bean);
fragment.setArguments(bundle);
return fragment;
}
@Override
protected String getLogTag() {
return TAG;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
initViewModel();
pageObj = (MenuBean) SafeBundleUtil.getSerializable(getArguments(), IntentConstants.PARAM_PAGE_OBJ);
if (pageObj != null) {
mPageId = pageObj.getPageId();
}
}
@Override
protected int getLayout() {
return R.layout.fragment_main;
}
@Override
protected void initView(View view) {
mRootView = ViewUtils.findViewById(view, R.id.container);
initPageView(mRootView);
}
@Override
protected void lazyLoadData() {
initData();
}
private void initViewModel() {
}
private void initPageView(@NonNull ViewGroup rootView) {
Logger.t(TAG).i("initNavBar");
mLayoutManager = new ItemNoTitleLayoutManager();
pageView = LayoutInflater.from(getContext()).inflate(mLayoutManager.getItemViewType(), rootView, false);
rootView.removeView(pageView);
rootView.addView(pageView);
}
private void initData() {
int status_height = StatusBarCompat.getStatusBarHeight(getActivity());
pageObj.setTopMargin(status_height);
mLayoutManager.setFragment(this);
mLayoutManager.prepareItem(mRootView, 0);
mLayoutManager.bindItem(mRootView, 0, pageObj);
}
}