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 static void makeEllipseEnd(TextView textView, String str, int maxLine) { | |
textView.setText(str); | |
textView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { | |
@Override | |
public boolean onPreDraw() { | |
textView.getViewTreeObserver().removeOnPreDrawListener(this); | |
if (textView.getLineCount() > maxLine) { | |
int offset = textView.getLayout().getLineEnd(maxLine - 1); | |
String text = textView.getText().subSequence(0, offset).toString(); | |
if (text.endsWith("\n")) { |
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
# AS中注释掉内容 | |
*.gradle | |
gradle* | |
build | |
.idea | |
*.iml | |
local.properties |
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
1.debug false | |
2.sign true | |
3.test proguard | |
4.change version code | |
5.upload new apk to umeng and test update works | |
6.merge master to release branch | |
7.upload new apk to appstores |
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
#!/bin/bash | |
# Script adb+ | |
# Run any command adb provides on all your currently connected devices, | |
# Or prompt to select one device | |
showHelp() { | |
echo "Usage: adb+ [-a] <command>" | |
echo " -h: show help" | |
echo " -a: run command on all device" | |
echo " command: normal adb commands" |
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
#!/bin/bash | |
function zip_align() | |
{ | |
TEMP="${1}" | |
DEST="${2}" | |
if [ ! -f "${TEMP}" ]; then | |
echo "${TEMP} is NOT a file" | |
return |
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
我试着使用Java生成一个随机整数,但是随机被指定在一个范围里。例如,整数范围是5~10,就是说5是最小的随机值,10是最大的。5到10之间的书也可以是生成的随机数。 | |
解决方案 | |
标准的解决方式(Java1.7 之前)如下: | |
import java.util.Random; | |
public static int randInt(int min, int max) { | |
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
遍历HashMap中元素的最佳方法是什么? | |
解决方案 | |
这样遍历entrySet: | |
public static void printMap(Map mp) { | |
Iterator it = mp.entrySet().iterator(); | |
while (it.hasNext()) { | |
Map.Entry pair = (Map.Entry)it.next(); |
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
private WeakReference<ClassName> mActivityWeakReference = new WeakReference<ClassName>(this); | |
private final Handler mHandler = new InnerHandler(mActivityWeakReference); | |
private static class InnerHandler extends Handler { | |
WeakReference<ClassName> activityWeakReference; | |
InnerHandler(WeakReference<ClassName> activityWeakReference) { | |
this.activityWeakReference = activityWeakReference; | |
} | |
public void handleMessage(android.os.Message msg) { |
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 void doubleClickDetect(View view){ | |
Observable<Void> observable = RxView.clicks(view).share(); | |
observable.buffer(observable.debounce(200, TimeUnit.MILLISECONDS)) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribe(new Action1<List<Void>>() { | |
@Override | |
public void call(List<Void> voids) { | |
if(voids.size() >= 2){ | |
//double click detected | |
} |
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
内部类不能被混淆,否则h5页面内找不到android中类 | |
-keep class com.sohu.tv.activity.IndividualH5Activity$*{*;} | |
webView.addJavascriptInterface(new HTMLHandler(), "handler"); | |
webView.loadUrl(getJsOfFetchMeta()); | |
class HTMLHandler { |
OlderNewer