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
ca043d91
Commit
ca043d91
authored
Nov 24, 2016
by
lumisce
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add AddDishReview
parent
49041c35
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
197 additions
and
0 deletions
+197
-0
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+4
-0
AddDishReviewActivity.java
app/src/main/java/com/testapp/AddDishReviewActivity.java
+73
-0
CanteeneoApiInterface.java
app/src/main/java/com/testapp/CanteeneoApiInterface.java
+5
-0
DishViewActivity.java
app/src/main/java/com/testapp/DishViewActivity.java
+21
-0
DishReview.java
app/src/main/java/com/testapp/entities/DishReview.java
+3
-0
ic_done.xml
app/src/main/res/drawable/ic_done.xml
+9
-0
activity_add_review.xml
app/src/main/res/layout/activity_add_review.xml
+34
-0
content_add_review.xml
app/src/main/res/layout/content_add_review.xml
+47
-0
strings.xml
app/src/main/res/values/strings.xml
+1
-0
No files found.
app/src/main/AndroidManifest.xml
View file @
ca043d91
...
...
@@ -40,6 +40,10 @@
<activity
android:name=
".StallViewActivity"
android:label=
"@string/title_activity_stall_view"
android:theme=
"@style/AppTheme"
/>
<activity
android:name=
".AddDishReviewActivity"
android:label=
"@string/title_activity_add_dish_review"
android:theme=
"@style/AppTheme"
></activity>
</application>
...
...
app/src/main/java/com/testapp/AddDishReviewActivity.java
0 → 100644
View file @
ca043d91
package
com
.
testapp
;
import
android.os.Bundle
;
import
android.support.design.widget.FloatingActionButton
;
import
android.support.design.widget.Snackbar
;
import
android.support.v7.app.AppCompatActivity
;
import
android.support.v7.widget.Toolbar
;
import
android.view.View
;
import
android.widget.EditText
;
import
android.widget.RatingBar
;
import
android.widget.Toast
;
import
com.testapp.entities.DishReview
;
import
okhttp3.ResponseBody
;
import
retrofit2.Call
;
import
retrofit2.Callback
;
import
retrofit2.Response
;
public
class
AddDishReviewActivity
extends
AppCompatActivity
{
private
EditText
title
;
private
EditText
body
;
private
RatingBar
rating
;
private
int
id
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_add_review
);
Toolbar
toolbar
=
(
Toolbar
)
findViewById
(
R
.
id
.
toolbar
);
setSupportActionBar
(
toolbar
);
setTitle
(
"Add Dish Review"
);
title
=
(
EditText
)
findViewById
(
R
.
id
.
rv_title
);
body
=
(
EditText
)
findViewById
(
R
.
id
.
rv_body
);
rating
=
(
RatingBar
)
findViewById
(
R
.
id
.
rv_rating
);
id
=
getIntent
().
getIntExtra
(
"ID"
,
0
);
FloatingActionButton
fab
=
(
FloatingActionButton
)
findViewById
(
R
.
id
.
fab
);
fab
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
DishReview
rv
=
new
DishReview
();
rv
.
setTitle
(
title
.
getText
().
toString
());
rv
.
setBody
(
body
.
getText
().
toString
());
rv
.
setRating
((
int
)
rating
.
getRating
());
//todo add user_id
sendReview
(
id
,
rv
);
}
});
}
private
void
sendReview
(
int
id
,
DishReview
rv
)
{
Call
<
ResponseBody
>
call
=
AppUtils
.
service
.
newDishReview
(
id
,
rv
);
call
.
enqueue
(
new
Callback
<
ResponseBody
>()
{
@Override
public
void
onResponse
(
Call
<
ResponseBody
>
call
,
Response
<
ResponseBody
>
response
)
{
finish
();
}
@Override
public
void
onFailure
(
Call
<
ResponseBody
>
call
,
Throwable
t
)
{
Toast
.
makeText
(
getApplicationContext
(),
"Posting review failed"
,
Toast
.
LENGTH_SHORT
);
}
});
}
}
app/src/main/java/com/testapp/CanteeneoApiInterface.java
View file @
ca043d91
...
...
@@ -13,7 +13,9 @@ import java.util.List;
import
okhttp3.ResponseBody
;
import
retrofit2.Call
;
import
retrofit2.http.Body
;
import
retrofit2.http.GET
;
import
retrofit2.http.POST
;
import
retrofit2.http.Path
;
import
retrofit2.http.Query
;
...
...
@@ -47,4 +49,7 @@ public interface CanteeneoApiInterface {
@GET
(
"api/stalls/{id}/dishes"
)
Call
<
List
<
Dish
>>
getDishesByStall
(
@Path
(
"id"
)
int
id
);
@POST
(
"api/dishes/{id}/reviews"
)
Call
<
ResponseBody
>
newDishReview
(
@Path
(
"id"
)
int
id
,
DishReview
review
);
}
app/src/main/java/com/testapp/DishViewActivity.java
View file @
ca043d91
...
...
@@ -6,9 +6,11 @@ import android.support.v7.app.AppCompatActivity;
import
android.support.v7.widget.Toolbar
;
import
android.view.MenuItem
;
import
android.view.View
;
import
android.widget.Button
;
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.DishReview
;
...
...
@@ -59,6 +61,17 @@ public class DishViewActivity extends AppCompatActivity {
});
}
Button
addReviewBtn
=
(
Button
)
findViewById
(
R
.
id
.
add_review_button
);
addReviewBtn
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
Intent
i
=
new
Intent
(
DishViewActivity
.
this
,
AddDishReviewActivity
.
class
);
i
.
putExtra
(
"ID"
,
i
.
getIntExtra
(
"ID"
,
0
));
startActivityForResult
(
i
,
0
);
}
});
ListView
lv
=
(
ListView
)
findViewById
(
R
.
id
.
dish_reviews
);
adapter
=
new
DishReviewAdapter
(
this
,
reviews
);
lv
.
setAdapter
(
adapter
);
...
...
@@ -101,4 +114,12 @@ public class DishViewActivity extends AppCompatActivity {
});
}
@Override
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
if
(
requestCode
==
0
)
{
if
(
resultCode
==
RESULT_OK
)
{
Toast
.
makeText
(
this
,
"Review Added"
,
Toast
.
LENGTH_SHORT
);
}
}
}
}
app/src/main/java/com/testapp/entities/DishReview.java
View file @
ca043d91
...
...
@@ -9,6 +9,9 @@ public class DishReview {
int
user_id
;
int
dish_id
;
public
DishReview
()
{
}
public
DishReview
(
int
id
,
String
title
,
String
body
,
int
rating
,
int
user_id
,
int
dish_id
)
{
this
.
id
=
id
;
this
.
title
=
title
;
...
...
app/src/main/res/drawable/ic_done.xml
0 → 100644
View file @
ca043d91
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:width=
"24dp"
android:height=
"24dp"
android:viewportWidth=
"24.0"
android:viewportHeight=
"24.0"
>
<path
android:fillColor=
"#FFFFFF"
android:pathData=
"M9,16.2L4.8,12l-1.4,1.4L9,19 21,7l-1.4,-1.4L9,16.2z"
/>
</vector>
app/src/main/res/layout/activity_add_review.xml
0 → 100644
View file @
ca043d91
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:fitsSystemWindows=
"true"
tools:context=
"com.testapp.AddDishReviewActivity"
>
<android.support.design.widget.AppBarLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:theme=
"@style/AppTheme.AppBarOverlay"
>
<android.support.v7.widget.Toolbar
android:id=
"@+id/toolbar"
android:layout_width=
"match_parent"
android:layout_height=
"?attr/actionBarSize"
android:background=
"?attr/colorPrimary"
app:popupTheme=
"@style/AppTheme.PopupOverlay"
/>
</android.support.design.widget.AppBarLayout>
<include
layout=
"@layout/content_add_review"
/>
<android.support.design.widget.FloatingActionButton
android:id=
"@+id/fab"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"bottom|end"
android:layout_margin=
"@dimen/fab_margin"
android:src=
"@drawable/ic_done"
/>
</android.support.design.widget.CoordinatorLayout>
app/src/main/res/layout/content_add_review.xml
0 → 100644
View file @
ca043d91
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:paddingBottom=
"@dimen/activity_vertical_margin"
android:paddingLeft=
"@dimen/activity_horizontal_margin"
android:paddingRight=
"@dimen/activity_horizontal_margin"
android:paddingTop=
"@dimen/activity_vertical_margin"
app:layout_behavior=
"@string/appbar_scrolling_view_behavior"
tools:context=
"com.testapp.AddDishReviewActivity"
tools:showIn=
"@layout/activity_add_review"
>
<EditText
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:id=
"@+id/rv_title"
android:layout_alignParentTop=
"true"
android:layout_alignParentLeft=
"true"
android:layout_alignParentStart=
"true"
android:layout_alignParentRight=
"true"
android:layout_alignParentEnd=
"true"
android:hint=
"Title"
/>
<RatingBar
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:id=
"@+id/rv_rating"
android:layout_below=
"@+id/rv_title"
android:layout_alignParentLeft=
"true"
android:layout_alignParentStart=
"true"
android:numStars=
"10"
android:stepSize=
"1"
/>
<EditText
android:layout_width=
"match_parent"
android:layout_height=
"400dp"
android:inputType=
"textMultiLine"
android:ems=
"10"
android:id=
"@+id/rv_body"
android:layout_below=
"@+id/rv_rating"
android:layout_alignParentLeft=
"true"
android:layout_alignParentStart=
"true"
android:layout_alignParentRight=
"true"
android:layout_alignParentEnd=
"true"
/>
</RelativeLayout>
app/src/main/res/values/strings.xml
View file @
ca043d91
...
...
@@ -43,4 +43,5 @@
</string-array>
<string
name=
"title_activity_blahblah"
>
blahblah
</string>
<string
name=
"title_activity_stall_view"
>
StallViewActivity
</string>
<string
name=
"title_activity_add_dish_review"
>
AddDishReviewActivity
</string>
</resources>
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