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
| class Person { | |
| var name = "" | |
| var age = 0 | |
| init(name: String, age:Int) { | |
| self.name = name | |
| self.age = age | |
| } | |
| } |
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
| // sort int | |
| var ar = [3,2,5,6] | |
| sort(&ar, <) | |
| // or | |
| ar = ar.sorted(<) | |
| print(ar); |
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
| // on error the server sends JSON | |
| /* | |
| { "error": { "data": { "message":"A thing went wrong" } } } | |
| */ | |
| // create model classes.. | |
| public class ErrorResponse { | |
| Error error; | |
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 RRDrawable extends Drawable { | |
| private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); | |
| public RRDrawable(int color) { | |
| paint.setColor(color); | |
| paint.setStyle(Paint.Style.FILL); | |
| } | |
| @Override | |
| public void draw(Canvas canvas) { |
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.util.util; | |
| import android.text.Spannable; | |
| import android.text.TextPaint; | |
| import android.text.style.URLSpan; | |
| import android.widget.TextView; | |
| public class TextViewUtils { | |
| private static final String TAG = TextViewUtils.class.getSimpleName(); |
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
| ###################################################### | |
| # Proguard file to remove debug logs and NOT kill the application | |
| # | |
| # @benclayton github.com/benvium 15-12-2014 | |
| # | |
| # https://gist.github.com/benvium/8995326bc944f47f2c64 | |
| ###################################################### | |
| # To use this file, your project's build.gradle 'buildTypes' section should look like this: | |
| # |
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
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
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
| /** | |
| * Align image to bottom, fill width. and crop top if needed. | |
| * | |
| * http://stackoverflow.com/questions/6330084/imageview-scaling-top-crop | |
| * https://gist.github.com/arriolac/3843346 | |
| */ | |
| import android.content.Context; | |
| import android.graphics.Matrix; | |
| import android.util.AttributeSet; | |
| import android.widget.ImageView; |
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
| #!/bin/bash -e | |
| # Ensure we're running in location of script. | |
| cd "`dirname $0`" | |
| function fail { | |
| echo "FAILED with $1" | |
| exit 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.media.MediaPlayer; | |
| import android.media.MediaPlayer.OnCompletionListener; | |
| import android.media.MediaPlayer.OnErrorListener; | |
| import android.media.MediaPlayer.OnPreparedListener; | |
| import android.view.View; | |
| import android.view.ViewGroup; | |
| import android.view.ViewGroup.LayoutParams; | |
| import android.webkit.WebChromeClient; | |
| import android.widget.FrameLayout; | |
| import android.widget.VideoView; |