Example usage for android.graphics.drawable Drawable getIntrinsicHeight

List of usage examples for android.graphics.drawable Drawable getIntrinsicHeight

Introduction

In this page you can find the example usage for android.graphics.drawable Drawable getIntrinsicHeight.

Prototype

public int getIntrinsicHeight() 

Source Link

Document

Returns the drawable's intrinsic height.

Usage

From source file:com.phonemetra.turbo.launcher.AsyncTaskCallback.java

private boolean beginDraggingWidget(View v) {
    mDraggingWidget = true;//from   w  w w  .  j av  a 2  s  .co  m
    // Get the widget preview as the drag representation
    ImageView image = (ImageView) v.findViewById(R.id.widget_preview);
    PendingAddItemInfo createItemInfo = (PendingAddItemInfo) v.getTag();

    // If the ImageView doesn't have a drawable yet, the widget preview hasn't been loaded and
    // we abort the drag.
    if (image.getDrawable() == null) {
        mDraggingWidget = false;
        return false;
    }

    // Compose the drag image
    Bitmap preview;
    Bitmap outline;
    float scale = 1f;
    Point previewPadding = null;

    if (createItemInfo instanceof PendingAddWidgetInfo) {
        // This can happen in some weird cases involving multi-touch. We can't start dragging
        // the widget if this is null, so we break out.
        if (mCreateWidgetInfo == null) {
            return false;
        }

        PendingAddWidgetInfo createWidgetInfo = mCreateWidgetInfo;
        createItemInfo = createWidgetInfo;
        int spanX = createItemInfo.spanX;
        int spanY = createItemInfo.spanY;
        int[] size = mLauncher.getWorkspace().estimateItemSize(spanX, spanY, createWidgetInfo, true);

        FastBitmapDrawable previewDrawable = (FastBitmapDrawable) image.getDrawable();
        float minScale = 1.25f;
        int maxWidth, maxHeight;
        maxWidth = Math.min((int) (previewDrawable.getIntrinsicWidth() * minScale), size[0]);
        maxHeight = Math.min((int) (previewDrawable.getIntrinsicHeight() * minScale), size[1]);

        int[] previewSizeBeforeScale = new int[1];

        preview = getWidgetPreviewLoader().generateWidgetPreview(createWidgetInfo.componentName,
                createWidgetInfo.previewImage, createWidgetInfo.icon, spanX, spanY, maxWidth, maxHeight, null,
                previewSizeBeforeScale);

        // Compare the size of the drag preview to the preview in the AppsCustomize tray
        int previewWidthInAppsCustomize = Math.min(previewSizeBeforeScale[0],
                getWidgetPreviewLoader().maxWidthForWidgetPreview(spanX));
        scale = previewWidthInAppsCustomize / (float) preview.getWidth();

        // The bitmap in the AppsCustomize tray is always the the same size, so there
        // might be extra pixels around the preview itself - this accounts for that
        if (previewWidthInAppsCustomize < previewDrawable.getIntrinsicWidth()) {
            int padding = (previewDrawable.getIntrinsicWidth() - previewWidthInAppsCustomize) / 2;
            previewPadding = new Point(padding, 0);
        }
    } else {
        PendingAddShortcutInfo createShortcutInfo = (PendingAddShortcutInfo) v.getTag();
        Drawable icon = mIconCache.getFullResIcon(createShortcutInfo.shortcutActivityInfo);
        preview = Bitmap.createBitmap(icon.getIntrinsicWidth(), icon.getIntrinsicHeight(),
                Bitmap.Config.ARGB_8888);

        mCanvas.setBitmap(preview);
        mCanvas.save();
        WidgetPreviewLoader.renderDrawableToBitmap(icon, preview, 0, 0, icon.getIntrinsicWidth(),
                icon.getIntrinsicHeight());
        mCanvas.restore();
        mCanvas.setBitmap(null);
        createItemInfo.spanX = createItemInfo.spanY = 1;
    }

    // Don't clip alpha values for the drag outline if we're using the default widget preview
    boolean clipAlpha = !(createItemInfo instanceof PendingAddWidgetInfo
            && (((PendingAddWidgetInfo) createItemInfo).previewImage == 0));

    // Save the preview for the outline generation, then dim the preview
    outline = Bitmap.createScaledBitmap(preview, preview.getWidth(), preview.getHeight(), false);

    // Start the drag
    mLauncher.lockScreenOrientation();
    mLauncher.getWorkspace().onDragStartedWithItem(createItemInfo, outline, clipAlpha);
    mDragController.startDrag(image, preview, this, createItemInfo, DragController.DRAG_ACTION_COPY,
            previewPadding, scale);
    outline.recycle();
    preview.recycle();
    return true;
}

