// Path: sender/Android/JoKenNERD/app/src/main/java/com/littleredgroup/jokennerd/utils/CastMessages.java
// public class CastMessages {
// 
// 	public static String messageToChoice(int valueChoice) {
// 		JSONObject object = new JSONObject();
// 		try {
// 			object.put(Constants.KEY_ACTION, Constants.ACTION_CHOICE);
// 			object.put(Constants.KEY_VALUE, valueChoice);
// 			Log.d("messageToChoice: ", String.valueOf(valueChoice));
// 		} catch (JSONException e) {
// 			e.printStackTrace();
// 		}
// 		return object.toString();
// 	}
// 
// 	public static String messageSetupUser(String name) {
// 		JSONObject object = new JSONObject();
// 		try {
// 			object.put(Constants.KEY_ACTION, Constants.ACTION_CONNECT);
// 			object.put(Constants.KEY_NAME, name);
// 			Log.d("messageSetupUser: ", name);
// 		} catch (JSONException e) {
// 			e.printStackTrace();
// 		}
// 		return object.toString();
// 	}
// 
// 	public static String messageUpdateUser(String name) {
// 		JSONObject object = new JSONObject();
// 		try {
// 			object.put(Constants.KEY_ACTION, Constants.ACTION_UPDATE);
// 			object.put(Constants.KEY_NAME, name);
// 			Log.d("messageUpdateUser: ", name);
// 		} catch (JSONException e) {
// 			e.printStackTrace();
// 		}
// 		return object.toString();
// 	}
// 
// }
// 
// Path: sender/Android/JoKenNERD/app/src/main/java/com/littleredgroup/jokennerd/utils/Constants.java
// public class Constants {
// 
//     public static final String KEY_ACTION = "action";
//     public static final String KEY_VALUE = "value";
//     public static final String KEY_NAME = "name";
//     public static final String KEY_RESULT = "result";
//     public static final String KEY_SUCESS = "sucess";
//     public static final String KEY_ERROR = "error";
// 
//     public static final String ACTION_CHOICE = "choice";
//     public static final String ACTION_CONNECT = "connect";
//     public static final String ACTION_UPDATE = "update";
// 
//     public static final int CHOICE_ROCK = 1;
//     public static final int CHOICE_PAPER = 2;
//     public static final int CHOICE_SCISSOR = 3;
//     public static final int CHOICE_LIZARD = 4;
//     public static final int CHOICE_SPOCK = 5;
// 
//     public static final String RESULT_WIN = "win";
//     public static final String RESULT_LOSE = "loses";
//     public static final String RESULT_DRAW = "draw";
//     public static final String RESULT_ALREADY_CONNECTED = "already_connected";
//     public static final String RESULT_ROOM_IS_FULL = "room_full";
//     public static final String RESULT_SUCCESS_CONECTED = "sucess_conected";
// 
//     public static final String TAG_NAME = "name";
// 
//     public static final String URL_CHROMECAST = "https://www.google.com.br/chrome/devices/chromecast/";
//     public static final String URL_GOOGLE_SDK_CAST = "https://developers.google.com/cast/";
//     public static final String URL_HACKATHON_GDGJF = "http://emjuizdefora.com/gdgjf/eventos/projeto-campeao-1o-hackathon-gdgjf/";
// 
// }
// 
// Path: sender/Android/JoKenNERD/app/src/main/java/com/littleredgroup/jokennerd/utils/Utils.java
// public class Utils {
// 
//     public static void openHiperlink(Activity activity, String url) {
//         Intent i = new Intent(Intent.ACTION_VIEW);
//         i.setData(Uri.parse(url));
//         activity.startActivity(i);
//     }
// }


import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.MediaRouteActionProvider;
import android.support.v7.media.MediaRouteSelector;
import android.support.v7.media.MediaRouter;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import com.google.android.gms.cast.Cast;
import com.google.android.gms.cast.CastDevice;
import com.google.android.gms.cast.CastMediaControlIntent;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
import com.littleredgroup.jokennerd.utils.CastMessages;
import com.littleredgroup.jokennerd.utils.Constants;
import com.littleredgroup.jokennerd.utils.Utils;
import org.json.JSONObject;
import java.io.IOException;
package com.littleredgroup.jokennerd;





/**
 * Created by fbvictorhugo on 10/4/14.
 * <p/>
 * implements Google APIs
 */
public class ChromecastGameActivity extends GameActivity
        implements GoogleApiClient.OnConnectionFailedListener,
        GoogleApiClient.ConnectionCallbacks {

    private String TAG = ChromecastGameActivity.class.getSimpleName();

    private MediaRouter mMediaRouter;
    private MediaRouteSelector mMediaRouteSelector;
    private MediaRouter.Callback mMediaRouterCallback;
    private CastDevice mSelectedDevice;
    private GoogleApiClient mGoogleApiClient;
    private boolean wasLaunched;
    private boolean mWaitingForReconnect;
    private MyMessageReceivedCallback mMyMessageReceivedCallbacks;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getSupportActionBar().setTitle(R.string.lbl_multi_player);
        showGameContent(false);
        initializeMediaRouter();
        addCallbackMediaRouter();
    }

    @Override
    public void onResume() {
        super.onResume();
        addCallbackMediaRouter();
    }

