Search in sources :

Example 6 with CircleTransform

use of io.plaidapp.util.glide.CircleTransform 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)

Example 7 with CircleTransform

use of io.plaidapp.util.glide.CircleTransform in project plaid by nickbutcher.

the class DribbbleShot method onCreate.

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_dribbble_shot);
    dribbblePrefs = DribbblePrefs.get(this);
    circleTransform = new CircleTransform(this);
    ButterKnife.bind(this);
    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 = shotDescription.findViewById(R.id.shot_description);
    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);
    setupCommenting();
    commentsList.addOnScrollListener(scrollListener);
    commentsList.setOnFlingListener(flingListener);
    back.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            setResultAndFinish();
        }
    });
    fab.setOnClickListener(fabClick);
    chromeFader = new ElasticDragDismissFrameLayout.SystemChromeFader(this) {

        @Override
        public void onDragDismissed() {
            setResultAndFinish();
        }
    };
    final Intent intent = getIntent();
    if (intent.hasExtra(EXTRA_SHOT)) {
        shot = intent.getParcelableExtra(EXTRA_SHOT);
        bindShot(true);
    } else if (intent.getData() != null) {
        final HttpUrl url = HttpUrl.parse(intent.getDataString());
        if (url.pathSize() == 2 && url.pathSegments().get(0).equals("shots")) {
            try {
                final String shotPath = url.pathSegments().get(1);
                final long id = Long.parseLong(shotPath.substring(0, shotPath.indexOf("-")));
                final Call<Shot> shotCall = dribbblePrefs.getApi().getShot(id);
                shotCall.enqueue(new Callback<Shot>() {

                    @Override
                    public void onResponse(Call<Shot> call, Response<Shot> response) {
                        shot = response.body();
                        bindShot(false);
                    }

                    @Override
                    public void onFailure(Call<Shot> call, Throwable t) {
                        reportUrlError();
                    }
                });
            } catch (NumberFormatException | StringIndexOutOfBoundsException ex) {
                reportUrlError();
            }
        } else {
            reportUrlError();
        }
    }
}
Also used : Call(retrofit2.Call) CircleTransform(io.plaidapp.util.glide.CircleTransform) CustomTabsIntent(android.support.customtabs.CustomTabsIntent) Intent(android.content.Intent) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) AuthorTextView(io.plaidapp.ui.widget.AuthorTextView) ForegroundImageView(io.plaidapp.ui.widget.ForegroundImageView) TextView(android.widget.TextView) FabOverlapTextView(io.plaidapp.ui.widget.FabOverlapTextView) ParallaxScrimageView(io.plaidapp.ui.widget.ParallaxScrimageView) RecyclerView(android.support.v7.widget.RecyclerView) HttpUrl(okhttp3.HttpUrl) Response(retrofit2.Response) ElasticDragDismissFrameLayout(io.plaidapp.ui.widget.ElasticDragDismissFrameLayout) Callback(retrofit2.Callback)

Example 8 with CircleTransform

use of io.plaidapp.util.glide.CircleTransform in project plaid by nickbutcher.

the class PlayerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_dribbble_player);
    ButterKnife.bind(this);
    circleTransform = new CircleTransform(this);
    chromeFader = new ElasticDragDismissFrameLayout.SystemChromeFader(this);
    final Intent intent = getIntent();
    if (intent.hasExtra(EXTRA_PLAYER)) {
        player = intent.getParcelableExtra(EXTRA_PLAYER);
        bindPlayer();
    } else if (intent.hasExtra(EXTRA_PLAYER_NAME)) {
        String name = intent.getStringExtra(EXTRA_PLAYER_NAME);
        playerName.setText(name);
        if (intent.hasExtra(EXTRA_PLAYER_ID)) {
            long userId = intent.getLongExtra(EXTRA_PLAYER_ID, 0L);
            loadPlayer(userId);
        } else if (intent.hasExtra(EXTRA_PLAYER_USERNAME)) {
            String username = intent.getStringExtra(EXTRA_PLAYER_USERNAME);
            loadPlayer(username);
        }
    } else if (intent.getData() != null) {
    // todo support url intents
    }
    // setup immersive mode i.e. draw behind the system chrome & adjust insets
    draggableFrame.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
    draggableFrame.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {

        @Override
        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
            final ViewGroup.MarginLayoutParams lpFrame = (ViewGroup.MarginLayoutParams) draggableFrame.getLayoutParams();
            // landscape
            lpFrame.leftMargin += insets.getSystemWindowInsetLeft();
            // landscape
            lpFrame.rightMargin += insets.getSystemWindowInsetRight();
            ((ViewGroup.MarginLayoutParams) avatar.getLayoutParams()).topMargin += insets.getSystemWindowInsetTop();
            ViewUtils.setPaddingTop(container, insets.getSystemWindowInsetTop());
            ViewUtils.setPaddingBottom(shots, insets.getSystemWindowInsetBottom());
            // clear this listener so insets aren't re-applied
            draggableFrame.setOnApplyWindowInsetsListener(null);
            return insets;
        }
    });
    setExitSharedElementCallback(FeedAdapter.createSharedElementReenterCallback(this));
}
Also used : ElasticDragDismissFrameLayout(io.plaidapp.ui.widget.ElasticDragDismissFrameLayout) WindowInsets(android.view.WindowInsets) ViewGroup(android.view.ViewGroup) CircleTransform(io.plaidapp.util.glide.CircleTransform) Intent(android.content.Intent) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView)

