Example usage for android.widget FrameLayout getTag

List of usage examples for android.widget FrameLayout getTag

Introduction

In this page you can find the example usage for android.widget FrameLayout getTag.

Prototype

@ViewDebug.ExportedProperty
public Object getTag() 

Source Link

Document

Returns this view's tag.

Usage

From source file:com.ndn.menurandom.ImageDownloader.java

private void makeFrameLayout(ImageView imageView) {
    boolean isExist = false;
    ViewGroup vg = (ViewGroup) imageView.getParent();
    if (vg instanceof FrameLayout) {
        FrameLayout frameLayout = (FrameLayout) vg;
        String tag = (String) frameLayout.getTag();
        if (tag != null && tag.equals("fl_imagedownloader")) {
            isExist = true;/*  ww  w.  j a  v a  2 s .c om*/
        }
    }

    if (!isExist) {
        int childCount = vg.getChildCount();
        int index = 0;
        while (index < childCount) {
            if (imageView == vg.getChildAt(index)) {
                break;
            }
            index++;
        }
        vg.removeViewAt(index);

        FrameLayout frameLayout = new FrameLayout(vg.getContext().getApplicationContext());
        frameLayout.setTag("fl_imagedownloader");
        ViewGroup.LayoutParams lpImageView = (ViewGroup.LayoutParams) imageView.getLayoutParams();
        frameLayout.setLayoutParams(lpImageView);
        imageView.setLayoutParams(new LayoutParams(lpImageView.width, lpImageView.height));
        frameLayout.setPadding(imageView.getPaddingLeft(), imageView.getPaddingTop(),
                imageView.getPaddingRight(), imageView.getPaddingBottom());
        imageView.setPadding(0, 0, 0, 0);
        frameLayout.addView(imageView);
        vg.addView(frameLayout, index);

        ProgressBar progressBar = new ProgressBar(frameLayout.getContext());
        progressBar.setTag("pb_imagedownloader");
        int leftRightPadding = (imageView.getLayoutParams().width - 50) / 2;
        int topBottomPadding = (imageView.getLayoutParams().height - 50) / 2;
        progressBar.setPadding(leftRightPadding, topBottomPadding, leftRightPadding, topBottomPadding);
        frameLayout.addView(progressBar);

    }
}

From source file:com.jrummyapps.android.colorpicker.ColorPickerDialog.java

private void setupTransparency() {
    int progress = 255 - Color.alpha(color);
    transparencySeekBar.setMax(255);//from ww w .ja  v  a  2s. co  m
    transparencySeekBar.setProgress(progress);
    int percentage = (int) ((double) progress * 100 / 255);
    transparencyPercText.setText(String.format(Locale.ENGLISH, "%d%%", percentage));
    transparencySeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            int percentage = (int) ((double) progress * 100 / 255);
            transparencyPercText.setText(String.format(Locale.ENGLISH, "%d%%", percentage));
            int alpha = 255 - progress;
            // update items in GridView:
            for (int i = 0; i < adapter.colors.length; i++) {
                int color = adapter.colors[i];
                int red = Color.red(color);
                int green = Color.green(color);
                int blue = Color.blue(color);
                adapter.colors[i] = Color.argb(alpha, red, green, blue);
            }
            adapter.notifyDataSetChanged();
            // update shades:
            for (int i = 0; i < shadesLayout.getChildCount(); i++) {
                FrameLayout layout = (FrameLayout) shadesLayout.getChildAt(i);
                ColorPanelView cpv = layout.findViewById(R.id.cpv_color_panel_view);
                ImageView iv = layout.findViewById(R.id.cpv_color_image_view);
                if (layout.getTag() == null) {
                    // save the original border color
                    layout.setTag(cpv.getBorderColor());
                }
                int color = cpv.getColor();
                color = Color.argb(alpha, Color.red(color), Color.green(color), Color.blue(color));
                if (alpha <= ALPHA_THRESHOLD) {
                    cpv.setBorderColor(color | 0xFF000000);
                } else {
                    cpv.setBorderColor((int) layout.getTag());
                }
                if (cpv.getTag() != null && (Boolean) cpv.getTag()) {
                    // The alpha changed on the selected shaded color. Update the checkmark color filter.
                    if (alpha <= ALPHA_THRESHOLD) {
                        iv.setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_IN);
                    } else {
                        if (ColorUtils.calculateLuminance(color) >= 0.65) {
                            iv.setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_IN);
                        } else {
                            iv.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN);
                        }
                    }
                }
                cpv.setColor(color);
            }
            // update color:
            int red = Color.red(color);
            int green = Color.green(color);
            int blue = Color.blue(color);
            color = Color.argb(alpha, red, green, blue);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });
}

From source file:com.jaredrummler.android.colorpicker.ColorPickerDialog.java

