Search in sources :

Example 6 with ActivityOptionsCompat

use of android.support.v4.app.ActivityOptionsCompat in project Hummingbird-for-Android by xiprox.

the class FeedTimelineAdapter method getInfiniteScrollListView.

@Override
public View getInfiniteScrollListView(final int position, View convertView, ViewGroup parent) {
    if (getCount() != 0) {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        rootView = new View(context);
        final Story item = mItems.get(position);
        storyType = item.getStoryType();
        if (storyType.equals(Story.STORY_TYPE_COMMENT))
            rootView = inflater.inflate(R.layout.item_story_comment, null);
        else if (storyType.equals(Story.STORY_TYPE_MEDIA))
            rootView = inflater.inflate(R.layout.item_story_media, null);
        if (storyType.equals(Story.STORY_TYPE_COMMENT)) {
            FrameLayout mAvatarHolder = (FrameLayout) rootView.findViewById(R.id.item_story_comment_avatar_holder);
            ImageView mAvatar = (ImageView) rootView.findViewById(R.id.item_story_comment_avatar);
            TextView mUsername = (TextView) rootView.findViewById(R.id.item_story_comment_username);
            RelativeTimeTextView mTime = (RelativeTimeTextView) rootView.findViewById(R.id.item_story_comment_time);
            TextView mText = (TextView) rootView.findViewById(R.id.item_story_comment_text);
            mAvatarHolder.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(context, ProfileActivity.class);
                    intent.putExtra(ProfileActivity.ARG_USERNAME, item.getPoster().getName());
                    context.startActivity(intent);
                }
            });
            /* The following 2 won't be used until we find out how to obtain the necessary data */
            View mDivider = rootView.findViewById(R.id.item_story_comment_divider);
            LinearLayout mComments = (LinearLayout) rootView.findViewById(R.id.item_story_comment_comments);
            Picasso.with(context).load(item.getPoster().getAvatar()).transform(new CircleTransformation()).into(mAvatar);
            mUsername.setText(item.getPoster().getName());
            for (Substory substory : item.getSubstories()) {
                if (substory.getSubstoryType().equals(Substory.SUBSTORY_TYPE_COMMENT)) {
                    mTime.setReferenceTime(substory.getCreatedAt());
                    mText.setText(substory.getComment());
                }
            }
        }
        if (storyType.equals(Story.STORY_TYPE_MEDIA)) {
            final CardView mCard = (CardView) rootView.findViewById(R.id.item_story_media_card);
            FrameLayout mCoverHolder = (FrameLayout) rootView.findViewById(R.id.item_story_media_cover_holder);
            final ImageView mCover = (ImageView) rootView.findViewById(R.id.item_story_media_cover);
            final TextView mTitle = (TextView) rootView.findViewById(R.id.item_story_media_title);
            final LinearLayout mSubstories = (LinearLayout) rootView.findViewById(R.id.item_story_media_substories);
            final TextView mMoreIndicator = (TextView) rootView.findViewById(R.id.item_story_media_more);
            AbsListView.LayoutParams params = new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, Utils.dpToPx(context, 160));
            rootView.setLayoutParams(params);
            expanded[position] = false;
            mCoverHolder.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    Intent intent = new Intent(context, AnimeDetailsActivity.class);
                    intent.putExtra(AnimeDetailsActivity.ARG_ID, item.getMedia().getId());
                    intent.putExtra(AnimeDetailsActivity.ARG_ANIME_OBJ, item.getMedia());
                    ActivityOptionsCompat transition = ActivityOptionsCompat.makeSceneTransitionAnimation((Activity) context, Pair.create((View) mCover, "anime_cover"));
                    Utils.startActivityWithTransition(context, intent, transition);
                }
            });
            /* Hide the VIEW MORE button if there are no more than a single substory */
            if (item.getSubstoriesCount() == 1)
                mMoreIndicator.setVisibility(View.GONE);
            if (item.getSubstoriesCount() > 1) {
                rootView.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View view) {
                        if (!expanded[position]) {
                            for (int i = 0; i < mSubstories.getChildCount(); i++) {
                                View v = mSubstories.getChildAt(i);
                                v.setVisibility(View.VISIBLE);
                            }
                            AbsListView.LayoutParams params = new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, AbsListView.LayoutParams.WRAP_CONTENT);
                            mCard.setLayoutParams(params);
                            expanded[position] = true;
                        } else {
                            for (int i = 0; i < mSubstories.getChildCount(); i++) {
                                if (i > 0) {
                                    View v = mSubstories.getChildAt(i);
                                    v.setVisibility(View.GONE);
                                }
                            }
                            AbsListView.LayoutParams params = new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, Utils.dpToPx(context, 160));
                            mCard.setLayoutParams(params);
                            expanded[position] = false;
                            notifyDataSetChanged();
                        }
                    }
                });
            }
            Picasso.with(context).load(item.getMedia().getCoverImage()).into(mCover);
            mTitle.setText(item.getMedia().getTitle());
            List<Substory> sortedSubstories = Utils.sortSubstoriesByDate(item.getSubstories());
            mSubstories.removeAllViews();
            for (Substory substory : sortedSubstories) {
                View view = inflater.inflate(R.layout.item_substory, null);
                FrameLayout avatarHolder = (FrameLayout) view.findViewById(R.id.item_substory_avatar_holder);
                ImageView avatar = (ImageView) view.findViewById(R.id.item_substory_avatar);
                TextView username = (TextView) view.findViewById(R.id.item_substory_username);
                RelativeTimeTextView time = (RelativeTimeTextView) view.findViewById(R.id.item_substory_time);
                Picasso.with(context).load(item.getUser().getAvatar()).transform(new CircleTransformation()).into(avatar);
                avatarHolder.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View view) {
                        Intent intent = new Intent(context, ProfileActivity.class);
                        intent.putExtra(ProfileActivity.ARG_USERNAME, item.getUser().getName());
                        context.startActivity(intent);
                    }
                });
                username.setText(item.getUser().getName());
                time.setReferenceTime(substory.getCreatedAt());
                if (substory.getSubstoryType().equals(Substory.SUBSTORY_TYPE_WATCHED_EPISODE)) {
                    String textToSet = getString(R.string.content_watched_episode) + " " + substory.getEpisodeNumber();
                    ((TextView) view.findViewById(R.id.item_substory_text)).setText(textToSet);
                }
                if (substory.getSubstoryType().equals(Substory.SUBSTORY_TYPE_WATCHLIST_STATUS_UPDATE)) {
                    String textToSet = "";
                    String watchlistStatusUpdate = substory.getNewStatus();
                    if (watchlistStatusUpdate.equals(Substory.WATCHLIST_STATUS_CURRENTLY_WATCHING))
                        textToSet = getString(R.string.content_is_currently_watching);
                    if (watchlistStatusUpdate.equals(Substory.WATCHLIST_STATUS_COMPLETED))
                        textToSet = getString(R.string.content_has_completed);
                    if (watchlistStatusUpdate.equals(Substory.WATCHLIST_STATUS_DROPPED))
                        textToSet = getString(R.string.content_has_dropped);
                    if (watchlistStatusUpdate.equals(Substory.WATCHLIST_STATUS_ON_HOLD))
                        textToSet = getString(R.string.content_has_placed_on_hold);
                    if (watchlistStatusUpdate.equals(Substory.WATCHLIST_STATUS_PLAN_TO_WATCH))
                        textToSet = getString(R.string.content_is_planning_to_watch);
                    ((TextView) view.findViewById(R.id.item_substory_text)).setText(textToSet);
                }
                if (mSubstories.getChildCount() >= 1)
                    view.setVisibility(View.GONE);
                mSubstories.addView(view);
            }
        }
        return rootView;
    } else
        return getInfiniteScrollListView(position, convertView, parent);
}
Also used : ProfileActivity(tr.bcxip.hummingbird.ProfileActivity) CardView(android.support.v7.widget.CardView) AbsListView(android.widget.AbsListView) AnimeDetailsActivity(tr.bcxip.hummingbird.AnimeDetailsActivity) ProfileActivity(tr.bcxip.hummingbird.ProfileActivity) Activity(android.app.Activity) Intent(android.content.Intent) RelativeTimeTextView(tr.bcxip.hummingbird.widget.RelativeTimeTextView) ImageView(android.widget.ImageView) RelativeTimeTextView(tr.bcxip.hummingbird.widget.RelativeTimeTextView) View(android.view.View) CardView(android.support.v7.widget.CardView) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat) CircleTransformation(tr.bcxip.hummingbird.utils.CircleTransformation) Substory(tr.bcxip.hummingbird.api.objects.Substory) LayoutInflater(android.view.LayoutInflater) FrameLayout(android.widget.FrameLayout) RelativeTimeTextView(tr.bcxip.hummingbird.widget.RelativeTimeTextView) TextView(android.widget.TextView) AnimeDetailsActivity(tr.bcxip.hummingbird.AnimeDetailsActivity) ImageView(android.widget.ImageView) Story(tr.bcxip.hummingbird.api.objects.Story) LinearLayout(android.widget.LinearLayout)

