Java Code Examples for com.gizwits.gizwifisdk.api.GizWifiDevice

The following examples show how to use com.gizwits.gizwifisdk.api.GizWifiDevice. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
protected void didSetSubscribe(GizWifiErrorCode result, GizWifiDevice device, boolean isSubscribed) {
	// TODO 控制页面跳转
	progressDialog.cancel();
	Message msg = new Message();
	if (GizWifiErrorCode.GIZ_SDK_SUCCESS == result) {
		msg.what = TOCONTROL;
		msg.obj = device;
	} else {
		if (device.isBind()) {
			msg.what = TOAST;
			// String setSubscribeFail = (String)
			// getText(R.string.setsubscribe_failed);
			msg.obj = toastError(result);// setSubscribeFail + "\n" + arg0;
		}
	}
	handler.sendMessage(msg);
}
 
Example 2
Source Project: Gizwits-SmartBuld_Android   Source File: GosDeviceListActivity.java    License: MIT License 6 votes vote down vote up
@Override
protected void didSetSubscribe(GizWifiErrorCode result, GizWifiDevice device, boolean isSubscribed) {
	// TODO 控制页面跳转
	progressDialog.cancel();
	Message msg = new Message();
	if (GizWifiErrorCode.GIZ_SDK_SUCCESS == result) {
		msg.what = TOCONTROL;
		msg.obj = device;
	} else {
		if (device.isBind()) {
			msg.what = TOAST;
			// String setSubscribeFail = (String)
			// getText(R.string.setsubscribe_failed);
			msg.obj = toastError(result);// setSubscribeFail + "\n" + arg0;
		}
	}
	handler.sendMessage(msg);
}
 
Example 3
Source Project: gokit-android   Source File: GosDeviceListActivity.java    License: MIT License 6 votes vote down vote up
@Override
protected void didSetSubscribe(GizWifiErrorCode result, GizWifiDevice device, boolean isSubscribed) {
	// TODO 控制页面跳转
	progressDialog.cancel();
	Message msg = new Message();
	if (GizWifiErrorCode.GIZ_SDK_SUCCESS == result) {
		msg.what = TOCONTROL;
		msg.obj = device;
	} else {
		if (device.isBind()) {
			msg.what = TOAST;
			// String setSubscribeFail = (String)
			// getText(R.string.setsubscribe_failed);
			msg.obj = toastError(result);// setSubscribeFail + "\n" + arg0;
		}
	}
	handler.sendMessage(msg);
}
 
Example 4
protected void didDiscovered(GizWifiErrorCode result, java.util.List<GizWifiDevice> deviceList) {
	GosDeviceModuleBaseActivity.deviceslist.clear();
	for (GizWifiDevice gizWifiDevice : deviceList) {
		GosDeviceModuleBaseActivity.deviceslist.add(gizWifiDevice);
	}
	handler.sendEmptyMessage(UPDATALIST);

}
 
Example 5
Source Project: Gizwits-SmartBuld_Android   Source File: GosDeviceMoreActivity.java    License: MIT License 5 votes vote down vote up
@Override
protected void didReceiveData(GizWifiErrorCode result, GizWifiDevice device,
		ConcurrentHashMap<String, Object> dataMap, int sn) {
	super.didReceiveData(result, device, dataMap, sn);
	if (result == GizWifiErrorCode.GIZ_SDK_SUCCESS) {
		deviceDataMap = dataMap;
		getDataFromDateMap();
		updateUI();
	}
}
 
Example 6
@Override
protected void didSetCustomInfo(GizWifiErrorCode result, GizWifiDevice device2) {
	super.didSetCustomInfo(result, device2);
	if (result == GizWifiErrorCode.GIZ_SDK_SUCCESS) {
		myToast(R.string.modify_succeed);
		progressDialog.cancel();
		backToDeviceList();
	} else {
		progressDialog.cancel();
		// 修改失败
		myToast(R.string.updata_fail);
	}
}
 
Example 7
@Override
protected void didReceiveData(GizWifiErrorCode result, GizWifiDevice device,
		ConcurrentHashMap<String, Object> dataMap, int sn) {
	super.didReceiveData(result, device, dataMap, sn);
	if (result == GizWifiErrorCode.GIZ_SDK_SUCCESS) {
		deviceDataMap = dataMap;
		getDataFromDateMap();
	}
}
 
