For example, you want to set 40% alpha transparence to #000000
(black color), you need to add 66
like this #66000000
.
This file contains hidden or 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
/** | |
* Find the greatest number in an array with a multi-threaded fork/join approach. | |
* | |
* This is a simple recursive divide&conquer approach to search through a list | |
* and return the max-element. It is using a subclass of java.util.concurrent.ForkJoinTask | |
* (namely RecursiveTask<V>). | |
* | |
* Theoretical aspect: Amdahl's Law. | |
* Possible speedup with n processors: S(n) = 1 / (B + 1-B*(1/n)) | |
* where B is the fractal of the programm which can only be |
This file contains hidden or 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
// status bar height | |
int statusBarHeight = 0; | |
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); | |
if (resourceId > 0) { | |
statusBarHeight = getResources().getDimensionPixelSize(resourceId); | |
} | |
// action bar height | |
int actionBarHeight = 0; | |
final TypedArray styledAttributes = getActivity().getTheme().obtainStyledAttributes( |
This file contains hidden or 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 RomanConversion { | |
public static void main(String[] args){ | |
System.out.println(toRoman(1904)); | |
} | |
public static String toRoman(int x){ | |
StringBuilder sb = new StringBuilder(); | |
String number = x + ""; |
This file contains hidden or 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.content.Context; | |
import android.content.res.TypedArray; | |
import android.text.TextUtils; | |
import android.util.AttributeSet; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.view.ViewTreeObserver; | |
import android.view.ViewTreeObserver.OnGlobalLayoutListener; | |
import android.widget.FrameLayout; | |
import android.widget.TextView; |
This file contains hidden or 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
//We can do this with only one loop | |
//thanks to the fact that we are looking for | |
//EXACTLY 2 movies which match the length. | |
//Duplicates are not being counted | |
//as we check for a hit FIRST and then put the | |
//value of the first movie into the map. | |
public static boolean isTwoMovies(int fl, int[] ml){ | |
HashMap<Integer, Boolean> hm = new HashMap<Integer, Boolean >(); |
This file contains hidden or 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.animation.ArgbEvaluator; | |
import android.os.Handler; | |
import android.support.v4.view.ViewPager; | |
import static android.support.v4.view.ViewPager.SCROLL_STATE_IDLE; | |
import static com.corewillsoft.loansdeposits.ui.utils.SwipeDirectionDetector.Direction.LEFT; | |
import static com.corewillsoft.loansdeposits.ui.utils.SwipeDirectionDetector.Direction.RIGHT; | |
public abstract class ColorChangeEvaluatorListener implements ViewPager.OnPageChangeListener { |
This file contains hidden or 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
/* | |
Given an integer n and two indexes i, j s.t. i >= j. | |
return a integer where all the bits between positions i and j (both inclusive) | |
are set to 1. The bits outside of this range shall not be modified. | |
*/ | |
//Comments assuming 8 bit numbers | |
//Goal is to make a mask with 1's at positions j through i | |
public static int setBetween(int n, int i, int j){ //n = 00010000, i = 3, j = 1 |
This file contains hidden or 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.Rect; | |
import android.support.v7.widget.RecyclerView; | |
import android.view.View; | |
public class ItemDecoration extends RecyclerView.ItemDecoration { | |
/** | |
* | |
* {@link #startPadding} and {@link #endPadding} are final and required on initialization | |
* because {@link android.support.v7.widget.RecyclerView.ItemDecoration} are drawn |
This file contains hidden or 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
package com.foo.ui.view; | |
import android.content.Context; | |
import android.support.v4.view.ViewPager; | |
import android.util.AttributeSet; | |
import android.view.View; | |
/** | |
* Created by fdoyle on 11/2/15. | |
*/ |