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