当前位置: 首页>>代码示例>>Java>>正文


Java ResourcesCompat类代码示例

本文整理汇总了Java中android.support.v4.content.res.ResourcesCompat的典型用法代码示例。如果您正苦于以下问题:Java ResourcesCompat类的具体用法?Java ResourcesCompat怎么用?Java ResourcesCompat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ResourcesCompat类属于android.support.v4.content.res包,在下文中一共展示了ResourcesCompat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initializeColorBar

import android.support.v4.content.res.ResourcesCompat; //导入依赖的package包/类
private void initializeColorBar() {
    drawerLayout.setScrimColor(ContextCompat.getColor(this, R.color.scrimColor));
    for (NoteColor noteColor : NoteColor.values()) {
        ImageView view = new ImageView(this);
        Drawable circle;
        if (noteColor == NoteColor.NO_COLOR) {
            circle = ResourcesCompat.getDrawable(getResources(),
                    R.drawable.ic_remove_filter, null);
        } else {
            circle = ResourcesCompat.getDrawable(getResources(),
                    R.drawable.color_circle, null);
            circle.setColorFilter(Color.parseColor(noteColor.toHexString()),
                    PorterDuff.Mode.SRC_IN);
        }
        view.setImageDrawable(circle);
        view.setLayoutParams(getColorBarItemParams());
        view.setTag(noteColor);
        view.setOnClickListener(getOnClickListener());
        view.setAdjustViewBounds(true);
        view.setScaleType(ImageView.ScaleType.FIT_CENTER);
        colorBar.addView(view);
    }
}
 
开发者ID:Laaidback,项目名称:A.scribe,代码行数:24,代码来源:MainActivity.java

示例2: update

import android.support.v4.content.res.ResourcesCompat; //导入依赖的package包/类
public void update() {
    mTemperatureTextView.setText(String.format("%d", mDevice.getTemperature()));

    int activeColor = ResourcesCompat.getColor(getResources(), R.color.colorPrimary, null);
    int inactiveColor = ResourcesCompat.getColor(getResources(), R.color.colorSecondaryText, null);

    final Device.Mode mode = mDevice.getMode();

    setImageButtonColorFilter(R.id.autoModeButton, mode == Device.Mode.AUTO ? activeColor : inactiveColor);
    setImageButtonColorFilter(R.id.coolModeButton, mode == Device.Mode.COOL ? activeColor : inactiveColor);
    setImageButtonColorFilter(R.id.dryModeButton, mode == Device.Mode.DRY ? activeColor : inactiveColor);
    setImageButtonColorFilter(R.id.fanModeButton, mode == Device.Mode.FAN ? activeColor : inactiveColor);
    setImageButtonColorFilter(R.id.heatModeButton, mode == Device.Mode.HEAT ? activeColor : inactiveColor);
    setImageButtonColorFilter(R.id.powerButton, mDevice.isPoweredOn() ? activeColor : inactiveColor);

    setSwitchChecked(R.id.airSwitch, mDevice.isAirModeEnabled());
    setSwitchChecked(R.id.healthSwitch, mDevice.isHealthModeEnabled());
    setSwitchChecked(R.id.xfanSwitch, mDevice.isXfanModeEnabled());
    setSwitchChecked(R.id.sleepSwitch, mDevice.isSleepModeEnabled());
    setSwitchChecked(R.id.quietSwitch, mDevice.isQuietModeEnabled());
    setSwitchChecked(R.id.turboSwitch, mDevice.isTurboModeEnabled());
    setSwitchChecked(R.id.energySavingSwitch, mDevice.isSavingModeEnabled());
    setSwitchChecked(R.id.lightSwitch, mDevice.isLightEnabled());

    ((SeekBar) findViewById(R.id.fanSpeedSeekBar)).setProgress(mDevice.getFanSpeed().ordinal());
}
 
开发者ID:tomikaa87,项目名称:gree-remote,代码行数:27,代码来源:DeviceActivity.java

示例3: loadInBackground

