Example usage for android.graphics RectF RectF

List of usage examples for android.graphics RectF RectF

Introduction

In this page you can find the example usage for android.graphics RectF RectF.

Prototype

public RectF(float left, float top, float right, float bottom) 

Source Link

Document

Create a new rectangle with the specified coordinates.

Usage

From source file:com.googlecode.eyesfree.widget.RadialMenuView.java

private void drawCenterDot(Canvas canvas, int width, int height) {
    final Context context = getContext();
    final float centerX = (width / 2.0f);
    final float centerY = (height / 2.0f);
    final float radius = mInnerRadius;
    final RectF dotBounds = new RectF((centerX - radius), (centerY - radius), (centerX + radius),
            (centerY + radius));/*from   ww  w.  java  2 s  .c  o m*/

    mPaint.setStyle(Style.FILL);
    mPaint.setColor(mDotFillColor);
    mPaint.setShadowLayer(mTextShadowRadius, 0, 0, mTextShadowColor);
    canvas.drawOval(dotBounds, mPaint);
    mPaint.setShadowLayer(0, 0, 0, 0);

    if (mDotStrokeWidth >= 0) {
        contractBounds(dotBounds, (mDotStrokeWidth / 2));

        mPaint.setStrokeWidth(mDotStrokeWidth);
        mPaint.setStyle(Style.STROKE);
        mPaint.setColor(mDotStrokeColor);
        mPaint.setPathEffect(mDotPathEffect);
        canvas.drawOval(dotBounds, mPaint);
        mPaint.setPathEffect(null);
    }
}

From source file:com.zenithed.core.widget.scaledimageview.ScaledImageView.java

/**
 * Loads the optimum tiles for display at the current scale and translate, so the screen can be filled with tiles
 * that are at least as high resolution as the screen. Frees up bitmaps that are now off the screen.
 * @param load Whether to load the new tiles needed. Use false while scrolling/panning for performance.
 *///from  ww w  . j  a v  a  2 s . c  om
private void refreshRequiredTiles(boolean load) {
    final int sampleSize = Math.min(mFullImageSampleSize,
            calculateInSampleSize((int) (mScale * mContentWidth), (int) (mScale * mContentHeight)));
    final RectF vVisRect = new RectF(0, 0, getWidth(), getHeight());
    final RectF sVisRect = viewToSourceRect(vVisRect);

    // Load tiles of the correct sample size that are on screen. Discard tiles off screen, and those that are higher
    // resolution than required, or lower res than required but not the base layer, so the base layer is always present.
    final SparseArray<List<Tile>> tileMap = mTileMap;
    final int SIZE = mTileMap.size();

    List<Tile> tileList = null;

    for (int i = 0; i < SIZE; i++) {
        tileList = tileMap.valueAt(i);
        for (Tile tile : tileList) {
            if (tile.sampleSize < sampleSize
                    || (tile.sampleSize > sampleSize && tile.sampleSize != mFullImageSampleSize)) {
                tile.visible = false;
                if (tile.bitmap != null) {
                    tile.bitmap.recycle();
                    tile.bitmap = null;
                }
            }
            if (tile.sampleSize == sampleSize) {
                if (RectF.intersects(sVisRect, convertRect(tile.sRect))) {
                    tile.visible = true;
                    if (!tile.loading && tile.bitmap == null && load) {
                        BitmapTileTask task = new BitmapTileTask(this, mBitmapRegionDecoder, tile);
                        task.execute();

                        mTasks.add(task);
                    }
                } else if (tile.sampleSize != mFullImageSampleSize) {
                    tile.visible = false;
                    if (tile.bitmap != null) {
                        tile.bitmap.recycle();
                        tile.bitmap = null;
                    }
                }
            } else if (tile.sampleSize == mFullImageSampleSize) {
                tile.visible = true;
            }
        }
    }

}

From source file:com.android.screenspeak.contextmenu.RadialMenuView.java

