// Path: app/src/main/java/com/pandocloud/freeiot/ui/app/AppConstants.java
// public class AppConstants {
// 	
// 	public static final String VENDOR_KEY = "570f93557db3532727b54336e47f1a3500b3c0e564";
// 	
//     //FreeIOT
//     public static final String PRODUCT_KEY = "f07fd3f2782ff4964b74d51e89ad0aabf0192ec066";
// }


import android.content.Context;
import com.pandocloud.android.api.DeviceLoginManager;
import com.pandocloud.android.api.DeviceState;
import com.pandocloud.android.api.interfaces.SimpleRequestListener;
import com.pandocloud.freeiot.ui.app.AppConstants;

package com.pandocloud.freeiot.ui.helper;




public class DeviceRegisterHelper {
	
	private static DeviceRegisterHelper sInstances;
	
	private int tryCount = 0;
	
	private static final int MAX_TRY_COUNT = 3;
	
	private DeviceRegisterHelper(){
	}
	
	public static DeviceRegisterHelper getInstances() {
		if (sInstances == null) {
			synchronized (DeviceRegisterHelper.class) {
				if (sInstances == null) {
					sInstances = new DeviceRegisterHelper();
				}
			}
		}
		return sInstances;
	}

	public void checkDeviceRegister(Context context) {
		if (!DeviceState.getInstances(context).hasAccessToken()) {
			registerDevice(context);
		}
	}
	
	private void registerDevice(final Context context) {
		tryCount ++;
		if (tryCount > MAX_TRY_COUNT) {
			tryCount = 0;
			return;
		}
		DeviceLoginManager.getInstances().registerDevice(context,

// Path: app/src/main/java/com/pandocloud/freeiot/ui/app/AppConstants.java
// public class AppConstants {
// 	
// 	public static final String VENDOR_KEY = "570f93557db3532727b54336e47f1a3500b3c0e564";
// 	
//     //FreeIOT
//     public static final String PRODUCT_KEY = "f07fd3f2782ff4964b74d51e89ad0aabf0192ec066";
// }


// Path: app/src/main/java/com/pandocloud/freeiot/ui/helper/DeviceRegisterHelper.java
import android.content.Context;
import com.pandocloud.android.api.DeviceLoginManager;
import com.pandocloud.android.api.DeviceState;
import com.pandocloud.android.api.interfaces.SimpleRequestListener;
import com.pandocloud.freeiot.ui.app.AppConstants;

package com.pandocloud.freeiot.ui.helper;




public class DeviceRegisterHelper {
	
	private static DeviceRegisterHelper sInstances;
	
	private int tryCount = 0;
	
	private static final int MAX_TRY_COUNT = 3;
	
	private DeviceRegisterHelper(){
	}
	
	public static DeviceRegisterHelper getInstances() {
		if (sInstances == null) {
			synchronized (DeviceRegisterHelper.class) {
				if (sInstances == null) {
					sInstances = new DeviceRegisterHelper();
				}
			}
		}
		return sInstances;
	}

	public void checkDeviceRegister(Context context) {
		if (!DeviceState.getInstances(context).hasAccessToken()) {
			registerDevice(context);
		}
	}
	
	private void registerDevice(final Context context) {
		tryCount ++;
		if (tryCount > MAX_TRY_COUNT) {
			tryCount = 0;
			return;
		}
		DeviceLoginManager.getInstances().registerDevice(context,

				AppConstants.VENDOR_KEY,
