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.graphics.Color; | |
public final class PaintUtils { | |
private PaintUtils() { throw new AssertionError(); } | |
public static int createInterimColor(int colorFrom, int colorTo, float percentage) { | |
int[] colorFromArray, colorToArray; | |
colorFromArray = new int[] { |
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 static boolean isTriangularNumber(int number) { | |
return (((Math.sqrt((8*number)+1)) % 1) == 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
/** | |
* SparseBooleanArray that is also Parcelable. Had to put this together so I could pass this to a | |
* {@code Fragment} bundle. | |
*/ | |
public class ParcelableSparseBooleanArray extends SparseBooleanArray implements Parcelable { | |
public ParcelableSparseBooleanArray(){ | |
super(); | |
} |
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 MainActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager); | |
MyViewPagerAdapter adapter = new MyViewPagerAdapter(getSupportFragmentManager()); | |
viewPager.setAdapter(adapter); |
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 TouchDelegatingRecyclerView extends RecyclerView { | |
private static final String TAG = TouchDelegatingRecyclerView.class.getSimpleName(); | |
private static final int UP_SWIPE = 803; | |
private static final int DOWN_SWIPE = UP_SWIPE + 1; | |
private float originalY = 0; | |
private int swipeDirection = 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 SlowAutoSwipeViewPager extends ViewPager { | |
public SlowAutoSwipeViewPager(Context context) { | |
super(context); | |
} | |
public SlowAutoSwipeViewPager(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
} | |
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 java.util.*; | |
import java.lang.*; | |
import java.io.*; | |
class WhatsAbubbleSort { | |
public static void main (String[] args) throws java.lang.Exception { | |
final int[] unsorted = new int[] { 23, 25, 7, 13, 94, 11 }; |
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 static char[] reverseCharArray(char[] input){ | |
char[] output = new char[input.length]; | |
char temp; | |
int index = 0; | |
for (int i = (output.length - 1); i >= (output.length/2); i--) { | |
temp = input[i]; | |
output[i] = input[index]; | |
output[index] = temp; |
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
private static SpannableString getSpannedString(String text, char... triggers) { | |
SpannableString spanString = new SpannableString(text); | |
for (int i = 0; i < spanString.length(); i++) { | |
for (char trigger : triggers) { | |
if (spanString.charAt(i) == trigger) { | |
spanString.setSpan(new ForegroundColorSpan(Color.CYAN), i, i+1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); | |
} | |
} |
OlderNewer