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);
}
Aggregations