Example 7 with ActivityOptionsCompat

use of android.support.v4.app.ActivityOptionsCompat in project Hummingbird-for-Android by xiprox.

the class AnimeDetailsActivity method displayAnimeInfo.

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void displayAnimeInfo() {
    Resources res = getResources();
    final ImageView imageView = new ImageView(AnimeDetailsActivity.this);
    Picasso.with(AnimeDetailsActivity.this).load(anime.getCoverImage()).into(imageView, new Callback() {

        @Override
        public void onSuccess() {
            coverBitmap = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
        }

        @Override
        public void onError() {
        }
    });
    if (coverBitmap != null) {
        mPalette = Palette.generate(coverBitmap);
        if (mPalette != null) {
            darkMutedColor = mPalette.getDarkMutedColor(res.getColor(R.color.neutral_darker));
            vibrantColor = mPalette.getVibrantColor(res.getColor(R.color.apptheme_primary));
            darkVibrantColor = mPalette.getDarkVibrantColor(res.getColor(R.color.apptheme_primary_dark));
        }
    } else
        darkMutedColor = res.getColor(R.color.neutral_darker);
    float[] vibrantColorHsv = new float[3];
    Color.colorToHSV(vibrantColor, vibrantColorHsv);
    vibrantColorHsv[2] = 1.0f - 0.8f * (1.0f - vibrantColorHsv[2]);
    vibrantColorLighter = Color.HSVToColor(vibrantColorHsv);
    float[] darkMutedColorHsv = new float[3];
    Color.colorToHSV(darkMutedColor, darkMutedColorHsv);
    darkMutedColorHsv[2] = 1.0f - 0.9f * (1.0f - darkMutedColorHsv[2]);
    darkMutedColorLighter = Color.HSVToColor(darkMutedColorHsv);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        getWindow().setStatusBarColor(darkMutedColor);
    int alpha = mActionBarBackgroundDrawable.getAlpha();
    mActionBarBackgroundDrawable = new ColorDrawable(darkMutedColorLighter);
    mActionBarBackgroundDrawable.setAlpha(alpha);
    if (toolbar != null)
        toolbar.setBackgroundDrawable(mActionBarBackgroundDrawable);
    mActionButton.setOnClickListener(new OnAddToLibraryClickListener());
    mActionButton.setColorNormal(vibrantColor);
    mActionButton.setColorPressed(vibrantColorLighter);
    mCoverImage.setImageBitmap(coverBitmap);
    mCoverHolder.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent intent = new Intent(AnimeDetailsActivity.this, FullscreenImageActivity.class);
            intent.putExtra(FullscreenImageActivity.ARG_IMAGE_URL, anime.getCoverImage());
            ActivityOptionsCompat transition = ActivityOptionsCompat.makeSceneTransitionAnimation(AnimeDetailsActivity.this, mCoverImage, FullscreenImageActivity.TRANSITION_NAME_IMAGE);
            Utils.startActivityWithTransition(AnimeDetailsActivity.this, intent, transition);
        }
    });
    // TODO - Put something else here
    mHeaderImage.setImageBitmap(coverBitmap);
    mHeaderHolder.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent intent = new Intent(AnimeDetailsActivity.this, FullscreenImageActivity.class);
            intent.putExtra(FullscreenImageActivity.ARG_IMAGE_URL, anime.getCoverImage());
            ActivityOptionsCompat transition = ActivityOptionsCompat.makeSceneTransitionAnimation(AnimeDetailsActivity.this, mHeaderImage, FullscreenImageActivity.TRANSITION_NAME_IMAGE);
            Utils.startActivityWithTransition(AnimeDetailsActivity.this, intent, transition);
        }
    });
    mTitle.setText(anime.getTitle());
    mType.setText(anime.getShowType());
    /*
            TODO
            For some reason the API omits genres in the Anime object bundled with the Library Entry
            object. Gotta find a solution for this. God! I really don't wanna have to load all data
            just because of a few damn genres!
         */
    String genres = null;
    if (anime.getGenres() != null) {
        for (int i = 0; i < anime.getGenres().size(); i++) {
            if (i == 0)
                genres = anime.getGenres().get(i).getName();
            else
                genres += ", " + anime.getGenres().get(i).getName();
        }
    }
    mGenre.setText(genres != null ? genres : getString(R.string.content_unknown));
    int episodeCount = anime.getEpisodeCount();
    mEpisodeCount.setText(episodeCount != 0 ? episodeCount + "" : getString(R.string.content_unknown));
    int episodeLength = anime.getEpisodeLength();
    mEpisodeLength.setText(episodeLength != 0 ? episodeLength + " " + getString(R.string.content_minutes).toLowerCase() : getString(R.string.content_unknown));
    mAgeRating.setText(anime.getAgeRating() != null ? anime.getAgeRating() : getString(R.string.content_unknown));
    SimpleDateFormat airDateFormat = new SimpleDateFormat("d MMMM yyyy");
    long airStart = anime.getAiringStartDate();
    long airEnd = anime.getAiringFinishedDate();
    Date airStartDate = new Date(airStart);
    Date airEndDate = new Date(airEnd);
    Calendar todayCal = Calendar.getInstance();
    Calendar airStartCal = Calendar.getInstance();
    airStartCal.setTime(airStartDate);
    if (airStart == 0 && airEnd == 0)
        mAired.setText(R.string.content_not_yet_aired);
    if (airStart == 0 && airEnd != 0)
        mAired.setText(getString(R.string.content_unknown) + " " + getString(R.string.to) + " " + airDateFormat.format(airEnd));
    if (airStart != 0 && airEnd == 0) {
        if (anime.getEpisodeCount() == 1)
            mAired.setText(airDateFormat.format(airStart));
        else
            mAired.setText(getString(R.string.content_airing_since) + " " + airDateFormat.format(airStart));
    }
    if (airStart != 0 && airEnd != 0)
        mAired.setText(airDateFormat.format(airStart) + " " + getString(R.string.to) + " " + airDateFormat.format(airEnd));
    if (airStartCal.get(Calendar.YEAR) > todayCal.get(Calendar.YEAR)) {
        if (anime.getEpisodeCount() == 1)
            mAired.setText(getString(R.string.content_will_air_on) + " " + airDateFormat.format(airStart));
        else
            mAired.setText(getString(R.string.content_will_start_airing_on) + " " + airDateFormat.format(airStart));
    }
    String comRating = String.valueOf(anime.getCommunityRating());
    if (comRating.length() > 3)
        comRating = comRating.substring(0, 4);
    else if (comRating.equals("0.0"))
        comRating = "?";
    mCommunityRating.setText(comRating);
    mSynopsis.setText(anime.getSynopsis());
    mSynopsisHolder.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            MaterialDialog dialog = new MaterialDialog.Builder(AnimeDetailsActivity.this).title(anime.getTitle()).customView(R.layout.dialog_text, true).build();
            ((TextView) dialog.getCustomView()).setText(anime.getSynopsis());
            dialog.show();
        }
    });
    mMoreSimilarAnime.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
        // TODO - More similar activity...
        }
    });
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Calendar(java.util.Calendar) Intent(android.content.Intent) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ImageView(android.widget.ImageView) ObservableScrollView(tr.bcxip.hummingbird.widget.ObservableScrollView) View(android.view.View) AdapterView(android.widget.AdapterView) SimpleRatingView(tr.xip.widget.simpleratingview.SimpleRatingView) TextView(android.widget.TextView) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat) Date(java.util.Date) Callback(com.squareup.picasso.Callback) ColorDrawable(android.graphics.drawable.ColorDrawable) Resources(android.content.res.Resources) ImageView(android.widget.ImageView) SimpleDateFormat(java.text.SimpleDateFormat) TargetApi(android.annotation.TargetApi)

