提交 d5a89e0d 编写于 作者: 门心叼龙's avatar 门心叼龙

1.bitmaputil增加了一个方法

2.NetUtil增增加了一个判断网络类型的方法
上级 b41435c1
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fly.tour.common"/>
package="com.fly.tour.common">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
</manifest>
......@@ -406,6 +406,12 @@ public class BitmapUtil {
options.inJustDecodeBounds = false;
return BitmapFactory.decodeFile(path, options);
}
/**
* 获取图片原始的宽、高
* @param url
* @return
*/
public static int[] getImageSize(String url) {
int[] size = new int[]{0, 0};
if (FileUtil.isImageFile(url)) {
......
......@@ -7,6 +7,10 @@ import android.support.annotation.NonNull;
import com.fly.tour.common.BaseApplication;
import static com.fly.tour.common.util.NetUtil.NetType.NET_4G;
import static com.fly.tour.common.util.NetUtil.NetType.NO_NET;
import static com.fly.tour.common.util.NetUtil.NetType.WIFI;
/**
* Description: <ToastUtil><br>
* Author: gxl<br>
......@@ -64,5 +68,28 @@ public class NetUtil {
}
return false;
}
public static NetType isNetWorkState(Context context) {
ConnectivityManager manager =
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = manager.getActiveNetworkInfo();
if (activeNetwork != null) {
if (activeNetwork.isConnected()) {
if (activeNetwork.getType() == ConnectivityManager.TYPE_WIFI) {
// Logger.v(TAG, "当前WiFi连接可用 ");
return WIFI;
} else if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) {
// Logger.v(TAG, "当前移动网络连接可用 ");
return NET_4G;
}
} else {
// Logger.v(TAG, "当前没有网络连接,请确保你已经打开网络 ");
return NO_NET;
}
} else {
// Logger.v(TAG, "当前没有网络连接,请确保你已经打开网络 ");
return NO_NET;
}
return NO_NET;
}
public enum NetType{WIFI,NET_4G,NO_NET};
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册