Example usage for android.content.res Resources getQuantityString

List of usage examples for android.content.res Resources getQuantityString

Introduction

In this page you can find the example usage for android.content.res Resources getQuantityString.

Prototype

@NonNull
public String getQuantityString(@PluralsRes int id, int quantity, Object... formatArgs)
        throws NotFoundException 

Source Link

Document

Formats the string necessary for grammatically correct pluralization of the given resource ID for the given quantity, using the given arguments.

Usage

From source file:it.geosolutions.geocollect.android.core.mission.PendingMissionListFragment.java

/**
 * checks if background data for the current template is available if not, the user is asked to download
 *//*from  www .ja v  a  2 s.  co m*/
private void checkIfBackgroundIsAvailableForTemplate() {

    boolean exists = MissionUtils.checkTemplateForBackgroundData(getActivity(), missionTemplate);

    if (!exists) {

        final HashMap<String, Integer> urls = MissionUtils
                .getContentUrlsAndFileAmountForTemplate(missionTemplate);

        if (BuildConfig.DEBUG) {
            Log.i(TAG, "downloading " + urls.toString());
        }

        Resources res = getResources();
        for (String url : urls.keySet()) {

            final String mount = MapFilesProvider.getEnvironmentDirPath(getActivity());

            String dialogMessage = res.getQuantityString(R.plurals.dialog_message_with_amount, urls.get(url),
                    urls.get(url));
            new ZipFileManager(getActivity(), mount, MapFilesProvider.getBaseDir(), url, null, dialogMessage) {
                @Override
                public void launchMainActivity(final boolean success) {

                    // TODO apply ? this was earlier in StartupActivity
                    // if (getActivity().getApplication() instanceof GeoCollectApplication) {
                    // ((GeoCollectApplication) getActivity().getApplication()).setupMBTilesBackgroundConfiguration();
                    // }
                    // launch.putExtra(PendingMissionListFragment.INFINITE_SCROLL, false);
                    if (success) {

                        Toast.makeText(getActivity(), getString(R.string.download_successfull),
                                Toast.LENGTH_SHORT).show();
                    }

                }
            };
        }

    }

}

From source file:com.nachiket.titan.LibraryActivity.java

