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.widget.AbsListView; | |
import android.widget.ListView; | |
/** | |
* Makes a listview to have a pull down, this is a wrapper. | |
* Is not a good idea to override a ListView because there | |
* are a lot of libraries and we dont know when we need one. | |
*/ | |
public class PulldownListViewHelper { |
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. | |
} |
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) { |
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); | |
} | |
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) { |
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); | |
} | |
}); |
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 abstract class BaseActivity extends AppCompatActivity { | |
private Toolbar toolbar; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(getLayoutResource()); | |
toolbar = (Toolbar) findViewById(R.id.toolbar); | |
if (toolbar != null) { |
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 RightAlignedHorizontalScrollView extends HorizontalScrollView { | |
private static final boolean DEFAULT_GRAVITY_RIGHT = true; | |
private static final boolean DEFAULT_AUTOSCROLL = true; | |
private boolean autoScroll; | |
private boolean gravityRight; | |
public RightAlignedHorizontalScrollView(Context context) { | |
this(context, null); | |
} |
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 PreferencesObjectHelper<T> { | |
private static final String TAG = "PreferencesObjectHelper"; | |
private final SharedPreferences preferences; | |
private final SharedPreferences.Editor editor; | |
@SuppressLint("CommitPrefEdits") | |
public PreferencesObjectHelper(Context context, String fileName) { | |
preferences = context.getSharedPreferences(fileName, Context.MODE_PRIVATE); | |
editor = preferences.edit(); |
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
@IntDef({ | |
FIND_STREAK_LESS_THAN_ZERO, FIND_STREAK_LESS_EQUAL_TO_ZERO, FIND_STREAK_LESS_GREATER_ZERO | |
}) @Retention(RetentionPolicy.SOURCE) public @interface FIND_STREAK_OPERATOR { | |
} | |
public static final int FIND_STREAK_LESS_THAN_ZERO = 0; | |
public static final int FIND_STREAK_LESS_EQUAL_TO_ZERO = 1; | |
public static final int FIND_STREAK_LESS_GREATER_ZERO = 2; | |
public int findLongestStreak(float[] values, @FIND_STREAK_OPERATOR int operator) { |
OlderNewer