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


Java View.getResources方法代碼示例

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


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

示例1: matchesSafely

import android.view.View; //導入方法依賴的package包/類
@Override
protected boolean matchesSafely(final View itemView) {
    resources = itemView.getResources();
    if (childItemView == null) {
        final RecyclerView recyclerView = (RecyclerView) itemView.getRootView().findViewById(recyclerViewId);
        if (recyclerView != null && recyclerView.getId() == recyclerViewId) {
            childItemView = recyclerView.findViewHolderForAdapterPosition(position).itemView;
        } else {
            return false;
        }
    }

    if (targetViewId == -1) {
        return itemView == childItemView;
    } else {
        final View targetView = childItemView.findViewById(targetViewId);
        return itemView == targetView;
    }
}
 
開發者ID:ParaskP7,項目名稱:sample-code-posts,代碼行數:20,代碼來源:RecyclerTypeSafeMatcher.java

示例2: BlurTask

import android.view.View; //導入方法依賴的package包/類
public BlurTask(View target, BlurFactor factor, Callback callback) {
  target.setDrawingCacheEnabled(true);
  this.res = target.getResources();
  this.factor = factor;
  this.callback = callback;

  target.destroyDrawingCache();
  target.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_LOW);
  capture = target.getDrawingCache();
  contextWeakRef = new WeakReference<>(target.getContext());
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:BlurTask.java

示例3: createFloatingBitmap

import android.view.View; //導入方法依賴的package包/類
private BitmapDrawable createFloatingBitmap(View v) {
    floatingItemStatingBounds = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom());
    floatingItemBounds = new Rect(floatingItemStatingBounds);

    Bitmap bitmap = Bitmap.createBitmap(floatingItemStatingBounds.width(),
            floatingItemStatingBounds.height(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    v.draw(canvas);

    BitmapDrawable retDrawable = new BitmapDrawable(v.getResources(), bitmap);
    retDrawable.setBounds(floatingItemBounds);

    return retDrawable;
}
 
開發者ID:ccrama,項目名稱:Slide-RSS,代碼行數:15,代碼來源:DragSortRecycler.java

示例4: startAnimators

import android.view.View; //導入方法依賴的package包/類
public static void startAnimators(final View view, int startOffsetX, int startOffsetY, long delay) {
    if (view.getVisibility() == View.VISIBLE && view.getAlpha() != 0f) {
        view.clearAnimation();
        view.animate().cancel();
        final Resources res = view.getResources();
        final float endAlpha = view.getAlpha();
        final float endTranslateX = view.getTranslationX();
        final float endTranslateY = view.getTranslationY();
        view.setAlpha(0);
        final Animator fade = ObjectAnimator.ofFloat(view, View.ALPHA, endAlpha);
        fade.setDuration(res.getInteger(R.integer.material_in_fade_anim_duration));
        fade.setInterpolator(new AccelerateInterpolator());
        fade.setStartDelay(delay);
        fade.start();
        ViewPropertyAnimator slide = view.animate();
        if (startOffsetY != 0) {
            view.setTranslationY(startOffsetY);
            slide.translationY(endTranslateY);
        } else {
            view.setTranslationX(startOffsetX);
            slide.translationX(endTranslateX);
        }
        slide.setInterpolator(new DecelerateInterpolator(2));
        slide.setDuration(res.getInteger(R.integer.material_in_slide_anim_duration));
        slide.setStartDelay(delay);
        slide.setListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationCancel(Animator animation) {
                if (fade.isStarted()) {
                    fade.cancel();
                }
                view.setAlpha(endAlpha);
                view.setTranslationX(endTranslateX);
                view.setTranslationY(endTranslateY);
            }
        });
        slide.start();
    }
}
 
開發者ID:rumaan,項目名稱:file.io-app,代碼行數:40,代碼來源:MaterialIn.java

示例5: forceCustomPadding

import android.view.View; //導入方法依賴的package包/類
public static void forceCustomPadding(View view, boolean additive) {
    final Resources res = view.getResources();
    final int paddingSide = res.getDimensionPixelSize(R.dimen.settings_side_margin);

    final int paddingStart = paddingSide + (additive ? view.getPaddingStart() : 0);
    final int paddingEnd = paddingSide + (additive ? view.getPaddingEnd() : 0);
    final int paddingBottom = res.getDimensionPixelSize(
            R.dimen.preference_fragment_padding_bottom);

    view.setPaddingRelative(paddingStart, 0, paddingEnd, paddingBottom);
}
 
開發者ID:Trumeet,項目名稱:MiPushFramework,代碼行數:12,代碼來源:Utils.java

示例6: ImageGetterAsyncTask

import android.view.View; //導入方法依賴的package包/類
public ImageGetterAsyncTask(UrlDrawable d, MyHtmlHttpImageGetter imageGetter, View container,
                            boolean matchParentWidth, boolean compressImage, int qualityImage) {
    this.drawableReference = new WeakReference<>(d);
    this.imageGetterReference = new WeakReference<>(imageGetter);
    this.containerReference = new WeakReference<>(container);
    this.resources = new WeakReference<>(container.getResources());
    this.matchParentWidth = matchParentWidth;
    this.compressImage = compressImage;
    this.qualityImage = qualityImage;
}
 
