package org.jboss.aerogear.unifiedpush.helloworld.activities;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import org.jboss.aerogear.android.unifiedpush.MessageHandler;
import org.jboss.aerogear.android.unifiedpush.Registrations;
import org.jboss.aerogear.unifiedpush.helloworld.HelloWorldApplication;
import org.jboss.aerogear.unifiedpush.helloworld.R;
import org.jboss.aerogear.unifiedpush.helloworld.handler.NotificationBarMessageHandler;

import java.util.ArrayList;
import java.util.List;

public class MessagesActivity extends Activity implements MessageHandler{

    private HelloWorldApplication application;
    private ListView listView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.messages);

        application = (HelloWorldApplication) getApplication();

        listView = (ListView) findViewById(R.id.messages);

        if(getIntent().getExtras() != null) {
            addNewMessage(getIntent().getExtras());
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        Registrations.registerMainThreadHandler(this);
        Registrations.unregisterBackgroundThreadHandler(NotificationBarMessageHandler.instance);

        displayMessages();
    }

    @Override
    protected void onStop() {
        super.onStop();
        Registrations.unregisterMainThreadHandler(this);
        Registrations.registerBackgroundThreadHandler(NotificationBarMessageHandler.instance);
    }

    @Override
    public void onMessage(Context context, Bundle message) {
        addNewMessage(message);
    }

    @Override
    public void onDeleteMessage(Context context, Bundle message) {
    }

    @Override
    public void onError() {
    }

    private void addNewMessage(Bundle message) {
        application.addMessage(message.getString("alert"));
        displayMessages();
    }

    private void displayMessages() {
        ArrayAdapter<String> adapter = new ArrayAdapter<>(getApplicationContext(),
                R.layout.message_item, application.getMessages());
        listView.setAdapter(adapter);
    }

}

@@ -1045,16 +1045,20 @@
         
+    
 if(getIn
@@ -1083,24 +1083,28 @@
  != null) %7B%0A
+    
             
@@ -1139,24 +1139,28 @@
 tExtras());%0A
+    
         %7D%0A  
@@ -1458,20 +1458,21 @@
  void on
-Stop
+Pause
 () %7B%0A   
@@ -1488,12 +1488,13 @@
 r.on
-Stop
+Pause
 ();%0A

Replace onStop by onPause