This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.myapp; | |
public class SampleApplication extends TestingAwareApplication { | |
@Override | |
protected String getFullyQualifiedTestFile() { | |
return "com.myapp.TestMode"; | |
} | |
@Override | |
protected void initAppInstance() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.Activity; | |
import android.content.Context; | |
import android.os.PowerManager; | |
import android.os.PowerManager.WakeLock; | |
import android.test.ActivityInstrumentationTestCase2; | |
/** | |
* This requires to be declared in the effective manifest: | |
* <uses-permission android:name="android.permission.WAKE_LOCK"/> | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.graphics.Rect; | |
import android.view.MotionEvent; | |
import android.view.TouchDelegate; | |
import android.view.View; | |
import android.view.ViewConfiguration; | |
/** | |
* There is a bug with TouchDelegate where ancestor views can get into an awkward state after | |
* a delegate view has been actioned upon by the touch delegate. | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.graphics.Rect; | |
import android.view.View; | |
import android.widget.CheckBox; | |
/** | |
* Enlarges the effective hit target of a checkbox to more closely match the dimensions of the | |
* provided root view. If the provided root isn't actually an ancestor view of the checkbox, bad | |
* things will happen. | |
* <p/> | |
* See: http://developer.android.com/training/gestures/viewgroup.html#delegate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.demo.okhttpissue; | |
import android.test.InstrumentationTestCase; | |
import com.squareup.okhttp.Callback; | |
import com.squareup.okhttp.OkHttpClient; | |
import com.squareup.okhttp.Request; | |
import com.squareup.okhttp.Response; | |
import com.squareup.okhttp.mockwebserver.MockResponse; | |
import com.squareup.okhttp.mockwebserver.MockWebServer; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If you do this... | |
list.addHeaderView(headerView); | |
// And then call this inside of onItemClick, the position value will not be what you expect (header is now index 0) | |
Fruit fruit = adapter.getItem(position); | |
// This is what you really want to call inside of onItemClick | |
Fruit fruit = (Fruit) parent.getItemAtPosition(position); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo "Crashlytics username (e-mail):" | |
read email | |
echo "Crashlytics password:" | |
read -s password | |
data="{\"email\":\"${email}\",\"password\":\"${password}\"}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DevicePhoneNumber { | |
public final String phoneNumber; | |
public DevicePhoneNumber(String phoneNumber) { | |
this.phoneNumber = phoneNumber; | |
} | |
@Override | |
public String toString() { | |
return "DevicePhoneNumber{" + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyActivity extends Activity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_my); | |
// Old school | |
Button button = (Button) findViewById(R.id.button); | |
button.setOnClickListener(new OnClickListener() { | |
@Override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.os.Parcel; | |
import android.os.Parcelable; | |
public class ParcelableHelper { | |
/** | |
* There is not always a guarantee that Parcelable values will be immediately written out and | |
* read back in. For data data that mutable (its own issue), this can be a problem. This is | |
* for the times when it would be great to have confidence that you will be working with a copy | |
* of that data. | |
*/ |