/**
 * Delete the media represented by the given intent and show a Toast
 * informing the user of this./*from   w  ww .  j  a  v a 2  s .c o m*/
 *
 * @param intent An intent created with
 * {@link LibraryAdapter#createData(View)}.
 */
private void delete(Intent intent) {
    int type = intent.getIntExtra("type", MediaUtils.TYPE_INVALID);
    long id = intent.getLongExtra("id", LibraryAdapter.INVALID_ID);
    String message = null;
    Resources res = getResources();

    if (type == MediaUtils.TYPE_FILE) {
        String file = intent.getStringExtra("file");
        boolean success = MediaUtils.deleteFile(new File(file));
        if (!success) {
            message = res.getString(R.string.delete_file_failed, file);
        }
    } else if (type == MediaUtils.TYPE_PLAYLIST) {
        Playlist.deletePlaylist(getContentResolver(), id);
    } else {
        int count = PlaybackService.get(this).deleteMedia(type, id);
        message = res.getQuantityString(R.plurals.deleted, count, count);
    }

    if (message == null) {
        message = res.getString(R.string.deleted, intent.getStringExtra("title"));
    }

    Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
}

From source file:org.mariotaku.twidere.view.holder.ActivityTitleSummaryViewHolder.java

private Spanned getTitleStringAboutMe(int stringRes, int stringResMulti, ParcelableUser[] sources) {
    if (sources == null || sources.length == 0)
        return null;
    final Context context = adapter.getContext();
    final boolean nameFirst = adapter.isNameFirst();
    final UserColorNameManager manager = adapter.getUserColorNameManager();
    final Resources resources = context.getResources();
    final Configuration configuration = resources.getConfiguration();
    final SpannableString firstDisplayName = new SpannableString(
            manager.getDisplayName(sources[0], nameFirst, false));
    firstDisplayName.setSpan(new StyleSpan(Typeface.BOLD), 0, firstDisplayName.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    if (sources.length == 1) {
        final String format = context.getString(stringRes);
        return SpanFormatter.format(configuration.locale, format, firstDisplayName);
    } else if (sources.length == 2) {
        final String format = context.getString(stringResMulti);
        final SpannableString secondDisplayName = new SpannableString(
                manager.getDisplayName(sources[1], nameFirst, false));
        secondDisplayName.setSpan(new StyleSpan(Typeface.BOLD), 0, secondDisplayName.length(),
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        return SpanFormatter.format(configuration.locale, format, firstDisplayName, secondDisplayName);
    } else {//from  w  w w  .  j a v  a2s.c o  m
        final int othersCount = sources.length - 1;
        final SpannableString nOthers = new SpannableString(
                resources.getQuantityString(R.plurals.N_others, othersCount, othersCount));
        nOthers.setSpan(new StyleSpan(Typeface.BOLD), 0, nOthers.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        final String format = context.getString(stringResMulti);
        return SpanFormatter.format(configuration.locale, format, firstDisplayName, nOthers);
    }
}

From source file:me.ccrama.redditslide.DragSort.ReorderSubreddits.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        finish();//from   ww  w.ja v  a 2 s  .co  m
        return true;
    case R.id.refresh:
        done = 0;
        final Dialog d = new MaterialDialog.Builder(ReorderSubreddits.this).title(R.string.general_sub_sync)
                .content(R.string.misc_please_wait).progress(true, 100).cancelable(false).show();
        new AsyncTask<Void, Void, ArrayList<String>>() {
            @Override
            protected ArrayList<String> doInBackground(Void... params) {
                ArrayList<String> newSubs = new ArrayList<>(
                        UserSubscriptions.syncSubreddits(ReorderSubreddits.this));
                UserSubscriptions.syncMultiReddits(ReorderSubreddits.this);
                return newSubs;
            }

            @Override
            protected void onPostExecute(ArrayList<String> newSubs) {
                d.dismiss();
                // Determine if we should insert subreddits at the end of the list or sorted
                boolean sorted = (subs.equals(UserSubscriptions.sortNoExtras(subs)));
                Resources res = getResources();

                for (String s : newSubs) {
                    if (!subs.contains(s)) {
                        done++;
                        subs.add(s);
                    }
                }
                if (sorted && done > 0) {
                    subs = UserSubscriptions.sortNoExtras(subs);
                    adapter = new CustomAdapter(subs);
                    recyclerView.setAdapter(adapter);
                } else if (done > 0) {
                    adapter.notifyDataSetChanged();
                    recyclerView.smoothScrollToPosition(subs.size());
                }
                new AlertDialogWrapper.Builder(ReorderSubreddits.this).setTitle(R.string.reorder_sync_complete)
                        .setMessage(res.getQuantityString(R.plurals.reorder_subs_added, done, done))
                        .setPositiveButton(R.string.btn_ok, null).show();
            }
        }.execute();
        return true;
    case R.id.alphabetize:
        subs = UserSubscriptions.sortNoExtras(subs);
        adapter = new CustomAdapter(subs);
        //  adapter.setHasStableIds(true);
        recyclerView.setAdapter(adapter);
        return true;
    case R.id.info:
        new AlertDialogWrapper.Builder(ReorderSubreddits.this).setTitle(R.string.reorder_subs_FAQ)
                .setMessage(R.string.sorting_faq).show();
        return true;
    }
    return false;
}

From source file:mp.teardrop.LibraryActivity.java

/**
 * Delete the media represented by the given intent and show a Toast
 * informing the user of this./*from ww  w. j  ava  2 s . c om*/
 *
 * @param intent An intent created with
 *               {@link LibraryAdapter#createData(View)}.
 */
private void delete(Intent intent) {
    int type = intent.getIntExtra("type", MediaUtils.TYPE_INVALID);
    long id = intent.getLongExtra("id", LibraryAdapter.INVALID_ID);
    String message = null;
    Resources res = getResources();

    if (type == MediaUtils.TYPE_FILE) {
        String file = intent.getStringExtra("file");
        boolean success = MediaUtils.deleteFile(new File(file));
        if (!success) {
            message = res.getString(R.string.delete_file_failed, file);
        }
        //} else if (type == MediaUtils.TYPE_PLAYLIST) {
        /* } else if(false) {
           Playlist.deletePlaylist(getContentResolver(), id); */
    } else {
        int count = PlaybackService.get(this).deleteMedia(type, id);
        message = res.getQuantityString(R.plurals.deleted, count, count);
    }

    if (message == null) {
        message = res.getString(R.string.deleted_item, intent.getStringExtra("title"));
    }

    Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
}

From source file:com.hippo.ehviewer.ui.scene.GalleryDetailScene.java

private void bindViewSecond() {
    GalleryDetail gd = mGalleryDetail;/*from w w w  . j  a  va  2  s.c om*/
    if (gd == null) {
        return;
    }
    if (mThumb == null || mTitle == null || mUploader == null || mCategory == null || mLanguage == null
            || mPages == null || mSize == null || mPosted == null || mFavoredTimes == null
            || mRatingText == null || mRating == null || mTorrent == null) {
        return;
    }

    Resources resources = getResources2();
    Assert.assertNotNull(resources);

    mThumb.load(EhCacheKeyFactory.getThumbKey(gd.gid), gd.thumb);
    mTitle.setText(EhUtils.getSuitableTitle(gd));
    mUploader.setText(gd.uploader);
    mCategory.setText(EhUtils.getCategory(gd.category));
    mCategory.setTextColor(EhUtils.getCategoryColor(gd.category));
    updateDownloadText();

    mLanguage.setText(gd.language);
    mPages.setText(resources.getQuantityString(R.plurals.page_count, gd.pages, gd.pages));
    mSize.setText(gd.size);
    mPosted.setText(gd.posted);
    mFavoredTimes.setText(resources.getString(R.string.favored_times, gd.favoriteCount));

    mRatingText.setText(getAllRatingText(gd.rating, gd.ratingCount));
    mRating.setRating(gd.rating);

    updateFavoriteDrawable();

    mTorrent.setText(resources.getString(R.string.torrent_count, gd.torrentCount));

    bindTags(gd.tags);
    bindComments(gd.comments);
    bindPreviews(gd);
}

From source file:org.mariotaku.twidere.view.holder.ActivityTitleSummaryViewHolder.java

private Spanned getTitleStringByFriends(int stringRes, int stringResMulti, ParcelableUser[] sources,
        Object[] targets) {/*from   www.jav a 2  s .c o  m*/
    if (sources == null || sources.length == 0)
        return null;
    final Context context = adapter.getContext();
    final Resources resources = context.getResources();
    final Configuration configuration = resources.getConfiguration();
    final UserColorNameManager manager = adapter.getUserColorNameManager();
    final boolean nameFirst = adapter.isNameFirst();
    final SpannableString firstSourceName = new SpannableString(
            manager.getDisplayName(sources[0], nameFirst, false));
    firstSourceName.setSpan(new StyleSpan(Typeface.BOLD), 0, firstSourceName.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    final String displayName;
    final Object target = targets[0];
    if (target instanceof ParcelableUser) {
        displayName = manager.getDisplayName((ParcelableUser) target, nameFirst, false);
    } else if (target instanceof ParcelableStatus) {
        displayName = manager.getDisplayName((ParcelableStatus) target, nameFirst, false);
    } else {
        throw new IllegalArgumentException();
    }
    final SpannableString firstTargetName = new SpannableString(displayName);
    firstTargetName.setSpan(new StyleSpan(Typeface.BOLD), 0, firstTargetName.length(),
            Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    if (sources.length == 1) {
        final String format = context.getString(stringRes);
        return SpanFormatter.format(configuration.locale, format, firstSourceName, firstTargetName);
    } else if (sources.length == 2) {
        final String format = context.getString(stringResMulti);
        final SpannableString secondSourceName = new SpannableString(
                manager.getDisplayName(sources[1], nameFirst, false));
        secondSourceName.setSpan(new StyleSpan(Typeface.BOLD), 0, secondSourceName.length(),
                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        return SpanFormatter.format(configuration.locale, format, firstSourceName, secondSourceName,
                firstTargetName);
    } else {
        final int othersCount = sources.length - 1;
        final SpannableString nOthers = new SpannableString(
                resources.getQuantityString(R.plurals.N_others, othersCount, othersCount));
        nOthers.setSpan(new StyleSpan(Typeface.BOLD), 0, nOthers.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        final String format = context.getString(stringResMulti);
        return SpanFormatter.format(configuration.locale, format, firstSourceName, nOthers, firstTargetName);
    }
}

From source file:org.getlantern.firetweet.provider.FiretweetDataProvider.java

private void showTimelineNotification(AccountPreferences pref, long position) {
    final long accountId = pref.getAccountId();
    final Context context = getContext();
    final Resources resources = context.getResources();
    final NotificationManager nm = getNotificationManager();
    final Expression selection = Expression.and(Expression.equals(Statuses.ACCOUNT_ID, accountId),
            Expression.greaterThan(Statuses.STATUS_ID, position));
    final String filteredSelection = Utils.buildStatusFilterWhereClause(Statuses.TABLE_NAME, selection)
            .getSQL();//from www .  j  av a 2 s  . co m
    final String[] userProjection = { Statuses.USER_ID, Statuses.USER_NAME, Statuses.USER_SCREEN_NAME };
    final String[] statusProjection = { Statuses.STATUS_ID };
    final Cursor statusCursor = mDatabaseWrapper.query(Statuses.TABLE_NAME, statusProjection, filteredSelection,
            null, null, null, Statuses.SORT_ORDER_TIMESTAMP_DESC);
    final Cursor userCursor = mDatabaseWrapper.query(Statuses.TABLE_NAME, userProjection, filteredSelection,
            null, Statuses.USER_ID, null, Statuses.SORT_ORDER_TIMESTAMP_DESC);
    try {
        final int usersCount = userCursor.getCount();
        final int statusesCount = statusCursor.getCount();
        if (statusesCount == 0 || usersCount == 0)
            return;
        final int idxStatusId = statusCursor.getColumnIndex(Statuses.STATUS_ID),
                idxUserName = userCursor.getColumnIndex(Statuses.USER_NAME),
                idxUserScreenName = userCursor.getColumnIndex(Statuses.USER_NAME),
                idxUserId = userCursor.getColumnIndex(Statuses.USER_NAME);
        final long statusId = statusCursor.moveToFirst() ? statusCursor.getLong(idxStatusId) : -1;
        final String notificationTitle = resources.getQuantityString(R.plurals.N_new_statuses, statusesCount,
                statusesCount);
        final String notificationContent;
        userCursor.moveToFirst();
        final String displayName = UserColorNameUtils.getUserNickname(context, userCursor.getLong(idxUserId),
                mNameFirst ? userCursor.getString(idxUserName) : userCursor.getString(idxUserScreenName));
        if (usersCount == 1) {
            notificationContent = context.getString(R.string.from_name, displayName);
        } else if (usersCount == 2) {
            userCursor.moveToPosition(1);
            final String othersName = UserColorNameUtils.getUserNickname(context, userCursor.getLong(idxUserId),
                    mNameFirst ? userCursor.getString(idxUserName) : userCursor.getString(idxUserScreenName));
            notificationContent = resources.getQuantityString(R.plurals.from_name_and_N_others, usersCount - 1,
                    othersName, usersCount - 1);
        } else {
            userCursor.moveToPosition(1);
            final String othersName = UserColorNameUtils.getUserNickname(context, userCursor.getLong(idxUserId),
                    mNameFirst ? userCursor.getString(idxUserName) : userCursor.getString(idxUserScreenName));
            notificationContent = resources.getString(R.string.from_name_and_N_others, othersName,
                    usersCount - 1);
        }

        // Setup notification
        final NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
        builder.setAutoCancel(true);
        builder.setSmallIcon(R.drawable.ic_stat_twitter);
        builder.setTicker(notificationTitle);
        builder.setContentTitle(notificationTitle);
        builder.setContentText(notificationContent);
        builder.setCategory(NotificationCompat.CATEGORY_SOCIAL);
        builder.setContentIntent(getContentIntent(context, AUTHORITY_HOME, accountId));
        builder.setDeleteIntent(getDeleteIntent(context, AUTHORITY_HOME, accountId, statusId));
        builder.setNumber(statusesCount);
        builder.setColor(pref.getNotificationLightColor());
        setNotificationPreferences(builder, pref, pref.getHomeTimelineNotificationType());
        nm.notify("home_" + accountId, NOTIFICATION_ID_HOME_TIMELINE, builder.build());
        Utils.sendPebbleNotification(context, notificationContent);
    } finally {
        statusCursor.close();
        userCursor.close();
    }
}

From source file:com.android.dialer.calllog.DefaultVoicemailNotifier.java

/**
 * Updates the notification and notifies of the call with the given URI.
 *
 * Clears the notification if there are no new voicemails, and notifies if the given URI
 * corresponds to a new voicemail.//w w w  . jav a 2s.  co  m
 *
 * It is not safe to call this method from the main thread.
 */
public void updateNotification(Uri newCallUri) {
    // Lookup the list of new voicemails to include in the notification.
    // TODO: Move this into a service, to avoid holding the receiver up.
    final List<NewCall> newCalls = CallLogNotificationsHelper.getInstance(mContext).getNewVoicemails();

    if (newCalls == null) {
        // Query failed, just return.
        return;
    }

    if (newCalls.isEmpty()) {
        // No voicemails to notify about: clear the notification.
        getNotificationManager().cancel(NOTIFICATION_TAG, NOTIFICATION_ID);
        return;
    }

    Resources resources = mContext.getResources();

    // This represents a list of names to include in the notification.
    String callers = null;

    // Maps each number into a name: if a number is in the map, it has already left a more
    // recent voicemail.
    final Map<String, String> names = Maps.newHashMap();

    // Determine the call corresponding to the new voicemail we have to notify about.
    NewCall callToNotify = null;

    // Iterate over the new voicemails to determine all the information above.
    Iterator<NewCall> itr = newCalls.iterator();
    while (itr.hasNext()) {
        NewCall newCall = itr.next();

        // Skip notifying for numbers which are blocked.
        if (FilteredNumbersUtil.shouldBlockVoicemail(mContext, newCall.number, newCall.countryIso,
                newCall.dateMs)) {
            itr.remove();

            // Delete the voicemail.
            mContext.getContentResolver().delete(newCall.voicemailUri, null, null);
            continue;
        }

        // Check if we already know the name associated with this number.
        String name = names.get(newCall.number);
        if (name == null) {
            name = CallLogNotificationsHelper.getInstance(mContext).getName(newCall.number,
                    newCall.numberPresentation, newCall.countryIso);
            names.put(newCall.number, name);
            // This is a new caller. Add it to the back of the list of callers.
            if (TextUtils.isEmpty(callers)) {
                callers = name;
            } else {
                callers = resources.getString(R.string.notification_voicemail_callers_list, callers, name);
            }
        }
        // Check if this is the new call we need to notify about.
        if (newCallUri != null && newCall.voicemailUri != null
                && ContentUris.parseId(newCallUri) == ContentUris.parseId(newCall.voicemailUri)) {
            callToNotify = newCall;
        }
    }

    // All the potential new voicemails have been removed, e.g. if they were spam.
    if (newCalls.isEmpty()) {
        return;
    }

    // If there is only one voicemail, set its transcription as the "long text".
    String transcription = null;
    if (newCalls.size() == 1) {
        transcription = newCalls.get(0).transcription;
    }

    if (newCallUri != null && callToNotify == null) {
        Log.e(TAG, "The new call could not be found in the call log: " + newCallUri);
    }

    // Determine the title of the notification and the icon for it.
    final String title = resources.getQuantityString(R.plurals.notification_voicemail_title, newCalls.size(),
            newCalls.size());
    // TODO: Use the photo of contact if all calls are from the same person.
    final int icon = android.R.drawable.stat_notify_voicemail;

    Pair<Uri, Integer> info = getNotificationInfo(callToNotify);

    Notification.Builder notificationBuilder = new Notification.Builder(mContext).setSmallIcon(icon)
            .setContentTitle(title).setContentText(callers)
            .setStyle(new Notification.BigTextStyle().bigText(transcription))
            .setColor(resources.getColor(R.color.dialer_theme_color)).setSound(info.first)
            .setDefaults(info.second).setDeleteIntent(createMarkNewVoicemailsAsOldIntent()).setAutoCancel(true);

    // Determine the intent to fire when the notification is clicked on.
    final Intent contentIntent;
    // Open the call log.
    contentIntent = new Intent(mContext, DialtactsActivity.class);
    contentIntent.putExtra(DialtactsActivity.EXTRA_SHOW_TAB, ListsFragment.TAB_INDEX_VOICEMAIL);
    notificationBuilder.setContentIntent(
            PendingIntent.getActivity(mContext, 0, contentIntent, PendingIntent.FLAG_UPDATE_CURRENT));

    // The text to show in the ticker, describing the new event.
    if (callToNotify != null) {
        CharSequence msg = ContactDisplayUtils.getTtsSpannedPhoneNumber(resources,
                R.string.notification_new_voicemail_ticker, names.get(callToNotify.number));
        notificationBuilder.setTicker(msg);
    }
    Log.i(TAG, "Creating voicemail notification");
    getNotificationManager().notify(NOTIFICATION_TAG, NOTIFICATION_ID, notificationBuilder.build());
}

From source file:io.plaidapp.ui.DribbbleShot.java

void bindShot(final boolean postponeEnterTransition) {
    final Resources res = getResources();

    // load the main image
    final int[] imageSize = shot.images.bestSize();
    Glide.with(this).load(shot.images.best()).listener(shotLoadListener)
            .diskCacheStrategy(DiskCacheStrategy.SOURCE).priority(Priority.IMMEDIATE)
            .override(imageSize[0], imageSize[1]).into(imageView);
    imageView.setOnClickListener(shotClick);
    shotSpacer.setOnClickListener(shotClick);

    if (postponeEnterTransition)
        postponeEnterTransition();//  w w w  .  ja v  a2 s  .  c o m
    imageView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
        @Override
        public boolean onPreDraw() {
            imageView.getViewTreeObserver().removeOnPreDrawListener(this);
            calculateFabPosition();
            if (postponeEnterTransition)
                startPostponedEnterTransition();
            return true;
        }
    });

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        ((FabOverlapTextView) title).setText(shot.title);
    } else {
        ((TextView) title).setText(shot.title);
    }
    if (!TextUtils.isEmpty(shot.description)) {
        final Spanned descText = shot.getParsedDescription(
                ContextCompat.getColorStateList(this, R.color.dribbble_links),
                ContextCompat.getColor(this, R.color.dribbble_link_highlight));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            ((FabOverlapTextView) description).setText(descText);
        } else {
            HtmlUtils.setTextWithNiceLinks((TextView) description, descText);
        }
    } else {
        description.setVisibility(View.GONE);
    }
    NumberFormat nf = NumberFormat.getInstance();
    likeCount.setText(
            res.getQuantityString(R.plurals.likes, (int) shot.likes_count, nf.format(shot.likes_count)));
    likeCount.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ((AnimatedVectorDrawable) likeCount.getCompoundDrawables()[1]).start();
            if (shot.likes_count > 0) {
                PlayerSheet.start(DribbbleShot.this, shot);
            }
        }
    });
    if (shot.likes_count == 0) {
        likeCount.setBackground(null); // clear touch ripple if doesn't do anything
    }
    viewCount.setText(
            res.getQuantityString(R.plurals.views, (int) shot.views_count, nf.format(shot.views_count)));
    viewCount.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ((AnimatedVectorDrawable) viewCount.getCompoundDrawables()[1]).start();
        }
    });
    share.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ((AnimatedVectorDrawable) share.getCompoundDrawables()[1]).start();
            new ShareDribbbleImageTask(DribbbleShot.this, shot).execute();
        }
    });
    if (shot.user != null) {
        playerName.setText(shot.user.name.toLowerCase());
        Glide.with(this).load(shot.user.getHighQualityAvatarUrl()).transform(circleTransform)
                .placeholder(R.drawable.avatar_placeholder).override(largeAvatarSize, largeAvatarSize)
                .into(playerAvatar);
        View.OnClickListener playerClick = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent player = new Intent(DribbbleShot.this, PlayerActivity.class);
                if (shot.user.shots_count > 0) { // legit user object
                    player.putExtra(PlayerActivity.EXTRA_PLAYER, shot.user);
                } else {
                    // search doesn't fully populate the user object,
                    // in this case send the ID not the full user
                    player.putExtra(PlayerActivity.EXTRA_PLAYER_NAME, shot.user.username);
                    player.putExtra(PlayerActivity.EXTRA_PLAYER_ID, shot.user.id);
                }
                ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(DribbbleShot.this,
                        playerAvatar, getString(R.string.transition_player_avatar));
                startActivity(player, options.toBundle());
            }
        };
        playerAvatar.setOnClickListener(playerClick);
        playerName.setOnClickListener(playerClick);
        if (shot.created_at != null) {
            shotTimeAgo
                    .setText(
                            DateUtils
                                    .getRelativeTimeSpanString(shot.created_at.getTime(),
                                            System.currentTimeMillis(), DateUtils.SECOND_IN_MILLIS)
                                    .toString().toLowerCase());
        }
    } else {
        playerName.setVisibility(View.GONE);
        playerAvatar.setVisibility(View.GONE);
        shotTimeAgo.setVisibility(View.GONE);
    }

    commentAnimator = new CommentAnimator();
    commentsList.setItemAnimator(commentAnimator);
    adapter = new CommentsAdapter(shotDescription, commentFooter, shot.comments_count,
            getResources().getInteger(R.integer.comment_expand_collapse_duration));
    commentsList.setAdapter(adapter);
    commentsList.addItemDecoration(new InsetDividerDecoration(CommentViewHolder.class,
            res.getDimensionPixelSize(R.dimen.divider_height), res.getDimensionPixelSize(R.dimen.keyline_1),
            ContextCompat.getColor(this, R.color.divider)));
    if (shot.comments_count != 0) {
        loadComments();
    }
    checkLiked();
}