Search in sources :

Example 1 with PreviousUsersAdapter

use of com.instructure.loginapi.login.adapter.PreviousUsersAdapter in project instructure-android by instructure.

the class BaseLoginLandingPageActivity method loadPreviousUsers.

private void loadPreviousUsers() {
    ArrayList<SignedInUser> previousUsers = PreviousUsersUtils.get(this);
    resizePreviousUsersRecyclerView(previousUsers);
    mPreviousLoginRecyclerView.setLayoutManager(new LinearLayoutManager(this, RecyclerView.VERTICAL, false));
    mPreviousLoginRecyclerView.setAdapter(new PreviousUsersAdapter(previousUsers, new PreviousUsersAdapter.PreviousUsersEvents() {

        @Override
        public void onPreviousUserClick(SignedInUser user) {
            ApiPrefs.setProtocol(user.protocol);
            ApiPrefs.setUser(user.user);
            ApiPrefs.setDomain(user.domain);
            ApiPrefs.setToken(user.token);
            Intent intent = launchApplicationMainActivityIntent();
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
            startActivity(intent);
            finish();
        }

        @Override
        public void onRemovePreviousUserClick(SignedInUser user, int position) {
            PreviousUsersUtils.remove(BaseLoginLandingPageActivity.this, user);
        }

        @Override
        public void onNowEmpty() {
            ObjectAnimator fade = ObjectAnimator.ofFloat(mPreviousLoginWrapper, View.ALPHA, 1F, 0F);
            ObjectAnimator move = ObjectAnimator.ofFloat(mPreviousLoginWrapper, View.TRANSLATION_Y, 0, mPreviousLoginWrapper.getTop());
            AnimatorSet set = new AnimatorSet();
            set.playTogether(fade, move);
            set.setDuration(430);
            set.start();
        }
    }));
    mPreviousLoginWrapper.setVisibility((previousUsers.size() > 0) ? View.VISIBLE : View.GONE);
}
Also used : SignedInUser(com.instructure.loginapi.login.model.SignedInUser) ObjectAnimator(android.animation.ObjectAnimator) PreviousUsersAdapter(com.instructure.loginapi.login.adapter.PreviousUsersAdapter) Intent(android.content.Intent) AnimatorSet(android.animation.AnimatorSet) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Aggregations

AnimatorSet (android.animation.AnimatorSet)1 ObjectAnimator (android.animation.ObjectAnimator)1 Intent (android.content.Intent)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 PreviousUsersAdapter (com.instructure.loginapi.login.adapter.PreviousUsersAdapter)1 SignedInUser (com.instructure.loginapi.login.model.SignedInUser)1