Java Code Examples for androidx.appcompat.widget.AppCompatImageView#setImageDrawable()

The following examples show how to use androidx.appcompat.widget.AppCompatImageView#setImageDrawable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExchangeSpinnerAdapter.java    From guarda-android-wallets with GNU General Public License v3.0 6 votes vote down vote up
@Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        view = inflater.inflate(R.layout.spinner_item, null);

        try {
            AppCompatImageView icon = view.findViewById(R.id.imageView);
//            icon.setImageDrawable(rows.get(i).icon);
            TextView name = (TextView) view.findViewById(R.id.textView);
            name.setText(rows.get(i).text);
            if (rows.get(i).url != null && !rows.get(i).url.equalsIgnoreCase("")) {
                Picasso
                        .with(inflater.getContext())
                        .load(rows.get(i).url)
                        .placeholder(R.drawable.ic_curr_empty)
                        .error(R.drawable.ic_curr_empty)
                        .into(icon);
            } else {
                icon.setImageDrawable(rows.get(i).icon);
            }
        } catch (IndexOutOfBoundsException iobe) {
            iobe.printStackTrace();
        }

        return view;
    }
 
Example 2
Source File: MinimalIconDialog.java    From GeometricWeather with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void initWidget(View view) {
    if (getActivity() == null) {
        return;
    }

    AppCompatImageView xmlIcon = view.findViewById(R.id.dialog_minimal_icon_xmlIcon);
    xmlIcon.setImageDrawable(xmlIconDrawable);

    TextView titleView = view.findViewById(R.id.dialog_minimal_icon_title);
    titleView.setText(title);

    AppCompatImageView lightIconView = view.findViewById(R.id.dialog_minimal_icon_lightIcon);
    lightIconView.setImageDrawable(lightDrawable);

    AppCompatImageView greyIconView = view.findViewById(R.id.dialog_minimal_icon_greyIcon);
    greyIconView.setImageDrawable(greyDrawable);

    AppCompatImageView darkIconView = view.findViewById(R.id.dialog_minimal_icon_darkIcon);
    darkIconView.setImageDrawable(darkDrawable);
}
 
Example 3
Source File: MainActivity.java    From SmartFlasher with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    // Initialize App Theme & FaceBook Ads
    Utils.initializeAppTheme(this);
    Utils.getInstance().initializeFaceBookAds(this);
    super.onCreate(savedInstanceState);
    // Set App Language
    Utils.setLanguage(this);
    setContentView(R.layout.activity_main);

    AppCompatImageView unsupported = findViewById(R.id.no_root_Image);
    TextView textView = findViewById(R.id.no_root_Text);
    TabLayout tabLayout = findViewById(R.id.tabLayoutID);
    mViewPager = findViewById(R.id.viewPagerID);

    if (!RootUtils.rootAccess()) {
        textView.setText(getString(R.string.no_root));
        unsupported.setImageDrawable(Utils.getColoredIcon(R.drawable.ic_help, this));
        return;
    }

    PagerAdapter adapter = new PagerAdapter(getSupportFragmentManager());
    adapter.AddFragment(new FlasherFragment(), getString(R.string.flasher));
    adapter.AddFragment(new BackupFragment(), getString(R.string.backup));
    adapter.AddFragment(new AboutFragment(), getString(R.string.about));

    mViewPager.setAdapter(adapter);
    tabLayout.setupWithViewPager(mViewPager);
}
 
Example 4
Source File: AppCompat.java    From HaoReader with GNU General Public License v3.0 5 votes vote down vote up
public static void useSimpleStyleForSearchView(SearchView searchView, String hint){
    AppCompatImageView search = searchView.findViewById(androidx.appcompat.R.id.search_mag_icon);
    search.setImageDrawable(null);
    LinearLayout plate = searchView.findViewById(R.id.search_plate);
    plate.setBackground(null);
    AppCompatImageView close = searchView.findViewById(R.id.search_close_btn);
    AppCompat.setTint(close, searchView.getResources().getColor(R.color.colorBarText));
    SearchView.SearchAutoComplete searchAutoComplete = searchView.findViewById(R.id.search_src_text);
    searchAutoComplete.setHint(hint);
}
 
