Search in sources :

Example 1 with Team

use of com.supercilex.robotscouter.data.model.Team in project Robot-Scouter by SUPERCILEX.

the class TeamDetailsDialog method updateUi.

private void updateUi() {
    if (mMedia != null && mName != null && mNameEditText != null && mMediaCapture != null && mWebsiteEditText != null) {
        Team team = mTeamHelper.getTeam();
        mMediaLoadProgress.setVisibility(View.VISIBLE);
        Glide.with(getContext()).load(team.getMedia()).apply(RequestOptions.circleCropTransform().error(R.drawable.ic_memory_grey_48dp).fallback(R.drawable.ic_memory_grey_48dp)).listener(new RequestListener<Drawable>() {

            @Override
            public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
                mMediaLoadProgress.setVisibility(View.GONE);
                return false;
            }

            @Override
            public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
                mMediaLoadProgress.setVisibility(View.GONE);
                return false;
            }
        }).into(mMedia);
        mName.setText(team.toString());
        mNameEditText.setText(team.getName());
        mMediaEditText.setText(team.getMedia());
        mWebsiteEditText.setText(team.getWebsite());
    }
}
Also used : Target(com.bumptech.glide.request.target.Target) RequestListener(com.bumptech.glide.request.RequestListener) Drawable(android.graphics.drawable.Drawable) Team(com.supercilex.robotscouter.data.model.Team) GlideException(com.bumptech.glide.load.engine.GlideException) Nullable(android.support.annotation.Nullable) DataSource(com.bumptech.glide.load.DataSource)

Example 2 with Team

use of com.supercilex.robotscouter.data.model.Team in project Robot-Scouter by SUPERCILEX.

the class TeamDetailsDialog method onClick.

@Override
public boolean onClick() {
    boolean isMediaValid = validateUrl(mMediaEditText.getText().toString(), mMediaInputLayout);
    boolean isWebsiteValid = validateUrl(mWebsiteEditText.getText().toString(), mWebsiteInputLayout);
    if (isWebsiteValid && isMediaValid) {
        Team team = mTeamHelper.getTeam();
        String rawName = mNameEditText.getText().toString();
        String name = TextUtils.isEmpty(rawName) ? null : rawName;
        if (!TextUtils.equals(team.getName(), name)) {
            team.setHasCustomName(!TextUtils.isEmpty(name));
            team.setName(name);
        }
        String media = formatUrl(mMediaEditText.getText().toString());
        if (!TextUtils.equals(team.getMedia(), media)) {
            team.setHasCustomMedia(!TextUtils.isEmpty(media));
            team.setMedia(media);
        }
        String website = formatUrl(mWebsiteEditText.getText().toString());
        if (!TextUtils.equals(team.getWebsite(), website)) {
            team.setHasCustomWebsite(!TextUtils.isEmpty(website));
            team.setWebsite(website);
        }
        mTeamHelper.forceUpdateTeam();
        mTeamHelper.forceRefresh();
        // If we are being called from TeamListFragment, reset the menu if the click was consumed
        Fragment fragment = getParentFragment();
        if (fragment instanceof TeamListFragment) {
            ((TeamListFragment) fragment).resetMenu();
        }
        return true;
    } else {
        return false;
    }
}
Also used : TeamListFragment(com.supercilex.robotscouter.ui.teamlist.TeamListFragment) Team(com.supercilex.robotscouter.data.model.Team) TeamListFragment(com.supercilex.robotscouter.ui.teamlist.TeamListFragment) Fragment(android.support.v4.app.Fragment)

Example 3 with Team

use of com.supercilex.robotscouter.data.model.Team in project Robot-Scouter by SUPERCILEX.

the class ScoutListFragmentBase method addListeners.

private void addListeners() {
    if (TextUtils.isEmpty(mTeamHelper.getTeam().getKey())) {
        for (int i = 0; i < Constants.sFirebaseTeams.size(); i++) {
            Team team = Constants.sFirebaseTeams.getObject(i);
            if (team.getNumberAsLong() == mTeamHelper.getTeam().getNumberAsLong()) {
                mTeamHelper.getTeam().setKey(team.getKey());
                addListeners();
                return;
            }
        }
        mTeamHelper.addTeam();
        addListeners();
        TbaDownloader.Companion.load(mTeamHelper.getTeam(), getContext()).addOnSuccessListener(team -> mTeamHelper.updateTeam(team));
    } else {
        Constants.sFirebaseTeams.addChangeEventListener(this);
    }
}
Also used : Team(com.supercilex.robotscouter.data.model.Team)

Example 4 with Team

use of com.supercilex.robotscouter.data.model.Team in project Robot-Scouter by SUPERCILEX.

the class TeamHelper method copyMediaInfo.

public void copyMediaInfo(TeamHelper newHelper) {
    Team currentTeam = getTeam();
    Team newTeam = newHelper.getTeam();
    currentTeam.setMedia(newTeam.getMedia());
    currentTeam.setShouldUploadMediaToTba(newTeam.getShouldUploadMediaToTba() != null);
    currentTeam.setMediaYear(Calendar.getInstance().get(Calendar.YEAR));
}
Also used : Team(com.supercilex.robotscouter.data.model.Team)

Example 5 with Team

use of com.supercilex.robotscouter.data.model.Team in project Robot-Scouter by SUPERCILEX.

the class TeamMenuHelper method setTeamSpecificItemsVisible.

private void setTeamSpecificItemsVisible(boolean visible) {
    mVisitTbaWebsiteItem.setVisible(visible);
    mVisitTeamWebsiteItem.setVisible(visible);
    mEditTeamDetailsItem.setVisible(visible);
    if (visible) {
        Team team = mSelectedTeams.get(0).getTeam();
        mVisitTbaWebsiteItem.setTitle(mFragment.getString(R.string.visit_team_website_on_tba, team.getNumber()));
        mVisitTeamWebsiteItem.setTitle(mFragment.getString(R.string.visit_team_website, team.getNumber()));
    }
}
Also used : Team(com.supercilex.robotscouter.data.model.Team)

Aggregations

Team (com.supercilex.robotscouter.data.model.Team)6 Drawable (android.graphics.drawable.Drawable)1 Nullable (android.support.annotation.Nullable)1 Fragment (android.support.v4.app.Fragment)1 DataSource (com.bumptech.glide.load.DataSource)1 GlideException (com.bumptech.glide.load.engine.GlideException)1 RequestListener (com.bumptech.glide.request.RequestListener)1 Target (com.bumptech.glide.request.target.Target)1 DatabaseReference (com.google.firebase.database.DatabaseReference)1 TeamHelper (com.supercilex.robotscouter.data.util.TeamHelper)1 TeamListFragment (com.supercilex.robotscouter.ui.teamlist.TeamListFragment)1