Example usage for android.graphics.drawable BitmapDrawable BitmapDrawable

List of usage examples for android.graphics.drawable BitmapDrawable BitmapDrawable

Introduction

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

Prototype

private BitmapDrawable(BitmapState state, Resources res) 

Source Link

Usage

From source file:com.amaze.carbonfilemanager.fragments.MainFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.main_frag, container, false);
    setRetainInstance(true);//from w  w w  . j a va 2s .  com
    listView = (android.support.v7.widget.RecyclerView) rootView.findViewById(R.id.listView);
    mToolbarContainer = (AppBarLayout) getActivity().findViewById(R.id.lin);
    fastScroller = (FastScroller) rootView.findViewById(R.id.fastscroll);
    fastScroller.setPressedHandleColor(Color.parseColor(fabSkin));
    listView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            if (adapter != null && stopAnims) {
                stopAnimation();
                stopAnims = false;
            }
            return false;
        }
    });
    mToolbarContainer.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            if (adapter != null && stopAnims) {
                stopAnimation();
                stopAnims = false;
            }
            return false;
        }
    });

    mSwipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.activity_main_swipe_refresh_layout);

    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            loadlist((CURRENT_PATH), false, openMode);
        }
    });
    buttons = (LinearLayout) getActivity().findViewById(R.id.buttons);
    pathbar = (LinearLayout) getActivity().findViewById(R.id.pathbar);
    SHOW_THUMBS = sharedPref.getBoolean("showThumbs", true);
    res = getResources();
    pathname = (TextView) getActivity().findViewById(R.id.pathname);
    mFullPath = (TextView) getActivity().findViewById(R.id.fullpath);
    //String itemsstring = res.getString(R.string.items);// TODO: 23/5/2017 use or delete
    apk = new BitmapDrawable(res, BitmapFactory.decodeResource(res, R.drawable.ic_doc_apk_grid));
    mToolbarContainer.setBackgroundColor(MainActivity.currentTab == 1 ? skinTwoColor : skin_color);

    if (!sharedPref.getBoolean("intelliHideToolbar", true)) {
        AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) getActivity()
                .findViewById(R.id.action_bar).getLayoutParams();
        params.setScrollFlags(0);
        mToolbarContainer.setExpanded(true, true);
    }

    //   listView.setPadding(listView.getPaddingLeft(), paddingTop, listView.getPaddingRight(), listView.getPaddingBottom());
    return rootView;
}

From source file:com.orbar.pxdemo.ImageView.FivePXImageFragment.java

@Override
public void onResume() {
    Log.d(TAG, "onResume");
    super.onResume();

    //Restore the original actionbar settings
    actionBar.setIcon(R.drawable.ic_launcher);
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);

    BitmapDrawable icon = new BitmapDrawable(getResources(), actionBarUserImage);

    actionBar.setIcon(icon);//ww  w  .  j  a  v a2s  . com

    // Remove Listeners
    mSlidingPaneLayout.setPanelSlideListener(new slideUpLayoutListener());
    userAccountLayout.setOnClickListener(new userAccountClickListener());
    imageStats.setOnClickListener(new ImageControlsListener());
    imageComments.setOnClickListener(new ImageControlsListener());
    imageLikes.setOnClickListener(new ImageControlsListener());
    imageFavorites.setOnClickListener(new ImageControlsListener());
    imageControlsLayout.setOnClickListener(new ImageControlsListener());
    commentsListView.setOnScrollListener(new commentScrollListener());
    submitComment.setOnClickListener(new submitCommentListener());
    mAttacher.setOnPhotoTapListener(new PhotoTapListener());

}

From source file:com.gokuai.yunkuandroidsdk.imageutils.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be
 * set on the ImageView./*w w  w.jav  a2 s. c om*/
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td = new TransitionDrawable(
                new Drawable[] { new ColorDrawable(android.R.color.transparent),
                        isRoundDrawable
                                ? new BitmapDrawable(mResources,
                                        Util.makeRoundDrawable(drawable, GKApplication.getInstance(), false))
                                : drawable });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(isRoundDrawable
                ? new BitmapDrawable(mResources,
                        Util.makeRoundDrawable(drawable, GKApplication.getInstance(), false))
                : new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        if (isRoundDrawable) {

            imageView.setImageBitmap(Util.makeRoundDrawable(drawable, GKApplication.getInstance(), false));
        } else {

            imageView.setImageDrawable(drawable);
        }
    }
}

From source file:com.google.android.apps.muzei.settings.SettingsChooseSourceFragment.java