From source file:cnedu.ustcjd.widget.MultiSlider.java

private void setThumbDrawable(Thumb thumb, Drawable thumbDrawable, int thumbColor) {
    requireNonNull(thumbDrawable);/*from  w  w  w. ja v  a  2  s . com*/
    Drawable nThumbDrawable = getTintedDrawable(thumbDrawable.getConstantState().newDrawable(), thumbColor);
    nThumbDrawable.setCallback(this);

    // Assuming the thumb drawable is symmetric, set the thumb offset
    // such that the thumb will hang halfway off either edge of the
    // progress bar.
    thumb.setThumbOffset(thumbDrawable.getIntrinsicWidth() / 2);

    // If we're updating get the new states
    if (thumb.getThumb() != null && (nThumbDrawable.getIntrinsicWidth() != thumb.getThumb().getIntrinsicWidth()
            || nThumbDrawable.getIntrinsicHeight() != thumb.getThumb().getIntrinsicHeight())) {
        requestLayout();
    }
    thumb.setThumb(nThumbDrawable);

    invalidate();
    if (nThumbDrawable != null && nThumbDrawable.isStateful()) {
        // Note that if the states are different this won't work.
        // For now, let's consider that an app bug.
        int[] state = getDrawableState();
        nThumbDrawable.setState(state);
    }
}

From source file:com.android.launcher2.AsyncTaskCallback.java

private Bitmap getWidgetPreview(ComponentName provider, int previewImage, int iconId, int cellHSpan,
        int cellVSpan, int maxWidth, int maxHeight) {
    // Load the preview image if possible
    String packageName = provider.getPackageName();
    if (maxWidth < 0)
        maxWidth = Integer.MAX_VALUE;
    if (maxHeight < 0)
        maxHeight = Integer.MAX_VALUE;

    Drawable drawable = null;
    if (previewImage != 0) {
        drawable = mPackageManager.getDrawable(packageName, previewImage, null);
        if (drawable == null) {
            Log.w(TAG, "Can't load widget preview drawable 0x" + Integer.toHexString(previewImage)
                    + " for provider: " + provider);
        }/*from  w w  w  . jav a  2 s .  c  o m*/
    }

    int bitmapWidth;
    int bitmapHeight;
    Bitmap defaultPreview = null;
    boolean widgetPreviewExists = (drawable != null);
    if (widgetPreviewExists) {
        bitmapWidth = drawable.getIntrinsicWidth();
        bitmapHeight = drawable.getIntrinsicHeight();
    } else {
        // Generate a preview image if we couldn't load one
        if (cellHSpan < 1)
            cellHSpan = 1;
        if (cellVSpan < 1)
            cellVSpan = 1;

        BitmapDrawable previewDrawable = (BitmapDrawable) getResources()
                .getDrawable(R.drawable.widget_preview_tile);
        final int previewDrawableWidth = previewDrawable.getIntrinsicWidth();
        final int previewDrawableHeight = previewDrawable.getIntrinsicHeight();
        bitmapWidth = previewDrawableWidth * cellHSpan; // subtract 2 dips
        bitmapHeight = previewDrawableHeight * cellVSpan;

        defaultPreview = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Config.ARGB_8888);
        final Canvas c = mCachedAppWidgetPreviewCanvas.get();
        c.setBitmap(defaultPreview);
        previewDrawable.setBounds(0, 0, bitmapWidth, bitmapHeight);
        previewDrawable.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
        previewDrawable.draw(c);
        c.setBitmap(null);

        // Draw the icon in the top left corner
        int minOffset = (int) (mAppIconSize * sWidgetPreviewIconPaddingPercentage);
        int smallestSide = Math.min(bitmapWidth, bitmapHeight);
        float iconScale = Math.min((float) smallestSide / (mAppIconSize + 2 * minOffset), 1f);

        try {
            Drawable icon = null;
            int hoffset = (int) ((previewDrawableWidth - mAppIconSize * iconScale) / 2);
            int yoffset = (int) ((previewDrawableHeight - mAppIconSize * iconScale) / 2);
            if (iconId > 0)
                icon = mIconCache.getFullResIcon(packageName, iconId);
            if (icon != null) {
                renderDrawableToBitmap(icon, defaultPreview, hoffset, yoffset, (int) (mAppIconSize * iconScale),
                        (int) (mAppIconSize * iconScale));
            }
        } catch (Resources.NotFoundException e) {
        }
    }

    // Scale to fit width only - let the widget preview be clipped in the
    // vertical dimension
    float scale = 1f;
    if (bitmapWidth > maxWidth) {
        scale = maxWidth / (float) bitmapWidth;
    }
    if (scale != 1f) {
        bitmapWidth = (int) (scale * bitmapWidth);
        bitmapHeight = (int) (scale * bitmapHeight);
    }

    Bitmap preview = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Config.ARGB_8888);

    // Draw the scaled preview into the final bitmap
    if (widgetPreviewExists) {
        renderDrawableToBitmap(drawable, preview, 0, 0, bitmapWidth, bitmapHeight);
    } else {
        final Canvas c = mCachedAppWidgetPreviewCanvas.get();
        final Rect src = mCachedAppWidgetPreviewSrcRect.get();
        final Rect dest = mCachedAppWidgetPreviewDestRect.get();
        c.setBitmap(preview);
        src.set(0, 0, defaultPreview.getWidth(), defaultPreview.getHeight());
        dest.set(0, 0, preview.getWidth(), preview.getHeight());

        Paint p = mCachedAppWidgetPreviewPaint.get();
        if (p == null) {
            p = new Paint();
            p.setFilterBitmap(true);
            mCachedAppWidgetPreviewPaint.set(p);
        }
        c.drawBitmap(defaultPreview, src, dest, p);
        c.setBitmap(null);
    }
    return preview;
}

