Search in sources :

Example 1 with Activity

use of com.kickstarter.models.pushdata.Activity in project android-oss by kickstarter.

the class DebugPushNotificationsView method simulateProjectLaunchButtonClick.

@OnClick(R.id.simulate_project_launch_button)
public void simulateProjectLaunchButtonClick() {
    final GCM gcm = GCM.builder().title("Want to be the first backer?").alert("Taylor Moore just launched a project!").build();
    final Activity activity = Activity.builder().category(com.kickstarter.models.Activity.CATEGORY_LAUNCH).id(5).projectId(PROJECT_ID).build();
    final PushNotificationEnvelope envelope = PushNotificationEnvelope.builder().activity(activity).gcm(gcm).build();
    pushNotifications.add(envelope);
}
Also used : GCM(com.kickstarter.models.pushdata.GCM) PushNotificationEnvelope(com.kickstarter.services.apiresponses.PushNotificationEnvelope) Activity(com.kickstarter.models.pushdata.Activity) OnClick(butterknife.OnClick)

Example 2 with Activity

use of com.kickstarter.models.pushdata.Activity in project android-oss by kickstarter.

the class DebugPushNotificationsView method projectSuccessEnvelope.

@NonNull
private PushNotificationEnvelope projectSuccessEnvelope() {
    final GCM gcm = GCM.builder().title("Time to celebrate!").alert("SKULL GRAPHIC TEE has been successfully funded.").build();
    final Activity activity = Activity.builder().category(com.kickstarter.models.Activity.CATEGORY_SUCCESS).id(6).projectId(PROJECT_ID).projectPhoto(PROJECT_PHOTO).build();
    return PushNotificationEnvelope.builder().activity(activity).gcm(gcm).build();
}
Also used : GCM(com.kickstarter.models.pushdata.GCM) Activity(com.kickstarter.models.pushdata.Activity) NonNull(android.support.annotation.NonNull)

Example 3 with Activity

use of com.kickstarter.models.pushdata.Activity in project android-oss by kickstarter.

the class PushNotifications method displayNotificationFromProjectActivity.

private void displayNotificationFromProjectActivity(@NonNull final PushNotificationEnvelope envelope) {
    final GCM gcm = envelope.gcm();
    final Activity activity = envelope.activity();
    if (activity == null) {
        return;
    }
    final Long projectId = activity.projectId();
    if (projectId == null) {
        return;
    }
    final String projectPhoto = activity.projectPhoto();
    final String projectParam = ObjectUtils.toString(projectId);
    NotificationCompat.Builder notificationBuilder = notificationBuilder(gcm.title(), gcm.alert()).setContentIntent(projectContentIntent(envelope, projectParam));
    if (projectPhoto != null) {
        notificationBuilder = notificationBuilder.setLargeIcon(fetchBitmap(projectPhoto, false));
    }
    final Notification notification = notificationBuilder.build();
    notificationManager().notify(envelope.signature(), notification);
}
Also used : GCM(com.kickstarter.models.pushdata.GCM) ProjectActivity(com.kickstarter.ui.activities.ProjectActivity) Activity(com.kickstarter.models.pushdata.Activity) WebViewActivity(com.kickstarter.ui.activities.WebViewActivity) NotificationCompat(android.support.v4.app.NotificationCompat) Notification(android.app.Notification)

Example 4 with Activity

use of com.kickstarter.models.pushdata.Activity in project android-oss by kickstarter.

the class MessageService method onMessageReceived.

/**
   * Called when a message is received from GCM.
   *
   * @param from SenderID of the sender.
   * @param data Data bundle containing message data as key/value pairs.
   */
@Override
public void onMessageReceived(@NonNull final String from, @NonNull final Bundle data) {
    final String senderId = getString(R.string.gcm_defaultSenderId);
    if (!from.equals(senderId)) {
        Timber.e("Received a message from %s, expecting %s", from, senderId);
        return;
    }
    final PushNotificationEnvelope envelope = PushNotificationEnvelope.builder().activity(gson.fromJson(data.getString("activity"), Activity.class)).gcm(gson.fromJson(data.getString("gcm"), GCM.class)).build();
    if (envelope == null) {
        Timber.e("Cannot parse message, malformed or unexpected data: %s", data.toString());
        return;
    }
    Timber.d("Received message: %s", envelope.toString());
    pushNotifications.add(envelope);
}
Also used : PushNotificationEnvelope(com.kickstarter.services.apiresponses.PushNotificationEnvelope) Activity(com.kickstarter.models.pushdata.Activity)

Example 5 with Activity

use of com.kickstarter.models.pushdata.Activity in project android-oss by kickstarter.

the class DebugPushNotificationsView method simulateProjectCancellationButtonClick.

@OnClick(R.id.simulate_project_cancellation_button)
public void simulateProjectCancellationButtonClick() {
    final GCM gcm = GCM.builder().title("Kickstarter").alert("SKULL GRAPHIC TEE has been canceled.").build();
    final Activity activity = Activity.builder().category(com.kickstarter.models.Activity.CATEGORY_CANCELLATION).id(3).projectId(PROJECT_ID).projectPhoto(PROJECT_PHOTO).build();
    final PushNotificationEnvelope envelope = PushNotificationEnvelope.builder().activity(activity).gcm(gcm).build();
    pushNotifications.add(envelope);
}
Also used : GCM(com.kickstarter.models.pushdata.GCM) PushNotificationEnvelope(com.kickstarter.services.apiresponses.PushNotificationEnvelope) Activity(com.kickstarter.models.pushdata.Activity) OnClick(butterknife.OnClick)

Aggregations

Activity (com.kickstarter.models.pushdata.Activity)12 GCM (com.kickstarter.models.pushdata.GCM)10 PushNotificationEnvelope (com.kickstarter.services.apiresponses.PushNotificationEnvelope)7 OnClick (butterknife.OnClick)6 ProjectActivity (com.kickstarter.ui.activities.ProjectActivity)4 WebViewActivity (com.kickstarter.ui.activities.WebViewActivity)4 Notification (android.app.Notification)3 NonNull (android.support.annotation.NonNull)1 Nullable (android.support.annotation.Nullable)1 NotificationCompat (android.support.v4.app.NotificationCompat)1 Update (com.kickstarter.models.Update)1