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);
}
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...
}
});
}
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());
}
});
}
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()) : "");
}
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);
}
Aggregations