Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
23_126
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
23-126
23_126
Commits
a7a78c1c
Commit
a7a78c1c
authored
Oct 11, 2023
by
Weesinghe W.M.P.D
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change Styles
parent
30ebe44f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
134 additions
and
3 deletions
+134
-3
app/src/androidTest/java/PredictReward.java
app/src/androidTest/java/PredictReward.java
+128
-0
app/src/main/java/com/example/thetrek/screens/locationsHandler/AddLocations.java
...xample/thetrek/screens/locationsHandler/AddLocations.java
+1
-0
app/src/main/res/layout/activity_create.xml
app/src/main/res/layout/activity_create.xml
+3
-2
app/src/main/res/layout/activity_suggest.xml
app/src/main/res/layout/activity_suggest.xml
+2
-1
No files found.
app/src/androidTest/java/PredictReward.java
0 → 100644
View file @
a7a78c1c
import
android.os.Bundle
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.EditText
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
androidx.appcompat.app.AppCompatActivity
;
import
com.android.volley.Request
;
import
com.android.volley.RequestQueue
;
import
com.android.volley.Response
;
import
com.android.volley.VolleyError
;
import
com.android.volley.toolbox.StringRequest
;
import
com.android.volley.toolbox.Volley
;
import
com.example.thetrek.R
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
PredictReward
extends
AppCompatActivity
{
EditText
Latitude
,
Longitude
,
Elevation
;
Button
predict
;
TextView
Reward
;
String
url
=
"https://trek-7f4725930ac3.herokuapp.com/predict"
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
predict_reward
);
Latitude
=
findViewById
(
R
.
id
.
latitude
);
Longitude
=
findViewById
(
R
.
id
.
longitude
);
Elevation
=
findViewById
(
R
.
id
.
elevation
);
predict
=
findViewById
(
R
.
id
.
predict
);
Reward
=
findViewById
(
R
.
id
.
reward
);
predict
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
// hit the API -> Volley
StringRequest
stringRequest
=
new
StringRequest
(
Request
.
Method
.
POST
,
url
,
new
Response
.
Listener
<
String
>()
{
@Override
public
void
onResponse
(
String
response
)
{
try
{
JSONObject
jsonObject
=
new
JSONObject
(
response
);
String
data
=
jsonObject
.
getString
(
"predict"
);
// switch (data) {
// case "0":
// Reward.setText("Reward level 0 can get!");
// break;
// case "1":
// Reward.setText("Reward level 1 can get!");
// break;
// case "2":
// Reward.setText("Reward level 2 can get!");
// break;
// case "3":
// Reward.setText("Reward level 3 can get!");
// break;
// case "4":
// Reward.setText("Reward level 4 can get!");
// break;
// case "5":
// Reward.setText("Reward level 5 can get!");
// break;
// default:
// Reward.setText("No any reward can get!");
// break;
// }
// } catch (JSONException e) {
// e.printStackTrace();
// }
//
// }
// },
if
(
data
.
equals
(
"0"
)){
Reward
.
setText
(
"Reward level 0 can get!"
);
}
else
if
(
data
.
equals
(
"1"
)){
Reward
.
setText
(
"Reward level 1 can get!"
);
}
else
if
(
data
.
equals
(
"2"
)){
Reward
.
setText
(
"Reward level 2 can get!"
);
}
else
if
(
data
.
equals
(
"3"
)){
Reward
.
setText
(
"Reward level 3 can get!"
);
}
else
if
(
data
.
equals
(
"4"
)){
Reward
.
setText
(
"Reward level 4 can get!"
);
}
else
if
(
data
.
equals
(
"5"
)){
Reward
.
setText
(
"Reward level 5 can get!"
);
}
else
{
Reward
.
setText
(
"No any reward can get!"
);
}
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
}
},
new
Response
.
ErrorListener
()
{
@Override
public
void
onErrorResponse
(
VolleyError
error
)
{
Toast
.
makeText
(
PredictReward
.
this
,
error
.
getMessage
(),
Toast
.
LENGTH_SHORT
).
show
();
}
}){
@Override
protected
Map
<
String
,
String
>
getParams
(){
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
params
.
put
(
"Latitude"
,
Latitude
.
getText
().
toString
());
params
.
put
(
"Longitude"
,
Longitude
.
getText
().
toString
());
params
.
put
(
"Elevation"
,
Elevation
.
getText
().
toString
());
return
params
;
}
};
RequestQueue
queue
=
Volley
.
newRequestQueue
(
PredictReward
.
this
);
queue
.
add
(
stringRequest
);
}
});
}
}
app/src/main/java/com/example/thetrek/screens/locationsHandler/AddLocations.java
View file @
a7a78c1c
...
...
@@ -11,6 +11,7 @@ import android.widget.Toast;
import
com.example.thetrek.R
;
import
com.example.thetrek.db.LocationDAO
;
import
com.example.thetrek.screens.findPlaces.FindPlacesActivity
;
public
class
AddLocations
extends
AppCompatActivity
{
private
EditText
editTextLatitude
;
...
...
app/src/main/res/layout/activity_create.xml
View file @
a7a78c1c
...
...
@@ -5,7 +5,7 @@
android:layout_width=
"match_parent"
android:padding=
"16dp"
android:layout_height=
"match_parent"
android:background=
"@drawable/
home
"
android:background=
"@drawable/
background
"
tools:context=
".activities.CreateActivity"
>
<TextView
...
...
@@ -14,7 +14,8 @@
android:layout_height=
"wrap_content"
android:text=
"@string/profile_info"
android:textSize=
"20sp"
android:textColor=
"@color/white"
android:textColor=
"@color/black"
android:textStyle=
"bold"
android:paddingBottom=
"12dp"
app:layout_constraintTop_toTopOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
...
...
app/src/main/res/layout/activity_suggest.xml
View file @
a7a78c1c
...
...
@@ -5,6 +5,7 @@
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
".SuggestActivity"
android:background=
"@drawable/background"
android:orientation=
"vertical"
>
<TextView
...
...
@@ -78,7 +79,7 @@
<Button
android:layout_width=
"match_parent"
android:layout_height=
"65dp"
android:text=
"Predict"
android:text=
"
Click For
Predict"
android:layout_marginTop=
"20dp"
android:textStyle=
"bold"
android:id=
"@+id/predict"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment