当前位置: 首页>>代码示例>>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;未经允许,请勿转载。