ItemNoTitleLayoutManager.java
5.02 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*
* Copyright (c) People Technologies Co., Ltd. 2019-2022. All rights reserved.
*/
package com.wd.display.comp.page;
import android.text.TextUtils;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.Observer;
import com.orhanobut.logger.Logger;
import com.people.common.constant.Constants;
import com.people.component.R;
import com.people.component.comp.layoutmanager.ItemContainerManager;
import com.people.component.ui.channel.listener.PageInforToLayoutManagerCallback;
import com.people.component.ui.fragment.ColumnFragment;
import com.people.component.utils.ColorUtils;
import com.people.entity.custom.MenuBean;
import com.people.entity.custom.comp.ChannelInfoBean;
import com.people.entity.custom.comp.TopicInfoBean;
import com.people.entity.theme.ThemeMessage;
import com.people.livedate.EventConstants;
import com.people.livedate.base.LiveDataBus;
import com.wondertek.wheat.ability.tools.ViewUtils;
/**
* 全屏无标题布局管理器
*
* @version 1.0.0
* @description:
* @author: liyubing
* @date :2023/2/2 15:56
*/
public class ItemNoTitleLayoutManager extends ItemContainerManager<MenuBean> {
private static final String TAG = "ItemTopTextSearch";
private FrameLayout rvContent;
private ImageView backgroundBottomBg;
private ConstraintLayout clParent;
private String pageId;
private ColumnFragment mColumnFragment;
@Override
public int getItemViewType() {
return R.layout.page_item_layout_no_title;
}
@Override
public void prepareItem(View itemView, int position) {
Logger.t(TAG).d("prepareItem");
}
@Override
public int bindItem(View itemView, int position, MenuBean data) {
if (data == null) {
return position;
}
rvContent = ViewUtils.findViewById(itemView, R.id.rv_content);
clParent = ViewUtils.findViewById(itemView, R.id.clParent);
backgroundBottomBg = ViewUtils.findViewById(itemView, R.id.fragment_top_bg_item);
pageId = data.getPageId();
mColumnFragment = ColumnFragment.newInstance(pageId);
mColumnFragment.setPageLayoutManagerListener(tabChangInter);
mColumnFragment.setSuperRootLayout(clParent);
if (getFragment() != null) {
FragmentManager fragmentManager = getFragment().getChildFragmentManager();
FragmentTransaction ft = fragmentManager.beginTransaction();
ft.add(R.id.rv_content, mColumnFragment);
ft.commit();
// 注册Event 事件
registerEventBus();
}
int topMargin = data.getTopMargin();
ConstraintLayout.LayoutParams rvContentLp = (ConstraintLayout.LayoutParams) rvContent.getLayoutParams();
rvContentLp.topMargin = topMargin;
rvContent.setLayoutParams(rvContentLp);
return position;
}
private PageInforToLayoutManagerCallback tabChangInter = new PageInforToLayoutManagerCallback() {
@Override
public void onPageThemeChange( ThemeMessage message) {
if (message == null) {
return;
}
Logger.t(TAG).d("onChangeTheme, getBackgroundColor: " + message.getBackgroundColor());
setTopOrNavBackgroud(message.getBackgroundImage(), message.getBackgroundColor());
}
@Override
public void listenerTopicInfoBean(TopicInfoBean bean) {
}
@Override
public void listenerChannelInfoBean(ChannelInfoBean bean) {
}
@Override
public void fragmentRequestCallback(boolean isRefresh, boolean isOpenLoadMore) {
}
@Override
public void isTop() {
}
@Override
public void failedPage(int errorCode) {
}
};
/**
* 注册EventBus接收器
*/
private void registerEventBus() {
// 注册登录EventBus
LiveDataBus.getInstance().with(EventConstants.USER_ALREADY_LOGIN, Boolean.class).observe(getFragment(), new Observer<Boolean>() {
@Override
public void onChanged(Boolean aBoolean) {
if (mColumnFragment != null) {
mColumnFragment.handlerLoginLogic(aBoolean);
}
}
});
}
/**
* 统一设置顶部背景图或导航栏颜色
*
* @param topBackgroundImageUrl
* @param navBackgroundColor
*/
public void setTopOrNavBackgroud(String topBackgroundImageUrl, String navBackgroundColor) {
// ImageUtils.getInstance().homeThemeImageLoadAndSave(backgroundBottomBg, 0, topBackgroundImageUrl,com.people.daily.english.toolset.R.drawable.shape_ellipse_white_theme);
if (TextUtils.isEmpty(navBackgroundColor)) {
ColorUtils.setBackgroundColor(clParent, Constants.DEFUALT_PAGE_COLOR);
} else {
ColorUtils.setBackgroundColor(clParent, navBackgroundColor);
}
}
}