android.database.Observable Java Examples

The following examples show how to use android.database.Observable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestUtils.java    From FeatureAdapter with Apache License 2.0 6 votes vote down vote up
/**
 * Fixes internal dependencies to android.database.Observable so that a RecyclerView.Adapter can
 * be tested using regular unit tests while verifying changes to the data.
 *
 * <p>Pulled from:
 * https://github.com/badoo/Chateau/blob/master/ExampleApp/src/test/java/com/badoo/chateau/example/ui/utils/TestUtils.java
 */
public static RecyclerView.AdapterDataObserver fixAdapterForTesting(RecyclerView.Adapter adapter)
    throws NoSuchFieldException, IllegalAccessException {
  // Observables are not mocked by default so we need to hook the adapter up to an observer so we can track changes
  Field observableField = RecyclerView.Adapter.class.getDeclaredField("mObservable");
  observableField.setAccessible(true);
  Object observable = observableField.get(adapter);
  Field observersField = Observable.class.getDeclaredField("mObservers");
  observersField.setAccessible(true);
  final ArrayList<Object> observers = new ArrayList<>();
  RecyclerView.AdapterDataObserver dataObserver =
      createMock(RecyclerView.AdapterDataObserver.class);
  observers.add(dataObserver);
  observersField.set(observable, observers);
  return dataObserver;
}
 
Example #2
Source File: TestUtils.java    From expandable-recycler-view with MIT License 5 votes vote down vote up
/**
 * Fixes internal dependencies to android.database.Observable so that a RecyclerView.Adapter
 * can be tested using regular unit tests while verifying changes to the data.
 *
 * Pulled from: https://github.com/badoo/Chateau/blob/master/ExampleApp/src/test/java/com/badoo/chateau/example/ui/utils/TestUtils.java
 */
public static RecyclerView.AdapterDataObserver fixAdapterForTesting(RecyclerView.Adapter adapter) throws NoSuchFieldException, IllegalAccessException {
    // Observables are not mocked by default so we need to hook the adapter up to an observer so we can track changes
    Field observableField = RecyclerView.Adapter.class.getDeclaredField("mObservable");
    observableField.setAccessible(true);
    Object observable = observableField.get(adapter);
    Field observersField = Observable.class.getDeclaredField("mObservers");
    observersField.setAccessible(true);
    final ArrayList<Object> observers = new ArrayList<>();
    RecyclerView.AdapterDataObserver dataObserver = mock(RecyclerView.AdapterDataObserver.class);
    observers.add(dataObserver);
    observersField.set(observable, observers);
    return dataObserver;
}
 
Example #3
Source File: ApiInterface.java    From Android-Bluetooth-Fingerprint with Apache License 2.0 4 votes vote down vote up
@Headers("Authorization :" + AUTHORIZATION)
@POST(CAPTURE)
Observable<CaptureItem> capture(@Body JSONObject payload);
 
Example #4
Source File: ApiInterface.java    From Android-Bluetooth-Fingerprint with Apache License 2.0 4 votes vote down vote up
@Headers("Authorization :" + AUTHORIZATION)
@GET(GET_ENROLL)
Observable<List<EnrollItem>> getEnroll(@Query("item_pos") String item_pos);
 
Example #5
Source File: ApiInterface.java    From Android-Bluetooth-Fingerprint with Apache License 2.0 4 votes vote down vote up
@Headers("Authorization :" + AUTHORIZATION)
@GET(GET_CAPTURE)
Observable<List<CaptureItem>> getCapture(@Query("item_pos") String item_pos);
 
Example #6
Source File: FetchNewest.java    From MaterialWpp with Apache License 2.0 4 votes vote down vote up
@GET("index.php/3/Wallpaper/picLatest/start/{start}/limit/{limit}/")
Observable<NewestData> fetchNewestData(@Path("start") int start,@Path("limit") int limit);