This test rule is now in the 'test-rules' support repository. Use that one!
https://developer.android.com/reference/android/support/test/rule/ActivityTestRule.html
/** | |
* Transforms an observable to run on a new thread | |
* and to be observed on Androids main thread. | |
*/ | |
public static <T> Observable.Transformer<T, T> androidAsync() { | |
return new Observable.Transformer<T, T>() { | |
@Override | |
public Observable<T> call(Observable<T> observable) { | |
return observable | |
.subscribeOn(Schedulers.newThread()) |
<?xml version="1.0"?> | |
<!DOCTYPE module PUBLIC | |
"-//Puppy Crawl//DTD Check Configuration 1.2//EN" | |
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd"> | |
<module name="Checker"> | |
<module name="FileLength"><property name="max" value="800"/></module> | |
<module name="TreeWalker"> | |
<module name="MethodLength"><property name="max" value="60"/></module> |
<?xml version="1.0" encoding="utf-8"?> | |
<!-- | |
Copyright (C) 2015 The Android Open Source Project | |
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 |
public static Bitmap blur(View v) { | |
return blur(v.getContext(), getScreenshot(v)); | |
} | |
public static void blur(Activity activity) { | |
Window window = activity.getWindow(); | |
BlurredDiceActivity.sBlurredBackgroundImage = blur(activity, getScreenshot(window.getDecorView())); | |
} | |
public static Bitmap blur(Context ctx, Bitmap image) { |
/** | |
* Show the activity over the lockscreen and wake up the device. If you launched the app manually | |
* both of these conditions are already true. If you deployed from the IDE, however, this will | |
* save you from hundreds of power button presses and pattern swiping per day! | |
*/ | |
public static void riseAndShine(Activity activity) { | |
activity.getWindow().addFlags(FLAG_SHOW_WHEN_LOCKED); | |
PowerManager power = (PowerManager) activity.getSystemService(POWER_SERVICE); | |
PowerManager.WakeLock lock = |
This test rule is now in the 'test-rules' support repository. Use that one!
https://developer.android.com/reference/android/support/test/rule/ActivityTestRule.html
Trying this plugin: https://github.com/kageiit/gradle-robojava-plugin
I am starting from a Blank Activity wizard hello world project - nothing fancy. I stashed by attempts at the manual configuration route that I was pursuing yesterday.
Used the drop down menu, selected Java at the very bottom.
/* | |
* Copyright 2014 Chris Banes | |
* | |
* 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 |
private Notification buildNotification() { | |
NotificationCompat.Builder builder = new NotificationCompat.Builder(context) | |
.setCategory(NotificationCompat.CATEGORY_EVENT) | |
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE) // default | |
.setContentTitle(title) | |
.setContentText(shortText) | |
.setStyle(new NotificationCompat.BigTextStyle().bigText(fullText)) | |
.setSmallIcon(R.drawable.ic_stat_notification) | |
.setColor(context.getResources().getColor(R.color.my_color)) | |
.setContentIntent(intent); |
import android.view.View; | |
import org.hamcrest.Description; | |
import org.hamcrest.Matcher; | |
import org.hamcrest.TypeSafeMatcher; | |
import static org.hamcrest.Matchers.is; | |
public class CustomMatchers { | |
public static Matcher<View> withResourceName(String resourceName) { |