Apply the main stream ratio 16:9, here are the screen sizes:
- mdpi: ~160dpi, 640 x 360 px
- hdpi: ~240dpi, 960 x 540 px
- xhdpi: ~320dpi, 1280 x 720 px
- xxhdpi: ~higher, 1920 x 1080 px
| import android.content.Context; | |
| import android.graphics.Canvas; | |
| import android.graphics.Color; | |
| import android.graphics.Matrix; | |
| import android.graphics.Paint; | |
| import android.graphics.Path; | |
| import android.graphics.RectF; | |
| import android.util.AttributeSet; | |
| import android.view.View; | |
| import android.view.animation.AccelerateDecelerateInterpolator; |
| /* | |
| * Copyright 2014 Google Inc. | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software |
| import android.view.View; | |
| import android.view.ViewGroup; | |
| /** | |
| * A {@link ViewGroup.OnHierarchyChangeListener hierarchy change listener} which recursively | |
| * monitors an entire tree of views. | |
| */ | |
| public final class HierarchyTreeChangeListener implements ViewGroup.OnHierarchyChangeListener { | |
| /** | |
| * Wrap a regular {@link ViewGroup.OnHierarchyChangeListener hierarchy change listener} with one |
| function dex-method-count() { | |
| cat $1 | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"' | |
| } | |
| function dex-method-count-by-package() { | |
| dir=$(mktemp -d -t dex) | |
| baksmali $1 -o $dir | |
| for pkg in `find $dir/* -type d`; do | |
| smali $pkg -o $pkg/classes.dex | |
| count=$(dex-method-count $pkg/classes.dex) | |
| name=$(echo ${pkg:(${#dir} + 1)} | tr '/' '.') |
| import android.view.animation.Interpolator; | |
| /** | |
| * Created with IntelliJ IDEA, best IDE in the world. User: castorflex Date: 06/06/13 Time: 22:18 | |
| */ | |
| public class CustomBounceInterpolator implements Interpolator { | |
| @Override | |
| public float getInterpolation(float t) { | |
| return -(float) Math.abs(Math.sin((float) Math.PI * (t + 1) * (t + 1)) * (1 - t)); |
| public class ResizeAnimation extends Animation { | |
| final int startWidth; | |
| final int targetWidth; | |
| View view; | |
| public ResizeAnimation(View view, int targetWidth) { | |
| this.view = view; | |
| this.targetWidth = targetWidth; | |
| startWidth = view.getWidth(); | |
| } |
| import threading | |
| # Based on tornado.ioloop.IOLoop.instance() approach. | |
| # See https://github.com/facebook/tornado | |
| class SingletonMixin(object): | |
| __singleton_lock = threading.Lock() | |
| __singleton_instance = None | |
| @classmethod |
| // Copyright 2012 Pierre-Yves Ricau | |
| // | |
| // Licensed under the Apache License, Version 2.0 (the "License"); you may not | |
| // use this file except in compliance with the License. You may obtain a copy of | |
| // the License at | |
| // | |
| // http://www.apache.org/licenses/LICENSE-2.0 | |
| // | |
| // Unless required by applicable law or agreed to in writing, software | |
| // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| package com.squareup.example; | |
| public abstract BaseActivity extends SherlockActivity { | |
| private final ScopedBus scopedBus = new ScopedBus(); | |
| protected ScopedBus getBus() { | |
| return scopedBus; | |
| } | |
| @Override public void onPause() { |