com.gizwits.gizwifisdk.enumration.GizWifiDeviceNetStatus Java Examples

The following examples show how to use com.gizwits.gizwifisdk.enumration.GizWifiDeviceNetStatus. 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
Source File: GosDeviceControlModuleBaseActivity.java    From Gizwits-SmartBuld_Android with MIT License 5 votes vote down vote up
/**
	 * <p>
	 * Description: 下发控制指令
	 * </p>
	 * 
	 * @param key
	 *            对应的数据点
	 * @param value
	 *            对应数据点的值
	 * @param isShowProgressDialog
	 *            是否弹出提示框,true为弹出
	 */
	protected void sendCommand(String key, Object value) {

		if (device.getNetStatus() != GizWifiDeviceNetStatus.GizDeviceControlled) {
			myToast(R.string.device_no_ready);
			return;
		}
		
//		int sn = 5; // 如果App不使用sn,此处可写成 int sn = 0;
		int sn = 0;
		ConcurrentHashMap<String, Object> command = new ConcurrentHashMap<String, Object>();
		command.put(key, value);
		device.write(command, sn);
	}
 
Example #2
Source File: GosDeviceControlActivity.java    From Gizwits-SmartBuld_Android with MIT License 5 votes vote down vote up
@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 #3
Source File: GosDeviceControlActivity.java    From gokit-android with 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 #4
Source File: GosDeviceListAdapter.java    From GOpenSource_AppKit_Android_AS with MIT License 4 votes vote down vote up
@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 #5
Source File: GosDeviceListActivity.java    From GOpenSource_AppKit_Android_AS with MIT License 4 votes vote down vote up
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 #6
Source File: GosDeviceControlModuleBaseActivity.java    From Gizwits-SmartBuld_Android with MIT License 4 votes vote down vote up
public void didUpdateNetStatus(GizWifiDevice device,
		com.gizwits.gizwifisdk.enumration.GizWifiDeviceNetStatus netStatus) {
	GosDeviceControlModuleBaseActivity.this.didUpdateNetStatus(device, netStatus);
}
 
Example #7
Source File: GosDeviceControlActivity.java    From Gizwits-SmartBuld_Android with MIT License 4 votes vote down vote up
private boolean isDeviceCanBeControlled() {
	return device.getNetStatus() == GizWifiDeviceNetStatus.GizDeviceControlled;
}
 
Example #8
Source File: GosDeviceListAdapter.java    From Gizwits-SmartBuld_Android with MIT License 4 votes vote down vote up
@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 #9
Source File: GosDeviceListActivity.java    From Gizwits-SmartBuld_Android with MIT License 4 votes vote down vote up
private void UpdateUI() {
	if (GosDeviceModuleBaseActivity.deviceslist.isEmpty()) {
		svListGroup.setVisibility(View.GONE);
		llNoDevice.setVisibility(View.VISIBLE);
		return;
	} else {
		llNoDevice.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 #10
Source File: GosDeviceListAdapter.java    From gokit-android with MIT License 4 votes vote down vote up
@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 #11
Source File: GosDeviceListActivity.java    From gokit-android with MIT License 4 votes vote down vote up
private void UpdateUI() {
	if (GosDeviceModuleBaseActivity.deviceslist.isEmpty()) {
		svListGroup.setVisibility(View.GONE);
		llNoDevice.setVisibility(View.VISIBLE);
		return;
	} else {
		llNoDevice.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 #12
Source File: GosControlModuleBaseActivity.java    From gokit-android with MIT License 4 votes vote down vote up
/** 用于设备状态变化 */
public void didUpdateNetStatus(GizWifiDevice device, GizWifiDeviceNetStatus netStatus) {
	GosControlModuleBaseActivity.this.didUpdateNetStatus(device, netStatus);
}
 
Example #13
Source File: GosDeviceControlActivity.java    From gokit-android with MIT License 4 votes vote down vote up
private boolean isDeviceCanBeControlled() {
	return mDevice.getNetStatus() == GizWifiDeviceNetStatus.GizDeviceControlled;
}
 
Example #14
Source File: GosDeviceControlModuleBaseActivity.java    From Gizwits-SmartBuld_Android with MIT License 2 votes vote down vote up
protected void didUpdateNetStatus(GizWifiDevice device, GizWifiDeviceNetStatus netStatus) {

	}
 
Example #15
Source File: GosControlModuleBaseActivity.java    From gokit-android with MIT License 2 votes vote down vote up
/**
 * 设备状态变化回调
 * 
 * @param arg0
 * @param arg1
 */
protected void didUpdateNetStatus(GizWifiDevice device, GizWifiDeviceNetStatus netStatus) {
}