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.content.Context; | |
import android.graphics.Canvas; | |
import android.graphics.Color; | |
import android.graphics.Paint; | |
import android.support.annotation.Nullable; | |
import android.util.AttributeSet; | |
import android.util.Log; | |
import android.view.View; |
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 java.io.IOException; | |
import java.io.Reader; | |
import java.io.StringReader; | |
import java.io.Writer; | |
/** | |
* 转换utf-8 3个字节无法表示的字符 | |
* | |
* @author CJL | |
* @since 2018-02-26 |
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.Activity; | |
import android.content.Context; | |
import android.content.res.Resources; | |
import android.graphics.PixelFormat; | |
import android.support.annotation.StringRes; | |
import android.support.v4.app.NotificationManagerCompat; | |
import android.util.Log; | |
import android.view.Gravity; |
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
UserCharge imoney为double类型: | |
cursor.getText() 和 cursor.getDouble()效果不能保证为一致! | |
getText()方法可能丢失精度,getDouble()方法结果正确 | |
UserCharge imoney 为 text类型: | |
查询cursor.getText() 和 cursor.getDouble()效果一致!而且text类型并不影响sql对字段查询统计求和等操作 | |
而且由于cursor代码是系统代码无法修改,ORM 将UserCharge的imoney字段改为String 或者 BigDecimal都只是按text读取,反而用double能保证读取结果正确 |
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 boolean isDark(Bitmap bitmap) { | |
final float darkThreshold = bitmap.getWidth() * bitmap.getHeight() * 0.45f; | |
final int w = bitmap.getWidth(); | |
final int h = bitmap.getHeight(); | |
int darkPixels = 0; | |
int[] lineColor = new int[w]; | |
for (int i = 0; i < h - 1; i++) { | |
bitmap.getPixels(lineColor, 0, w, 0, i, w, 1); | |
for (int color : lineColor) { |
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 LogUtil { | |
private boolean debug; | |
private String tag; | |
private static final String LOG_FILE_NAME = "jz.log"; | |
public LogUtil() { | |
this(null); | |
} |
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
client.interceptors().add(new Interceptor() { | |
@Override | |
public Response intercept(Chain chain) throws IOException { | |
final Request request = chain.request(); | |
if (!HttpMethod.requiresRequestBody(request.method())) { | |
return chain.proceed(request); | |
} | |
final RequestBody newRb = new FormEncodingBuilder() |
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
写ripple drawable时候,如果默认背景带透明度,则item加一个id="@android:id/mask",以保证边界: | |
<ripple xmlns:android="http://schemas.android.com/apk/res/android" | |
android:color="?android:colorControlHighlight"> | |
<item android:id="@android:id/mask"> | |
<shape> | |
<corners android:radius="4dp" /> | |
<solid android:color="@color/white" /> | |
</shape> | |
</item> |
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
int currentVersion = android.os.Build.VERSION.SDK_INT; | |
if (currentVersion > android.os.Build.VERSION_CODES.ECLAIR_MR1) { | |
Intent startMain = new Intent(Intent.ACTION_MAIN); | |
startMain.addCategory(Intent.CATEGORY_HOME); | |
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |
startActivity(startMain); | |
System.exit(0); | |
} else {// android2.1 | |
ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE); | |
am.restartPackage(getPackageName()); |
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
/** | |
* 根据经纬度计算日出日落时间 | |
* @param lat 纬度 | |
* @param lng 经度 | |
* @param isSunRise true计算日出,false计算日落 | |
* @return int[] 0位置为小时,1位置为分钟 | |
*/ | |
public static int[] getDayTime(double lat, double lng, boolean isSunRise){ | |
lat = Math.toRadians(lat); |