private void drawCancel(Canvas canvas) {
    final float centerX = mCenter.x;
    final float centerY = mCenter.y;
    final float radius = mInnerRadius;
    final float iconRadius = (radius / 4.0f);

    final RectF dotBounds = new RectF((centerX - radius), (centerY - radius), (centerX + radius),
            (centerY + radius));//  w w w . j a  v  a2 s  .co m

    // Apply the appropriate color filters.
    final boolean selected = (mFocusedItem == null);

    mPaint.setStyle(Style.FILL);
    mPaint.setColor(selected ? mSelectionColor : mCenterFillColor);
    mPaint.setShadowLayer(mShadowRadius, 0, 0, (selected ? mSelectionShadowColor : mTextShadowColor));
    canvas.drawOval(dotBounds, mPaint);
    mPaint.setShadowLayer(0, 0, 0, 0);

    mPaint.setStyle(Style.STROKE);
    mPaint.setColor(selected ? mSelectionTextFillColor : mCenterTextFillColor);
    mPaint.setStrokeCap(Cap.SQUARE);
    mPaint.setStrokeWidth(10.0f);
    canvas.drawLine((centerX - iconRadius), (centerY - iconRadius), (centerX + iconRadius),
            (centerY + iconRadius), mPaint);
    canvas.drawLine((centerX + iconRadius), (centerY - iconRadius), (centerX - iconRadius),
            (centerY + iconRadius), mPaint);
}

From source file:com.googlecode.eyesfree.widget.RadialMenuView.java

private void drawCancel(Canvas canvas, int width, int height, float center) {
    final float centerX = mCenter.x;
    final float centerY = mCenter.y;
    final float radius = mInnerRadius;
    final float iconRadius = (radius / 4.0f);

    final RectF dotBounds = new RectF((centerX - radius), (centerY - radius), (centerX + radius),
            (centerY + radius));/*from  w ww.  j  av a 2s. c  o m*/

    // Apply the appropriate color filters.
    final boolean selected = (mFocusedItem == null);

    mPaint.setStyle(Style.FILL);
    mPaint.setColor(selected ? mSelectionColor : mCenterFillColor);
    mPaint.setShadowLayer(mShadowRadius, 0, 0, (selected ? mSelectionShadowColor : mTextShadowColor));
    canvas.drawOval(dotBounds, mPaint);
    mPaint.setShadowLayer(0, 0, 0, 0);

    mPaint.setStyle(Style.STROKE);
    mPaint.setColor(selected ? mSelectionTextFillColor : mCenterTextFillColor);
    mPaint.setStrokeCap(Cap.SQUARE);
    mPaint.setStrokeWidth(10.0f);
    canvas.drawLine((centerX - iconRadius), (centerY - iconRadius), (centerX + iconRadius),
            (centerY + iconRadius), mPaint);
    canvas.drawLine((centerX + iconRadius), (centerY - iconRadius), (centerX - iconRadius),
            (centerY + iconRadius), mPaint);
}

From source file:com.owen.view.views.PieChart.java

@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);

    ///*from  w  w w .j  av  a 2s .c o  m*/
    // Set dimensions for text, pie chart, etc
    //
    // Account for padding
    float xpad = (float) (getPaddingLeft() + getPaddingRight());
    float ypad = (float) (getPaddingTop() + getPaddingBottom());

    // Account for the label
    if (mShowText)
        xpad += mTextWidth;

    float ww = (float) w - xpad;
    float hh = (float) h - ypad;

    // Figure out how big we can make the pie.
    float diameter = Math.min(ww, hh);
    mPieBounds = new RectF(0.0f, 0.0f, diameter, diameter);
    mPieBounds.offsetTo(getPaddingLeft(), getPaddingTop());

    mPointerY = mTextY - (mTextHeight / 2.0f);
    float pointerOffset = mPieBounds.centerY() - mPointerY;

    // Make adjustments based on text position
    if (mTextPos == TEXTPOS_LEFT) {
        mTextPaint.setTextAlign(Paint.Align.RIGHT);
        if (mShowText)
            mPieBounds.offset(mTextWidth, 0.0f);
        mTextX = mPieBounds.left;

        if (pointerOffset < 0) {
            pointerOffset = -pointerOffset;
            mCurrentItemAngle = 225;
        } else {
            mCurrentItemAngle = 135;
        }
        mPointerX = mPieBounds.centerX() - pointerOffset;
    } else {
        mTextPaint.setTextAlign(Paint.Align.LEFT);
        mTextX = mPieBounds.right;

        if (pointerOffset < 0) {
            pointerOffset = -pointerOffset;
            mCurrentItemAngle = 315;
        } else {
            mCurrentItemAngle = 45;
        }
        mPointerX = mPieBounds.centerX() + pointerOffset;
    }

    mShadowBounds = new RectF(mPieBounds.left + 10, mPieBounds.bottom + 10, mPieBounds.right - 10,
            mPieBounds.bottom + 20);

    // Lay out the child view that actually draws the pie.
    mPieView.layout((int) mPieBounds.left, (int) mPieBounds.top, (int) mPieBounds.right,
            (int) mPieBounds.bottom);
    mPieView.setPivot(mPieBounds.width() / 2, mPieBounds.height() / 2);

    mPointerView.layout(0, 0, w, h);
    onDataChanged();
}

