android.widget.ImageView#getDrawable ( )源码实例Demo

下面列出了android.widget.ImageView#getDrawable ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jmessage-android-uikit   文件: DialogCreator.java
public static Dialog createLoadingDialog(Context context, String msg) {
    LayoutInflater inflater = LayoutInflater.from(context);
    View v = inflater.inflate(IdHelper.getLayout(context, "jmui_loading_view"), null);
    RelativeLayout layout = (RelativeLayout) v.findViewById(IdHelper.getViewID(context, "jmui_dialog_view"));
    ImageView mLoadImg = (ImageView) v.findViewById(IdHelper.getViewID(context, "jmui_loading_img"));
    TextView mLoadText = (TextView) v.findViewById(IdHelper.getViewID(context, "jmui_loading_txt"));
    AnimationDrawable mDrawable = (AnimationDrawable) mLoadImg.getDrawable();
    mDrawable.start();
    mLoadText.setText(msg);
    final Dialog loadingDialog = new Dialog(context, IdHelper.getStyle(context, "jmui_loading_dialog_style"));
    loadingDialog.setCancelable(true);
    loadingDialog.setContentView(layout, new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT));
    return loadingDialog;
}
 
源代码2 项目: Album   文件: PhotoViewAttacher.java
@Override
public boolean setDisplayMatrix(Matrix finalMatrix) {
    if (finalMatrix == null) {
        throw new IllegalArgumentException("Matrix cannot be null");
    }

    ImageView imageView = getImageView();
    if (null == imageView) {
        return false;
    }

    if (null == imageView.getDrawable()) {
        return false;
    }

    mSuppMatrix.set(finalMatrix);
    setImageViewMatrix(getDrawMatrix());
    checkMatrixBounds();

    return true;
}
 
源代码3 项目: GPS2SMS   文件: RepoListAdapterSMS.java
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View rowView = super.getView(position, convertView, parent);

    //imageView.setImageDrawable(icons[position]);
    ImageView imageView = (ImageView) rowView.findViewById(R.id.icon);

    if (contactids.length > position) {
        if (contactids[position] != null) {
            Uri u = getPhotoUri(contactids[position]);
            if (u != null) {
                imageView.setImageURI(u);
                if (imageView.getDrawable() == null)
                    imageView.setImageResource(R.drawable.ic_launcher);
                //Log.d("gps1", u.toString());
            } else {
                //imageView.setImageResource(R.drawable.ic_contact_picture_2);
            }
        }

    }

    return rowView;
}
 
源代码4 项目: o2oa   文件: DialogCreator.java
public static Dialog createLoadingDialog(Context context, String msg) {
    LayoutInflater inflater = LayoutInflater.from(context);
    View v = inflater.inflate(IdHelper.getLayout(context, "jmui_loading_view"), null);
    RelativeLayout layout = (RelativeLayout) v.findViewById(IdHelper.getViewID(context, "jmui_dialog_view"));
    ImageView mLoadImg = (ImageView) v.findViewById(IdHelper.getViewID(context, "jmui_loading_img"));
    TextView mLoadText = (TextView) v.findViewById(IdHelper.getViewID(context, "jmui_loading_txt"));
    AnimationDrawable mDrawable = (AnimationDrawable) mLoadImg.getDrawable();
    mDrawable.start();
    mLoadText.setText(msg);
    final Dialog loadingDialog = new Dialog(context, R.style.loading_dialog);
    loadingDialog.setCancelable(true);
    loadingDialog.setContentView(layout, new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT));
    return loadingDialog;
}
 
源代码5 项目: Android   文件: PhotoViewAttacher.java
@Override
public boolean setDisplayMatrix(Matrix finalMatrix) {
    if (finalMatrix == null) {
        throw new IllegalArgumentException("Matrix cannot be null");
    }

    ImageView imageView = getImageView();
    if (null == imageView) {
        return false;
    }

    if (null == imageView.getDrawable()) {
        return false;
    }

    mSuppMatrix.set(finalMatrix);
    setImageViewMatrix(getDrawMatrix());
    checkMatrixBounds();

    return true;
}
 
