Skip to content

Instantly share code, notes, and snippets.

View beilly's full-sized avatar

benli.shi beilly

View GitHub Profile
@beilly
beilly / OkHttp3Stack.java
Last active February 13, 2017 08:47
Volley Stack with OkHttp3,and it will trusting all certificates. You can remove "allowAllSSLOkHttp(builder);" if you do't want to trusting all.
package com.benli.app.utils.net;
import com.android.volley.AuthFailureError;
import com.android.volley.Request;
import com.android.volley.toolbox.HttpStack;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.ProtocolVersion;
import org.apache.http.StatusLine;
@beilly
beilly / InputTools.java
Last active April 25, 2016 05:24
键盘管理器
package com.benli.app.utils;
import android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import java.util.Timer;
import java.util.TimerTask;
@beilly
beilly / ToastUtil.java
Last active April 25, 2016 05:24
Android Toast 工具类,可关闭支持线程中和延时效果。
package com.benli.app.utils;
import android.content.Context;
import android.os.Handler;
import android.view.View;
import android.widget.Toast;
/**
* @ClassName: ToastUtil
* @Description: TODO(...)
@beilly
beilly / DeviceUuidFactory.java
Last active February 19, 2019 08:57
实现在设备上更通用的获取设备唯一标识
package com.benli.app.utils;
import android.content.Context;
import android.content.SharedPreferences;
import android.provider.Settings.Secure;
import android.telephony.TelephonyManager;
import android.util.Log;
import java.io.UnsupportedEncodingException;
import java.util.UUID;
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN" "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
<!-- Generated by RHY @will_awoke -->
<module name="Checker">
<property name="charset" value="UTF-8"/>
<property name="severity" value="warning"/>
@beilly
beilly / LauncherActivity_OnCreate
Created August 26, 2016 07:05
解决4.4机器上面按home键返回桌面后恢复需要重新走launcher页面的bug
if (!isTaskRoot()) {
Intent intent = getIntent();
String action = intent.getAction();
if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && action != null && action.equals(Intent.ACTION_MAIN)) {
finish();
return;
}
}
@beilly
beilly / AndroidBug5497Workaround.java
Created August 31, 2016 07:18
WebView adjustResize windowSoftInputMode breaks when activity is fullscreen.Depent on https://github.com/madebycm/AndroidBug5497Workaround
package com.vcredit.utils;
import android.app.Activity;
import android.graphics.Rect;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
/**
* Created by shibenli on 2016/8/31.
@beilly
beilly / AdapterHolder.java
Created September 19, 2016 02:57
通用Adapter与ListView滚动时不加载图片的封装,摘自http://www.kymjs.com/code/2015/04/28/01/
/*
* Copyright (c) 2014, 张涛.
*
* 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
@beilly
beilly / AndroidComment.java
Created October 8, 2016 07:01
android跳转到应用市场评论
try {
Uri uri = Uri.parse("market://details?id="
+ BuildConfig.APPLICATION_ID);//需要评分的APP包名
Intent intent5 = new Intent(Intent.ACTION_VIEW, uri);
intent5.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent5);
} catch (Exception e) {
TooltipUtils.showToastL(this, getString(R.string.common_no_function));
}
@beilly
beilly / FakeX509TrustManager.java
Last active September 11, 2019 15:17
Volley Stack with default HttpsURLConnection, and it will trusting all certificates
package com.beilly.utils.net;
import android.content.Context;
import java.io.IOException;
import java.io.InputStream;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;