Example 8
private void initDevice() {
	Intent intent = getIntent();
	GizWifiDevice dev = (GizWifiDevice) intent.getParcelableExtra("GizWifiDevice");
	if (dev != null) {
		device = dev;
		device.setListener(gizWifiDeviceListener);
	} else {
		toastDeviceNoReadyAndExit();
	}
}
 
Example 9
public void cColor(GizWifiDevice device, int color){
	sendMoreCommand("Color_R", Color.red(color), 
			"Color_G", Color.green(color), "Color_B", Color.blue(color));
	color_num_r = Color.red(color);
	color_num_g = Color.green(color);
	color_num_b = Color.blue(color);
}
 
Example 10
public void cColorTemp(GizWifiDevice device, int color_num){
	sendMoreCommand("Temperature_R", Color.red(color_num), 
			"Temperature_G", Color.green(color_num), "Temperature_B", Color.blue(color_num));
	color_num_temp_r = Color.red(color_num);
	color_num_temp_g = Color.green(color_num);
	color_num_temp_b = Color.blue(color_num);
}
 
Example 11
@Override
protected void didReceiveData(GizWifiErrorCode result, GizWifiDevice device,
		ConcurrentHashMap<String, Object> dataMap, int sn) {
	super.didReceiveData(result, device, dataMap, sn);
	if (result == GizWifiErrorCode.GIZ_SDK_SUCCESS) {
		deviceDataMap = dataMap;
		handler.sendEmptyMessage(handler_key.RECEIVED.ordinal());
	}
}
 
Example 12
@Override
protected void didUpdateNetStatus(GizWifiDevice device, GizWifiDeviceNetStatus netStatus) {
	super.didUpdateNetStatus(device, netStatus);
	if (device.isSubscribed()) {
		if (netStatus == GizWifiDeviceNetStatus.GizDeviceControlled) {
			handler.removeCallbacks(mRunnable);
			progressDialog.cancel();
			// 后面操作是等待sdk下发查询设备状态命令,收到设备状态后再更新界面
		} else {
			myToast(R.string.device_dropped);
			finish();
		}
	}
}
 
Example 13
Source Project: Gizwits-SmartBuld_Android   Source File: GosScheduleSiteTool.java    License: MIT License 5 votes vote down vote up
/**
 * @param context
 */
public GosScheduleSiteTool(Context context, GizWifiDevice device, String token) {
	super();
	this.device = device;
	this.token = token;
	mRequestQueue = Volley.newRequestQueue(context.getApplicationContext());
	APPID = GosDeploy.setAppID();

}
 
Example 14
Source Project: Gizwits-SmartBuld_Android   Source File: GosDeviceListActivity.java    License: MIT License 5 votes vote down vote up
protected void didDiscovered(GizWifiErrorCode result, java.util.List<GizWifiDevice> deviceList) {
	GosDeviceModuleBaseActivity.deviceslist.clear();
	for (GizWifiDevice gizWifiDevice : deviceList) {
		GosDeviceModuleBaseActivity.deviceslist.add(gizWifiDevice);
	}
	handler.sendEmptyMessage(UPDATALIST);

}
 
Example 15
Source Project: gokit-android   Source File: GosDeviceListActivity.java    License: MIT License 5 votes vote down vote up
protected void didDiscovered(GizWifiErrorCode result, java.util.List<GizWifiDevice> deviceList) {
	GosDeviceModuleBaseActivity.deviceslist.clear();
	for (GizWifiDevice gizWifiDevice : deviceList) {
		GosDeviceModuleBaseActivity.deviceslist.add(gizWifiDevice);
	}
	handler.sendEmptyMessage(UPDATALIST);

}
 
Example 16
Source Project: gokit-android   Source File: GosDeviceControlActivity.java    License: MIT License 5 votes vote down vote up
private void initDevice() {
	Intent intent = getIntent();
	mDevice = (GizWifiDevice) intent.getParcelableExtra("GizWifiDevice");
	deviceStatu = new ConcurrentHashMap<String, Object>();

	if (TextUtils.isEmpty(mDevice.getAlias())) {
		title = mDevice.getProductName();
	} else {
		title = mDevice.getAlias();
	}
}
 
