Skip to content

Instantly share code, notes, and snippets.

Orhan Obut orhanobut

Block or report user

Report or block orhanobut

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 LineBackgroundSpanSampleActivity.java
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,
View MyApplication.java
class MyApplication extends Application {
Override public void onCreate(){
super.onCreate();
Stetho.initializeWithDefaults(this);
}
}
View StethoUtils.java
public class StethoUtils {
private StethoUtils() {
// no instance
}
public static void init(Context context) {
// no-op
}
View MyApplication.java
public class MyApplication extends Application {
@Override public void onCreate(){
super.onCreate();
StethoUtils.init(this);
}
}
View StethoUtils.java
public class StethoUtils {
private StethoUtils() {
// no instance
}
public static void init(Context context) {
Stetho.initializeWithDefaults(context);
}
View Handler1.java
Thread thread = new Thread(new Runnable() {
@Override public void run() {
// your long task
textView.setText("Task 4 Result"); //update view
}
});
thread.start();
View GooglePlacesApiTest3.java
@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
View GooglePlacesApiTest2.java
@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)
View GooglePlacesApiTest.java
@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)
View Singleton4.java
class Account {
private void save(String value) {
DiskPersistent.getInstance().save(value);
}
}
You can’t perform that action at this time.