Example usage for android.view View getTag

List of usage examples for android.view View getTag

Introduction

In this page you can find the example usage for android.view View getTag.

Prototype

@ViewDebug.ExportedProperty
public Object getTag() 

Source Link

Document

Returns this view's tag.

Usage

From source file:com.android.inputmethod.latin.suggestions.SuggestionStripView.java

@Override
public void onClick(final View view) {
    AudioAndHapticFeedbackManager.getInstance().performHapticAndAudioFeedback(Constants.CODE_UNSPECIFIED, this);
    if (view == mImportantNoticeStrip) {
        mListener.showImportantNoticeContents();
        return;//from www  .j a  v  a  2s  .co m
    }
    if (view == mVoiceKey) {
        mListener.onCodeInput(Constants.CODE_SHORTCUT, Constants.SUGGESTION_STRIP_COORDINATE,
                Constants.SUGGESTION_STRIP_COORDINATE, false /* isKeyRepeat */);
        return;
    }

    final Object tag = view.getTag();
    // {@link Integer} tag is set at
    // {@link SuggestionStripLayoutHelper#setupWordViewsTextAndColor(SuggestedWords,int)} and
    // {@link SuggestionStripLayoutHelper#layoutPunctuationSuggestions(SuggestedWords,ViewGroup}
    if (tag instanceof Integer) {
        final int index = (Integer) tag;
        if (index >= mSuggestedWords.size()) {
            return;
        }
        final SuggestedWordInfo wordInfo = mSuggestedWords.getInfo(index);
        mListener.pickSuggestionManually(wordInfo);
    }
}

From source file:activities.Activity_Main.java

public void onClick(View v) {
    dont_freeze = false; // By default, onPause() will stop WidgetUpdate engine...
    //ALL other that are not explicitly used
    if (v.getTag().equals("reload_cancel")) {
        Tracer.v(mytag, "Choosing no reload settings");
        reload = false;/*from   w w  w.  ja  va  2s  .c o  m*/
        synchronized (waiting_thread) {
            waiting_thread.notifyAll();
        }
        return;
    } else if (v.getTag().equals("reload_ok")) {
        Tracer.v(mytag, "Choosing settings reload");
        reload = true;
        synchronized (waiting_thread) {
            waiting_thread.notifyAll();
        }
    }
}

From source file:com.aniruddhc.acemusic.player.MusicLibraryEditorActivity.MusicLibraryEditorArtistsMultiselectAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final Cursor c = (Cursor) getItem(position);
    SongsListViewHolder holder = null;/* w  w w  . j  av  a  2  s  . co m*/

    if (convertView == null) {

        convertView = LayoutInflater.from(mContext).inflate(R.layout.music_library_editor_artists_layout,
                parent, false);
        holder = new SongsListViewHolder();
        holder.image = (ImageView) convertView.findViewById(R.id.artistThumbnailMusicLibraryEditor);
        holder.title = (TextView) convertView.findViewById(R.id.artistNameMusicLibraryEditor);
        holder.checkBox = (CheckBox) convertView.findViewById(R.id.artistCheckboxMusicLibraryEditor);

        convertView.setTag(holder);
    } else {
        holder = (SongsListViewHolder) convertView.getTag();
    }

    final View finalConvertView = convertView;
    final String songId = c.getString(c.getColumnIndex(DBAccessHelper._ID));
    final String songArtist = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ARTIST));
    String songAlbumArtPath = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ALBUM_ART_PATH));

    holder.title.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
    holder.title.setPaintFlags(holder.title.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);

    //Set the song title.
    holder.title.setText(songArtist);
    mApp.getImageLoader().displayImage(songAlbumArtPath, holder.image,
            MusicLibraryEditorActivity.displayImageOptions);

    //Check if the song's DB ID exists in the HashSet and set the appropriate checkbox status.
    if (MusicLibraryEditorActivity.songDBIdsList.contains(songId)) {
        holder.checkBox.setChecked(true);
        convertView.setBackgroundColor(0xCC0099CC);
    } else {
        holder.checkBox.setChecked(false);
        convertView.setBackgroundColor(0x00000000);
    }

    //Set a tag to the row that will attach the artist's name to it.
    convertView.setTag(R.string.artist, songArtist);

    holder.checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean isChecked) {

            if (isChecked == true) {

                //Only receive inputs by the user and ignore any system-made changes to the checkbox state.
                if (checkbox.isPressed()) {
                    finalConvertView.setBackgroundColor(0xCC0099CC);
                    AsyncGetArtistSongIds task = new AsyncGetArtistSongIds(songArtist);
                    task.execute(new String[] { "ADD" });
                }

            } else if (isChecked == false) {

                //Only receive inputs by the user and ignore any system-made changes to the checkbox state.
                if (checkbox.isPressed()) {
                    finalConvertView.setBackgroundColor(0x00000000);
                    AsyncGetArtistSongIds task = new AsyncGetArtistSongIds(songArtist);
                    task.execute(new String[] { "REMOVE" });

                }

            }

        }

    });

    return convertView;
}

