Remove Android specific URI from ContractClass

This commit is contained in:
Benedikt Elser 2018-07-13 16:21:06 +02:00
parent 26017dce2c
commit 89b0a350bc
3 changed files with 10 additions and 16 deletions

View File

@ -114,7 +114,7 @@ public class HRContentProvider extends ContentProvider {
// This notifies the observer
getContext().
getContentResolver().
notifyChange(HRContentProviderContract.REALTIME_URI, null);
notifyChange(Uri.parse(HRContentProviderContract.REALTIME_URL), null);
break;
default:
break;

View File

@ -16,8 +16,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.contentprovider;
import android.net.Uri;
public final class HRContentProviderContract {
public static final String COLUMN_STATUS = "Status";
@ -35,13 +33,9 @@ public final class HRContentProviderContract {
public static final String AUTHORITY = "nodomain.freeyourgadget.gadgetbridge.realtimesamples.provider";
static final String ACTIVITY_START_URL = "content://" + AUTHORITY + "/activity_start";
static final String ACTIVITY_STOP_URL = "content://" + AUTHORITY + "/activity_stop";
static final String REALTIME_URL = "content://" + AUTHORITY + "/realtime";
static final String DEVICES_URL = "content://" + AUTHORITY + "/devices";
public static final String ACTIVITY_START_URL = "content://" + AUTHORITY + "/activity_start";
public static final String ACTIVITY_STOP_URL = "content://" + AUTHORITY + "/activity_stop";
public static final String REALTIME_URL = "content://" + AUTHORITY + "/realtime";
public static final String DEVICES_URL = "content://" + AUTHORITY + "/devices";
public static final Uri ACTIVITY_START_URI = Uri.parse(ACTIVITY_START_URL);
public static final Uri ACTIVITY_STOP_URI = Uri.parse(ACTIVITY_STOP_URL);
public static final Uri REALTIME_URI = Uri.parse(REALTIME_URL);
public static final Uri DEVICES_URI = Uri.parse(DEVICES_URL);
}

View File

@ -240,7 +240,7 @@ public class SampleProviderTest extends TestBase {
/*
* Test the device uri
*/
cursor = mContentResolver.query(HRContentProviderContract.DEVICES_URI, null, null, null, null);
cursor = mContentResolver.query(Uri.parse(HRContentProviderContract.DEVICES_URL), null, null, null, null);
assertNotNull(cursor);
assertEquals(1, cursor.getCount());
@ -258,7 +258,7 @@ public class SampleProviderTest extends TestBase {
/*
* Test the activity start uri
*/
cursor = mContentResolver.query(HRContentProviderContract.ACTIVITY_START_URI, null, null, null, null);
cursor = mContentResolver.query(Uri.parse(HRContentProviderContract.ACTIVITY_START_URL), null, null, null, null);
if (cursor.moveToFirst()) {
do {
String status = cursor.getString(0);
@ -272,7 +272,7 @@ public class SampleProviderTest extends TestBase {
/*
* Test the activity stop uri
*/
cursor = mContentResolver.query(HRContentProviderContract.ACTIVITY_STOP_URI, null, null, null, null);
cursor = mContentResolver.query(Uri.parse(HRContentProviderContract.ACTIVITY_STOP_URL), null, null, null, null);
if (cursor.moveToFirst()) {
do {
String status = cursor.getString(0);
@ -295,7 +295,7 @@ public class SampleProviderTest extends TestBase {
@Override
public void onChange(boolean selfChange, Uri uri) {
super.onChange(selfChange, uri);
Cursor cursor = mContentResolver.query(HRContentProviderContract.REALTIME_URI, null, null, null, null);
Cursor cursor = mContentResolver.query(Uri.parse(HRContentProviderContract.REALTIME_URL), null, null, null, null);
if (cursor.moveToFirst()) {
do {
String status = cursor.getString(0);
@ -311,7 +311,7 @@ public class SampleProviderTest extends TestBase {
}
A1 a1 = new A1();
mContentResolver.registerContentObserver(HRContentProviderContract.REALTIME_URI, false, a1);
mContentResolver.registerContentObserver(Uri.parse(HRContentProviderContract.REALTIME_URL), false, a1);
generateSampleStream(sampleProvider);
assertEquals(a1.numObserved, 10);