Search in sources :

Example 1 with CircleTransform

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

the class DesignerNewsLogin method showLoggedInUser.

private void showLoggedInUser() {
    final Call<User> authedUser = designerNewsPrefs.getApi().getAuthedUser();
    authedUser.enqueue(new Callback<User>() {

        @Override
        public void onResponse(Call<User> call, Response<User> response) {
            final User user = response.body();
            designerNewsPrefs.setLoggedInUser(user);
            final Toast confirmLogin = new Toast(getApplicationContext());
            final 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.toLowerCase());
            // 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 onFailure(Call<User> call, Throwable t) {
            Log.e(getClass().getCanonicalName(), t.getMessage(), t);
        }
    });
}
Also used : User(io.plaidapp.data.api.designernews.model.User) Toast(android.widget.Toast) CircleTransform(io.plaidapp.util.glide.CircleTransform) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) TextView(android.widget.TextView) AutoCompleteTextView(android.widget.AutoCompleteTextView)

Example 2 with CircleTransform

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

the class DesignerNewsStory method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_designer_news_story);
    ButterKnife.bind(this);
    story = getIntent().getParcelableExtra(EXTRA_STORY);
    fab.setOnClickListener(fabClick);
    chromeFader = new ElasticDragDismissFrameLayout.SystemChromeFader(this);
    markdown = new Bypass(this, new Bypass.Options().setBlockQuoteLineColor(ContextCompat.getColor(this, R.color.designer_news_quote_line)).setBlockQuoteLineWidth(// dps
    2).setBlockQuoteLineIndent(// dps
    8).setPreImageLinebreakHeight(//dps
    4).setBlockQuoteIndentSize(TypedValue.COMPLEX_UNIT_DIP, 2f).setBlockQuoteTextColor(ContextCompat.getColor(this, R.color.designer_news_quote)));
    circleTransform = new CircleTransform(this);
    designerNewsPrefs = DesignerNewsPrefs.get(this);
    layoutManager = new LinearLayoutManager(this);
    commentsList.setLayoutManager(layoutManager);
    commentsList.setItemAnimator(new CommentAnimator(getResources().getInteger(R.integer.comment_expand_collapse_duration)));
    header = getLayoutInflater().inflate(R.layout.designer_news_story_description, commentsList, false);
    bindDescription();
    // setup title/toolbar
    if (collapsingToolbar != null) {
        // narrow device: collapsing toolbar
        collapsingToolbar.addOnLayoutChangeListener(titlebarLayout);
        collapsingToolbar.setTitle(story.title);
        final Toolbar toolbar = (Toolbar) findViewById(R.id.story_toolbar);
        toolbar.setNavigationOnClickListener(backClick);
        commentsList.addOnScrollListener(headerScrollListener);
        setEnterSharedElementCallback(new SharedElementCallback() {

            @Override
            public void onSharedElementStart(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
                ReflowText.setupReflow(getIntent(), collapsingToolbar);
            }

            @Override
            public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
                ReflowText.setupReflow(collapsingToolbar);
            }
        });
    } else {
        // w600dp configuration: content card scrolls over title bar
        final TextView title = (TextView) findViewById(R.id.story_title);
        title.setText(story.title);
        findViewById(R.id.back).setOnClickListener(backClick);
    }
    final View enterCommentView = setupCommentField();
    if (story.comment_count > 0) {
        // flatten the comments from a nested structure {@see Comment#comments} to a
        // list appropriate for our adapter (using the depth attribute).
        List<Comment> flattened = new ArrayList<>(story.comment_count);
        unnestComments(story.comments, flattened);
        commentsAdapter = new DesignerNewsCommentsAdapter(header, flattened, enterCommentView);
        commentsList.setAdapter(commentsAdapter);
    } else {
        commentsAdapter = new DesignerNewsCommentsAdapter(header, new ArrayList<Comment>(0), enterCommentView);
        commentsList.setAdapter(commentsAdapter);
    }
    customTab = new CustomTabActivityHelper();
    customTab.setConnectionCallback(customTabConnect);
}
Also used : ActivityOptions(android.app.ActivityOptions) Comment(io.plaidapp.data.api.designernews.model.Comment) ArrayList(java.util.ArrayList) CircleTransform(io.plaidapp.util.glide.CircleTransform) SpannableString(android.text.SpannableString) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) AuthorTextView(io.plaidapp.ui.widget.AuthorTextView) TextView(android.widget.TextView) PinnedOffsetView(io.plaidapp.ui.widget.PinnedOffsetView) RecyclerView(android.support.v7.widget.RecyclerView) ElasticDragDismissFrameLayout(io.plaidapp.ui.widget.ElasticDragDismissFrameLayout) CustomTabActivityHelper(io.plaidapp.util.customtabs.CustomTabActivityHelper) Bypass(in.uncod.android.bypass.Bypass) AuthorTextView(io.plaidapp.ui.widget.AuthorTextView) TextView(android.widget.TextView) SharedElementCallback(android.app.SharedElementCallback) Toolbar(android.widget.Toolbar)

