Skip to content

Commit

Permalink
see 07/17 log
Browse files Browse the repository at this point in the history
  • Loading branch information
Blankj committed Jul 17, 2017
1 parent f43059d commit ad9f8c4
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public void onWidgetClick(View view) {

private void setAboutNetwork() {
tvAboutNetwork.setText("isConnected: " + NetworkUtils.isConnected()
+ "\nisAvailableByPing: " + NetworkUtils.isAvailableByPing()
+ "\ngetDataEnabled: " + NetworkUtils.getDataEnabled()
+ "\nis4G: " + NetworkUtils.is4G()
+ "\ngetWifiEnabled: " + NetworkUtils.getWifiEnabled()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ public int bindLayout() {

@Override
public void initView(Bundle savedInstanceState, View view) {

BarUtils.setStatusBar4ImageViewInFragment(mActivity, null);
}

@Override
public void doBusiness(Context context) {
BarUtils.setStatusBar4ImageViewInFragment(mActivity, null);

}

@Override
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/activity_snackbar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="@dimen/spacing_16">
android:padding="@dimen/spacing_16"
android:paddingBottom="@dimen/spacing_80">

<Button
android:id="@+id/btn_short_snackbar"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<dimen name="spacing_8">8dp</dimen>
<dimen name="spacing_16">16dp</dimen>
<dimen name="spacing_24">24dp</dimen>
<dimen name="spacing_80">80dp</dimen>

<dimen name="font_40">40sp</dimen>
<dimen name="font_26">26sp</dimen>
Expand Down
1 change: 1 addition & 0 deletions update_log.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* 17/07/17 将NetworkUtils的isAvailableByPing函数新增ip参数
* 17/07/14 将FragmentUtils的FragmentNode置为public
* 17/07/11 将不常用的工具类放在subutil中
* 17/07/10 新增subutil库
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,28 @@ public static boolean isConnected() {
/**
* 判断网络是否可用
* <p>需添加权限 {@code <uses-permission android:name="android.permission.INTERNET"/>}</p>
* <p>需要异步ping,如果ping不通就说明网络不可用</p>
* <p>ping的ip为阿里巴巴公共ip: 223.5.5.5</p>
*
* @return {@code true}: 可用<br>{@code false}: 不可用
*/
public static boolean isAvailableByPing() {
ShellUtils.CommandResult result = ShellUtils.execCmd("ping -c 1 -w 1 223.5.5.5", false);
return isAvailableByPing();
}

/**
* 判断网络是否可用
* <p>需添加权限 {@code <uses-permission android:name="android.permission.INTERNET"/>}</p>
* <p>需要异步ping,如果ping不通就说明网络不可用</p>
*
* @param ip ip地址(自己服务器ip),如果为空,ip为阿里巴巴公共ip
* @return {@code true}: 可用<br>{@code false}: 不可用
*/
public static boolean isAvailableByPing(String ip) {
if (ip == null || ip.length() <= 0) {
ip = "223.5.5.5";// 阿里巴巴公共ip
}
ShellUtils.CommandResult result = ShellUtils.execCmd(String.format("ping -c 1 %s", ip), false);
boolean ret = result.result == 0;
if (result.errorMsg != null) {
Log.d("NetworkUtils", "isAvailableByPing() called" + result.errorMsg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static void init() {
Utils.init(RuntimeEnvironment.application);
}

// @Test
// @Test
public void readme2Eng() throws Exception {
formatCN();
File readmeCN = new File(new File(System.getProperty("user.dir")).getAbsolutePath() + FILE_SEP + "README-CN.md");
Expand Down

0 comments on commit ad9f8c4

Please sign in to comment.