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 Bitmap getCroppedBitmap(Bitmap bitmap) { | |
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888); | |
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); | |
Canvas canvas = new Canvas(output); | |
final Paint paint = new Paint(); | |
paint.setAntiAlias(true); |
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
package com.coolands.open; | |
import android.graphics.Path; | |
import android.graphics.PathMeasure; | |
import android.view.animation.Animation; | |
import android.view.animation.Transformation; | |
/** | |
* Animation along path | |
* by Ewan Chou (https://github.com/coocood) |
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 String md5(String s) { | |
try { | |
// Create MD5 Hash | |
MessageDigest digest = java.security.MessageDigest.getInstance("MD5"); | |
digest.update(s.getBytes()); | |
byte messageDigest[] = digest.digest(); | |
// Create Hex String | |
StringBuffer hexString = new StringBuffer(); | |
for (int i=0; i<messageDigest.length; i++) |
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
package com.fada21.android.orientation; | |
import java.util.concurrent.locks.ReentrantLock; | |
import android.content.Context; | |
import android.content.res.Configuration; | |
import android.view.OrientationEventListener; | |
import android.view.Surface; | |
import android.view.WindowManager; |
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
Android, żeby obsłużyć wiele ekranów ma swoją specyfikę. | |
W najprostszej formie tła próbujemy sobie rozciągnąć lub skropować. | |
Ikon potrzebujemy w rozmiarze ok 72x72px (telefony) lub 96x96px (tablety), | |
które się obpowiednio skalują na różnych rozdzielczościach (przeważnie wyglądają marnie na rozdzielczościach innych od hdpi). | |
To przejdzie. Jednak aby było ładnie potrzebowalibyśmy assetów conajmniej w czterech rozdzielczościach wg proporcji 2:3:4:6. | |
Te najniższe dla ikon najczęściej przyjmuje się jako 48x48px. | |
http://stackoverflow.com/questions/11581649/about-android-image-size-and-assets-sizes |
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
// by Chris Banes (http://chris.banes.me/2014/03/27/measuring-text/) | |
int mTextWidth, mTextHeight; // Our calculated text bounds | |
Paint mTextPaint = new Paint(); | |
// Now lets calculate the size of the text | |
Rect textBounds = new Rect(); | |
mTextPaint.getTextBounds(mText, 0, mText.length(), textBounds); | |
mTextWidth = mTextPaint.measureText(mText); // Use measureText to calculate width | |
mTextHeight = textBounds.height(); // Use height from getTextBounds() |
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
package com.? | |
import java.io.File; | |
import android.annotation.SuppressLint; | |
import android.content.Context; | |
import android.os.Build; | |
import android.os.StatFs; | |
import com.squareup.picasso.Downloader; |
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
{ | |
final ViewTreeObserver viewTreeObserver = someView.getViewTreeObserver(); | |
viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { | |
@SuppressWarnings("deprecation") | |
@SuppressLint("NewApi") | |
public void onGlobalLayout() { | |
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { | |
viewTreeObserver.removeGlobalOnLayoutListener(this); | |
} else { |
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
val line2nums = io.StdIn.readLine.split(" ").map(_.toInt) | |
val lines2nums = io.Source.stdin.getLines().map(_.toInt) | |
val streamOfInts = Stream.continually(io.StdIn.readInt()) | |
val fib = { | |
def f(f0:Int, f1:Int): Stream[Int] = f0 #:: f(f1, f0 + f1) | |
f(0,1) | |
} | |
//fib(18) | |
//fib.take(19).toList |
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
# ubuntu/mint setup tips | |
# SETUP ============ | |
## ================= | |
# http://mintguide.org/tools/317-make-a-bootable-flash-drive-from-an-iso-image-on-linux-mint.html | |
# df # lists mounted devices | |
# sudo dd if=/home/USER/linuxmint.iso of=/dev/sdb | |
# watch -n5 'sudo kill -USR1 $(pgrep ^dd)' # monitoring dd progress | |
# git ppa | |
sudo add-apt-repository ppa:git-core/ppa |
OlderNewer