Example 8 with ActivityOptionsCompat

use of android.support.v4.app.ActivityOptionsCompat in project MaterialLogin by fanrunqi.

the class MainActivity method setListener.

private void setListener() {
    btGo.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Explode explode = new Explode();
            explode.setDuration(500);
            getWindow().setExitTransition(explode);
            getWindow().setEnterTransition(explode);
            ActivityOptionsCompat oc2 = ActivityOptionsCompat.makeSceneTransitionAnimation(MainActivity.this);
            Intent i2 = new Intent(MainActivity.this, LoginSuccessActivity.class);
            startActivity(i2, oc2.toBundle());
        }
    });
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            getWindow().setExitTransition(null);
            getWindow().setEnterTransition(null);
            ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(MainActivity.this, fab, fab.getTransitionName());
            startActivity(new Intent(MainActivity.this, RegisterActivity.class), options.toBundle());
        }
    });
}
Also used : Explode(android.transition.Explode) Intent(android.content.Intent) CardView(android.support.v7.widget.CardView) View(android.view.View) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat) ActivityOptions(android.app.ActivityOptions)

Example 9 with ActivityOptionsCompat

use of android.support.v4.app.ActivityOptionsCompat in project twicalico by moko256.

the class StatusView method updateView.

private void updateView() {
    final Status item = status.isRetweet() ? status.getRetweetedStatus() : status;
    if (status.isRetweet()) {
        if (retweetUserName.getVisibility() != View.VISIBLE) {
            retweetUserName.setVisibility(View.VISIBLE);
        }
        retweetUserName.setText(getContext().getString(R.string.repeat_by, status.getUser().getName()));
    } else {
        if (retweetUserName.getVisibility() != View.GONE) {
            retweetUserName.setVisibility(View.GONE);
        }
    }
    boolean isReply = item.getInReplyToScreenName() != null;
    if (isReply) {
        if (replyUserName.getVisibility() != View.VISIBLE) {
            replyUserName.setVisibility(View.VISIBLE);
        }
        replyUserName.setText(getContext().getString((item.getInReplyToStatusId() != -1) ? R.string.reply_to : R.string.mention_to, item.getInReplyToScreenName()));
    } else {
        if (replyUserName.getVisibility() != View.GONE) {
            replyUserName.setVisibility(View.GONE);
        }
    }
    if (status.isRetweet() || isReply) {
        if (headerBottomMargin.getVisibility() != VISIBLE) {
            headerBottomMargin.setVisibility(VISIBLE);
        }
    } else {
        if (headerBottomMargin.getVisibility() != GONE) {
            headerBottomMargin.setVisibility(GONE);
        }
    }
    if (GlobalApplication.configuration.isTimelineImageLoad) {
        glideRequests.load(item.getUser().get400x400ProfileImageURLHttps()).circleCrop().into(userImage);
    } else {
        userImage.setImageResource(R.drawable.border_frame_round);
    }
    userName.setText(item.getUser().getName());
    userId.setText(TwitterStringUtils.plusAtMark(item.getUser().getScreenName()));
    TwitterStringUtils.setLinkedSequenceTo(item, tweetContext);
    if (!tweetContext.getText().toString().trim().isEmpty()) {
        tweetContext.setMovementMethod(LinkMovementMethod.getInstance());
        if (tweetContext.getVisibility() != VISIBLE) {
            tweetContext.setVisibility(VISIBLE);
        }
    } else {
        tweetContext.setMovementMethod(null);
        if (tweetContext.getVisibility() != GONE) {
            tweetContext.setVisibility(GONE);
        }
    }
    timeStampText.setText(DateUtils.getRelativeTimeSpanString(item.getCreatedAt().getTime(), System.currentTimeMillis(), 0));
    userImage.setOnClickListener(v -> {
        ActivityOptionsCompat animation = ActivityOptionsCompat.makeSceneTransitionAnimation(((Activity) getContext()), v, "icon_image");
        getContext().startActivity(ShowUserActivity.getIntent(getContext(), item.getUser().getId()), animation.toBundle());
    });
    setOnClickListener(v -> {
        ActivityOptionsCompat animation = ActivityOptionsCompat.makeSceneTransitionAnimation(((Activity) getContext()), userImage, "icon_image");
        getContext().startActivity(ShowTweetActivity.getIntent(getContext(), item.getId()), animation.toBundle());
    });
    Status quotedStatus = item.getQuotedStatus();
    if (quotedStatus != null) {
        if (quoteTweetLayout.getVisibility() != View.VISIBLE) {
            quoteTweetLayout.setVisibility(View.VISIBLE);
        }
        quoteTweetLayout.setOnClickListener(v -> getContext().startActivity(ShowTweetActivity.getIntent(getContext(), quotedStatus.getId())));
        quoteTweetUserName.setText(quotedStatus.getUser().getName());
        quoteTweetUserId.setText(TwitterStringUtils.plusAtMark(quotedStatus.getUser().getScreenName()));
        quoteTweetContext.setText(quotedStatus.getText());
    } else {
        if (quoteTweetLayout.getVisibility() != View.GONE) {
            quoteTweetLayout.setVisibility(View.GONE);
        }
    }
    MediaEntity[] mediaEntities = item.getMediaEntities();
    if (mediaEntities.length != 0) {
        imageTableView.setVisibility(View.VISIBLE);
        imageTableView.setMediaEntities(mediaEntities, item.isPossiblySensitive());
    } else {
        imageTableView.setVisibility(View.GONE);
    }
    likeButton.setOnCheckedChangeListener((compoundButton, b) -> Single.create(subscriber -> {
        try {
            if (b && (!item.isFavorited())) {
                subscriber.onSuccess(GlobalApplication.twitter.createFavorite(item.getId()));
            } else if ((!b) && item.isFavorited()) {
                subscriber.onSuccess(GlobalApplication.twitter.destroyFavorite(item.getId()));
            }
        } catch (TwitterException e) {
            subscriber.onError(e);
        }
    }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(result -> {
        Status status = (Status) result;
        GlobalApplication.statusCache.add(status);
        setStatus(GlobalApplication.statusCache.get(this.status.getId()));
        Toast.makeText(getContext(), R.string.succeeded, Toast.LENGTH_SHORT).show();
    }, throwable -> {
        throwable.printStackTrace();
        Toast.makeText(getContext(), R.string.error_occurred, Toast.LENGTH_SHORT).show();
    }));
    likeButton.setChecked(item.isFavorited());
    retweetButton.setOnCheckedChangeListener((compoundButton, b) -> Single.create(subscriber -> {
        try {
            if (b && (!item.isRetweeted())) {
                subscriber.onSuccess(GlobalApplication.twitter.retweetStatus(item.getId()));
            } else if ((!b) && item.isRetweeted()) {
                subscriber.onSuccess(GlobalApplication.twitter.unRetweetStatus(item.getId()));
            }
        } catch (TwitterException e) {
            subscriber.onError(e);
        }
    }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(result -> {
        Status status = (Status) result;
        GlobalApplication.statusCache.add(status);
        setStatus(GlobalApplication.statusCache.get(this.status.getId()));
        Toast.makeText(getContext(), R.string.succeeded, Toast.LENGTH_SHORT).show();
    }, throwable -> {
        throwable.printStackTrace();
        Toast.makeText(getContext(), R.string.error_occurred, Toast.LENGTH_SHORT).show();
    }));
    retweetButton.setChecked(item.isRetweeted());
    retweetButton.setEnabled(GlobalApplication.clientType == Type.MASTODON || !(item.getUser().isProtected()) || item.getUser().getId() == GlobalApplication.userId);
    replyButton.setOnClickListener(v -> getContext().startActivity(PostActivity.getIntent(getContext(), item.getId(), TwitterStringUtils.convertToReplyTopString(GlobalApplication.userCache.get(GlobalApplication.userId).getScreenName(), item.getUser().getScreenName(), item.getUserMentionEntities()).toString())));
    likeCount.setText((item.getFavoriteCount() != 0) ? TwitterStringUtils.convertToSIUnitString(item.getFavoriteCount()) : "");
    retweetCount.setText((item.getRetweetCount() != 0) ? TwitterStringUtils.convertToSIUnitString(item.getRetweetCount()) : "");
}
Also used : Status(twitter4j.Status) Context(android.content.Context) ImageButton(android.widget.ImageButton) Type(com.github.moko256.twicalico.entity.Type) DateUtils(android.text.format.DateUtils) Space(android.widget.Space) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) LinkMovementMethod(android.text.method.LinkMovementMethod) TwitterStringUtils(com.github.moko256.twicalico.text.TwitterStringUtils) MediaEntity(twitter4j.MediaEntity) Single(rx.Single) AttributeSet(android.util.AttributeSet) CheckBox(android.widget.CheckBox) Toast(android.widget.Toast) Schedulers(rx.schedulers.Schedulers) View(android.view.View) TwitterException(twitter4j.TwitterException) LayoutInflater(android.view.LayoutInflater) TweetImageTableView(com.github.moko256.twicalico.widget.TweetImageTableView) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat) TextView(android.widget.TextView) Status(twitter4j.Status) RelativeLayout(android.widget.RelativeLayout) Activity(android.app.Activity) Activity(android.app.Activity) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat) TwitterException(twitter4j.TwitterException) MediaEntity(twitter4j.MediaEntity)

