use of android.net.wifi.ScanResult in project wifilibrary by LiShiHui24740.
the class WifiAdmin method getWifiListWithFilting.
public synchronized List<ScanResult> getWifiListWithFilting() {
updateWifiList();
if (mWifiList != null) {
ArrayList<ScanResult> removeList = new ArrayList<>();
ScanResult connect_scanResult = null;
int size = mWifiList.size();
for (int i = 0; i < size; i++) {
if (TextUtils.isEmpty(mWifiList.get(i).SSID)) {
removeList.add(mWifiList.get(i));
} else {
for (int j = i + 1; j < size; j++) {
if (mWifiList.get(i).SSID.equals(mWifiList.get(j).SSID)) {
removeList.add(mWifiList.get(i));
}
}
}
}
mWifiList.removeAll(removeList);
removeList.clear();
for (ScanResult scanResult : mWifiList) {
if (scanResult.BSSID.equals(getBSSID())) {
removeList.add(scanResult);
connect_scanResult = scanResult;
}
}
mWifiList.removeAll(removeList);
removeList.clear();
if (connect_scanResult != null) {
mWifiList.add(0, connect_scanResult);
}
}
if (filterWifiLists != null) {
filterWifiLists.clear();
filterWifiLists.addAll(mWifiList);
}
return filterWifiLists;
}
use of android.net.wifi.ScanResult in project wifilibrary by LiShiHui24740.
the class WifiAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder;
if (convertView == null) {
convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.wifi_adapter_item_layout, parent, false);
viewHolder = new ViewHolder();
viewHolder.connected = (ImageView) convertView.findViewById(R.id.id_iv_wifi_connected);
viewHolder.name = (TextView) convertView.findViewById(R.id.id_tv_wifi_ssid_name);
viewHolder.lock = (ImageView) convertView.findViewById(R.id.id_iv_wifi_lock);
viewHolder.wifi = (ImageView) convertView.findViewById(R.id.id_iv_wifi_signal);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
ScanResult result = getItem(position);
if (result.BSSID.equals(WifiAdmin.getInstance(parent.getContext()).getBSSID()) && NetUtils.isWifi(parent.getContext())) {
if (mPresenter != null && TextUtils.isEmpty(mPresenter.getPassWord(result.SSID)))
mPresenter.savePassword(result.SSID);
viewHolder.connected.setVisibility(View.VISIBLE);
} else {
viewHolder.connected.setVisibility(View.INVISIBLE);
}
if (textSize != 0) {
viewHolder.name.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
}
if (textColor != 0) {
viewHolder.name.setTextColor(textColor);
}
viewHolder.name.setText(result.SSID);
String security = "";
if (!TextUtils.isEmpty(result.capabilities))
security = result.capabilities.toLowerCase();
if (security.contains("wpa")) {
viewHolder.lock.setVisibility(View.VISIBLE);
} else if (security.contains("wep")) {
viewHolder.lock.setVisibility(View.VISIBLE);
} else {
viewHolder.lock.setVisibility(View.INVISIBLE);
}
int signalLevel = WifiManager.calculateSignalLevel(result.level, 4);
viewHolder.wifi.setVisibility(View.VISIBLE);
switch(signalLevel) {
case -1:
viewHolder.wifi.setVisibility(View.INVISIBLE);
break;
case 0:
viewHolder.wifi.setVisibility(View.VISIBLE);
viewHolder.wifi.setImageResource(R.drawable.ic_set_wifi_1);
break;
case 1:
viewHolder.wifi.setVisibility(View.VISIBLE);
viewHolder.wifi.setImageResource(R.drawable.ic_set_wifi_2);
break;
case 2:
viewHolder.wifi.setVisibility(View.VISIBLE);
viewHolder.wifi.setImageResource(R.drawable.ic_set_wifi_3);
break;
case 3:
viewHolder.wifi.setVisibility(View.VISIBLE);
viewHolder.wifi.setImageResource(R.drawable.ic_set_wifi_4);
break;
}
return convertView;
}
use of android.net.wifi.ScanResult in project android_packages_apps_Settings by crdroidandroid.
the class WifiStatusTest method handleScanResultsAvailable.
private void handleScanResultsAvailable() {
List<ScanResult> list = mWifiManager.getScanResults();
StringBuffer scanList = new StringBuffer();
if (list != null) {
for (int i = list.size() - 1; i >= 0; i--) {
final ScanResult scanResult = list.get(i);
if (scanResult == null) {
continue;
}
if (TextUtils.isEmpty(scanResult.SSID)) {
continue;
}
scanList.append(scanResult.SSID + " ");
}
}
mScanList.setText(scanList);
}
use of android.net.wifi.ScanResult in project android_packages_apps_Settings by LineageOS.
the class WifiStatusTest method handleScanResultsAvailable.
private void handleScanResultsAvailable() {
List<ScanResult> list = mWifiManager.getScanResults();
StringBuffer scanList = new StringBuffer();
if (list != null) {
for (int i = list.size() - 1; i >= 0; i--) {
final ScanResult scanResult = list.get(i);
if (scanResult == null) {
continue;
}
if (TextUtils.isEmpty(scanResult.SSID)) {
continue;
}
scanList.append(scanResult.SSID + " ");
}
}
mScanList.setText(scanList);
}
use of android.net.wifi.ScanResult in project routerkeygenAndroid by routerkeygen.
the class NetworksListFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
RelativeLayout root = (RelativeLayout) inflater.inflate(R.layout.fragment_networks_list, container, false);
listview = (ListView) root.findViewById(R.id.networks_list);
wifiListAdapter = new WifiListAdapter(getActivity());
listview.setAdapter(wifiListAdapter);
noNetworksMessage = root.findViewById(R.id.message_group);
if (savedInstanceState != null) {
if (savedInstanceState.containsKey(NETWORKS_FOUND)) {
Parcelable[] storedNetworksFound = savedInstanceState.getParcelableArray(NETWORKS_FOUND);
networksFound = new ScanResult[storedNetworksFound.length];
for (int i = 0; i < storedNetworksFound.length; ++i) networksFound[i] = (ScanResult) storedNetworksFound[i];
onScanFinished(networksFound);
}
if (savedInstanceState.containsKey(STATE_ACTIVATED_POSITION)) {
setActivatedPosition(savedInstanceState.getInt(STATE_ACTIVATED_POSITION));
}
}
registerForContextMenu(listview);
return root;
}
Aggregations