1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-03 17:02:13 +01:00

Avoid potential NPE when subclasses return null for rawKindSampleProperty

This commit is contained in:
cpfeiffer 2016-08-27 15:36:42 +02:00
parent 350e72d534
commit ec0db033b1

View File

@ -1,5 +1,8 @@
package nodomain.freeyourgadget.gadgetbridge.devices; package nodomain.freeyourgadget.gadgetbridge.devices;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -110,6 +113,10 @@ public abstract class AbstractSampleProvider<T extends AbstractActivitySample> i
return null; return null;
} }
Property rawKindProperty = getRawKindSampleProperty(); Property rawKindProperty = getRawKindSampleProperty();
if (rawKindProperty == null) {
return null;
}
if (dbActivityTypes.length == 1) { if (dbActivityTypes.length == 1) {
return rawKindProperty.eq(dbActivityTypes[0]); return rawKindProperty.eq(dbActivityTypes[0]);
} }
@ -142,7 +149,12 @@ public abstract class AbstractSampleProvider<T extends AbstractActivitySample> i
public abstract AbstractDao<T,?> getSampleDao(); public abstract AbstractDao<T,?> getSampleDao();
@Nullable
protected abstract Property getRawKindSampleProperty(); protected abstract Property getRawKindSampleProperty();
@NonNull
protected abstract Property getTimestampSampleProperty(); protected abstract Property getTimestampSampleProperty();
@NonNull
protected abstract Property getDeviceIdentifierSampleProperty(); protected abstract Property getDeviceIdentifierSampleProperty();
} }