From source file:org.mariotaku.twidere.view.ShapedImageView.java

private void updateShadowBitmap() {
    if (useOutline())
        return;//from  w ww.j  av a 2s  .  c  o m
    final int width = getWidth(), height = getHeight();
    if (width <= 0 || height <= 0)
        return;
    final int contentLeft = getPaddingLeft(), contentTop = getPaddingTop(),
            contentRight = width - getPaddingRight(), contentBottom = height - getPaddingBottom();
    final int contentWidth = contentRight - contentLeft, contentHeight = contentBottom - contentTop;
    final float radius = mShadowRadius, dy = radius * 1.5f / 2;
    final int size = Math.round(Math.min(contentWidth, contentHeight) + radius * 2);
    mShadowBitmap = Bitmap.createBitmap(size, Math.round(size + dy), Config.ARGB_8888);
    Canvas canvas = new Canvas(mShadowBitmap);
    final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setColor(0xFF000000 | mBackgroundPaint.getColor());
    paint.setShadowLayer(radius, 0, radius * 1.5f / 2, SHADOW_START_COLOR);
    final RectF rect = new RectF(radius, radius, size - radius, size - radius);
    if (getStyle() == SHAPE_CIRCLE) {
        canvas.drawOval(rect, paint);
        paint.setShadowLayer(0, 0, 0, 0);
        paint.setXfermode(new PorterDuffXfermode(Mode.CLEAR));
        canvas.drawOval(rect, paint);
    } else {
        final float cr = getCalculatedCornerRadius();
        canvas.drawRoundRect(rect, cr, cr, paint);
        paint.setShadowLayer(0, 0, 0, 0);
        paint.setXfermode(new PorterDuffXfermode(Mode.CLEAR));
        canvas.drawRoundRect(rect, cr, cr, paint);
    }
    invalidate();
}

