@@ -23,7 +23,7 @@ public class EmoticonsToolBarView extends RelativeLayout {
2323
2424 protected LayoutInflater mInflater ;
2525 protected Context mContext ;
26- protected ArrayList <View > mToolBtnList = new ArrayList <>();
26+ protected final ArrayList <View > mToolBtnList = new ArrayList <>();
2727 protected int mBtnWidth ;
2828
2929 protected HorizontalScrollView hsv_toolbar ;
@@ -68,6 +68,75 @@ public void addFixedToolItemView(View view, boolean isRight) {
6868 hsv_toolbar .setLayoutParams (hsvParams );
6969 }
7070
71+ public View addFixedToolItemView (boolean isRight , int rec , final PageSetEntity pageSetEntity , OnClickListener onClickListener ) {
72+ View toolBtnView = getCommonItemToolBtn ();
73+ LayoutParams params = new LayoutParams (LayoutParams .WRAP_CONTENT , LayoutParams .MATCH_PARENT );
74+ LayoutParams hsvParams = (LayoutParams ) hsv_toolbar .getLayoutParams ();
75+ if (toolBtnView .getId () <= 0 ) {
76+ toolBtnView .setId (isRight ? R .id .id_toolbar_right : R .id .id_toolbar_left );
77+ }
78+ if (isRight ) {
79+ params .addRule (ALIGN_PARENT_RIGHT );
80+ hsvParams .addRule (LEFT_OF , toolBtnView .getId ());
81+ } else {
82+ params .addRule (ALIGN_PARENT_LEFT );
83+ hsvParams .addRule (RIGHT_OF , toolBtnView .getId ());
84+ }
85+ addView (toolBtnView , params );
86+ hsv_toolbar .setLayoutParams (hsvParams );
87+ initItemToolBtn (toolBtnView , rec , pageSetEntity , onClickListener );
88+ return toolBtnView ;
89+ }
90+
91+ public View addToolItemView (PageSetEntity pageSetEntity ) {
92+ return addToolItemView (0 , pageSetEntity , null );
93+ }
94+
95+ public View addToolItemView (int rec , OnClickListener onClickListener ) {
96+ return addToolItemView (rec , null , onClickListener );
97+ }
98+
99+ public View addToolItemView (int rec , final PageSetEntity pageSetEntity , OnClickListener onClickListener ) {
100+ View toolBtnView = getCommonItemToolBtn ();
101+ if (pageSetEntity != null ) {
102+ toolBtnView .setTag (R .id .id_toolbar_uuid , pageSetEntity .getUuid ());
103+ }
104+ initItemToolBtn (toolBtnView , rec , pageSetEntity , onClickListener );
105+ ly_tool .addView (toolBtnView );
106+ mToolBtnList .add (getToolBgBtn (toolBtnView ));
107+ return toolBtnView ;
108+ }
109+
110+ public void clear () {
111+ mToolBtnList .clear ();
112+ hsv_toolbar .removeAllViews ();
113+ }
114+
115+ public void remove (PageSetEntity pageSetEntity ) {
116+ if (pageSetEntity == null ) {
117+ return ;
118+ }
119+ String uuid = pageSetEntity .getUuid ();
120+ if (TextUtils .isEmpty (uuid )) {
121+ return ;
122+ }
123+
124+ for (int i = 0 ; i < ly_tool .getChildCount (); i ++) {
125+ if (uuid .equals (ly_tool .getChildAt (i ).getTag (R .id .id_toolbar_uuid ))){
126+ mToolBtnList .remove (ly_tool .getChildAt (i ));
127+ ly_tool .removeView (ly_tool .getChildAt (i ));
128+ }
129+ }
130+ }
131+
132+ public void removeFixed (boolean isLeft ) {
133+ int id = isLeft ? R .id .id_toolbar_left : R .id .id_toolbar_right ;
134+ View view = hsv_toolbar .findViewById (id );
135+ if (view != null ) {
136+ hsv_toolbar .removeView (view );
137+ }
138+ }
139+
71140 protected View getCommonItemToolBtn () {
72141 return mInflater == null ? null : mInflater .inflate (R .layout .item_toolbtn , null );
73142 }
@@ -101,40 +170,6 @@ protected View getToolBgBtn(View parentView) {
101170 return parentView .findViewById (R .id .iv_icon );
102171 }
103172
104- public void addFixedToolItemView (boolean isRight , int rec , final PageSetEntity pageSetEntity , OnClickListener onClickListener ) {
105- View toolBtnView = getCommonItemToolBtn ();
106- LayoutParams params = new LayoutParams (LayoutParams .WRAP_CONTENT , LayoutParams .MATCH_PARENT );
107- LayoutParams hsvParams = (LayoutParams ) hsv_toolbar .getLayoutParams ();
108- if (toolBtnView .getId () <= 0 ) {
109- toolBtnView .setId (isRight ? R .id .id_toolbar_right : R .id .id_toolbar_left );
110- }
111- if (isRight ) {
112- params .addRule (ALIGN_PARENT_RIGHT );
113- hsvParams .addRule (LEFT_OF , toolBtnView .getId ());
114- } else {
115- params .addRule (ALIGN_PARENT_LEFT );
116- hsvParams .addRule (RIGHT_OF , toolBtnView .getId ());
117- }
118- addView (toolBtnView , params );
119- hsv_toolbar .setLayoutParams (hsvParams );
120- initItemToolBtn (toolBtnView , rec , pageSetEntity , onClickListener );
121- }
122-
123- public void addToolItemView (PageSetEntity pageSetEntity ) {
124- addToolItemView (0 , pageSetEntity , null );
125- }
126-
127- public void addToolItemView (int rec , OnClickListener onClickListener ) {
128- addToolItemView (rec , null , onClickListener );
129- }
130-
131- public void addToolItemView (int rec , final PageSetEntity pageSetEntity , OnClickListener onClickListener ) {
132- View toolBtnView = getCommonItemToolBtn ();
133- initItemToolBtn (toolBtnView , rec , pageSetEntity , onClickListener );
134- ly_tool .addView (toolBtnView );
135- mToolBtnList .add (getToolBgBtn (toolBtnView ));
136- }
137-
138173 public void setToolBtnSelect (String uuid ) {
139174 if (TextUtils .isEmpty (uuid )) {
140175 return ;
0 commit comments