import android.support.v4.content.res.ResourcesCompat; //导入依赖的package包/类
@Override
public List<Item> loadInBackground() {
    items = new ArrayList<>();
    for (SearchData data : SEARCHES_DATA) {
        Drawable icon = context.getDrawable(data.src);
        if (icon != null){
            icon.setTint(ResourcesCompat.getColor(context.getResources(),R.color.color_secondary,null));
        }
        Item search;
        if (data.packageName == null) {
            search = new InputSearch(data.label, icon, data.link, data.priority);
        } else {
            //Uri gmmIntentUri = Uri.parse("geo:0,0?q=1600 Amphitheatre Parkway, Mountain+View, California");
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setPackage(data.packageName);
            search = new InputSearch(data.label, icon, intent, data.link, data.priority);
        }
        items.add(search);
    }
    return items;
}
 
开发者ID:RawLauncher,项目名称:RawLauncher,代码行数:22,代码来源:InputSearchLoader.java

示例4: setupView

import android.support.v4.content.res.ResourcesCompat; //导入依赖的package包/类
protected void setupView(View view) {
    if (hasToolbar()) {
        toolbar.setVisibility(android.view.View.VISIBLE);
        toolbar.setBackgroundColor(
                ResourcesCompat.getColor(getResources(), toolbarBackground(),
                        getContext().getTheme()));
    } else {
        toolbar.setVisibility(android.view.View.GONE);
    }

    swipeRefreshLayout.setOnRefreshListener(this);
    swipeRefreshLayout.setColorSchemeResources(R.color.colorAccent);

    recyclerView.setHasFixedSize(true);
    recyclerView.setAdapter(proteinAdapter = new ProteinAdapter());
    recyclerView.setLayoutManager(createLayoutManager());

    recyclerViewObserver = new RecyclerViewObserver()
            .subscribeOn(recyclerView)
            .setOnLoadMoreListener(() -> {
                if (!TextUtils.isEmpty(listPresenter.getNextPageUrl())) {
                    listPresenter.fetchMoreData();
                }
            })
            .initialize();
}
 
开发者ID:gejiaheng,项目名称:Protein,代码行数:27,代码来源:ListFragment.java

示例5: getIcon

import android.support.v4.content.res.ResourcesCompat; //导入依赖的package包/类
private Bitmap getIcon(String appPackage) {
    Bitmap storedIcon = iconCache.get(appPackage);
    if (storedIcon != null) {
        return storedIcon;
    }


    try {
        Drawable appIconDrawable = service.getPackageManager().getApplicationIcon(appPackage);
        Bitmap iconBitmap = BitmapUtils.getBitmap(appIconDrawable);
        if (iconBitmap != null) {
            iconBitmap = BitmapUtils.shrinkPreservingRatio(iconBitmap, 64, 64);

            iconCache.put(appPackage, iconBitmap);
            return iconBitmap;
        }
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }

    return BitmapUtils.getBitmap(ResourcesCompat.getDrawable(service.getResources(), android.R.drawable.sym_def_app_icon, null));
}
 
开发者ID:matejdro,项目名称:WearVibrationCenter,代码行数:23,代码来源:AppMuteManager.java

示例6: bindMovie

import android.support.v4.content.res.ResourcesCompat; //导入依赖的package包/类
void bindMovie(Movie movie, int position) {
    mMovie = movie;

    positionView.setText(String.valueOf(position + 1));
    Drawable placeholder = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.background_reel, null);
    Picasso.with(mContext)
            .load(Constants.TMDB_IMAGE_URL + Constants.POSTER_SIZE_W342 + movie.getPosterPath())
            .placeholder(placeholder)
            .fit().centerCrop()
            .noFade()
            .into(posterView);
    nameView.setText(movie.getTitle());
    originalNameView.setText(mContext.getString(R.string.movie_original_name, movie.getOriginalTitle(), StringUtils.getYear(movie.getReleaseDate())));
    voteAverageView.setText(String.valueOf(movie.getVoteAverage()));
    voteCountView.setText(String.valueOf(movie.getVoteCount()));
}
 
开发者ID:ansarisufiyan777,项目名称:Show_Chat,代码行数:17,代码来源:MoviesAdapter.java

示例7: bindTv

import android.support.v4.content.res.ResourcesCompat; //导入依赖的package包/类
void bindTv(TV tv, int position) {
    mTV = tv;

    positionView.setText(String.valueOf(position + 1));
    Drawable placeholder = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.background_reel, null);
    Picasso.with(mContext)
            .load(Constants.TMDB_IMAGE_URL + Constants.POSTER_SIZE_W342 + tv.getPosterPath())
            .placeholder(placeholder)
            .fit().centerCrop()
            .noFade()
            .into(posterView);
    nameView.setText(tv.getName());
    originalNameView.setText(mContext.getString(R.string.movie_original_name, tv.getOriginalName(), StringUtils.getYear(tv.getFirstAirDate())));
    voteAverageView.setText(String.valueOf(tv.getVoteAverage()));
    voteCountView.setText(String.valueOf(tv.getVoteCount()));
}
 