Example 5
Source File: RatingBar.java    From Kore with Apache License 2.0 5 votes vote down vote up
private FrameLayout createStar(Context context, AttributeSet attrs, int defStyle) {
    FrameLayout frameLayout = new FrameLayout(getContext());
    frameLayout.setLayoutParams(new LayoutParams(WRAP_CONTENT, MATCH_PARENT));

    AppCompatImageView ivStarBackground = new AppCompatImageView(context, attrs, defStyle);
    ivStarBackground.setLayoutParams(new LayoutParams(WRAP_CONTENT, MATCH_PARENT));
    ivStarBackground.setImageResource(iconResourceId);
    ivStarBackground.setAdjustViewBounds(true);
    ImageViewCompat.setImageTintList(ivStarBackground, ColorStateList.valueOf(backgroundColor));
    frameLayout.addView(ivStarBackground);

    ClipDrawable clipDrawable = new ClipDrawable(
            ContextCompat.getDrawable(context, iconResourceId),
            Gravity.START,
            ClipDrawable.HORIZONTAL);

    AppCompatImageView ivStarForeground = new AppCompatImageView(context, attrs, defStyle);
    ivStarForeground.setLayoutParams(new LayoutParams(WRAP_CONTENT, MATCH_PARENT));
    ivStarForeground.setImageDrawable(clipDrawable);
    ivStarForeground.setAdjustViewBounds(true);
    ImageViewCompat.setImageTintList(ivStarForeground, ColorStateList.valueOf(foregroundColor));
    frameLayout.addView(ivStarForeground);

    clipDrawables.add((ClipDrawable) ivStarForeground.getDrawable());

    return frameLayout;
}
 
Example 6
Source File: TopicInfoFragment.java    From tindroid with Apache License 2.0 4 votes vote down vote up
private void notifyContentChanged() {

        final Activity activity = getActivity();
        if (activity == null || activity.isFinishing() || activity.isDestroyed()) {
            return;
        }

        final AppCompatImageView avatar = activity.findViewById(R.id.imageAvatar);
        final TextView title = activity.findViewById(R.id.topicTitle);
        final TextView subtitle = activity.findViewById(R.id.topicSubtitle);

        VxCard pub = mTopic.getPub();
        if (pub != null && !TextUtils.isEmpty(pub.fn)) {
            title.setText(pub.fn);
            title.setTypeface(null, Typeface.NORMAL);
            title.setTextIsSelectable(true);
        } else {
            title.setText(R.string.placeholder_contact_title);
            title.setTypeface(null, Typeface.ITALIC);
            title.setTextIsSelectable(false);
        }

        final Bitmap bmp = pub != null ? pub.getBitmap() : null;
        if (bmp != null) {
            avatar.setImageDrawable(new RoundImageDrawable(getResources(), bmp));
        } else {
            avatar.setImageDrawable(
                    new LetterTileDrawable(requireContext())
                            .setIsCircular(true)
                            .setContactTypeAndColor(
                                    mTopic.getTopicType() == Topic.TopicType.P2P ?
                                            LetterTileDrawable.ContactType.PERSON :
                                            LetterTileDrawable.ContactType.GROUP)
                            .setLetterAndColor(pub != null ? pub.fn : null, mTopic.getName()));
        }

        PrivateType priv = mTopic.getPriv();
        if (priv != null && !TextUtils.isEmpty(priv.getComment())) {
            subtitle.setText(priv.getComment());
            subtitle.setTypeface(null, Typeface.NORMAL);
            TypedValue typedValue = new TypedValue();
            Resources.Theme theme = getActivity().getTheme();
            theme.resolveAttribute(android.R.attr.textColorSecondary, typedValue, true);
            TypedArray arr = activity.obtainStyledAttributes(typedValue.data,
                    new int[]{android.R.attr.textColorSecondary});
            subtitle.setTextColor(arr.getColor(0, -1));
            arr.recycle();
            subtitle.setTextIsSelectable(true);
        } else {
            subtitle.setText(R.string.placeholder_private);
            subtitle.setTypeface(null, Typeface.ITALIC);
            subtitle.setTextColor(getResources().getColor(R.color.colorTextPlaceholder));
            subtitle.setTextIsSelectable(false);
        }

        ((Switch) activity.findViewById(R.id.switchMuted)).setChecked(mTopic.isMuted());
        ((Switch) activity.findViewById(R.id.switchArchived)).setChecked(mTopic.isArchived());

        Acs acs = mTopic.getAccessMode();
        ((TextView) activity.findViewById(R.id.permissionsSingle)).setText(acs == null ? "" : acs.getMode());
    }