開發者ID:mzlogin,項目名稱:guanggoo-android,代碼行數:11,代碼來源:MyHtmlHttpImageGetter.java

示例7: SetupStep

import android.view.View; //導入方法依賴的package包/類
public SetupStep(final int stepNo, final String applicationName, final TextView bulletView,
        final View stepView, final int title, final int instruction,
        final int finishedInstruction, final int actionIcon, final int actionLabel) {
    mStepNo = stepNo;
    mStepView = stepView;
    mBulletView = bulletView;
    final Resources res = stepView.getResources();
    mActivatedColor = res.getColor(R.color.setup_text_action);
    mDeactivatedColor = res.getColor(R.color.setup_text_dark);

    final TextView titleView = (TextView)mStepView.findViewById(R.id.setup_step_title);
    titleView.setText(res.getString(title, applicationName));
    mInstruction = (instruction == 0) ? null
            : res.getString(instruction, applicationName);
    mFinishedInstruction = (finishedInstruction == 0) ? null
            : res.getString(finishedInstruction, applicationName);

    mActionLabel = (TextView)mStepView.findViewById(R.id.setup_step_action_label);
    mActionLabel.setText(res.getString(actionLabel));
    if (actionIcon == 0) {
        final int paddingEnd = ViewCompatUtils.getPaddingEnd(mActionLabel);
        ViewCompatUtils.setPaddingRelative(mActionLabel, paddingEnd, 0, paddingEnd, 0);
    } else {
        TextViewCompatUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(
                mActionLabel, res.getDrawable(actionIcon), null, null, null);
    }
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:28,代碼來源:SetupWizardActivity.java

示例8: matchesSafely

import android.view.View; //導入方法依賴的package包/類
@Override
public boolean matchesSafely(View view) {
    if (resources == null) {
        resources = view.getResources();
        String typeName = resources.getResourceTypeName(resourceId);
        if ("string".matches(typeName)) {
            matcher = withText(resourceId);
        } else if ("id".equals(typeName)) {
            matcher = withId(resourceId);
        } else {
            throw new Resources.NotFoundException("Type not supported, only id & string are supported!");
        }
    }
    return matcher.matches(view);
}
 
開發者ID:vincetreur,項目名稱:Ristretto,代碼行數:16,代碼來源:RistrettoViewMatchers.java

示例9: BlurTask

import android.view.View; //導入方法依賴的package包/類
public BlurTask(View target, BlurFactor factor, Callback callback) {
	this.res = target.getResources();
	this.factor = factor;
	this.callback = callback;
	this.contextWeakRef = new WeakReference<Context>(target.getContext());

	target.setDrawingCacheEnabled(true);
	target.destroyDrawingCache();
	target.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_LOW);
	bitmap = target.getDrawingCache();
}
 
開發者ID:MobClub,項目名稱:BBSSDK-for-Android,代碼行數:12,代碼來源:BlurTask.java

示例10: ImageGetterAsyncTask

import android.view.View; //導入方法依賴的package包/類
public ImageGetterAsyncTask(UrlDrawable d, HtmlHttpImageGetter imageGetter, View container,
                            boolean matchParentWidth, boolean compressImage, int qualityImage) {
    this.drawableReference = new WeakReference<>(d);
    this.imageGetterReference = new WeakReference<>(imageGetter);
    this.containerReference = new WeakReference<>(container);
    this.resources = new WeakReference<>(container.getResources());
    this.matchParentWidth = matchParentWidth;
    this.compressImage = compressImage;
    this.qualityImage = qualityImage;
}
 
開發者ID:RanKKI,項目名稱:PSNine,代碼行數:11,代碼來源:HtmlHttpImageGetter.java

示例11: parseColor

import android.view.View; //導入方法依賴的package包/類
public static int parseColor(View view, String text) {
    if (text.startsWith("@color/")) {
        Resources resources = view.getResources();
        return resources.getColor(resources.getIdentifier(text.substring("@color/".length()), "color", view.getContext().getPackageName()));
    }
    if (text.length() == 4 && text.startsWith("#")) {
        text = "#" + text.charAt(1) + text.charAt(1) + text.charAt(2) + text.charAt(2) + text.charAt(3) + text.charAt(3);
    }
    return Color.parseColor(text);
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:11,代碼來源:DynamicLayoutInflator.java

示例12: onCreateViewHolder

import android.view.View; //導入方法依賴的package包/類
@Override
public DayDetailsListHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view = LayoutInflater.from(parent.getContext())
            .inflate(R.layout.day_details_list_item, parent, false);

    res = view.getResources();

    return new DayDetailsListHolder(view);
}
 
