package com.erpdevelopment.vbvm;

import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.support.v4.media.MediaDescriptionCompat;
import android.support.v4.media.MediaMetadataCompat;
import android.support.v4.media.session.MediaButtonReceiver;
import android.support.v4.media.session.MediaControllerCompat;
import android.support.v4.media.session.MediaSessionCompat;
import android.support.v4.media.session.PlaybackStateCompat;
import android.support.v7.app.NotificationCompat;

/**
 * Helper APIs for constructing MediaStyle notifications
 */
public class MediaStyleHelper {
    /**
     * Build a notification using the information from the given media session. Makes heavy use
     * of {@link MediaMetadataCompat#getDescription()} to extract the appropriate information.
     * @param context Context used to construct the notification.
     * @param mediaSession Media session to get information.
     * @return A pre-built notification with information from the given media session.
     */
    public static NotificationCompat.Builder from(
            Context context, MediaSessionCompat mediaSession) {
        MediaControllerCompat controller = mediaSession.getController();
        MediaMetadataCompat mediaMetadata = controller.getMetadata();
        MediaDescriptionCompat description = mediaMetadata.getDescription();

        NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
        builder
                .setContentTitle(description.getTitle())
                .setContentText(description.getSubtitle())
                .setSubText(description.getDescription())
                .setLargeIcon(description.getIconBitmap())
                .setContentIntent(controller.getSessionActivity())
                .setDeleteIntent(
                        MediaButtonReceiver.buildMediaButtonPendingIntent(context, PlaybackStateCompat.ACTION_STOP))
                .setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
        return builder;
    }
}

@@ -1308,85 +1308,8 @@
 a();
-%0A        MediaDescriptionCompat description = mediaMetadata.getDescription();
 %0A%0A  
@@ -1392,16 +1392,139 @@
 ntext);%0A
+%0A        if (mediaMetadata != null) %7B%0A            MediaDescriptionCompat description = mediaMetadata.getDescription();%0A    
         
@@ -1531,16 +1531,20 @@
 builder%0A
+    
         
@@ -1600,32 +1600,36 @@
                 
+    
 .setContentText(
@@ -1667,24 +1667,28 @@
             
+ 
+   
 .setSubText(
@@ -1729,24 +1729,28 @@
             
+  
+  
 .setLargeIco
@@ -1779,16 +1779,17 @@
 itmap())
+;
 %0A       
@@ -1785,32 +1785,35 @@
 ));%0A        
+%7D%0A%0A
         
 .setContentI
@@ -1792,32 +1792,39 @@
      %7D%0A%0A        
+builder
 .setContentInten

fix null pointer exception