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
70855ed8
Commit
70855ed8
authored
Dec 04, 2016
by
Willard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hide "Add Review" button and disable favorite button when on guest mode
parent
6d8f41a2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
11 deletions
+10
-11
DishViewActivity.java
app/src/main/java/com/testapp/DishViewActivity.java
+5
-4
StallViewActivity.java
app/src/main/java/com/testapp/StallViewActivity.java
+5
-7
No files found.
app/src/main/java/com/testapp/DishViewActivity.java
View file @
70855ed8
...
...
@@ -68,6 +68,7 @@ public class DishViewActivity extends AppCompatActivity {
}
favoriteCheckbox
=
(
CheckBox
)
findViewById
(
R
.
id
.
favorite_checkbox
);
favoriteCheckbox
.
setEnabled
(
AppUtils
.
isLoggedIn
());
favoriteCheckbox
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
...
...
@@ -75,7 +76,7 @@ public class DishViewActivity extends AppCompatActivity {
favoriteCall
.
enqueue
(
new
Callback
<
FavoriteInfo
>()
{
@Override
public
void
onResponse
(
Call
<
FavoriteInfo
>
call
,
Response
<
FavoriteInfo
>
response
)
{
favoriteCheckbox
.
setText
(
"Favorite ("
+
response
.
body
().
getCount
()
+
")
"
);
favoriteCheckbox
.
setText
(
response
.
body
().
getCount
()
+
" users favorited this
"
);
}
@Override
...
...
@@ -91,12 +92,12 @@ public class DishViewActivity extends AppCompatActivity {
@Override
public
void
onResponse
(
Call
<
FavoriteInfo
>
call
,
Response
<
FavoriteInfo
>
response
)
{
favoriteCheckbox
.
setChecked
(
response
.
body
().
isFavorited
());
favoriteCheckbox
.
setText
(
"Favorite ("
+
response
.
body
().
getCount
()
+
")
"
);
favoriteCheckbox
.
setText
(
response
.
body
().
getCount
()
+
" users favorited this
"
);
}
@Override
public
void
onFailure
(
Call
<
FavoriteInfo
>
call
,
Throwable
t
)
{
favoriteCheckbox
.
setText
(
"
Favorite (-1)
"
);
favoriteCheckbox
.
setText
(
"
-
"
);
}
});
...
...
@@ -151,7 +152,7 @@ public class DishViewActivity extends AppCompatActivity {
newReviews
.
remove
(
ownedReview
);
reviews
.
add
(
ownedReview
);
}
findViewById
(
R
.
id
.
add_review_button
).
setVisibility
(
ownedReview
!=
null
?
View
.
INVISIBLE
:
View
.
VISIBLE
);
findViewById
(
R
.
id
.
add_review_button
).
setVisibility
(
ownedReview
!=
null
||
!
AppUtils
.
isLoggedIn
()
?
View
.
INVISIBLE
:
View
.
VISIBLE
);
reviews
.
addAll
(
newReviews
);
adapter
.
notifyDataSetChanged
();
...
...
app/src/main/java/com/testapp/StallViewActivity.java
View file @
70855ed8
...
...
@@ -9,15 +9,13 @@ import android.view.View;
import
android.widget.AdapterView
;
import
android.widget.Button
;
import
android.widget.CheckBox
;
import
android.widget.ImageView
;
import
android.widget.ListView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
com.squareup.picasso.Picasso
;
import
com.testapp.entities.Dish
;
import
com.testapp.entities.Stall
;
import
com.testapp.entities.FavoriteInfo
;
import
com.testapp.entities.Stall
;
import
com.testapp.entities.StallReview
;
import
java.util.ArrayList
;
...
...
@@ -85,7 +83,7 @@ public class StallViewActivity extends AppCompatActivity {
favoriteCall
.
enqueue
(
new
Callback
<
FavoriteInfo
>()
{
@Override
public
void
onResponse
(
Call
<
FavoriteInfo
>
call
,
Response
<
FavoriteInfo
>
response
)
{
favoriteCheckbox
.
setText
(
"Favorite ("
+
response
.
body
().
getCount
()
+
")
"
);
favoriteCheckbox
.
setText
(
response
.
body
().
getCount
()
+
" users favorited this
"
);
}
@Override
...
...
@@ -101,12 +99,12 @@ public class StallViewActivity extends AppCompatActivity {
@Override
public
void
onResponse
(
Call
<
FavoriteInfo
>
call
,
Response
<
FavoriteInfo
>
response
)
{
favoriteCheckbox
.
setChecked
(
response
.
body
().
isFavorited
());
favoriteCheckbox
.
setText
(
"Favorite ("
+
response
.
body
().
getCount
()
+
")
"
);
favoriteCheckbox
.
setText
(
response
.
body
().
getCount
()
+
" users favorited this
"
);
}
@Override
public
void
onFailure
(
Call
<
FavoriteInfo
>
call
,
Throwable
t
)
{
favoriteCheckbox
.
setText
(
"
Favorite (-1)
"
);
favoriteCheckbox
.
setText
(
"
-
"
);
}
});
...
...
@@ -188,7 +186,7 @@ public class StallViewActivity extends AppCompatActivity {
newReviews
.
remove
(
ownedReview
);
reviews
.
add
(
ownedReview
);
}
findViewById
(
R
.
id
.
add_review_button
).
setVisibility
(
ownedReview
!=
null
?
View
.
INVISIBLE
:
View
.
VISIBLE
);
findViewById
(
R
.
id
.
add_review_button
).
setVisibility
(
ownedReview
!=
null
||
!
AppUtils
.
isLoggedIn
()
?
View
.
INVISIBLE
:
View
.
VISIBLE
);
reviews
.
addAll
(
newReviews
);
srAdapter
.
notifyDataSetChanged
();
...
...
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