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.content.Context; | |
import android.content.res.Resources; | |
import android.graphics.Bitmap; | |
import android.graphics.drawable.BitmapDrawable; | |
import android.graphics.drawable.Drawable; | |
import android.graphics.drawable.LayerDrawable; | |
import android.net.Uri; | |
import android.util.Log; | |
import com.squareup.picasso.Picasso; |
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
@TargetApi(VERSION_CODES.LOLLIPOP) | |
private Animator createCenteredReveal(View view) { | |
// Could optimize by reusing a temporary Rect instead of allocating a new one | |
Rect bounds = new Rect(); | |
view.getDrawingRect(bounds); | |
int centerX = bounds.centerX(); | |
int centerY = bounds.centerY(); | |
int finalRadius = Math.max(bounds.width(), bounds.height()); | |
return ViewAnimationUtils.createCircularReveal(view, centerX, centerY, 0f, finalRadius); | |
} |
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 is in the inistantiateItem() method of my PagerAdapter. | |
//View view is my inflated layout, and SharedPreferences prefs contains my backing data. | |
final SeekBar seekBar = (SeekBar) view.findViewById(R.id.transparency_seekbar); | |
seekBar.setMax(80); | |
seekBar.setProgress(prefs.getInt(seekBar.getContext().getString(R.string.pref_transparency), | |
0)); | |
seekBar.addOnAttachStateChangeListener(new OnAttachStateChangeListener() { | |
private IntentFilter mTransparencyFilter = new IntentFilter( |
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.content.Context; | |
import android.support.v4.content.AsyncTaskLoader; | |
public abstract class CachedLoader<D> extends AsyncTaskLoader<D> { | |
private D mResult; | |
public CachedLoader(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
<!-- Replace 111222 with your secret code --> | |
<receiver android:name=".receiver.DiagnoserReceiver"> | |
<intent-filter> | |
<action android:name="android.provider.Telephony.SECRET_CODE"/> | |
<data android:scheme="android_secret_code" android:host="111222"/> | |
</intent-filter> | |
</receiver> |
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 StylableString extends SpannableString { | |
public StylableString(CharSequence source) { | |
super(source); | |
} | |
public StylableString setForegroundColor(int color) { | |
ForegroundColorSpan colorSpan = new ForegroundColorSpan(color); | |
setSpan(colorSpan, 0, length(), 0); | |
return this; |
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 Util { | |
public static String buildConcatString(String delimeter, String... strings) { | |
StringBuilder builder = new StringBuilder(); | |
boolean isFirst = true; | |
for (String string : strings) { | |
if (TextUtils.isEmpty(string)) { | |
continue; | |
} | |
if (!isFirst) { |
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.support.annotation.WorkerThread; | |
import android.support.annotation.Nullable; | |
import android.database.Cursor; | |
public class CursorReaderExample { | |
// Example columns, would likely be in a different file (e.g. a contract class). | |
private static String COLUMN_FOO = "foo"; | |
private static String COLUMN_BAR = "bar"; |
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
/** | |
* What you'd think an abstract factory would look like. Unfortunately, this class won't compile. | |
*/ | |
public abstract class HeadlessFragmentFactory<F extends Fragment & ParentedFragment<F, ? extends P>, P> { | |
protected abstract F newInstance(); | |
/* There will be a compiler warning on P. When joining types, only the first type is allowed to | |
be a class. All others MUST be interfaces. In this situation, there is no way for the compiler | |
to know that P will be an interface. If P is removed, there is no longer a compile-time check |
OlderNewer