Example usage for twitter4j Status isFavorited

List of usage examples for twitter4j Status isFavorited

Introduction

In this page you can find the example usage for twitter4j Status isFavorited.

Prototype

boolean isFavorited();

Source Link

Document

Test if the status is favorited

Usage

From source file:com.freshdigitable.udonroad.StatusDetailFragment.java

License:Apache License

@Override
public void onStart() {
    super.onStart();

    final long statusId = getStatusId();
    statusRequestWorker.open();/*  w w  w  .  ja  v  a  2s  .  c o m*/
    final TypedCache<Status> statusCache = statusRequestWorker.getCache();
    final Status status = statusCache.find(statusId);
    if (status == null) {
        Toast.makeText(getContext(), "status is not found", Toast.LENGTH_SHORT).show();
        return;
    }

    final StatusDetailView statusView = binding.statusView;
    StatusViewImageHelper.load(status, statusView);
    final User user = StatusViewImageHelper.getBindingUser(status);

    final ImageView icon = statusView.getIcon();
    final OnUserIconClickedListener userIconClickedListener = createUserIconClickedListener();
    icon.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            userIconClickedListener.onUserIconClicked(view, user);
        }
    });
    statusView.getUserName().setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            userIconClickedListener.onUserIconClicked(icon, user);
        }
    });
    statusView.getMediaContainer().setOnMediaClickListener(new OnMediaClickListener() {
        @Override
        public void onMediaClicked(View view, int index) {
            MediaViewActivity.start(view.getContext(), status, index);
        }
    });

    setTintList(binding.sdFav.getDrawable(), R.color.selector_fav_icon);
    binding.sdFav.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (status.isFavorited()) {
                statusRequestWorker.destroyFavorite(statusId);
            } else {
                statusRequestWorker.createFavorite(statusId);
            }
        }
    });
    setTintList(binding.sdRetweet.getDrawable(), R.color.selector_rt_icon);
    binding.sdRetweet.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (status.isRetweeted()) {
                statusRequestWorker.destroyRetweet(statusId);
            } else {
                statusRequestWorker.retweetStatus(statusId);
            }
        }
    });
    DrawableCompat.setTint(binding.sdReply.getDrawable(),
            ContextCompat.getColor(getContext(), R.color.twitter_action_normal));
    binding.sdReply.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            setupInput(TweetInputFragment.TYPE_REPLY);
        }
    });
    setTintList(binding.sdQuote.getDrawable(), R.color.twitter_action_normal);
    binding.sdQuote.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            setupInput(TweetInputFragment.TYPE_QUOTE);
        }
    });

    subscription = statusCache.observeById(statusId).subscribe(new Action1<Status>() {
        @Override
        public void call(Status status) {
            binding.statusView.bindStatus(status);
            binding.sdFav.setActivated(status.isFavorited());
            binding.sdRetweet.setActivated(status.isRetweeted());
        }
    });

    final Status bindingStatus = StatusViewImageHelper.getBindingStatus(status);
    if (bindingStatus.getURLEntities().length < 1) {
        return;
    }
    if (twitterCard != null) {
        setupTwitterCard(twitterCard);
    } else {
        TwitterCardFetcher.observeFetch(bindingStatus.getURLEntities()[0].getExpandedURL())
                .observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<TwitterCard>() {
                    @Override
                    public void call(final TwitterCard twitterCard) {
                        setupTwitterCard(twitterCard);
                    }
                }, new Action1<Throwable>() {
                    @Override
                    public void call(Throwable throwable) {
                        Log.e(TAG, "card fetch: ", throwable);
                    }
                });
    }
}

From source file:com.freshdigitable.udonroad.StatusViewBase.java

License:Apache License

protected void bindFavorite(Status bindingStatus) {
    final int favCount = bindingStatus.getFavoriteCount();
    if (favCount > 0) {
        this.setFavCountVisibility(VISIBLE);
        setTint(favIcon,//from   ww w  .  ja  v  a2 s  .com
                bindingStatus.isFavorited() ? R.color.twitter_action_faved : R.color.twitter_action_normal);
        this.favCount.setText(String.valueOf(favCount));
    }
}

