package com.mego.weblink.utils;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.RectF;
import android.location.Location;
import android.media.ExifInterface;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.NetworkInfo.State;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.os.StatFs;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.text.InputFilter;
import android.text.Spanned;
import android.text.TextUtils;
import android.view.MotionEvent;
import android.widget.Toast;
import org.apache.commons.codec.binary.Base64;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import static java.lang.Math.PI;
// 通用的方法
@SuppressLint("FloatMath")
public class Utils {
public static int dip2px(Context context, float dpValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}
private static long lastClickTime;
// 防止快速点击按钮
public static boolean isFastDoubleClick() {
long time = System.currentTimeMillis();
long timeD = time - lastClickTime;
if (0 < timeD && timeD < 500) {
return true;
}
lastClickTime = time;
return false;
}
// 完整删除指定目录
public static void deletePath(String path) {
File file = new File(path);
if (!file.exists()) {
return;
}
if (!file.isDirectory()) {
file.delete();
return;
}
String[] nlist = file.list();
File temp = null;
for (int i = 0; i < nlist.length; ++i) {
if (path.endsWith(File.separator)) {
temp = new File(path + nlist[i]);
} else {
temp = new File(path + File.separator + nlist[i]);
}
if (temp.isFile()) {
temp.delete();
} else if (temp.isDirectory()) {
deletePath(temp.getAbsolutePath());
}
}
// delete folder
file.delete();
}
// 当前是否连同网络
public static boolean isNetConnected(Context context) {
try {
ConnectivityManager connectivity = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity != null) {
NetworkInfo info = connectivity.getActiveNetworkInfo();
if (info != null && info.isConnected()) {
if (info.getState() == State.CONNECTED) {
return true;
}
}
}
} catch (Exception e) {
return false;
}
return false;
}
// 判断网络是否已经真连接
public static boolean isNetConnected() {
String str = "http://www.baidu.com";
Process p;
try {
p = Runtime.getRuntime().exec("ping -c 1 -w 100 " + str);
int status = p.waitFor();
if (status == 0) {
return true;
}
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
return false;
}
// 当前是否是wifi
public static boolean isWifiConnected(Context context) {
return getNetworkState(context, ConnectivityManager.TYPE_WIFI) == State.CONNECTED;
}
// 返回当前的网络状态
private static State getNetworkState(Context context, int networkType) {
ConnectivityManager cm = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = cm.getNetworkInfo(networkType);
return info == null ? null : info.getState();
}
// 存储size表示
static public String toSDSpace(long bytes) {
if (bytes < 100) {
return Long.toString(bytes) + "b";
}
double space = bytes / 1024;
if (space < 100) {
int s = (int) space;
return Integer.toString(s) + "Kb";
}
space = space / 1024;
if (space < 100) {
int s = (int) space;
return Integer.toString(s) + "MB";
} else {
space = space / 1024;
DecimalFormat df = new DecimalFormat();
df.setMaximumFractionDigits(2);
df.setMinimumFractionDigits(2);
return df.format(space) + "GB";
}
}
// 指定目录的剩余空间
@SuppressWarnings("deprecation")
static public long getFreeSpace(String path) {
StatFs sf = new StatFs(path);
long blockSize = sf.getBlockSize();
long availCount = sf.getAvailableBlocks();
long freeSpace = availCount * blockSize;
return freeSpace;
}
// 指定目录的剩余空间-string信息
static public String getSDSpaceInfo(String path) {
String name = new File(path).getName();
if (name == null || name.length() == 0) {
return "";
}
long free = getFreeSpace(path);
long total = getTotalSpace(path);
String info = name + "\n可用空间" + toSDSpace(free) + "\n总容量:"
+ toSDSpace(total);
return info;
}
// sd卡的剩余空间
@SuppressWarnings("deprecation")
public static long getSDFreeSpace() {
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
File sdcardDir = Environment.getExternalStorageDirectory();
StatFs sf = new StatFs(sdcardDir.getPath());
long blockSize = sf.getBlockSize();
long availCount = sf.getAvailableBlocks();
long freeSpace = availCount * blockSize;
return freeSpace;
}
return 0;
}
// 指定目录的空间
@SuppressWarnings("deprecation")
static public long getTotalSpace(String path) {
StatFs sf = new StatFs(path);
long blockSize = sf.getBlockSize();
long blockCount = sf.getBlockCount();
// long availCount = sf.getAvailableBlocks();
long totalSpace = blockCount * blockSize;
return totalSpace;
}
// scan all sd that maybe sd card under /storage/ dir
// 找到所有的SDcard
static public ArrayList<String> scanAllMaybeSD(boolean isF
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本项目为红色高跟鞋主题的网页设计源码,采用Java为主要开发语言,并辅以C、C、HTML等语言。源码共计450个文件,其中包含214个Java源文件、176个XML配置文件、20个PNG图片文件、6个Gradle构建文件、6个SO库文件、4个C/C++源文件、4个属性文件、3个Git忽略文件以及2个Makefile文件。
资源推荐
资源详情
资源评论
收起资源包目录
基于Java语言的红色高跟鞋网页设计源码 (451个子文件)
daemon_api21.c 4KB
daemon_api20.c 4KB
daemon.c 3KB
common.c 3KB
daemon 13KB
daemon 9KB
daemon 9KB
.gitignore 1KB
.gitignore 7B
.gitignore 7B
build.gradle 3KB
build.gradle 2KB
build.gradle 1KB
build.gradle 632B
build.gradle 605B
settings.gradle 65B
com_marswin89_marsdaemon_nativ_NativeDaemonAPI21.h 681B
com_marswin89_marsdaemon_nativ_NativeDaemonAPI20.h 654B
log.h 493B
constant.h 324B
demo_unicode.html 32KB
zxing.jar 323KB
Utils.java 65KB
MainActivity.java 62KB
XfService.java 36KB
MyService.java 36KB
WheelTime.java 35KB
MainService.java 33KB
WheelView.java 30KB
TimePickerView.java 22KB
BaseActivity.java 21KB
SystemBarTintManager.java 20KB
OptionsPickerView.java 18KB
LunarCalendar.java 18KB
StringUtil.java 18KB
UpdateManager.java 17KB
LjActivity.java 16KB
BaseRecyclerFragment.java 16KB
TimeUtil.java 16KB
BaseTabActivity.java 15KB
CommonUtil.java 15KB
ChinaDate.java 15KB
BaseTabFragment.java 14KB
BaseListFragment.java 14KB
BaseRecyclerActivity.java 13KB
EditTextInfoActivity.java 13KB
CommandlogCenter.java 13KB
TimePickerWindow.java 13KB
TaizhuActivity.java 13KB
BaseListActivity.java 13KB
WheelOptions.java 13KB
WebActivity.java 13KB
HttpManager.java 13KB
DatePickerWindow.java 13KB
CameraManager.java 12KB
CacheManager.java 11KB
GPSProvider.java 11KB
GridPickerView.java 11KB
EditTextInfoWindow.java 11KB
BasePickerView.java 10KB
BaseFragment.java 10KB
ThmlogDao.java 10KB
ServerSettingActivity.java 10KB
CameraConfigurationManager.java 9KB
BaseView.java 9KB
NetworkUtils.java 9KB
WelcomeActivity.java 9KB
EditTextUtil.java 9KB
CutPictureActivity.java 9KB
PlacePickerWindow.java 9KB
BaseAdapter.java 8KB
DataKeeper.java 8KB
SelectPictureActivity.java 8KB
DaemonStrategy23.java 7KB
BottomMenuWindow.java 7KB
SettingUtil.java 7KB
BaseHttpRecyclerFragment.java 7KB
DaemonStrategyXiaomi.java 7KB
WebViewActivity.java 7KB
BaseHttpListFragment.java 7KB
BaseViewBottomWindow.java 7KB
DaemonStrategy22.java 7KB
WifiConnector.java 7KB
CrashHandler.java 7KB
BaseHttpRecyclerActivity.java 7KB
BaseHttpListActivity.java 7KB
BaseBottomTabActivity.java 6KB
CityDB.java 6KB
Intents.java 6KB
TopMenuWindow.java 6KB
CaptureActivity.java 6KB
ViewfinderView.java 6KB
TopTabView.java 6KB
TimeRefresher.java 6KB
GridAdapter.java 5KB
BottomMenuView.java 5KB
HttpRequest.java 5KB
ThreadManager.java 5KB
DaemonStrategy21.java 5KB
FlashlightManager.java 5KB
共 451 条
- 1
- 2
- 3
- 4
- 5
资源评论
lsx202406
- 粉丝: 2241
- 资源: 5546
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功