List of usage examples for android.content.res Resources getDrawable
@Deprecated public Drawable getDrawable(@DrawableRes int id) throws NotFoundException
From source file:com.example.kushagar.knockknock.FragmentMain.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub View rootView = inflater.inflate(R.layout.fragment_main, container, false); //TextView mTxtTitle = (TextView) rootView.findViewById(R.id.txtTitle); //mTxtTitle.setText(getArguments().getString(TEXT_FRAGMENT)); mCardContainer = (CardContainer) rootView.findViewById(R.id.layoutview); SimpleCardStackAdapter adapter = new SimpleCardStackAdapter(getActivity()); Resources r = getResources(); //add the cards here by posting a get request. byte[] encodeByte = Base64.decode("Description goes here", Base64.DEFAULT); Bitmap bitmap = BitmapFactory.decodeByteArray(encodeByte, 0, encodeByte.length); Drawable d = new BitmapDrawable(bitmap); adapter.add(new CardModel("Title1", "Description goes here", d)); CardModel cardModel = new CardModel("Title1", "Description goes here", r.getDrawable(R.drawable.picture1)); cardModel.setOnClickListener(new CardModel.OnClickListener() { @Override/*from ww w .ja v a 2 s. c o m*/ public void OnClickListener() { Log.i("Swipeable Cards", "I am pressing the card"); } }); cardModel.setOnCardDimissedListener(new CardModel.OnCardDimissedListener() { @Override public void onLike() { Log.i("Swipeable Cards", "I like the card"); } @Override public void onDislike() { Log.i("Swipeable Cards", "I dislike the card"); } }); adapter.add(cardModel); mCardContainer.setAdapter(adapter); rootView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); return rootView; }
From source file:com.morlunk.mumbleclient.channel.ChannelListAdapter.java
private Drawable getTalkStateDrawable(IUser user) { Resources resources = mContext.getResources(); if (user.isSelfDeafened()) { return resources.getDrawable(R.drawable.outline_circle_deafened); } else if (user.isDeafened()) { return resources.getDrawable(R.drawable.outline_circle_server_deafened); } else if (user.isSelfMuted()) { return resources.getDrawable(R.drawable.outline_circle_muted); } else if (user.isMuted()) { return resources.getDrawable(R.drawable.outline_circle_server_muted); } else if (user.isSuppressed()) { return resources.getDrawable(R.drawable.outline_circle_suppressed); } else {/* www .j ava2s . c om*/ // Passive drawables if (user.getTexture() != null) { // FIXME: cache bitmaps Bitmap bitmap = BitmapFactory.decodeByteArray(user.getTexture(), 0, user.getTexture().length); return new CircleDrawable(mContext.getResources(), bitmap); } else { return resources.getDrawable(R.drawable.outline_circle_talking_off); } } }
From source file:github.madmarty.madsonic.util.ImageLoader.java
private void createUnknownAvatarImage(Context context) { Resources res = context.getResources(); Drawable contact = res.getDrawable(R.drawable.ic_contact_picture); unknownAvatarImage = Util.createBitmapFromDrawable(contact); }
From source file:org.dash.wallet.common.ui.CurrencyAmountView.java
private void init(final Context context) { final Resources resources = context.getResources(); significantColor = resources.getColor(R.color.fg_significant); lessSignificantColor = resources.getColor(R.color.fg_less_significant); errorColor = resources.getColor(R.color.fg_error); colorPrimary = resources.getColor(R.color.colorPrimary); deleteButtonDrawable = resources.getDrawable(R.drawable.ic_clear_grey600_24dp); }
From source file:com.rockerhieu.emojicon.EmojiconsPopup.java
private void setupTab(TabLayout layout) { final LayoutInflater inflater = LayoutInflater.from(layout.getContext()); final Resources res = layout.getContext().getResources(); int tabcount = layout.getTabCount(); for (int i = 0; i < tabcount; i++) { TabLayout.Tab tab = layout.getTabAt(i); switch (i) { case 0://from w w w . j a va 2 s . co m tab.setIcon(res.getDrawable(R.drawable.ic_emoji_recent_light)); break; case 1: tab.setIcon(res.getDrawable(R.drawable.ic_emoji_people_light)); break; case 2: tab.setIcon(res.getDrawable(R.drawable.ic_emoji_nature_light)); break; case 3: tab.setIcon(res.getDrawable(R.drawable.ic_emoji_objects_light)); break; case 4: tab.setIcon(res.getDrawable(R.drawable.ic_emoji_places_light)); break; case 5: tab.setIcon(res.getDrawable(R.drawable.ic_emoji_symbols_light)); break; } } }
From source file:net.alexjf.tmm.fragments.ImmedTransactionEditorFragment.java
private boolean validateInputFields() { boolean error = false; Resources res = getResources(); Drawable errorDrawable = res.getDrawable(R.drawable.indicator_input_error); errorDrawable.setBounds(0, 0, errorDrawable.getIntrinsicWidth(), errorDrawable.getIntrinsicHeight()); String value = valueText.getText().toString(); if (TextUtils.isEmpty(value)) { valueText.setError(res.getString(R.string.error_trans_value_unspecified), errorDrawable); error = true;/* www.j av a2 s. co m*/ } else { try { new ExpressionBuilder(value).build(); } catch (Exception e) { valueText.setError(res.getString(R.string.error_trans_value_invalid), errorDrawable); error = true; } } if (selectedCategory == null) { categoryButton.setError(true); error = true; } if (transferCheck.isChecked()) { if (selectedTransferMoneyNode == null) { transferMoneyNodeButton.setError(true); error = true; } else { CurrencyUnit thisTransactionCurrency = currentMoneyNode.getCurrency(); CurrencyUnit otherTransactionCurrency = selectedTransferMoneyNode.getCurrency(); if (!thisTransactionCurrency.equals(otherTransactionCurrency)) { String conversionAmount = transferConversionAmountText.getText().toString(); if (TextUtils.isEmpty(conversionAmount)) { transferConversionAmountText.setError( res.getString(R.string.error_trans_other_currency_unspecified), errorDrawable); error = true; } else { try { new ExpressionBuilder(conversionAmount).build(); } catch (Exception e) { transferConversionAmountText.setError(res.getString(R.string.error_trans_value_invalid), errorDrawable); error = true; } } } } } return !error; }
From source file:com.jacr.instagramtrendreader.Main.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setContentView(R.layout.activity_main); /* Customizing ActionBar */ Resources r = getResources(); ActionBar ab = super.getActionBar(false); ab.setIcon(r.getDrawable(R.drawable.ic_menu_home)); ab.setTitle(Util.getTitleActivity(getString(R.string.title_my_gallery_app))); /* Views *//* www .j av a 2 s . c om*/ layoutThumbnail = (TableLayout) findViewById(R.id.layoutThumbnail); layoutThumbnail.setPadding(1, 1, 1, 1); /* Setting Viewpager and Indicator */ mPager = (ViewPager) findViewById(R.id.pagerMain); mAdapter = new ViewPagerAdapter<MainFragment>(getSupportFragmentManager()); mPager.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageScrollStateChanged(int arg0) { } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageSelected(int arg0) { int key = feedReader.getListThumbnailKeys().get(arg0); feedReader.highlightThumbnail(key); } }); /* Receiver */ mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); Bundle extras = intent.getExtras(); if (action.contentEquals(ACTION_IMAGE_CLICK)) { int key = extras.getInt(ACTION_IMAGE_CLICK); if (key != -1) { Intent in = new Intent(Main.this, ImageDetails.class); Bundle b = new Bundle(); /* * Warning with Error FAILED BINDED TRANSACTION: it * happens When the transfer of "extras" out of memory. * in This case, when images are sent in intent. */ b.putSerializable(ImageDetails.KEY_THUMBNAIL_DATA, feedReader.getListThumbnailData()); b.putSerializable(ImageDetails.KEY_THUMBNAIL_KEYS, feedReader.getListThumbnailKeys()); b.putInt(ImageDetails.KEY_THUMBNAIL_ACTUAL_KEY, key); in.putExtras(b); startActivity(in); } } } }; IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_IMAGE_CLICK); registerReceiver(mReceiver, filter); /* Load data from Instagram */ cargarFeedReader(); }
From source file:com.abcvoipsip.ui.dialpad.DialerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.dialer_digit, container, false); // Store the backgrounds objects that will be in use later Resources r = getResources(); digitsBackground = r.getDrawable(R.drawable.btn_dial_textfield_active); digitsEmptyBackground = r.getDrawable(R.drawable.btn_dial_textfield_normal); // Store some object that could be useful later digits = (DigitsEditText) v.findViewById(R.id.digitsText); digitsWrapper = (LinearLayout) v.findViewById(R.id.topField); dialPad = (Dialpad) v.findViewById(R.id.dialPad); callBar = (DialerCallBar) v.findViewById(R.id.dialerCallBar); autoCompleteList = (ListView) v.findViewById(R.id.autoCompleteList); accountChooserButton = (AccountChooserButton) v.findViewById(R.id.accountChooserButton); switchTextView = (ImageButton) v.findViewById(R.id.switchTextView); // isTablet = Compatibility.isTabletScreen(getActivity()); // Digits field setup isDigit = prefsWrapper.startIsDigit(); digits.setOnEditorActionListener(new OnEditorActionListener() { @Override/*from www . ja v a 2 s . c om*/ public boolean onEditorAction(TextView tv, int action, KeyEvent arg2) { if (action == EditorInfo.IME_ACTION_GO) { placeCall(); return true; } return false; } }); // Account chooser button setup accountChooserButton.setShowExternals(true); accountChooserButton.setOnAccountChangeListener(new OnAccountChangeListener() { @Override public void onChooseAccount(SipProfile account) { long accId = SipProfile.INVALID_ID; if (account != null) { accId = account.id; } autoCompleteAdapter.setSelectedAccount(accId); } }); // Dialpad dialPad.setOnDialKeyListener(this); // Auto complete list in case of text autoCompleteAdapter = new ContactsSearchAdapter(getActivity()); // We only need to add the autocomplete list if we DialerCallBar listCallBar = new DialerCallBar(getActivity(), null); listCallBar.setOnDialActionListener(this); autoCompleteList.addFooterView(listCallBar); autoCompleteList.setAdapter(autoCompleteAdapter); autoCompleteList.setOnItemClickListener(new OnAutoCompleteListItemClicked(autoCompleteAdapter)); // Bottom bar setup callBar.setOnDialActionListener(this); // Ensure that current mode (text/digit) is applied setTextDialing(!isDigit); // Init other buttons initButtons(v); // Apply third party theme if any applyTheme(); v.setOnKeyListener(this); return v; }
From source file:com.google.android.apps.forscience.whistlepunk.project.ProjectTabsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Resources res = getResources(); View view = inflater.inflate(R.layout.fragment_project_list, container, false); mEmptyView = (TextView) view.findViewById(R.id.empty); mEmptyView.setText(res.getString(R.string.empty_project_library)); mEmptyView.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, null, res.getDrawable(R.drawable.empty_project)); mRecyclerView = (RecyclerView) view.findViewById(R.id.projects_list); mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false)); mRecyclerView.setItemAnimator(new DefaultItemAnimator() { private void setAlpha(RecyclerView.ViewHolder item) { // The default item animator messes with the alpha, so we need to reset the alpha. ProjectAdapter.CardViewHolder holder = (ProjectAdapter.CardViewHolder) item; holder.itemView.setAlpha(holder.itemView.getResources() .getFraction(holder.archivedIndicator.getVisibility() == View.VISIBLE ? R.fraction.metadata_card_archived_alpha : R.fraction.metadata_card_alpha, 1, 1)); }// w ww .ja v a 2 s . c o m @Override public void onAddFinished(RecyclerView.ViewHolder item) { setAlpha(item); } @Override public void onChangeFinished(RecyclerView.ViewHolder item, boolean oldItem) { setAlpha(item); } }); mAdapter = new ProjectAdapter(); mRecyclerView.setAdapter(mAdapter); if (savedInstanceState != null) { mIncludeArchived = savedInstanceState.getBoolean(EXTRA_INCLUDE_ARCHIVED, false); } FloatingActionButton createProjectBtn = (FloatingActionButton) view .findViewById(R.id.create_project_button); createProjectBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { getDataController().createProject(new LoggingConsumer<Project>(TAG, "Create project") { @Override public void success(Project project) { UpdateProjectActivity.launch(getActivity(), project.getProjectId(), true /* new project */); } }); } }); return view; }
From source file:com.ovrhere.android.currencyconverter.ui.fragments.MainFragment.java
/** Updates source views to match source currency. */ private void updateSourceCurrency() { if (sp_sourceCurr == null || tv_warning == null || tv_currSymbol == null || img_currFlag == null || getActivity() == null) {/*from w ww. j a va 2 s . c o m*/ return; //nothing can be set. } int position = sp_sourceCurr.getSelectedItemPosition(); if (position < 0 || sourceCurrAdapter.getCount() < 1) { return; //nothing to show yet. } CurrencyData data = null; try { data = sourceCurrAdapter.getItem(position); } catch (IndexOutOfBoundsException e) { Log.w(LOGTAG, "Index out:" + position); } if (data == null) { Log.w(LOGTAG, "Irregular behaviour skipping update."); return; } Resources r = getActivity().getResources(); checkTimestampWarning(data); tv_currSymbol.setText(data.getCurrencySymbol()); int flagId = data.getFlagResource(); if (flagId >= 0) { img_currFlag.setImageDrawable(r.getDrawable(flagId)); } }