Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CS123-CanteeneoAndroid
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Willard Torres
CS123-CanteeneoAndroid
Commits
ad5aa333
Commit
ad5aa333
authored
Dec 03, 2016
by
Willard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix adding dish review
parent
08af01f0
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
40 additions
and
16 deletions
+40
-16
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+0
-2
AddDishReviewActivity.java
app/src/main/java/com/testapp/AddDishReviewActivity.java
+6
-5
AppUtils.java
app/src/main/java/com/testapp/AppUtils.java
+1
-0
DishViewActivity.java
app/src/main/java/com/testapp/DishViewActivity.java
+6
-3
LoginActivity.java
app/src/main/java/com/testapp/LoginActivity.java
+1
-0
Token.java
app/src/main/java/com/testapp/entities/Token.java
+22
-2
content_add_review.xml
app/src/main/res/layout/content_add_review.xml
+4
-4
No files found.
app/src/main/AndroidManifest.xml
View file @
ad5aa333
...
@@ -43,8 +43,6 @@
...
@@ -43,8 +43,6 @@
android:theme=
"@style/AppTheme"
/>
android:theme=
"@style/AppTheme"
/>
<activity
android:name=
".RegisterActivity"
>
<activity
android:name=
".RegisterActivity"
>
</activity>
</activity>
<activity
android:name=
".AddStallReviewActivity"
>
</activity>
</application>
</application>
</manifest>
</manifest>
\ No newline at end of file
app/src/main/java/com/testapp/AddDishReviewActivity.java
View file @
ad5aa333
...
@@ -38,7 +38,7 @@ public class AddDishReviewActivity extends AppCompatActivity {
...
@@ -38,7 +38,7 @@ public class AddDishReviewActivity extends AppCompatActivity {
rating
=
(
RatingBar
)
findViewById
(
R
.
id
.
rv_rating
);
rating
=
(
RatingBar
)
findViewById
(
R
.
id
.
rv_rating
);
id
=
getIntent
().
getIntExtra
(
"ID"
,
0
);
id
=
getIntent
().
getIntExtra
(
"ID"
,
0
);
Toast
.
makeText
(
getApplicationContext
(),
id
+
""
,
Toast
.
LENGTH_SHORT
).
show
();
FloatingActionButton
fab
=
(
FloatingActionButton
)
findViewById
(
R
.
id
.
fab
);
FloatingActionButton
fab
=
(
FloatingActionButton
)
findViewById
(
R
.
id
.
fab
);
fab
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
fab
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
@Override
...
@@ -47,8 +47,8 @@ public class AddDishReviewActivity extends AppCompatActivity {
...
@@ -47,8 +47,8 @@ public class AddDishReviewActivity extends AppCompatActivity {
rv
.
setTitle
(
title
.
getText
().
toString
());
rv
.
setTitle
(
title
.
getText
().
toString
());
rv
.
setBody
(
body
.
getText
().
toString
());
rv
.
setBody
(
body
.
getText
().
toString
());
rv
.
setRating
((
int
)
rating
.
getRating
());
rv
.
setRating
((
int
)
rating
.
getRating
());
rv
.
setDishId
(
id
);
//todo add user_id
rv
.
setUserId
(
AppUtils
.
userId
);
sendReview
(
id
,
rv
);
sendReview
(
id
,
rv
);
}
}
...
@@ -60,8 +60,9 @@ public class AddDishReviewActivity extends AppCompatActivity {
...
@@ -60,8 +60,9 @@ public class AddDishReviewActivity extends AppCompatActivity {
call
.
enqueue
(
new
Callback
<
ResponseBody
>()
{
call
.
enqueue
(
new
Callback
<
ResponseBody
>()
{
@Override
@Override
public
void
onResponse
(
Call
<
ResponseBody
>
call
,
Response
<
ResponseBody
>
response
)
{
public
void
onResponse
(
Call
<
ResponseBody
>
call
,
Response
<
ResponseBody
>
response
)
{
Toast
.
makeText
(
getApplicationContext
(),
"Review posted!"
,
Toast
.
LENGTH_SHORT
);
setResult
(
RESULT_OK
);
//finish();
finish
();
}
}
@Override
@Override
...
...
app/src/main/java/com/testapp/AppUtils.java
View file @
ad5aa333
...
@@ -25,6 +25,7 @@ public class AppUtils {
...
@@ -25,6 +25,7 @@ public class AppUtils {
private
static
Context
c
;
private
static
Context
c
;
public
static
String
username
=
""
;
public
static
String
username
=
""
;
public
static
String
password
=
""
;
public
static
String
password
=
""
;
public
static
int
userId
=
-
1
;
public
static
boolean
isNetworkAvailable
(
Context
c
)
{
public
static
boolean
isNetworkAvailable
(
Context
c
)
{
ConnectivityManager
connectivity
=(
ConnectivityManager
)
c
.
getSystemService
(
Context
.
CONNECTIVITY_SERVICE
);
ConnectivityManager
connectivity
=(
ConnectivityManager
)
c
.
getSystemService
(
Context
.
CONNECTIVITY_SERVICE
);
...
...
app/src/main/java/com/testapp/DishViewActivity.java
View file @
ad5aa333
...
@@ -31,6 +31,8 @@ public class DishViewActivity extends AppCompatActivity {
...
@@ -31,6 +31,8 @@ public class DishViewActivity extends AppCompatActivity {
private
DishReviewAdapter
adapter
;
private
DishReviewAdapter
adapter
;
private
CheckBox
favoriteCheckbox
;
private
CheckBox
favoriteCheckbox
;
private
int
id
;
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
...
@@ -44,7 +46,7 @@ public class DishViewActivity extends AppCompatActivity {
...
@@ -44,7 +46,7 @@ public class DishViewActivity extends AppCompatActivity {
setTitle
(
"Dish Pls"
);
setTitle
(
"Dish Pls"
);
Intent
i
=
getIntent
();
Intent
i
=
getIntent
();
final
int
id
=
i
.
getIntExtra
(
"ID"
,
0
);
id
=
i
.
getIntExtra
(
"ID"
,
0
);
TextView
dishName
=
(
TextView
)
findViewById
(
R
.
id
.
dish_name
);
TextView
dishName
=
(
TextView
)
findViewById
(
R
.
id
.
dish_name
);
dishName
.
setText
(
i
.
getStringExtra
(
"NAME"
));
dishName
.
setText
(
i
.
getStringExtra
(
"NAME"
));
TextView
dishPrice
=
(
TextView
)
findViewById
(
R
.
id
.
dish_price
);
TextView
dishPrice
=
(
TextView
)
findViewById
(
R
.
id
.
dish_price
);
...
@@ -103,7 +105,7 @@ public class DishViewActivity extends AppCompatActivity {
...
@@ -103,7 +105,7 @@ public class DishViewActivity extends AppCompatActivity {
@Override
@Override
public
void
onClick
(
View
v
)
{
public
void
onClick
(
View
v
)
{
Intent
i
=
new
Intent
(
DishViewActivity
.
this
,
AddDishReviewActivity
.
class
);
Intent
i
=
new
Intent
(
DishViewActivity
.
this
,
AddDishReviewActivity
.
class
);
i
.
putExtra
(
"ID"
,
i
.
getIntExtra
(
"ID"
,
0
)
);
i
.
putExtra
(
"ID"
,
i
d
);
startActivityForResult
(
i
,
0
);
startActivityForResult
(
i
,
0
);
}
}
});
});
...
@@ -154,7 +156,8 @@ public class DishViewActivity extends AppCompatActivity {
...
@@ -154,7 +156,8 @@ public class DishViewActivity extends AppCompatActivity {
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
if
(
requestCode
==
0
)
{
if
(
requestCode
==
0
)
{
if
(
resultCode
==
RESULT_OK
)
{
if
(
resultCode
==
RESULT_OK
)
{
Toast
.
makeText
(
this
,
"Review Added"
,
Toast
.
LENGTH_SHORT
);
Toast
.
makeText
(
this
,
"Review Added"
,
Toast
.
LENGTH_SHORT
).
show
();
getDishReviews
(
id
);
}
}
}
}
}
}
...
...
app/src/main/java/com/testapp/LoginActivity.java
View file @
ad5aa333
...
@@ -129,6 +129,7 @@ public class LoginActivity extends AppCompatActivity {
...
@@ -129,6 +129,7 @@ public class LoginActivity extends AppCompatActivity {
Toast
.
makeText
(
LoginActivity
.
this
,
"Invalid credentials!"
,
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
LoginActivity
.
this
,
"Invalid credentials!"
,
Toast
.
LENGTH_LONG
).
show
();
}
else
{
}
else
{
Toast
.
makeText
(
LoginActivity
.
this
,
"Logged in as "
+
AppUtils
.
username
+
" successfully."
,
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
LoginActivity
.
this
,
"Logged in as "
+
AppUtils
.
username
+
" successfully."
,
Toast
.
LENGTH_LONG
).
show
();
AppUtils
.
userId
=
response
.
body
().
getId
();
Intent
intent
=
new
Intent
(
LoginActivity
.
this
,
NavDrawerActivity
.
class
);
Intent
intent
=
new
Intent
(
LoginActivity
.
this
,
NavDrawerActivity
.
class
);
startActivity
(
intent
);
startActivity
(
intent
);
}
}
...
...
app/src/main/java/com/testapp/entities/Token.java
View file @
ad5aa333
package
com
.
testapp
.
entities
;
package
com
.
testapp
.
entities
;
public
class
Token
{
public
class
Token
{
String
token
;
int
duration
;
int
id
;
public
Token
(
String
token
,
int
duration
)
{
String
token
;
int
duration
;
public
Token
(
int
id
,
String
token
,
int
duration
)
{
this
.
id
=
id
;
this
.
token
=
token
;
this
.
token
=
token
;
this
.
duration
=
duration
;
this
.
duration
=
duration
;
}
}
public
int
getDuration
()
{
return
duration
;
}
public
void
setDuration
(
int
duration
)
{
this
.
duration
=
duration
;
}
public
String
getToken
()
{
public
String
getToken
()
{
return
token
;
return
token
;
}
}
...
@@ -14,4 +26,12 @@ public class Token {
...
@@ -14,4 +26,12 @@ public class Token {
public
void
setToken
(
String
token
)
{
public
void
setToken
(
String
token
)
{
this
.
token
=
token
;
this
.
token
=
token
;
}
}
public
int
getId
()
{
return
id
;
}
public
void
setId
(
int
id
)
{
this
.
id
=
id
;
}
}
}
\ No newline at end of file
app/src/main/res/layout/content_add_review.xml
View file @
ad5aa333
...
@@ -24,14 +24,14 @@
...
@@ -24,14 +24,14 @@
android:hint=
"Title"
/>
android:hint=
"Title"
/>
<RatingBar
<RatingBar
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:id=
"@+id/rv_rating"
android:id=
"@+id/rv_rating"
android:layout_below=
"@+id/rv_title"
android:layout_below=
"@+id/rv_title"
android:layout_
alignParentLeft
=
"true"
android:layout_
centerHorizontal
=
"true"
android:layout_alignParentStart=
"true"
android:numStars=
"5"
android:numStars=
"5"
android:stepSize=
".5"
/>
android:stepSize=
".5"
android:layout_width=
"wrap_content"
/>
<EditText
<EditText
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
...
...
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