From source file:com.freshdigitable.udonroad.TimelineInstTestBase.java

License:Apache License

protected void setupCreateFavorite(final int rtCount, final int favCount) throws TwitterException {
    when(twitter.createFavorite(anyLong())).thenAnswer(new Answer<Status>() {
        @Override//from   ww  w .  ja  v  a 2 s  . c  o m
        public Status answer(InvocationOnMock invocation) throws Throwable {
            final Long id = invocation.getArgumentAt(0, Long.class);
            final Status status = findByStatusId(id);
            when(status.getFavoriteCount()).thenReturn(favCount);
            when(status.getRetweetCount()).thenReturn(rtCount);
            when(status.isFavorited()).thenReturn(true);
            return status;
        }
    });
}

From source file:com.github.jcustenborder.kafka.connect.twitter.StatusConverter.java

License:Apache License

public static void convert(Status status, Struct struct) {
    struct.put("CreatedAt", status.getCreatedAt()).put("Id", status.getId()).put("Text", status.getText())
            .put("Source", status.getSource()).put("Truncated", status.isTruncated())
            .put("InReplyToStatusId", status.getInReplyToStatusId())
            .put("InReplyToUserId", status.getInReplyToUserId())
            .put("InReplyToScreenName", status.getInReplyToScreenName()).put("Favorited", status.isFavorited())
            .put("Retweeted", status.isRetweeted()).put("FavoriteCount", status.getFavoriteCount())
            .put("Retweet", status.isRetweet()).put("RetweetCount", status.getRetweetCount())
            .put("RetweetedByMe", status.isRetweetedByMe())
            .put("CurrentUserRetweetId", status.getCurrentUserRetweetId())
            .put("PossiblySensitive", status.isPossiblySensitive()).put("Lang", status.getLang());

    Struct userStruct;/*from  w  w w. j  a v a2 s.  c  o m*/
    if (null != status.getUser()) {
        userStruct = new Struct(USER_SCHEMA);
        convert(status.getUser(), userStruct);
    } else {
        userStruct = null;
    }
    struct.put("User", userStruct);

    Struct placeStruct;
    if (null != status.getPlace()) {
        placeStruct = new Struct(PLACE_SCHEMA);
        convert(status.getPlace(), placeStruct);
    } else {
        placeStruct = null;
    }
    struct.put("Place", placeStruct);

    Struct geoLocationStruct;
    if (null != status.getGeoLocation()) {
        geoLocationStruct = new Struct(GEO_LOCATION_SCHEMA);
        convert(status.getGeoLocation(), geoLocationStruct);
    } else {
        geoLocationStruct = null;
    }
    struct.put("GeoLocation", geoLocationStruct);
    List<Long> contributers = new ArrayList<>();

    if (null != status.getContributors()) {
        for (Long l : status.getContributors()) {
            contributers.add(l);
        }
    }
    struct.put("Contributors", contributers);

    List<String> withheldInCountries = new ArrayList<>();
    if (null != status.getWithheldInCountries()) {
        for (String s : status.getWithheldInCountries()) {
            withheldInCountries.add(s);
        }
    }
    struct.put("WithheldInCountries", withheldInCountries);

    struct.put("HashtagEntities", convert(status.getHashtagEntities()));
    struct.put("UserMentionEntities", convert(status.getUserMentionEntities()));
    struct.put("MediaEntities", convert(status.getMediaEntities()));
    struct.put("SymbolEntities", convert(status.getSymbolEntities()));
    struct.put("URLEntities", convert(status.getURLEntities()));
}

From source file:com.javielinux.infos.InfoTweet.java

License:Apache License