Example 3 with CircleTransform

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

the class DribbbleLogin method showLoggedInUser.

void showLoggedInUser() {
    final Call<User> authenticatedUser = dribbblePrefs.getApi().getAuthenticatedUser();
    authenticatedUser.enqueue(new Callback<User>() {

        @Override
        public void onResponse(Call<User> call, Response<User> response) {
            final User user = response.body();
            dribbblePrefs.setLoggedInUser(user);
            final Toast confirmLogin = new Toast(getApplicationContext());
            final View v = LayoutInflater.from(DribbbleLogin.this).inflate(R.layout.toast_logged_in_confirmation, null, false);
            ((TextView) v.findViewById(R.id.name)).setText(user.name.toLowerCase());
            // need to use app context here as the activity will be destroyed shortly
            Glide.with(getApplicationContext()).load(user.avatar_url).placeholder(R.drawable.ic_player).transform(new CircleTransform(getApplicationContext())).into((ImageView) v.findViewById(R.id.avatar));
            v.findViewById(R.id.scrim).setBackground(ScrimUtil.makeCubicGradientScrimDrawable(ContextCompat.getColor(DribbbleLogin.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 onFailure(Call<User> call, Throwable t) {
        }
    });
}
Also used : User(io.plaidapp.data.api.dribbble.model.User) Toast(android.widget.Toast) CircleTransform(io.plaidapp.util.glide.CircleTransform) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) TextView(android.widget.TextView)

Example 4 with CircleTransform

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

the class DesignerNewsStory method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_designer_news_story);
    ButterKnife.bind(this);
    getWindow().getSharedElementReturnTransition().addListener(returnHomeListener);
    story = getIntent().getParcelableExtra(EXTRA_STORY);
    fab.setOnClickListener(fabClick);
    chromeFader = new ElasticDragDismissFrameLayout.SystemChromeFader(getWindow()) {

        @Override
        public void onDragDismissed() {
            finishAfterTransition();
        }
    };
    markdown = new Bypass(this, new Bypass.Options().setBlockQuoteLineColor(ContextCompat.getColor(this, R.color.designer_news_quote_line)).setBlockQuoteLineWidth(// dps
    2).setBlockQuoteLineIndent(// dps
    8).setPreImageLinebreakHeight(// dps
    4).setBlockQuoteIndentSize(TypedValue.COMPLEX_UNIT_DIP, 2f).setBlockQuoteTextColor(ContextCompat.getColor(this, R.color.designer_news_quote)));
    circleTransform = new CircleTransform(this);
    designerNewsPrefs = DesignerNewsPrefs.get(this);
    createDesignerNewsApi();
    layoutManager = new LinearLayoutManager(this);
    commentsList.setLayoutManager(layoutManager);
    header = getLayoutInflater().inflate(R.layout.designer_news_story_description, commentsList, false);
    bindDescription();
    // setup toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.story_toolbar);
    if (collapsingToolbar != null) {
        // portrait: collapsing toolbar
        collapsingToolbar.setTitle(story.title);
        collapsingToolbar.addOnLayoutChangeListener(titlebarLayout);
    } else {
        // landscape: scroll toolbar with content
        toolbar = (Toolbar) header.findViewById(R.id.story_toolbar);
        FontTextView title = (FontTextView) toolbar.findViewById(R.id.story_title);
        title.setText(story.title);
    }
    commentsList.addOnScrollListener(headerScrollListener);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            finishAfterTransition();
        }
    });
    View enterCommentView = setupCommentField();
    if (story.comment_count > 0) {
        // flatten the comments from a nested structure {@see Comment#comments} to an
        // array for our adapter (saving the depth).
        List<ThreadedComment> wrapped = new ArrayList<>(story.comment_count);
        addComments(story.comments, 0, wrapped);
        commentsAdapter = new DesignerNewsCommentsAdapter(header, wrapped, enterCommentView);
        commentsList.setAdapter(commentsAdapter);
    } else {
        commentsAdapter = new DesignerNewsCommentsAdapter(header, new ArrayList<ThreadedComment>(0), enterCommentView);
        commentsList.setAdapter(commentsAdapter);
    }
    customTab = new CustomTabActivityHelper();
    customTab.setConnectionCallback(customTabConnect);
    setEnterSharedElementCallback(sharedEnterCallback);
}
Also used : ActivityOptions(android.app.ActivityOptions) ArrayList(java.util.ArrayList) CircleTransform(io.plaidapp.util.glide.CircleTransform) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) View(android.view.View) AuthorTextView(io.plaidapp.ui.widget.AuthorTextView) TextView(android.widget.TextView) FontTextView(io.plaidapp.ui.widget.FontTextView) PinnedOffsetView(io.plaidapp.ui.widget.PinnedOffsetView) RecyclerView(android.support.v7.widget.RecyclerView) ElasticDragDismissFrameLayout(io.plaidapp.ui.widget.ElasticDragDismissFrameLayout) CustomTabActivityHelper(io.plaidapp.util.customtabs.CustomTabActivityHelper) Bypass(in.uncod.android.bypass.Bypass) FontTextView(io.plaidapp.ui.widget.FontTextView) Toolbar(android.widget.Toolbar)

