Skip to content

Instantly share code, notes, and snippets.

Miles Peele mformetal

Block or report user

Report or block mformetal

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
mformetal / build.gradle
Created Jun 7, 2016
Gradle command line builds
View build.gradle
task appStart(type: Exec, dependsOn: 'installDebug') {
def adb = "$System.env.ANDROID_HOME/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', ''
mformetal /
Created Apr 5, 2016
Base-Handling class for Fragments. Yes, I hate casting this much.
public abstract class BaseFragment extends Fragment {
public void onAttach(Context context) {
((MainApp) context.getApplicationContext()).getApplicationComponent().inject(this);
Map<Object, Class> map = getCastMap();
for (Object object: map.keySet()) {
Class clazz = map.get(object);
mformetal /
Created Mar 8, 2016
My solution to the Pinch-To-Zoom problem
// Defines the actions of the Zoomer class. Feel free to implement as you see fit
public interface MotionEventHandler {
// Defines which "Mode" the user is in. NONE means they have not taken any action, DRAG means tehy're dragging,
// ZOOM means they're zooming
enum Mode {
public class CancelEditTextListener {
private EditText widget;
private Drawable[] hideDrawables;
private Drawable canceler;
public CancelListener(EditText editText) {
widget = editText;
View.OnTouchListener touchListener = (v, event) -> {
mformetal /
Last active Apr 7, 2017
A simple way to add a predraw listener to a view
public abstract class PreDrawer<T extends View> {
// Private constructor prevent instantiation by the caller. Use addPredrawer() method instead.
private PreDrawer(final T view) {
// Adds the observer to the given view, then calls notifyPredraw() when clean up has been done ready
final ViewTreeObserver viewTreeObserver = view.getViewTreeObserver();
viewTreeObserver.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
public boolean onPreDraw() {
You can’t perform that action at this time.