public InfoTweet(Status status) {
    urls = new ArrayList<URLContent>();
    mTypeFrom = FROM_STATUS;/*from w  ww .  j  a  va2s.c om*/
    id = status.getId();
    urlAvatar = status.getUser().getProfileImageURL().toString();
    userId = status.getUser().getId();
    text = status.getText();
    username = status.getUser().getScreenName();
    fullname = status.getUser().getName();
    source = status.getSource();
    toUsername = status.getInReplyToScreenName();
    toUserId = status.getInReplyToUserId();
    createAt = status.getCreatedAt();
    toReplyId = status.getInReplyToStatusId();
    favorited = status.isFavorited();
    if (status.getGeoLocation() != null) {
        latitude = status.getGeoLocation().getLatitude();
        longitude = status.getGeoLocation().getLongitude();
    }
    if (status.getRetweetedStatus() != null) {
        retweet = true;
        urlAvatarRetweet = status.getRetweetedStatus().getUser().getProfileImageURL().toString();
        textRetweet = status.getRetweetedStatus().getText();
        usernameRetweet = status.getRetweetedStatus().getUser().getScreenName();
        fullnameRetweet = status.getRetweetedStatus().getUser().getName();
        sourceRetweet = status.getRetweetedStatus().getSource();
    }

    urlTweet = "http://twitter.com/#!/" + username.toLowerCase() + PREFIX_URL_TWITTER + id;

    calculateLinks();
}

From source file:com.klinker.android.twitter.activities.tweet_viewer.fragments.TweetFragment.java

License:Apache License

