Search in sources :

Example 1 with DomainAdapter

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

the class BaseLoginFindSchoolActivity method bindViews.

private void bindViews() {
    mToolbar = findViewById(R.id.toolbar);
    mDomainInput = findViewById(R.id.domainInput);
    mWhatsYourSchoolName = findViewById(R.id.whatsYourSchoolName);
    mLoginFlowLogout = findViewById(R.id.loginFlowLogout);
    mToolbar.setNavigationIcon(ContextCompat.getDrawable(this, R.drawable.ic_action_arrow_back));
    mToolbar.setNavigationContentDescription(R.string.close);
    mToolbar.inflateMenu(R.menu.menu_next);
    mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            if (item.getItemId() == R.id.next) {
                validateDomain(new AccountDomain(mDomainInput.getText().toString()));
                return true;
            }
            return false;
        }
    });
    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            finish();
        }
    });
    AccessibilityManager a11yManager = ((AccessibilityManager) getSystemService(Context.ACCESSIBILITY_SERVICE));
    if (a11yManager != null && (a11yManager.isEnabled() || a11yManager.isTouchExplorationEnabled())) {
        mToolbar.setFocusable(true);
        mToolbar.setFocusableInTouchMode(true);
        mToolbar.postDelayed(new Runnable() {

            @Override
            public void run() {
                mToolbar.requestFocus();
                mToolbar.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
            }
        }, 500);
    }
    mNextActionButton = findViewById(R.id.next);
    mNextActionButton.setEnabled(false);
    mNextActionButton.setTextColor(ContextCompat.getColor(BaseLoginFindSchoolActivity.this, R.color.login_grayCanvasLogo));
    mDomainInput.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            validateDomain(new AccountDomain(mDomainInput.getText().toString()));
            return true;
        }
    });
    mDomainInput.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            if (mDomainAdapter != null) {
                mDomainAdapter.getFilter().filter(s);
                fetchAccountDomains();
            }
            if (mNextActionButton != null) {
                if (TextUtils.isEmpty(s.toString())) {
                    mNextActionButton.setEnabled(false);
                    mNextActionButton.setTextColor(ContextCompat.getColor(BaseLoginFindSchoolActivity.this, R.color.login_grayCanvasLogo));
                } else {
                    mNextActionButton.setEnabled(true);
                    mNextActionButton.setTextColor(ContextCompat.getColor(BaseLoginFindSchoolActivity.this, R.color.login_loginFlowBlue));
                }
            }
        }
    });
    mDomainAdapter = new DomainAdapter(new DomainAdapter.DomainEvents() {

        @Override
        public void onDomainClick(AccountDomain account) {
            mDomainInput.setText(account.getDomain());
            mDomainInput.setSelection(mDomainInput.getText().length());
            validateDomain(account);
        }

        @Override
        public void onHelpClick() {
            ZendeskDialogStyled dialog = new ZendeskDialogStyled();
            dialog.setArguments(ZendeskDialogStyled.createBundle(true, true));
            dialog.show(getSupportFragmentManager(), ZendeskDialogStyled.TAG);
        }
    });
    RecyclerView recyclerView = findViewById(R.id.findSchoolRecyclerView);
    recyclerView.addItemDecoration(new DividerItemDecoration(this, RecyclerView.VERTICAL));
    recyclerView.setLayoutManager(new LinearLayoutManager(this, RecyclerView.VERTICAL, false));
    recyclerView.setAdapter(mDomainAdapter);
}
Also used : ZendeskDialogStyled(com.instructure.loginapi.login.api.zendesk.utilities.ZendeskDialogStyled) AccountDomain(com.instructure.canvasapi2.models.AccountDomain) MenuItem(android.view.MenuItem) DomainAdapter(com.instructure.loginapi.login.adapter.DomainAdapter) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) KeyEvent(android.view.KeyEvent) AccessibilityManager(android.view.accessibility.AccessibilityManager) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 Toolbar (android.support.v7.widget.Toolbar)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 KeyEvent (android.view.KeyEvent)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 AccessibilityManager (android.view.accessibility.AccessibilityManager)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 AccountDomain (com.instructure.canvasapi2.models.AccountDomain)1 DomainAdapter (com.instructure.loginapi.login.adapter.DomainAdapter)1 ZendeskDialogStyled (com.instructure.loginapi.login.api.zendesk.utilities.ZendeskDialogStyled)1