Search in sources :

Example 1 with WebcastClickListener

use of com.thebluealliance.androidclient.listeners.WebcastClickListener in project the-blue-alliance-android by the-blue-alliance.

the class WebcastListElement method getView.

@Override
public View getView(final Context c, LayoutInflater inflater, View convertView) {
    ViewHolder holder;
    if (convertView == null || !(convertView.getTag() instanceof ViewHolder)) {
        convertView = inflater.inflate(R.layout.list_item_carded_webcast, null);
        holder = new ViewHolder();
        holder.label = (TextView) convertView.findViewById(R.id.label);
        holder.value = (TextView) convertView.findViewById(R.id.value);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }
    holder.label.setText(String.format(c.getString(R.string.webcast_event_format), eventName, number));
    final String service = webcast.get("type").getAsString();
    final WebcastType type = WebcastHelper.getType(service);
    if (service != null) {
        holder.value.setVisibility(View.VISIBLE);
        holder.value.setText(type.render(c));
        holder.value.setTypeface(null, Typeface.NORMAL);
        convertView.setOnClickListener(new WebcastClickListener(c, eventKey, type, webcast, number));
    } else {
        holder.value.setVisibility(View.GONE);
    }
    return convertView;
}
Also used : WebcastType(com.thebluealliance.androidclient.types.WebcastType) WebcastClickListener(com.thebluealliance.androidclient.listeners.WebcastClickListener)

Example 2 with WebcastClickListener

use of com.thebluealliance.androidclient.listeners.WebcastClickListener 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);
}
Also used : WebcastType(com.thebluealliance.androidclient.types.WebcastType) WebcastClickListener(com.thebluealliance.androidclient.listeners.WebcastClickListener) AlertDialog(androidx.appcompat.app.AlertDialog) Dialog(android.app.Dialog) ActionBarTitleEvent(com.thebluealliance.androidclient.eventbus.ActionBarTitleEvent) JsonObject(com.google.gson.JsonObject)

Aggregations

WebcastClickListener (com.thebluealliance.androidclient.listeners.WebcastClickListener)2 WebcastType (com.thebluealliance.androidclient.types.WebcastType)2 Dialog (android.app.Dialog)1 AlertDialog (androidx.appcompat.app.AlertDialog)1 JsonObject (com.google.gson.JsonObject)1 ActionBarTitleEvent (com.thebluealliance.androidclient.eventbus.ActionBarTitleEvent)1