List of usage examples for android.support.v4.graphics.drawable RoundedBitmapDrawableFactory create
public static RoundedBitmapDrawable create(Resources resources, InputStream inputStream)
From source file:com.stockita.stockitapointofsales.activities.SecondActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_second); // ButterKnife ButterKnife.bind(this); // Toolbar//from w w w . j av a 2 s .c o m setSupportActionBar(toolbar); // Set the fab to gone fab.setVisibility(View.GONE); // Navigation draw ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawerLayout.addDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); /** * The code below is about the nav_header */ View headerLayout = navigationView.getHeaderView(0); final ImageView imageView = (ImageView) headerLayout.findViewById(R.id.imageView); TextView name = (TextView) headerLayout.findViewById(R.id.textView1); TextView email = (TextView) headerLayout.findViewById(R.id.textView2); // Display user image in circular frame if (mPhotoUrl != null) { Glide.with(this).load("https://lh3.googleusercontent.com" + mPhotoUrl).asBitmap() .into(new BitmapImageViewTarget(imageView) { @Override protected void setResource(Bitmap resource) { super.setResource(resource); RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory .create(getResources(), resource); circularBitmapDrawable.setCircular(true); imageView.setImageDrawable(circularBitmapDrawable); } }); } // Display the user name and email on the nav_header name.setText(mUserName); email.setText(Utility.decodeEmail(mUserEncodedEmail)); /** * Create the adapter that will return a fragment for each of the * primary sections of the activity. */ mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager()); //Set up the ViewPager with the sections adapter. */ if (container != null) { container.setAdapter(mSectionsPagerAdapter); } /* Tab layout */ if (tabs != null) { tabs.setupWithViewPager(container); } /** * This is listener is to get the tab position, however it does an other think * but we are only interested for the current tab position */ if (tabs != null) { tabs.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { @Override public void onTabSelected(TabLayout.Tab tab) { /* First we invoke this method for mViewPager */ container.setCurrentItem(tab.getPosition()); /** * Then we can assign the value of the current position to * a static field, there are some other way to do this. */ sSelection = tab.getPosition(); } @Override public void onTabUnselected(TabLayout.Tab tab) { } @Override public void onTabReselected(TabLayout.Tab tab) { } }); } if (savedInstanceState != null) { mPaidSalesHeaderListFragmentUI = (PaidSalesHeaderListFragmentUI) getFragmentManager() .getFragment(savedInstanceState, KEY_ONE); mBarGraph = (BarGraph) getFragmentManager().getFragment(savedInstanceState, KEY_TWO); } }
From source file:org.chromium.chrome.browser.history.HistoryItemView.java
@Override public void onLargeIconAvailable(Bitmap icon, int fallbackColor, boolean isFallbackColorDefault) { // TODO(twellington): move this somewhere that can be shared with bookmarks. if (icon == null) { mIconGenerator.setBackgroundColor(fallbackColor); icon = mIconGenerator.generateIconForUrl(getItem().getUrl()); mIconImageView.setImageDrawable(new BitmapDrawable(getResources(), icon)); } else {/*from ww w .ja va 2s .c o m*/ RoundedBitmapDrawable roundedIcon = RoundedBitmapDrawableFactory.create(getResources(), Bitmap.createScaledBitmap(icon, mDisplayedIconSize, mDisplayedIconSize, false)); roundedIcon.setCornerRadius(mCornerRadius); mIconImageView.setImageDrawable(roundedIcon); } }
From source file:com.android.mms.ui.MessageListItem.java
public MessageListItem(Context context, AttributeSet attrs) { super(context, attrs); Resources res = context.getResources(); mColorSpan = new ForegroundColorSpan(res.getColor(R.color.timestamp_color)); mDefaultCountryIso = MmsApp.getApplication().getCurrentCountryIso(); if (sDefaultContactImage == null) { Bitmap defaultImage = BitmapFactory.decodeResource(res, R.drawable.ic_contact_picture); sDefaultContactImage = RoundedBitmapDrawableFactory.create(res, defaultImage); sDefaultContactImage.setAntiAlias(true); sDefaultContactImage/*from www . j a va 2s .c om*/ .setCornerRadius(Math.max(defaultImage.getWidth() / 2, defaultImage.getHeight() / 2)); } }
From source file:com.pengfei.fastopen.adapter.SettingAdapter.java
private void childUninstallApp(View convertView, final int groupPosition, final int childPosition, final SaveAppEntity child, TextView item) { item.setText(child.getName());/*from www . ja v a2s . c om*/ byte[] icon = child.getIcon(); if (icon != null) { Bitmap bitmap = ImageUtils.changeByteToBitmap(icon); Drawable drawable = RoundedBitmapDrawableFactory.create(context.getResources(), bitmap); drawable.setBounds(0, 0, 36, 36); item.setCompoundDrawables(drawable, null, null, null); } final String[] items = new String[] { "", "" }; convertView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DialogUtils.getItemsDialog(child.getName(), context, items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: IntentUtils.openApplicationMarket(context, child.getPackageName()); break; case 1: SaveAppDBManager.deleteApp(child.getPackageName()); list.get(groupPosition).childItems.remove(childPosition); notifyDataSetChanged(); list.get(groupPosition).updateName(); Toast.makeText(context, "?", Toast.LENGTH_SHORT).show(); break; } } }).create().show(); } }); }
From source file:arun.com.chromer.fragments.AboutFragment.java
private void populateData(View rootView) { ListView chromerList = (ListView) rootView.findViewById(R.id.about_app_version_list); ListView authorList = (ListView) rootView.findViewById(R.id.about_author_version_list); View daniel = rootView.findViewById(R.id.daniel); daniel.setOnClickListener(new View.OnClickListener() { @Override/*from ww w. java2s . c o m*/ public void onClick(View v) { Intent googleIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://plus.google.com/u/0/+DanielCiao/about")); getActivity().startActivity(googleIntent); } }); // Loading the header chromerList.setAdapter(new ExtendedBaseAdapter() { final Context context = getActivity().getApplicationContext(); @Override public int getCount() { return 4; } @Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater mInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); ViewHolder holder; if (convertView == null) { holder = new ViewHolder(); convertView = mInflater.inflate(R.layout.fragment_about_listview_template, parent, false); holder.imageView = (ImageView) convertView.findViewById(R.id.about_row_item_image); holder.subtitle = (TextView) convertView.findViewById(R.id.about_app_subtitle); holder.title = (TextView) convertView.findViewById(R.id.about_app_title); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } int materialdarkColor = ContextCompat.getColor(context, R.color.accent); holder.subtitle.setVisibility(View.VISIBLE); switch (position) { case 0: holder.title.setText(R.string.version); holder.subtitle.setText(Util.getPackageVersion(context)); holder.imageView.setBackground(new IconicsDrawable(context) .icon(GoogleMaterial.Icon.gmd_info_outline).color(materialdarkColor).sizeDp(24)); break; case 1: holder.title.setText(R.string.changelog); holder.subtitle.setVisibility(View.GONE); holder.imageView.setBackground(new IconicsDrawable(context) .icon(GoogleMaterial.Icon.gmd_track_changes).color(materialdarkColor).sizeDp(24)); break; case 2: holder.title.setText(R.string.join_google_plus); holder.subtitle.setText(R.string.share_ideas); holder.imageView.setBackground( new IconicsDrawable(context).icon(CommunityMaterial.Icon.cmd_google_circles_communities) .color(materialdarkColor).sizeDp(24)); break; case 3: holder.title.setText(R.string.licenses); holder.subtitle.setVisibility(View.GONE); holder.imageView.setBackground(new IconicsDrawable(context) .icon(GoogleMaterial.Icon.gmd_card_membership).color(materialdarkColor).sizeDp(24)); break; } return convertView; } }); authorList.setAdapter(new ExtendedBaseAdapter() { final Context context = getActivity().getApplicationContext(); @Override public int getCount() { return 5; } @Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater mInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final ViewHolder holder; if (convertView == null) { holder = new ViewHolder(); convertView = mInflater.inflate(R.layout.fragment_about_listview_template, parent, false); holder.imageView = (ImageView) convertView.findViewById(R.id.about_row_item_image); holder.subtitle = (TextView) convertView.findViewById(R.id.about_app_subtitle); holder.title = (TextView) convertView.findViewById(R.id.about_app_title); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } switch (position) { case 0: holder.title.setText(StringConstants.ME); holder.subtitle.setText(StringConstants.LOCATION); holder.imageView.getLayoutParams().height = (int) getResources() .getDimension(R.dimen.arun_height); holder.imageView.getLayoutParams().width = (int) getResources() .getDimension(R.dimen.arun_width); Bitmap imageBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.arun); RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory .create(getResources(), imageBitmap); roundedBitmapDrawable.setAntiAlias(true); roundedBitmapDrawable.setCircular(true); holder.imageView.setImageDrawable(roundedBitmapDrawable); break; case 1: holder.title.setText(R.string.add_to_circles); holder.subtitle.setVisibility(View.GONE); holder.imageView.setBackground( new IconicsDrawable(context).icon(CommunityMaterial.Icon.cmd_google_circles) .color(ContextCompat.getColor(getActivity(), R.color.google_plus)).sizeDp(24)); break; case 2: holder.title.setText(R.string.follow_twitter); holder.subtitle.setVisibility(View.GONE); holder.imageView .setBackground(new IconicsDrawable(context).icon(CommunityMaterial.Icon.cmd_twitter) .color(ContextCompat.getColor(getActivity(), R.color.twitter)).sizeDp(24)); break; case 3: holder.title.setText(R.string.connect_linkedIn); holder.subtitle.setVisibility(View.GONE); holder.imageView.setBackground( new IconicsDrawable(context).icon(CommunityMaterial.Icon.cmd_linkedin_box) .color(ContextCompat.getColor(getActivity(), R.color.linkedin)).sizeDp(24)); break; case 4: holder.title.setText(R.string.more_apps); holder.subtitle.setVisibility(View.GONE); holder.imageView.setBackground(new IconicsDrawable(context) .icon(CommunityMaterial.Icon.cmd_google_play) .color(ContextCompat.getColor(getActivity(), R.color.playstore_green)).sizeDp(24)); break; } return convertView; } }); chromerList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: return; case 1: ChangelogUtil.showChangelogDialog(getActivity()); break; case 2: Intent googleIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://plus.google.com/communities/109754631011301174504")); getActivity().startActivity(googleIntent); break; case 3: new LicensesDialog.Builder(getActivity()).setNotices(Licenses.getNotices()) .setTitle(R.string.licenses).build().showAppCompat(); break; } } }); authorList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: return; case 1: Intent googleIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://google.com/+arunkumar5592")); getActivity().startActivity(googleIntent); break; case 2: Intent twitterIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://twitter.com/arunkumar_9t2")); getActivity().startActivity(twitterIntent); break; case 3: Intent linkedinIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://in.linkedin.com/in/arunkumar9t2")); getActivity().startActivity(linkedinIntent); break; case 4: try { getActivity().startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pub:Arunkumar"))); } catch (android.content.ActivityNotFoundException anfe) { getActivity().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/search?q=pub:Arunkumar"))); } break; } } }); }
From source file:me.trashout.fragment.ProfileEditFragment.java
private void setupUserProfile(User user) { if (user.getImage() != null && !TextUtils.isEmpty(user.getImage().getFullStorageLocation())) { StorageReference mImageRef = FirebaseStorage.getInstance() .getReferenceFromUrl(user.getImage().getFullStorageLocation()); GlideApp.with(this).asBitmap().load(mImageRef).placeholder(R.drawable.ic_image_placeholder_rectangle) .into(new BitmapImageViewTarget(profileEditImage) { @Override//w ww. j ava2s.c om public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory .create(getActivity().getResources(), resource); circularBitmapDrawable.setCircular(true); profileEditImage.setImageDrawable(circularBitmapDrawable); } }); } profileEditFirstName.setText(user.getFirstName()); profileEditLastName.setText(user.getLastName()); profileEditEmail.setText(user.getEmail()); profileEditPhone.setText(user.getPhoneNumber()); // post da profileEditOrganizations.postDelayed(new Runnable() { @Override public void run() { if (mSelectedOrganizations != null && !mSelectedOrganizations.isEmpty()) { StringBuilder orgText = new StringBuilder(); for (Organization organization : mSelectedOrganizations) { orgText.append(organization.getName()).append(", "); } profileEditOrganizations.setText(orgText.toString().substring(0, orgText.length() - 2)); } else { profileEditOrganizations.setText(""); } } }, 100); profileEditCleaningActionNotificationCheckbox.setChecked(user.isVolunteerCleanup()); profileEditOrganizeCleaningActionCheckbox.setChecked(user.isEventOrganizer()); profileEditGpsFormatDegrees .setChecked(PreferencesHandler.getUserPreferredLocationFormat(getContext()) == 0); profileEditGpsFormatDms.setChecked(PreferencesHandler.getUserPreferredLocationFormat(getContext()) == 1); }
From source file:com.qhn.bhne.xhmusic.utils.MyUtils.java
public static void setCircleIMG(final Activity activity, Object resImageId, final ImageView userPhoto) { if (resImageId instanceof String && TextUtils.isEmpty((String) resImageId)) { Toast.makeText(activity, "?", Toast.LENGTH_SHORT).show(); return;//from w ww .ja va2s. c o m } if (resImageId instanceof Integer && (Integer) resImageId == 0) { Toast.makeText(activity, "?", Toast.LENGTH_SHORT).show(); return; } if (userPhoto == null) { Toast.makeText(activity, "", Toast.LENGTH_SHORT).show(); return; } Glide.with(activity).load(resImageId).asBitmap().placeholder(R.drawable.ic_placeholder).centerCrop() .into(new BitmapImageViewTarget(userPhoto) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory .create(activity.getResources(), resource); //circularBitmapDrawable.setCircular(true); circularBitmapDrawable.setCornerRadius(2); userPhoto.setImageDrawable(circularBitmapDrawable); } }); }
From source file:com.tr4android.support.extension.widget.CircleImageView.java
/** * Helper for creating a circle bitmap drawable using the {@link android.support.v4.graphics.drawable.RoundedBitmapDrawable} * * @param bitmap The bitmap which should be converted to a circle bitmap drawable * @return the {@link android.support.v4.graphics.drawable.RoundedBitmapDrawable} containing the bitmap *///from www.j a va2 s . c o m public static RoundedBitmapDrawable getCircleBitmapDrawable(Context context, Bitmap bitmap) { RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(context.getResources(), bitmap); drawable.setCornerRadius(Math.max(bitmap.getWidth() / 2, bitmap.getHeight() / 2)); drawable.setAntiAlias(true); return drawable; }
From source file:es.esy.vivekrajendran.news.MainActivity.java
/** * mehod to initialize the firebaseauth and authstatelistener object *//*from w w w. j a v a2 s . c om*/ private void initListener() { mFirebaseAuth = FirebaseAuth.getInstance(); mAuthStateListener = new FirebaseAuth.AuthStateListener() { @Override public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { FirebaseUser mUser = firebaseAuth.getCurrentUser(); if (mUser == null) { Intent intent = new Intent(MainActivity.this, SplashActivity.class); intent.putExtra("show_image", true); startActivity(intent); } else { //Setting up user profile in drawer layout View header = navigationView.getHeaderView(0); final ImageView profPic = (ImageView) header.findViewById(R.id.header_imageView); TextView name = (TextView) header.findViewById(R.id.header_name); TextView email = (TextView) header.findViewById(R.id.header_email); Glide.with(getApplicationContext()).load(mUser.getPhotoUrl()).asBitmap().centerCrop() .placeholder(R.drawable.ic_account_circle_black_24px) .into(new BitmapImageViewTarget(profPic) { @Override protected void setResource(Bitmap resource) { RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory .create(getApplicationContext().getResources(), resource); circularBitmapDrawable.setCircular(true); profPic.setImageDrawable(circularBitmapDrawable); } }); name.setText(mUser.getDisplayName()); email.setText(mUser.getEmail()); } } }; }
From source file:io.github.protino.codewatch.ui.ProfileActivity.java
private void bindViews() { Glide.with(this).load(profileItem.getPhotoUrl()).asBitmap() .placeholder(R.drawable.ic_account_circle_white_24dp).into(new BitmapImageViewTarget(avatar) { @Override/*from w w w .j a va2 s .c o m*/ protected void setResource(Bitmap resource) { RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(getResources(), resource); drawable.setCircular(true); avatar.setImageDrawable(drawable); } }); userName.setText(profileItem.getName()); collapsingToolbarLayout.setTitle(profileItem.getName()); rank.setText(String.valueOf(profileItem.getRank())); website.setText(profileItem.getWebsite()); Linkify.addLinks(website, Linkify.WEB_URLS); removeViewIfNoData(website); email.setText(profileItem.getEmail()); Linkify.addLinks(email, Linkify.EMAIL_ADDRESSES); removeViewIfNoData(email); location.setText(profileItem.getLocation()); removeViewIfNoData(location); dailyAverage.setText(getString(R.string.daily_average_format, FormatUtils.getFormattedTime(this, profileItem.getDailyAverage()))); JSONObject languageMap; try { languageMap = new JSONObject(profileItem.getLanguageStats()); Iterator<?> keys = languageMap.keys(); while (keys.hasNext()) { String key = (String) keys.next(); languageList.add(new Pair<>(key, languageMap.getInt(key))); } } catch (JSONException e) { Timber.e(e); } languageAdapter.swapData(languageList); }