當前位置: 首頁>>代碼示例>>Java>>正文


Java Drawable.setLevel方法代碼示例

本文整理匯總了Java中android.graphics.drawable.Drawable.setLevel方法的典型用法代碼示例。如果您正苦於以下問題:Java Drawable.setLevel方法的具體用法?Java Drawable.setLevel怎麽用?Java Drawable.setLevel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.drawable.Drawable的用法示例。


在下文中一共展示了Drawable.setLevel方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setProgress

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private void setProgress(float progress) {
  Drawable progressBarDrawable = mFadeDrawable.getDrawable(PROGRESS_BAR_IMAGE_INDEX);
  if (progressBarDrawable == null) {
    return;
  }

  // display progressbar when not fully loaded, hide otherwise
  if (progress >= 0.999f) {
    if (progressBarDrawable instanceof Animatable) {
      ((Animatable) progressBarDrawable).stop();
    }
    fadeOutLayer(PROGRESS_BAR_IMAGE_INDEX);
  } else {
    if (progressBarDrawable instanceof Animatable) {
      ((Animatable) progressBarDrawable).start();
    }
    fadeInLayer(PROGRESS_BAR_IMAGE_INDEX);
  }
  // set drawable level, scaled to [0, 10000] per drawable specification
  progressBarDrawable.setLevel(Math.round(progress * 10000));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:22,代碼來源:GenericDraweeHierarchy.java

示例2: tileifyIndeterminate

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
 * Convert a AnimationDrawable for use as a barberpole animation.
 * Each frame of the animation is wrapped in a ClipDrawable and
 * given a tiling BitmapShader.
 */
private Drawable tileifyIndeterminate(Drawable drawable) {
    if (drawable instanceof AnimationDrawable) {
        AnimationDrawable background = (AnimationDrawable) drawable;
        final int N = background.getNumberOfFrames();
        AnimationDrawable newBg = new AnimationDrawable();
        newBg.setOneShot(background.isOneShot());

        for (int i = 0; i < N; i++) {
            Drawable frame = tileify(background.getFrame(i), true);
            frame.setLevel(10000);
            newBg.addFrame(frame, background.getDuration(i));
        }
        newBg.setLevel(10000);
        drawable = newBg;
    }
    return drawable;
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:23,代碼來源:IcsProgressBar.java

示例3: fixIconImage

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
void fixIconImage(Resources resources, RemoteViews remoteViews, boolean hasIconBitmap, Notification notification) {
    if (remoteViews == null) return;
    if (!mNotificationCompat.isSystemLayout(remoteViews)) {
        return;
    }
    try {
        //noinspection deprecation
        int id = R_Hide.id.icon.get();
        //only fake small icon
        if (!hasIconBitmap && notification.largeIcon == null) {
            Drawable drawable = resources.getDrawable(notification.icon);
            drawable.setLevel(notification.iconLevel);
            Bitmap bitmap = drawableToBitMap(drawable);
            remoteViews.setImageViewBitmap(id, bitmap);
        }
        if (Build.VERSION.SDK_INT >= 21) {
            remoteViews.setInt(id, "setBackgroundColor", Color.TRANSPARENT);
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            remoteViews.setViewPadding(id, 0, 0, 0, 0);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:7763sea,項目名稱:VirtualHook,代碼行數:26,代碼來源:NotificationFixer.java

示例4: tileifyIndeterminate

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private Drawable tileifyIndeterminate(Drawable drawable) {
    if (!(drawable instanceof AnimationDrawable)) {
        return drawable;
    }
    AnimationDrawable background = (AnimationDrawable) drawable;
    int N = background.getNumberOfFrames();
    Drawable newBg = new AnimationDrawable();
    newBg.setOneShot(background.isOneShot());
    for (int i = 0; i < N; i++) {
        Drawable frame = tileify(background.getFrame(i), true);
        frame.setLevel(10000);
        newBg.addFrame(frame, background.getDuration(i));
    }
    newBg.setLevel(10000);
    return newBg;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:17,代碼來源:AppCompatProgressBarHelper.java

示例5: setWrappedDrawable

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
public final void setWrappedDrawable(Drawable dr) {
    if (this.mDrawable != null) {
        this.mDrawable.setCallback(null);
    }
    this.mDrawable = dr;
    if (dr != null) {
        dr.setCallback(this);
        dr.setVisible(isVisible(), true);
        dr.setState(getState());
        dr.setLevel(getLevel());
        dr.setBounds(getBounds());
        if (this.mState != null) {
            this.mState.mDrawableState = dr.getConstantState();
        }
    }
    invalidateSelf();
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:18,代碼來源:DrawableWrapperDonut.java

示例6: fixIconImage

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
void fixIconImage(Resources resources, RemoteViews remoteViews, boolean hasIconBitmap, Notification notification) {
    if (remoteViews == null || notification.icon == 0) return;
    if (!mNotificationCompat.isSystemLayout(remoteViews)) {
        return;
    }
    try {
        //noinspection deprecation
        int id = R_Hide.id.icon.get();
        //only fake small icon
        if (!hasIconBitmap && notification.largeIcon == null) {
            Drawable drawable = resources.getDrawable(notification.icon);
            drawable.setLevel(notification.iconLevel);
            Bitmap bitmap = drawableToBitMap(drawable);
            remoteViews.setImageViewBitmap(id, bitmap);
            //emui
            if(OSUtils.getInstance().isEmui()) {
                if (notification.largeIcon == null) {
                    notification.largeIcon = bitmap;
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:26,代碼來源:NotificationFixer.java

示例7: updateColor

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private void updateColor() {
    Drawable leftDrawable = name.getCompoundDrawablesRelative()[0];
    String domain = entity.getDomain();
    if (leftDrawable != null && (domain.equals(LIGHT) || domain.equals(SWITCH))) {
        if (!(leftDrawable instanceof LevelListDrawable)) {
            LevelListDrawable levelListDrawable = new LevelListDrawable();
            // Add states
            levelListDrawable.addLevel(1, 1, leftDrawable);
            BitmapDrawable enabledDrawable = (BitmapDrawable) leftDrawable.getConstantState().newDrawable().mutate();
            enabledDrawable.setTintList(ColorStateList.valueOf(ContextCompat.getColor(name.getContext(), R.color.color_activated)));
            levelListDrawable.addLevel(2, 2, enabledDrawable);
            // Restore bounds
            levelListDrawable.setBounds(0, 0, name.getResources().getDimensionPixelSize(R.dimen.icon_size), name.getResources().getDimensionPixelSize(R.dimen.icon_size));

            // Set drawable
            name.setCompoundDrawablesRelative(levelListDrawable, null, null, null);
            leftDrawable = levelListDrawable;
        }
        leftDrawable.setLevel(entity.state.equals(HassUtils.getOnState(entity, false)) ? 1 : 2);
    }
}
 
開發者ID:Maxr1998,項目名稱:home-assistant-Android,代碼行數:22,代碼來源:SwitchViewHolder.java

示例8: onLevelChange

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@Override
protected boolean onLevelChange(int level) {
  boolean levelChanged = false;
  for (int i = 0; i < mLayers.length; i++) {
    Drawable drawable = mLayers[i];
    if (drawable != null && drawable.setLevel(level)) {
      levelChanged = true;
    }
  }
  return levelChanged;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:ArrayDrawable.java

示例9: copyProperties

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
 * Copies various properties from one drawable to the other.
 * @param to drawable to copy properties to
 * @param from drawable to copy properties from
 */
public static void copyProperties(Drawable to, Drawable from) {
  if (from == null || to == null || to == from) {
    return;
  }

  to.setBounds(from.getBounds());
  to.setChangingConfigurations(from.getChangingConfigurations());
  to.setLevel(from.getLevel());
  to.setVisible(from.isVisible(), /* restart */ false);
  to.setState(from.getState());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:DrawableUtils.java

示例10: onDraw

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@Override
protected synchronized void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    Drawable d = mCurrentDrawable;
    if (d != null) {
        // Translate canvas so a indeterminate circular progress bar with padding
        // rotates properly in its animation
        canvas.save();
        canvas.translate(getPaddingLeft() + mIndeterminateRealLeft, getPaddingTop() + mIndeterminateRealTop);
        long time = getDrawingTime();
        if (mAnimation != null) {
            mAnimation.getTransformation(time, mTransformation);
            float scale = mTransformation.getAlpha();
            try {
                mInDrawing = true;
                d.setLevel((int) (scale * MAX_LEVEL));
            } finally {
                mInDrawing = false;
            }
            if (SystemClock.uptimeMillis() - mLastDrawTime >= mAnimationResolution) {
                mLastDrawTime = SystemClock.uptimeMillis();
                postInvalidateDelayed(mAnimationResolution);
            }
        }
        d.draw(canvas);
        canvas.restore();
        if (mShouldStartAnimationDrawable && d instanceof Animatable) {
            ((Animatable) d).start();
            mShouldStartAnimationDrawable = false;
        }
    }
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:34,代碼來源:IcsProgressBar.java

示例11: updateDrawable

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private void updateDrawable(Drawable d) {
        if (mDrawable != null) {
            mDrawable.setCallback(null);
            unscheduleDrawable(mDrawable);
            if (isAttachedWindow) {
                mDrawable.setVisible(false, false);
            }
        }
        mDrawable = d;

        if (d != null) {
            d.setCallback(this);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                d.setLayoutDirection(getLayoutDirection());
            }
            if (d.isStateful()) {
                d.setState(getDrawableState());
            }
            if (isAttachedWindow) {
                d.setVisible(getWindowVisibility() == VISIBLE && isShown(), true);
            }
            d.setLevel(mLevel);
            mDrawableWidth = d.getIntrinsicWidth();
            mDrawableHeight = d.getIntrinsicHeight();
//            applyImageTint();
//            applyColorMod();
//
//            configureBounds();
        } else {
            mDrawableWidth = mDrawableHeight = -1;
        }
    }
 
開發者ID:jeasinlee,項目名稱:AndroidBasicLibs,代碼行數:33,代碼來源:LargeImageView.java

示例12: updateDrawable

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private void updateDrawable(Drawable d) {
        boolean sameDrawable = false;
        boolean sCompatDrawableVisibilityDispatch = false;

        if (mDrawable != null) {
            sameDrawable = mDrawable == d;
            mDrawable.setCallback(null);
            unscheduleDrawable(mDrawable);
            if (!sCompatDrawableVisibilityDispatch && !sameDrawable && isAttachedWindow) {
                mDrawable.setVisible(false, false);
            }
        }

        mDrawable = d;

        if (d != null) {
            d.setCallback(this);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                d.setLayoutDirection(getLayoutDirection());
            }
            if (d.isStateful()) {
                d.setState(getDrawableState());
            }
            if (!sameDrawable || sCompatDrawableVisibilityDispatch) {
                final boolean visible = sCompatDrawableVisibilityDispatch
                        ? getVisibility() == VISIBLE
                        : isAttachedWindow && getWindowVisibility() == VISIBLE && isShown();
                d.setVisible(visible, true);
            }
            d.setLevel(mLevel);
            mDrawableWidth = d.getIntrinsicWidth();
            mDrawableHeight = d.getIntrinsicHeight();
//            applyImageTint();
//            applyColorMod();
//
//            configureBounds();
        } else {
            mDrawableWidth = mDrawableHeight = -1;
        }
    }
 
開發者ID:jeasinlee,項目名稱:AndroidBasicLibs,代碼行數:41,代碼來源:UpdateImageView.java

示例13: fixIconImage

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
void fixIconImage(Resources resources, RemoteViews remoteViews, boolean hasIconBitmap, Notification notification) {
		if (remoteViews == null) return;
		if (!mNotificationCompat.isSystemLayout(remoteViews)) {
			VLog.w(TAG, "ignore not system contentView");
			return;
		}
//        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
		try {
			//noinspection deprecation
			int id = R_Hide.id.icon.get();
			if (!hasIconBitmap) {
				Drawable drawable = resources.getDrawable(android.R.drawable.sym_def_app_icon);//notification.icon);
				drawable.setLevel(notification.iconLevel);
				Bitmap bitmap = drawableToBitMap(drawable);
//                Log.i(NotificationHandler.TAG, "den" + resources.getConfiguration().densityDpi);
				remoteViews.setImageViewBitmap(id, bitmap);
			}
			if (Build.VERSION.SDK_INT >= 21) {
				remoteViews.setInt(id, "setBackgroundColor", Color.TRANSPARENT);
			}
			if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
				remoteViews.setViewPadding(id, 0, 0, 0, 0);
			}
		} catch (Exception e) {
			e.printStackTrace();
			VLog.w(TAG, "fix icon", e);
		}
//        } else {
//            try {
//                int id = R_Hide.id.icon.get();
//                Icon icon = notification.getLargeIcon();
//                if (icon == null) {
//                    icon = notification.getSmallIcon();
//                }
//                remoteViews.setImageViewIcon(id, icon);
//                if (Build.VERSION.SDK_INT >= 21) {
//                    remoteViews.setInt(id, "setBackgroundColor", Color.TRANSPARENT);
//                }
//                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
//                    remoteViews.setViewPadding(id, 0, 0, 0, 0);
//                }
//            } catch (Exception e) {
//                e.printStackTrace();
//            }
//        }
	}
 
開發者ID:codehz,項目名稱:container,代碼行數:47,代碼來源:NotificationFixer.java

示例14: updateDrawableScale

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
 * Updates a scale level of the given <var>drawable</var> according to the specified scale
 * value.
 *
 * @param drawable The drawable of which scale level to update.
 * @param scale    The scale value from the range {@code [0.0, 1.0]}.
 */
private void updateDrawableScale(Drawable drawable, float scale) {
	if (drawable instanceof ScaleDrawable) drawable.setLevel(Math.round(scale * MAX_LEVEL));
}
 
開發者ID:universum-studios,項目名稱:android_ui,代碼行數:11,代碼來源:SeekBarWidget.java

示例15: updateProgressDrawableLevel

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
 * If one the drawable layers of the wrapped drawable is {@link android.R.id#progress} this will
 * update its current level to the specified one.
 *
 * @param level The level to be set to the progress layer (if presented).
 * @return {@code True} if the given level has been set and it actually changed to the current
 * level of the progress layer, {@code false} otherwise.
 */
private boolean updateProgressDrawableLevel(int level) {
	final Drawable progressDrawable = ((LayerDrawable) mDrawable).findDrawableByLayerId(android.R.id.progress);
	return progressDrawable != null && progressDrawable.setLevel(level);
}
 
開發者ID:universum-studios,項目名稱:android_ui,代碼行數:13,代碼來源:TintLayerDrawable.java


注:本文中的android.graphics.drawable.Drawable.setLevel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。