Fixed some static analysis issues

This commit is contained in:
Alexandros Schillings
2015-07-03 14:43:54 +01:00
parent 56e27ffab1
commit 5f55a3ea45
14 changed files with 16 additions and 50 deletions
@@ -76,7 +76,6 @@ public class DeviceControlActivity extends Activity {
private boolean mConnected = false;
private String mExportString;
private BluetoothLeDevice mDevice;
// Code to manage Service lifecycle.
private final ServiceConnection mServiceConnection = new ServiceConnection() {
@@ -280,9 +279,9 @@ public class DeviceControlActivity extends Activity {
setContentView(R.layout.activity_gatt_services);
final Intent intent = getIntent();
mDevice = intent.getParcelableExtra(EXTRA_DEVICE);
mDeviceName = mDevice.getName();
mDeviceAddress = mDevice.getAddress();
final BluetoothLeDevice device = intent.getParcelableExtra(EXTRA_DEVICE);
mDeviceName = device.getName();
mDeviceAddress = device.getAddress();
ButterKnife.inject(this);
@@ -77,7 +77,7 @@ public class DeviceDetailsActivity extends ListActivity{
CompanyIdentifierResolver.getCompanyName(iBeaconData.getCompanyIdentifier(), getString(R.string.unknown))
+ " (" + hexEncode(iBeaconData.getCompanyIdentifier()) + ")");
tvAdvert.setText(iBeaconData.getIBeaconAdvertisement() + " (" + hexEncode( iBeaconData.getIBeaconAdvertisement() ) + ")");
tvUUID.setText(iBeaconData.getUUID().toString());
tvUUID.setText(iBeaconData.getUUID());
tvMajor.setText(iBeaconData.getMajor() + " (" + hexEncode( iBeaconData.getMajor() ) + ")");
tvMinor.setText(iBeaconData.getMinor() + " (" + hexEncode( iBeaconData.getMinor() ) + ")");
tvTxPower.setText(iBeaconData.getCalibratedTxPower() + " (" + hexEncode( iBeaconData.getCalibratedTxPower() ) + ")");
@@ -35,7 +35,7 @@ public class MainActivity extends ListActivity {
private LeDeviceListAdapter mLeDeviceListAdapter;
private BluetoothLeDeviceStore mDeviceStore;
private BluetoothAdapter.LeScanCallback mLeScanCallback = new BluetoothAdapter.LeScanCallback() {
private final BluetoothAdapter.LeScanCallback mLeScanCallback = new BluetoothAdapter.LeScanCallback() {
@Override
public void onLeScan(final BluetoothDevice device, final int rssi, final byte[] scanRecord) {
@@ -121,10 +121,9 @@ public class MainActivity extends ListActivity {
@Override
protected void onListItemClick(final ListView l, final View v, final int position, final long id) {
final BluetoothLeDevice device = (BluetoothLeDevice) mLeDeviceListAdapter.getItem(position);
final BluetoothLeDevice device = mLeDeviceListAdapter.getItem(position);
if (device == null) return;
final Intent intent = new Intent(this, DeviceDetailsActivity.class);
intent.putExtra(DeviceDetailsActivity.EXTRA_DEVICE, device);
@@ -57,7 +57,7 @@ public class LeDeviceListAdapter extends SimpleCursorAdapter {
viewHolder.ibeaconDistance = (TextView) view.findViewById(R.id.ibeacon_distance);
viewHolder.ibeaconUUID = (TextView) view.findViewById(R.id.ibeacon_uuid);
viewHolder.ibeaconTxPower = (TextView) view.findViewById(R.id.ibeacon_tx_power);
viewHolder.ibeaconSection = (View) view.findViewById(R.id.ibeacon_section);
viewHolder.ibeaconSection = view.findViewById(R.id.ibeacon_section);
viewHolder.ibeaconDistanceDescriptor = (TextView) view.findViewById(R.id.ibeacon_distance_descriptor);
view.setTag(viewHolder);
} else {
@@ -44,7 +44,7 @@ public class BluetoothLeDeviceStore {
}
private FileWriter generateFile(final File file, final String contents){
private static FileWriter generateFile(final File file, final String contents){
FileWriter writer = null;
try {
writer = new FileWriter(file);
@@ -10,14 +10,13 @@ import android.content.pm.PackageManager;
public final class BluetoothUtils {
private final Activity mActivity;
private final BluetoothAdapter mBluetoothAdapter;
private final BluetoothManager mBluetoothManager;
public final static int REQUEST_ENABLE_BT = 2001;
public BluetoothUtils(final Activity activity){
mActivity = activity;
mBluetoothManager = (BluetoothManager) mActivity.getSystemService(Context.BLUETOOTH_SERVICE);
mBluetoothAdapter = mBluetoothManager.getAdapter();
final BluetoothManager btManager = (BluetoothManager) mActivity.getSystemService(Context.BLUETOOTH_SERVICE);
mBluetoothAdapter = btManager.getAdapter();
}
public void askUserToEnableBluetoothIfNeeded(){