// Path: vor-android/mobile/src/main/java/com/futurice/vor/utils/ToiletUtils.java
// public class ToiletUtils {
//     /**
//      * Implementation of the click listener to show methane level
//      *
//      * @param json the json string
//      */
//     public static void setClickListener(String json, Context context) {
//         if (json != null) {
//             try {
//                 JSONObject jsonData = new JSONObject(json);
//                 Integer methane = jsonData.getInt(METHANE_KEY);
//                 showMethaneToast(methane, context);
//             } catch (JSONException e) {
//                 e.printStackTrace();
//             }
//         }
//     }
// 
//     public static void updateView(SharedPreferences sharedPreferences, String key, View view, Context context) {
//         String json = sharedPreferences.getString(key, null);
//         if (json != null) {
//             try {
//                 JSONObject jsonData = new JSONObject(json);
//                 updateToiletBackground(view, jsonData.getBoolean(RESERVED_KEY), context);
//             } catch (JSONException e) {
//                 e.printStackTrace();
//             }
//         }
//     }
// 
//     /**
//      * Updates the background of the view depending on toilet availability
//      *
//      * @param view the view
//      * @param reserved the state of the toilet
//      */
//     public static void updateToiletBackground(View view, Boolean reserved, Context context) {
//         Drawable freeBg = ContextCompat.getDrawable(context, R.drawable.toilet_free_bg);
//         Drawable takenBg = ContextCompat.getDrawable(context, R.drawable.toilet_taken_bg);
//         view.setBackground(reserved ? takenBg : freeBg);
//     }
// 
//     /**
//      * Shows a toast with the methane level
//      *
//      * @param methane the methane level
//      *
//      * @param context the context
//      */
//     public static void showMethaneToast(Integer methane, Context context) {
//         String message = "Methane level: " + Integer.toString(methane);
//         Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
//     }
// }


import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import com.futurice.vor.R;
import com.futurice.vor.Toilet;
import com.futurice.vor.utils.ToiletUtils;
import butterknife.Bind;
import butterknife.ButterKnife;
package com.futurice.vor.fragment;




public class Floor7Fragment extends Fragment {
    @Bind(R.id.toilet7AM) RelativeLayout mToilet7AM;
    @Bind(R.id.toilet7BM) RelativeLayout mToilet7BM;

    Activity mActivity;

    SharedPreferences mToilet7amSP;
    SharedPreferences mToilet7bmSP;

    OnSharedPreferenceChangeListener toilet7amListener = (sharedPreferences, key) -> {
// Path: vor-android/mobile/src/main/java/com/futurice/vor/utils/ToiletUtils.java
// public class ToiletUtils {
//     /**
//      * Implementation of the click listener to show methane level
//      *
//      * @param json the json string
//      */
//     public static void setClickListener(String json, Context context) {
//         if (json != null) {
//             try {
//                 JSONObject jsonData = new JSONObject(json);
//                 Integer methane = jsonData.getInt(METHANE_KEY);
//                 showMethaneToast(methane, context);
//             } catch (JSONException e) {
//                 e.printStackTrace();
//             }
//         }
//     }
// 
//     public static void updateView(SharedPreferences sharedPreferences, String key, View view, Context context) {
//         String json = sharedPreferences.getString(key, null);
//         if (json != null) {
//             try {
//                 JSONObject jsonData = new JSONObject(json);
//                 updateToiletBackground(view, jsonData.getBoolean(RESERVED_KEY), context);
//             } catch (JSONException e) {
//                 e.printStackTrace();
//             }
//         }
//     }
// 
//     /**
//      * Updates the background of the view depending on toilet availability
//      *
//      * @param view the view
//      * @param reserved the state of the toilet
//      */
//     public static void updateToiletBackground(View view, Boolean reserved, Context context) {
//         Drawable freeBg = ContextCompat.getDrawable(context, R.drawable.toilet_free_bg);
//         Drawable takenBg = ContextCompat.getDrawable(context, R.drawable.toilet_taken_bg);
//         view.setBackground(reserved ? takenBg : freeBg);
//     }
// 
//     /**
//      * Shows a toast with the methane level
//      *
//      * @param methane the methane level
//      *
//      * @param context the context
//      */
//     public static void showMethaneToast(Integer methane, Context context) {
//         String message = "Methane level: " + Integer.toString(methane);
//         Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
//     }
// }


// Path: vor-android/mobile/src/main/java/com/futurice/vor/fragment/Floor7Fragment.java
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import com.futurice.vor.R;
import com.futurice.vor.Toilet;
import com.futurice.vor.utils.ToiletUtils;
import butterknife.Bind;
import butterknife.ButterKnife;

package com.futurice.vor.fragment;




public class Floor7Fragment extends Fragment {
    @Bind(R.id.toilet7AM) RelativeLayout mToilet7AM;
    @Bind(R.id.toilet7BM) RelativeLayout mToilet7BM;

    Activity mActivity;

    SharedPreferences mToilet7amSP;
    SharedPreferences mToilet7bmSP;

    OnSharedPreferenceChangeListener toilet7amListener = (sharedPreferences, key) -> {
        ToiletUtils.updateView(sharedPreferences, key, mToilet7AM, getActivity());