Search in sources :

Example 1 with NotificationFunnel

use of org.wikipedia.analytics.NotificationFunnel in project apps-android-wikipedia by wikimedia.

the class NotificationItemActionsDialog method onActionClick.

@OnClick({ R.id.notification_action_primary, R.id.notification_action_secondary, R.id.notification_action_tertiary })
void onActionClick(View v) {
    Notification.Link link = (Notification.Link) v.getTag();
    int linkIndex = v.getId() == R.id.notification_action_primary ? 0 : v.getId() == R.id.notification_action_secondary ? 1 : 2;
    String url = link.getUrl();
    if (TextUtils.isEmpty(url)) {
        return;
    }
    new NotificationFunnel(WikipediaApp.getInstance(), notification).logAction(linkIndex, link);
    linkHandler.setWikiSite(new WikiSite(url));
    linkHandler.onUrlClick(url, null, "");
}
Also used : NotificationFunnel(org.wikipedia.analytics.NotificationFunnel) WikiSite(org.wikipedia.dataclient.WikiSite) OnClick(butterknife.OnClick)

Example 2 with NotificationFunnel

use of org.wikipedia.analytics.NotificationFunnel in project apps-android-wikipedia by wikimedia.

the class NotificationActivity method deleteItems.

private void deleteItems(List<NotificationListItemContainer> items, boolean markUnread) {
    Map<WikiSite, List<Notification>> notificationsPerWiki = new HashMap<>();
    Long selectionKey = items.size() > 1 ? new Random().nextLong() : null;
    for (NotificationListItemContainer item : items) {
        WikiSite wiki = dbNameMap.containsKey(item.notification.wiki()) ? dbNameMap.get(item.notification.wiki()) : WikipediaApp.getInstance().getWikiSite();
        if (!notificationsPerWiki.containsKey(wiki)) {
            notificationsPerWiki.put(wiki, new ArrayList<>());
        }
        notificationsPerWiki.get(wiki).add(item.notification);
        if (markUnread && !displayArchived) {
            notificationList.add(item.notification);
        } else {
            notificationList.remove(item.notification);
            new NotificationFunnel(WikipediaApp.getInstance(), item.notification).logMarkRead(selectionKey);
        }
    }
    for (WikiSite wiki : notificationsPerWiki.keySet()) {
        if (markUnread) {
            NotificationPollBroadcastReceiver.markRead(wiki, notificationsPerWiki.get(wiki), true);
        } else {
            NotificationPollBroadcastReceiver.markRead(wiki, notificationsPerWiki.get(wiki), false);
            showDeleteItemsUndoSnackbar(items);
        }
    }
    postprocessAndDisplay();
}
Also used : Random(java.util.Random) HashMap(java.util.HashMap) NotificationFunnel(org.wikipedia.analytics.NotificationFunnel) List(java.util.List) ArrayList(java.util.ArrayList) WikiSite(org.wikipedia.dataclient.WikiSite)

Aggregations

NotificationFunnel (org.wikipedia.analytics.NotificationFunnel)2 WikiSite (org.wikipedia.dataclient.WikiSite)2 OnClick (butterknife.OnClick)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Random (java.util.Random)1