public void getInfo(final View favButton, final TextView favCount, final TextView retweetCount,
        final long tweetId, final View retweetButton) {

    Thread getInfo = new Thread(new Runnable() {
        @Override/*from  w  w  w  . j a va 2 s. co  m*/
        public void run() {
            String location = "";
            String via = "";
            long realTime = 0;
            boolean retweetedByMe = false;
            try {
                Twitter twitter = getTwitter();

                TwitterMultipleImageHelper helper = new TwitterMultipleImageHelper();
                status = twitter.showStatus(tweetId);

                ArrayList<String> i = new ArrayList<String>();

                if (picture) {
                    i = helper.getImageURLs(status, twitter);
                }

                final ArrayList<String> images = i;

                GeoLocation loc = status.getGeoLocation();
                try {
                    Geocoder geocoder = new Geocoder(context, Locale.getDefault());
                    List<Address> addresses = geocoder.getFromLocation(loc.getLatitude(), loc.getLongitude(),
                            1);
                    if (addresses.size() > 0) {
                        Address address = addresses.get(0);
                        location += address.getLocality() + ", " + address.getCountryName();
                    } else {
                        location = "";
                    }
                } catch (Exception x) {
                    location = "";
                }

                via = android.text.Html.fromHtml(status.getSource()).toString();

                final String sfavCount;
                if (status.isRetweet()) {
                    twitter4j.Status status2 = status.getRetweetedStatus();
                    via = android.text.Html.fromHtml(status2.getSource()).toString();
                    realTime = status2.getCreatedAt().getTime();
                    sfavCount = status2.getFavoriteCount() + "";
                } else {
                    realTime = status.getCreatedAt().getTime();
                    sfavCount = status.getFavoriteCount() + "";
                }

                retweetedByMe = status.isRetweetedByMe();
                final String retCount = "" + status.getRetweetCount();

                final String timeDisplay;

                if (!settings.militaryTime) {
                    timeDisplay = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.US).format(realTime)
                            + " " + DateFormat.getTimeInstance(DateFormat.SHORT, Locale.US).format(realTime);
                } else {
                    timeDisplay = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.GERMAN).format(realTime)
                            + " "
                            + DateFormat.getTimeInstance(DateFormat.SHORT, Locale.GERMAN).format(realTime);
                }
                final String fVia = " " + getResources().getString(R.string.via) + " " + via;
                final String fLoc = location.equals("") ? "" : "\n" + location;

                final boolean fRet = retweetedByMe;
                final long fTime = realTime;
                final Status fStatus = status;
                ((Activity) context).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        retweetCount.setText(" " + retCount);

                        if (retweetButton instanceof ImageButton) {
                            if (fRet) {
                                if (!settings.addonTheme) {
                                    ((ImageButton) retweetButton)
                                            .setColorFilter(context.getResources().getColor(R.color.app_color));
                                } else {
                                    ((ImageButton) retweetButton).setColorFilter(settings.accentInt);
                                }
                            } else {
                                ((ImageButton) retweetButton).clearColorFilter();
                            }
                        } else {
                            if (fRet) {
                                if (!settings.addonTheme) {
                                    retweetButton.setBackgroundColor(
                                            context.getResources().getColor(R.color.app_color));
                                } else {
                                    retweetButton.setBackgroundColor(settings.accentInt);
                                }
                            } else {
                                retweetButton.setBackgroundColor(
                                        getResources().getColor(android.R.color.transparent));
                            }
                        }

                        timetv.setText(timeDisplay + fVia);
                        timetv.append(fLoc);

                        favCount.setText(" " + sfavCount);

                        if (favButton instanceof ImageButton) {
                            if (fStatus.isFavorited()) {
                                TypedArray a = context.getTheme()
                                        .obtainStyledAttributes(new int[] { R.attr.favoritedButton });
                                int resource = a.getResourceId(0, 0);
                                a.recycle();

                                if (!settings.addonTheme) {
                                    ((ImageButton) favButton)
                                            .setColorFilter(context.getResources().getColor(R.color.app_color));
                                } else {
                                    ((ImageButton) favButton).setColorFilter(settings.accentInt);
                                }

                                ((ImageButton) favButton)
                                        .setImageDrawable(context.getResources().getDrawable(resource));
                                isFavorited = true;
                            } else {
                                TypedArray a = context.getTheme()
                                        .obtainStyledAttributes(new int[] { R.attr.notFavoritedButton });
                                int resource = a.getResourceId(0, 0);
                                a.recycle();

                                ((ImageButton) favButton)
                                        .setImageDrawable(context.getResources().getDrawable(resource));
                                isFavorited = false;

                                ((ImageButton) favButton).clearColorFilter();
                            }
                        } else {
                            if (fStatus.isFavorited()) {
                                TypedArray a = context.getTheme()
                                        .obtainStyledAttributes(new int[] { R.attr.favoritedButton });
                                int resource = a.getResourceId(0, 0);
                                a.recycle();

                                if (!settings.addonTheme) {
                                    favButton.setBackgroundColor(
                                            context.getResources().getColor(R.color.app_color));
                                } else {
                                    favButton.setBackgroundColor(settings.accentInt);
                                }

                                isFavorited = true;
                            } else {
                                isFavorited = false;

                                favButton.setBackgroundColor(
                                        getResources().getColor(android.R.color.transparent));
                            }
                        }

                        for (String s : images) {
                            Log.v("talon_image", s);
                        }
                        if (images.size() > 1) {
                            Log.v("talon_images", "size: " + images.size());
                            try {
                                mAttacher.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {
                                    @Override
                                    public void onViewTap(View view, float x, float y) {
                                        Intent viewPics = new Intent(context, ViewPictures.class);
                                        viewPics.putExtra("images", images);
                                        startActivity(viewPics);
                                    }
                                });
                            } catch (Exception e) {
                                // addon theme without the attacher
                                profilePic.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View v) {
                                        Intent viewPics = new Intent(context, ViewPictures.class);
                                        viewPics.putExtra("images", images);
                                        startActivity(viewPics);
                                    }
                                });
                            }
                        }

                    }
                });
            } catch (Exception e) {

            }
        }
    });

    getInfo.setPriority(Thread.MAX_PRIORITY);
    getInfo.start();
}

From source file:com.klinker.android.twitter.adapters.TimeLineCursorAdapter.java

License:Apache License