Example 17
Source Project: gokit-android   Source File: GosDeviceControlActivity.java    License: MIT License 5 votes vote down vote up
protected void didGetHardwareInfo(GizWifiErrorCode result, GizWifiDevice device,
		java.util.concurrent.ConcurrentHashMap<String, String> hardwareInfo) {
	Log.i("Apptest", hardwareInfo.toString());
	StringBuffer sb = new StringBuffer();
	Message msg = new Message();
	if (GizWifiErrorCode.GIZ_SDK_SUCCESS != result) {
		msg.what = TOAST;
		msg.obj = toastError(result);
	} else {
		sb.append("Wifi Hardware Version:" + hardwareInfo.get(wifiHardVerKey) + "\r\n");
		sb.append("Wifi Software Version:" + hardwareInfo.get(wifiSoftVerKey) + "\r\n");
		sb.append("MCU Hardware Version:" + hardwareInfo.get(mcuHardVerKey) + "\r\n");
		sb.append("MCU Software Version:" + hardwareInfo.get(mcuSoftVerKey) + "\r\n");
		sb.append("Wifi Firmware Id:" + hardwareInfo.get(FirmwareIdKey) + "\r\n");
		sb.append("Wifi Firmware Version:" + hardwareInfo.get(FirmwareVerKey) + "\r\n");
		sb.append("Product Key:" + "\r\n" + hardwareInfo.get(productKey) + "\r\n");

		// 设备属性
		sb.append("Device ID:" + "\r\n" + mDevice.getDid() + "\r\n");
		sb.append("Device IP:" + mDevice.getIPAddress() + "\r\n");
		sb.append("Device MAC:" + mDevice.getMacAddress() + "\r\n");

		msg.what = HARDWARE;
		msg.obj = sb.toString();
	}

	handler.sendMessage(msg);
}
 
Example 18
Source Project: gokit-android   Source File: GosDeviceControlActivity.java    License: MIT License 5 votes vote down vote up
protected void didSetCustomInfo(GizWifiErrorCode result, GizWifiDevice device) {
	progressDialog.cancel();
	Message msg = new Message();
	msg.what = TOAST;
	String toastText;
	if (GizWifiErrorCode.GIZ_SDK_SUCCESS == result) {
		toastText = (String) getText(R.string.set_info_successful);
	} else {
		toastText = toastError(result);
	}
	msg.obj = toastText;
	handler.sendMessage(msg);
}
 
Example 19
Source Project: gokit-android   Source File: GosDeviceControlActivity.java    License: MIT License 5 votes vote down vote up
protected void didUpdateNetStatus(GizWifiDevice device, GizWifiDeviceNetStatus netStatus) {
	if (device == mDevice) {
		if (GizWifiDeviceNetStatus.GizDeviceUnavailable == netStatus
				|| GizWifiDeviceNetStatus.GizDeviceOffline == netStatus) {
			handler.sendEmptyMessage(DISCONNECT);
		} else {
			handler.removeCallbacks(mRunnable);
			progressDialog.cancel();
			mDevice.getDeviceStatus();
		}
	}
}
 
Example 20
public GosDeviceListAdapter(Context context, List<GizWifiDevice> deviceList) {
	super();
	this.context = context;
	this.deviceList = deviceList;
}
 