public void updateSources() {
    mSelectedSource = null;/*from w w  w . ja  v a  2 s.c om*/
    Intent queryIntent = new Intent(ACTION_MUZEI_ART_SOURCE);
    PackageManager pm = getActivity().getPackageManager();
    mSources.clear();
    List<ResolveInfo> resolveInfos = pm.queryIntentServices(queryIntent, PackageManager.GET_META_DATA);

    for (ResolveInfo ri : resolveInfos) {
        Source source = new Source();
        source.label = ri.loadLabel(pm).toString();
        source.icon = new BitmapDrawable(getResources(), generateSourceImage(ri.loadIcon(pm)));
        source.componentName = new ComponentName(ri.serviceInfo.packageName, ri.serviceInfo.name);
        if (ri.serviceInfo.descriptionRes != 0) {
            try {
                Context packageContext = getActivity()
                        .createPackageContext(source.componentName.getPackageName(), 0);
                Resources packageRes = packageContext.getResources();
                source.description = packageRes.getString(ri.serviceInfo.descriptionRes);
            } catch (PackageManager.NameNotFoundException e) {
                Log.e(TAG, "Can't read package resources for source " + source.componentName);
            }
        }
        Bundle metaData = ri.serviceInfo.metaData;
        source.color = Color.WHITE;
        if (metaData != null) {
            String settingsActivity = metaData.getString("settingsActivity");
            if (!TextUtils.isEmpty(settingsActivity)) {
                source.settingsActivity = ComponentName
                        .unflattenFromString(ri.serviceInfo.packageName + "/" + settingsActivity);
            }

            String setupActivity = metaData.getString("setupActivity");
            if (!TextUtils.isEmpty(setupActivity)) {
                source.setupActivity = ComponentName
                        .unflattenFromString(ri.serviceInfo.packageName + "/" + setupActivity);
            }

            source.color = metaData.getInt("color", source.color);

            try {
                float[] hsv = new float[3];
                Color.colorToHSV(source.color, hsv);
                boolean adjust = false;
                if (hsv[2] < 0.8f) {
                    hsv[2] = 0.8f;
                    adjust = true;
                }
                if (hsv[1] > 0.4f) {
                    hsv[1] = 0.4f;
                    adjust = true;
                }
                if (adjust) {
                    source.color = Color.HSVToColor(hsv);
                }
                if (Color.alpha(source.color) != 255) {
                    source.color = Color.argb(255, Color.red(source.color), Color.green(source.color),
                            Color.blue(source.color));
                }
            } catch (IllegalArgumentException ignored) {
            }
        }

        mSources.add(source);
    }

    final String appPackage = getActivity().getPackageName();
    Collections.sort(mSources, new Comparator<Source>() {
        @Override
        public int compare(Source s1, Source s2) {
            String pn1 = s1.componentName.getPackageName();
            String pn2 = s2.componentName.getPackageName();
            if (!pn1.equals(pn2)) {
                if (appPackage.equals(pn1)) {
                    return -1;
                } else if (appPackage.equals(pn2)) {
                    return 1;
                }
            }
            return s1.label.compareTo(s2.label);
        }
    });

    redrawSources();
}

From source file:com.gmall.gmallmanager.widget.videoimage.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be 
 * set on the ImageView./*from   w w  w . ja v a  2  s  . c  om*/
 *
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td = new TransitionDrawable(
                new Drawable[] { new ColorDrawable(R.color.transparent), drawable });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}

From source file:com.linhnv.apps.funnybox.utils.ImageWorker.java

/**
 * Called when the processing is complete and the final bitmap should be set on the ImageView.
 *
 * @param imageView// w  w w. j  a v  a 2s .co  m
 * @param bitmap
 */
private void setImageBitmap(ImageView imageView, Bitmap bitmap) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drwabale and the final bitmap
        final TransitionDrawable td = new TransitionDrawable(new Drawable[] {
                new ColorDrawable(android.R.color.transparent), new BitmapDrawable(mResources, bitmap) });
        // Set background to loading bitmap
        imageView.setImageDrawable(new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageBitmap(bitmap);
        imageView.setBackgroundColor(Color.BLACK);
    }
}

From source file:com.android.simpleimageloader.image.ImageWorker.java

/**
 * Called when the processing is complete and the final drawable should be set on the ImageView.
 * /*from  w  w  w  .j  a v a 2  s .c  om*/
 * @param imageView
 * @param drawable
 */
private void setImageDrawable(ImageView imageView, Drawable drawable, DisplayOptions options) {
    if (options.mFadeInBitmap) {
        // Transition drawable with a transparent drawable and the final drawable
        final TransitionDrawable td = new TransitionDrawable(
                new Drawable[] { new ColorDrawable(android.R.color.transparent), drawable });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(new BitmapDrawable(mResources, options.mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageDrawable(drawable);
    }
}

From source file:com.codingPower.framework.worker.ImageWorker.java

/**
 * Called when the processing is complete and the final bitmap should be set on the ImageView.
 *
 * @param imageView/* w  w  w.  j a  v a 2s . com*/
 * @param bitmap
 */
private void setImageBitmap(ImageView imageView, Bitmap bitmap) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drwabale and the final bitmap
        final TransitionDrawable td = new TransitionDrawable(new Drawable[] {
                new ColorDrawable(android.R.color.transparent), new BitmapDrawable(mResources, bitmap) });
        // Set background to loading bitmap
        //imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageBitmap(bitmap);
    }
}

From source file:cn.mimail.sdk.net.image.ImageWorker.java

/**
 * Called when the processing is complete and the final bitmap should be set on the ImageView.
 *
 * @param imageView//from ww w .  ja v  a2  s.c o  m
 * @param bitmap
 */
private void setImageBitmap(ImageView imageView, Bitmap bitmap) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drwabale and the final bitmap
        final TransitionDrawable td = new TransitionDrawable(new Drawable[] {
                new ColorDrawable(android.R.color.transparent), new BitmapDrawable(mResources, bitmap) });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageBitmap(bitmap);
    }
}

From source file:com.mp.common.photo.ImageWorker.java

/**
 * Called when the processing is complete and the final bitmap should be set on the ImageView.
 *
 * @param imageView//w ww. j av a 2s  .  co  m
 * @param bitmap
 */
@SuppressWarnings("deprecation")
protected void setImageBitmap(ImageView imageView, Bitmap bitmap) {
    if (mFadeInBitmap) {
        // Transition drawable with a transparent drwabale and the final bitmap
        final TransitionDrawable td = new TransitionDrawable(new Drawable[] {
                new ColorDrawable(android.R.color.transparent), new BitmapDrawable(mResources, bitmap) });
        // Set background to loading bitmap
        imageView.setBackgroundDrawable(new BitmapDrawable(mResources, mLoadingBitmap));

        imageView.setImageDrawable(td);
        td.startTransition(FADE_IN_TIME);
    } else {
        imageView.setImageBitmap(bitmap);
    }
}