public void getCounts(final ViewHolder holder, final long tweetId) {

    Thread getCount = new Thread(new Runnable() {
        @Override//w ww. ja v a2s  .  c o  m
        public void run() {
            try {
                Twitter twitter = Utils.getTwitter(context, settings);
                final Status status;
                if (holder.retweeter.getVisibility() != View.GONE) {
                    status = twitter.showStatus(holder.tweetId).getRetweetedStatus();
                } else {
                    status = twitter.showStatus(tweetId);
                }

                if (status != null && holder.tweetId == tweetId) {
                    ((Activity) context).runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            holder.favCount.setText(" " + status.getFavoriteCount());
                            holder.retweetCount.setText(" " + status.getRetweetCount());

                            if (status.isFavorited()) {
                                TypedArray a = context.getTheme()
                                        .obtainStyledAttributes(new int[] { R.attr.favoritedButton });
                                int resource = a.getResourceId(0, 0);
                                a.recycle();

                                if (!settings.addonTheme) {
                                    holder.favorite
                                            .setColorFilter(context.getResources().getColor(R.color.app_color));
                                } else {
                                    holder.favorite.setColorFilter(settings.accentInt);
                                }

                                holder.favorite.setImageDrawable(context.getResources().getDrawable(resource));
                                holder.isFavorited = true;
                            } else {
                                TypedArray a = context.getTheme()
                                        .obtainStyledAttributes(new int[] { R.attr.notFavoritedButton });
                                int resource = a.getResourceId(0, 0);
                                a.recycle();

                                holder.favorite.setImageDrawable(context.getResources().getDrawable(resource));
                                holder.isFavorited = false;

                                holder.favorite.clearColorFilter();
                            }

                            if (status.isRetweetedByMe()) {
                                if (!settings.addonTheme) {
                                    holder.retweet
                                            .setColorFilter(context.getResources().getColor(R.color.app_color));
                                } else {
                                    holder.retweet.setColorFilter(settings.accentInt);
                                }
                            } else {
                                holder.retweet.clearColorFilter();
                            }
                        }
                    });
                }

            } catch (Exception e) {

            }
        }
    });

    getCount.setPriority(7);
    getCount.start();
}

From source file:com.klinker.android.twitter.ui.tweet_viewer.fragments.TweetFragment.java

License:Apache License

public void getFavoriteCount(final TextView favs, final View favButton, final long tweetId) {
    new Thread(new Runnable() {
        @Override/*w w  w  .  j  ava2s  .co m*/
        public void run() {
            try {
                Twitter twitter = Utils.getTwitter(context, settings);
                twitter4j.Status status = twitter.showStatus(tweetId);
                if (status.isRetweet()) {
                    twitter4j.Status retweeted = status.getRetweetedStatus();
                    status = retweeted;
                }

                final twitter4j.Status fStatus = status;
                ((Activity) context).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        favs.setText(" " + fStatus.getFavoriteCount());

                        if (fStatus.isFavorited()) {
                            TypedArray a = context.getTheme()
                                    .obtainStyledAttributes(new int[] { R.attr.favoritedButton });
                            int resource = a.getResourceId(0, 0);
                            a.recycle();

                            if (favButton instanceof ImageButton) {
                                if (!settings.addonTheme) {
                                    ((ImageButton) favButton)
                                            .setColorFilter(context.getResources().getColor(R.color.app_color));
                                } else {
                                    ((ImageButton) favButton).setColorFilter(settings.accentInt);
                                }

                                ((ImageButton) favButton)
                                        .setImageDrawable(context.getResources().getDrawable(resource));
                            } else if (favButton instanceof LinearLayout) {
                                if (!settings.addonTheme) {
                                    favButton.setBackgroundColor(
                                            context.getResources().getColor(R.color.app_color));
                                } else {
                                    favButton.setBackgroundColor(settings.accentInt);
                                }
                            }
                            isFavorited = true;
                        } else {
                            TypedArray a = context.getTheme()
                                    .obtainStyledAttributes(new int[] { R.attr.notFavoritedButton });
                            int resource = a.getResourceId(0, 0);
                            a.recycle();

                            if (favButton instanceof ImageButton) {
                                ((ImageButton) favButton)
                                        .setImageDrawable(context.getResources().getDrawable(resource));
                                isFavorited = false;

                                ((ImageButton) favButton).clearColorFilter();
                            } else {
                                favButton.setBackgroundColor(
                                        getResources().getColor(android.R.color.transparent));
                            }
                        }
                    }
                });
            } catch (Exception e) {

            }
        }
    }).start();
}

From source file:com.klinker.android.twitter.ui.tweet_viewer.fragments.TweetFragment.java