Example 10 with ActivityOptionsCompat

use of android.support.v4.app.ActivityOptionsCompat in project twicalico by moko256.

the class UsersAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(@NonNull ViewHolder viewHolder, final int i) {
    User item = GlobalApplication.userCache.get(data.get(i));
    glideRequests.load(item.get400x400ProfileImageURLHttps()).circleCrop().into(viewHolder.userUserImage);
    viewHolder.userUserName.setText(item.getName());
    viewHolder.userUserId.setText(TwitterStringUtils.plusAtMark(item.getScreenName()));
    viewHolder.itemView.setOnClickListener(v -> {
        ActivityOptionsCompat animation = ActivityOptionsCompat.makeSceneTransitionAnimation(((Activity) context), viewHolder.userUserImage, "icon_image");
        context.startActivity(ShowUserActivity.getIntent(context, item.getId()), animation.toBundle());
    });
    viewHolder.userLockIcon.setVisibility(item.isProtected() ? View.VISIBLE : View.GONE);
}
Also used : User(twitter4j.User) Activity(android.app.Activity) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat)

Aggregations

ActivityOptionsCompat (android.support.v4.app.ActivityOptionsCompat)92 Intent (android.content.Intent)72 View (android.view.View)31 Pair (android.support.v4.util.Pair)18 ImageView (android.widget.ImageView)15 TextView (android.widget.TextView)14 RecyclerView (android.support.v7.widget.RecyclerView)13 Activity (android.app.Activity)12 OnClick (butterknife.OnClick)7 ActivityOptions (android.app.ActivityOptions)4 Context (android.content.Context)4 Bundle (android.os.Bundle)4 Handler (android.os.Handler)4 BindView (butterknife.BindView)4 CardView (android.support.v7.widget.CardView)3 Explode (android.transition.Explode)3 AdapterView (android.widget.AdapterView)3 LinearLayout (android.widget.LinearLayout)3 Uri (android.net.Uri)2 LayoutInflater (android.view.LayoutInflater)2