private void setupTransparency() {
    int progress = 255 - Color.alpha(color);
    transparencySeekBar.setMax(255);//from   w w w.j a  v  a2s . com
    transparencySeekBar.setProgress(progress);
    int percentage = (int) ((double) progress * 100 / 255);
    transparencyPercText.setText(String.format(Locale.ENGLISH, "%d%%", percentage));
    transparencySeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            int percentage = (int) ((double) progress * 100 / 255);
            transparencyPercText.setText(String.format(Locale.ENGLISH, "%d%%", percentage));
            int alpha = 255 - progress;
            // update items in GridView:
            for (int i = 0; i < adapter.colors.length; i++) {
                int color = adapter.colors[i];
                int red = Color.red(color);
                int green = Color.green(color);
                int blue = Color.blue(color);
                adapter.colors[i] = Color.argb(alpha, red, green, blue);
            }
            adapter.notifyDataSetChanged();
            // update shades:
            for (int i = 0; i < shadesLayout.getChildCount(); i++) {
                FrameLayout layout = (FrameLayout) shadesLayout.getChildAt(i);
                ColorPanelView cpv = (ColorPanelView) layout.findViewById(R.id.cpv_color_panel_view);
                ImageView iv = (ImageView) layout.findViewById(R.id.cpv_color_image_view);
                if (layout.getTag() == null) {
                    // save the original border color
                    layout.setTag(cpv.getBorderColor());
                }
                int color = cpv.getColor();
                color = Color.argb(alpha, Color.red(color), Color.green(color), Color.blue(color));
                if (alpha <= ALPHA_THRESHOLD) {
                    cpv.setBorderColor(color | 0xFF000000);
                } else {
                    cpv.setBorderColor((int) layout.getTag());
                }
                if (cpv.getTag() != null && (Boolean) cpv.getTag()) {
                    // The alpha changed on the selected shaded color. Update the checkmark color filter.
                    if (alpha <= ALPHA_THRESHOLD) {
                        iv.setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_IN);
                    } else {
                        if (ColorUtils.calculateLuminance(color) >= 0.65) {
                            iv.setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_IN);
                        } else {
                            iv.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN);
                        }
                    }
                }
                cpv.setColor(color);
            }
            // update color:
            int red = Color.red(color);
            int green = Color.green(color);
            int blue = Color.blue(color);
            color = Color.argb(alpha, red, green, blue);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });
}

From source file:com.pdftron.pdf.controls.UserCropDialogFragment.java

private void initUI(final View view) {
    final FrameLayout layout = (FrameLayout) view.findViewById(R.id.layout_root);
    mPageNumberTextView = (TextView) view.findViewById(R.id.page_num_text_view);
    mLayoutName = layout.getTag().toString();

    mDisablingOverlay = view.findViewById(R.id.disabling_overlay);
    mProgressBarHost = view.findViewById(R.id.progress_bar_host);
    mDisablingOverlay.setOnTouchListener(new View.OnTouchListener() {
        @Override//from  ww  w .ja  v  a 2  s . c  om
        public boolean onTouch(View v, MotionEvent event) {
            return true; // ensure the user can't click buttons
        }
    });

    mCropPageHost = (RelativeLayout) view.findViewById(R.id.page_crop_host);

    mCropImageBorder = view.findViewById(R.id.image_crop_border);

    mCropImageView = (com.edmodo.cropper.CropImageView) view.findViewById(R.id.image_crop_view);
    mCropImageView.setGuidelines(0); // off

    mCropImageBorder.setVisibility(View.GONE);

    mBlankPagePlaceholder = view.findViewById(R.id.blank_page_placeholder);
    mBlankPageSpinnerHost = (ContentLoadingRelativeLayout) view.findViewById(R.id.blank_page_progress_bar_host);

    if (mRemoveCropHelperMode) {
        View manualCropRoot = view.findViewById(R.id.manual_crop_root_layout);
        manualCropRoot.setVisibility(View.GONE);

        setCropBoxAndClose();
    } else {
        mCropPageHost.postDelayed(new Runnable() {
            @Override
            public void run() {
                if (mIsActive) {

                    if (mLayoutName.equals("layout-sw480dp-port")
                            || mLayoutName.equals("layout-sw480dp-land")) {
                        if (view.getWidth() < 540) {
                            View buttonHost = view.findViewById(R.id.page_buttons_host);
                            int[] location = new int[2];
                            buttonHost.getLocationInWindow(location);
                            int buttonsLeft = location[0];
                            View pageNumText = view.findViewById(R.id.page_num_text_view);
                            pageNumText.getLocationInWindow(location);
                            int pageNumRight = location[0] + pageNumText.getWidth();
                            if (pageNumRight > buttonsLeft - 10) {
                                RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) buttonHost
                                        .getLayoutParams();
                                layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
                                layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, 0);
                            }
                        }
                    }

                    mCropImageBorder.setVisibility(View.VISIBLE);
                    setPage(mCurrentPage);
                }
            }
        }, 200); // Extra delay to ensure that view has time to settle. post alone doesn't work.
    }

    getButtons(view);

    if (mDisablingOverlayShowing) {
        mDisablingOverlay.setVisibility(View.VISIBLE);
    }
    if (mSpinnerShowing) {
        mProgressBarHost.setVisibility(View.VISIBLE);
    }
}