Example 21
@Override
public View getView(int position, View convertView, ViewGroup parent) {
	View view = convertView;
	Holder holder;

	if (view == null) {
		view = LayoutInflater.from(context).inflate(
				R.layout.item_gos_device_list, null);
		holder = new Holder(view);
		view.setTag(holder);
	} else {
		holder = (Holder) view.getTag();
	}
	final GizWifiDevice device = deviceList.get(position);
	String LAN, noLAN, unbind;
	LAN = (String) context.getText(R.string.lan);
	noLAN = (String) context.getText(R.string.no_lan);
	unbind = (String) context.getText(R.string.unbind);
	String deviceAlias = device.getAlias();
	String devicePN = device.getProductName();
	if (device.getNetStatus() == GizWifiDeviceNetStatus.GizDeviceOnline
			|| device.getNetStatus() == GizWifiDeviceNetStatus.GizDeviceControlled) {
		if (device.isBind()) {// 已绑定设备
			holder.getTvDeviceMac().setText(device.getMacAddress());
			if (device.isLAN()) {
				holder.getTvDeviceStatus().setText(LAN);
			} else {
				holder.getTvDeviceStatus().setText(noLAN);
			}
			if (TextUtils.isEmpty(deviceAlias)) {
				holder.getTvDeviceName().setText(devicePN);
			} else {
				holder.getTvDeviceName().setText(deviceAlias);
			}
		} else {// 未绑定设备
			holder.getTvDeviceMac().setText(device.getMacAddress());
			holder.getTvDeviceStatus().setText(unbind);
			if (TextUtils.isEmpty(deviceAlias)) {
				holder.getTvDeviceName().setText(devicePN);
			} else {
				holder.getTvDeviceName().setText(deviceAlias);
			}
		}
	} else {// 设备不在线

		holder.getTvDeviceMac().setText(device.getMacAddress());
		holder.getTvDeviceMac().setTextColor(
				context.getResources().getColor(R.color.gray));
		holder.getTvDeviceStatus().setText("");
		holder.getTvDeviceStatus().setTextColor(
				context.getResources().getColor(R.color.gray));
		holder.getImgRight().setVisibility(View.GONE);
		holder.getLlLeft().setBackgroundResource(
				R.drawable.btn_getcode_shape_gray);
		if (TextUtils.isEmpty(deviceAlias)) {
			holder.getTvDeviceName().setText(devicePN);
		} else {
			holder.getTvDeviceName().setText(deviceAlias);
		}
		holder.getTvDeviceName().setTextColor(
				context.getResources().getColor(R.color.gray));
	}
	holder.getDelete2().setOnClickListener(new OnClickListener() {

		@Override
		public void onClick(View v) {
			Message message = new Message();
			message.what = UNBOUND;
			message.obj = device.getDid().toString();
			handler.sendMessage(message);
		}
	});
	return view;
}
 
Example 22
/** 用于设备列表 */
public void didDiscovered(GizWifiErrorCode result, java.util.List<GizWifiDevice> deviceList) {
	GosDeviceModuleBaseActivity.this.didDiscovered(result, deviceList);
}
 
Example 23
public void didSetSubscribe(GizWifiErrorCode result, GizWifiDevice device, boolean isSubscribed) {
	GosDeviceModuleBaseActivity.this.didSetSubscribe(result, device, isSubscribed);
}
 
Example 24
private void UpdateUI() {
	if (GosDeviceModuleBaseActivity.deviceslist.isEmpty()) {
		svListGroup.setVisibility(View.GONE);
		llNoDevice.setVisibility(View.VISIBLE);
		mSwipeLayout1.setVisibility(View.VISIBLE);
		return;
	} else {
		llNoDevice.setVisibility(View.GONE);
		mSwipeLayout1.setVisibility(View.GONE);
		svListGroup.setVisibility(View.VISIBLE);
	}

	boundDevicesList = new ArrayList<GizWifiDevice>();
	foundDevicesList = new ArrayList<GizWifiDevice>();
	offlineDevicesList = new ArrayList<GizWifiDevice>();

	for (GizWifiDevice gizWifiDevice : GosDeviceModuleBaseActivity.deviceslist) {
		if (GizWifiDeviceNetStatus.GizDeviceOnline == gizWifiDevice.getNetStatus()
				|| GizWifiDeviceNetStatus.GizDeviceControlled == gizWifiDevice.getNetStatus()) {
			if (gizWifiDevice.isBind()) {
				boundDevicesList.add(gizWifiDevice);
			} else {
				foundDevicesList.add(gizWifiDevice);
			}
		} else {
			offlineDevicesList.add(gizWifiDevice);
		}
	}

	if (boundDevicesList.isEmpty()) {
		slvBoundDevices.setVisibility(View.GONE);
		llNoBoundDevices.setVisibility(View.VISIBLE);
	} else {
		myadapter = new GosDeviceListAdapter(this, boundDevicesList);
		myadapter.setHandler(handler);
		slvBoundDevices.setAdapter(myadapter);
		llNoBoundDevices.setVisibility(View.GONE);
		slvBoundDevices.setVisibility(View.VISIBLE);
	}

	if (foundDevicesList.isEmpty()) {
		slvFoundDevices.setVisibility(View.GONE);
		llNoFoundDevices.setVisibility(View.VISIBLE);
	} else {
		myadapter = new GosDeviceListAdapter(this, foundDevicesList);
		slvFoundDevices.setAdapter(myadapter);
		llNoFoundDevices.setVisibility(View.GONE);
		slvFoundDevices.setVisibility(View.VISIBLE);
	}

	if (offlineDevicesList.isEmpty()) {
		slvOfflineDevices.setVisibility(View.GONE);
		llNoOfflineDevices.setVisibility(View.VISIBLE);
	} else {
		myadapter = new GosDeviceListAdapter(this, offlineDevicesList);
		myadapter.setHandler(handler);
		slvOfflineDevices.setAdapter(myadapter);
		llNoOfflineDevices.setVisibility(View.GONE);
		slvOfflineDevices.setVisibility(View.VISIBLE);
	}

}
 
