Skip to content

Instantly share code, notes, and snippets.

Rodrigo Sicarelli rsicarelli

  • Amsterdam
Block or report user

Report or block rsicarelli

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View SpannableTextView
class SpannableTextView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyle: Int = 0
) : TextView(context, attrs, defStyle) {
fun setSpannableText(vararg texts: SpannableStyle) {
buildWith(breaker = " ", blocks = *texts)
}
View Example with Espresso intercepting Intent
public static Intent getCallingIntent(Context context, ArrayList<GalleryPhoto> imagesOnDevice) {
Intent intent = new Intent(context, GalleryActivity.class);
intent.putParcelableArrayListExtra(EXTRA_IMAGES_ON_DEVICE, imagesOnDevice);
return intent;
}
...
@Test
public void someTest() {
View Espresso Intents use case
@Test
public void shouldShareImageFromGallery() {
Instrumentation.ActivityResult result = new Instrumentation.ActivityResult(Activity.RESULT_OK, data);
intending(hasAction(Intent.ACTION_CHOOSER)).respondWith(result);
onView(withId(R.id.share)).perform(click());
intended(allOf(
hasExtras(allOf(
View Sharing image Android Intent
public void shareImage(String text, Uri imageUri) {
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
shareIntent.setType("image/*");
activity.startActivity(Intent.createChooser(shareIntent, text));
}
View Using intending method on Espresso
@Test
public void shouldSelectImageOnCamera() {
Instrumentation.ActivityResult result = new Instrumentation.ActivityResult(Activity.RESULT_OK, data);
intending(hasAction(MediaStore.ACTION_IMAGE_CAPTURE)).respondWith(result);
onView(withId(R.id.camera)).perform(click());
}
View Espresso Intents API initialization
@Test
public void someTest() {
Intents.init();
onView(withId(R.id.some_id)).perform(click());
Intents.release();
}
View ActivityTestRule Espresso Android
@Rule
public ActivityTestRule activityRule = new ActivityTestRule<>(
MainActivity.class,
true, // initialTouchMode
false); // launchActivity. False to set intent per method
View Navigate to camera Android
public void navigateToCamera(Uri photoLocalUri, int requestImageCapture) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, photoLocalUri);
activity.startActivityForResult(intent, requestImageCapture);
}
View Android type family possibilities
Added in Android Jelly Bean (4.1) - API 16 :
Regular (default):
<item name="android:fontFamily">sans-serif</item>
<item name="android:textStyle">normal</item>
Italic:
<item name="android:fontFamily">sans-serif</item>
<item name="android:textStyle">italic</item>
View fabric android
//build.gradle do root do projeto
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'io.fabric.tools:gradle:1.+'
}
You can’t perform that action at this time.