當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。