Example usage for android.widget ImageView setColorFilter

List of usage examples for android.widget ImageView setColorFilter

Introduction

In this page you can find the example usage for android.widget ImageView setColorFilter.

Prototype

public final void setColorFilter(int color, PorterDuff.Mode mode) 

Source Link

Document

Sets a tinting option for the image.

Usage

From source file:de.mdxdave.materialbreadcrumbsnavigation.MaterialBreadcrumbsNavigation.java

private void addItem(final NavigationItem item, int position, boolean isRoot, boolean setActive) {
    LayoutInflater vi = (LayoutInflater) context.getApplicationContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = vi.inflate(R.layout.item_view, null);

    int last;/*from   w w w .java 2  s.c  om*/
    if (isRoot) {
        last = 0;
        list.add(item);
    } else if (position == -1) {
        last = viewGroup.getChildCount();
        last = (last < 0) ? 0 : last;
        list.add(item);
    } else {
        last = position;
        list.set(position, item);
    }

    final TextView textView = (TextView) v.findViewById(R.id.breadcrumbnav_textView);
    textView.setTextColor(darkenColor(textColor));
    textView.setText(item.getTitle().toUpperCase());

    item.setId(last);

    final int finalLast = last;
    textView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            setActive(finalLast, false, true);
        }
    });

    ImageView imageView = (ImageView) v.findViewById(R.id.breadcrumbnav_imageView);
    imageView.setColorFilter(indicatorColor, PorterDuff.Mode.MULTIPLY);

    // Padding and root item
    if (isRoot) {
        imageView.setVisibility(View.GONE);
        int padding_left = 48;
        int padding_right = 12;
        int padding = 18;
        final float scale = getResources().getDisplayMetrics().density;
        int padding_left_px = (int) (padding_left * scale + 0.5f);
        int padding_right_px = (int) (padding_right * scale + 0.5f);
        int padding_px = (int) (padding * scale + 0.5f);
        textView.setPadding(padding_left_px, padding_px, padding_right_px, padding_px);
    }

    // Scroll to end

    final int finalLast1 = last;
    horizontalScrollView.post(new Runnable() {
        @Override
        public void run() {
            if (finalLast1 == viewGroup.getChildCount())
                horizontalScrollView.fullScroll(HorizontalScrollView.FOCUS_RIGHT);
        }
    });

    viewGroup.addView(v, last, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    if (setActive || getCurrent() == position || list.size() == 0)
        setActive(last, true);
}

From source file:org.mariotaku.twidere.util.ThemeUtils.java

public static void setActionBarContextViewColor(@NonNull ActionBarContextView contextView, int itemColor) {
    contextView.setTitle(contextView.getTitle());
    contextView.setSubtitle(contextView.getSubtitle());
    final ImageView actionModeCloseButton = (ImageView) contextView
            .findViewById(android.support.v7.appcompat.R.id.action_mode_close_button);
    final ActionMenuView menuView = ViewSupport.findViewByType(contextView, ActionMenuView.class);
    if (actionModeCloseButton != null) {
        actionModeCloseButton.setColorFilter(itemColor, Mode.SRC_ATOP);
    }/*from w ww  .  j  a  v  a  2s. c om*/
    if (menuView != null) {
        setActionBarOverflowColor(menuView, itemColor);
        ThemeUtils.wrapToolbarMenuIcon(menuView, itemColor, itemColor);
    }
}

From source file:info.papdt.blacklight.ui.statuses.SingleActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    mLayout = R.layout.single;/*  w  w w .j a  v a  2  s  .  com*/
    super.onCreate(savedInstanceState);

    mActionBarColor = Utility.getColorPrimary(this);
    mDragBackgroundColor = Utility.getDragBackground(this);
    mGray = getResources().getColor(R.color.action_gray);
    mWhite = getResources().getColor(R.color.white);
    mDark = Utility.isDarkMode(this);

    // Arguments
    mMsg = getIntent().getParcelableExtra("msg");
    mMsg.inSingleActivity = true;
    mFavourited = mMsg.favorited;
    mLiked = mMsg.liked;
    if (mMsg.user != null && mMsg.user.id != null) {
        mIsMine = new LoginApiCache(this).getUid().equals(mMsg.user.id);
    }

    // Initialize views
    mPager = Utility.findViewById(this, R.id.single_pager);
    mRoot = Utility.findViewById(this, R.id.single_root);
    mDragger = Utility.findViewById(this, R.id.single_dragger);
    mContent = Utility.findViewById(this, R.id.single_content);
    mIndicator = Utility.findViewById(this, R.id.single_indicator);
    mCollapse = Utility.findViewById(this, R.id.iv_collapse);
    mIcons[0] = Utility.findViewById(this, R.id.single_comment_img);
    mIcons[1] = Utility.findViewById(this, R.id.single_repost_img);

    View comment = Utility.findViewById(this, R.id.single_comment);
    View repost = Utility.findViewById(this, R.id.single_repost);

    if (Build.VERSION.SDK_INT >= 21) {
        mDragger.setElevation(getToolbarElevation());
    }

    // Bind onClick events
    Utility.bindOnClick(this, comment, "commentOn");
    Utility.bindOnClick(this, repost, "repost");

    // Dark
    if (mDark) {
        for (ImageView v : mIcons) {
            v.setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_IN);
        }
    }

    mMsgFragment = new HackyFragment();
    Bundle b = new Bundle();
    b.putParcelable("msg", mMsg);
    mMsgFragment.setArguments(b);

    mCommentFragment = new StatusCommentFragment(mMsg.id);
    mRepostFragment = new RepostTimeLineFragment(mMsg.id);
    getFragmentManager().beginTransaction().replace(R.id.single_content, mMsgFragment).commit();
    ViewCompat.setTransitionName(findViewById(R.id.single_content), "msg");

    mPager.setAdapter(new FragmentStatePagerAdapter(getFragmentManager()) {
        @Override
        public int getCount() {
            return 2;
        }

        @Override
        public Fragment getItem(int position) {
            switch (position) {
            case 0:
                return mCommentFragment;
            case 1:
                return mRepostFragment;
            default:
                return null;
            }
        }

        @Override
        public CharSequence getPageTitle(int position) {
            switch (position) {
            case 0:
                return getResources().getString(R.string.comment) + " "
                        + Utility.addUnitToInt(SingleActivity.this, mMsg.comments_count);
            case 1:
                return getResources().getString(R.string.retweet) + " "
                        + Utility.addUnitToInt(SingleActivity.this, mMsg.reposts_count);
            default:
                return "";
            }
        }
    });

    mRoot.setPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() {

        @Override
        public void onPanelSlide(View panel, float slideOffset) {
            //Utility.setActionBarTranslation(SingleActivity.this, mRoot.getCurrentParalaxOffset());

            // Gradient color if in light mode
            //if (!mDark) {

            if (Build.VERSION.SDK_INT >= 21) {
                getToolbar().setElevation(slideOffset * 12.8f);
            }

            float gradientFactor = 1 - slideOffset;
            mDragger.setBackgroundColor(
                    Utility.getGradientColor(mDragBackgroundColor, mActionBarColor, gradientFactor));
            mColorizer.setBlendColor(Utility.getGradientColor(mGray, mActionBarColor, gradientFactor));
            mIndicator.notifyIndicatorColorChanged();
            if (!mDark) {
                mIndicatorColor = Utility.getGradientColor(mGray, mWhite, gradientFactor);
                mCollapse.setColorFilter(Utility.getGradientColor(mGray, mDragBackgroundColor, gradientFactor),
                        PorterDuff.Mode.SRC_IN);
            }
            //}

            mCollapse.setRotation((1 - slideOffset) * -180);
        }

        @Override
        public void onPanelCollapsed(View panel) {
        }

        @Override
        public void onPanelExpanded(View panel) {
        }

        @Override
        public void onPanelAnchored(View panel) {

        }

    });

    // Indicator
    mIndicatorColor = mDark ? mWhite : mGray;

    mColorizer.setBlendColor(mGray);
    mIndicator.setViewPager(mPager);

    mIndicator.setCustomTabColorizer(mColorizer);
    mIndicator.notifyIndicatorColorChanged();
}

From source file:com.davisosa.structura.activities.base.BaseActivity.java

private void formatDrawerItem(View view, int itemId, boolean selected) {
    if (isSeparator(itemId)) {
        return; // N/A
    }// www .j a va2s .  c  o  m

    ImageView iconView = (ImageView) view.findViewById(R.id.icon);
    TextView titleView = (TextView) view.findViewById(R.id.title);

    if (selected) {
        view.setBackgroundResource(R.drawable.drawer_item_bg_selected);
    }

    // Configure its appearance according to whether or not it's selected.
    Resources res = getResources();
    titleView.setTextColor(selected ? res.getColor(R.color.drawer_text_color_selected)
            : res.getColor(R.color.drawer_text_color));
    iconView.setColorFilter(
            selected ? res.getColor(R.color.drawer_icon_tint_selected) : res.getColor(R.color.drawer_icon_tint),
            PorterDuff.Mode.SRC_IN);
}

From source file:com.appteam.nimbus.activity.homeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    personalData = new PersonalData(this);
    if (personalData.getStatus() == false) {
        Intent i = new Intent(homeActivity.this, Login.class);
        i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(i);/*from w w  w .j  a  v  a  2 s. com*/
        finish();
    }

    setContentView(R.layout.activity_home);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    ImageView icon1 = (ImageView) findViewById(R.id.icon1);
    ImageView arrow1 = (ImageView) findViewById(R.id.arrow1);
    ImageView icon2 = (ImageView) findViewById(R.id.icon2);
    ImageView arrow2 = (ImageView) findViewById(R.id.arrow2);
    ImageView icon3 = (ImageView) findViewById(R.id.icon3);
    ImageView arrow3 = (ImageView) findViewById(R.id.arrow3);
    ImageView icon4 = (ImageView) findViewById(R.id.icon4);
    ImageView arrow4 = (ImageView) findViewById(R.id.arrow4);
    ImageView icon5 = (ImageView) findViewById(R.id.icon5);
    ImageView arrow5 = (ImageView) findViewById(R.id.arrow5);

    final int newColor = getResources().getColor(R.color.new_color);
    icon1.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP);
    arrow1.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP);
    icon2.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP);
    arrow2.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP);
    icon3.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP);
    arrow3.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP);
    icon4.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP);
    arrow4.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP);
    icon5.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP);
    arrow5.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);

    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    findViewById(R.id.department).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            startActivity(new Intent(homeActivity.this, DepartmentalTeam.class));
            overridePendingTransition(R.anim.open_next, R.anim.open_main);
        }
    });

    findViewById(R.id.coreteam).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            startActivity(new Intent(homeActivity.this, CoreTeamActivity.class));
            overridePendingTransition(R.anim.open_next, R.anim.open_main);
        }
    });

    findViewById(R.id.event).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            startActivity(new Intent(homeActivity.this, EventActivity.class));
            overridePendingTransition(R.anim.open_next, R.anim.open_main);
        }
    });
    findViewById(R.id.welcome).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(homeActivity.this, AboutNimbusSplash.class);
            intent.putExtra(ABOUT_NIMBUS, "rule");
            startActivity(intent);
        }
    });
    findViewById(R.id.sponsors).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            startActivity(new Intent(homeActivity.this, SponserActivity.class));
            overridePendingTransition(R.anim.open_next, R.anim.open_main);
        }
    });
}

From source file:com.geecko.QuickLyric.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    IMMLeaks.fixFocusedViewLeak(getApplication());
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    int[] themes = new int[] { R.style.Theme_QuickLyric, R.style.Theme_QuickLyric_Red,
            R.style.Theme_QuickLyric_Purple, R.style.Theme_QuickLyric_Indigo, R.style.Theme_QuickLyric_Green,
            R.style.Theme_QuickLyric_Lime, R.style.Theme_QuickLyric_Brown, R.style.Theme_QuickLyric_Dark };
    themeNum = Integer.valueOf(sharedPref.getString("pref_theme", "0"));
    boolean nightMode = sharedPref.getBoolean("pref_night_mode", false);
    if (nightMode && NightTimeVerifier.check(this))
        setTheme(R.style.Theme_QuickLyric_Night);
    else/*  w  w w. ja  v a  2  s .c  o  m*/
        setTheme(themes[themeNum]);
    super.onCreate(savedInstanceState);
    setStatusBarColor(null);
    setNavBarColor(null);
    final FragmentManager fragmentManager = getFragmentManager();
    setContentView(layout.nav_drawer_activity);
    setSupportActionBar((android.support.v7.widget.Toolbar) findViewById(id.toolbar));
    getSupportActionBar().setDisplayShowTitleEnabled(true);
    getSupportActionBar().setTitle(string.app_name);

    AppBarLayout appBarLayout = (AppBarLayout) findViewById(id.appbar);
    appBarLayout.addOnOffsetChangedListener(this);

    /** Drawer setup */
    final ListView drawerList = (ListView) findViewById(id.drawer_list);
    DrawerAdapter drawerAdapter = new DrawerAdapter(this, this.getResources().getStringArray(array.nav_items));
    drawerList.setAdapter(drawerAdapter);
    drawerView = this.findViewById(id.left_drawer);
    drawer = this.findViewById(id.drawer_layout);
    if (drawer instanceof DrawerLayout) { // if phone
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        mDrawerToggle = new ActionBarDrawerToggle(this, (DrawerLayout) drawer, string.drawer_open_desc,
                string.drawer_closed_desc) {

            /**
             * Called when a drawer has settled in a completely open state.
             */
            public void onDrawerOpened(View drawerView) {
                focusOnFragment = false;
                if (mActionMode != null)
                    mActionMode.finish();
                MainActivity.this.invalidateOptionsMenu(); // onPrepareOptionsMenu()
            }

            /**
             * Called when a drawer has settled in a completely closed state.
             */
            public void onDrawerClosed(View view) {
                focusOnFragment = true;
                if (selectedRow != -1)
                    selectItem(selectedRow);
                MainActivity.this.selectedRow = -1;
                MainActivity.this.invalidateOptionsMenu(); // onPrepareOptionsMenu()
            }
        };
        Resources.Theme theme = getTheme();
        TypedValue darkColorValue = new TypedValue();
        TypedValue primaryColorValue = new TypedValue();
        theme.resolveAttribute(R.attr.colorPrimaryDark, darkColorValue, true);
        theme.resolveAttribute(R.attr.colorPrimary, primaryColorValue, true);
        ((DrawerLayout) drawer).addDrawerListener(mDrawerToggle);
        ((DrawerLayout) drawer).setStatusBarBackground(null);

        if (themeNum > 0 && themeNum != 7) { // Is not Amber or Dark
            final ImageView drawerHeader = (ImageView) findViewById(id.drawer_header);
            drawerHeader.setColorFilter(darkColorValue.data, PorterDuff.Mode.OVERLAY);
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription(null, null,
                    primaryColorValue.data);
            this.setTaskDescription(taskDescription);
        }
    }

    drawerListener = new DrawerItemClickListener();
    drawerList.setOnItemClickListener(drawerListener);

    Intent intent = getIntent();
    String extra = intent.getStringExtra(Intent.EXTRA_TEXT);
    Lyrics receivedLyrics = getBeamedLyrics(intent);
    if (receivedLyrics != null) {
        updateLyricsFragment(0, 0, false, receivedLyrics);
    } else {
        String s = intent.getAction();
        if ("com.geecko.QuickLyric.getLyrics".equals(s) && intent.getStringArrayExtra("TAGS") != null) {
            String[] metadata = intent.getStringArrayExtra("TAGS");
            String artist = metadata[0];
            String track = metadata[1];
            updateLyricsFragment(0, artist, track);
        } else if ("android.intent.action.SEND".equals(s)) {
            new IdDecoder(this, init(fragmentManager, true)).execute(getIdUrl(extra));
        } else
            init(fragmentManager, false);
    }
    boolean seenIntro = getSharedPreferences("intro_slides", Context.MODE_PRIVATE).getBoolean("seen", false);
    if (!seenIntro) {
        registerTempReceiver();
        setupDemoScreen();
    }

    SharedPreferences updatePrefs = getSharedPreferences("update_tracker", Context.MODE_PRIVATE);
    int versionCode = updatePrefs.getInt("VERSION_CODE",
            seenIntro ? BuildConfig.VERSION_CODE - 1 : BuildConfig.VERSION_CODE);
    updatePrefs.edit().putInt("VERSION_CODE", BuildConfig.VERSION_CODE).apply();
    if (versionCode < BuildConfig.VERSION_CODE)
        onAppUpdated(versionCode);
}

From source file:com.waz.zclient.newreg.fragments.FirstTimeAssignUsernameFragment.java

@Nullable
@Override/*  w  ww . java 2s  .  c o m*/
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_username_first_launch, container, false);
    nameTextView = ViewUtils.getView(view, R.id.ttv__name);
    usernameTextView = ViewUtils.getView(view, R.id.ttv__username);
    backgroundImageView = ViewUtils.getView(view, R.id.iaiv__user_photo);
    final ImageView vignetteOverlay = ViewUtils.getView(view, R.id.iv_background_vignette_overlay);
    ZetaButton chooseYourOwnButton = ViewUtils.getView(view, R.id.zb__username_first_assign__choose);
    ZetaButton keepButton = ViewUtils.getView(view, R.id.zb__username_first_assign__keep);
    TypefaceTextView summaryTextView = ViewUtils.getView(view, R.id.ttv__username_first_assign__summary);
    AccentColor accentColor = getControllerFactory().getAccentColorController().getAccentColor();
    final int color = accentColor != null ? accentColor.getColor() : Color.TRANSPARENT;
    final int darkenColor = ColorUtils.injectAlpha(
            ResourceUtils.getResourceFloat(getResources(), R.dimen.background_solid_black_overlay_opacity),
            Color.BLACK);

    backgroundImageView.setDisplayType(ImageAssetImageView.DisplayType.REGULAR);

    vignetteOverlay.setImageBitmap(BitmapUtils.getVignetteBitmap(getResources()));
    vignetteOverlay.setColorFilter(darkenColor, PorterDuff.Mode.DARKEN);

    selfModelObserver.setAndUpdate(getStoreFactory().getZMessagingApiStore().getApi().getSelf());

    chooseYourOwnButton.setIsFilled(true);
    chooseYourOwnButton.setAccentColor(color);
    chooseYourOwnButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            getContainer().onChooseUsernameChosen();
        }
    });

    suggestedUsername = getArguments().getString(ARG_SUGGESTED_USERNAME, "");
    keepButton.setIsFilled(false);
    keepButton.setAccentColor(color);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
        //noinspection deprecation
        keepButton.setTextColor(getResources().getColor(R.color.white));
    } else {
        keepButton.setTextColor(getResources().getColor(R.color.white, getContext().getTheme()));
    }
    keepButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            getContainer().onKeepUsernameChosen(suggestedUsername);
        }
    });

    nameTextView.setText(getArguments().getString(ARG_NAME, ""));
    usernameTextView.setText(StringUtils.formatHandle(suggestedUsername));

    if (TextUtils.isEmpty(suggestedUsername)) {
        usernameTextView.setVisibility(View.INVISIBLE);
        keepButton.setVisibility(View.GONE);
    }

    TextViewUtils.linkifyText(summaryTextView, Color.WHITE, com.waz.zclient.ui.R.string.wire__typeface__light,
            false, new Runnable() {
                @Override
                public void run() {
                    ((BaseActivity) getActivity()).injectJava(GlobalTrackingController.class)
                            .tagEvent(new OpenedUsernameFAQEvent());
                    getContainer().onOpenUrl(getString(R.string.usernames__learn_more__link));
                }
            });

    return view;
}

From source file:org.mariotaku.twidere.adapter.ComposeAutoCompleteAdapter.java

@Override
public void bindView(final View view, final Context context, final Cursor cursor) {
    final TextView text1 = (TextView) view.findViewById(android.R.id.text1);
    final TextView text2 = (TextView) view.findViewById(android.R.id.text2);
    final ImageView icon = (ImageView) view.findViewById(android.R.id.icon);

    // Clear images in order to prevent images in recycled view shown.
    icon.setImageDrawable(null);/*  www .  jav  a 2  s.  com*/

    if (Suggestions.AutoComplete.TYPE_USERS.equals(cursor.getString(mTypeIdx))) {
        text1.setText(mUserColorNameManager.getUserNickname(cursor.getString(mExtraIdIdx),
                cursor.getString(mTitleIdx)));
        text2.setText(String.format("@%s", cursor.getString(mSummaryIdx)));
        if (mDisplayProfileImage) {
            final String profileImageUrl = cursor.getString(mIconIdx);
            mProfileImageLoader.displayProfileImage(icon, profileImageUrl);
        } else {
            mProfileImageLoader.cancelDisplayTask(icon);
        }

        icon.clearColorFilter();
    } else {
        text1.setText(String.format("#%s", cursor.getString(mTitleIdx)));
        text2.setText(R.string.hashtag);

        icon.setImageResource(R.drawable.ic_action_hashtag);
        icon.setColorFilter(text1.getCurrentTextColor(), Mode.SRC_ATOP);
    }
    icon.setVisibility(mDisplayProfileImage ? View.VISIBLE : View.GONE);
    super.bindView(view, context, cursor);
}

From source file:ca.zadrox.dota2esportticker.ui.MatchDetailActivity.java

private void updateContentFromCursor(Cursor c) {
    if (c.moveToFirst()) {
        dateTime = c.getString(1);//from w ww . j a v  a  2 s.c  om
        bestOf = c.getString(2);
        teamLeftName = c.getString(3);
        teamLeftFlagUrl = c.getString(4);
        teamRightName = c.getString(5);
        teamRightFlagUrl = c.getString(6);
        tournamentName = c.getString(7);
        tournamentLogo = c.getString(8);
        tournamentUrl = c.getString(9);
        mUrl = c.getString(10);

        mMatchStart = Long.parseLong(dateTime);

        mTitle.setText(teamLeftName + " vs " + teamRightName);
        mSubtitle.setText(TimeUtils.toReadableLocalTime(dateTime));
        mBestOfView.setText(bestOf.toUpperCase());

        View tournamentCard = getLayoutInflater().inflate(R.layout.card_tournament, mDetailsContainer, false);

        ImageView tournamentLogoView = (ImageView) tournamentCard.findViewById(R.id.card_tournament_logo);
        TextView tournamentNameView = (TextView) tournamentCard.findViewById(R.id.card_tournament_details);

        DisplayMetrics dm = mContext.getResources().getDisplayMetrics();

        int rpx = Math.round(UIUtils.dpToPx(dm, 3f));

        tournamentLogoView.setColorFilter(Color.rgb(123, 123, 123), android.graphics.PorterDuff.Mode.MULTIPLY);

        Picasso.with(this).load(teamLeftFlagUrl).transform(new RoundedTransformation(rpx, 0)).fit()
                .into(mMatchTeamOneImageView);

        Picasso.with(this).load(teamRightFlagUrl).transform(new RoundedTransformation(rpx, 0)).fit()
                .into(mMatchTeamTwoImageView);

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
            Picasso.with(this).load(tournamentLogo).transform(new TopRoundedTransformation(rpx)).fit()
                    .centerCrop().into(tournamentLogoView);
        } else {
            Picasso.with(this).load(tournamentLogo).into(tournamentLogoView);
        }

        tournamentNameView.setText(tournamentName);

        final Uri tournamentLink = Uri.parse(tournamentUrl);

        tournamentCard.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW, tournamentLink);
                startActivity(intent);
            }
        });

        mDetailsContainer.addView(tournamentCard);

        mAddReminderButton.setVisibility(View.VISIBLE);

        final boolean isReminderSet = c.getInt(11) != 0;

        showStarredDeferred(mInitStarred = isReminderSet, false);

        getLoaderManager().initLoader(GGNET_LOADER, null, mMatchCallbacks);
        getLoaderManager().initLoader(STEAM_LOADER, null, mLiveGameLoaderCallbacks);

    } else {
        return;
    }
}

From source file:org.getlantern.firetweet.adapter.UserHashtagAutoCompleteAdapter.java

@Override
public void bindView(final View view, final Context context, final Cursor cursor) {
    if (isCursorClosed())
        return;//from  w w w .  j a v  a 2  s .co m
    final TextView text1 = (TextView) view.findViewById(android.R.id.text1);
    final TextView text2 = (TextView) view.findViewById(android.R.id.text2);
    final ImageView icon = (ImageView) view.findViewById(android.R.id.icon);

    // Clear images in prder to prevent images in recycled view shown.
    icon.setImageDrawable(null);

    if (mScreenNameIdx != -1 && mNameIdx != -1 && mUserIdIdx != -1) {
        text1.setText(getUserNickname(context, cursor.getLong(mUserIdIdx), cursor.getString(mNameIdx)));
        text2.setText("@" + cursor.getString(mScreenNameIdx));
    } else {
        text1.setText("#" + cursor.getString(mNameIdx));
        text2.setText(R.string.hashtag);
    }
    icon.setVisibility(mDisplayProfileImage ? View.VISIBLE : View.GONE);
    if (mProfileImageUrlIdx != -1) {
        if (mDisplayProfileImage) {
            final String profileImageUrl = cursor.getString(mProfileImageUrlIdx);
            mProfileImageLoader.displayProfileImage(icon, profileImageUrl);
        } else {
            mProfileImageLoader.cancelDisplayTask(icon);
            //                icon.setImageResource(R.drawable.ic_profile_image_default);
        }
        icon.clearColorFilter();
    } else {
        icon.setImageResource(R.drawable.ic_action_hashtag);
        icon.setColorFilter(text1.getCurrentTextColor(), Mode.SRC_ATOP);
    }
    super.bindView(view, context, cursor);
}