// Path: sender/Android/JoKenNERD/app/src/main/java/com/littleredgroup/jokennerd/utils/CastMessages.java
// public class CastMessages {
// 
// 	public static String messageToChoice(int valueChoice) {
// 		JSONObject object = new JSONObject();
// 		try {
// 			object.put(Constants.KEY_ACTION, Constants.ACTION_CHOICE);
// 			object.put(Constants.KEY_VALUE, valueChoice);
// 			Log.d("messageToChoice: ", String.valueOf(valueChoice));
// 		} catch (JSONException e) {
// 			e.printStackTrace();
// 		}
// 		return object.toString();
// 	}
// 
// 	public static String messageSetupUser(String name) {
// 		JSONObject object = new JSONObject();
// 		try {
// 			object.put(Constants.KEY_ACTION, Constants.ACTION_CONNECT);
// 			object.put(Constants.KEY_NAME, name);
// 			Log.d("messageSetupUser: ", name);
// 		} catch (JSONException e) {
// 			e.printStackTrace();
// 		}
// 		return object.toString();
// 	}
// 
// 	public static String messageUpdateUser(String name) {
// 		JSONObject object = new JSONObject();
// 		try {
// 			object.put(Constants.KEY_ACTION, Constants.ACTION_UPDATE);
// 			object.put(Constants.KEY_NAME, name);
// 			Log.d("messageUpdateUser: ", name);
// 		} catch (JSONException e) {
// 			e.printStackTrace();
// 		}
// 		return object.toString();
// 	}
// 
// }
// 
// Path: sender/Android/JoKenNERD/app/src/main/java/com/littleredgroup/jokennerd/utils/Constants.java
// public class Constants {
// 
//     public static final String KEY_ACTION = "action";
//     public static final String KEY_VALUE = "value";
//     public static final String KEY_NAME = "name";
//     public static final String KEY_RESULT = "result";
//     public static final String KEY_SUCESS = "sucess";
//     public static final String KEY_ERROR = "error";
// 
//     public static final String ACTION_CHOICE = "choice";
//     public static final String ACTION_CONNECT = "connect";
//     public static final String ACTION_UPDATE = "update";
// 
//     public static final int CHOICE_ROCK = 1;
//     public static final int CHOICE_PAPER = 2;
//     public static final int CHOICE_SCISSOR = 3;
//     public static final int CHOICE_LIZARD = 4;
//     public static final int CHOICE_SPOCK = 5;
// 
//     public static final String RESULT_WIN = "win";
//     public static final String RESULT_LOSE = "loses";
//     public static final String RESULT_DRAW = "draw";
//     public static final String RESULT_ALREADY_CONNECTED = "already_connected";
//     public static final String RESULT_ROOM_IS_FULL = "room_full";
//     public static final String RESULT_SUCCESS_CONECTED = "sucess_conected";
// 
//     public static final String TAG_NAME = "name";
// 
//     public static final String URL_CHROMECAST = "https://www.google.com.br/chrome/devices/chromecast/";
//     public static final String URL_GOOGLE_SDK_CAST = "https://developers.google.com/cast/";
//     public static final String URL_HACKATHON_GDGJF = "http://emjuizdefora.com/gdgjf/eventos/projeto-campeao-1o-hackathon-gdgjf/";
// 
// }
// 
// Path: sender/Android/JoKenNERD/app/src/main/java/com/littleredgroup/jokennerd/utils/Utils.java
// public class Utils {
// 
//     public static void openHiperlink(Activity activity, String url) {
//         Intent i = new Intent(Intent.ACTION_VIEW);
//         i.setData(Uri.parse(url));
//         activity.startActivity(i);
//     }
// }


// Path: sender/Android/JoKenNERD/app/src/main/java/com/littleredgroup/jokennerd/ChromecastGameActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.MediaRouteActionProvider;
import android.support.v7.media.MediaRouteSelector;
import android.support.v7.media.MediaRouter;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import com.google.android.gms.cast.Cast;
import com.google.android.gms.cast.CastDevice;
import com.google.android.gms.cast.CastMediaControlIntent;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
import com.littleredgroup.jokennerd.utils.CastMessages;
import com.littleredgroup.jokennerd.utils.Constants;
import com.littleredgroup.jokennerd.utils.Utils;
import org.json.JSONObject;
import java.io.IOException;

package com.littleredgroup.jokennerd;





/**
 * Created by fbvictorhugo on 10/4/14.
 * <p/>
 * implements Google APIs
 */
public class ChromecastGameActivity extends GameActivity
        implements GoogleApiClient.OnConnectionFailedListener,
        GoogleApiClient.ConnectionCallbacks {

    private String TAG = ChromecastGameActivity.class.getSimpleName();

    private MediaRouter mMediaRouter;
    private MediaRouteSelector mMediaRouteSelector;
    private MediaRouter.Callback mMediaRouterCallback;
    private CastDevice mSelectedDevice;
    private GoogleApiClient mGoogleApiClient;
    private boolean wasLaunched;
    private boolean mWaitingForReconnect;
    private MyMessageReceivedCallback mMyMessageReceivedCallbacks;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getSupportActionBar().setTitle(R.string.lbl_multi_player);
        showGameContent(false);
        initializeMediaRouter();
        addCallbackMediaRouter();
    }

    @Override
    public void onResume() {
        super.onResume();
        addCallbackMediaRouter();
    }

    @Override