From source file:com.andrewshu.android.reddit.comments.CommentsListActivity.java

/**
 * Helper function to add links from mVoteTargetThing to the button
 * @param linkButton Button that should open list of links
 *///  w ww . j av  a2s. com
private void linkToEmbeddedURLs(Button linkButton) {
    final ArrayList<String> urls = new ArrayList<String>();
    final ArrayList<MarkdownURL> vtUrls = mVoteTargetThing.getUrls();
    int urlsCount = vtUrls.size();
    for (int i = 0; i < urlsCount; i++) {
        urls.add(vtUrls.get(i).url);
    }
    if (urlsCount == 0) {
        linkButton.setEnabled(false);
    } else {
        linkButton.setEnabled(true);
        linkButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                removeDialog(Constants.DIALOG_COMMENT_CLICK);

                ArrayAdapter<MarkdownURL> adapter = new ArrayAdapter<MarkdownURL>(CommentsListActivity.this,
                        android.R.layout.select_dialog_item, vtUrls) {
                    public View getView(int position, View convertView, ViewGroup parent) {
                        TextView tv;
                        if (convertView == null) {
                            tv = (TextView) ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE))
                                    .inflate(android.R.layout.select_dialog_item, null);
                        } else {
                            tv = (TextView) convertView;
                        }

                        String url = getItem(position).url;
                        String anchorText = getItem(position).anchorText;
                        if (Constants.LOGGING)
                            Log.d(TAG, "links url=" + url + " anchorText=" + anchorText);

                        Drawable d = null;
                        try {
                            d = getPackageManager()
                                    .getActivityIcon(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
                        } catch (NameNotFoundException ignore) {
                        }
                        if (d != null) {
                            d.setBounds(0, 0, d.getIntrinsicHeight(), d.getIntrinsicHeight());
                            tv.setCompoundDrawablePadding(10);
                            tv.setCompoundDrawables(d, null, null, null);
                        }

                        final String telPrefix = "tel:";
                        if (url.startsWith(telPrefix)) {
                            url = PhoneNumberUtils.formatNumber(url.substring(telPrefix.length()));
                        }

                        if (anchorText != null)
                            tv.setText(Html.fromHtml(
                                    "<span>" + anchorText + "</span><br /><small>" + url + "</small>"));
                        else
                            tv.setText(Html.fromHtml(url));

                        return tv;
                    }
                };

                AlertDialog.Builder b = new AlertDialog.Builder(
                        new ContextThemeWrapper(CommentsListActivity.this, mSettings.getDialogTheme()));

                DialogInterface.OnClickListener click = new DialogInterface.OnClickListener() {
                    public final void onClick(DialogInterface dialog, int which) {
                        if (which >= 0) {
                            Common.launchBrowser(CommentsListActivity.this, urls.get(which),
                                    Util.createThreadUri(getOpThingInfo()).toString(), false, false,
                                    mSettings.isUseExternalBrowser(), mSettings.isSaveHistory());
                        }
                    }
                };

                b.setTitle(R.string.select_link_title);
                b.setCancelable(true);
                b.setAdapter(adapter, click);

                b.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                    public final void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });

                b.show();
            }
        });
    }
}

