示例#1
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: private void prepareActionButtons(final FcContext context, java.util.List<FcActionItem> actions, android.widget.LinearLayout parent)
        private void prepareActionButtons(FcContext context, IList <FcActionItem> actions, LinearLayout parent)
        {
            int i = 0;

            foreach (FcActionItem action in actions)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final android.widget.ImageButton button = context.inflate(com.samsung.android.sdk.professionalaudio.widgets.R.layout.fc_main_action_button, parent);
                ImageButton button = context.inflate(R.layout.fc_main_action_button, parent);

                button.ImageDrawable   = action.getIcon(context);
                button.Enabled         = action.Enabled;
                button.Visibility      = action.Visible ? View.VISIBLE : View.GONE;
                button.OnClickListener = new OnClickListenerAnonymousInnerClassHelper(this);
                int index = i;
                if (parent.LayoutDirection == View.LAYOUT_DIRECTION_RTL)
                {
                    index = actions.Count - index - 1;
                }
                DrawableTool.setBackground(button, index, actions.Count, context);

                parent.addView(button);
                i++;
            }
        }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: private void addBypassAction(FcContext fcContext, android.widget.LinearLayout linearLayout, final FcActionItem fcActionItem, int buttonText)
        private void addBypassAction(FcContext fcContext, LinearLayout linearLayout, FcActionItem fcActionItem, int buttonText)
        {
            Button bypassButton = (Button)LayoutInflater.from(fcContext.Context).inflate(R.layout.bypass_action_button, mDeviceActions, false);

            //        bypassButton.setBackground(fcActionItem.getIcon(fcContext));
            bypassButton.Enabled         = fcActionItem.Enabled;
            bypassButton.Visibility      = fcActionItem.Visible ? View.VISIBLE : View.GONE;
            bypassButton.Text            = fcContext.Context.Resources.getString(buttonText);
            bypassButton.OnClickListener = new OnClickListenerAnonymousInnerClassHelper2(this, fcActionItem);

            DrawableTool.setBackground(bypassButton, 0, 1, fcContext);
            linearLayout.addView(bypassButton);
        }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: private void addActionButton(final android.widget.LinearLayout linearLayout, final FcActionItem fcActionItem, final int resId, final int index, final int numberOfElements, final FcContext fcContext, final boolean adjustBackgroundToPositionInLayout)
        private void addActionButton(LinearLayout linearLayout, FcActionItem fcActionItem, int resId, int index, int numberOfElements, FcContext fcContext, bool adjustBackgroundToPositionInLayout)
        {
            ImageButton imageButton = (ImageButton)LayoutInflater.from(fcContext.Context).inflate(resId, mDeviceActions, false);

            imageButton.ImageDrawable   = fcActionItem.getIcon(fcContext);
            imageButton.Enabled         = fcActionItem.Enabled;
            imageButton.Visibility      = fcActionItem.Visible ? View.VISIBLE : View.GONE;
            imageButton.OnClickListener = new OnClickListenerAnonymousInnerClassHelper3(this, fcActionItem);

            if (adjustBackgroundToPositionInLayout)
            {
                DrawableTool.setBackground(imageButton, index, numberOfElements, fcContext);
            }

            linearLayout.addView(imageButton);
        }
        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;
            }
        }