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
/** | |
* 解压一个压缩文档 到指定位置 | |
* | |
* @param zipFileString 压缩包的名字 | |
* @param outPathString 指定的路径 | |
* @throws Exception | |
*/ | |
public static void UnZipFolder(String zipFileString, String outPathString) throws Exception { | |
java.util.zip.ZipInputStream inZip = new java.util.zip.ZipInputStream(new java.io.FileInputStream(zipFileString)); | |
java.util.zip.ZipEntry zipEntry; |
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 String getNetworkTypeName(Context context) { | |
if (context != null) { | |
ConnectivityManager connectMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); | |
if (connectMgr != null) { | |
NetworkInfo info = connectMgr.getActiveNetworkInfo(); | |
if (info != null) { | |
switch (info.getType()) { | |
case ConnectivityManager.TYPE_WIFI: | |
return "WIFI"; | |
case ConnectivityManager.TYPE_MOBILE: |
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 void saveCurrentPosition() { | |
if (mListView != null) { | |
int position = mListView.getFirstVisiblePosition(); | |
View v = mListView.getChildAt(0); | |
int top = (v == null) ? 0 : v.getTop(); | |
//保存position和top | |
} | |
} | |
private void restorePosition() { |
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
import android.content.Context; | |
public class DensityUtil { | |
/** | |
* 根据手机的分辨率从 dp 的单位 转成为 px(像素) | |
*/ | |
public static int dip2px(Context context, float dpValue) { | |
final float scale = context.getResources().getDisplayMetrics().density; | |
return (int) (dpValue * scale + 0.5f); |
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 boolean isIntentAvailable(Context context, String action) { | |
final PackageManager packageManager = context.getPackageManager(); | |
final Intent intent = new Intent(action); | |
List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); | |
return list.size() > 0; | |
} |
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 boolean checkNickname(String sequence) { | |
final String format = "[^\\u4E00-\\u9FA5\\uF900-\\uFA2D\\w-_]"; | |
Pattern pattern = Pattern.compile(format); | |
Matcher matcher = pattern.matcher(sequence); | |
return !matcher.find(); | |
} |
NewerOlder