// Path: app/src/main/java/org/noorganization/instalist/GlobalApplication.java
// 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) {
//         mCurrentShoppingList = _selectedShoppingList.mShoppingList;
//     }
// 
//     public void onEvent(ShoppingListOverviewFragmentActiveEvent _event) {
//         mBufferItemChangedMessages = !_event.mActive;
//         if (!mBufferItemChangedMessages) {
//             for (ListItemChangedMessage message : mBufferedMessages)
//                 EventBus.getDefault().post(message);
// 
//             mBufferedMessages.clear();
//         }
//     }
// 
//     public void onEvent(ListItemChangedMessage _message) {
//         if (mBufferItemChangedMessages) {
//             mBufferedMessages.add(_message);
//         }
//     }
// 
//     public void onEvent(ProductSelectMessage _message) {
//         if (mCurrentShoppingList == null) {
//             Toast.makeText(getContext(), R.string.abc_no_shopping_list_selected, Toast.LENGTH_SHORT).show();
//             return;
//         }
//         if (mHandlingProductSelectedMessages) {
//             Map<Product, Float> productAmounts = _message.mProducts;
//             IListController controller = ControllerFactory.getListController(getContext());
//             for (Product currentProduct : productAmounts.keySet()) {
//                 controller.addOrChangeItem(mCurrentShoppingList, currentProduct,
//                                            productAmounts.get(currentProduct), true);
//             }
//         }
//     }
// 
// }


import android.os.Parcel;
import android.os.Parcelable;
import android.util.SparseBooleanArray;
import org.noorganization.instalist.GlobalApplication;
import org.noorganization.instalist.presenter.implementation.ControllerFactory;
import org.noorganization.instalist.model.Recipe;
/*
 * 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.view.modelwrappers;



/**
 * The wrapper for Recipes to strike/unstrike them.
 * Created by TS on 25.05.2015.
 */
public class RecipeListEntry implements IBaseListEntry {

    public static final int CHECKED_PROPERTY = 0;
    private Recipe mRecipe;
    private boolean mChecked;

    public RecipeListEntry(Recipe _Recipe) {
        mRecipe = _Recipe;
    }

    private RecipeListEntry(Parcel _In) {
// Path: app/src/main/java/org/noorganization/instalist/GlobalApplication.java
// 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) {
//         mCurrentShoppingList = _selectedShoppingList.mShoppingList;
//     }
// 
//     public void onEvent(ShoppingListOverviewFragmentActiveEvent _event) {
//         mBufferItemChangedMessages = !_event.mActive;
//         if (!mBufferItemChangedMessages) {
//             for (ListItemChangedMessage message : mBufferedMessages)
//                 EventBus.getDefault().post(message);
// 
//             mBufferedMessages.clear();
//         }
//     }
// 
//     public void onEvent(ListItemChangedMessage _message) {
//         if (mBufferItemChangedMessages) {
//             mBufferedMessages.add(_message);
//         }
//     }
// 
//     public void onEvent(ProductSelectMessage _message) {
//         if (mCurrentShoppingList == null) {
//             Toast.makeText(getContext(), R.string.abc_no_shopping_list_selected, Toast.LENGTH_SHORT).show();
//             return;
//         }
//         if (mHandlingProductSelectedMessages) {
//             Map<Product, Float> productAmounts = _message.mProducts;
//             IListController controller = ControllerFactory.getListController(getContext());
//             for (Product currentProduct : productAmounts.keySet()) {
//                 controller.addOrChangeItem(mCurrentShoppingList, currentProduct,
//                                            productAmounts.get(currentProduct), true);
//             }
//         }
//     }
// 
// }


// Path: app/src/main/java/org/noorganization/instalist/view/modelwrappers/RecipeListEntry.java
import android.os.Parcel;
import android.os.Parcelable;
import android.util.SparseBooleanArray;
import org.noorganization.instalist.GlobalApplication;
import org.noorganization.instalist.presenter.implementation.ControllerFactory;
import org.noorganization.instalist.model.Recipe;

/*
 * 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.view.modelwrappers;



/**
 * The wrapper for Recipes to strike/unstrike them.
 * Created by TS on 25.05.2015.
 */
public class RecipeListEntry implements IBaseListEntry {

    public static final int CHECKED_PROPERTY = 0;
    private Recipe mRecipe;
    private boolean mChecked;

    public RecipeListEntry(Recipe _Recipe) {
        mRecipe = _Recipe;
    }

    private RecipeListEntry(Parcel _In) {
        mRecipe = ControllerFactory.getRecipeController(GlobalApplication.getContext()).findById(_In.readString());