use of io.plaidapp.ui.widget.ForegroundImageView in project sbt-android by scala-android.
the class DribbbleShot method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dribbble_shot);
shot = getIntent().getParcelableExtra(EXTRA_SHOT);
setupDribbble();
setExitSharedElementCallback(fabLoginSharedElementCallback);
getWindow().getSharedElementReturnTransition().addListener(shotReturnHomeListener);
Resources res = getResources();
ButterKnife.bind(this);
View shotDescription = getLayoutInflater().inflate(R.layout.dribbble_shot_description, commentsList, false);
shotSpacer = shotDescription.findViewById(R.id.shot_spacer);
title = shotDescription.findViewById(R.id.shot_title);
description = (TextView) shotDescription.findViewById(R.id.shot_description);
shotActions = (LinearLayout) shotDescription.findViewById(R.id.shot_actions);
likeCount = (Button) shotDescription.findViewById(R.id.shot_like_count);
viewCount = (Button) shotDescription.findViewById(R.id.shot_view_count);
share = (Button) shotDescription.findViewById(R.id.shot_share_action);
playerName = (TextView) shotDescription.findViewById(R.id.player_name);
playerAvatar = (ImageView) shotDescription.findViewById(R.id.player_avatar);
shotTimeAgo = (TextView) shotDescription.findViewById(R.id.shot_time_ago);
commentsList = (ListView) findViewById(R.id.dribbble_comments);
commentsList.addHeaderView(shotDescription);
View enterCommentView = getLayoutInflater().inflate(R.layout.dribbble_enter_comment, commentsList, false);
userAvatar = (ForegroundImageView) enterCommentView.findViewById(R.id.avatar);
enterComment = (EditText) enterCommentView.findViewById(R.id.comment);
postComment = (ImageButton) enterCommentView.findViewById(R.id.post_comment);
enterComment.setOnFocusChangeListener(enterCommentFocus);
commentsList.addFooterView(enterCommentView);
commentsList.setOnScrollListener(scrollListener);
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
expandImageAndFinish();
}
});
fab.setOnClickListener(fabClick);
chromeFader = new ElasticDragDismissFrameLayout.SystemChromeFader(getWindow()) {
@Override
public void onDragDismissed() {
expandImageAndFinish();
}
};
circleTransform = new CircleTransform(this);
// load the main image
Glide.with(this).load(shot.images.best()).listener(shotLoadListener).diskCacheStrategy(DiskCacheStrategy.SOURCE).priority(Priority.IMMEDIATE).into(imageView);
imageView.setOnClickListener(shotClick);
shotSpacer.setOnClickListener(shotClick);
postponeEnterTransition();
imageView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
imageView.getViewTreeObserver().removeOnPreDrawListener(this);
calculateFabPosition();
enterAnimation();
startPostponedEnterTransition();
return true;
}
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
((FabOverlapTextView) title).setText(shot.title);
} else {
((TextView) title).setText(shot.title);
}
if (!TextUtils.isEmpty(shot.description)) {
HtmlUtils.setTextWithNiceLinks(description, shot.getParsedDescription(description));
} else {
description.setVisibility(View.GONE);
}
NumberFormat nf = NumberFormat.getInstance();
likeCount.setText(res.getQuantityString(R.plurals.likes, (int) shot.likes_count, nf.format(shot.likes_count)));
// TODO onClick show likes
viewCount.setText(res.getQuantityString(R.plurals.views, (int) shot.views_count, nf.format(shot.views_count)));
share.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new ShareDribbbleImageTask(DribbbleShot.this, shot).execute();
}
});
if (shot.user != null) {
playerName.setText("–" + shot.user.name);
Glide.with(this).load(shot.user.avatar_url).transform(circleTransform).placeholder(R.drawable.avatar_placeholder).into(playerAvatar);
playerAvatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DribbbleShot.this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(shot.user.html_url)));
}
});
if (shot.created_at != null) {
shotTimeAgo.setText(DateUtils.getRelativeTimeSpanString(shot.created_at.getTime(), System.currentTimeMillis(), DateUtils.SECOND_IN_MILLIS));
}
} else {
playerName.setVisibility(View.GONE);
playerAvatar.setVisibility(View.GONE);
shotTimeAgo.setVisibility(View.GONE);
}
if (shot.comments_count > 0) {
loadComments();
} else {
commentsList.setAdapter(getNoCommentsAdapter());
}
if (dribbblePrefs.isLoggedIn() && !TextUtils.isEmpty(dribbblePrefs.getUserAvatar())) {
Glide.with(this).load(dribbblePrefs.getUserAvatar()).transform(circleTransform).placeholder(R.drawable.ic_player).into(userAvatar);
}
}
Aggregations