From source file:com.aniruddhc.acemusic.player.PlaylistEditorActivity.PlaylistEditorArtistsMultiselectAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final Cursor c = (Cursor) getItem(position);
    SongsListViewHolder holder = null;/*from w w w  .j  a  v  a  2 s . co m*/

    if (convertView == null) {

        convertView = LayoutInflater.from(mContext).inflate(R.layout.music_library_editor_artists_layout,
                parent, false);
        holder = new SongsListViewHolder();
        holder.image = (ImageView) convertView.findViewById(R.id.artistThumbnailMusicLibraryEditor);
        holder.title = (TextView) convertView.findViewById(R.id.artistNameMusicLibraryEditor);
        holder.checkBox = (CheckBox) convertView.findViewById(R.id.artistCheckboxMusicLibraryEditor);

        convertView.setTag(holder);
    } else {
        holder = (SongsListViewHolder) convertView.getTag();
    }

    final View finalConvertView = convertView;
    final String songId = c.getString(c.getColumnIndex(DBAccessHelper._ID));
    final String songArtist = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ARTIST));
    String songAlbumArtPath = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ALBUM_ART_PATH));

    holder.title.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
    holder.title.setPaintFlags(holder.title.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);

    //Set the song title.
    holder.title.setText(songArtist);
    mApp.getImageLoader().displayImage(songAlbumArtPath, holder.image,
            PlaylistEditorActivity.displayImageOptions);

    //Check if the song's DB ID exists in the HashSet and set the appropriate checkbox status.
    if (PlaylistEditorActivity.songDBIdsList.contains(songId)) {
        holder.checkBox.setChecked(true);
        convertView.setBackgroundColor(0xCC0099CC);
    } else {
        holder.checkBox.setChecked(false);
        convertView.setBackgroundColor(0x00000000);
    }

    //Set a tag to the row that will attach the artist's name to it.
    convertView.setTag(R.string.artist, songArtist);

    holder.checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean isChecked) {

            if (isChecked == true) {

                //Only receive inputs by the user and ignore any system-made changes to the checkbox state.
                if (checkbox.isPressed()) {
                    finalConvertView.setBackgroundColor(0xCC0099CC);
                    AsyncGetArtistSongIds task = new AsyncGetArtistSongIds(mContext, songArtist);
                    task.execute(new String[] { "ADD" });
                }

            } else if (isChecked == false) {

                //Only receive inputs by the user and ignore any system-made changes to the checkbox state.
                if (checkbox.isPressed()) {
                    finalConvertView.setBackgroundColor(0x00000000);
                    AsyncGetArtistSongIds task = new AsyncGetArtistSongIds(mContext, songArtist);
                    task.execute(new String[] { "REMOVE" });

                }

            }

        }

    });

    return convertView;
}

From source file:com.housekeeper.activity.view.MediaImagePagerAdapter.java

@Override
public View getView(final int position, View view, ViewGroup container) {
    ViewHolder holder;//w w  w .j av  a 2s. c o  m
    if (view == null) {
        holder = new ViewHolder();
        view = holder.imageView = new NetworkImageView(context);

        holder.imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                LinkArticle media = imageURLList.get(getPosition(position));

                if (!StringUtils.isBlank(media.getLink())) {
                    Intent intent = new Intent(context, ShowWebViewActivity.class);
                    intent.putExtra("title", media.getTitle());
                    intent.putExtra("url", media.getLink());
                    context.startActivity(intent);
                }
            }
        });

        view.setTag(holder);
    } else {
        holder = (ViewHolder) view.getTag();
    }

    holder.imageView.setScaleType(ScaleType.CENTER_CROP);
    holder.imageView.setImageUrl(Constants.HOST_IP + imageURLList.get(getPosition(position)).getImgUrl(),
            ImageCacheManager.getInstance().getImageLoader());
    return view;
}

