Skip to content

Instantly share code, notes, and snippets.

@wingoku
wingoku / Rx Alert Dialog
Created August 27, 2017 18:45
Following is the Rxified version of AlertDialog. Feel free to include it in your code.
public static Completable showAlertDialog(final Context context, final String title, final String message, final String positiveButtonText, final String negativeButtonText) {
return Completable.create(new CompletableOnSubscribe() {
@Override
public void subscribe(@NonNull final CompletableEmitter e) throws Exception {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(title);
builder.setMessage(message);
builder.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
package com.wingoku.example;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.support.test.espresso.idling.CountingIdlingResource;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class MainActivity extends AppCompatActivity {
/*
* Copyright (C) 2016 Umer Farooq (wingoku)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* Copyright (C) 2016 Umer Farooq (wingoku)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* Copyright (C) 2016 Umer Farooq (wingoku)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* Copyright (C) 2016 Umer Farooq (wingoku)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* Copyright (C) 2016 Umer Farooq (wingoku)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* Copyright (C) 2016 Umer Farooq (wingoku)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
package com.wingoku.myTests;
import android.app.Activity;
import android.app.Instrumentation;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Looper;
import android.support.test.InstrumentationRegistry;
import android.support.test.espresso.Espresso;
Add this class to your project, sample: https://github.com/tajchert/ShapeWear/blob/master/wear/src/main/java/pl/tajchert/shapewearsample/MainActivity.java
To start call `ShapeWear.initShapeWear(this);` and in most basic case use `ShapeWear.isRound()` to check if device screen is round.
Source: https://github.com/tajchert/ShapeWear
```java
package pl.tajchert.shapewear;
/*