View ImageCenteredSpan.java
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
class ImageCenteredSpan extends ImageSpan { | |
public ImageCenteredSpan(Drawable d) { | |
super(d); | |
} | |
@Override | |
public void draw(Canvas canvas, CharSequence text, | |
int start, int end, float x, | |
int top, int y, int bottom, Paint paint) { | |
Drawable b = getDrawable(); |
View Log.java
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 Log { | |
static final boolean isLoggable = BuildConfig.DEBUG; | |
static final String TAG = BuildConfig.APPLICATION_ID; | |
public static void i(String tag, String string) { | |
if (isLoggable) android.util.Log.i(tag, string); | |
} | |
public static void i(String string) { | |
if (isLoggable) android.util.Log.i(TAG, string); |
View CustomGenerateViewId.java
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 CustomGenerateViewId { | |
private static final AtomicInteger nextGeneratedId = new AtomicInteger(1); | |
public static int customGenerateViewId() { | |
for (; ; ) { | |
final int result = nextGeneratedId.get(); | |
// aapt-generated IDs have the high byte nonzero; clamp to the range under that. | |
int newValue = result + 1; | |
if (newValue > 0x00FFFFFF) { | |
newValue = 1; // Roll over to 1, not 0. | |
} |
View OutlineTextView.java
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 OutlineTextView extends TextView { | |
private static final int DEFAULT_OUTLINE_COLOR = 0xFF000000; | |
private static final int DEFAULT_OUTLINE_SIZE = 7; | |
private static final boolean DEFAULT_OUTLINE_STATE = true; | |
private int outlineColor; | |
private int outlineSize; | |
private boolean outlineState; | |
public OutlineTextView(Context context) { |
View SpaceItemDecoration.java
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 SpaceItemDecoration extends RecyclerView.ItemDecoration { | |
private static final boolean DEFAULT_ADD_SPACE_ABOVE_FIRST_ITEM = false; | |
private static final boolean DEFAULT_ADD_SPACE_BELOW_LAST_ITEM = false; | |
private final int space; | |
private final boolean addSpaceAboveFirstItem; | |
private final boolean addSpaceBelowLastItem; | |
public SpaceItemDecoration(int space) { | |
this(space, DEFAULT_ADD_SPACE_ABOVE_FIRST_ITEM, DEFAULT_ADD_SPACE_BELOW_LAST_ITEM); |
View SquareRelativeLayout.java
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 SquareRelativeLayout extends RelativeLayout { | |
public SquareRelativeLayout(Context context) { | |
this(context, null); | |
} | |
public SquareRelativeLayout(Context context, AttributeSet attrs) { | |
this(context, attrs, 0); | |
} | |
View ObservableScrollView.java
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 ObservableScrollView extends ScrollView { | |
private static final int DEFAULT_THRESHOLD_DP = 4; | |
private ScrollDirectionListener scrollDirectionListener; | |
private int scrollThreshold; | |
public ObservableScrollView(Context context) { | |
this(context, null); | |
} | |
View SafeStringUtils.java
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 SafeStringUtils { | |
public static boolean safeEquals(Object o1, Object o2) { | |
return o1 != null && o1.equals(o2); | |
} | |
public static boolean safeEqualsIgnoreCase(String s1, String s2) { | |
return s1 != null && s1.equalsIgnoreCase(s2); | |
} | |
public static boolean safeIsEmpty(String s) { |
View ExampleActivity.java
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
int totalItems=10; | |
horizontalScrollView = (HorizontalScrollViewSelector) findViewById(R.id.horizontalScrollView); | |
horizontalScrollView.setListener(new HorizontalScrollViewSelector.OnScrollChangedListener() { | |
@Override | |
public void onScrollChanged(int totalX, int x) { | |
items = x * totalItems / maxX); | |
} | |
}); |
OlderNewer