From source file:de.gebatzens.sia.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(SIAApp.SIA_APP.school.getTheme());
    super.onCreate(savedInstanceState);
    Log.w("ggvp", "CREATE NEW MAINACTIVITY");
    //Debug.startMethodTracing("sia3");
    SIAApp.SIA_APP.activity = this;
    savedState = savedInstanceState;/*from  ww w  .j  a  va 2 s.  c o m*/

    final FragmentData.FragmentList fragments = SIAApp.SIA_APP.school.fragments;

    Intent intent = getIntent();
    if (intent != null && intent.getStringExtra("fragment") != null) {
        FragmentData frag = fragments
                .getByType(FragmentData.FragmentType.valueOf(intent.getStringExtra("fragment"))).get(0);
        SIAApp.SIA_APP.setFragmentIndex(fragments.indexOf(frag));
    }

    if (intent != null && intent.getBooleanExtra("reload", false)) {
        SIAApp.SIA_APP.refreshAsync(null, true, fragments.get(SIAApp.SIA_APP.getFragmentIndex()));
        intent.removeExtra("reload");
    }

    setContentView(R.layout.activity_main);

    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    mContent = getFragment();
    transaction.replace(R.id.content_fragment, mContent, "gg_content_fragment");
    transaction.commit();

    Log.d("ggvp", "DATA: " + fragments.get(SIAApp.SIA_APP.getFragmentIndex()).getData());
    if (fragments.get(SIAApp.SIA_APP.getFragmentIndex()).getData() == null)
        SIAApp.SIA_APP.refreshAsync(null, true, fragments.get(SIAApp.SIA_APP.getFragmentIndex()));

    if ("Summer".equals(SIAApp.SIA_APP.getCurrentThemeName())) {
        ImageView summerNavigationPalm = (ImageView) findViewById(R.id.summer_navigation_palm);
        summerNavigationPalm.setImageResource(R.drawable.summer_palm);
        ImageView summerBackgroundImage = (ImageView) findViewById(R.id.summer_background_image);
        summerBackgroundImage.setImageResource(R.drawable.summer_background);
    }

    mToolBar = (Toolbar) findViewById(R.id.toolbar);
    mToolBar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {

            switch (menuItem.getItemId()) {
            case R.id.action_refresh:
                ((SwipeRefreshLayout) mContent.getView().findViewById(R.id.refresh)).setRefreshing(true);
                SIAApp.SIA_APP.refreshAsync(new Runnable() {
                    @Override
                    public void run() {
                        ((SwipeRefreshLayout) mContent.getView().findViewById(R.id.refresh))
                                .setRefreshing(false);
                    }
                }, true, fragments.get(SIAApp.SIA_APP.getFragmentIndex()));
                return true;
            case R.id.action_settings:
                Intent i = new Intent(MainActivity.this, SettingsActivity.class);
                startActivityForResult(i, 1);
                return true;
            case R.id.action_addToCalendar:
                showExamDialog();
                return true;
            case R.id.action_help:
                AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                builder.setTitle(getApplication().getString(R.string.help));
                builder.setMessage(getApplication().getString(R.string.exam_explain));
                builder.setPositiveButton(getApplication().getString(R.string.close),
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();
                            }
                        });
                builder.create().show();
                return true;
            }

            return false;
        }
    });

    updateToolbar(SIAApp.SIA_APP.school.name, fragments.get(SIAApp.SIA_APP.getFragmentIndex()).name);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        SIAApp.SIA_APP.setStatusBarColorTransparent(getWindow()); // because of the navigation drawer
    }

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolBar, R.string.drawer_open,
            R.string.drawer_close) {

        /** Called when a drawer has settled in a completely closed state. */
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }

        /** Called when a drawer has settled in a completely open state. */
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }
    };
    mDrawerLayout.addDrawerListener(mDrawerToggle);
    navigationView = (NavigationView) findViewById(R.id.navigation_view);
    mNavigationHeader = navigationView.getHeaderView(0);
    mNavigationSchoolpictureText = (TextView) mNavigationHeader.findViewById(R.id.drawer_image_text);
    mNavigationSchoolpictureText.setText(SIAApp.SIA_APP.school.name);
    mNavigationSchoolpicture = (ImageView) mNavigationHeader.findViewById(R.id.navigation_schoolpicture);
    mNavigationSchoolpicture.setImageBitmap(SIAApp.SIA_APP.school.loadImage());
    mNavigationSchoolpictureLink = mNavigationHeader.findViewById(R.id.navigation_schoolpicture_link);
    mNavigationSchoolpictureLink.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View viewIn) {
            mDrawerLayout.closeDrawers();
            Intent linkIntent = new Intent(Intent.ACTION_VIEW);
            linkIntent.setData(Uri.parse(SIAApp.SIA_APP.school.website));
            startActivity(linkIntent);
        }
    });

    final Menu menu = navigationView.getMenu();
    menu.clear();
    for (int i = 0; i < fragments.size(); i++) {
        MenuItem item = menu.add(R.id.fragments, Menu.NONE, i, fragments.get(i).name);
        item.setIcon(fragments.get(i).getIconRes());
    }

    menu.add(R.id.settings, R.id.settings_item, fragments.size(), R.string.settings);
    menu.setGroupCheckable(R.id.fragments, true, true);
    menu.setGroupCheckable(R.id.settings, false, false);

    final Menu navMenu = navigationView.getMenu();
    selectedItem = SIAApp.SIA_APP.getFragmentIndex();
    if (selectedItem != -1)
        navMenu.getItem(selectedItem).setChecked(true);

    navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(MenuItem menuItem) {
            if (menuItem.getItemId() == R.id.settings_item) {
                mDrawerLayout.closeDrawers();
                Intent i = new Intent(MainActivity.this, SettingsActivity.class);
                startActivityForResult(i, 1);
            } else {
                final int index = menuItem.getOrder();
                if (SIAApp.SIA_APP.getFragmentIndex() != index) {
                    SIAApp.SIA_APP.setFragmentIndex(index);
                    menuItem.setChecked(true);
                    updateToolbar(SIAApp.SIA_APP.school.name, menuItem.getTitle().toString());
                    mContent = getFragment();
                    Animation fadeOut = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_out);
                    fadeOut.setAnimationListener(new Animation.AnimationListener() {

                        @Override
                        public void onAnimationStart(Animation animation) {

                        }

                        @Override
                        public void onAnimationEnd(Animation animation) {
                            FrameLayout contentFrame = (FrameLayout) findViewById(R.id.content_fragment);
                            contentFrame.setVisibility(View.INVISIBLE);
                            if (fragments.get(index).getData() == null)
                                SIAApp.SIA_APP.refreshAsync(null, true, fragments.get(index));

                            //removeAllFragments();

                            FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
                            transaction.replace(R.id.content_fragment, mContent, "gg_content_fragment");
                            transaction.commit();

                            snowView.updateSnow();
                        }

                        @Override
                        public void onAnimationRepeat(Animation animation) {

                        }
                    });
                    FrameLayout contentFrame = (FrameLayout) findViewById(R.id.content_fragment);
                    contentFrame.startAnimation(fadeOut);
                    mDrawerLayout.closeDrawers();
                } else {
                    mDrawerLayout.closeDrawers();
                }
            }
            return true;
        }
    });

    if (Build.VERSION.SDK_INT >= 25) {
        ShortcutManager shortcutManager = getSystemService(ShortcutManager.class);
        shortcutManager.removeAllDynamicShortcuts();

        for (int i = 0; i < fragments.size(); i++) {
            Drawable drawable = getDrawable(fragments.get(i).getIconRes());
            Bitmap icon;
            if (drawable instanceof VectorDrawable) {
                icon = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(),
                        Bitmap.Config.ARGB_8888);
                Canvas canvas = new Canvas(icon);
                drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
                drawable.draw(canvas);
            } else {
                icon = BitmapFactory.decodeResource(getResources(), fragments.get(i).getIconRes());
            }

            Bitmap connectedIcon = Bitmap.createBitmap(icon.getWidth(), icon.getHeight(),
                    Bitmap.Config.ARGB_8888);
            Canvas canvas = new Canvas(connectedIcon);
            Paint paint = new Paint();
            paint.setAntiAlias(true);
            paint.setColor(Color.parseColor("#f5f5f5"));
            canvas.drawCircle(icon.getWidth() / 2, icon.getHeight() / 2, icon.getWidth() / 2, paint);
            paint.setColorFilter(
                    new PorterDuffColorFilter(SIAApp.SIA_APP.school.getColor(), PorterDuff.Mode.SRC_ATOP));
            canvas.drawBitmap(icon, null, new RectF(icon.getHeight() / 4.0f, icon.getHeight() / 4.0f,
                    icon.getHeight() - icon.getHeight() / 4.0f, icon.getHeight() - icon.getHeight() / 4.0f),
                    paint);

            Intent newTaskIntent = new Intent(this, MainActivity.class);
            newTaskIntent.setAction(Intent.ACTION_MAIN);
            newTaskIntent.putExtra("fragment", fragments.get(i).type.toString());

            ShortcutInfo shortcut = new ShortcutInfo.Builder(this, fragments.get(i).name)
                    .setShortLabel(fragments.get(i).name).setLongLabel(fragments.get(i).name)
                    .setIcon(Icon.createWithBitmap(connectedIcon)).setIntent(newTaskIntent).build();

            shortcutManager.addDynamicShortcuts(Arrays.asList(shortcut));
        }
    }

    if (SIAApp.SIA_APP.preferences.getBoolean("app_130_upgrade", true)) {
        if (!SIAApp.SIA_APP.preferences.getBoolean("first_use_filter", true)) {
            TextDialog.newInstance(R.string.upgrade1_3title, R.string.upgrade1_3)
                    .show(getSupportFragmentManager(), "upgrade_dialog");
        }

        SIAApp.SIA_APP.preferences.edit().putBoolean("app_130_upgrade", false).apply();
    }

    snowView = (SnowView) findViewById(R.id.snow_view);

    shareToolbar = (Toolbar) findViewById(R.id.share_toolbar);
    shareToolbar.getMenu().clear();
    shareToolbar.inflateMenu(R.menu.share_toolbar_menu);
    shareToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            toggleShareToolbar(false);
            for (Shareable s : MainActivity.this.shared) {
                s.setMarked(false);
            }
            MainActivity.this.shared.clear();

            mContent.updateFragment();
        }
    });

    shareToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            toggleShareToolbar(false);

            HashMap<Date, ArrayList<Shareable>> dates = new HashMap<Date, ArrayList<Shareable>>();

            for (Shareable s : MainActivity.this.shared) {
                ArrayList<Shareable> list = dates.get(s.getDate());
                if (list == null) {
                    list = new ArrayList<Shareable>();
                    dates.put(s.getDate(), list);
                }

                list.add(s);

                s.setMarked(false);
            }
            MainActivity.this.shared.clear();

            List<Date> dateList = new ArrayList<Date>(dates.keySet());
            Collections.sort(dateList);
            String content = "";

            for (Date key : dateList) {
                content += SubstListAdapter.translateDay(key) + "\n\n";

                Collections.sort(dates.get(key));
                for (Shareable s : dates.get(key)) {
                    content += s.getShareContent() + "\n";
                }

                content += "\n";
            }

            content = content.substring(0, content.length() - 1);

            mContent.updateFragment();

            if (item.getItemId() == R.id.action_copy) {
                ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);

                ClipData clip = ClipData.newPlainText(getString(R.string.entries), content);
                clipboard.setPrimaryClip(clip);
            } else if (item.getItemId() == R.id.action_share) {
                Intent sendIntent = new Intent();
                sendIntent.setAction(Intent.ACTION_SEND);
                sendIntent.putExtra(Intent.EXTRA_TEXT, content);
                sendIntent.setType("text/plain");
                startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_to)));
            }

            return true;
        }
    });

    if (shared.size() > 0) {
        shareToolbar.setVisibility(View.VISIBLE);
        updateShareToolbarText();
    }

    // if a fragment is opened via a notification or a shortcut reset the shared entries
    // delete extra fragment because the same intent is used when the device gets rotated and the user could have opened a new fragment
    if (intent != null && intent.hasExtra("fragment")) {
        resetShareToolbar();
        intent.removeExtra("fragment");
    }

}