Example 9 with CircleTransform

use of io.plaidapp.util.glide.CircleTransform in project sbt-android by scala-android.

the class DesignerNewsLogin method showLoggedInUser.

private void showLoggedInUser() {
    DesignerNewsService designerNewsService = new RestAdapter.Builder().setEndpoint(DesignerNewsService.ENDPOINT).setRequestInterceptor(new ClientAuthInterceptor(designerNewsPrefs.getAccessToken(), BuildConfig.DESIGNER_NEWS_CLIENT_ID)).build().create(DesignerNewsService.class);
    designerNewsService.getAuthedUser(new Callback<UserResponse>() {

        @Override
        public void success(UserResponse userResponse, Response response) {
            final User user = userResponse.user;
            designerNewsPrefs.setLoggedInUser(user);
            Toast confirmLogin = new Toast(getApplicationContext());
            View v = LayoutInflater.from(DesignerNewsLogin.this).inflate(R.layout.toast_logged_in_confirmation, null, false);
            ((TextView) v.findViewById(R.id.name)).setText(user.display_name);
            // need to use app context here as the activity will be destroyed shortly
            Glide.with(getApplicationContext()).load(user.portrait_url).placeholder(R.drawable.avatar_placeholder).transform(new CircleTransform(getApplicationContext())).into((ImageView) v.findViewById(R.id.avatar));
            v.findViewById(R.id.scrim).setBackground(ScrimUtil.makeCubicGradientScrimDrawable(ContextCompat.getColor(DesignerNewsLogin.this, R.color.scrim), 5, Gravity.BOTTOM));
            confirmLogin.setView(v);
            confirmLogin.setGravity(Gravity.BOTTOM | Gravity.FILL_HORIZONTAL, 0, 0);
            confirmLogin.setDuration(Toast.LENGTH_LONG);
            confirmLogin.show();
        }

        @Override
        public void failure(RetrofitError error) {
            Log.e(getClass().getCanonicalName(), error.getMessage(), error);
        }
    });
}
Also used : User(io.plaidapp.data.api.designernews.model.User) CircleTransform(io.plaidapp.util.glide.CircleTransform) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) AutoCompleteTextView(android.widget.AutoCompleteTextView) UserResponse(io.plaidapp.data.api.designernews.model.UserResponse) UserResponse(io.plaidapp.data.api.designernews.model.UserResponse) Response(retrofit.client.Response) Toast(android.widget.Toast) DesignerNewsService(io.plaidapp.data.api.designernews.DesignerNewsService) ClientAuthInterceptor(io.plaidapp.data.api.ClientAuthInterceptor) ImageView(android.widget.ImageView) RetrofitError(retrofit.RetrofitError)

Aggregations

View (android.view.View)9 ImageView (android.widget.ImageView)9 TextView (android.widget.TextView)9 CircleTransform (io.plaidapp.util.glide.CircleTransform)9 BindView (butterknife.BindView)5 ElasticDragDismissFrameLayout (io.plaidapp.ui.widget.ElasticDragDismissFrameLayout)5 RecyclerView (android.support.v7.widget.RecyclerView)4 Toast (android.widget.Toast)4 AuthorTextView (io.plaidapp.ui.widget.AuthorTextView)4 Intent (android.content.Intent)3 ActivityOptions (android.app.ActivityOptions)2 CustomTabsIntent (android.support.customtabs.CustomTabsIntent)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 AutoCompleteTextView (android.widget.AutoCompleteTextView)2 Toolbar (android.widget.Toolbar)2 Bypass (in.uncod.android.bypass.Bypass)2 User (io.plaidapp.data.api.designernews.model.User)2 User (io.plaidapp.data.api.dribbble.model.User)2 FabOverlapTextView (io.plaidapp.ui.widget.FabOverlapTextView)2 ForegroundImageView (io.plaidapp.ui.widget.ForegroundImageView)2