Skip to content

Instantly share code, notes, and snippets.

@rharter
rharter / colorcat.py
Created June 12, 2013 15:39
This is a simple modification fo Jeff Sharkey's colored logcat script that adds the ability to use standard logcat filtering. For instance, I use this script with `./colorcat.py -d Hashnote:* *:E`.
#!/usr/bin/python
'''
Copyright 2009, The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@rharter
rharter / AllStoriesFragment.java
Last active May 5, 2016 17:00
This contains many parts of the main fragment for an app I did that has an autoscrolling horizontal view pager on top of a list, very similar to Marvel. The reason I wanted to share this is because I think it is directly transferrable to solve some of the issues with the promo pager on the main screen. Notice the GestureDetector that is used. Th…
private static GestureDetector GESTURE_DETECTOR;
private static final long HEADLINE_SCROLL_DELAY = 5000;
private Timer mAutoScroller;
private ViewPager mHeadlinePager;
private HeadlineAdapter mHeadlineAdapter;
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
@rharter
rharter / View.java
Last active December 16, 2015 02:58
The issue here is that the View.setBackgroundDrawable method has been deprecated but the replacement method, View.setBackground, just delegates to the deprecated method. How can I handle this in a safe manner?
/**
* Unless I'm mistaken, this should never happen. If you deprecate a method
* to replace it with another, shouldn't the actual functionality be moved
* to the new method and the deprecated method be made to delegate to the
* replacement method?
*/
public void setBackground(Drawable background) {
//noinspection deprecation
setBackgroundDrawable(background);
}