Example 25
Source Project: GOpenSource_AppKit_Android_AS   Source File: mySharedFragment.java    License: MIT License 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

	// 动态找到布局文件,再从这个布局中find出TextView对象
	View contextView = inflater.inflate(R.layout.activity_gos_shared_list, container, false);
	final ListView mListView = (ListView) contextView.findViewById(R.id.mysharedlist);
	myview = (TextView) contextView.findViewById(R.id.shareddeviceproductname);

	initData();
	myadapter1 = new myadapter();

	mListView.setAdapter(myadapter1);

	mListView.setOnItemClickListener(new OnItemClickListener() {

		@Override
		public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {

			GizWifiDevice wifiDevice = list.get(arg2);

			GizDeviceSharingUserRole sharingRole = wifiDevice.getSharingRole();
			int role = sharingRole.ordinal();
			boolean isgetsharing = false;

			if (role == 2) {
				isgetsharing = true;
			}

			mListView.setEnabled(false);
			mListView.postDelayed(new Runnable() {
				@Override
				public void run() {
					mListView.setEnabled(true);
				}
			}, 1000);
			
			Intent tent = new Intent(getActivity(), SharedDeviceManagerActivity.class);

			GosConstant.mybindUsers.clear();
			GosConstant.mydeviceSharingInfos.clear();
			tent.putExtra("productname", wifiDevice.getProductName());
			tent.putExtra("deviceid", wifiDevice.getDid());
			tent.putExtra("isgetsharing", isgetsharing);
			startActivity(tent);
		}
	});

	return contextView;
}
 
Example 26
private void initDevice() {
	Intent intent = getIntent();
	device = (GizWifiDevice) intent.getParcelableExtra("GizWifiDevice");
	Log.i("Apptest", device.getDid());
}
 
Example 27
@Override
public void didSetSubscribe(GizWifiErrorCode arg0, GizWifiDevice arg1, boolean arg2) {
	GosDeviceControlModuleBaseActivity.this.didSetSubscribe(arg0, arg1, arg2);
}
 
Example 28
public void didReceiveData(GizWifiErrorCode result, GizWifiDevice device,
		java.util.concurrent.ConcurrentHashMap<String, Object> dataMap, int sn) {
	GosDeviceControlModuleBaseActivity.this.didReceiveData(result, device, dataMap, sn);
}
 
Example 29
public void didUpdateNetStatus(GizWifiDevice device,
		com.gizwits.gizwifisdk.enumration.GizWifiDeviceNetStatus netStatus) {
	GosDeviceControlModuleBaseActivity.this.didUpdateNetStatus(device, netStatus);
}
 
Example 30
public void didSetCustomInfo(GizWifiErrorCode result, GizWifiDevice device) {
	GosDeviceControlModuleBaseActivity.this.didSetCustomInfo(result, device);
}