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