From source file:com.huewu.pla.lib.internal.PLAListView.java

/**
 * Sets the drawable that will be drawn between each item in the list. If
 * the drawable does not have an intrinsic height, you should also call
 * {@link #setDividerHeight(int)}//  w  w  w  .j a  v  a2 s.  c om
 * 
 * @param divider The drawable to use.
 */
public void setDivider(final Drawable divider) {
    if (divider != null) {
        mDividerHeight = divider.getIntrinsicHeight();
        mClipDivider = divider instanceof ColorDrawable;
    } else {
        mDividerHeight = 0;
        mClipDivider = false;
    }
    mDivider = divider;
    mDividerIsOpaque = divider == null || divider.getOpacity() == PixelFormat.OPAQUE;
    requestLayoutIfNecessary();
}

From source file:cw.kop.autobackground.LiveWallpaperService.java

@SuppressLint("NewApi")
private void startNotification(boolean useNotification) {
    if (useNotification) {
        normalView = new RemoteViews(getPackageName(), R.layout.notification_layout);
        normalView.setInt(R.id.notification_container, "setBackgroundColor",
                AppSettings.getNotificationColor());
        normalView.setImageViewResource(R.id.notification_icon, R.drawable.app_icon);
        normalView.setTextViewText(R.id.notification_title, AppSettings.getNotificationTitle());
        normalView.setInt(R.id.notification_title, "setTextColor", AppSettings.getNotificationTitleColor());
        normalView.setTextViewText(R.id.notification_summary, AppSettings.getNotificationSummary());
        normalView.setInt(R.id.notification_summary, "setTextColor", AppSettings.getNotificationSummaryColor());

        Drawable coloredImageOne = LiveWallpaperService.this.getResources()
                .getDrawable(AppSettings.getNotificationOptionDrawable(0));
        Drawable coloredImageTwo = LiveWallpaperService.this.getResources()
                .getDrawable(AppSettings.getNotificationOptionDrawable(1));
        Drawable coloredImageThree = LiveWallpaperService.this.getResources()
                .getDrawable(AppSettings.getNotificationOptionDrawable(2));

        coloredImageOne.mutate().setColorFilter(AppSettings.getNotificationOptionColor(0),
                PorterDuff.Mode.MULTIPLY);
        coloredImageTwo.mutate().setColorFilter(AppSettings.getNotificationOptionColor(1),
                PorterDuff.Mode.MULTIPLY);
        coloredImageThree.mutate().setColorFilter(AppSettings.getNotificationOptionColor(2),
                PorterDuff.Mode.MULTIPLY);

        Bitmap mutableBitmapOne = Bitmap.createBitmap(coloredImageOne.getIntrinsicWidth(),
                coloredImageOne.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvasOne = new Canvas(mutableBitmapOne);
        coloredImageOne.setBounds(0, 0, coloredImageOne.getIntrinsicWidth(),
                coloredImageOne.getIntrinsicHeight());
        coloredImageOne.draw(canvasOne);

        Bitmap mutableBitmapTwo = Bitmap.createBitmap(coloredImageTwo.getIntrinsicWidth(),
                coloredImageTwo.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvasTwo = new Canvas(mutableBitmapTwo);
        coloredImageTwo.setBounds(0, 0, coloredImageTwo.getIntrinsicWidth(),
                coloredImageTwo.getIntrinsicHeight());
        coloredImageTwo.draw(canvasTwo);

        Bitmap mutableBitmapThree = Bitmap.createBitmap(coloredImageThree.getIntrinsicWidth(),
                coloredImageThree.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
        Canvas canvasThree = new Canvas(mutableBitmapThree);
        coloredImageThree.setBounds(0, 0, coloredImageThree.getIntrinsicWidth(),
                coloredImageThree.getIntrinsicHeight());
        coloredImageThree.draw(canvasThree);

        if (AppSettings.useNotificationGame()) {
            if (setupGameTiles()) {
                bigView = new RemoteViews(getPackageName(), R.layout.notification_game);
                tileIds = new int[] { R.id.notification_game_tile_0, R.id.notification_game_tile_1,
                        R.id.notification_game_tile_2, R.id.notification_game_tile_3,
                        R.id.notification_game_tile_4, R.id.notification_game_tile_5,
                        R.id.notification_game_tile_6, R.id.notification_game_tile_7,
                        R.id.notification_game_tile_8, R.id.notification_game_tile_9 };
                bigView.setOnClickPendingIntent(tileIds[0], pendingTile0);
                bigView.setOnClickPendingIntent(tileIds[1], pendingTile1);
                bigView.setOnClickPendingIntent(tileIds[2], pendingTile2);
                bigView.setOnClickPendingIntent(tileIds[3], pendingTile3);
                bigView.setOnClickPendingIntent(tileIds[4], pendingTile4);
                bigView.setOnClickPendingIntent(tileIds[5], pendingTile5);
                bigView.setOnClickPendingIntent(tileIds[6], pendingTile6);
                bigView.setOnClickPendingIntent(tileIds[7], pendingTile7);
                bigView.setOnClickPendingIntent(tileIds[8], pendingTile8);
                bigView.setOnClickPendingIntent(tileIds[9], pendingTile9);
            } else {
                bigView = new RemoteViews(getPackageName(), R.layout.notification_big_layout);
                closeNotificationDrawer(LiveWallpaperService.this);
                Toast.makeText(LiveWallpaperService.this, "Not enough images to create game", Toast.LENGTH_LONG)
                        .show();//ww w .  j a  v  a 2s. c  o m
                AppSettings.setUseNotificationGame(false);
            }
        } else {
            bigView = new RemoteViews(getPackageName(), R.layout.notification_big_layout);
        }
        bigView.setInt(R.id.notification_big_container, "setBackgroundColor",
                AppSettings.getNotificationColor());
        bigView.setImageViewResource(R.id.notification_big_icon, R.drawable.app_icon);
        bigView.setTextViewText(R.id.notification_big_title, AppSettings.getNotificationTitle());
        bigView.setInt(R.id.notification_big_title, "setTextColor", AppSettings.getNotificationTitleColor());
        bigView.setTextViewText(R.id.notification_big_summary, AppSettings.getNotificationSummary());
        bigView.setInt(R.id.notification_big_summary, "setTextColor",
                AppSettings.getNotificationSummaryColor());

        bigView.setImageViewBitmap(R.id.notification_button_one_image, mutableBitmapOne);
        bigView.setImageViewBitmap(R.id.notification_button_two_image, mutableBitmapTwo);
        bigView.setImageViewBitmap(R.id.notification_button_three_image, mutableBitmapThree);
        bigView.setTextViewText(R.id.notification_button_one_text, AppSettings.getNotificationOptionTitle(0));
        bigView.setInt(R.id.notification_button_one_text, "setTextColor",
                AppSettings.getNotificationOptionColor(0));
        bigView.setTextViewText(R.id.notification_button_two_text, AppSettings.getNotificationOptionTitle(1));
        bigView.setInt(R.id.notification_button_two_text, "setTextColor",
                AppSettings.getNotificationOptionColor(1));
        bigView.setTextViewText(R.id.notification_button_three_text, AppSettings.getNotificationOptionTitle(2));
        bigView.setInt(R.id.notification_button_three_text, "setTextColor",
                AppSettings.getNotificationOptionColor(2));

        if (getIntentForNotification(AppSettings.getNotificationIconAction()) != null) {
            normalView.setOnClickPendingIntent(R.id.notification_icon,
                    getIntentForNotification(AppSettings.getNotificationIconAction()));
            bigView.setOnClickPendingIntent(R.id.notification_big_icon,
                    getIntentForNotification(AppSettings.getNotificationIconAction()));
        } else {
            normalView.setOnClickPendingIntent(R.id.notification_icon, pendingAppIntent);
            bigView.setOnClickPendingIntent(R.id.notification_big_icon, pendingAppIntent);
        }

        notificationBuilder = new Notification.Builder(this).setContent(normalView)
                .setSmallIcon(R.drawable.notification_icon).setOngoing(true);

        if (Build.VERSION.SDK_INT >= 16) {
            if (AppSettings.useNotificationGame()) {
                notificationBuilder.setPriority(Notification.PRIORITY_MAX);
            } else {
                notificationBuilder.setPriority(Notification.PRIORITY_MIN);
            }
            if (getIntentForNotification(AppSettings.getNotificationOptionTitle(0)) != null) {
                bigView.setOnClickPendingIntent(R.id.notification_button_one,
                        getIntentForNotification(AppSettings.getNotificationOptionTitle(0)));
            }
            if (getIntentForNotification(AppSettings.getNotificationOptionTitle(1)) != null) {
                bigView.setOnClickPendingIntent(R.id.notification_button_two,
                        getIntentForNotification(AppSettings.getNotificationOptionTitle(1)));
            }
            if (getIntentForNotification(AppSettings.getNotificationOptionTitle(2)) != null) {
                bigView.setOnClickPendingIntent(R.id.notification_button_three,
                        getIntentForNotification(AppSettings.getNotificationOptionTitle(2)));
            }
        } else {
            notificationBuilder.setContentTitle(AppSettings.getNotificationTitle());
            notificationBuilder.setContentText(AppSettings.getNotificationSummary());
            notificationBuilder.addAction(AppSettings.getNotificationOptionDrawable(0),
                    AppSettings.getNotificationOptionTitle(0),
                    getIntentForNotification(AppSettings.getNotificationOptionTitle(0)));
            notificationBuilder.addAction(AppSettings.getNotificationOptionDrawable(1),
                    AppSettings.getNotificationOptionTitle(1),
                    getIntentForNotification(AppSettings.getNotificationOptionTitle(1)));
            notificationBuilder.addAction(AppSettings.getNotificationOptionDrawable(2),
                    AppSettings.getNotificationOptionTitle(2),
                    getIntentForNotification(AppSettings.getNotificationOptionTitle(2)));
        }

        pushNotification();

        if (FileHandler.getCurrentBitmapFile() != null) {
            notifyChangeImage();
        }
    } else {
        notificationManager.cancel(NOTIFICATION_ID);
    }
}

From source file:com.huewu.pla.lib.internal.PLA_ListView.java

/**
 * Sets the drawable that will be drawn between each item in the list. If
 * the drawable does not have an intrinsic height, you should also call
 * {@link #setDividerHeight(int)}//from   w  w w  .  j  a  v a 2  s  .c  o  m
 * 
 * @param divider
 *            The drawable to use.
 */
public void setDivider(Drawable divider) {
    if (divider != null) {
        mDividerHeight = divider.getIntrinsicHeight();
        mClipDivider = divider instanceof ColorDrawable;
    } else {
        mDividerHeight = 0;
        mClipDivider = false;
    }
    mDivider = divider;
    mDividerIsOpaque = divider == null || divider.getOpacity() == PixelFormat.OPAQUE;
    requestLayoutIfNecessary();
}

From source file:zemin.notification.NotificationBoard.java

/**
 * Set header divider.//from  w ww .  j ava2s  . c o  m
 *
 * @param drawable
 */
public void setHeaderDivider(Drawable drawable) {
    mHeaderDivider = drawable;
    if (drawable != null) {
        mHeaderDividerHeight = drawable.getIntrinsicHeight();
    } else {
        mHeaderDividerHeight = 0;
    }
    mContentView.setWillNotDraw(drawable == null);
    mContentView.invalidate();
}

From source file:zemin.notification.NotificationBoard.java

/**
 * Set footer divider.// w  w  w.j a v a  2s . c  o  m
 *
 * @param drawable
 */
public void setFooterDivider(Drawable drawable) {
    mFooterDivider = drawable;
    if (drawable != null) {
        mFooterDividerHeight = drawable.getIntrinsicHeight();
    } else {
        mFooterDividerHeight = 0;
    }
    mContentView.setWillNotDraw(drawable == null);
    mContentView.invalidate();
}

From source file:com.cxsplay.wallyskim.widget.flexbox.FlexboxLayout.java

/**
 * Set a drawable to be used as a horizontal divider between items.
 *
 * @param divider Drawable that will divide each item.
 * @see #setDividerDrawable(Drawable)//from  w  w  w .j  a  va 2 s  . c o m
 * @see #setShowDivider(int)
 * @see #setShowDividerHorizontal(int)
 */
public void setDividerDrawableHorizontal(Drawable divider) {
    if (divider == mDividerDrawableHorizontal) {
        return;
    }
    mDividerDrawableHorizontal = divider;
    if (divider != null) {
        mDividerHorizontalHeight = divider.getIntrinsicHeight();
    } else {
        mDividerHorizontalHeight = 0;
    }
    setWillNotDrawFlag();
    requestLayout();
}