Search in sources :

Example 1 with ForegroundImageView

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);
    }
}
Also used : CircleTransform(io.plaidapp.util.glide.CircleTransform) CustomTabsIntent(android.support.customtabs.CustomTabsIntent) Intent(android.content.Intent) FabOverlapTextView(io.plaidapp.ui.widget.FabOverlapTextView) ImageView(android.widget.ImageView) View(android.view.View) AuthorTextView(io.plaidapp.ui.widget.AuthorTextView) ForegroundImageView(io.plaidapp.ui.widget.ForegroundImageView) TextView(android.widget.TextView) ListView(android.widget.ListView) FabOverlapTextView(io.plaidapp.ui.widget.FabOverlapTextView) ParallaxScrimageView(io.plaidapp.ui.widget.ParallaxScrimageView) AbsListView(android.widget.AbsListView) ElasticDragDismissFrameLayout(io.plaidapp.ui.widget.ElasticDragDismissFrameLayout) AuthorTextView(io.plaidapp.ui.widget.AuthorTextView) TextView(android.widget.TextView) FabOverlapTextView(io.plaidapp.ui.widget.FabOverlapTextView) Resources(android.content.res.Resources) ViewTreeObserver(android.view.ViewTreeObserver) NumberFormat(java.text.NumberFormat)

Aggregations

Intent (android.content.Intent)1 Resources (android.content.res.Resources)1 CustomTabsIntent (android.support.customtabs.CustomTabsIntent)1 View (android.view.View)1 ViewTreeObserver (android.view.ViewTreeObserver)1 AbsListView (android.widget.AbsListView)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 AuthorTextView (io.plaidapp.ui.widget.AuthorTextView)1 ElasticDragDismissFrameLayout (io.plaidapp.ui.widget.ElasticDragDismissFrameLayout)1 FabOverlapTextView (io.plaidapp.ui.widget.FabOverlapTextView)1 ForegroundImageView (io.plaidapp.ui.widget.ForegroundImageView)1 ParallaxScrimageView (io.plaidapp.ui.widget.ParallaxScrimageView)1 CircleTransform (io.plaidapp.util.glide.CircleTransform)1 NumberFormat (java.text.NumberFormat)1