// Path: app/src/main/java/org/noorganization/instalist/view/event/ActivityStateMessage.java
// public class ActivityStateMessage {
//     public enum State {
//         PAUSED,
//         RESUMED
//     }
// 
//     /**
//      * The activity which state changes.
//      */
//     public Activity mActivity;
// 
//     /**
//      * The new state of the activity.
//      */
//     public State    mState;
// 
//     public ActivityStateMessage(Activity _activity, State _state) {
//         mActivity = _activity;
//         mState    = _state;
//     }
// }
// 
// Path: app/src/main/java/org/noorganization/instalist/view/event/ProductSelectMessage.java
// public class ProductSelectMessage {
//     public Map<Product, Float> mProducts;
// 
//     public ProductSelectMessage(Map<Product, Float> _products) {
//         mProducts = _products;
//     }
// }
// 
// Path: app/src/main/java/org/noorganization/instalist/view/event/ShoppingListOverviewFragmentActiveEvent.java
// public class ShoppingListOverviewFragmentActiveEvent {
// 
//     public boolean mActive;
// 
//     public ShoppingListOverviewFragmentActiveEvent(boolean _active){
//         mActive = _active;
//     }
// }
// 
// Path: app/src/main/java/org/noorganization/instalist/view/event/ShoppingListSelectedMessage.java
// public class ShoppingListSelectedMessage {
// 
//     /**
//      * The attribute ShoppingList.
//      */
//     public ShoppingList mShoppingList;
// 
//     /**
//      * Constructor of the EventMessage.
//      * @param _shoppingList the shoppingList that was selected.
//      */
//     public ShoppingListSelectedMessage(@NonNull ShoppingList _shoppingList) {
//         mShoppingList = _shoppingList;
//     }
// }


import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import de.greenrobot.event.EventBus;
import android.app.Application;
import android.content.Context;
import android.widget.Toast;
import org.noorganization.instalist.model.Product;
import org.noorganization.instalist.model.ShoppingList;
import org.noorganization.instalist.presenter.IListController;
import org.noorganization.instalist.presenter.event.ListItemChangedMessage;
import org.noorganization.instalist.presenter.implementation.ControllerFactory;
import org.noorganization.instalist.view.event.ActivityStateMessage;
import org.noorganization.instalist.view.event.ProductSelectMessage;
import org.noorganization.instalist.view.event.ShoppingListOverviewFragmentActiveEvent;
import org.noorganization.instalist.view.event.ShoppingListSelectedMessage;
/*
 * Copyright 2016 Tino Siegmund, Michael Wodniok
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.noorganization.instalist;





/**
 * Global application class.
 * Created by TS on 21.04.2015.
 */
public class GlobalApplication extends Application {

    private final static String LOG_TAG = GlobalApplication.class.getName();

    private static GlobalApplication mInstance;
    private ShoppingList mCurrentShoppingList;

    private boolean mBufferItemChangedMessages;
    private boolean mHandlingProductSelectedMessages;
    private List<ListItemChangedMessage> mBufferedMessages;

    public static GlobalApplication getInstance() {
        return mInstance;
    }

    public static Context getContext() {
        return getInstance().getApplicationContext();
    }

    @Override
    public void onCreate() {
        super.onCreate();
        mInstance = this;
        EventBus.getDefault().register(this);
        mBufferedMessages = new LinkedList<>();
    }

    @Override
    public void onTerminate() {
        super.onTerminate();
    }

    public void onEvent(ActivityStateMessage _message) {
        mHandlingProductSelectedMessages = (_message.mState == ActivityStateMessage.State.RESUMED);
    }

// Path: app/src/main/java/org/noorganization/instalist/view/event/ActivityStateMessage.java
// public class ActivityStateMessage {
//     public enum State {
//         PAUSED,
//         RESUMED
//     }
// 
//     /**
//      * The activity which state changes.
//      */
//     public Activity mActivity;
// 
//     /**
//      * The new state of the activity.
//      */
//     public State    mState;
// 
//     public ActivityStateMessage(Activity _activity, State _state) {
//         mActivity = _activity;
//         mState    = _state;
//     }
// }
// 
// Path: app/src/main/java/org/noorganization/instalist/view/event/ProductSelectMessage.java
// public class ProductSelectMessage {
//     public Map<Product, Float> mProducts;
// 
//     public ProductSelectMessage(Map<Product, Float> _products) {
//         mProducts = _products;
//     }
// }
// 
// Path: app/src/main/java/org/noorganization/instalist/view/event/ShoppingListOverviewFragmentActiveEvent.java
// public class ShoppingListOverviewFragmentActiveEvent {
// 
//     public boolean mActive;
// 
//     public ShoppingListOverviewFragmentActiveEvent(boolean _active){
//         mActive = _active;
//     }
// }
// 
// Path: app/src/main/java/org/noorganization/instalist/view/event/ShoppingListSelectedMessage.java
// public class ShoppingListSelectedMessage {
// 
//     /**
//      * The attribute ShoppingList.
//      */
//     public ShoppingList mShoppingList;
// 
//     /**
//      * Constructor of the EventMessage.
//      * @param _shoppingList the shoppingList that was selected.
//      */
//     public ShoppingListSelectedMessage(@NonNull ShoppingList _shoppingList) {
//         mShoppingList = _shoppingList;
//     }
// }


// Path: app/src/main/java/org/noorganization/instalist/GlobalApplication.java
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import de.greenrobot.event.EventBus;
import android.app.Application;
import android.content.Context;
import android.widget.Toast;
import org.noorganization.instalist.model.Product;
import org.noorganization.instalist.model.ShoppingList;
import org.noorganization.instalist.presenter.IListController;
import org.noorganization.instalist.presenter.event.ListItemChangedMessage;
import org.noorganization.instalist.presenter.implementation.ControllerFactory;
import org.noorganization.instalist.view.event.ActivityStateMessage;
import org.noorganization.instalist.view.event.ProductSelectMessage;
import org.noorganization.instalist.view.event.ShoppingListOverviewFragmentActiveEvent;
import org.noorganization.instalist.view.event.ShoppingListSelectedMessage;

/*
 * Copyright 2016 Tino Siegmund, Michael Wodniok
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.noorganization.instalist;





/**
 * Global application class.
 * Created by TS on 21.04.2015.
 */
public class GlobalApplication extends Application {

    private final static String LOG_TAG = GlobalApplication.class.getName();

    private static GlobalApplication mInstance;
    private ShoppingList mCurrentShoppingList;

    private boolean mBufferItemChangedMessages;
    private boolean mHandlingProductSelectedMessages;
    private List<ListItemChangedMessage> mBufferedMessages;

    public static GlobalApplication getInstance() {
        return mInstance;
    }

    public static Context getContext() {
        return getInstance().getApplicationContext();
    }

    @Override
    public void onCreate() {
        super.onCreate();
        mInstance = this;
        EventBus.getDefault().register(this);
        mBufferedMessages = new LinkedList<>();
    }

    @Override
    public void onTerminate() {
        super.onTerminate();
    }

    public void onEvent(ActivityStateMessage _message) {
        mHandlingProductSelectedMessages = (_message.mState == ActivityStateMessage.State.RESUMED);
    }

    public void onEvent(ShoppingListSelectedMessage _selectedShoppingList) {