This file contains 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
/** | |
* Execute an {@link AsyncTask} on a thread pool. | |
* | |
* @param task Task to execute. | |
* @param args Optional arguments to pass to {@link AsyncTask#execute(Object[])}. | |
* @param <T> Task argument type. | |
*/ | |
public static <T> void execute(AsyncTask<T, ?, ?> task, T... args) { | |
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.DONUT) { | |
throw new UnsupportedOperationException("This class can only be used on API 4 and newer."); |
This file contains 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.squareup.example; | |
public abstract BaseActivity extends SherlockActivity { | |
private final ScopedBus scopedBus = new ScopedBus(); | |
protected ScopedBus getBus() { | |
return scopedBus; | |
} | |
@Override public void onPause() { |
This file contains 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
upstream thumborbe { | |
server thumbor.myhost.com:8090 ; | |
server thumbor.myhost.com:8091 ; | |
server thumbor.myhost.com:8092 ; | |
server thumbor.myhost.com:8093 ; | |
server thumbor.myhost.com:8094 ; | |
server thumbor.myhost.com:8095 ; | |
} | |
location ~* "^/.{28}/.*(jpg|jpeg|gif|png)(#.*)?$" { |
This file contains 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 Consumer { | |
@Inject ExampleClass.Factory exampleClassFactory; | |
public void fireZeMissles() { | |
ExampleClass ex = exampleClassFactory.createForUser(42); | |
ex.doThings(); | |
} | |
} |
This file contains 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
// Custom interface that enables communication between Fragment and its Activity | |
public interface OnItemSelectedListener | |
{ | |
public void onItemSelected(String item); | |
} |
This file contains 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
// This causes some IPC to the WindowManager, so use with caution as its slow | |
Rect displayArea = new Rect(); | |
Window window = activity.getWindow(); | |
window.getDecorView().getWindowVisibleDisplayFrame(displayArea); | |
Log.d(TAG, "Visible Display Frame Method: " + displayArea.width() + "x" + displayArea.height()); | |
// This is not immediately available as the full view layout needs to happen | |
View root = window.getDecorView().findViewById(android.R.id.content); | |
Log.d(TAG, "Root Content View Method: " + root.getMeasuredWidth() + "x" + root.getMeasuredHeight()); |
This file contains 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.cyrilmottier.android.resourcesadditions; | |
import android.content.res.Resources; | |
import android.content.res.XmlResourceParser; | |
import android.os.Bundle; | |
import org.xmlpull.v1.XmlPullParser; | |
import org.xmlpull.v1.XmlPullParserException; | |
/** | |
* @author Cyril Mottier |
This file contains 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.text.SpannableStringBuilder; | |
import java.util.ArrayDeque; | |
import java.util.Deque; | |
import static android.text.Spanned.SPAN_INCLUSIVE_EXCLUSIVE; | |
/** A {@link SpannableStringBuilder} wrapper whose API doesn't make me want to stab my eyes out. */ | |
public class Truss { | |
private final SpannableStringBuilder builder; | |
private final Deque<Span> stack; |
This file contains 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 AccountAuthenticator extends AbstractAccountAuthenticator { | |
private final Context context; | |
@Inject @ClientId String clientId; | |
@Inject @ClientSecret String clientSecret; | |
@Inject ApiService apiService; | |
public AccountAuthenticator(Context context) { | |
super(context); |
This file contains 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 com.google.auto.value.AutoValue; | |
import java.lang.annotation.Retention; | |
import java.lang.annotation.Target; | |
import static java.lang.annotation.ElementType.TYPE; | |
import static java.lang.annotation.RetentionPolicy.RUNTIME; | |
/** | |
* Marks an {@link AutoValue @AutoValue}-annotated type for proper Gson serialization. | |
* <p> |
OlderNewer