Skip to content

Commit a64c2e0

Browse files
committed
see 11/02 log
1 parent b20421e commit a64c2e0

File tree

15 files changed

+175
-38
lines changed

15 files changed

+175
-38
lines changed

app/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,8 @@ dependencies {
2424
compile project(':utilcode')
2525
compile rootProject.ext.deps.design
2626
compile rootProject.ext.deps.supportV4
27+
28+
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
29+
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
30+
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
2731
}

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
<activity android:name=".activities.AppActivity"/>
4040
<activity android:name=".activities.CleanActivity"/>
4141
<activity android:name=".activities.DeviceActivity"/>
42+
<activity android:name=".activities.HandlerActivity"/>
4243
<activity android:name=".activities.ImageActivity"/>
4344
<activity
4445
android:name=".activities.KeyboardActivity"

app/src/main/java/com/blankj/androidutilcode/App.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import com.blankj.utilcode.utils.CrashUtils;
88
import com.blankj.utilcode.utils.LogUtils;
9+
import com.squareup.leakcanary.LeakCanary;
910

1011
import java.lang.ref.WeakReference;
1112

@@ -28,6 +29,12 @@ public static App getInstance() {
2829
@Override
2930
public void onCreate() {
3031
super.onCreate();
32+
if (LeakCanary.isInAnalyzerProcess(this)) {
33+
// This process is dedicated to LeakCanary for heap analysis.
34+
// You should not init your app in this process.
35+
return;
36+
}
37+
LeakCanary.install(this);
3138
ourInstance = this;
3239
CrashUtils.getInstance().init(this);
3340
LogUtils.getBuilder(this).setTag("MyTag").setLog2FileSwitch(true).create();

app/src/main/java/com/blankj/androidutilcode/activities/DeviceActivity.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.view.View;
66
import android.widget.TextView;
77

8+
import com.blankj.androidutilcode.App;
89
import com.blankj.androidutilcode.R;
910
import com.blankj.utilcode.utils.DeviceUtils;
1011

@@ -17,7 +18,7 @@
1718
* </pre>
1819
*/
1920
public class DeviceActivity extends Activity
20-
implements View.OnClickListener{
21+
implements View.OnClickListener {
2122

2223
@Override
2324
protected void onCreate(Bundle savedInstanceState) {
@@ -31,8 +32,8 @@ protected void onCreate(Bundle savedInstanceState) {
3132

3233
tvAboutDevice.setText("isRoot: " + DeviceUtils.isDeviceRoot() +
3334
"\ngetSDKVersion: " + DeviceUtils.getSDKVersion() +
34-
"\ngetAndroidID: " + DeviceUtils.getAndroidID(this) +
35-
"\ngetMacAddress: " + DeviceUtils.getMacAddress(this)+
35+
"\ngetAndroidID: " + DeviceUtils.getAndroidID(App.getInstance()) +
36+
"\ngetMacAddress: " + DeviceUtils.getMacAddress(App.getInstance()) +
3637
"\ngetManufacturer: " + DeviceUtils.getManufacturer() +
3738
"\ngetModel: " + DeviceUtils.getModel()
3839
);
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package com.blankj.androidutilcode.activities;
2+
3+
import android.app.Activity;
4+
import android.os.Bundle;
5+
import android.os.Message;
6+
import android.view.View;
7+
import android.widget.TextView;
8+
9+
import com.blankj.androidutilcode.R;
10+
import com.blankj.utilcode.utils.DeviceUtils;
11+
import com.blankj.utilcode.utils.HandlerUtils;
12+
import com.blankj.utilcode.utils.LogUtils;
13+
14+
/**
15+
* <pre>
16+
* author: Blankj
17+
* blog : http://blankj.com
18+
* time : 2016/9/27
19+
* desc : Device工具类测试
20+
* </pre>
21+
*/
22+
public class HandlerActivity extends Activity
23+
implements View.OnClickListener, HandlerUtils.OnReceiveMessageListener {
24+
25+
private TextView tvAboutHandler0;
26+
private TextView tvAboutHandler1;
27+
HandlerUtils.HandlerHolder handlerHolder;
28+
29+
@Override
30+
protected void onCreate(Bundle savedInstanceState) {
31+
super.onCreate(savedInstanceState);
32+
setContentView(R.layout.activity_handler);
33+
34+
tvAboutHandler0 = (TextView) findViewById(R.id.tv_about_handler0);
35+
tvAboutHandler1 = (TextView) findViewById(R.id.tv_about_handler1);
36+
findViewById(R.id.btn_send_msg_after_3s).setOnClickListener(this);
37+
38+
handlerHolder = new HandlerUtils.HandlerHolder(this);
39+
}
40+
41+
@Override
42+
public void onClick(View view) {
43+
switch (view.getId()) {
44+
case R.id.btn_send_msg_after_3s:
45+
handlerHolder.sendEmptyMessageDelayed(0, 30000);
46+
break;
47+
}
48+
}
49+
50+
@Override
51+
public void handlerMessage(Message msg) {
52+
tvAboutHandler1.setText("get_msg_after_3s");
53+
}
54+
}

app/src/main/java/com/blankj/androidutilcode/activities/MainActivity.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ public void deviceClick(View view) {
4343
startActivity(new Intent(this, DeviceActivity.class));
4444
}
4545

46+
public void handlerClick(View view) {
47+
startActivity(new Intent(this, HandlerActivity.class));
48+
}
49+
4650
public void imageClick(View view) {
4751
startActivity(new Intent(this, ImageActivity.class));
4852
}

app/src/main/res/layout/activity_device.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,5 @@
3636
android:gravity="center"
3737
/>
3838

39-
4039
</LinearLayout>
4140
</ScrollView>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<ScrollView
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent">
6+
<LinearLayout
7+
android:layout_width="match_parent"
8+
android:layout_height="wrap_content"
9+
android:gravity="center_horizontal"
10+
android:orientation="vertical"
11+
android:padding="@dimen/spacing_small">
12+
13+
14+
<Button
15+
android:id="@+id/btn_send_msg_after_3s"
16+
style="@style/BtnFont"
17+
android:layout_width="match_parent"
18+
android:layout_height="wrap_content"
19+
android:text="@string/handler.send_msg_after_3s"
20+
/>
21+
22+
<TextView
23+
android:id="@+id/tv_about_handler0"
24+
style="@style/Font"
25+
android:layout_width="match_parent"
26+
android:layout_height="wrap_content"
27+
android:gravity="center"
28+
/>
29+
30+
<TextView
31+
android:id="@+id/tv_about_handler1"
32+
style="@style/Font"
33+
android:layout_width="match_parent"
34+
android:layout_height="wrap_content"
35+
android:gravity="center"
36+
/>
37+
38+
39+
</LinearLayout>
40+
</ScrollView>

app/src/main/res/layout/activity_main.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@
5151
android:text="@string/test.device"
5252
/>
5353

54+
<Button
55+
style="@style/BtnFont"
56+
android:layout_width="match_parent"
57+
android:layout_height="wrap_content"
58+
android:onClick="handlerClick"
59+
android:text="@string/test.handler"
60+
/>
61+
5462
<Button
5563
style="@style/BtnFont"
5664
android:layout_width="match_parent"

app/src/main/res/values/string.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<string name="test.clean">CleanUtils Test</string>
88
<string name="test.crash">CrashUtils Test</string>
99
<string name="test.device">DeviceUtils Test</string>
10+
<string name="test.handler">HandlerUtils Test</string>
1011
<string name="test.image">ImageUtils Test</string>
1112
<string name="test.keyboard">KeyboardUtils Test</string>
1213
<string name="test.network">NetworkUtils Test</string>
@@ -33,6 +34,9 @@
3334
<string name="device.shutdown">Shutdown</string>
3435
<string name="device.reboot">Reboot</string>
3536

37+
<!--Handler相关-->
38+
<string name="handler.send_msg_after_3s">Send Msg After 3s</string>
39+
3640
<!--Network相关-->
3741
<string name="network.open_wireless_settings">Open Wireless Settings</string>
3842
<string name="network.set_data_enabled">Set Data Enabled</string>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy