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
@orhanobut
orhanobut / gist:8665372
Created Jan 28, 2014
Up down animation for dialog fragment
View gist:8665372
// Slide up animation
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromYDelta="100%"
android:interpolator="@android:anim/accelerate_interpolator"
android:toXDelta="0" />
@orhanobut
orhanobut / gist:9267654
Last active Jun 23, 2019
how to find square root of an integer with binary search
View gist:9267654
public static int sqr(int a){
if (a < 1) return 0;
int low = 1;
int h = a;
while (low < h){
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 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 Handler1.java
Thread thread = new Thread(new Runnable() {
@Override public void run() {
// your long task
textView.setText("Task 4 Result"); //update view
}
});
thread.start();
You can’t perform that action at this time.