開發者ID:farukydnn,項目名稱:WeatherPlus,代碼行數:10,代碼來源:DayDetailsListAdapter.java

示例13: BlurTask

import android.view.View; //導入方法依賴的package包/類
public BlurTask(View target, BlurFactor factor, Callback callback) {
  this.res = target.getResources();
  this.factor = factor;
  this.callback = callback;
  this.contextWeakRef = new WeakReference<>(target.getContext());

  target.setDrawingCacheEnabled(true);
  target.destroyDrawingCache();
  target.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_LOW);
  bitmap = target.getDrawingCache();
}
 
開發者ID:A-Miracle,項目名稱:QiangHongBao,代碼行數:12,代碼來源:BlurTask.java

示例14: initAnimation

import android.view.View; //導入方法依賴的package包/類
private static void initAnimation(View view, int offsetX, int offsetY, int delayDir, int slideDir) {
    if (offsetX < 0) {
        offsetX = 0;
    }
    if (offsetY < 0) {
        offsetY = 0;
    }
    if (view instanceof ViewGroup && ((ViewGroup) view).getChildCount() > 0 &&
            !MATERIAL_IN_BLOCK.equals(view.getTag()) &&
            !MATERIAL_IN_BLOCK_WITHOUT_SLIDE.equals(view.getTag())) {
        ViewGroup viewGroup = (ViewGroup) view;
        int viewHeight = viewGroup.getHeight();
        for (int i = 0; i < viewGroup.getChildCount(); i++) {
            View child = viewGroup.getChildAt(i);
            int nextOffsetX = offsetX + ((delayDir == Gravity.RIGHT) ? child.getLeft() :
                    (delayDir == Gravity.LEFT ? viewHeight - child.getRight() : 0));
            int nextOffsetY = offsetY + ((delayDir == Gravity.BOTTOM) ? child.getTop() :
                    (delayDir == Gravity.TOP ? viewHeight - child.getBottom() : 0));
            initAnimation(child, nextOffsetX, nextOffsetY, delayDir, slideDir);
        }
    } else {
        final Resources res = view.getResources();
        int slideTranslation = res.getDimensionPixelSize(R.dimen.material_in_anim_slide_offset);
        if (MATERIAL_IN_BLOCK_WITHOUT_SLIDE.equals(view.getTag())) {
            slideTranslation = 0;
        }
        int multY = 0;
        if (slideDir == Gravity.TOP) {
            multY = 1;
        } else if (slideDir == Gravity.BOTTOM) {
            multY = -1;
        }
        int multX = 0;
        if (slideDir == Gravity.LEFT) {
            multX = 1;
        } else if (slideDir == Gravity.RIGHT) {
            multX = -1;
        }
        int delayOffset = delayDir == Gravity.TOP || delayDir == Gravity.BOTTOM ? offsetY : offsetX;
        float delayDenominator = res.getDimension(R.dimen.material_in_delay_denominator);
        long delay = (long) (delayOffset / delayDenominator);
        startAnimators(view, slideTranslation * multX, slideTranslation * multY, delay);
    }
}
 
開發者ID:rumaan,項目名稱:file.io-app,代碼行數:45,代碼來源:MaterialIn.java

示例15: getViewSign

import android.view.View; //導入方法依賴的package包/類
/**
 * 獲取View的簽名
 *
 * @param view
 * @return
 */
public static String getViewSign(View view) {
    StringBuilder sign = new StringBuilder(128);
    sign.append(view.getClass().getName());
    sign.append('{');
    sign.append(Integer.toHexString(System.identityHashCode(view)));
    sign.append(' ');
    sign.append(view.getLeft());
    sign.append(',');
    sign.append(view.getTop());
    sign.append('-');
    sign.append(view.getRight());
    sign.append(',');
    sign.append(view.getBottom());
    final int id = view.getId();
    if (id != View.NO_ID) {
        sign.append(" #");
        sign.append(Integer.toHexString(id));
        final Resources r = view.getResources();
        if (id > 0 && resourceHasPackage(id) && r != null) {
            try {
                String pkgname;
                switch (id & 0xff000000) {
                    case 0x7f000000:
                        pkgname = "app";
                        break;
                    case 0x01000000:
                        pkgname = "android";
                        break;
                    default:
                        pkgname = r.getResourcePackageName(id);
                        break;
                }
                String typename = r.getResourceTypeName(id);
                String entryname = r.getResourceEntryName(id);
                sign.append(" ");
                sign.append(pkgname);
                sign.append(":");
                sign.append(typename);
                sign.append("/");
                sign.append(entryname);
                if ("android".equals(pkgname) && "id".equals(typename) && "content".equals(entryname)) {
                    //找到android:id/content的父View,認為是根View了,不再查找
                    isRootParent = true;
                }
            } catch (Resources.NotFoundException e) {
            }
        }
    }
    sign.append('}');
    return sign.toString();
}
 
開發者ID:zkwlx,項目名稱:DroidTelescope,代碼行數:58,代碼來源:ViewUtils.java


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