Search in sources :

Example 1 with AccountDomain

use of com.instructure.canvasapi2.models.AccountDomain in project instructure-android by instructure.

the class DomainAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
    if (holder instanceof ViewHolder) {
        ViewHolder viewHolder = (ViewHolder) holder;
        AccountDomain account = mDisplayAccounts.get(position);
        if (account.getName() == null || account.getName().length() == 0) {
            viewHolder.schoolDomain.setText(account.getDomain());
        } else {
            viewHolder.schoolDomain.setText(account.getName());
        }
        holder.itemView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (mCallback != null) {
                    mCallback.onDomainClick(mDisplayAccounts.get(holder.getAdapterPosition()));
                }
            }
        });
    } else if (holder instanceof FooterViewHolder) {
        FooterViewHolder viewHolder = (FooterViewHolder) holder;
        viewHolder.itemView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (mCallback != null) {
                    mCallback.onHelpClick();
                }
            }
        });
    }
}
Also used : AccountDomain(com.instructure.canvasapi2.models.AccountDomain) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 2 with AccountDomain

use of com.instructure.canvasapi2.models.AccountDomain in project instructure-android by instructure.

the class AccountDomainAPI method searchAccounts.

public static void searchAccounts(final String query, final StatusCallback<List<AccountDomain>> callback) {
    if (query == null || query.length() < 3)
        return;
    final RestBuilder adapter = new RestBuilder(callback);
    final RestParams params = new RestParams.Builder().withShouldIgnoreToken(true).withPerPageQueryParam(true).withForceReadFromCache(false).withForceReadFromNetwork(true).withDomain(DEFAULT_DOMAIN).build();
    if (query.contains(".")) {
        callback.addCall(adapter.build(AccountDomainInterface.class, params).campusDomainSearch(query)).enqueue(callback);
    } else {
        callback.addCall(adapter.build(AccountDomainInterface.class, params).campusNameSearch(query)).enqueue(callback);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 3 with AccountDomain

use of com.instructure.canvasapi2.models.AccountDomain in project instructure-android by instructure.

the class AccountDomainAPI method getAllAccountDomains.

public static void getAllAccountDomains(final StatusCallback<List<AccountDomain>> callback) {
    final RestBuilder adapter = new RestBuilder(callback);
    final RestParams params = new RestParams.Builder().withShouldIgnoreToken(true).withPerPageQueryParam(true).withForceReadFromCache(false).withForceReadFromNetwork(true).withDomain(DEFAULT_DOMAIN).build();
    if (StatusCallback.isFirstPage(callback.getLinkHeaders())) {
        callback.addCall(adapter.build(AccountDomainInterface.class, params).getDomains()).enqueue(callback);
    } else if (StatusCallback.moreCallsExist(callback.getLinkHeaders()) && callback.getLinkHeaders() != null) {
        callback.addCall(adapter.build(AccountDomainInterface.class, params).next(callback.getLinkHeaders().nextUrl)).enqueue(callback);
    }
}
Also used : RestParams(com.instructure.canvasapi2.builders.RestParams) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder) RestBuilder(com.instructure.canvasapi2.builders.RestBuilder)

Example 4 with AccountDomain

use of com.instructure.canvasapi2.models.AccountDomain 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)

Example 5 with AccountDomain

use of com.instructure.canvasapi2.models.AccountDomain in project instructure-android by instructure.

the class BaseLoginFindSchoolActivity method createAccountForDebugging.

private AccountDomain createAccountForDebugging(String domain) {
    AccountDomain account = new AccountDomain();
    account.setDomain(domain);
    account.setName("@ " + domain);
    account.setDistance(0);
    return account;
}
Also used : AccountDomain(com.instructure.canvasapi2.models.AccountDomain)

Aggregations

AccountDomain (com.instructure.canvasapi2.models.AccountDomain)3 RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 TextView (android.widget.TextView)2 RestBuilder (com.instructure.canvasapi2.builders.RestBuilder)2 RestParams (com.instructure.canvasapi2.builders.RestParams)2 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)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 AccessibilityManager (android.view.accessibility.AccessibilityManager)1 ImageView (android.widget.ImageView)1 DomainAdapter (com.instructure.loginapi.login.adapter.DomainAdapter)1 ZendeskDialogStyled (com.instructure.loginapi.login.api.zendesk.utilities.ZendeskDialogStyled)1