Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ddea335

Browse files
author
chenyouwei
committed
feat:新增debug判断
1 parent 9b8d4cb commit ddea335

File tree

9 files changed

+125
-14
lines changed

9 files changed

+125
-14
lines changed

‎app/build.gradle‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ android {
1111
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1212
}
1313
buildTypes {
14+
15+
debug{
16+
debuggable true
17+
}
18+
1419
release {
1520
minifyEnabled false
1621
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
@@ -52,4 +57,7 @@ dependencies {
5257
// ExoPlayer as IMediaPlayer: optional, experimental
5358
compile 'tv.danmaku.ijk.media:ijkplayer-exo:0.8.8'
5459
implementation 'com.android.support:cardview-v7:25.3.1'
60+
// 滴滴调试工具
61+
debugImplementation 'com.didichuxing.doraemonkit:doraemonkit:1.2.1'
62+
releaseImplementation 'com.didichuxing.doraemonkit:doraemonkit-no-op:1.2.0'
5563
}

‎app/src/main/AndroidManifest.xml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
<activity android:name=".constraintlayout.ConstraintLayoutActivity"/>
6363
<activity android:name=".rvlooper.LooperActivity"/>
6464
<activity android:name=".footer.HeaderAndFooterActivity"/>
65+
6566
</application>
6667

68+
69+
6770
</manifest>

‎app/src/main/java/com/hugh/basis/HughApplication.java‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
package com.hugh.basis;
22

33
import android.app.Application;
4+
import android.content.Context;
5+
import android.content.pm.ApplicationInfo;
6+
import android.os.Debug;
47
import android.util.Log;
58

9+
import com.didichuxing.doraemonkit.DoraemonKit;
10+
611
/**
712
* Created by {chenyouwei}
813
* Date: {2019年4月9日}
@@ -14,7 +19,19 @@ public class HughApplication extends Application {
1419
@Override
1520
public void onCreate() {
1621
super.onCreate();
22+
DoraemonKit.install(this);
1723

1824
Log.e(TAG, "onCreate : getProcessName:" );
25+
Log.e(TAG,"isDebug"+isApkInDebug(this));
26+
}
27+
28+
//判断当前应用是否是debug状态
29+
public static boolean isApkInDebug(Context context) {
30+
try {
31+
ApplicationInfo info = context.getApplicationInfo();
32+
return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
33+
} catch (Exception e) {
34+
return false;
35+
}
1936
}
2037
}

‎app/src/main/java/com/hugh/basis/MainActivity.java‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.annotation.SuppressLint;
44
import android.content.Context;
55
import android.content.Intent;
6+
import android.content.pm.ApplicationInfo;
67
import android.content.res.Configuration;
78
import android.support.v7.app.AppCompatActivity;
89
import android.os.Bundle;
@@ -65,7 +66,8 @@ public class MainActivity extends AppCompatActivity {
6566
private HashMap hashMap = new HashMap();
6667
public static int markNum = 100;
6768
private Button button5;
68-
69+
private int ppp;
70+
private TextView mTvMsg;
6971

7072
@Override
7173
protected void onSaveInstanceState(Bundle outState) {
@@ -212,6 +214,7 @@ protected void onCreate(Bundle savedInstanceState) {
212214
}
213215

214216
setContentView(R.layout.activity_main);
217+
mTvMsg = findViewById(R.id.tv_hello_world);
215218
button = findViewById(R.id.btn_goto);
216219

217220
button.setOnClickListener(new View.OnClickListener() {
@@ -390,8 +393,34 @@ public void onClick(View v) {
390393
startActivity(intent2);
391394
}
392395
});
396+
397+
Log.e("aaa ----pppp",ppp+"");
393398
// ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor();
394399

400+
// Log.e("aaa","111111");
401+
// String a = "";
402+
// if(a.equals("")){
403+
// throw new IllegalArgumentException("类型错误!");
404+
// }
405+
// Log.e("aaa","222222222");
406+
407+
if(isApkInDebug(this)){
408+
mTvMsg.setText("这是debug打开状态");
409+
}else{
410+
mTvMsg.setText("这是debug关闭状态");
411+
}
412+
}
413+
414+
/**
415+
* 判断当前应用是否是debug状态
416+
*/
417+
public static boolean isApkInDebug(Context context) {
418+
try {
419+
ApplicationInfo info = context.getApplicationInfo();
420+
return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
421+
} catch (Exception e) {
422+
return false;
423+
}
395424
}
396425

397426
//1 创建 client对象
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.hugh.basis.kit;
2+
3+
import android.os.Bundle;
4+
import android.support.annotation.Nullable;
5+
import android.support.v7.app.AppCompatActivity;
6+
7+
import com.hugh.basis.R;
8+
9+
/**
10+
* Created by chenyw on 2019年08月19日.
11+
*/
12+
public class KitActivity extends AppCompatActivity {
13+
@Override
14+
protected void onCreate(@Nullable Bundle savedInstanceState) {
15+
super.onCreate(savedInstanceState);
16+
setContentView(R.layout.activity_kit);
17+
}
18+
}

‎app/src/main/java/com/hugh/basis/rvlooper/AutoRollAdapter.java‎

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.text.SpannableString;
77
import android.text.Spanned;
88
import android.text.style.ForegroundColorSpan;
9+
import android.util.Log;
910
import android.view.LayoutInflater;
1011
import android.view.View;
1112
import android.view.ViewGroup;
@@ -29,6 +30,7 @@ public class AutoRollAdapter extends RecyclerView.Adapter<AutoRollAdapter.BaseVi
2930
HashMap<String, CountDownTimer> timerMap = new HashMap<>();
3031
ArrayList<String> timerKeyList = new ArrayList<>();
3132
private List<GroupBookingEntity> mData;
33+
HashMap<String, Long> secondsMap = new HashMap<>();
3234

3335

3436
public AutoRollAdapter(List<GroupBookingEntity> list) {
@@ -53,6 +55,7 @@ public void onBindViewHolder(final BaseViewHolder holder, final int position) {
5355
long endTime = Long.parseLong(data.end_time);
5456
long seconds = endTime - currenTime;
5557
final String mCollageId = data.id;
58+
String index = String.valueOf(position);
5659

5760
holder.mLayoutGoGourp.setOnClickListener(new View.OnClickListener() {
5861
@Override
@@ -65,26 +68,45 @@ public void onClick(View v) {
6568

6669
holder.mTvleaveMembers.setText(spannableString);
6770
String id = data.id;
68-
if (!timerKeyList.contains(id)) {
69-
timerKeyList.add(id);
71+
if (!timerKeyList.contains(index)) {
72+
timerKeyList.add(index);
7073
}
7174

7275
// -----一开始初始化数据
7376

7477
if (holder.countDownTimer != null) {
7578
holder.countDownTimer.cancel();
7679
}
77-
holder.countDownTimer = new CountDownTimer(seconds * 1000, 1000) {
78-
public void onTick(long l) {
79-
holder.mTvCountDown.setText(getTimeStr(l));
80-
}
8180

82-
public void onFinish() {
83-
//倒计时结束
81+
82+
if (secondsMap.get(id) == null) {
83+
holder.countDownTimer = new CountDownTimer(seconds * 1000, 1000) {
84+
public void onTick(long l) {
85+
holder.mTvCountDown.setText(getTimeStr(l));
86+
Log.e("aaa",l+"");
87+
secondsMap.put(id, l);
88+
}
89+
90+
public void onFinish() {
91+
//倒计时结束
8492
// holder.timeTv.setText("00:00");
85-
}
86-
}.start();
87-
timerMap.put(id, holder.countDownTimer);
93+
}
94+
}.start();
95+
} else {
96+
holder.countDownTimer = new CountDownTimer(secondsMap.get(id) , 1000) {
97+
public void onTick(long l) {
98+
holder.mTvCountDown.setText(getTimeStr(l));
99+
secondsMap.put(id, l);
100+
Log.e("ccc",l+"");
101+
}
102+
103+
public void onFinish() {
104+
//倒计时结束
105+
// holder.timeTv.setText("00:00");
106+
}
107+
}.start();
108+
}
109+
timerMap.put(index, holder.countDownTimer);
88110
}
89111

90112
private String getTimeStr(long l) {

‎app/src/main/java/com/hugh/basis/rvlooper/LooperActivity.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ protected void onCreate(Bundle savedInstanceState) {
2929
}
3030

3131
private void initData() {
32-
for (int i = 0; i < 5; i++) {
32+
for (int i = 0; i < 2; i++) {
3333
GroupBookingEntity entity = new GroupBookingEntity();
3434
entity.nickname = "我是一个游客"+i;
3535
entity.collage_people = "10";
3636
entity.now_people = i+"";
3737
entity.end_time = "86400";
38-
entity.current_time =(100+i*30)+"";
38+
entity.current_time =(1000+i*300)+"";
3939
entity.id="id"+i;
4040
list.add(entity);
4141
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent">
6+
7+
<TextView
8+
android:layout_width="wrap_content"
9+
android:layout_height="wrap_content"
10+
android:text="这是一个kit"
11+
/>
12+
13+
</LinearLayout>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
android:orientation="vertical">
1313

1414
<TextView
15+
android:id="@+id/tv_hello_world"
1516
android:layout_width="wrap_content"
1617
android:layout_height="wrap_content"
1718
android:text="Hello World!"

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /