List of usage examples for android.support.v4.content.res ResourcesCompat getDrawable
public static Drawable getDrawable(Resources resources, int i, Theme theme) throws NotFoundException
From source file:com.example.android.leanback.CardPresenter.java
@Override public void onBindViewHolder(ViewHolder viewHolder, Object item, List<Object> payloads) { if (payloads.isEmpty()) { super.onBindViewHolder(viewHolder, item, payloads); } else {// w ww .j a v a2 s . c o m PhotoItem photoItem = (PhotoItem) item; Bundle o = (Bundle) payloads.get(0); for (String key : o.keySet()) { if (key.equals(IMAGE)) { final Context context = viewHolder.view.getContext(); Drawable drawable = ResourcesCompat.getDrawable(context.getResources(), photoItem.getImageResourceId(), context.getTheme()); ((ImageCardView) viewHolder.view).setMainImage(drawable); } if (key.equals(CONTENT)) { ((ImageCardView) viewHolder.view).setContentText(photoItem.getContent()); } if (key.equals(TITLE)) { ((ImageCardView) viewHolder.view).setTitleText(photoItem.getTitle()); } } } }
From source file:com.google.cloud.android.language.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mIntroduction = findViewById(R.id.introduction); mResults = findViewById(R.id.results); mProgress = findViewById(R.id.progress); // Set up the input EditText so that it accepts multiple lines mInput = (EditText) findViewById(R.id.input); // sum=(Button)findViewById(R.id.button); mInput.setHorizontallyScrolling(false); mInput.setMaxLines(Integer.MAX_VALUE); // Set up the view pager final FragmentManager fm = getSupportFragmentManager(); mAdapter = new ResultPagerAdapter(fm, this); mViewPager = (ViewPager) findViewById(R.id.pager); final Resources resources = getResources(); mViewPager.setPageMargin(resources.getDimensionPixelSize(R.dimen.page_margin)); mViewPager//from w w w .j ava 2s . c o m .setPageMarginDrawable(ResourcesCompat.getDrawable(resources, R.drawable.page_margin, getTheme())); mViewPager.setOffscreenPageLimit(3); mViewPager.setAdapter(mAdapter); TabLayout tab = (TabLayout) findViewById(R.id.tab); tab.setupWithViewPager(mViewPager); if (savedInstanceState == null) { // The app has just launched; handle share intent if it is necessary handleShareIntent(); } else { // Configuration changes; restore UI states boolean results = savedInstanceState.getBoolean(STATE_SHOWING_RESULTS); if (results) { mIntroduction.setVisibility(View.GONE); mResults.setVisibility(View.VISIBLE); mProgress.setVisibility(View.INVISIBLE); } else { mResults.setVisibility(View.INVISIBLE); } } // Bind event listeners mInput.setOnEditorActionListener(mOnEditorActionListener); findViewById(R.id.analyze).setOnClickListener(mOnClickListener); findViewById(R.id.button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent in = new Intent(getApplicationContext(), Output.class); startActivity(in); } }); // Prepare the API if (getApiFragment() == null) { fm.beginTransaction().add(new ApiFragment(), FRAGMENT_API).commit(); } prepareApi(); }
From source file:com.nttec.everychan.chans.makaba.MakabaModule.java
@Override public Drawable getChanFavicon() { return ResourcesCompat.getDrawable(resources, R.drawable.favicon_makaba, null); }
From source file:com.nttec.everychan.chans.cirno.MikubaModule.java
@Override public Drawable getChanFavicon() { return ResourcesCompat.getDrawable(resources, R.drawable.favicon_mikuba, null); }
From source file:uz.efir.alqalam.SurahActivity.java
private void showData() { AyatIconifiedText ait;//ww w .ja v a2 s.co m final Drawable iconBismillah = ResourcesCompat.getDrawable(getResources(), R.drawable.bismillah, null); final Drawable bookmarkImage = ResourcesCompat.getDrawable(getResources(), R.drawable.bookmark_icon, null); surahAdapter.clear(); resetData(); for (int i = 0; i < Utils.SURAH_NUMBER_OF_AYATS[mSurahNumber]; i++) { ait = new AyatIconifiedText(i, i + 1, AYATSARABIC[i], AYATSTRANS[i]); // check if BISMILLAH must be shown if (i == 0 && mSurahNumber != 0 && mSurahNumber != 8) { ait.setBismillahImage(iconBismillah); } // Put bookmarks if (mBookmarks != null && Arrays.binarySearch(mBookmarks, i + 1) >= 0) { ait.setAyatBookmarkImage(bookmarkImage); ait.setAyatBackground(Color.rgb(243, 255, 140)); } // Put juz and/or sajda icons ait.setAyatSpecialImage(getSpecialImage(mSurahNumber + 1, i + 1)); surahAdapter.addItem(ait); } // make verses appear in list view ayatList.setAdapter(surahAdapter); ayatList.setDivider(null); // Jump to specific Ayat (if defined); if (mCurrentAyat > 0) { ayatList.setSelectionFromTop(mCurrentAyat - 1, 0); } }
From source file:com.android.contacts.editor.EditorUiUtils.java
/** * Return an icon that represents {@param mimeType}. *//*w w w .j a v a 2 s.c o m*/ public static Drawable getMimeTypeDrawable(Context context, String mimeType) { switch (mimeType) { case StructuredName.CONTENT_ITEM_TYPE: return ResourcesCompat.getDrawable(context.getResources(), R.drawable.quantum_ic_person_vd_theme_24, null); case StructuredPostal.CONTENT_ITEM_TYPE: return ResourcesCompat.getDrawable(context.getResources(), R.drawable.quantum_ic_place_vd_theme_24, null); case SipAddress.CONTENT_ITEM_TYPE: return ResourcesCompat.getDrawable(context.getResources(), R.drawable.quantum_ic_dialer_sip_vd_theme_24, null); case Phone.CONTENT_ITEM_TYPE: return ResourcesCompat.getDrawable(context.getResources(), R.drawable.quantum_ic_phone_vd_theme_24, null); case Im.CONTENT_ITEM_TYPE: return ResourcesCompat.getDrawable(context.getResources(), R.drawable.quantum_ic_message_vd_theme_24, null); case Event.CONTENT_ITEM_TYPE: return ResourcesCompat.getDrawable(context.getResources(), R.drawable.quantum_ic_event_vd_theme_24, null); case Email.CONTENT_ITEM_TYPE: return ResourcesCompat.getDrawable(context.getResources(), R.drawable.quantum_ic_email_vd_theme_24, null); case Website.CONTENT_ITEM_TYPE: return ResourcesCompat.getDrawable(context.getResources(), R.drawable.quantum_ic_public_vd_theme_24, null); case Photo.CONTENT_ITEM_TYPE: return ResourcesCompat.getDrawable(context.getResources(), R.drawable.quantum_ic_camera_alt_vd_theme_24, null); case GroupMembership.CONTENT_ITEM_TYPE: return ResourcesCompat.getDrawable(context.getResources(), R.drawable.quantum_ic_label_vd_theme_24, null); case Organization.CONTENT_ITEM_TYPE: return ResourcesCompat.getDrawable(context.getResources(), R.drawable.quantum_ic_business_vd_theme_24, null); case Note.CONTENT_ITEM_TYPE: return ResourcesCompat.getDrawable(context.getResources(), R.drawable.quantum_ic_insert_comment_vd_theme_24, null); case Relation.CONTENT_ITEM_TYPE: return ResourcesCompat.getDrawable(context.getResources(), R.drawable.quantum_ic_circles_ext_vd_theme_24, null); default: return null; } }
From source file:com.nttec.everychan.chans.infinity.InfinityModule.java
@Override public Drawable getChanFavicon() { return ResourcesCompat.getDrawable(resources, R.drawable.favicon_8chan, null); }
From source file:com.nttec.everychan.chans.fourchan.FourchanModule.java
@Override public Drawable getChanFavicon() { return ResourcesCompat.getDrawable(resources, R.drawable.favicon_4chan, null); }
From source file:nya.miku.wishmaster.chans.hispachan.HispachanModule.java
@Override public Drawable getChanFavicon() { return ResourcesCompat.getDrawable(resources, R.drawable.favicon_hispachan, null); }
From source file:com.karma.konnect.BeaconConfigFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_beacon_config, container, false); mEditCard = (LinearLayout) view.findViewById(R.id.edit_card); // Get handles to Status and Address views mEditCardAddress = (TextView) view.findViewById(R.id.edit_card_address); // Setup the URL Edit Text handler mEditCardUrl = (EditText) view.findViewById(R.id.edit_card_url); mEditCardUrl.setOnEditorActionListener(this); // Setup the animation mScanningStatus = (TextView) view.findViewById(R.id.textView_scanningStatus); mScanningAnimation = (AnimationDrawable) ResourcesCompat.getDrawable(getResources(), R.drawable.scanning_animation, null); mScanningStatus.setCompoundDrawablesWithIntrinsicBounds(null, mScanningAnimation, null, null); Button button = (Button) view.findViewById(R.id.edit_card_save); button.setOnClickListener(new View.OnClickListener() { @Override/*from w w w .j ava 2s. c om*/ public void onClick(View view) { saveEditCardUrlToBeacon(); } }); return view; }