2222import com .fox2code .mmm .MainApplication ;
2323import com .fox2code .mmm .NotificationType ;
2424import com .fox2code .mmm .R ;
25+ import com .fox2code .mmm .compat .CompatDisplay ;
2526import com .fox2code .mmm .manager .LocalModuleInfo ;
2627import com .fox2code .mmm .manager .ModuleInfo ;
2728import com .fox2code .mmm .manager .ModuleManager ;
@@ -75,14 +76,13 @@ public static class ViewHolder extends RecyclerView.ViewHolder {
7576 private final TextView creditText ;
7677 private final TextView descriptionText ;
7778 private final HorizontalScrollView moduleOptionsHolder ;
79+ private final TextView moduleLayoutHelper ;
7880 private final TextView updateText ;
7981 private final Chip [] actionsButtons ;
8082 private final ArrayList <ActionButtonType > actionButtonsTypes ;
8183 private boolean initState ;
8284 public ModuleHolder moduleHolder ;
8385 public Drawable background ;
84- private boolean canExpand ;
85- private boolean expanded ;
8686
8787 public ViewHolder (@ NonNull View itemView ) {
8888 super (itemView );
@@ -95,6 +95,7 @@ public ViewHolder(@NonNull View itemView) {
9595 this .creditText = itemView .findViewById (R .id .credit_text );
9696 this .descriptionText = itemView .findViewById (R .id .description_text );
9797 this .moduleOptionsHolder = itemView .findViewById (R .id .module_options_holder );
98+ this .moduleLayoutHelper = itemView .findViewById (R .id .module_layout_helper );
9899 this .updateText = itemView .findViewById (R .id .updated_text );
99100 this .actionsButtons = new Chip [6 ];
100101 this .actionsButtons [0 ] = itemView .findViewById (R .id .button_action1 );
@@ -114,11 +115,6 @@ public ViewHolder(@NonNull View itemView) {
114115 } else if (moduleHolder .notificationType != null ) {
115116 onClickListener = moduleHolder .notificationType .onClickListener ;
116117 if (onClickListener != null ) onClickListener .onClick (v );
117- } else if (this .canExpand ) {
118- this .cardView .setClickable (false );
119- if (this .expanded ) return ;
120- this .expanded = true ;
121- // TODO Animated expand code
122118 }
123119 }
124120 });
@@ -178,17 +174,13 @@ public boolean update(ModuleHolder moduleHolder) {
178174 this .cardView .setVisibility (View .GONE );
179175 this .moduleHolder = null ;
180176 this .initState = false ;
181- this .expanded = false ;
182177 return true ;
183- } else if (moduleHolder != this .moduleHolder ) {
184- this .expanded = false ;
185178 }
186179 ModuleHolder .Type type = moduleHolder .getType ();
187180 ModuleHolder .Type vType = moduleHolder .getCompareType (type );
188181 this .cardView .setVisibility (View .VISIBLE );
189182 boolean showCaseMode = MainApplication .isShowcaseMode ();
190183 if (moduleHolder .isModuleHolder ()) {
191- this .canExpand = false ;
192184 this .buttonAction .setVisibility (View .GONE );
193185 this .buttonAction .setBackground (null );
194186 LocalModuleInfo localModuleInfo = moduleHolder .moduleInfo ;
@@ -201,6 +193,7 @@ public boolean update(ModuleHolder moduleHolder) {
201193 }
202194 this .creditText .setVisibility (View .VISIBLE );
203195 this .moduleOptionsHolder .setVisibility (View .VISIBLE );
196+ this .moduleLayoutHelper .setVisibility (View .VISIBLE );
204197 this .descriptionText .setVisibility (View .VISIBLE );
205198
206199 ModuleInfo moduleInfo = moduleHolder .getMainModuleInfo ();
@@ -230,6 +223,7 @@ public boolean update(ModuleHolder moduleHolder) {
230223 this .descriptionText .setText (moduleInfo .description );
231224 }
232225 String updateText = moduleHolder .getUpdateTimeText ();
226+ boolean hasUpdateText = true ;
233227 if (!updateText .isEmpty ()) {
234228 RepoModule repoModule = moduleHolder .repoModule ;
235229 this .updateText .setVisibility (View .VISIBLE );
@@ -247,8 +241,7 @@ public boolean update(ModuleHolder moduleHolder) {
247241 this .updateText .setText (R .string .substratum_builtin_module );
248242 } else {
249243 this .updateText .setVisibility (View .GONE );
250- this .canExpand = false ;
251- this .expanded = true ;
244+ hasUpdateText = false ;
252245 }
253246 this .actionButtonsTypes .clear ();
254247 moduleHolder .getButtons (itemView .getContext (), this .actionButtonsTypes , showCaseMode );
@@ -271,8 +264,13 @@ public boolean update(ModuleHolder moduleHolder) {
271264 }
272265 }
273266 if (this .actionButtonsTypes .isEmpty ()) {
274- this .canExpand = false ;
275- this .expanded = false ;
267+ this .moduleOptionsHolder .setVisibility (View .GONE );
268+ this .moduleLayoutHelper .setVisibility (View .GONE );
269+ } else if (this .actionButtonsTypes .size () > 3 || !hasUpdateText ) {
270+ this .moduleLayoutHelper .setMinHeight (
271+ this .moduleOptionsHolder .getHeight () - CompatDisplay .dpToPixel (14F ));
272+ } else {
273+ this .moduleLayoutHelper .setMinHeight (CompatDisplay .dpToPixel (4F ));
276274 }
277275 this .cardView .setClickable (false );
278276 if (moduleHolder .isModuleHolder () &&
@@ -282,8 +280,6 @@ public boolean update(ModuleHolder moduleHolder) {
282280 this .titleText .setTypeface (Typeface .DEFAULT );
283281 }
284282 } else {
285- this .canExpand = false ;
286- this .expanded = false ;
287283 if (type == ModuleHolder .Type .SEPARATOR && moduleHolder .filterLevel != 0 ) {
288284 this .buttonAction .setVisibility (View .VISIBLE );
289285 this .buttonAction .setImageResource (moduleHolder .filterLevel );
@@ -297,6 +293,7 @@ public boolean update(ModuleHolder moduleHolder) {
297293 this .switchMaterial .setVisibility (View .GONE );
298294 this .creditText .setVisibility (View .GONE );
299295 this .moduleOptionsHolder .setVisibility (View .GONE );
296+ this .moduleLayoutHelper .setVisibility (View .GONE );
300297 this .descriptionText .setVisibility (View .GONE );
301298 this .updateText .setVisibility (View .GONE );
302299 this .titleText .setText (" " );
@@ -384,11 +381,6 @@ public boolean update(ModuleHolder moduleHolder) {
384381 } else {
385382 this .titleText .setMinHeight (0 );
386383 }
387- if (this .expanded ) {
388- // TODO Static expand code
389- } else {
390- // TODO Static retract code
391- }
392384 this .moduleHolder = moduleHolder ;
393385 this .initState = false ;
394386 return false ;
0 commit comments