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 static void passwordVisibleToggle(EditText editText) { | |
Log.d("input", "passwordVisibleToggle " + editText.getInputType()); | |
if (editText.getInputType() == InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD) { | |
editText.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD | InputType.TYPE_CLASS_TEXT); | |
} else { | |
editText.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); |
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"?> | |
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | |
<item | |
android:left="-6dp" | |
android:right="-6dp" | |
android:top="-6dp"> | |
<shape> | |
<solid android:color="@color/main_white_color" /> | |
<stroke | |
android:width="1px" |
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 <T extends View> T $(int id) { | |
return (T) super.findViewById(id); | |
} | |
public <T extends View> T $(View view, int id) { | |
return (T) view.findViewById(id); | |
} |
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
long[] mClicks = new long[n]; | |
view.setOnClickListener(new OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
System.arraycopy(mClicks, 1, mClicks, 0, mClicks.length - 1); | |
mClicks[mClicks.length - 1] = SystemClock.uptimeMillis(); | |
if(mClicks[0] >= (SystemClock.uptimeMillis() - 500)){ | |
doSomething(); |
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
/** | |
* This demonstrates how to test AsyncTasks in android JUnit. Below I used | |
* an in line implementation of a asyncTask, but in real life you would want | |
* to replace that with some task in your application. | |
* @throws Throwable | |
*/ | |
public void testSomeAsynTask () throws Throwable { | |
// create a signal to let us know when our task is done. | |
final CountDownLatch signal = new CountDownLatch(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.app.Application; | |
import android.os.Handler; | |
import android.os.Looper; | |
import java.lang.ref.WeakReference; | |
import java.lang.reflect.Field; | |
import java.lang.reflect.InvocationTargetException; | |
import java.lang.reflect.Method; | |
import java.util.concurrent.Semaphore; | |
/** |
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 Test { | |
public static final Map<String,String> sData = new TreeMap<>(); | |
static { | |
sData.put("a","A"); | |
} | |
public static final Map<String,String> sData2 = new TreeMap<String,String>(){ | |
{ | |
this.put("a","A"); |
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.text.TextWatcher; | |
/** | |
* This is a wrapper around {@link TextWatcher} that overrides | |
* {@link TextWatcher#beforeTextChanged(CharSequence, int, int, int)} and | |
* {@link TextWatcher#onTextChanged(CharSequence, int, int, int)} with empty bodies. | |
*/ | |
public abstract class EasyTextWatcher implements TextWatcher { | |
@Override |
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
ArrayList<Entity> list = new ArrayList<Entity>(); | |
someObject.someMethod(p1, p2, new InnerInterface<Entity>() { | |
@Override | |
public boolean onEntry(Entity entity) | |
{ | |
//some logic | |
legs.add(entry); | |
return true; | |
} | |
}); |
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
/** | |
* Copyright 2016 Harish Sridharan | |
* <p/> | |
* 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 | |
* <p/> | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* <p/> | |
* Unless required by applicable law or agreed to in writing, software |