From source file:org.getlantern.firetweet.view.ShapedImageView.java

private void updateShadowBitmap() {
    if (USE_OUTLINE)
        return;//ww  w .  j a va 2 s . c  o m
    final int width = getWidth(), height = getHeight();
    if (width <= 0 || height <= 0)
        return;
    final int contentLeft = getPaddingLeft(), contentTop = getPaddingTop(),
            contentRight = width - getPaddingRight(), contentBottom = height - getPaddingBottom();
    final int contentWidth = contentRight - contentLeft, contentHeight = contentBottom - contentTop;
    final float radius = mShadowRadius, dy = radius * 1.5f / 2;
    final int size = Math.round(Math.min(contentWidth, contentHeight) + radius * 2);
    mShadowBitmap = Bitmap.createBitmap(size, Math.round(size + dy), Config.ARGB_8888);
    Canvas canvas = new Canvas(mShadowBitmap);
    final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setColor(0xFF000000 | mBackgroundPaint.getColor());
    paint.setShadowLayer(radius, 0, radius * 1.5f / 2, SHADOW_START_COLOR);
    final RectF rect = new RectF(radius, radius, size - radius, size - radius);
    if (getStyle() == SHAPE_CIRCLE) {
        canvas.drawOval(rect, paint);
        paint.setShadowLayer(0, 0, 0, 0);
        paint.setXfermode(new PorterDuffXfermode(Mode.CLEAR));
        canvas.drawOval(rect, paint);
    } else {
        final float cr = getCalculatedCornerRadius();
        canvas.drawRoundRect(rect, cr, cr, paint);
        paint.setShadowLayer(0, 0, 0, 0);
        paint.setXfermode(new PorterDuffXfermode(Mode.CLEAR));
        canvas.drawRoundRect(rect, cr, cr, paint);
    }
    invalidate();
}

From source file:com.wanikani.androidnotifier.graph.HistogramPlot.java

@Override
protected void onSizeChanged(int width, int height, int ow, int oh) {
    meas.updateSize(new RectF(0, 0, width, height));
    vp.updateSize();//w ww  . j  a  v a 2s . c o  m

    invalidate();
}

From source file:com.winneredge.stockly.wcommons.floatingactionwidget.FloatingActionButton.java

private void setupProgressBounds() {
    int circleInsetHorizontal = hasShadow() ? getShadowX() : 0;
    int circleInsetVertical = hasShadow() ? getShadowY() : 0;
    mProgressCircleBounds = new RectF(circleInsetHorizontal + mProgressWidth / 2,
            circleInsetVertical + mProgressWidth / 2,
            calculateMeasuredWidth() - circleInsetHorizontal - mProgressWidth / 2,
            calculateMeasuredHeight() - circleInsetVertical - mProgressWidth / 2);
}