use of com.thebluealliance.androidclient.eventbus.ActionBarTitleEvent in project the-blue-alliance-android by the-blue-alliance.
the class TeamAtDistrictSummarySubscriber method parseData.
@Override
public void parseData() {
mDataToBind.clear();
EventsTable eventsTable = mDb.getEventsTable();
mDataToBind.add(new LabelValueListItem(mResources.getString(R.string.district_point_rank), mAPIData.getRank() + Utilities.getOrdinalFor(mAPIData.getRank())));
@Nullable IDistrictEventPoints event1Points = getEventPoints(mAPIData, 0);
if (event1Points != null) {
mDataToBind.add(renderEventPoints(mAPIData.getTeamKey(), event1Points, eventsTable, mResources));
}
@Nullable IDistrictEventPoints event2Points = getEventPoints(mAPIData, 1);
if (event2Points != null) {
mDataToBind.add(renderEventPoints(mAPIData.getTeamKey(), event2Points, eventsTable, mResources));
}
@Nullable IDistrictEventPoints cmpPoints = getEventPoints(mAPIData, 2);
if (cmpPoints != null) {
mDataToBind.add(renderEventPoints(mAPIData.getTeamKey(), cmpPoints, eventsTable, mResources));
}
if (mAPIData.getPointTotal() != null) {
mDataToBind.add(new LabelValueListItem(mResources.getString(R.string.total_district_points), String.format(mResources.getString(R.string.district_points_format), mAPIData.getPointTotal())));
}
String actionBarTitle = String.format(mResources.getString(R.string.team_actionbar_title), mTeamKey.substring(3));
String actionBarSubtitle = String.format("@ %1$s %2$s", mDistrictKey.substring(0, 4), mDistrictKey.substring(4).toUpperCase());
mEventBus.post(new ActionBarTitleEvent(actionBarTitle, actionBarSubtitle));
}
use of com.thebluealliance.androidclient.eventbus.ActionBarTitleEvent in project the-blue-alliance-android by the-blue-alliance.
the class DistrictEventsBinder method updateData.
@Override
public void updateData(@Nullable List<Object> data) {
super.updateData(data);
// Because we don't want to rely on the key -> constant mappings
if (isDataBound() && mList != null) {
for (int i = 0; i < mList.size(); i++) {
Object item = mList.get(i);
if (item instanceof EventViewModel) {
EventViewModel viewModel = ((EventViewModel) item);
String district = viewModel.getDistrictString();
int year = viewModel.getYear();
if (district != null && !district.isEmpty()) {
String title = mResources.getString(R.string.district_title_format, year, district);
mEventBus.post(new ActionBarTitleEvent(title));
return;
}
}
}
}
}
use of com.thebluealliance.androidclient.eventbus.ActionBarTitleEvent in project the-blue-alliance-android by the-blue-alliance.
the class EventInfoBinder method updateData.
@Override
public void updateData(@Nullable Model data) {
if (data == null) {
if (!isDataBound()) {
bindNoDataView();
}
return;
}
mSocialClickListener.setModelKey(data.eventKey);
mIsLive = data.isLive;
eventName.setText(data.nameString);
if (data.dateString == null || data.dateString.isEmpty()) {
eventDateContainer.setVisibility(View.GONE);
} else {
eventDate.setText(data.dateString);
}
// Show a venue if it is available, otherwise show just the location. If neither is available, hide
if (data.venueString != null && !data.venueString.isEmpty()) {
eventVenue.setText(data.venueString);
} else if (data.locationString != null && !data.locationString.isEmpty()) {
eventVenue.setText(data.locationString);
} else {
eventVenue.setText(R.string.no_location_available);
eventVenueContainer.setVisibility(View.GONE);
}
// setup social media intents
// Default to showing the nav arrow in the venue view and the venue view being clickable
// We need to set these again even though they're defined in XML in case we gain a location
// or venue on a refresh and we're reusing the same view.
eventVenueContainer.setFocusable(true);
eventVenueContainer.setClickable(true);
eventVenueContainer.setOnClickListener(mSocialClickListener);
if (data.venueString != null && !data.venueString.isEmpty()) {
// Set the tag to the event venue if it is available
eventVenueContainer.setTag("geo:0,0?q=" + Uri.encode(data.venueString));
} else if (data.locationString != null && !data.locationString.isEmpty()) {
// Otherwise, use the location
eventVenueContainer.setTag("geo:0,0?q=" + Uri.encode(data.locationString));
} else {
// If neither location nor venue are available, hide the nav arrow, remove the tag,
// and set the view to not clickable so the user cannot interact with it.
// It will contain the text "No location available".
eventVenueContainer.setTag(null);
eventVenueContainer.setFocusable(false);
eventVenueContainer.setClickable(false);
}
// If the event doesn't have a defined website, create a Google search for the event name
if (data.eventWebsite != null && data.eventWebsite.isEmpty()) {
eventWebsiteContainer.setTag("https://www.google.com/search?q=" + Uri.encode(data.nameString));
eventWebsiteTitle.setText(R.string.find_event_on_google);
} else {
eventWebsiteContainer.setTag(data.eventWebsite);
eventWebsiteTitle.setText(R.string.view_event_website);
}
eventWebsiteContainer.setOnClickListener(mSocialClickListener);
eventTwitterContainer.setTag("https://twitter.com/search?q=%23" + data.eventKey);
eventTwitterTitle.setText(mActivity.getString(R.string.view_event_twitter, data.eventKey));
eventTwitterContainer.setOnClickListener(mSocialClickListener);
eventYoutubeContainer.setTag("https://www.youtube.com/results?search_query=" + data.eventKey);
eventYoutubeTitle.setText(mActivity.getString(R.string.view_event_youtube, data.eventKey));
eventYoutubeContainer.setOnClickListener(mSocialClickListener);
eventCdContainer.setTag("https://www.chiefdelphi.com/search?q=category%3A11%20tags%3A" + data.eventKey);
eventCdContainer.setOnClickListener(mSocialClickListener);
if (data.isLive && data.webcasts != null && data.webcasts.size() > 0) {
if (data.webcasts.size() == 1) {
// Only one webcast, we can link directly to that
JsonObject eventWebcast = data.webcasts.get(0).getAsJsonObject();
WebcastType webcastType = WebcastHelper.getType(eventWebcast.get("type").getAsString());
webcastButton.setText(webcastType.render(mActivity));
webcastButton.setOnClickListener(new WebcastClickListener(mActivity, data.eventKey, webcastType, eventWebcast, 1));
} else {
webcastButton.setText(R.string.view_webcast_button);
webcastButton.setOnClickListener(v -> {
Dialog chooserDialog = buildMultiWebcastDialog(data.webcasts, data.eventKey);
chooserDialog.show();
});
}
webcastContainer.setVisibility(View.VISIBLE);
}
content.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.GONE);
EventBus.getDefault().post(new ActionBarTitleEvent(data.actionBarTitle, data.actionBarSubtitle));
mNoDataBinder.unbindData();
setDataBound(true);
}
use of com.thebluealliance.androidclient.eventbus.ActionBarTitleEvent in project the-blue-alliance-android by the-blue-alliance.
the class MatchInfoSubscriber method updateActionBarTitle.
private void updateActionBarTitle(String eventName) {
if (eventName != null && mMatchTitle != null && mMatchKey != null) {
String subtitle = "@ " + mMatchKey.substring(0, 4) + " " + eventName;
mEventBus.post(new ActionBarTitleEvent(mMatchTitle, subtitle));
}
}
Aggregations