源代码6 项目: example   文件: CardThumbnailView.java
protected static BitmapWorkerUrlTask getBitmapWorkerUrlTask(ImageView imageView) {
    if (imageView != null) {
        final Drawable drawable = imageView.getDrawable();
        if (drawable instanceof AsyncDrawableUrl) {
            final AsyncDrawableUrl asyncDrawable = (AsyncDrawableUrl) drawable;
            return asyncDrawable.getBitmapWorkerUrlTask();
        }
    }
    return null;
}
 
源代码7 项目: cannonball-android   文件: ImageLoader.java
/**
 * @param imageView Any imageView
 * @return Retrieve the currently active task (if any) associated with this imageView.
 * null if there is no such task.
 */
private BackgroundTask getBitmapDownloaderTask(ImageView imageView) {
    if (imageView != null) {
        Drawable drawable = imageView.getDrawable();
        if (drawable instanceof BackgroundTaskDrawable) {
            BackgroundTaskDrawable downloadedDrawable = (BackgroundTaskDrawable) drawable;
            return downloadedDrawable.getBitmapDownloaderTask();
        }
    }
    return null;
}
 
源代码8 项目: android_maplibui   文件: StyleFragment.java
private static void setColor(ImageView image, TextView text, int color) {
    // set color
    GradientDrawable sd = (GradientDrawable) image.getDrawable();
    sd.setColor(color);
    image.invalidate();

    // set color name
    text.setText(getColorName(color));
}
 
/**
 * Helper method that maps the supplied Matrix to the current Drawable
 *
 * @param matrix - Matrix to map Drawable against
 * @return RectF - Displayed Rectangle
 */
private RectF getDisplayRect(Matrix matrix) {
    ImageView imageView = getImageView();

    if (null != imageView) {
        Drawable d = imageView.getDrawable();
        if (null != d) {
            mDisplayRect.set(0, 0, d.getIntrinsicWidth(),
                    d.getIntrinsicHeight());
            matrix.mapRect(mDisplayRect);
            return mDisplayRect;
        }
    }
    return null;
}
 
源代码10 项目: evercam-android   文件: VideoActivity.java
private Bitmap getBitmapFromImageView(ImageView imageView) {
    Bitmap bitmap = null;
    if (imageView.getDrawable() instanceof BitmapDrawable) {
        bitmap = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
    } else {
        Drawable drawable = imageView.getDrawable();
        if (drawable != null) {
            bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);

            Canvas canvas = new Canvas(bitmap);
            drawable.draw(canvas);
        }
    }
    return bitmap;
}
 
public static int getPaletteColor(ImageView imageView) {
    BitmapDrawable drawable = (BitmapDrawable) imageView.getDrawable();
    Bitmap bitmap = drawable.getBitmap();
    Palette palette = Palette.generate(bitmap);
    int x = Color.parseColor("#ea0101");
    return palette.getVibrantColor(x);
}
 
源代码12 项目: Bailan   文件: GalleryActivity.java
private void recycleImage(View view) {
    if (!(view instanceof ImageView)) {
        ImageView imageView = (ImageView) view;
        Drawable drawable = imageView.getDrawable();
        if (drawable == null || !(drawable instanceof BitmapDrawable)) {
            return;
        } else {
            Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
            if (bitmap == null || bitmap.isRecycled()) {
                return;
            }
            bitmap.recycle();
        }
    }
}
 
源代码13 项目: iBeebo   文件: TimeLineBitmapDownloader.java
private static IPictureWorker getBitmapDownloaderTask(ImageView imageView) {
    if (imageView != null) {
        Drawable drawable = imageView.getDrawable();
        if (drawable instanceof PictureBitmapDrawable) {
            PictureBitmapDrawable downloadedDrawable = (PictureBitmapDrawable) drawable;
            return downloadedDrawable.getBitmapDownloaderTask();
        }
    }
    return null;
}
 
源代码14 项目: iBeebo   文件: AbstractWorker.java
private IPictureWorker getBitmapDownloaderTask(ImageView imageView) {
    if (imageView != null) {
        Drawable drawable = imageView.getDrawable();
        if (drawable instanceof PictureBitmapDrawable) {
            PictureBitmapDrawable downloadedDrawable = (PictureBitmapDrawable) drawable;
            return downloadedDrawable.getBitmapDownloaderTask();
        }
    }
    return null;
}
 
