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
// http://stackoverflow.com/questions/29797134/how-to-use-and-style-the-new-alertdialog-from-appcompat-22-1-and-above | |
private void showViewTimeSettingDialog() { | |
// not work | |
//ContextThemeWrapper themedContext = new ContextThemeWrapper(getActivity(), R.style.CustomAlertDialogStyle); | |
//AlertDialog.Builder builder = new AlertDialog.Builder(themedContext); | |
// 向 AppTheme 中加入自定义的 AlertDialog theme 无效,必须在 Builder() 中指定 style. not work | |
/* | |
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> |
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.os.SystemClock; | |
import android.view.View; | |
import java.util.Map; | |
import java.util.WeakHashMap; | |
/** | |
* A Debounced OnClickListener | |
* Rejects clicks that are too close together in time. | |
* This class is safe to use as an OnClickListener for multiple views, and will debounce each one separately. |
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
// From http://stackoverflow.com/questions/25628258/align-text-around-imagespan-center-vertical | |
public class CenteredImageSpan extends ImageSpan { | |
// Extra variables used to redefine the Font Metrics when an ImageSpan is added | |
private int initialDescent = 0; | |
private int extraSpace = 0; | |
public CenteredImageSpan(final Drawable drawable) { | |
this(drawable, entry, DynamicDrawableSpan.ALIGN_BOTTOM); |
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
/* __ | |
Like this (|__| represents an image): | |
__ __ | |
|__| Settings - |__| Safety. | |
Get TextView height by OnGlobalLayoutListener dynamically, and then | |
set drawable size by calling drawable.set(left, top, right, bottom), | |
in order to make sure the height of drawable is same as the string. | |
http://stackoverflow.com/questions/3591784/getwidth-and-getheight-of-view-returns-0 |
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
/** | |
* Created by weiyi on 3/28/16. | |
* http://li2.me/2016/03/android-spannablestring-example.html | |
* https://github.com/li2/Learning_Android_Open_Source/tree/master/AndroidTextSample | |
*/ | |
public class SpannableStringApiActivity extends AppCompatActivity { | |
@Bind(R.id.textView) TextView mTextView; | |
@Bind(R.id.spannableForegroundColor) TextView mForegroundColorTextView; | |
@Bind(R.id.spannableBackgroundColor) TextView mBackgroundColorTextView; |
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.os.SystemClock; | |
import android.view.View; | |
import java.util.Map; | |
import java.util.WeakHashMap; | |
// 源码基于 http://stackoverflow.com/questions/16534369/avoid-button-multiple-rapid-clicks | |
public abstract class OnMultipleClickListener implements View.OnClickListener { | |
private static final int DEFAULT_MAX_INTERVAL = 1000; // ms | |
private int mClickIndex; |
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
<?xml version="1.0" encoding="utf-8"?> | |
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | |
<solid android:color="@color/white"/> | |
<padding | |
android:left="16dp" | |
android:top="4dp" | |
android:right="16dp" | |
android:bottom="4dp"/> | |
<corners | |
android:radius="2dp"/> |
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
/** | |
* Created by weiyi on 4/18/16. | |
*/ | |
public class MonitorService extends IntentService { | |
private static final String TAG = makeLogTag(MonitorService.class); | |
private static final int MONITOR_INTERVAL = 5 * 1000; | |
private Context mAppContext; | |
private Handler mHandler; |
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
private void addPageTurnButton() { | |
View view = getLayoutInflater().inflate(R.layout.widget_page_turn, null); | |
/* | |
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( | |
RelativeLayout.LayoutParams.WRAP_CONTENT, | |
RelativeLayout.LayoutParams.WRAP_CONTENT); | |
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); | |
view.setLayoutParams(params); |