Example 5 with CircleTransform

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

the class DribbbleLogin method showLoggedInUser.

private void showLoggedInUser() {
    Gson gson = new GsonBuilder().setDateFormat(DribbbleService.DATE_FORMAT).create();
    RestAdapter restAdapter = new RestAdapter.Builder().setEndpoint(DribbbleService.ENDPOINT).setConverter(new GsonConverter(gson)).setRequestInterceptor(new AuthInterceptor(dribbblePrefs.getAccessToken())).build();
    DribbbleService dribbbleApi = restAdapter.create((DribbbleService.class));
    dribbbleApi.getAuthenticatedUser(new Callback<User>() {

        @Override
        public void success(User user, Response response) {
            dribbblePrefs.setLoggedInUser(user);
            Toast confirmLogin = new Toast(getApplicationContext());
            View v = LayoutInflater.from(DribbbleLogin.this).inflate(R.layout.toast_logged_in_confirmation, null, false);
            ((TextView) v.findViewById(R.id.name)).setText(user.name);
            // need to use app context here as the activity will be destroyed shortly
            Glide.with(getApplicationContext()).load(user.avatar_url).placeholder(R.drawable.ic_player).transform(new CircleTransform(getApplicationContext())).into((ImageView) v.findViewById(R.id.avatar));
            v.findViewById(R.id.scrim).setBackground(ScrimUtil.makeCubicGradientScrimDrawable(ContextCompat.getColor(DribbbleLogin.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) {
        }
    });
}
Also used : GsonConverter(retrofit.converter.GsonConverter) User(io.plaidapp.data.api.dribbble.model.User) GsonBuilder(com.google.gson.GsonBuilder) GsonBuilder(com.google.gson.GsonBuilder) AuthInterceptor(io.plaidapp.data.api.AuthInterceptor) Gson(com.google.gson.Gson) CircleTransform(io.plaidapp.util.glide.CircleTransform) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) Response(retrofit.client.Response) DribbbleService(io.plaidapp.data.api.dribbble.DribbbleService) Toast(android.widget.Toast) ImageView(android.widget.ImageView) RestAdapter(retrofit.RestAdapter) 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