fix some lint warnings, mostly simplifications

live-sensor-data
Andreas Shimokawa 2015-05-12 20:09:35 +02:00
parent f8341918ee
commit 1b2f20160a
18 changed files with 39 additions and 65 deletions

View File

@ -50,7 +50,6 @@ public class AppManagerActivity extends Activity {
}
};
final List<GBDeviceApp> appList = new ArrayList<>();
private ListView appListView;
private GBDeviceAppAdapter mGBDeviceAppAdapter;
private GBDeviceApp selectedApp = null;
@ -60,7 +59,7 @@ public class AppManagerActivity extends Activity {
setContentView(R.layout.activity_appmanager);
getActionBar().setDisplayHomeAsUpEnabled(true);
appListView = (ListView) findViewById(R.id.appListView);
ListView appListView = (ListView) findViewById(R.id.appListView);
mGBDeviceAppAdapter = new GBDeviceAppAdapter(this, appList);
appListView.setAdapter(this.mGBDeviceAppAdapter);
registerForContextMenu(appListView);

View File

@ -7,9 +7,9 @@ import nodomain.freeyourgadget.gadgetbridge.discovery.DeviceCandidate;
public interface DeviceCoordinator {
String EXTRA_DEVICE_MAC_ADDRESS = "nodomain.freeyourgadget.gadgetbridge.discovery.DeviceCandidate.EXTRA_MAC_ADDRESS";
public boolean supports(DeviceCandidate candidate);
public boolean supports(GBDevice device);
public DeviceType getDeviceType();
boolean supports(DeviceCandidate candidate);
boolean supports(GBDevice device);
DeviceType getDeviceType();
Class<? extends Activity> getPairingActivity();
}

View File

@ -1,7 +1,5 @@
package nodomain.freeyourgadget.gadgetbridge;
import android.bluetooth.BluetoothClass;
import java.util.ArrayList;
import java.util.List;

View File

@ -15,21 +15,20 @@ import android.content.Context;
* via Bluetooth, Bluetooth LE, Wifi or something else.
*/
public interface DeviceSupport extends EventHandler {
public void initialize(GBDevice gbDevice, BluetoothAdapter btAdapter, Context context);
void initialize(GBDevice gbDevice, BluetoothAdapter btAdapter, Context context);
public boolean isConnected();
boolean isConnected();
public boolean connect();
boolean connect();
public void dispose();
void dispose();
public GBDevice getDevice();
GBDevice getDevice();
public BluetoothAdapter getBluetoothAdapter();
BluetoothAdapter getBluetoothAdapter();
public Context getContext();
Context getContext();
boolean useAutoConnect();
public boolean useAutoConnect();
public void pair();
void pair();
}

View File

@ -1,23 +1,23 @@
package nodomain.freeyourgadget.gadgetbridge;
public interface EventHandler {
public void onSMS(String from, String body);
void onSMS(String from, String body);
public void onEmail(String from, String subject, String body);
void onEmail(String from, String subject, String body);
public void onSetTime(long ts);
void onSetTime(long ts);
public void onSetCallState(String number, String name, GBCommand command);
void onSetCallState(String number, String name, GBCommand command);
public void onSetMusicInfo(String artist, String album, String track);
void onSetMusicInfo(String artist, String album, String track);
public void onFirmwareVersionReq();
void onFirmwareVersionReq();
public void onBatteryInfoReq();
void onBatteryInfoReq();
public void onAppInfoReq();
void onAppInfoReq();
public void onAppDelete(int id, int index);
void onAppDelete(int id, int index);
public void onPhoneVersion(byte os);
void onPhoneVersion(byte os);
}

View File

@ -39,8 +39,6 @@ public class GBCallControlReceiver extends BroadcastReceiver {
}
break;
default:
return;
}
}
}

View File

@ -1,15 +1,8 @@
package nodomain.freeyourgadget.gadgetbridge;
import android.content.Intent;
import android.media.audiofx.BassBoost;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.support.v4.app.NavUtils;
import android.support.v4.content.LocalBroadcastManager;
import android.view.MenuItem;
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractSettingsActivity;
import nodomain.freeyourgadget.gadgetbridge.miband.MiBandPreferencesActivity;
@ -25,7 +18,7 @@ public class SettingsActivity extends AbstractSettingsActivity {
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
Preference pref = (Preference) findPreference("notifications_generic");
Preference pref = findPreference("notifications_generic");
pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
Intent enableIntent = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS");
@ -33,7 +26,7 @@ public class SettingsActivity extends AbstractSettingsActivity {
return true;
}
});
pref = (Preference) findPreference("pref_key_miband");
pref = findPreference("pref_key_miband");
pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
Intent enableIntent = new Intent(SettingsActivity.this, MiBandPreferencesActivity.class);

View File

@ -53,7 +53,7 @@ public class AbstractSettingsActivity extends PreferenceActivity {
preference.setSummary(stringValue);
}
}
};
}
private static class ExtraSetSummaryOnChangeListener extends SimpleSetSummaryOnChangeListener {
private Preference.OnPreferenceChangeListener delegate;

View File

@ -1,10 +1,7 @@
package nodomain.freeyourgadget.gadgetbridge.activities;
import android.app.Activity;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import nodomain.freeyourgadget.gadgetbridge.R;

View File

@ -18,13 +18,11 @@ import nodomain.freeyourgadget.gadgetbridge.discovery.DeviceCandidate;
public class DeviceCandidateAdapter extends ArrayAdapter<DeviceCandidate> {
private final Context context;
private final List<DeviceCandidate> deviceCandidates;
public DeviceCandidateAdapter(Context context, List<DeviceCandidate> deviceCandidates) {
super(context, 0, deviceCandidates);
this.context = context;
this.deviceCandidates = deviceCandidates;
}
@Override

View File

@ -16,13 +16,11 @@ import nodomain.freeyourgadget.gadgetbridge.R;
public class GBDeviceAppAdapter extends ArrayAdapter<GBDeviceApp> {
private final Context context;
private final List<GBDeviceApp> appList;
public GBDeviceAppAdapter(Context context, List<GBDeviceApp> appList) {
super(context, 0, appList);
this.context = context;
this.appList = appList;
}
@Override

View File

@ -33,13 +33,13 @@ public interface GattCallback {
* @param newState
* @see BluetoothGattCallback#onConnectionStateChange(BluetoothGatt, int, int)
*/
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState);
void onConnectionStateChange(BluetoothGatt gatt, int status, int newState);
/**
* @param gatt
* @see BluetoothGattCallback#onServicesDiscovered(BluetoothGatt, int)
*/
public void onServicesDiscovered(BluetoothGatt gatt);
void onServicesDiscovered(BluetoothGatt gatt);
/**
* @param gatt
@ -47,7 +47,7 @@ public interface GattCallback {
* @param status
* @see BluetoothGattCallback#onCharacteristicRead(BluetoothGatt, BluetoothGattCharacteristic, int)
*/
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status);
void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status);
/**
* @param gatt
@ -55,7 +55,7 @@ public interface GattCallback {
* @param status
* @see BluetoothGattCallback#onCharacteristicWrite(BluetoothGatt, BluetoothGattCharacteristic, int)
*/
public void onCharacteristicWrite(BluetoothGatt gatt,
void onCharacteristicWrite(BluetoothGatt gatt,
BluetoothGattCharacteristic characteristic, int status);
/**
@ -63,7 +63,7 @@ public interface GattCallback {
* @param characteristic
* @see BluetoothGattCallback#onCharacteristicChanged(BluetoothGatt, BluetoothGattCharacteristic)
*/
public void onCharacteristicChanged(BluetoothGatt gatt,
void onCharacteristicChanged(BluetoothGatt gatt,
BluetoothGattCharacteristic characteristic);
// /**
@ -97,7 +97,7 @@ public interface GattCallback {
* @param status
* @see BluetoothGattCallback#onReadRemoteRssi(BluetoothGatt, int, int)
*/
public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status);
void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status);
// /**
// * @see BluetoothGattCallback#onMtuChanged(BluetoothGatt, int, int)

View File

@ -93,7 +93,6 @@ public class DiscoveryActivity extends Activity implements AdapterView.OnItemCli
private ProgressBar progressView;
private BluetoothAdapter adapter;
private ArrayList<DeviceCandidate> deviceCandidates = new ArrayList<>();
private ListView deviceCandidatesView;
private DeviceCandidateAdapter cadidateListAdapter;
private Button startButton;
private Scanning isScanning = Scanning.SCANNING_OFF;
@ -122,7 +121,7 @@ public class DiscoveryActivity extends Activity implements AdapterView.OnItemCli
progressView.setProgress(0);
progressView.setIndeterminate(true);
progressView.setVisibility(View.GONE);
deviceCandidatesView = (ListView) findViewById(R.id.discovery_deviceCandidatesView);
ListView deviceCandidatesView = (ListView) findViewById(R.id.discovery_deviceCandidatesView);
cadidateListAdapter = new DeviceCandidateAdapter(this, deviceCandidates);
deviceCandidatesView.setAdapter(cadidateListAdapter);

View File

@ -1,7 +1,5 @@
package nodomain.freeyourgadget.gadgetbridge.miband;
import nodomain.freeyourgadget.gadgetbridge.GB;
public interface MiBandConst {
String PREF_USER_ALIAS = "mi_user_alias";
String PREF_USER_YEAR_OF_BIRTH = "mi_user_year_of_birth";

View File

@ -3,11 +3,9 @@ package nodomain.freeyourgadget.gadgetbridge.miband;
import android.content.Intent;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.support.v4.content.LocalBroadcastManager;
import nodomain.freeyourgadget.gadgetbridge.ControlCenter;
import nodomain.freeyourgadget.gadgetbridge.GB;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractSettingsActivity;

View File

@ -279,8 +279,8 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
if (pairResult.length == 1) {
try {
byte b = pairResult[0];
Integer intValue = Integer.valueOf(b);
if (intValue.intValue() == 2) {
Integer intValue = (int) b;
if (intValue == 2) {
LOG.info("Successfully paired MI device");
return;
}

View File

@ -74,8 +74,7 @@ public class UserInfo {
sequence[u] = normalizedAlias.getBytes()[u - 9];
byte[] crcSequence = new byte[19];
for (int u = 0; u < crcSequence.length; u++)
crcSequence[u] = sequence[u];
System.arraycopy(sequence, 0, crcSequence, 0, crcSequence.length);
sequence[19] = (byte) ((getCRC8(crcSequence) ^ Integer.parseInt(address.substring(address.length() - 2), 16)) & 0xff);

View File

@ -52,7 +52,7 @@ public class PBWReader {
this.uri = uri;
cr = context.getContentResolver();
InputStream fin = null;
InputStream fin;
try {
fin = new BufferedInputStream(cr.openInputStream(uri));
@ -153,7 +153,7 @@ public class PBWReader {
}
public ZipInputStream getInputStreamFile(String filename) {
InputStream fin = null;
InputStream fin;
try {
fin = new BufferedInputStream(cr.openInputStream(uri));
@ -163,7 +163,7 @@ public class PBWReader {
}
ZipInputStream zis = new ZipInputStream(fin);
ZipEntry ze = null;
ZipEntry ze;
try {
while ((ze = zis.getNextEntry()) != null) {
if (ze.getName().equals(filename)) {