开发者ID:qqq3,项目名称:inventum,代码行数:17,代码来源:TvAdapter.java

示例8: setButtonColor

import android.support.v4.content.res.ResourcesCompat; //导入依赖的package包/类
private void setButtonColor() {
    if (kanboardColors == null || defaultColor == null)
        return;

    btnColor.setEnabled(true);

    Drawable dot = ResourcesCompat.getDrawable(getResources(), R.drawable.shape_circle, null);
    if (colorId != null && kanboardColors.get(colorId) != null) {  //FIXME: it seems that colorId can have a value that is not in the list. Fallback to defaultColor for now.
        dot.setColorFilter(kanboardColors.get(colorId).getBackground(), PorterDuff.Mode.MULTIPLY);
        btnColor.setText(Utils.fromHtml(getString(R.string.taskedit_color, kanboardColors.get(colorId).getName())));
    } else {
        dot.setColorFilter(kanboardColors.get(defaultColor).getBackground(), PorterDuff.Mode.MULTIPLY);
        btnColor.setText(Utils.fromHtml(getString(R.string.taskedit_color, kanboardColors.get(defaultColor).getName())));
    }
    btnColor.setCompoundDrawablesRelativeWithIntrinsicBounds(dot, null, null, null);
}
 
开发者ID:andresth,项目名称:Kandroid,代码行数:17,代码来源:TaskEditActivity.java

示例9: onCreate

import android.support.v4.content.res.ResourcesCompat; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_postulaciones_activas);
    // Setting ViewPager for each Tabs
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager_pa);
    setupViewPager(viewPager);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerpa);
    // Adding menu icon to Toolbar
    ActionBar supportActionBar = getSupportActionBar();
    if (supportActionBar != null) {
        VectorDrawableCompat indicator
                = VectorDrawableCompat.create(getResources(), R.drawable.ic_menu, getTheme());
        indicator.setTint(ResourcesCompat.getColor(getResources(),R.color.white,getTheme()));
        supportActionBar.setHomeAsUpIndicator(indicator);
        supportActionBar.setDisplayHomeAsUpEnabled(true);
    }

}
 
开发者ID:sloiza,项目名称:changApp,代码行数:20,代码来源:PostulacionesActivasActivity.java

示例10: onCreate

import android.support.v4.content.res.ResourcesCompat; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_changas_pendientes);
    // Setting ViewPager for each Tabs
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager_cp);
    setupViewPager(viewPager);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerCP);
    // Adding menu icon to Toolbar
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar_cp));
    if (getSupportActionBar() != null) {
        VectorDrawableCompat indicator
                = VectorDrawableCompat.create(getResources(), R.drawable.ic_menu, getTheme());
        indicator.setTint(ResourcesCompat.getColor(getResources(),R.color.white,getTheme()));
        //getSupportActionBar().setHomeAsUpIndicator(indicator);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle("Mis changas pendientes");
    }

}
 
开发者ID:sloiza,项目名称:changApp,代码行数:21,代码来源:ChangasPendientesActivity.java

示例11: onCreate

import android.support.v4.content.res.ResourcesCompat; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_changas_activas);
    // Setting ViewPager for each Tabs
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager_ca);
    setupViewPager(viewPager);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerCA);
    // Adding menu icon to Toolbar
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar_ca));
    if (getSupportActionBar() != null) {
        VectorDrawableCompat indicator
                = VectorDrawableCompat.create(getResources(), R.drawable.ic_menu, getTheme());
        indicator.setTint(ResourcesCompat.getColor(getResources(),R.color.white,getTheme()));
        //getSupportActionBar().setHomeAsUpIndicator(indicator);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle("Mis changas");
    }

}
 
开发者ID:sloiza,项目名称:changApp,代码行数:21,代码来源:ChangasActivasActivity.java

示例12: onCreate

