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.content.Context; | |
import android.content.res.TypedArray; | |
import android.util.AttributeSet; | |
import android.widget.ImageView; | |
public class AspectImageView extends ImageView { | |
private static final int DEFAULT_XRATIO = 1; | |
private static final int DEFAULT_YRATIO = 1; |
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.content.Context; | |
import android.content.res.TypedArray; | |
import android.util.AttributeSet; | |
import android.widget.FrameLayout; | |
public class AspectFrameLayout extends FrameLayout { | |
private static final int DEFAULT_XRATIO = 1; | |
private static final int DEFAULT_YRATIO = 1; |
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.content.Context; | |
import android.graphics.Matrix; | |
import android.util.AttributeSet; | |
import android.widget.ImageView; | |
/** | |
* ImageView that scales like centerCrop, but instead of showing the centre of the image, it shows the top. | |
*/ | |
public class TopCropImageView extends ImageView { | |
public TopCropImageView(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
@Override | |
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { | |
int widthMode = MeasureSpec.getMode(widthMeasureSpec); | |
int heightMode = MeasureSpec.getMode(heightMeasureSpec); | |
int widthSize = MeasureSpec.getSize(widthMeasureSpec); | |
int heightSize = MeasureSpec.getSize(heightMeasureSpec); | |
int width, height; |
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.content.Context; | |
import android.util.AttributeSet; | |
import android.widget.ImageView; | |
public class SquareImageView extends ImageView { | |
// Inherited constructors | |
public SquareImageView(Context context) { | |
super(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
import android.content.res.AssetManager; | |
import android.graphics.Typeface; | |
import java.util.HashMap; | |
import java.util.Map; | |
public class CustomFontManager { | |
private static Map<String, Typeface> typefaces = new HashMap<String, Typeface>(); |
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
// Example usage: | |
// | |
// int[] numbers = {1, 2, 3, 4, 5, 6, 7}; | |
// int[][] chunks = chunkArray(numbers, 3); | |
// | |
// chunks now contains [ | |
// [1, 2, 3], | |
// [4, 5, 6], | |
// [7] | |
// ] |
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
// ONE implementation for everything | |
public static T[][] chunkArray<T>(T[] array, int chunkSize) { | |
int numOfChunks = (int)Math.Ceiling((double)array.Length / chunkSize); | |
T[][] output = new T[numOfChunks][]; | |
for(int i = 0; i < numOfChunks; ++i) { | |
int start = i * chunkSize; | |
int length = Math.Min(array.Length - start, chunkSize); | |
T[] temp = new T[length]; |
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
// APK signing | |
def signingPropFile = new File(project.rootDir, "signing.properties") | |
if(signingPropFile.exists()) { | |
Properties props = new Properties() | |
props.load(new FileInputStream(signingPropFile)) | |
android { | |
signingConfigs { | |
release { | |
storeFile file(props['signing.keystore']) |
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.content.Context; | |
import android.content.res.TypedArray; | |
import android.util.AttributeSet; | |
import android.widget.ImageView; | |
public class RatioImageView extends ImageView { | |
private static final float DEFAULT_WIDTH_RATIO = 1; | |
private static final float DEFAULT_HEIGHT_RATIO = 1; |
OlderNewer