Skip to content

Commit 2d9d6b4

Browse files
committed
add toolstore activity
1 parent 609c925 commit 2d9d6b4

20 files changed

+679
-37
lines changed

app/build.gradle

+10-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ android {
4141
}
4242
}
4343

44+
buildFeatures {
45+
dataBinding true
46+
}
47+
4448
lintOptions {
4549
abortOnError false
4650
}
@@ -52,7 +56,12 @@ dependencies {
5256
implementation fileTree(dir: 'libs', include: ['*.jar'])
5357
implementation 'androidx.appcompat:appcompat:1.1.0'
5458
implementation group: 'androidx.constraintlayout', name: 'constraintlayout', version: '1.1.3'
55-
implementation 'io.sentry:sentry-android:4.0.0-beta.1'
59+
implementation 'io.sentry:sentry-android:4.0.0'
60+
implementation 'com.android.volley:volley:1.1.1'
61+
implementation 'com.google.android.material:material:1.0.0'
62+
implementation 'androidx.navigation:navigation-fragment:2.1.0'
63+
implementation 'androidx.navigation:navigation-ui:2.1.0'
64+
// implementation 'androidx.appcompat:appcompat:1.0.0'
5665
}
5766

5867
sentry {

app/src/main/AndroidManifest.xml

+35-32
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,58 @@
1-
<?xml version="1.1" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools"
44
package="com.example.vu.android">
55

6+
<uses-sdk tools:overrideLibrary="io.sentry.android" />
7+
68
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
9+
<uses-permission android:name="android.permission.INTERNET" />
710
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
811

9-
<uses-sdk
10-
tools:overrideLibrary="io.sentry.android"/>
11-
1212
<application
1313
android:name=".MyApplication"
1414
android:allowBackup="true"
1515
android:icon="@mipmap/ic_launcher"
1616
android:label="@string/app_name"
1717
android:roundIcon="@mipmap/ic_launcher_round"
1818
android:supportsRtl="true"
19-
android:theme="@style/AppTheme"
20-
>
21-
<activity
22-
android:name=".MainActivity">
19+
android:theme="@style/AppTheme">
20+
<activity android:name=".MainActivity">
2321
<intent-filter>
2422
<action android:name="android.intent.action.MAIN" />
25-
2623
<category android:name="android.intent.category.LAUNCHER" />
2724
</intent-filter>
2825
</activity>
29-
30-
<meta-data android:name="io.sentry.dsn"
31-
android:value="https://[email protected]/1801383"/>
32-
<meta-data android:name="io.sentry.debug" android:value="true" />
33-
<meta-data android:name="io.sentry.auto-init" android:value="false" />
34-
35-
<!-- This line not needed any more, because now we have a safe guard, waiting for the Operating System to raise an ANR in the processor, it waits 5seconds. Lowering this number just makes it to check the state of the processor more times.-->
36-
<!-- lowering this number below 5000ms overrides the 5000ms, we check the state of the processor faster. doesn't mean we're detecting more ANR's or not-->
37-
38-
<!-- Default is 5seconds (is from the OperatingSystem, to define the state of Not Responding) and defined by the SDK-->
39-
<!--we can check the state of the property ourselves, using this-->
40-
<!-- <meta-data android:name="io.sentry.anr.timeout-interval-mills" android:value="3000" />-->
41-
26+
<activity
27+
android:name=".toolstore.ToolstoreActivity"
28+
android:label="@string/title_activity_toolstore"
29+
android:parentActivityName=".MainActivity">
30+
<meta-data
31+
android:name="android.support.PARENT_ACTIVITY"
32+
android:value=".MainActivity" />
33+
</activity>
34+
<meta-data
35+
android:name="io.sentry.dsn"
36+
android:value="https://[email protected]/1801383" />
37+
<meta-data
38+
android:name="io.sentry.debug"
39+
android:value="true" />
40+
<meta-data
41+
android:name="io.sentry.auto-init"
42+
android:value="false" /> <!-- This line not needed any more, because now we have a safe guard, waiting for the Operating System to raise an ANR in the processor, it waits 5seconds. Lowering this number just makes it to check the state of the processor more times. -->
43+
<!-- lowering this number below 5000ms overrides the 5000ms, we check the state of the processor faster. doesn't mean we're detecting more ANR's or not -->
44+
<!-- Default is 5seconds (is from the OperatingSystem, to define the state of Not Responding) and defined by the SDK -->
45+
<!-- we can check the state of the property ourselves, using this -->
46+
<!-- <meta-data android:name="io.sentry.anr.timeout-interval-mills" android:value="3000" /> -->
4247
<!-- Easy way to get a new release if you're testing, to separate from past releases with lots of crashes/sessions. overrides what's in app/build.gradle -->
43-
<!-- <meta-data android:name="io.sentry.release" android:value="[email protected]+1" />-->
44-
48+
<!-- <meta-data android:name="io.sentry.release" android:value="[email protected]+1" /> -->
4549
<!-- default interval for testing a session is 30seconds. Session starts when they open app. Session ends when user leaves app and it's idle for 30 seconds -->
46-
<meta-data android:name="io.sentry.session-tracking.timeout-interval-millis" android:value="3000" />
47-
48-
<!-- these are enabled by default, these are optional for us to disable the feature -->
49-
<!-- <meta-data android:name="io.sentry.ndk.enable" android:value="false" />
50-
<meta-data android:name="io.sentry.anr.enable" android:value="false" />
51-
-->
52-
50+
<meta-data
51+
android:name="io.sentry.session-tracking.timeout-interval-millis"
52+
android:value="3000" />
53+
<meta-data
54+
android:name="io.sentry.traces.sample-rate"
55+
android:value="1.0" />
5356
</application>
5457

55-
</manifest>
58+
</manifest>

app/src/main/java/com/example/vu/android/MainActivity.java

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
package com.example.vu.android;
22

33
import android.content.Context;
4+
import android.content.Intent;
45
import android.net.wifi.WifiManager;
56
import android.os.Bundle;
67
import android.text.format.Formatter;
78
import android.view.View;
89
import android.widget.Button;
910
import androidx.appcompat.app.AppCompatActivity;
11+
12+
import com.example.vu.android.toolstore.ToolstoreActivity;
13+
1014
import io.sentry.Breadcrumb;
1115
import io.sentry.Sentry;
1216
import io.sentry.SentryLevel;
@@ -58,9 +62,16 @@ protected void onCreate(Bundle savedInstanceState) {
5862
// Unhandled - NegativeArraySizeException
5963
Button negative_index_button = findViewById(R.id.negative_index);
6064
negative_index_button.setOnClickListener(view -> {
61-
addAttachment(view);
62-
Sentry.addBreadcrumb("Button for NegativeArraySizeException clicked...");
63-
int[] a = new int[-5];
65+
// addAttachment(view);
66+
// Sentry.addBreadcrumb("Button for NegativeArraySizeException clicked...");
67+
// int[] a = new int[-5];
68+
69+
//navigate to 2nd activity
70+
Intent intent = new Intent(this, ToolstoreActivity.class);
71+
// EditText editText = (EditText) findViewById(R.id.editText);
72+
// String message = editText.getText().toString();
73+
// intent.putExtra(EXTRA_MESSAGE, message);
74+
startActivity(intent);
6475
});
6576

6677
// Handled - ArrayIndexOutOfBoundsException
@@ -102,6 +113,7 @@ protected void onCreate(Bundle savedInstanceState) {
102113

103114
}
104115

116+
105117
private Boolean addAttachment(View view) {
106118
// Create a File and Add as attachment
107119
File f = null;

app/src/main/java/com/example/vu/android/MyApplication.java

+7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ public void onCreate() {
2222

2323
// we now enable this in AndroidManifest.xml
2424
// options.setEnableSessionTracking(true);
25+
// To set a uniform sample rate
26+
//options.setTracesSampleRate(1.0);
27+
// OR if you prefer, determine traces sample rate based on the sampling context
28+
// options.setTracesSampler(
29+
// context -> {
30+
// // return a number between 0 and 1
31+
// });
2532

2633
options.setBeforeSend((event, hint) -> {
2734

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.example.vu.android.toolstore;
2+
3+
import android.os.Bundle;
4+
import android.view.LayoutInflater;
5+
import android.view.View;
6+
import android.view.ViewGroup;
7+
8+
import androidx.annotation.NonNull;
9+
import androidx.fragment.app.Fragment;
10+
import androidx.navigation.fragment.NavHostFragment;
11+
12+
import com.example.vu.android.R;
13+
14+
public class FirstFragment extends Fragment {
15+
16+
@Override
17+
public View onCreateView(
18+
LayoutInflater inflater, ViewGroup container,
19+
Bundle savedInstanceState
20+
) {
21+
// Inflate the layout for this fragment
22+
return inflater.inflate(R.layout.fragment_first, container, false);
23+
}
24+
25+
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
26+
super.onViewCreated(view, savedInstanceState);
27+
28+
view.findViewById(R.id.button_first).setOnClickListener(new View.OnClickListener() {
29+
@Override
30+
public void onClick(View view) {
31+
NavHostFragment.findNavController(FirstFragment.this)
32+
.navigate(R.id.action_FirstFragment_to_SecondFragment);
33+
}
34+
});
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.example.vu.android.toolstore;
2+
3+
import android.content.Context;
4+
5+
import com.android.volley.Request;
6+
import com.android.volley.RequestQueue;
7+
import com.android.volley.toolbox.Volley;
8+
9+
public class RequestQueueSigleton {
10+
private static RequestQueueSigleton instance;
11+
private RequestQueue requestQueue;
12+
private static Context ctx;
13+
14+
private RequestQueueSigleton(Context context) {
15+
ctx = context;
16+
requestQueue = getRequestQueue();
17+
}
18+
19+
public static synchronized RequestQueueSigleton getInstance(Context context) {
20+
if (instance == null) {
21+
instance = new RequestQueueSigleton(context);
22+
}
23+
return instance;
24+
}
25+
26+
public RequestQueue getRequestQueue() {
27+
if (requestQueue == null) {
28+
// getApplicationContext() is key, it keeps you from leaking the
29+
// Activity or BroadcastReceiver if someone passes one in.
30+
requestQueue = Volley.newRequestQueue(ctx.getApplicationContext());
31+
}
32+
return requestQueue;
33+
}
34+
35+
public void addToRequestQueue(Request req) {
36+
getRequestQueue().add(req);
37+
}
38+
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.example.vu.android.toolstore;
2+
3+
import android.os.Bundle;
4+
import android.view.LayoutInflater;
5+
import android.view.View;
6+
import android.view.ViewGroup;
7+
8+
import androidx.annotation.NonNull;
9+
import androidx.fragment.app.Fragment;
10+
import androidx.navigation.fragment.NavHostFragment;
11+
12+
import com.example.vu.android.R;
13+
14+
public class SecondFragment extends Fragment {
15+
16+
@Override
17+
public View onCreateView(
18+
LayoutInflater inflater, ViewGroup container,
19+
Bundle savedInstanceState
20+
) {
21+
// Inflate the layout for this fragment
22+
return inflater.inflate(R.layout.fragment_second, container, false);
23+
}
24+
25+
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
26+
super.onViewCreated(view, savedInstanceState);
27+
28+
view.findViewById(R.id.button_second).setOnClickListener(new View.OnClickListener() {
29+
@Override
30+
public void onClick(View view) {
31+
NavHostFragment.findNavController(SecondFragment.this)
32+
.navigate(R.id.action_SecondFragment_to_FirstFragment);
33+
}
34+
});
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package com.example.vu.android.toolstore;
2+
3+
public class StoreItem {
4+
5+
String sku, name, image,type;
6+
int id, price;
7+
8+
public StoreItem() {
9+
}
10+
11+
public StoreItem(String sku, String name, String image, String type, int id, int price) {
12+
this.sku = sku;
13+
this.name = name;
14+
this.image = image;
15+
this.type = type;
16+
this.id = id;
17+
this.price = price;
18+
}
19+
20+
public void setSku(String sku) {
21+
this.sku = sku;
22+
}
23+
24+
public void setName(String name) {
25+
this.name = name;
26+
}
27+
28+
public void setImage(String image) {
29+
this.image = image;
30+
}
31+
32+
public void setType(String type) {
33+
this.type = type;
34+
}
35+
36+
public void setId(int id) {
37+
this.id = id;
38+
}
39+
40+
public void setPrice(int price) {
41+
this.price = price;
42+
}
43+
44+
public String getSku() {
45+
return sku;
46+
}
47+
48+
public String getName() {
49+
return name;
50+
}
51+
52+
public String getImage() {
53+
return image;
54+
}
55+
56+
public String getType() {
57+
return type;
58+
}
59+
60+
public int getId() {
61+
return id;
62+
}
63+
64+
public int getPrice() {
65+
return price;
66+
}
67+
}

0 commit comments

Comments
 (0)