Skip to content

Instantly share code, notes, and snippets.

View orhanobut's full-sized avatar

Orhan Obut orhanobut

View GitHub Profile
public class MainActivity extends Activity {
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SpannableString spannable = new SpannableString("aasdfasasdfasdfasdf span span");
spannable.setSpan(
new LineBackgroundSpan() {
@Override public void drawBackground(Canvas c, Paint p, int left, int right, int top, int baseline, int bottom,
class MyApplication extends Application {
Override public void onCreate(){
super.onCreate();
Stetho.initializeWithDefaults(this);
}
}
public class StethoUtils {
private StethoUtils() {
// no instance
}
public static void init(Context context) {
// no-op
}
public class MyApplication extends Application {
@Override public void onCreate(){
super.onCreate();
StethoUtils.init(this);
}
}
public class StethoUtils {
private StethoUtils() {
// no instance
}
public static void init(Context context) {
Stetho.initializeWithDefaults(context);
}
Thread thread = new Thread(new Runnable() {
@Override public void run() {
// your long task
textView.setText("Task 4 Result"); //update view
}
});
thread.start();
@Test public void shouldReturnPredictionsSuccessfully() throws Exception {
String queryToAutoComplete = "berlin";
PendingResult<AutocompletePredictionBuffer> result =
Places.GeoDataApi.getAutocompletePredictions(apiClient, queryToAutoComplete, null, null);
AutocompletePredictionBuffer predictions = result.await(3, SECONDS);
Status status = predictions.getStatus();
assertThat(status.isSuccess()).isTrue();
// more assertions
@RunWith(AndroidJUnit4.class)
public class GooglePlacesApiTest {
private GoogleApiClient apiClient;
@Before public void setup() throws InterruptedException {
Context context = InstrumentationRegistery.getContext();
final CountDownLatch latch = new CountDownLatch(1);
apiClient = new GoogleApiClient.Builder(context)
.addApi(Places.GEO_DATA_API)
@RunWith(AndroidJUnit4.class)
public class GooglePlacesApiTest {
GoogleApiClient apiClient;
@Before public void setup() throws InterruptedException {
Context context = InstrumentationRegistery.getContext();
apiClient = new GoogleApiClient.Builder(context)
.addApi(Places.GEO_DATA_API)
class Account {
private void save(String value) {
DiskPersistent.getInstance().save(value);
}
}