import android.support.v4.content.res.ResourcesCompat; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_changas_finalizadas);
    // Setting ViewPager for each Tabs
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager_cf);
    setupViewPager(viewPager);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerCF);
    // Adding menu icon to Toolbar
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar_cf));
    if (getSupportActionBar() != null) {
        VectorDrawableCompat indicator
                = VectorDrawableCompat.create(getResources(), R.drawable.ic_menu, getTheme());
        indicator.setTint(ResourcesCompat.getColor(getResources(),R.color.white,getTheme()));
        //getSupportActionBar().setHomeAsUpIndicator(indicator);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle("Mis changas finalizadas");
    }

}
 
开发者ID:sloiza,项目名称:changApp,代码行数:21,代码来源:ChangasFinalizadasActivity.java

示例13: initView

import android.support.v4.content.res.ResourcesCompat; //导入依赖的package包/类
private void initView() {
    initIndicator();
    initToolbar();

    mTvTitle.setText("水印处理");
    mColorGridAdapter = new ColorGridAdapter(MarkActivity.this);
    mColorGridAdapter.setOnColorItemClickListener(mOnColorItemClickListener);
    mGridColor.setAdapter(mColorGridAdapter);
    mGridColor.setSelector(ResourcesCompat.getDrawable(getResources(), R.drawable.md_transparent, null));

    mEtWaterMarker.addTextChangedListener(mTextWatcher);
    String defaultText = (String) SPUtils.get(this, KEY_DEFAULT_TEXT, "仅提供XX银行申请XX基金扣帐他用无效");
    mEtWaterMarker.setText(defaultText);
    mSeekBarDirection.setOnProgressChangedListener(mOnProgressChangedListener);
    mSeekBarAlpha.setOnProgressChangedListener(mOnProgressAlphaChangedListener);
    mSeekBarSize.setOnProgressChangedListener(mOnProgressSizeChangedListener);
    int color = (int) SPUtils.get(MarkActivity.this, COLOR_CHOOSE, Color.parseColor("#FF1744"));

    getPresenter().setWaterMask(mEtWaterMarker.getText().toString(), 45, 255, color, 18);
}
 
开发者ID:Loofer,项目名称:Watermark,代码行数:21,代码来源:MarkActivity.java

示例14: MapClusterOptionsProvider

import android.support.v4.content.res.ResourcesCompat; //导入依赖的package包/类
public MapClusterOptionsProvider(Resources resources) {
    int poiSize = resources.getDimensionPixelSize(R.dimen.map_poi_size);

    Drawable d = ResourcesCompat.getDrawable(resources, R.drawable.ic_wrapper_poi_cluster, null);
    d.setBounds(0, 0, poiSize, poiSize);
    Bitmap bitmap = Bitmap.createBitmap(poiSize, poiSize, Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    d.draw(canvas);
    baseBitmap = bitmap;

    littleFontPaint.setColor(Color.BLACK);
    littleFontPaint.setTextAlign(Align.CENTER);
    littleFontPaint.setFakeBoldText(true);
    littleFontPaint.setTextSize(resources.getDimension(R.dimen.map_marker_cluster_text_size_small));
    bigFontPaint.setColor(Color.BLACK);
    bigFontPaint.setTextAlign(Align.CENTER);
    bigFontPaint.setFakeBoldText(true);
    bigFontPaint.setTextSize(resources.getDimension(R.dimen.map_marker_cluster_text_size_big));
}
 
开发者ID:mosquitolabs,项目名称:referendum_1o_android,代码行数:20,代码来源:MapClusterOptionsProvider.java

示例15: onFileDownloaded

import android.support.v4.content.res.ResourcesCompat; //导入依赖的package包/类
@Override
public void onFileDownloaded(final String filePath) {
    setBottomNoticeMessage(getString(R.string.complete));
    mDownloadFile.setEnabled(true);
    mDownloadFile.setImageDrawable(ResourcesCompat.getDrawable(getResources(), R.drawable
            .ic_file_download_24dp, null));
    mOpenFile = true;
    mFilePath = filePath;
    mBottomNoticeLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            openFile(mFilePath);
            mOpenFile = false;
            mBottomNoticeLayout.setOnClickListener(null);
            hideBottomNotice();
        }
    });
}
 
开发者ID:metarhia,项目名称:metacom-android,代码行数:19,代码来源:FilesFragment.java


注:本文中的android.support.v4.content.res.ResourcesCompat类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。