public override void prepareViewHolder(FcContext fcContext, FcAdapterModel model, FcModelItem item) { if (FcConstants.OPT_DETAILED_LOGS) { Log.d(TAG, "prepareViewHolder(" + item + ")"); } Context context = fcContext.Context; cleanLayouts(); mFcModelItem = item; mExpandActionsButtonListener.Item = mFcModelItem; if (item.Expanded) { mDeviceRootLayout.Visibility = View.VISIBLE; mDeviceRootLayout.LayoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT; } else { mDeviceRootLayout.Visibility = View.VISIBLE; mDeviceRootLayout.LayoutParams.width = 0; } mDeviceRootLayout.requestLayout(); // Setting up device_app_button mDeviceAppButton.Background = getBackground(fcContext, item.Active); LinearLayout.LayoutParams @params = (LinearLayout.LayoutParams) mDeviceAppButton.LayoutParams; @params.gravity = Gravity.CENTER; int padding = context.Resources.getDimensionPixelSize(R.dimen.floating_controller_active_app_frame_stroke_width) + context.Resources.getDimensionPixelSize(R.dimen.floating_controller_ordinal_app_layout_distance_between_app_icon_and_active_indication_frame); Drawable deviceAppDrawable = mFcModelItem.Icon; if (model.isMultiInstance(item)) { int number = model.getInstanceNumber(item); int iconSize = context.Resources.getDimensionPixelSize(R.dimen.ord_app_expand_action_button_width); deviceAppDrawable = DrawableTool.getDrawableWithNumber(deviceAppDrawable, number, iconSize, context); } mIsFreeze = model.isAppFreeze(item.InstanceId); if (mIsFreeze) { deviceAppDrawable = getFreezeDrawable(fcContext.Context, deviceAppDrawable); } int actionCount = item.CallActions.Count; actionCount += item.VolumeActions.Count; actionCount += item.ReturnActions.Count; if (actionCount > 1) { mDeviceAppButton.OnClickListener = mExpandActionsButtonListener; } else { mDeviceAppButton.OnClickListener = mOpenAppDirectlyButtonListener; } mDeviceAppButton.setPadding(padding, padding, padding, padding); mDeviceAppButton.ImageDrawable = deviceAppDrawable; // Open Actions //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.List<FcActionItem> returnActions = item.getReturnActions(); IList<FcActionItem> returnActions = item.ReturnActions; int numberOfElements = returnActions.Count; for (int i = 0; i < numberOfElements; i++) { addActionButton(mDeviceOpenActions, returnActions[i], R.layout.fc_ordinal_open_app_button, i, numberOfElements, fcContext, false); } if (numberOfElements > 0) { mDeviceOpenActions.Visibility = View.VISIBLE; } else { mDeviceOpenActions.Visibility = View.GONE; } // Call Actions //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.List<FcActionItem> callActions = item.getCallActions(); IList<FcActionItem> callActions = item.CallActions; numberOfElements = callActions.Count; string bypassOn = fcContext.Context.Resources.getString([email protected]_on); string bypassOff = fcContext.Context.Resources.getString([email protected]_off); for (int i = 0; i < numberOfElements; i++) { string itemId = callActions[i].Id; if (itemId.Equals(bypassOff)) { addBypassAction(fcContext, mDeviceActions, callActions[i], [email protected]_text_off); } else if (itemId.Equals(bypassOn)) { addBypassAction(fcContext, mDeviceActions, callActions[i], [email protected]_text_on); } else { addActionButton(mDeviceActions, callActions[i], R.layout.fc_ordinal_action_button, i, numberOfElements, fcContext, true); } } if (numberOfElements > 0) { mDeviceActions.Visibility = View.VISIBLE; } else { mDeviceActions.Visibility = View.GONE; } // Volume Actions if (item.hasVolumeActions()) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.List<FcActionItem> volumeActions = item.getVolumeActions(); IList<FcActionItem> volumeActions = item.VolumeActions; numberOfElements = volumeActions.Count; // handle volume label anomaly if (item.Direction == LinearLayout.LAYOUT_DIRECTION_LTR) { for (int i = 0; i < numberOfElements; i++) { addActionButton(mDeviceVolumes, volumeActions[i], R.layout.fc_ordinal_action_button, i, numberOfElements, fcContext, true); } } else { for (int i = numberOfElements - 1; i >= 0; i--) { addActionButton(mDeviceVolumes, volumeActions[i], R.layout.fc_ordinal_action_button, numberOfElements - 1 - i, numberOfElements, fcContext, true); } } // this handles the requirement that volume label is always before volume actions in a layout float marginSize = fcContext.getDimensionPixelSize(R.dimen.ord_app_action_volume_layout_margin_ltr); if (item.Direction == LinearLayout.LAYOUT_DIRECTION_RTL) { marginSize = fcContext.getDimensionPixelSize(R.dimen.ord_app_action_volume_layout_margin_rtl); } reverseLayoutWithMargins(mDeviceVolumeActions, item.Direction, marginSize); mDeviceVolumeActions.Visibility = View.VISIBLE; } else { mDeviceVolumeActions.Visibility = View.GONE; } }
public override void prepareViewHolder(FcContext fcContext, FcAdapterModel model, FcModelItem item) { if (FcConstants.OPT_DETAILED_LOGS) { Log.d(TAG, "prepareViewHolder(" + item + ")"); } Context context = fcContext.Context; cleanLayouts(); mFcModelItem = item; mExpandActionsButtonListener.Item = mFcModelItem; if (item.Expanded) { mDeviceRootLayout.Visibility = View.VISIBLE; mDeviceRootLayout.LayoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT; } else { mDeviceRootLayout.Visibility = View.VISIBLE; mDeviceRootLayout.LayoutParams.width = 0; } mDeviceRootLayout.requestLayout(); // Setting up device_app_button mDeviceAppButton.Background = getBackground(fcContext, item.Active); LinearLayout.LayoutParams @params = (LinearLayout.LayoutParams)mDeviceAppButton.LayoutParams; @params.gravity = Gravity.CENTER; int padding = context.Resources.getDimensionPixelSize(R.dimen.floating_controller_active_app_frame_stroke_width) + context.Resources.getDimensionPixelSize(R.dimen.floating_controller_ordinal_app_layout_distance_between_app_icon_and_active_indication_frame); Drawable deviceAppDrawable = mFcModelItem.Icon; if (model.isMultiInstance(item)) { int number = model.getInstanceNumber(item); int iconSize = context.Resources.getDimensionPixelSize(R.dimen.ord_app_expand_action_button_width); deviceAppDrawable = DrawableTool.getDrawableWithNumber(deviceAppDrawable, number, iconSize, context); } mIsFreeze = model.isAppFreeze(item.InstanceId); if (mIsFreeze) { deviceAppDrawable = getFreezeDrawable(fcContext.Context, deviceAppDrawable); } int actionCount = item.CallActions.Count; actionCount += item.VolumeActions.Count; actionCount += item.ReturnActions.Count; if (actionCount > 1) { mDeviceAppButton.OnClickListener = mExpandActionsButtonListener; } else { mDeviceAppButton.OnClickListener = mOpenAppDirectlyButtonListener; } mDeviceAppButton.setPadding(padding, padding, padding, padding); mDeviceAppButton.ImageDrawable = deviceAppDrawable; // Open Actions //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.List<FcActionItem> returnActions = item.getReturnActions(); IList <FcActionItem> returnActions = item.ReturnActions; int numberOfElements = returnActions.Count; for (int i = 0; i < numberOfElements; i++) { addActionButton(mDeviceOpenActions, returnActions[i], R.layout.fc_ordinal_open_app_button, i, numberOfElements, fcContext, false); } if (numberOfElements > 0) { mDeviceOpenActions.Visibility = View.VISIBLE; } else { mDeviceOpenActions.Visibility = View.GONE; } // Call Actions //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.List<FcActionItem> callActions = item.getCallActions(); IList <FcActionItem> callActions = item.CallActions; numberOfElements = callActions.Count; string bypassOn = fcContext.Context.Resources.getString([email protected]_on); string bypassOff = fcContext.Context.Resources.getString([email protected]_off); for (int i = 0; i < numberOfElements; i++) { string itemId = callActions[i].Id; if (itemId.Equals(bypassOff)) { addBypassAction(fcContext, mDeviceActions, callActions[i], [email protected]_text_off); } else if (itemId.Equals(bypassOn)) { addBypassAction(fcContext, mDeviceActions, callActions[i], [email protected]_text_on); } else { addActionButton(mDeviceActions, callActions[i], R.layout.fc_ordinal_action_button, i, numberOfElements, fcContext, true); } } if (numberOfElements > 0) { mDeviceActions.Visibility = View.VISIBLE; } else { mDeviceActions.Visibility = View.GONE; } // Volume Actions if (item.hasVolumeActions()) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.List<FcActionItem> volumeActions = item.getVolumeActions(); IList <FcActionItem> volumeActions = item.VolumeActions; numberOfElements = volumeActions.Count; // handle volume label anomaly if (item.Direction == LinearLayout.LAYOUT_DIRECTION_LTR) { for (int i = 0; i < numberOfElements; i++) { addActionButton(mDeviceVolumes, volumeActions[i], R.layout.fc_ordinal_action_button, i, numberOfElements, fcContext, true); } } else { for (int i = numberOfElements - 1; i >= 0; i--) { addActionButton(mDeviceVolumes, volumeActions[i], R.layout.fc_ordinal_action_button, numberOfElements - 1 - i, numberOfElements, fcContext, true); } } // this handles the requirement that volume label is always before volume actions in a layout float marginSize = fcContext.getDimensionPixelSize(R.dimen.ord_app_action_volume_layout_margin_ltr); if (item.Direction == LinearLayout.LAYOUT_DIRECTION_RTL) { marginSize = fcContext.getDimensionPixelSize(R.dimen.ord_app_action_volume_layout_margin_rtl); } reverseLayoutWithMargins(mDeviceVolumeActions, item.Direction, marginSize); mDeviceVolumeActions.Visibility = View.VISIBLE; } else { mDeviceVolumeActions.Visibility = View.GONE; } }