Skip to content

Instantly share code, notes, and snippets.

Avatar

Muyangmin Muyangmin

View GitHub Profile
@Muyangmin
Muyangmin / AndroidManifest.xml
Created Mar 14, 2017 — forked from romannurik/AndroidManifest.xml
Android example of how to programmatically instantiate a View with a custom style.
View AndroidManifest.xml
<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 / LogWrapper.java
Created Sep 7, 2016
A sample wrapper class for usage of log libray.
View LogWrapper.java
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 / DeviceDetectUtil.java
Created Jul 6, 2016
detect android device info, MIUI version, etc.
View DeviceDetectUtil.java
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);
@Muyangmin
Muyangmin / GitAlias.md
Last active May 27, 2016
Git log alias
View GitAlias.md
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 / NetworkSpeedDetection.java
Created May 25, 2016
Android Network Speed Detection
View NetworkSpeedDetection.java
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:
You can’t perform that action at this time.