1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-29 12:05:53 +01:00

Some more lint warnings fixed

This commit is contained in:
cpfeiffer 2015-11-23 23:04:46 +01:00
parent 95dc67c98d
commit bd0716ba58
41 changed files with 71 additions and 72 deletions

View File

@ -8,7 +8,7 @@ import java.util.HashSet;
import java.util.Set;
public abstract class AbstractFragmentPagerAdapter extends FragmentStatePagerAdapter {
private Set<AbstractGBFragment> fragments = new HashSet<>();
private final Set<AbstractGBFragment> fragments = new HashSet<>();
private Object primaryFragment;
public AbstractFragmentPagerAdapter(FragmentManager fm) {

View File

@ -56,7 +56,7 @@ public abstract class AbstractSettingsActivity extends PreferenceActivity {
}
private static class ExtraSetSummaryOnChangeListener extends SimpleSetSummaryOnChangeListener {
private Preference.OnPreferenceChangeListener delegate;
private final Preference.OnPreferenceChangeListener delegate;
public ExtraSetSummaryOnChangeListener(Preference.OnPreferenceChangeListener delegate) {
this.delegate = delegate;
@ -72,7 +72,7 @@ public abstract class AbstractSettingsActivity extends PreferenceActivity {
}
}
private static SimpleSetSummaryOnChangeListener sBindPreferenceSummaryToValueListener = new SimpleSetSummaryOnChangeListener();
private static final SimpleSetSummaryOnChangeListener sBindPreferenceSummaryToValueListener = new SimpleSetSummaryOnChangeListener();
@Override
protected void onPostCreate(Bundle savedInstanceState) {

View File

@ -35,7 +35,7 @@ import nodomain.freeyourgadget.gadgetbridge.R;
public class AppBlacklistActivity extends Activity {
private static final Logger LOG = LoggerFactory.getLogger(AppBlacklistActivity.class);
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();

View File

@ -37,7 +37,7 @@ public class AppManagerActivity extends Activity {
= "nodomain.freeyourgadget.gadgetbridge.appmanager.action.refresh_applist";
private static final Logger LOG = LoggerFactory.getLogger(AppManagerActivity.class);
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();

View File

@ -50,7 +50,7 @@ public class DebugActivity extends Activity {
private Button importDBButton;
private EditText editContent;
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(ControlCenter.ACTION_QUIT)) {

View File

@ -36,9 +36,9 @@ public class DiscoveryActivity extends Activity implements AdapterView.OnItemCli
private static final Logger LOG = LoggerFactory.getLogger(DiscoveryActivity.class);
private static final long SCAN_DURATION = 60000; // 60s
private Handler handler = new Handler();
private final Handler handler = new Handler();
private BroadcastReceiver bluetoothReceiver = new BroadcastReceiver() {
private final BroadcastReceiver bluetoothReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
switch (intent.getAction()) {
@ -78,14 +78,14 @@ public class DiscoveryActivity extends Activity implements AdapterView.OnItemCli
}
};
private BluetoothAdapter.LeScanCallback leScanCallback = new BluetoothAdapter.LeScanCallback() {
private final BluetoothAdapter.LeScanCallback leScanCallback = new BluetoothAdapter.LeScanCallback() {
@Override
public void onLeScan(BluetoothDevice device, int rssi, byte[] scanRecord) {
handleDeviceFound(device, (short) rssi);
}
};
private Runnable stopRunnable = new Runnable() {
private final Runnable stopRunnable = new Runnable() {
@Override
public void run() {
stopDiscovery();
@ -94,7 +94,7 @@ public class DiscoveryActivity extends Activity implements AdapterView.OnItemCli
private ProgressBar progressView;
private BluetoothAdapter adapter;
private ArrayList<GBDeviceCandidate> deviceCandidates = new ArrayList<>();
private final ArrayList<GBDeviceCandidate> deviceCandidates = new ArrayList<>();
private DeviceCandidateAdapter cadidateListAdapter;
private Button startButton;
private Scanning isScanning = Scanning.SCANNING_OFF;

View File

@ -45,7 +45,7 @@ public class FwAppInstallerActivity extends Activity implements InstallActivity
private InstallHandler installHandler;
private boolean mayConnect;
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
@ -72,7 +72,7 @@ public class FwAppInstallerActivity extends Activity implements InstallActivity
};
private ProgressBar mProgressBar;
private ListView itemListView;
private List<ItemWithDetails> mItems = new ArrayList<>();
private final List<ItemWithDetails> mItems = new ArrayList<>();
private ItemWithDetailsAdapter mItemAdapter;
private void refreshBusyState(GBDevice dev) {

View File

@ -60,12 +60,12 @@ import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
* shift the date by one day.
*/
public abstract class AbstractChartFragment extends AbstractGBFragment {
protected int ANIM_TIME = 350;
protected final int ANIM_TIME = 350;
private static final Logger LOG = LoggerFactory.getLogger(AbstractChartFragment.class);
private final Set<String> mIntentFilterActions;
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
AbstractChartFragment.this.onReceive(context, intent);
@ -82,7 +82,7 @@ public abstract class AbstractChartFragment extends AbstractGBFragment {
protected static final class ActivityConfig {
public final int type;
public final String label;
public Integer color;
public final Integer color;
public ActivityConfig(int kind, String label, Integer color) {
this.type = kind;

View File

@ -80,7 +80,7 @@ public class ChartsActivity extends AbstractGBFragmentActivity implements Charts
}
}
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();

View File

@ -60,7 +60,7 @@ public class LiveActivityFragment extends AbstractChartFragment {
private CustomBarChart mStepsPerMinuteCurrentChart;
private CustomBarChart mTotalStepsChart;
private Steps mSteps = new Steps();
private final Steps mSteps = new Steps();
private ScheduledExecutorService pulseScheduler;
private int maxStepsResetCounter;
@ -140,7 +140,7 @@ public class LiveActivityFragment extends AbstractChartFragment {
}
}
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();

View File

@ -26,7 +26,7 @@ public class MiBandPairingActivity extends Activity {
private TextView message;
private boolean isPairing;
private String macAddress;
private BroadcastReceiver mPairingReceiver = new BroadcastReceiver() {
private final BroadcastReceiver mPairingReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (GBDevice.ACTION_DEVICE_CHANGED.equals(intent.getAction())) {

View File

@ -20,7 +20,7 @@ public class MiBandSampleProvider implements SampleProvider {
// public static final byte TYPE_WALKING = 1;
// maybe this should be configurable 256 seems way off, though.
private float movementDivisor = 180.0f; //256.0f;
private final float movementDivisor = 180.0f; //256.0f;
@Override
public int normalizeType(byte rawType) {

View File

@ -207,7 +207,7 @@ public class MiBandService {
*/
private static Map<UUID, String> MIBAND_DEBUG;
private static final Map<UUID, String> MIBAND_DEBUG;
static {
MIBAND_DEBUG = new HashMap<>();

View File

@ -10,13 +10,13 @@ import java.util.Arrays;
*/
public class UserInfo {
private String btAddress;
private String alias;
private int gender;
private int age;
private int height;
private int weight;
private int type;
private final String btAddress;
private final String alias;
private final int gender;
private final int age;
private final int height;
private final int weight;
private final int type;
private byte[] data = new byte[20];

View File

@ -40,8 +40,8 @@ public class VibrationProfile {
private final String id;
private int[] onOffSequence;
private short repeat;
private final int[] onOffSequence;
private final short repeat;
/**
* Creates a new profile instance.

View File

@ -4,7 +4,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
public class MisfitSampleProvider implements SampleProvider {
protected float movementDivisor = 300f;
protected final float movementDivisor = 300f;
@Override
public int normalizeType(byte rawType) {

View File

@ -14,7 +14,7 @@ import java.nio.ByteOrder;
public class STM32CRC {
private int crc;
private byte rem;
private byte buffer[] = {0, 0, 0, 0};
private final byte[] buffer = {0, 0, 0, 0};
private static final int[] crc_table = {
0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9,

View File

@ -1,7 +1,6 @@
package nodomain.freeyourgadget.gadgetbridge.externalevents;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.app.Notification;
import android.app.PendingIntent;
@ -12,7 +11,6 @@ import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.os.PowerManager;
import android.preference.PreferenceManager;
@ -41,7 +39,7 @@ public class NotificationListener extends NotificationListenerService {
public static final String ACTION_MUTE
= "nodomain.freeyourgadget.gadgetbridge.notificationlistener.action.mute";
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@SuppressLint("NewApi")
@Override
public void onReceive(Context context, Intent intent) {

View File

@ -18,7 +18,7 @@ import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PR
public class GBAlarm implements Alarm {
private int index;
private final int index;
private boolean enabled;
private boolean smartWakeup;
private int repetition;

View File

@ -14,8 +14,8 @@ import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
* support this candidate, will the candidate be promoted to a GBDevice.
*/
public class GBDeviceCandidate implements Parcelable {
private BluetoothDevice device;
private short rssi;
private final BluetoothDevice device;
private final short rssi;
private DeviceType deviceType = DeviceType.UNKNOWN;
public GBDeviceCandidate(BluetoothDevice device, short rssi) {

View File

@ -5,7 +5,7 @@ import android.content.Context;
import nodomain.freeyourgadget.gadgetbridge.R;
public class ActivityAmount {
private int activityKind;
private final int activityKind;
private short percent;
private long totalSeconds;

View File

@ -4,7 +4,7 @@ import java.util.ArrayList;
import java.util.List;
public class ActivityAmounts {
private List<ActivityAmount> amounts = new ArrayList<>(4);
private final List<ActivityAmount> amounts = new ArrayList<>(4);
private long totalSeconds;
public void addAmount(ActivityAmount amount) {

View File

@ -93,7 +93,7 @@ public class DeviceCommunicationService extends Service {
private MusicPlaybackReceiver mMusicPlaybackReceiver = null;
private TimeChangeReceiver mTimeChangeReceiver = null;
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();

View File

@ -18,7 +18,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.GB;
public class DeviceSupportFactory {
private final BluetoothAdapter mBtAdapter;
private Context mContext;
private final Context mContext;
public DeviceSupportFactory(Context context) {
mContext = context;

View File

@ -33,7 +33,7 @@ public abstract class AbstractBTLEDeviceSupport extends AbstractDeviceSupport im
private BtLEQueue mQueue;
private HashMap<UUID, BluetoothGattCharacteristic> mAvailableCharacteristics;
private Set<UUID> mSupportedServices = new HashSet<>(4);
private final Set<UUID> mSupportedServices = new HashSet<>(4);
public static final String BASE_UUID = "0000%s-0000-1000-8000-00805f9b34fb"; //this is common for all BTLE devices. see http://stackoverflow.com/questions/18699251/finding-out-android-bluetooth-le-gatt-profiles

View File

@ -31,8 +31,8 @@ public final class BtLEQueue {
private static final Logger LOG = LoggerFactory.getLogger(BtLEQueue.class);
private final Object mGattMonitor = new Object();
private GBDevice mGbDevice;
private BluetoothAdapter mBluetoothAdapter;
private final GBDevice mGbDevice;
private final BluetoothAdapter mBluetoothAdapter;
private BluetoothGatt mBluetoothGatt;
/**
* When an automatic reconnect was attempted after a connection breakdown (error)
@ -41,12 +41,12 @@ public final class BtLEQueue {
private static final long MIN_MILLIS_BEFORE_RECONNECT = 1000 * 60 * 5; // 5 minutes
private volatile BlockingQueue<Transaction> mTransactions = new LinkedBlockingQueue<>();
private final BlockingQueue<Transaction> mTransactions = new LinkedBlockingQueue<>();
private volatile boolean mDisposed;
private volatile boolean mCrashed;
private volatile boolean mAbortTransaction;
private Context mContext;
private final Context mContext;
private CountDownLatch mWaitForActionResultLatch;
private CountDownLatch mConnectionLatch;
private BluetoothGattCharacteristic mWaitCharacteristic;
@ -284,7 +284,7 @@ public final class BtLEQueue {
private
@Nullable
GattCallback mTransactionGattCallback;
private GattCallback mExternalGattCallback;
private final GattCallback mExternalGattCallback;
public InternalGattCallback(GattCallback externalGattCallback) {
mExternalGattCallback = externalGattCallback;

View File

@ -178,7 +178,7 @@ public class GattCharacteristic {
//do we need this?
private static Map<UUID, String> GATTCHARACTERISTIC_DEBUG;
private static final Map<UUID, String> GATTCHARACTERISTIC_DEBUG;
static {
GATTCHARACTERISTIC_DEBUG = new HashMap<>();

View File

@ -43,7 +43,7 @@ public class GattService {
//do we need this?
private static Map<UUID, String> GATTSERVICE_DEBUG;
private static final Map<UUID, String> GATTSERVICE_DEBUG;
static {
GATTSERVICE_DEBUG = new HashMap<>();

View File

@ -16,9 +16,9 @@ import java.util.Locale;
* @author TREND
*/
public class Transaction {
private String mName;
private List<BtLEAction> mActions = new ArrayList<>(4);
private long creationTimestamp = System.currentTimeMillis();
private final String mName;
private final List<BtLEAction> mActions = new ArrayList<>(4);
private final long creationTimestamp = System.currentTimeMillis();
private
@Nullable
GattCallback gattCallback;

View File

@ -14,7 +14,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.WriteAction;
public class TransactionBuilder {
private static final Logger LOG = LoggerFactory.getLogger(TransactionBuilder.class);
private Transaction mTransaction;
private final Transaction mTransaction;
private boolean mQueued;
public TransactionBuilder(String taskName) {

View File

@ -7,9 +7,9 @@ import nodomain.freeyourgadget.gadgetbridge.util.GB;
public class SetProgressAction extends PlainAction {
private String text;
private boolean ongoing;
private int percentage;
private final String text;
private final boolean ongoing;
private final int percentage;
private final Context context;
/**

View File

@ -4,7 +4,7 @@ import android.bluetooth.BluetoothGatt;
public class WaitAction extends PlainAction {
private int mMillis;
private final int mMillis;
public WaitAction(int millis) {
mMillis = millis;

View File

@ -13,7 +13,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.btle.BtLEAction;
*/
public class WriteAction extends BtLEAction {
private byte[] value;
private final byte[] value;
public WriteAction(BluetoothGattCharacteristic characteristic, byte[] value) {
super(characteristic);

View File

@ -1,7 +1,7 @@
package nodomain.freeyourgadget.gadgetbridge.service.devices.miband;
public class AbstractInfo {
protected byte[] mData;
protected final byte[] mData;
public AbstractInfo(byte[] data) {
mData = new byte[data.length];

View File

@ -78,8 +78,8 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
private DeviceInfo mDeviceInfo;
GBDeviceEventVersionInfo versionCmd = new GBDeviceEventVersionInfo();
GBDeviceEventBatteryInfo batteryCmd = new GBDeviceEventBatteryInfo();
private final GBDeviceEventVersionInfo versionCmd = new GBDeviceEventVersionInfo();
private final GBDeviceEventBatteryInfo batteryCmd = new GBDeviceEventBatteryInfo();
public MiBandSupport() {
addSupportedService(GattService.UUID_SERVICE_GENERIC_ACCESS);

View File

@ -50,13 +50,13 @@ public class FetchActivityOperation extends AbstractBTLEOperation<MiBandSupport>
//private ScheduledExecutorService scheduleTaskExecutor;
//private ScheduledFuture scheduledTask;
private int activityMetadataLength = 11;
private final int activityMetadataLength = 11;
//temporary buffer, size is a multiple of 60 because we want to store complete minutes (1 minute = 3 bytes)
private static final int activityDataHolderSize = 3 * 60 * 4; // 4h
private static class ActivityStruct {
private byte[] activityDataHolder = new byte[activityDataHolderSize];
private final byte[] activityDataHolder = new byte[activityDataHolderSize];
//index of the buffer above
private int activityDataHolderProgress = 0;
//number of bytes we will get in a single data transfer, used as counter

View File

@ -56,7 +56,7 @@ public class PebbleIoThread extends GBDeviceIoThread {
public static final String PEBBLEKIT_ACTION_APP_START = "com.getpebble.action.app.START";
public static final String PEBBLEKIT_ACTION_APP_STOP = "com.getpebble.action.app.STOP";
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getContext());
final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getContext());
private final PebbleProtocol mPebbleProtocol;
private final PebbleSupport mPebbleSupport;
@ -419,6 +419,7 @@ public class PebbleIoThread extends GBDeviceIoThread {
mOutStream.flush();
}
} catch (IOException e) {
LOG.error("Error writing.", e);
}
}

View File

@ -228,7 +228,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
"snowy_evt2", "snowy_dvt", "spalding_dvt", "snowy_s3", "spalding"
};
private static Random mRandom = new Random();
private static final Random mRandom = new Random();
boolean isFw3x = false;
boolean mForceProtocol = false;
@ -327,14 +327,14 @@ public class PebbleProtocol extends GBDeviceProtocol {
byte last_id = -1;
private ArrayList<UUID> tmpUUIDS = new ArrayList<>();
private final ArrayList<UUID> tmpUUIDS = new ArrayList<>();
private static final UUID UUID_GBPEBBLE = UUID.fromString("61476764-7465-7262-6469-656775527a6c");
private static final UUID UUID_MORPHEUZ = UUID.fromString("5be44f1d-d262-4ea6-aa30-ddbec1e3cab2");
private static final UUID UUID_WHETHERNEAT = UUID.fromString("3684003b-a685-45f9-a713-abc6364ba051");
private static final UUID UUID_MISFIT = UUID.fromString("0b73b76a-cd65-4dc2-9585-aaa213320858");
private static Map<UUID, AppMessageHandler> mAppMessageHandlers = new HashMap<>();
private static final Map<UUID, AppMessageHandler> mAppMessageHandlers = new HashMap<>();
{
mAppMessageHandlers.put(UUID_GBPEBBLE, new AppMessageHandlerGBPebble(UUID_GBPEBBLE, PebbleProtocol.this));

View File

@ -13,7 +13,7 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
public class DeviceHelper {
private static DeviceHelper instance = new DeviceHelper();
private static final DeviceHelper instance = new DeviceHelper();
public static DeviceHelper getInstance() {
return instance;

View File

@ -19,7 +19,7 @@ import nodomain.freeyourgadget.gadgetbridge.test.MockHelper;
public abstract class AbstractServiceTestCase<T extends Service> {
private static final int ID = -1; // currently not supported
private Class<T> mServiceClass;
private final Class<T> mServiceClass;
private T mServiceInstance;
private Context mContext;
private Application mApplication;

View File

@ -12,7 +12,7 @@ import java.util.Map;
public class GBMockIntent extends Intent {
private String mAction;
private Map<String,Object> extras = new HashMap<>();
private final Map<String,Object> extras = new HashMap<>();
@NonNull
@Override