From source file:babybear.akbquiz.ConfigActivity.java

/**
 * /*from ww w  . j  ava  2 s .  com*/
 */
private void loadPlaylistEditor() {

    musicList = queryMusics();
    playlistList = loadPlaylist();

    PlaylistAdapter playlistAdapter = new PlaylistAdapter(this, playlistList, new OnClickListener() {
        @Override
        public void onClick(View v) {
            int position = Integer.decode((String) v.getTag());
            onModifing = position;
            cfgflipper.showNext();
            ((TextView) findViewById(R.id.current)).setText(getString(R.string.config_bgm_onmodifing,
                    (onModifing + 1), playlistList.get(onModifing).TITLE));
            ((Button) findViewById(R.id.config_playlist_remove)).setText(R.string.remove);
        }
    });
    playlistView = (ListView) findViewById(R.id.playlist);
    playlistView.setAdapter(playlistAdapter);

    PlaylistAdapter musiclistAdapter = new PlaylistAdapter(this, musicList, new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            int position = Integer.parseInt((String) arg0.getTag());
            Log.d("", "set " + onModifing + " in Playlist with " + position + " in Musiclist");
            Music temp = musicList.get(position);
            // playlistAdapter.;
            if (onModifing == playlistList.size()) {
                playlistList.add(temp);
            } else {
                playlistList.set(onModifing, temp);
            }
            PlaylistAdapter adapter = (PlaylistAdapter) playlistView.getAdapter();
            adapter.remove(adapter.getItem(onModifing));
            adapter.insert(temp, onModifing);
            savePlaylist();

            isPlaylistChanged = true;
            cfgflipper.showPrevious();
        }

    });
    ListView musiclistView = (ListView) findViewById(R.id.musiclist);
    musiclistView.setAdapter(musiclistAdapter);

    ((Button) findViewById(R.id.config_playlist_add)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            int position = playlistList.size();
            onModifing = position;
            cfgflipper.showNext();
            ((TextView) findViewById(R.id.current)).setText(R.string.config_bgm_add);
            ((Button) findViewById(R.id.config_playlist_remove)).setText(android.R.string.cancel);
        }

    });

    ((Button) findViewById(R.id.config_playlist_remove)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (onModifing != playlistList.size()) {

                playlistList.remove(onModifing);

                // PlaylistAdapter adapter = (PlaylistAdapter)
                // playlistView
                // .getAdapter();
                // adapter.remove(adapter.getItem(onModifing));
                savePlaylist();

                isPlaylistChanged = true;
            }
            cfgflipper.showPrevious();
        }

    });

}

From source file:ch.blinkenlights.android.vanilla.LibraryActivity.java

@Override
public void onClick(View view) {
    if (view == mBottomBarControls) {
        openPlaybackActivity();/*from   w w w .  ja v  a2 s  .  c om*/
    } else if (view.getTag() != null) {
        // a limiter view was clicked
        int i = (Integer) view.getTag();

        Limiter limiter = mPagerAdapter.getCurrentLimiter();
        int type = limiter.type;
        if (i == 1 && type == MediaUtils.TYPE_ALBUM) {
            setLimiter(MediaUtils.TYPE_ARTIST, limiter.data.toString());
        } else if (i > 0) {
            Assert.assertEquals(MediaUtils.TYPE_FILE, limiter.type);
            File file = (File) limiter.data;
            int diff = limiter.names.length - i;
            while (--diff != -1) {
                file = file.getParentFile();
            }
            mPagerAdapter.setLimiter(FileSystemAdapter.buildLimiter(file));
        } else {
            mPagerAdapter.clearLimiter(type);
        }
        updateLimiterViews();
    } else {
        super.onClick(view);
    }
}