源代码15 项目: VideoOS-Android-SDK   文件: ImageUtil.java
/**
 * 调整图片的frame
 *
 * @param imageView
 */
public static void adjustSize(ImageView imageView) {
    if (imageView != null && imageView.getLayoutParams() != null && imageView.getDrawable() != null) {
         int width = (imageView.getDrawable()).getIntrinsicWidth();
         int height = (imageView.getDrawable()).getIntrinsicHeight();
        if (width != imageView.getLayoutParams().width || height != imageView.getLayoutParams().height) {
            imageView.getLayoutParams().width = width;
            imageView.getLayoutParams().height = height;
            imageView.requestLayout();
        }
    }
}
 
源代码16 项目: zone-sdk   文件: MeasureUtils.java
/**
 * 返回的 宽高数组 是图片 在当前分辨率手机的宽高
 *
 * @param imageView
 * @return
 */
public static float[] measureDrawableWH(final ImageView imageView) {
    Drawable drawable = imageView.getDrawable();
    Matrix mar = imageView.getImageMatrix();
    int intrinsicHeight = drawable.getIntrinsicHeight();
    int intrinsicWidth = drawable.getIntrinsicWidth();
    return new float[]{intrinsicWidth, intrinsicHeight};
}
 
private static BitmapWorkerTask getBitmapWorkerTask(ImageView imageView) {
    if (imageView != null) {
        final Drawable drawable = imageView.getDrawable();
        if (drawable instanceof AsyncDrawable) {
            final AsyncDrawable asyncDrawable = (AsyncDrawable) drawable;
            return asyncDrawable.getBitmapWorkerTask();
        }
    }
    return null;
}
 
源代码18 项目: FrameAnimation   文件: AnimationOne.java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.one);
    ImageView image = (ImageView) findViewById(R.id.image);


    AnimationDrawable animationDrawable = (AnimationDrawable) image.getDrawable();
    animationDrawable.start();
}
 
源代码19 项目: Album   文件: PhotoViewAttacher.java
/**
 * @return true if the ImageView exists, and its Drawable exists
 */
private static boolean hasDrawable(ImageView imageView) {
    return null != imageView && null != imageView.getDrawable();
}
 
源代码20 项目: iBeebo   文件: AnimationUtility.java
public static Rect getBitmapRectFromImageView(ImageView imageView) {
    Drawable drawable = imageView.getDrawable();
    Bitmap bitmap = null;
    if (drawable instanceof BitmapDrawable) {
        bitmap = ((BitmapDrawable) drawable).getBitmap();
    }

    Rect rect = new Rect();
    boolean isVisible = imageView.getGlobalVisibleRect(rect);
    if (!isVisible) {
        int[] location = new int[2];
        imageView.getLocationOnScreen(location);

        rect.left = location[0];
        rect.top = location[1];
        rect.right = rect.left + imageView.getWidth();
        rect.bottom = rect.top + imageView.getHeight();
    }

    if (bitmap != null) {

        int bitmapWidth = bitmap.getWidth();
        int bitmapHeight = bitmap.getHeight();

        int imageViewWidth = imageView.getWidth() - imageView.getPaddingLeft() - imageView.getPaddingRight();
        int imageviewHeight = imageView.getHeight() - imageView.getPaddingTop() - imageView.getPaddingBottom();

        float startScale;
        if ((float) imageViewWidth / bitmapWidth > (float) imageviewHeight / bitmapHeight) {
            // Extend start bounds horizontally
            startScale = (float) imageviewHeight / bitmapHeight;

        } else {
            startScale = (float) imageViewWidth / bitmapWidth;

        }

        bitmapHeight = (int) (bitmapHeight * startScale);
        bitmapWidth = (int) (bitmapWidth * startScale);

        int deltaX = (imageViewWidth - bitmapWidth) / 2;
        int deltaY = (imageviewHeight - bitmapHeight) / 2;

        rect.set(rect.left + deltaX, rect.top + deltaY, rect.right - deltaX, rect.bottom - deltaY);

        return rect;
    } else {
        return null;
    }

}