License:Apache License

public void getInfo(final View favButton, final TextView favCount, final TextView retweetCount,
        final long tweetId, final View retweetButton) {

    Thread getInfo = new Thread(new Runnable() {
        @Override//from  www  . j ava  2 s. c  o  m
        public void run() {
            String location = "";
            String via = "";
            long realTime = 0;
            boolean retweetedByMe = false;
            try {
                Twitter twitter = Utils.getTwitter(context, settings);

                TwitterMultipleImageHelper helper = new TwitterMultipleImageHelper();
                status = twitter.showStatus(tweetId);

                ArrayList<String> i = new ArrayList<String>();

                if (picture) {
                    i = helper.getImageURLs(status, twitter);
                }

                final ArrayList<String> images = i;

                GeoLocation loc = status.getGeoLocation();
                try {
                    Geocoder geocoder = new Geocoder(context, Locale.getDefault());
                    List<Address> addresses = geocoder.getFromLocation(loc.getLatitude(), loc.getLongitude(),
                            1);
                    if (addresses.size() > 0) {
                        Address address = addresses.get(0);
                        location += address.getLocality() + ", " + address.getCountryName();
                    } else {
                        location = "";
                    }
                } catch (Exception x) {
                    location = "";
                }

                via = android.text.Html.fromHtml(status.getSource()).toString();

                final String sfavCount;
                if (status.isRetweet()) {
                    twitter4j.Status status2 = status.getRetweetedStatus();
                    via = android.text.Html.fromHtml(status2.getSource()).toString();
                    realTime = status2.getCreatedAt().getTime();
                    sfavCount = status2.getFavoriteCount() + "";
                } else {
                    realTime = status.getCreatedAt().getTime();
                    sfavCount = status.getFavoriteCount() + "";
                }

                retweetedByMe = status.isRetweetedByMe();
                final String retCount = "" + status.getRetweetCount();

                final String timeDisplay;

                if (!settings.militaryTime) {
                    timeDisplay = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.US).format(realTime)
                            + " " + DateFormat.getTimeInstance(DateFormat.SHORT, Locale.US).format(realTime);
                } else {
                    timeDisplay = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.GERMAN).format(realTime)
                            + " "
                            + DateFormat.getTimeInstance(DateFormat.SHORT, Locale.GERMAN).format(realTime);
                }
                final String fVia = " " + getResources().getString(R.string.via) + " " + via;
                final String fLoc = location.equals("") ? "" : "\n" + location;

                final boolean fRet = retweetedByMe;
                final long fTime = realTime;
                final Status fStatus = status;
                ((Activity) context).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {

                        // you can't retweet a protected account
                        if (status.getUser().isProtected()) {
                            retweetButton.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View v) {
                                    Toast.makeText(context, getString(R.string.protected_account),
                                            Toast.LENGTH_SHORT).show();
                                }
                            });
                        }

                        retweetCount.setText(" " + retCount);

                        if (retweetButton instanceof ImageButton) {
                            if (fRet) {
                                if (!settings.addonTheme) {
                                    ((ImageButton) retweetButton)
                                            .setColorFilter(context.getResources().getColor(R.color.app_color));
                                } else {
                                    ((ImageButton) retweetButton).setColorFilter(settings.accentInt);
                                }
                            } else {
                                ((ImageButton) retweetButton).clearColorFilter();
                            }
                        } else {
                            if (fRet) {
                                if (!settings.addonTheme) {
                                    retweetButton.setBackgroundColor(
                                            context.getResources().getColor(R.color.app_color));
                                } else {
                                    retweetButton.setBackgroundColor(settings.accentInt);
                                }
                            } else {
                                retweetButton.setBackgroundColor(
                                        getResources().getColor(android.R.color.transparent));
                            }
                        }

                        timetv.setText(timeDisplay + fVia);
                        timetv.append(fLoc);

                        favCount.setText(" " + sfavCount);

                        if (favButton instanceof ImageButton) {
                            if (fStatus.isFavorited()) {
                                TypedArray a = context.getTheme()
                                        .obtainStyledAttributes(new int[] { R.attr.favoritedButton });
                                int resource = a.getResourceId(0, 0);
                                a.recycle();

                                if (!settings.addonTheme) {
                                    ((ImageButton) favButton)
                                            .setColorFilter(context.getResources().getColor(R.color.app_color));
                                } else {
                                    ((ImageButton) favButton).setColorFilter(settings.accentInt);
                                }

                                ((ImageButton) favButton)
                                        .setImageDrawable(context.getResources().getDrawable(resource));
                                isFavorited = true;
                            } else {
                                TypedArray a = context.getTheme()
                                        .obtainStyledAttributes(new int[] { R.attr.notFavoritedButton });
                                int resource = a.getResourceId(0, 0);
                                a.recycle();

                                ((ImageButton) favButton)
                                        .setImageDrawable(context.getResources().getDrawable(resource));
                                isFavorited = false;

                                ((ImageButton) favButton).clearColorFilter();
                            }
                        } else {
                            if (fStatus.isFavorited()) {
                                TypedArray a = context.getTheme()
                                        .obtainStyledAttributes(new int[] { R.attr.favoritedButton });
                                int resource = a.getResourceId(0, 0);
                                a.recycle();

                                if (!settings.addonTheme) {
                                    favButton.setBackgroundColor(
                                            context.getResources().getColor(R.color.app_color));
                                } else {
                                    favButton.setBackgroundColor(settings.accentInt);
                                }

                                isFavorited = true;
                            } else {
                                isFavorited = false;

                                favButton.setBackgroundColor(
                                        getResources().getColor(android.R.color.transparent));
                            }
                        }

                        for (String s : images) {
                            Log.v("talon_image", s);
                        }
                        if (images.size() > 1) {
                            Log.v("talon_images", "size: " + images.size());
                            try {
                                mAttacher.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {
                                    @Override
                                    public void onViewTap(View view, float x, float y) {
                                        Intent viewPics = new Intent(context, ViewPictures.class);
                                        viewPics.putExtra("images", images);
                                        startActivity(viewPics);
                                    }
                                });
                            } catch (Exception e) {
                                // addon theme without the attacher
                                profilePic.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View v) {
                                        Intent viewPics = new Intent(context, ViewPictures.class);
                                        viewPics.putExtra("images", images);
                                        startActivity(viewPics);
                                    }
                                });
                            }
                        }

                    }
                });
            } catch (Exception e) {

            }
        }
    });

    getInfo.setPriority(Thread.MAX_PRIORITY);
    getInfo.start();
}

From source file:com.raythos.sentilexo.twitter.domain.QueryResultItemMapper.java

License:Apache License

public static Map getFieldsMapFromStatus(String queryOwner, String queryName, String queryString,
        Status status) {

    if (queryName != null)
        queryName = queryName.toLowerCase();
    if (queryOwner != null)
        queryOwner = queryOwner.toLowerCase();
    Map m = StatusArraysHelper.getUserMentionMap(status);
    Map newMap = new HashMap();
    for (Object key : m.keySet()) {
        newMap.put(key.toString(), (Long) m.get(key));
    }//from   w w  w .  j  av  a 2 s.c  om
    Double longitude = null;
    Double lattitude = null;
    if (status.getGeoLocation() != null) {
        longitude = status.getGeoLocation().getLongitude();
        lattitude = status.getGeoLocation().getLatitude();
    }
    String place = null;
    if (status.getPlace() != null) {
        place = status.getPlace().getFullName();
    }

    boolean isRetweet = status.getRetweetedStatus() != null;
    Long retweetedId = null;
    String retweetedText = null;
    if (isRetweet) {
        retweetedId = status.getRetweetedStatus().getId();
        retweetedText = status.getRetweetedStatus().getText();
    }

    Map<String, Object> result = new HashMap<>();
    result.put(QueryResultItemFieldNames.STATUS_ID, status.getId());
    result.put(QueryResultItemFieldNames.CREATED_AT, status.getCreatedAt());
    result.put(QueryResultItemFieldNames.CURRENT_USER_RETWEET_ID, status.getCurrentUserRetweetId());
    result.put(QueryResultItemFieldNames.FAVOURITE_COUNT, status.getFavoriteCount());
    result.put(QueryResultItemFieldNames.FAVOURITED, status.isFavorited());
    result.put(QueryResultItemFieldNames.HASHTAGS, StatusArraysHelper.getHashTagsList(status));
    result.put(QueryResultItemFieldNames.IN_REPLY_TO_SCREEN_NAME, (status.getInReplyToScreenName()));
    result.put(QueryResultItemFieldNames.IN_REPLY_TO_STATUS_ID, status.getInReplyToStatusId());
    result.put(QueryResultItemFieldNames.IN_REPLY_TO_USER_ID, status.getInReplyToUserId());
    result.put(QueryResultItemFieldNames.LATITUDE, lattitude);
    result.put(QueryResultItemFieldNames.LONGITUDE, longitude);
    result.put(QueryResultItemFieldNames.MENTIONS, newMap);
    result.put(QueryResultItemFieldNames.LANGUAGE, status.getLang());
    result.put(QueryResultItemFieldNames.PLACE, place);
    result.put(QueryResultItemFieldNames.POSSIBLY_SENSITIVE, status.isPossiblySensitive());
    result.put(QueryResultItemFieldNames.QUERY_NAME, queryName);
    result.put(QueryResultItemFieldNames.QUERY_OWNER, queryOwner);
    result.put(QueryResultItemFieldNames.QUERY, queryString);
    result.put(QueryResultItemFieldNames.RELEVANT_QUERY_TERMS,
            TwitterUtils.relevantQueryTermsFromStatus(queryString, status));
    result.put(QueryResultItemFieldNames.RETWEET, isRetweet);
    result.put(QueryResultItemFieldNames.RETWEET_COUNT, status.getRetweetCount());
    result.put(QueryResultItemFieldNames.RETWEETED, status.isRetweeted());
    result.put(QueryResultItemFieldNames.RETWEETED_BY_ME, status.isRetweetedByMe());
    result.put(QueryResultItemFieldNames.RETWEET_STATUS_ID, retweetedId);
    result.put(QueryResultItemFieldNames.RETWEETED_TEXT, retweetedText);
    result.put(QueryResultItemFieldNames.SCOPES, StatusArraysHelper.getScopesList(status));
    result.put(QueryResultItemFieldNames.SCREEN_NAME, status.getUser().getScreenName());
    result.put(QueryResultItemFieldNames.SOURCE, (status.getSource()));
    result.put(QueryResultItemFieldNames.TEXT, (status.getText()));
    result.put(QueryResultItemFieldNames.TRUNCATED, status.isTruncated());
    result.put(QueryResultItemFieldNames.URLS, StatusArraysHelper.getUrlsList(status));
    result.put(QueryResultItemFieldNames.USER_ID, status.getUser().getId());
    result.put(QueryResultItemFieldNames.USER_NAME, (status.getUser().getName()));
    result.put(QueryResultItemFieldNames.USER_DESCRIPTION, (status.getUser().getDescription()));
    result.put(QueryResultItemFieldNames.USER_LOCATION, (status.getUser().getLocation()));
    result.put(QueryResultItemFieldNames.USER_URL, (status.getUser().getURL()));
    result.put(QueryResultItemFieldNames.USER_IS_PROTECTED, status.getUser().isProtected());
    result.put(QueryResultItemFieldNames.USER_FOLLOWERS_COUNT, status.getUser().getFollowersCount());
    result.put(QueryResultItemFieldNames.USER_CREATED_AT, status.getUser().getCreatedAt());
    result.put(QueryResultItemFieldNames.USER_FRIENDS_COUNT, status.getUser().getFriendsCount());
    result.put(QueryResultItemFieldNames.USER_LISTED_COUNT, status.getUser().getListedCount());
    result.put(QueryResultItemFieldNames.USER_STATUSES_COUNT, status.getUser().getStatusesCount());
    result.put(QueryResultItemFieldNames.USER_FAVOURITES_COUNT, status.getUser().getFavouritesCount());
    return result;
}