From source file:com.aniruddhc.acemusic.player.BlacklistManagerActivity.BlacklistedArtistsMultiselectAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final Cursor c = (Cursor) getItem(position);
    SongsListViewHolder holder = null;//w  w w.  ja v a  2  s  .  c  o  m

    if (convertView == null) {

        convertView = LayoutInflater.from(mContext).inflate(R.layout.music_library_editor_artists_layout,
                parent, false);
        holder = new SongsListViewHolder();
        holder.image = (ImageView) convertView.findViewById(R.id.artistThumbnailMusicLibraryEditor);
        holder.title = (TextView) convertView.findViewById(R.id.artistNameMusicLibraryEditor);
        holder.checkBox = (CheckBox) convertView.findViewById(R.id.artistCheckboxMusicLibraryEditor);

        convertView.setTag(holder);
    } else {
        holder = (SongsListViewHolder) convertView.getTag();
    }

    final View finalConvertView = convertView;
    final String songId = c.getString(c.getColumnIndex(DBAccessHelper._ID));
    final String songArtist = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ARTIST));
    final String songBlacklistStatus = c.getString(c.getColumnIndex(DBAccessHelper.BLACKLIST_STATUS));
    String songAlbumArtPath = c.getString(c.getColumnIndex(DBAccessHelper.SONG_ALBUM_ART_PATH));

    holder.title.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light"));
    holder.title.setPaintFlags(holder.title.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);

    //Set the song title.
    holder.title.setText(songArtist);
    mApp.getImageLoader().displayImage(songAlbumArtPath, holder.image,
            BlacklistManagerActivity.displayImageOptions);

    //Check if the song's DB ID exists in the HashSet and set the appropriate checkbox status.
    try {
        if (BlacklistManagerActivity.songIdBlacklistStatusPair.get(songId).equals("TRUE")) {
            holder.checkBox.setChecked(true);
            convertView.setBackgroundColor(0xCCFF4444);
        } else {
            holder.checkBox.setChecked(false);
            convertView.setBackgroundColor(0x00000000);
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

    //Set a tag to the row that will attach the artist's name to it.
    convertView.setTag(R.string.artist, songArtist);

    holder.checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton checkbox, boolean isChecked) {

            if (isChecked == true) {

                //Only receive inputs by the user and ignore any system-made changes to the checkbox state.
                if (checkbox.isPressed()) {
                    finalConvertView.setBackgroundColor(0xCCFF4444);
                    AsyncBlacklistArtistTask task = new AsyncBlacklistArtistTask(songArtist);
                    task.execute(new String[] { "ADD" });
                }

            } else if (isChecked == false) {

                //Only receive inputs by the user and ignore any system-made changes to the checkbox state.
                if (checkbox.isPressed()) {
                    finalConvertView.setBackgroundColor(0x00000000);
                    AsyncBlacklistArtistTask task = new AsyncBlacklistArtistTask(songArtist);
                    task.execute(new String[] { "REMOVE" });

                }

            }

        }

    });

    return convertView;
}

From source file:in.shick.diode.threads.ThreadsListActivity.java

public static void fillThreadsListItemView(int position, View view, ThingInfo item, ListActivity activity,
        HttpClient client, RedditSettings settings,
        ThumbnailOnClickListenerFactory thumbnailOnClickListenerFactory) {

    Resources res = activity.getResources();
    ViewHolder vh;//from www .  j  a  v  a 2  s . co  m
    if (view.getTag() == null) {
        vh = new ViewHolder();
        vh.titleView = (TextView) view.findViewById(R.id.title);
        vh.votesView = (TextView) view.findViewById(R.id.votes);
        vh.numCommentsSubredditView = (TextView) view.findViewById(R.id.numCommentsSubreddit);
        vh.nsfwView = (TextView) view.findViewById(R.id.nsfw);
        vh.voteUpView = (ImageView) view.findViewById(R.id.vote_up_image);
        vh.voteDownView = (ImageView) view.findViewById(R.id.vote_down_image);
        vh.thumbnailContainer = view.findViewById(R.id.thumbnail_view);
        vh.thumbnailFrame = (FrameLayout) view.findViewById(R.id.thumbnail_frame);
        vh.thumbnailImageView = (ImageView) view.findViewById(R.id.thumbnail);
        vh.indeterminateProgressBar = (ProgressBar) view.findViewById(R.id.indeterminate_progress);
        view.setTag(vh);
    } else {
        vh = (ViewHolder) view.getTag();
    }

    // Need to store the Thing's id in the thumbnail image so that the thumbnail loader task
    // knows that the row is still displaying the requested thumbnail.
    vh.thumbnailImageView.setTag(item.getId());
    // Set the title and domain using a SpannableStringBuilder
    SpannableStringBuilder builder = new SpannableStringBuilder();
    String title = item.getTitle();
    if (title == null)
        title = "";
    SpannableString titleSS = new SpannableString(title);
    int titleLen = title.length();
    titleSS.setSpan(
            new TextAppearanceSpan(activity,
                    Util.getTextAppearanceResource(settings.getTheme(), android.R.style.TextAppearance_Large)),
            0, titleLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    String domain = item.getDomain();
    if (domain == null)
        domain = "";
    String flair = item.getLink_flair_text();
    if (flair == null) {
        flair = "";
    } else {
        flair = "[" + flair + "] ";
    }
    int domainLen = domain.length() + flair.length();
    SpannableString domainSS = new SpannableString(flair + "(" + item.getDomain() + ")");
    domainSS.setSpan(
            new TextAppearanceSpan(activity,
                    Util.getTextAppearanceResource(settings.getTheme(), android.R.style.TextAppearance_Small)),
            0, domainLen + 2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    if (Util.isLightTheme(settings.getTheme())) {
        if (item.isClicked()) {
            ForegroundColorSpan fcs = new ForegroundColorSpan(res.getColor(R.color.purple));
            titleSS.setSpan(fcs, 0, titleLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        } else {
            ForegroundColorSpan fcs = new ForegroundColorSpan(res.getColor(R.color.blue));
            titleSS.setSpan(fcs, 0, titleLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        domainSS.setSpan(new ForegroundColorSpan(res.getColor(R.color.gray_50)), 0, domainLen + 2,
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    } else {
        if (item.isClicked()) {
            ForegroundColorSpan fcs = new ForegroundColorSpan(res.getColor(R.color.gray_50));
            titleSS.setSpan(fcs, 0, titleLen, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        domainSS.setSpan(new ForegroundColorSpan(res.getColor(R.color.gray_75)), 0, domainLen + 2,
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    }

    builder.append(titleSS).append(" ").append(domainSS);
    vh.titleView.setText(builder);

    vh.votesView.setText(String.format(Locale.US, "%d", item.getScore()));
    // Lock icon emoji
    String preText = item.isLocked() ? "\uD83D\uDD12 " : "";
    vh.numCommentsSubredditView
            .setText(preText + Util.showNumComments(item.getNum_comments()) + "  " + item.getSubreddit());

    vh.nsfwView.setVisibility(item.isOver_18() ? View.VISIBLE : View.GONE);

    // Set the up and down arrow colors based on whether user likes
    if (settings.isLoggedIn()) {
        if (item.getLikes() == null) {
            vh.voteUpView.setImageResource(R.drawable.vote_up_gray);
            vh.voteDownView.setImageResource(R.drawable.vote_down_gray);
            vh.votesView.setTextColor(res.getColor(R.color.gray_75));
        } else if (item.getLikes()) {
            vh.voteUpView.setImageResource(R.drawable.vote_up_red);
            vh.voteDownView.setImageResource(R.drawable.vote_down_gray);
            vh.votesView.setTextColor(res.getColor(R.color.arrow_red));
        } else {
            vh.voteUpView.setImageResource(R.drawable.vote_up_gray);
            vh.voteDownView.setImageResource(R.drawable.vote_down_blue);
            vh.votesView.setTextColor(res.getColor(R.color.arrow_blue));
        }
    } else {
        vh.voteUpView.setImageResource(R.drawable.vote_up_gray);
        vh.voteDownView.setImageResource(R.drawable.vote_down_gray);
        vh.votesView.setTextColor(res.getColor(R.color.gray_75));
    }

    // Thumbnails open links
    if (vh.thumbnailContainer != null) {
        if (Common.shouldLoadThumbnails(activity, settings)) {
            vh.thumbnailContainer.setVisibility(View.VISIBLE);

            if (item.getUrl() != null) {
                OnClickListener thumbnailOnClickListener = thumbnailOnClickListenerFactory
                        .getThumbnailOnClickListener(item, activity);
                if (thumbnailOnClickListener != null) {
                    vh.thumbnailFrame.setOnClickListener(thumbnailOnClickListener);
                }
            }

            // Show thumbnail based on ThingInfo
            if (Constants.NSFW_STRING.equalsIgnoreCase(item.getThumbnail())
                    || Constants.DEFAULT_STRING.equals(item.getThumbnail())
                    || Constants.SUBMIT_KIND_SELF.equals(item.getThumbnail())
                    || StringUtils.isEmpty(item.getThumbnail())) {
                vh.indeterminateProgressBar.setVisibility(View.GONE);
                vh.thumbnailImageView.setVisibility(View.VISIBLE);
                vh.thumbnailImageView.setImageResource(R.drawable.go_arrow);
            } else {
                if (item.getThumbnailBitmap() != null) {
                    vh.indeterminateProgressBar.setVisibility(View.GONE);
                    vh.thumbnailImageView.setVisibility(View.VISIBLE);
                    vh.thumbnailImageView.setImageBitmap(item.getThumbnailBitmap());
                } else {
                    vh.indeterminateProgressBar.setVisibility(View.VISIBLE);
                    vh.thumbnailImageView.setVisibility(View.GONE);
                    vh.thumbnailImageView.setImageBitmap(null);
                    new ShowThumbnailsTask(activity, client, R.drawable.go_arrow)
                            .execute(new ThumbnailLoadAction(item, vh.thumbnailImageView, position,
                                    vh.indeterminateProgressBar));
                }
            }

            // Set thumbnail background based on current theme
            if (Util.isLightTheme(settings.getTheme()))
                vh.thumbnailFrame.setBackgroundResource(R.drawable.thumbnail_background_light);
            else
                vh.thumbnailFrame.setBackgroundResource(R.drawable.thumbnail_background_dark);
        } else {
            // if thumbnails disabled, hide thumbnail icon
            vh.thumbnailContainer.setVisibility(View.GONE);
        }
    }
}

From source file:cc.softwarefactory.lokki.android.fragments.AddContactsFragment.java

private void setListAdapter() {

    adapter = new ArrayAdapter<String>(getActivity(), R.layout.add_people_row_layout, contactList) {

        @Override//from  w  w w .jav  a2 s . com
        public View getView(final int position, View convertView, ViewGroup parent) {

            ViewHolder holder;

            if (convertView == null) {
                convertView = getActivity().getLayoutInflater().inflate(R.layout.add_people_row_layout, parent,
                        false);
                holder = new ViewHolder();
                holder.name = (TextView) convertView.findViewById(R.id.contact_name);
                holder.email = (TextView) convertView.findViewById(R.id.contact_email);
                holder.photo = (ImageView) convertView.findViewById(R.id.contact_photo);
                convertView.setTag(holder);

            } else {
                holder = (ViewHolder) convertView.getTag();
            }

            try {
                AQuery aq = new AQuery(convertView);
                String contactName = getItem(position);
                final String email = MainApplication.mapping.getString(contactName);

                avatarLoader.load(email, holder.photo);

                aq.id(holder.name).text(contactName);
                aq.id(holder.email).text(email);
                holder.position = position;

                convertView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        final Context context = getContext();
                        String title = context.getResources().getString(R.string.add_contact);
                        String message = context.getResources().getString(R.string.add_contact_dialog_save,
                                email);
                        new AlertDialog.Builder(context).setTitle(title).setMessage(message)
                                .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialog, int which) {
                                        try {
                                            ServerApi.allowPeople(context, email);
                                            contactList.remove(position);
                                            notifyDataSetChanged();
                                            Toast.makeText(context, R.string.contact_added, Toast.LENGTH_SHORT)
                                                    .show();
                                        } catch (JSONException e) {
                                            e.printStackTrace();
                                        }
                                    }
                                }).setNegativeButton(R.string.cancel, null).show();
                    }
                });

            } catch (JSONException e) {
                Log.e(TAG, e.getMessage());
            }
            return convertView;
        }
    };

    aq.id(R.id.add_contacts_list_view).adapter(adapter);
}