Skip to content

Commit cb2f1fc

Browse files
authored
Merge pull request #64 from sentry-demos/perf-issues-db_main_thread
upgrade SDK with plugin 3.11.1 and add perf issues db main thread
2 parents 2d3a77e + f193e98 commit cb2f1fc

File tree

7 files changed

+40
-18
lines changed

7 files changed

+40
-18
lines changed

app-debug.apk

-4.14 MB
Binary file not shown.

app-release.apk

12.9 KB
Binary file not shown.

app/build.gradle

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import java.sql.Wrapper
22

33
buildscript {
4-
ext.kotlin_version= '1.8.0'
4+
ext.kotlin_version= '1.8.20'
55
dependencies {
66
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
77
}
@@ -11,7 +11,7 @@ buildscript {
1111
}
1212

1313
plugins {
14-
id "io.sentry.android.gradle" version "3.8.0"
14+
id "io.sentry.android.gradle" version "3.11.1"
1515
}
1616

1717
apply plugin: 'com.android.application'
@@ -42,8 +42,8 @@ android {
4242
applicationId "com.example.vu.android"
4343
minSdkVersion 21
4444
targetSdkVersion 29
45-
versionCode 26
46-
versionName "2.4.5"
45+
versionCode 27
46+
versionName "2.5.0"
4747

4848
externalNativeBuild {
4949
cmake {
@@ -91,9 +91,6 @@ dependencies {
9191
implementation fileTree(dir: 'libs', include: ['*.jar'])
9292
implementation 'androidx.appcompat:appcompat:1.1.0'
9393
implementation group: 'androidx.constraintlayout', name: 'constraintlayout', version: '1.1.3'
94-
implementation 'io.sentry:sentry-android:6.20.0'
95-
implementation 'io.sentry:sentry-android-okhttp:6.20.0'
96-
implementation 'io.sentry:sentry-android-fragment:6.20.0'
9794
implementation 'com.google.android.material:material:1.0.0'
9895
implementation 'androidx.navigation:navigation-fragment:2.5.3'
9996
implementation 'androidx.navigation:navigation-ui:2.5.3'

app/src/main/java/com/example/vu/android/empowerplant/AppDatabase.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@ public abstract class AppDatabase extends RoomDatabase {
1313

1414
private static volatile AppDatabase INSTANCE;
1515
//singleton recommended
16-
static AppDatabase getInstance(Context context){
17-
if(INSTANCE == null){
18-
synchronized (AppDatabase.class){
19-
if(INSTANCE == null){
20-
INSTANCE = Room.databaseBuilder(context.getApplicationContext(),
21-
AppDatabase.class,"AppDatabase").build();
22-
}
23-
}
16+
public static synchronized AppDatabase getInstance(Context context){
17+
if (INSTANCE == null){
18+
INSTANCE = Room.databaseBuilder(context.getApplicationContext(),
19+
AppDatabase.class,"AppDatabase")
20+
.allowMainThreadQueries()
21+
.build();
2422
}
2523
return INSTANCE;
2624
}

app/src/main/java/com/example/vu/android/empowerplant/EmpowerPlantActivity.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import android.widget.TextView;
1010

1111
import androidx.fragment.app.FragmentTransaction;
12+
import java.util.ArrayList;
13+
import java.util.List;
1214

1315
import com.example.vu.android.MainActivity;
1416
import com.example.vu.android.MyBaseActivity;
@@ -25,10 +27,32 @@ protected void onCreate(Bundle savedInstanceState) {
2527
super.onCreate(savedInstanceState);
2628

2729
setContentView(R.layout.activity_empowerplant);
30+
dbQuery();
2831
addAttachment(true);
2932
this.loadFragmentList();
3033
}
3134

35+
public void dbQuery() {
36+
List<StoreItem> tmpStoreItems = new ArrayList<StoreItem>();
37+
for (int i = 0; i < 30; i++) {
38+
StoreItem storeitem = new StoreItem();
39+
storeitem.setName("tmp");
40+
storeitem.setSku("tmp");
41+
storeitem.setPrice(i);
42+
storeitem.setImage("tmp");
43+
storeitem.setItemId(i);
44+
storeitem.setQuantity(1);
45+
tmpStoreItems.add(storeitem);
46+
}
47+
48+
AppDatabase.getInstance(getApplicationContext())
49+
.StoreItemDAO().insertAll(tmpStoreItems);
50+
51+
AppDatabase.getInstance(getApplicationContext())
52+
.StoreItemDAO().deleteAll();
53+
54+
}
55+
3256
@Override
3357
public boolean onCreateOptionsMenu(Menu menu) {
3458
// Inflate the menu; this adds items to the action bar if it is present.

app/src/main/java/com/example/vu/android/empowerplant/StoreItemDAO.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ public interface StoreItemDAO {
1212
@Query("SELECT * FROM storeitem")
1313
List<StoreItem> getAll();
1414

15+
@Query("DELETE FROM storeitem")
16+
public void deleteAll();
17+
1518
@Insert(onConflict = OnConflictStrategy.REPLACE)
1619
void insertAll(List<StoreItem> storeItems);
1720
//This assumes that PKs of demo data are static. Dynamically generated skus/product ids could problematically accumulate entries across simulations.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Mon Mar 28 08:58:46 PDT 2022
1+
#Sun Jul 02 13:22:01 PDT 2023
22
distributionBase=GRADLE_USER_HOME
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
43
distributionPath=wrapper/dists
5-
zipStorePath=wrapper/dists
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
65
zipStoreBase=GRADLE_USER_HOME
6+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)