Skip to content

Instantly share code, notes, and snippets.

View Muyangmin's full-sized avatar

Muyangmin Muyangmin

  • Chengdu, Sichuan, China.
View GitHub Profile
@Muyangmin
Muyangmin / NetworkSpeedDetection.java
Created May 25, 2016 06:21
Android Network Speed Detection
private static boolean isFastMobileNetwork(Context context) {
TelephonyManager telephonyManager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
switch (telephonyManager.getNetworkType()) {
case TelephonyManager.NETWORK_TYPE_1xRTT:
return false; // ~ 50-100 kbps
case TelephonyManager.NETWORK_TYPE_CDMA:
return false; // ~ 14-64 kbps
case TelephonyManager.NETWORK_TYPE_EDGE:
return false; // ~ 50-100 kbps
case TelephonyManager.NETWORK_TYPE_EVDO_0:
@Muyangmin
Muyangmin / GitAlias.md
Last active May 27, 2016 01:36
Git log alias
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

Now just executegit lg, it looks like this :

Enjoy it!

@Muyangmin
Muyangmin / LogWrapper.java
Created September 7, 2016 02:33
A sample wrapper class for usage of log libray.
package org.mym.prettylog.wrapper;
import android.content.Context;
import org.mym.plog.PLog;
import org.mym.plog.config.EasyLogController;
import org.mym.plog.config.PLogConfig;
/**
* <p>
@Muyangmin
Muyangmin / AndroidManifest.xml
Created March 14, 2017 07:45 — forked from romannurik/AndroidManifest.xml
Android example of how to programmatically instantiate a View with a custom style.
<manifest ...>
...
<!-- Make sure your app (or individual activity) uses the
theme with the custom attribute defined. -->
<application android:theme="@style/AppTheme" ...>
...
</application>
</manifest>
@Muyangmin
Muyangmin / DeviceDetectUtil.java
Created July 6, 2016 09:09
detect android device info, MIUI version, etc.
public static boolean isMiUi() {
return !TextUtils.isEmpty(getSystemProperty("ro.miui.ui.version.name"));
}
public static String getSystemProperty(String propName) {
String line;
BufferedReader input = null;
try {
java.lang.Process p = Runtime.getRuntime().exec("getprop " + propName);
input = new BufferedReader(new InputStreamReader(p.getInputStream()), 1024);