├── .gitignore
├── .idea
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── Group5 Documentation.pdf
├── README.md
├── androideatit-d8c6e-export.json
├── app
├── .gitignore
├── build.gradle
├── google-services.json
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── androideatit
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── assets
│ │ ├── databases
│ │ │ └── EatitDB.db
│ │ └── fonts
│ │ │ └── Nabila.ttf
│ ├── java
│ │ └── com
│ │ │ └── androideatit
│ │ │ ├── Cart.java
│ │ │ ├── Common
│ │ │ └── Common.java
│ │ │ ├── Database
│ │ │ └── Database.java
│ │ │ ├── FoodDetail.java
│ │ │ ├── FoodList.java
│ │ │ ├── Home.java
│ │ │ ├── Interface
│ │ │ └── ItemClickListener.java
│ │ │ ├── MainActivity.java
│ │ │ ├── Model
│ │ │ ├── Category.java
│ │ │ ├── Food.java
│ │ │ ├── Order.java
│ │ │ ├── Receipt.java
│ │ │ ├── Request.java
│ │ │ └── User.java
│ │ │ ├── OrderStatus.java
│ │ │ ├── SignIn.java
│ │ │ ├── SignUp.java
│ │ │ └── ViewHolder
│ │ │ ├── CartAdapter.java
│ │ │ ├── FoodViewHolder.java
│ │ │ ├── MenuViewHolder.java
│ │ │ └── OrderViewHolder.java
│ └── res
│ │ ├── drawable-hdpi
│ │ ├── background.png
│ │ └── logo.png
│ │ ├── drawable-mdpi
│ │ ├── background.png
│ │ └── logo.png
│ │ ├── drawable-v21
│ │ ├── ic_menu_camera.xml
│ │ ├── ic_menu_gallery.xml
│ │ ├── ic_menu_manage.xml
│ │ ├── ic_menu_send.xml
│ │ ├── ic_menu_share.xml
│ │ └── ic_menu_slideshow.xml
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable-xhdpi
│ │ ├── background.png
│ │ └── logo.png
│ │ ├── drawable-xxhdpi
│ │ ├── background.png
│ │ └── logo.png
│ │ ├── drawable-xxxhdpi
│ │ ├── background.png
│ │ └── logo.png
│ │ ├── drawable
│ │ ├── ic_access_time_black_24dp.xml
│ │ ├── ic_attach_money_black_24dp.xml
│ │ ├── ic_exit_to_app_black_24dp.xml
│ │ ├── ic_launcher_background.xml
│ │ ├── ic_restaurant_black_24dp.xml
│ │ ├── ic_shopping_cart_black_24dp.xml
│ │ └── side_nav_bar.xml
│ │ ├── layout
│ │ ├── activity_cart.xml
│ │ ├── activity_food_detail.xml
│ │ ├── activity_food_list.xml
│ │ ├── activity_home.xml
│ │ ├── activity_main.xml
│ │ ├── activity_order_status.xml
│ │ ├── activity_sign_in.xml
│ │ ├── activity_sign_up.xml
│ │ ├── app_bar_home.xml
│ │ ├── cart_layout.xml
│ │ ├── content_home.xml
│ │ ├── food_item.xml
│ │ ├── menu_item.xml
│ │ ├── nav_header_home.xml
│ │ └── order_layout.xml
│ │ ├── menu
│ │ ├── activity_home_drawer.xml
│ │ └── home.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── test.xml
│ │ ├── values-v21
│ │ └── styles.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── drawables.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── androideatit
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | 1.8
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Group5 Documentation.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lukchen/Android-Food-Order-Application-for-6150/1325c23c461967dcdfbbc086ec7e15803e55dd8b/Group5 Documentation.pdf
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AndroidEatIt
2 | tested on API 26, nexus4
3 |
4 | ● Used Firebase to store restaurant data, Applied MVC pattern design style for client
5 | side & server side.
6 |
7 | ● Provided sign in/sign up function, menu and food list loading, orders management
8 | process, and notifications for users
9 |
10 | ● Applied multi-threading manipulation, synchronization, JUnit Runner test as back end
11 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 |
4 | android {
5 | compileSdkVersion 26
6 | defaultConfig {
7 | applicationId "com.androideatit"
8 | minSdkVersion 21
9 | targetSdkVersion 26
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | multiDexEnabled true
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 |
23 | dependencies {
24 | implementation 'com.android.support:design:26.1.0'
25 | compile fileTree(dir: 'libs', include: ['*.jar'])
26 |
27 | compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
28 | compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
29 | compile 'com.cepheuen.elegant-number-button:lib:1.0.2'
30 | compile 'com.android.support:design:26.+'
31 | compile 'com.android.support:appcompat-v7:26.+'
32 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
33 | testCompile 'junit:junit:4.12'
34 | androidTestCompile 'com.android.support.test:runner:1.0.1'
35 | androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.1'
36 | compile 'com.google.firebase:firebase-core:10.2.1'
37 | compile 'com.google.firebase:firebase-database:10.2.1'
38 | compile 'com.rengwuxian.materialedittext:library:2.1.4'
39 | compile 'com.google.firebase:firebase-messaging:10.2.1'
40 |
41 | compile 'com.android.support:cardview-v7:26.+'
42 | compile 'com.android.support:recyclerview-v7:26.+'
43 | compile 'com.squareup.picasso:picasso:2.5.2'
44 | compile 'com.firebaseui:firebase-ui-database:1.2.0'
45 | compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
46 |
47 | }
48 | apply plugin: 'com.google.gms.google-services'
49 | repositories {
50 | mavenCentral()
51 | }
52 |
53 | apply plugin: 'kotlin-android-extensions'
--------------------------------------------------------------------------------
/app/google-services.json:
--------------------------------------------------------------------------------
1 | {
2 | "project_info": {
3 | "project_number": "74676403751",
4 | "firebase_url": "https://androideatit-d8c6e.firebaseio.com",
5 | "project_id": "androideatit-d8c6e",
6 | "storage_bucket": "androideatit-d8c6e.appspot.com"
7 | },
8 | "client": [
9 | {
10 | "client_info": {
11 | "mobilesdk_app_id": "1:74676403751:android:f7d42c03941a2754",
12 | "android_client_info": {
13 | "package_name": "com.androideatit"
14 | }
15 | },
16 | "oauth_client": [
17 | {
18 | "client_id": "74676403751-b1hdrj8mdronha5lvbefc5v395pbdk58.apps.googleusercontent.com",
19 | "client_type": 1,
20 | "android_info": {
21 | "package_name": "com.androideatit",
22 | "certificate_hash": "bc81b694d4be31bfb15cb15bd07de1ef413ea71b"
23 | }
24 | },
25 | {
26 | "client_id": "74676403751-d45v5ifbem854l45h5s2ahhathsg3cjf.apps.googleusercontent.com",
27 | "client_type": 3
28 | }
29 | ],
30 | "api_key": [
31 | {
32 | "current_key": "AIzaSyAddp_F7OVbo0og9tdj_irTmbBFkC9lPlQ"
33 | }
34 | ],
35 | "services": {
36 | "analytics_service": {
37 | "status": 1
38 | },
39 | "appinvite_service": {
40 | "status": 2,
41 | "other_platform_oauth_client": [
42 | {
43 | "client_id": "74676403751-d45v5ifbem854l45h5s2ahhathsg3cjf.apps.googleusercontent.com",
44 | "client_type": 3
45 | }
46 | ]
47 | },
48 | "ads_service": {
49 | "status": 2
50 | }
51 | }
52 | }
53 | ],
54 | "configuration_version": "1"
55 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/androideatit/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.androideatit;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.androideatit", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/assets/databases/EatitDB.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lukchen/Android-Food-Order-Application-for-6150/1325c23c461967dcdfbbc086ec7e15803e55dd8b/app/src/main/assets/databases/EatitDB.db
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/Nabila.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lukchen/Android-Food-Order-Application-for-6150/1325c23c461967dcdfbbc086ec7e15803e55dd8b/app/src/main/assets/fonts/Nabila.ttf
--------------------------------------------------------------------------------
/app/src/main/java/com/androideatit/Cart.java:
--------------------------------------------------------------------------------
1 | package com.androideatit;
2 |
3 | import android.app.Notification;
4 | import android.app.NotificationManager;
5 | import android.app.PendingIntent;
6 | import android.content.Context;
7 | import android.content.DialogInterface;
8 | import android.content.Intent;
9 | import android.os.Handler;
10 | import android.os.Looper;
11 | import android.os.Message;
12 | import android.provider.ContactsContract;
13 | import android.support.v4.app.NotificationCompat;
14 | import android.support.v7.app.AlertDialog;
15 | import android.support.v7.app.AppCompatActivity;
16 | import android.os.Bundle;
17 | import android.support.v7.widget.LinearLayoutManager;
18 | import android.support.v7.widget.RecyclerView;
19 | import android.util.Log;
20 | import android.view.MenuItem;
21 | import android.view.View;
22 | import android.widget.Button;
23 | import android.widget.EditText;
24 | import android.widget.LinearLayout;
25 | import android.widget.TextView;
26 | import android.widget.Toast;
27 |
28 | import com.androideatit.Common.Common;
29 | import com.androideatit.Database.Database;
30 | import com.androideatit.Model.Food;
31 | import com.androideatit.Model.Order;
32 | import com.androideatit.Model.Request;
33 | import com.androideatit.Model.Receipt;
34 | import com.androideatit.ViewHolder.CartAdapter;
35 | import com.google.firebase.database.DataSnapshot;
36 | import com.google.firebase.database.DatabaseError;
37 | import com.google.firebase.database.DatabaseReference;
38 | import com.google.firebase.database.FirebaseDatabase;
39 | import com.google.firebase.database.ValueEventListener;
40 |
41 | import java.text.NumberFormat;
42 | import java.util.ArrayList;
43 | import java.util.List;
44 | import java.util.Locale;
45 | import java.util.concurrent.Executors;
46 | import java.util.concurrent.ScheduledExecutorService;
47 | import java.util.concurrent.TimeUnit;
48 |
49 | import static android.content.ContentValues.TAG;
50 | import static com.androideatit.Cart.inventory;
51 | import static com.androideatit.Cart.inventoryList;
52 | import static com.androideatit.Cart.requestList;
53 | import static com.androideatit.Cart.requestId;
54 | import static com.androideatit.Cart.total;
55 |
56 | //this thread updates the inventoryList from firebase
57 | class IventoryListThread implements Runnable
58 | {
59 | DatabaseReference foods = FirebaseDatabase.getInstance().getReference("Foods");
60 |
61 | public void run()
62 | {
63 | foods.addValueEventListener(new ValueEventListener() {
64 | @Override
65 | public void onDataChange(DataSnapshot dataSnapshot) {
66 | inventoryList.clear();
67 | for(DataSnapshot singleSnapshot : dataSnapshot.getChildren()){
68 | inventory = singleSnapshot.getValue(Food.class);
69 | inventoryList.add(inventory);
70 | }
71 | System.out.println(inventoryList.size());
72 | }
73 |
74 | @Override
75 | public void onCancelled(DatabaseError databaseError) {
76 |
77 | }
78 | });
79 |
80 | }
81 | }
82 |
83 |
84 | public class Cart extends AppCompatActivity {
85 |
86 | RecyclerView recyclerView;
87 | RecyclerView.LayoutManager layoutManager;
88 |
89 | FirebaseDatabase database;
90 | DatabaseReference requests;
91 |
92 | TextView txtTotalPrice;
93 | Button btnPlace;
94 | float totalPrice;
95 |
96 | List cart = new ArrayList<>();
97 | CartAdapter adapter;
98 |
99 | //name the threads
100 | Thread inventorylistthread = new Thread(new IventoryListThread());
101 | Thread kitchenthread = new Thread(new KitchenThread());
102 |
103 | //name the variables in static, so they can be accessed and updated by the inventorylistthread
104 | static List> orderList = new ArrayList<>();
105 | static List inventoryList = new ArrayList<>();
106 | static Food inventory;
107 | static List requestId = new ArrayList<>();
108 | //The orderList is for inventoryList, the requestList is for the KitchenThread
109 | static List requestList = new ArrayList<>();
110 | static float total;
111 |
112 | //partial request flag
113 | private boolean partial = false;
114 |
115 | //unavailable food information
116 | static String unavailablefoodnames="";
117 | static float unavailablefoodprice=0;
118 |
119 | //The executor can makes inventorylistthread running in interval, which is 1 hour
120 | ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
121 |
122 | @Override
123 | protected void onCreate(Bundle savedInstanceState) {
124 | super.onCreate(savedInstanceState);
125 | setContentView(R.layout.activity_cart);
126 |
127 | //thread running in 1 hour interval
128 | executor.scheduleAtFixedRate(inventorylistthread, 0, 60, TimeUnit.MINUTES);
129 |
130 | //Firebase
131 | database = FirebaseDatabase.getInstance();
132 | requests = database.getReference("Requests");
133 |
134 | //Init
135 | recyclerView = findViewById(R.id.listCart);
136 | recyclerView.setHasFixedSize(true);
137 | layoutManager = new LinearLayoutManager(this);
138 | recyclerView.setLayoutManager(layoutManager);
139 |
140 | txtTotalPrice = findViewById(R.id.total);
141 | btnPlace = findViewById(R.id.btnPlaceOrder);
142 |
143 | //When the "Place Order" button clicked
144 | btnPlace.setOnClickListener(new View.OnClickListener() {
145 | @Override
146 | public void onClick(View v) {
147 | //update invetoryList immediately first
148 | executor.scheduleAtFixedRate(inventorylistthread, 0, 60, TimeUnit.MINUTES);
149 | if(!checkavailability(cart)) {
150 |
151 | //Create new Request
152 | showAlertDialog();
153 |
154 | }else {
155 |
156 | //Show user the "Partial order or cancel order options" dialog,
157 | System.out.println("Food Unavailble");
158 | AlertDialog.Builder alertPartialDialog = new AlertDialog.Builder(Cart.this);
159 | alertPartialDialog.setTitle(unavailablefoodnames + " is unavailable");
160 | unavailablefoodnames="";
161 | alertPartialDialog.setMessage("Do you accept partial order ?");
162 |
163 | alertPartialDialog.setPositiveButton("YES", new DialogInterface.OnClickListener(){
164 |
165 | @Override
166 | public void onClick(DialogInterface dialog, int which) {
167 | partial = true;
168 | showAlertDialog();
169 | }
170 | });
171 |
172 | alertPartialDialog.show();
173 |
174 | //If user choose Partial order, then do showAlertDialog() again, and set the partial flag to true in order to set this request partially
175 | /*showAlertDialog();
176 | partial = true;*/
177 |
178 | }
179 | }
180 | });
181 |
182 | loadListFood();
183 |
184 | }
185 |
186 | //Find out whether the foods in order contains unavailable food
187 | private boolean checkavailability(List cart){
188 | boolean partial = false;
189 | if(cart.size()==0){
190 | //Cart is empty, do nothing
191 | partial = true;
192 | }
193 | for(Order order : cart){
194 | for(Food food: inventoryList){
195 | /*System.out.println("SH-----------IT"+food.getFoodId());
196 | System.out.println("FU-----------CK"+order.getProductId());
197 | System.out.println("DA-----------MN"+food.getAvailabilityFlag());*/
198 | if(food.getFoodId().equals(order.getProductId())){
199 | if(food.getAvailabilityFlag().equals("0")){
200 | //if the availabilityFlag of this food is "0"
201 | partial = true;
202 | unavailablefoodprice += Integer.parseInt(food.getPrice());
203 | unavailablefoodprice = (float) (unavailablefoodprice*1.36);
204 | unavailablefoodnames += food.getName();
205 | }
206 | }
207 | }
208 |
209 |
210 | }
211 | return partial;
212 | }
213 |
214 | private void showAlertDialog() {
215 | AlertDialog.Builder alertDialog = new AlertDialog.Builder(Cart.this);
216 | alertDialog.setTitle("One more step!");
217 | alertDialog.setMessage("Enter your address");
218 | System.out.println("email address ");
219 | final EditText edtAddress = new EditText(Cart.this);
220 | LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
221 | LinearLayout.LayoutParams.MATCH_PARENT,
222 | LinearLayout.LayoutParams.MATCH_PARENT
223 | );
224 |
225 | edtAddress.setLayoutParams(lp);
226 | alertDialog.setView(edtAddress);
227 | alertDialog.setIcon(R.drawable.ic_shopping_cart_black_24dp);
228 |
229 | alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() {
230 | @Override
231 | public void onClick(DialogInterface dialog, int which) {
232 | Request request = new Request(
233 | Common.currentUser.getPhone(),
234 | Common.currentUser.getName(),
235 | edtAddress.getText().toString(),
236 | txtTotalPrice.getText().toString(),
237 | cart
238 | );
239 |
240 | if(partial) {
241 | request.setPartial(true);
242 | //add the request to top of the requestList if it's partial request
243 | requestList.add(0,request);
244 |
245 | //default partial is false, set it back to false to check next request
246 | partial = false;
247 |
248 | //cut the price of unavailable food
249 | //keep track of totalprice using global variable
250 | //txtTotalPrice is in currency format unable to parse
251 | Locale locale = new Locale("en","US");
252 | NumberFormat fmt = NumberFormat.getCurrencyInstance(locale);
253 | request.setTotal(fmt.format(totalPrice - unavailablefoodprice));
254 | unavailablefoodprice = 0;
255 |
256 |
257 |
258 | }else {
259 | requestList.add(request);
260 | }
261 |
262 | //Submit to Firebase
263 | //We will using System.Current
264 | requestId.add(String.valueOf(System.currentTimeMillis()));
265 | requests.child(requestId.get(requestId.size()-1)).setValue(request);
266 |
267 | //run the kitchenthread
268 | kitchenthread.start();
269 |
270 | //Delete the cart
271 | new Database(getBaseContext()).cleanCart();
272 |
273 | Toast.makeText(Cart.this, "Thank you, Order placed", Toast.LENGTH_SHORT).show();
274 | finish();
275 |
276 | // Code to show notification
277 | Intent intent = new Intent();
278 | PendingIntent pendingIntent = PendingIntent.getActivity(Cart.this,0,intent,0);
279 | Notification.Builder notificationBuilder = new Notification.Builder(Cart.this)
280 | .setTicker("Order Placed").setContentTitle("Order Placed")
281 | .setContentText("Your order is processing now").setSmallIcon(R.drawable.logo)
282 | .setContentIntent(pendingIntent);
283 | Notification notification = notificationBuilder.build();
284 | notification.flags = Notification.FLAG_AUTO_CANCEL;
285 | NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
286 | assert nm != null;
287 | nm.notify(0,notification);
288 | }
289 | });
290 |
291 |
292 | /*alertDialog.setPositiveButton("NO", new DialogInterface.OnClickListener() {
293 | @Override
294 | public void onClick(DialogInterface dialog, int which) {
295 | dialog.dismiss();
296 | }
297 | });*/
298 |
299 | alertDialog.show();
300 | // This code is to show notifications in android status bar when user places order
301 | // notification is selected
302 |
303 |
304 |
305 | }
306 |
307 | //this thread cooks requests
308 | class KitchenThread implements Runnable{
309 |
310 | @Override
311 | public void run() {
312 | while (true) {
313 | while (requestList.size() > 0) {
314 | DatabaseReference requests = FirebaseDatabase.getInstance().getReference("Requests");
315 | requests.child(requestId.get(0)).child("status").setValue("1");
316 | System.out.println("The chef is working on requests!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
317 |
318 | Intent intent = new Intent();
319 | PendingIntent pendingIntent = PendingIntent.getActivity(Cart.this,0,intent,0);
320 | Notification.Builder notificationBuilder = new Notification.Builder(Cart.this)
321 | .setTicker("Order Accepted").setContentTitle("Order Accepted")
322 | .setContentText("The Chef is working on your order").setSmallIcon(R.drawable.logo)
323 | .setContentIntent(pendingIntent);
324 | Notification notification = notificationBuilder.build();
325 | notification.flags = Notification.FLAG_AUTO_CANCEL;
326 | NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
327 | assert nm != null;
328 | nm.notify(0,notification);
329 |
330 | try {
331 | //cooking time: 180 sec
332 | Thread.sleep(10000);
333 | } catch (InterruptedException e) {
334 | e.printStackTrace();
335 | }
336 |
337 | System.out.println("Order Prepared!");
338 |
339 | Intent intent1 = new Intent();
340 | PendingIntent pendingIntent1 = PendingIntent.getActivity(Cart.this,0,intent1,0);
341 | Notification.Builder notificationBuilder1 = new Notification.Builder(Cart.this)
342 | .setTicker("Order Prepared").setContentTitle("Order Prepared")
343 | .setContentText("Your order is prepared").setSmallIcon(R.drawable.logo)
344 | .setContentIntent(pendingIntent1);
345 | Notification notification1 = notificationBuilder1.build();
346 | notification1.flags = Notification.FLAG_AUTO_CANCEL;
347 | NotificationManager nm1 = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
348 | assert nm1 != null;
349 | nm1.notify(0,notification1);
350 |
351 | requests.child(requestId.get(0)).child("status").setValue("2");
352 | try {
353 | //packaging time: 180 sec
354 | Thread.sleep(10000);
355 | } catch (InterruptedException e) {
356 | e.printStackTrace();
357 | }
358 | System.out.println("Order Packaged!");
359 |
360 | Intent intent2 = new Intent();
361 | PendingIntent pendingIntent2 = PendingIntent.getActivity(Cart.this,0,intent2,0);
362 | Notification.Builder notificationBuilder2 = new Notification.Builder(Cart.this)
363 | .setTicker("Order Packaged").setContentTitle("Order Packaged")
364 | .setContentText("Your order is packaged and ready to pick up!").setSmallIcon(R.drawable.logo)
365 | .setContentIntent(pendingIntent2);
366 | Notification notification2 = notificationBuilder2.build();
367 | notification2.flags = Notification.FLAG_AUTO_CANCEL;
368 | NotificationManager nm2 = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
369 | assert nm2 != null;
370 | nm2.notify(0,notification2);
371 |
372 | requests.child(requestId.get(0)).child("status").setValue("3");
373 |
374 | //The first request finished, generate receipt, then remove the finished request, working on next request in list
375 | Looper.prepare();
376 | Toast.makeText(Cart.this,GenerateReceipt(requestList.get(0)),Toast.LENGTH_SHORT).show();
377 | requestList.remove(0);
378 | requestId.remove(0);
379 |
380 | Looper.loop();
381 |
382 | }
383 | System.out.println("there are no requests yet, what a terrible day!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
384 | }
385 | }
386 |
387 | public String GenerateReceipt(Request request){
388 | Receipt receipt = new Receipt();
389 | receipt.items = request.getFoods();
390 | receipt.totalcost = request.getTotal();
391 | String message="---------Food Ready! Thank you!---------\n";
392 | for(Order i:receipt.items){
393 | message+=i.getProductName()+" :"+i.getQuanlity()+"\n";
394 | }
395 | message+="Total: "+total;
396 | return message;
397 |
398 |
399 | }
400 | }
401 |
402 |
403 | private void loadListFood() {
404 | cart = new Database(this).getCarts();
405 | orderList.add(cart);
406 | adapter = new CartAdapter(cart,this);
407 | recyclerView.setAdapter(adapter);
408 |
409 | //Calculate total price
410 | total = 0;
411 | for(Order order:cart)
412 | total+=(float) (Integer.parseInt(order.getPrice()))*(Integer.parseInt(order.getQuanlity()));
413 | Locale locale = new Locale("en","US");
414 | NumberFormat fmt = NumberFormat.getCurrencyInstance(locale);
415 |
416 |
417 | // add tax, profit to total, do we need to show the tax and profit on the app??
418 | float tax= (float) (total*0.06);
419 | float profit = (float) (total*0.3);
420 | total+=tax+profit;
421 |
422 | totalPrice =total;
423 |
424 | txtTotalPrice.setText(fmt.format(total));
425 |
426 | }
427 |
428 | //Delete item
429 |
430 |
431 | @Override
432 | public boolean onContextItemSelected(MenuItem item) {
433 | System.out.println("I CAME HERE?");
434 | System.out.println(item.getTitle());
435 | if(item.getTitle().equals(Common.DELETE)){
436 | System.out.println("I CAME HERE YAY");
437 | System.out.println(item.getItemId());
438 | System.err.println(item.getOrder());
439 | deleteFoodItem(item.getOrder());
440 | }
441 | return super.onContextItemSelected(item);
442 | }
443 |
444 | private void deleteFoodItem(int ord) {
445 | cart = new Database(this).getCarts();
446 | String order1 = cart.get(ord).getProductId();
447 | System.out.println("The order is " +order1);
448 | for(Order order:cart){
449 | System.err.println("The order id is " + order.getProductId());
450 | if(order.getProductId().equals(order1)){
451 | System.err.println(order.getProductName());
452 | System.err.println("I CAME HERE FUCK YEAAAAAHHHHHH");
453 | new Database(getBaseContext()).removeFromCart(order1);
454 | }
455 | }
456 | loadListFood();
457 | }
458 |
459 | }
460 |
--------------------------------------------------------------------------------
/app/src/main/java/com/androideatit/Common/Common.java:
--------------------------------------------------------------------------------
1 | package com.androideatit.Common;
2 |
3 | import com.androideatit.Model.User;
4 |
5 | /**
6 | * Created by 123456 on 2017/11/17.
7 | */
8 |
9 | public class Common {
10 | public static User currentUser;
11 | public static final String DELETE = "Delete";
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/java/com/androideatit/Database/Database.java:
--------------------------------------------------------------------------------
1 | package com.androideatit.Database;
2 |
3 | import android.content.Context;
4 | import android.database.Cursor;
5 | import android.database.sqlite.SQLiteDatabase;
6 | import android.database.sqlite.SQLiteQuery;
7 | import android.database.sqlite.SQLiteQueryBuilder;
8 |
9 | import com.androideatit.Model.Order;
10 | import com.readystatesoftware.sqliteasset.SQLiteAssetHelper;
11 |
12 | import java.util.ArrayList;
13 | import java.util.List;
14 |
15 | /**
16 | * Created by 123456 on 2017/11/19.
17 | */
18 |
19 | public class Database extends SQLiteAssetHelper {
20 |
21 | private static final String DB_NAME = "EatitDB.db";
22 | private static final int DB_VER = 1;
23 |
24 | public Database(Context context){
25 | super(context, DB_NAME,null, DB_VER);
26 | }
27 |
28 | public List getCarts(){
29 |
30 | SQLiteDatabase db = getReadableDatabase();
31 | SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
32 |
33 | String[] sqlSelect = {"ProductName", "ProductId", "Quantity", "Price", "Discount"};
34 | String sqlTable = "OrderDetail";
35 |
36 | qb.setTables(sqlTable);
37 | Cursor c = qb.query(db, sqlSelect, null, null, null, null, null);
38 |
39 | final List result = new ArrayList<>();
40 | if(c.moveToFirst()){
41 | do{
42 | result.add(new Order(c.getString(c.getColumnIndex("ProductId")),
43 | c.getString(c.getColumnIndex("ProductName")),
44 | c.getString(c.getColumnIndex("Quantity")),
45 | c.getString(c.getColumnIndex("Price")),
46 | c.getString(c.getColumnIndex("Discount"))
47 | ));
48 | }while (c.moveToNext());
49 | }
50 | return result;
51 | }
52 |
53 | public void addToCart(Order order){
54 | SQLiteDatabase db = getReadableDatabase();
55 | String query = String.format("INSERT INTO OrderDetail(ProductId, ProductName, Quantity, Price, Discount) VALUES('%s','%s','%s','%s','%s');",
56 | order.getProductId(),
57 | order.getProductName(),
58 | order.getQuanlity(),
59 | order.getPrice(),
60 | order.getDiscount());
61 |
62 | db.execSQL(query);
63 | }
64 |
65 | public void removeFromCart(String order){
66 |
67 | SQLiteDatabase db = getReadableDatabase();
68 |
69 | String query = String.format("DELETE FROM OrderDetail WHERE ProductId='"+order+"'");
70 | db.execSQL(query);
71 | }
72 |
73 | public void cleanCart(){
74 | SQLiteDatabase db = getReadableDatabase();
75 | String query = String.format("DELETE FROM OrderDetail");
76 | db.execSQL(query);
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/app/src/main/java/com/androideatit/FoodDetail.java:
--------------------------------------------------------------------------------
1 | package com.androideatit;
2 |
3 | import android.support.design.widget.CollapsingToolbarLayout;
4 | import android.support.design.widget.FloatingActionButton;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.os.Bundle;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.view.View;
9 | import android.widget.ImageView;
10 | import android.widget.TextView;
11 |
12 | import com.androideatit.Database.Database;
13 | import com.androideatit.Model.Food;
14 | import com.androideatit.Model.Order;
15 | import com.androideatit.ViewHolder.FoodViewHolder;
16 | import com.cepheuen.elegantnumberbutton.view.ElegantNumberButton;
17 | import com.firebase.ui.database.FirebaseRecyclerAdapter;
18 | import com.google.firebase.database.DataSnapshot;
19 | import com.google.firebase.database.DatabaseError;
20 | import com.google.firebase.database.DatabaseReference;
21 | import com.google.firebase.database.FirebaseDatabase;
22 | import com.google.firebase.database.ValueEventListener;
23 | import com.squareup.picasso.Picasso;
24 |
25 | public class FoodDetail extends AppCompatActivity {
26 |
27 | TextView food_name, food_price, food_description;
28 | ImageView food_image;
29 | CollapsingToolbarLayout collapsingToolbarLayout;
30 | FloatingActionButton btnCart;
31 | ElegantNumberButton numberButton;
32 | FirebaseDatabase database;
33 | DatabaseReference foods;
34 | Food currentFood;
35 |
36 | String foodId = "";
37 | FirebaseRecyclerAdapter adapter;
38 |
39 | @Override
40 | protected void onCreate(Bundle savedInstanceState) {
41 | super.onCreate(savedInstanceState);
42 | setContentView(R.layout.activity_food_detail);
43 |
44 | //Firebase
45 | database = FirebaseDatabase.getInstance();
46 | foods = database.getReference("Foods");
47 |
48 | //Init View
49 | numberButton = (ElegantNumberButton) findViewById(R.id.number_button);
50 | btnCart = (FloatingActionButton) findViewById(R.id.btnCart);
51 |
52 | btnCart.setOnClickListener(new View.OnClickListener() {
53 | @Override
54 | public void onClick(View v) {
55 |
56 | new Database(getBaseContext()).addToCart(new Order(
57 | foodId,
58 | currentFood.getName(),
59 | numberButton.getNumber(),
60 | currentFood.getPrice(),
61 | currentFood.getDiscount()
62 | ));
63 |
64 |
65 | }
66 | });
67 |
68 | food_description = (TextView) findViewById(R.id.food_description);
69 | food_name = (TextView) findViewById(R.id.food_name);
70 | food_price = (TextView) findViewById(R.id.food_price);
71 | food_image = (ImageView) findViewById(R.id.img_food);
72 |
73 | collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing);
74 | collapsingToolbarLayout.setExpandedTitleTextAppearance(R.style.ExpandedAppbar);
75 | collapsingToolbarLayout.setCollapsedTitleTextAppearance(R.style.CollapsedAppbar);
76 |
77 | //Get food ID from Intent
78 | if(getIntent() != null)
79 | foodId = getIntent().getStringExtra("FoodId");
80 | if(!foodId.isEmpty()){
81 | getDetailFood(foodId);
82 | }
83 |
84 | }
85 |
86 | private void getDetailFood(String foodId) {
87 | foods.child(foodId).addValueEventListener(new ValueEventListener(){
88 | @Override
89 | public void onDataChange(DataSnapshot dataSnapshot){
90 | currentFood = dataSnapshot.getValue(Food.class);
91 |
92 | //Set Image
93 | Picasso.with(getBaseContext()).load(currentFood.getImage()).into(food_image);
94 |
95 | collapsingToolbarLayout.setTitle(currentFood.getName());
96 |
97 | food_price.setText(currentFood.getPrice());
98 |
99 | food_name.setText(currentFood.getName());
100 |
101 | food_description.setText(currentFood.getDescription());
102 |
103 | }
104 |
105 | @Override
106 | public void onCancelled(DatabaseError databaseError){
107 |
108 | }
109 | });
110 |
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/app/src/main/java/com/androideatit/FoodList.java:
--------------------------------------------------------------------------------
1 | package com.androideatit;
2 |
3 | import android.content.Intent;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.support.v7.widget.LinearLayoutManager;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.util.Log;
9 | import android.view.View;
10 | import android.widget.TextView;
11 | import android.widget.Toast;
12 |
13 | import com.androideatit.Interface.ItemClickListener;
14 | import com.androideatit.Model.Category;
15 | import com.androideatit.Model.Food;
16 | import com.androideatit.ViewHolder.FoodViewHolder;
17 | import com.androideatit.ViewHolder.MenuViewHolder;
18 | import com.firebase.ui.database.FirebaseRecyclerAdapter;
19 | import com.google.firebase.database.DatabaseReference;
20 | import com.google.firebase.database.FirebaseDatabase;
21 | import com.squareup.picasso.Picasso;
22 |
23 | public class FoodList extends AppCompatActivity {
24 |
25 | FirebaseDatabase database;
26 | DatabaseReference foodList;
27 | RecyclerView recyclerView;
28 | RecyclerView.LayoutManager layoutManager;
29 |
30 | String categoryId = "";
31 | FirebaseRecyclerAdapter adapter;
32 |
33 | @Override
34 | protected void onCreate(Bundle savedInstanceState) {
35 | super.onCreate(savedInstanceState);
36 | setContentView(R.layout.activity_food_list);
37 | //Firebase
38 | database = FirebaseDatabase.getInstance();
39 | foodList = database.getReference("Foods");
40 |
41 | recyclerView = (RecyclerView) findViewById(R.id.recycler_food);
42 | recyclerView.setHasFixedSize(true);
43 | layoutManager = new LinearLayoutManager(this);
44 | recyclerView.setLayoutManager(layoutManager);
45 |
46 | //Get Intent here
47 | if(getIntent() != null)
48 | categoryId = getIntent().getStringExtra("CategoryId");
49 | if(!categoryId.isEmpty() && categoryId != null){
50 | loadListFood(categoryId);
51 | }
52 |
53 |
54 | }
55 |
56 | private void loadListFood(String categoryID){
57 | adapter = new FirebaseRecyclerAdapter(Food.class,
58 | R.layout.food_item,
59 | FoodViewHolder.class,
60 | foodList.orderByChild("MenuId").equalTo(categoryId)) { //like Select * from Foods where MenuID =
61 | @Override
62 | protected void populateViewHolder(FoodViewHolder viewHolder, Food model, int position) {
63 | viewHolder.food_name.setText(model.getName());
64 | Picasso.with(getBaseContext()).load(model.getImage()).into(viewHolder.food_image);
65 |
66 | final Food local = model;
67 | viewHolder.setItemClickListener(new ItemClickListener() {
68 | @Override
69 | public void onClick(View view, int position, boolean isLongClick) {
70 | //start new activity
71 | Intent foodDetail = new Intent(FoodList.this, FoodDetail.class);
72 | foodDetail.putExtra("FoodId", adapter.getRef(position).getKey());
73 | startActivity(foodDetail);
74 | }
75 | });
76 | }
77 | };
78 | //Set Adapter
79 | Log.d("TAG", ""+adapter.getItemCount());
80 | recyclerView.setAdapter(adapter);
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/app/src/main/java/com/androideatit/Home.java:
--------------------------------------------------------------------------------
1 | package com.androideatit;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.provider.ContactsContract;
6 | import android.support.design.widget.FloatingActionButton;
7 | import android.support.design.widget.Snackbar;
8 | import android.support.v7.widget.LinearLayoutManager;
9 | import android.support.v7.widget.RecyclerView;
10 | import android.view.View;
11 | import android.support.design.widget.NavigationView;
12 | import android.support.v4.view.GravityCompat;
13 | import android.support.v4.widget.DrawerLayout;
14 | import android.support.v7.app.ActionBarDrawerToggle;
15 | import android.support.v7.app.AppCompatActivity;
16 | import android.support.v7.widget.Toolbar;
17 | import android.view.Menu;
18 | import android.view.MenuItem;
19 | import android.widget.TextView;
20 | import android.widget.Toast;
21 |
22 | import com.androideatit.Common.Common;
23 | import com.androideatit.Interface.ItemClickListener;
24 | import com.androideatit.Model.Category;
25 | import com.androideatit.Model.Order;
26 | import com.androideatit.ViewHolder.MenuViewHolder;
27 | import com.firebase.ui.database.FirebaseRecyclerAdapter;
28 | import com.google.firebase.database.DatabaseReference;
29 | import com.google.firebase.database.FirebaseDatabase;
30 | import com.squareup.picasso.Picasso;
31 |
32 | import java.util.zip.CRC32;
33 |
34 | public class Home extends AppCompatActivity
35 | implements NavigationView.OnNavigationItemSelectedListener {
36 |
37 | FirebaseDatabase database;
38 | DatabaseReference category;
39 | TextView txtFullName;
40 | RecyclerView recycler_menu;
41 | RecyclerView.LayoutManager layoutManager;
42 |
43 | FirebaseRecyclerAdapter adapter;
44 |
45 | @Override
46 | protected void onCreate(Bundle savedInstanceState) {
47 | super.onCreate(savedInstanceState);
48 | setContentView(R.layout.activity_home);
49 |
50 |
51 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
52 | toolbar.setTitle("Menu");
53 |
54 | //Init Firebase
55 | database = FirebaseDatabase.getInstance();
56 | category = database.getReference("Category");
57 |
58 |
59 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
60 | fab.setOnClickListener(new View.OnClickListener() {
61 | @Override
62 | public void onClick(View view) {
63 | Intent cartIntent = new Intent(Home.this,Cart.class);
64 | startActivity(cartIntent);
65 |
66 | }
67 | });
68 |
69 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
70 | ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
71 | this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
72 | drawer.addDrawerListener(toggle);
73 | toggle.syncState();
74 |
75 | NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
76 | navigationView.setNavigationItemSelectedListener(this);
77 |
78 | //Set Name for user
79 | View headerView = navigationView.getHeaderView(0);
80 | txtFullName = headerView.findViewById(R.id.txtFullName);
81 | txtFullName.setText(Common.currentUser.getName());
82 |
83 | //Load menu
84 | recycler_menu = findViewById(R.id.recycler_menu);
85 | recycler_menu.setHasFixedSize(true);
86 | layoutManager = new LinearLayoutManager(this);
87 | recycler_menu.setLayoutManager(layoutManager);
88 |
89 | loadMenu();
90 |
91 | }
92 |
93 | private void loadMenu() {
94 |
95 | adapter = new FirebaseRecyclerAdapter(Category.class,R.layout.menu_item,MenuViewHolder.class,category) {
96 | @Override
97 | protected void populateViewHolder(MenuViewHolder viewHolder, Category model, int position) {
98 | viewHolder.txtMenuName.setText(model.getName());
99 | Picasso.with(getBaseContext()).load(model.getImage()).into(viewHolder.imageView);
100 | final Category clickItem = model;
101 | viewHolder.setItemClickListener(new ItemClickListener() {
102 | @Override
103 | public void onClick(View view, int position, boolean isLongClick) {
104 | //Get CategoryId and send to new Activity
105 | Intent foodList = new Intent(Home.this, FoodList.class);
106 | //Because CategoryId is key, so we just get the key of this item
107 | foodList.putExtra("CategoryId", adapter.getRef(position).getKey());
108 | startActivity(foodList);
109 | }
110 | });
111 | }
112 | };
113 | recycler_menu.setAdapter(adapter);
114 | }
115 |
116 | @Override
117 | public void onBackPressed() {
118 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
119 | if (drawer.isDrawerOpen(GravityCompat.START)) {
120 | drawer.closeDrawer(GravityCompat.START);
121 | } else {
122 | super.onBackPressed();
123 | }
124 | }
125 |
126 | @Override
127 | public boolean onCreateOptionsMenu(Menu menu) {
128 | // Inflate the menu; this adds items to the action bar if it is present.
129 | getMenuInflater().inflate(R.menu.home, menu);
130 | return true;
131 | }
132 |
133 | @Override
134 | public boolean onOptionsItemSelected(MenuItem item) {
135 |
136 | return super.onOptionsItemSelected(item);
137 | }
138 |
139 | @SuppressWarnings("StatementWithEmptyBody")
140 | @Override
141 | public boolean onNavigationItemSelected(MenuItem item) {
142 | // Handle navigation view item clicks here.
143 | int id = item.getItemId();
144 |
145 | if (id == R.id.nav_menu) {
146 | return true;
147 | }else if(id == R.id.nav_cart){
148 | Intent cartIntent = new Intent(Home.this, Cart.class);
149 | startActivity(cartIntent);
150 |
151 | }else if(id == R.id.nav_orders){
152 | Intent orderIntent = new Intent(Home.this, OrderStatus.class);
153 | startActivity(orderIntent);
154 |
155 | }else if(id == R.id.nav_log_out){
156 | Intent signIn = new Intent(Home.this, SignIn.class);
157 | signIn.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
158 | startActivity(signIn);
159 | }
160 |
161 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
162 | drawer.closeDrawer(GravityCompat.START);
163 | return true;
164 | }
165 | }
166 |
--------------------------------------------------------------------------------
/app/src/main/java/com/androideatit/Interface/ItemClickListener.java:
--------------------------------------------------------------------------------
1 | package com.androideatit.Interface;
2 |
3 | import android.view.View;
4 |
5 | /**
6 | * Created by 123456 on 2017/11/17.
7 | */
8 |
9 | public interface ItemClickListener {
10 | void onClick(View view, int position, boolean isLongClick);
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/java/com/androideatit/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.androideatit;
2 |
3 | import android.content.Intent;
4 | import android.graphics.Typeface;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.os.Bundle;
7 | import android.view.View;
8 | import android.widget.Button;
9 | import android.widget.TextView;
10 |
11 | public class MainActivity extends AppCompatActivity {
12 |
13 | Button btnSignIn, btnSignUp;
14 | TextView txtSlogan;
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | setContentView(R.layout.activity_main);
19 |
20 | btnSignIn = (Button) findViewById(R.id.btnSignIn);
21 | btnSignUp = (Button) findViewById(R.id.btnSignUp);
22 |
23 | txtSlogan = (TextView) findViewById(R.id.txtSlogan);
24 | Typeface face = Typeface.createFromAsset(getAssets(),"fonts/Nabila.ttf");
25 | txtSlogan.setTypeface(face);
26 |
27 | btnSignIn.setOnClickListener(new View.OnClickListener() {
28 | @Override
29 | public void onClick(View view) {
30 | Intent signin = new Intent(MainActivity.this, SignIn.class);
31 | startActivity(signin);
32 | }
33 | });
34 |
35 | btnSignUp.setOnClickListener(new View.OnClickListener() {
36 | @Override
37 | public void onClick(View v) {
38 | Intent signup = new Intent(MainActivity.this, SignUp.class);
39 | startActivity(signup);
40 | }
41 | });
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/com/androideatit/Model/Category.java:
--------------------------------------------------------------------------------
1 | package com.androideatit.Model;
2 |
3 | /**
4 | * Created by 123456 on 2017/11/17.
5 | */
6 |
7 | public class Category {
8 | private String Name;
9 | private String Image;
10 |
11 | public Category() {
12 | }
13 |
14 | public Category(String name, String image) {
15 | Name = name;
16 | Image = image;
17 | }
18 |
19 | public String getImage() {
20 | return Image;
21 | }
22 |
23 | public void setImage(String image) {
24 | Image = image;
25 | }
26 |
27 | public String getName() {
28 | return Name;
29 | }
30 |
31 | public void setName(String name) {
32 | Name = name;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/java/com/androideatit/Model/Food.java:
--------------------------------------------------------------------------------
1 | package com.androideatit.Model;
2 |
3 | /**
4 | * Created by 123456 on 2017/11/17.
5 | */
6 |
7 | public class Food {
8 | private String Name, Image, Description, Price, Discount, MenuId, FoodId, AvailabilityFlag;
9 |
10 | public Food() {
11 | }
12 |
13 | public Food(String name, String image, String description, String price, String discount, String menuId, String foodId, String availabilityFlag) {
14 | Name = name;
15 | Image = image;
16 | Description = description;
17 | Price = price;
18 | Discount = discount;
19 | MenuId = menuId;
20 | FoodId = foodId;
21 | AvailabilityFlag = availabilityFlag;
22 | }
23 |
24 |
25 |
26 | public String getName() {
27 | return Name;
28 | }
29 |
30 | public void setName(String name) {
31 | Name = name;
32 | }
33 |
34 | public String getImage() {
35 | return Image;
36 | }
37 |
38 | public void setImage(String image) {
39 | Image = image;
40 | }
41 |
42 | public String getDescription() {
43 | return Description;
44 | }
45 |
46 | public void setDescription(String description) {
47 | Description = description;
48 | }
49 |
50 | public String getPrice() {
51 | return Price;
52 | }
53 |
54 | public void setPrice(String price) {
55 | Price = price;
56 | }
57 |
58 | public String getDiscount() {
59 | return Discount;
60 | }
61 |
62 | public void setDiscount(String discount) {
63 | Discount = discount;
64 | }
65 |
66 | public String getMenuId() {
67 | return MenuId;
68 | }
69 |
70 | public void setMenuId(String menuId) {
71 | MenuId = menuId;
72 | }
73 |
74 | public String getFoodId() {
75 | return FoodId;
76 | }
77 |
78 | public void setFoodId(String foodId) {
79 | FoodId = foodId;
80 | }
81 |
82 | public String getAvailabilityFlag() {
83 | return AvailabilityFlag;
84 | }
85 |
86 | public void setAvailabilityFlag(String availabilityFlag) {
87 | AvailabilityFlag = availabilityFlag;
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/app/src/main/java/com/androideatit/Model/Order.java:
--------------------------------------------------------------------------------
1 | package com.androideatit.Model;
2 |
3 | /**
4 | * Created by 123456 on 2017/11/19.
5 | */
6 |
7 | public class Order {
8 | private String ProductId;
9 | private String ProductName;
10 | private String Quanlity;
11 | private String Price;
12 | private String Discount;
13 |
14 | public Order() {
15 | }
16 |
17 | public Order(String productId, String productName, String quanlity, String price, String discount) {
18 | ProductId = productId;
19 | ProductName = productName;
20 | Quanlity = quanlity;
21 | Price = price;
22 | Discount = discount;
23 | }
24 |
25 | public String getProductId() {
26 | return ProductId;
27 | }
28 |
29 | public void setProductId(String productId) {
30 | ProductId = productId;
31 | }
32 |
33 | public String getProductName() {
34 | return ProductName;
35 | }
36 |
37 | public void setProductName(String productName) {
38 | ProductName = productName;
39 | }
40 |
41 | public String getQuanlity() {
42 | return Quanlity;
43 | }
44 |
45 | public void setQuanlity(String quanlity) {
46 | Quanlity = quanlity;
47 | }
48 |
49 | public String getPrice() {
50 | return Price;
51 | }
52 |
53 | public void setPrice(String price) {
54 | Price = price;
55 | }
56 |
57 | public String getDiscount() {
58 | return Discount;
59 | }
60 |
61 | public void setDiscount(String discount) {
62 | Discount = discount;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/app/src/main/java/com/androideatit/Model/Receipt.java:
--------------------------------------------------------------------------------
1 | package com.androideatit.Model;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * Created by 123456 on 2017/11/27.
7 | */
8 |
9 | public class Receipt {
10 | public List items;
11 | public String totalcost;
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/java/com/androideatit/Model/Request.java:
--------------------------------------------------------------------------------
1 | package com.androideatit.Model;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * Created by 123456 on 2017/11/20.
7 | */
8 |
9 | public class Request {
10 | private String phone;
11 | private String name;
12 | private String address;
13 | private String total;
14 | private String status;
15 | private List foods;
16 | private boolean partial = false;
17 |
18 | public Request() {
19 | }
20 |
21 | public Request(String phone, String name, String address, String total, List foods) {
22 | this.phone = phone;
23 | this.name = name;
24 | this.address = address;
25 | this.total = total;
26 | this.foods = foods;
27 | this.status="0"; //Default is 0, 0:Placed, 1: Shipping, 2: Shipped
28 | }
29 |
30 | public boolean isPartial() {
31 | return partial;
32 | }
33 |
34 | public void setPartial(boolean partial) {
35 | this.partial = partial;
36 | }
37 |
38 | public String getStatus() {
39 | return status;
40 | }
41 |
42 | public void setStatus(String status) {
43 | this.status = status;
44 | }
45 |
46 | public String getPhone() {
47 | return phone;
48 | }
49 |
50 | public void setPhone(String phone) {
51 | this.phone = phone;
52 | }
53 |
54 | public String getName() {
55 | return name;
56 | }
57 |
58 | public void setName(String name) {
59 | this.name = name;
60 | }
61 |
62 | public String getAddress() {
63 | return address;
64 | }
65 |
66 | public void setAddress(String address) {
67 | this.address = address;
68 | }
69 |
70 | public String getTotal() {
71 | return total;
72 | }
73 |
74 | public void setTotal(String total) {
75 | this.total = total;
76 | }
77 |
78 | public List getFoods() {
79 | return foods;
80 | }
81 |
82 | public void setFoods(List foods) {
83 | this.foods = foods;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/app/src/main/java/com/androideatit/Model/User.java:
--------------------------------------------------------------------------------
1 | package com.androideatit.Model;
2 |
3 | /**
4 | * Created by 123456 on 2017/11/16.
5 | */
6 |
7 | public class User {
8 | private String Name;
9 | private String Password;
10 | private String Phone;
11 |
12 | public User() {
13 | }
14 |
15 | public User(String name, String password) {
16 | Name = name;
17 | Password = password;
18 | }
19 |
20 | public void setPhone(String phone) {
21 | Phone = phone;
22 | }
23 |
24 | public String getPhone() {
25 |
26 | return Phone;
27 | }
28 |
29 | public String getName() {
30 | return Name;
31 | }
32 |
33 | public void setName(String name) {
34 | Name = name;
35 | }
36 |
37 | public String getPassword() {
38 | return Password;
39 | }
40 |
41 | public void setPassword(String password) {
42 | Password = password;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/java/com/androideatit/OrderStatus.java:
--------------------------------------------------------------------------------
1 | package com.androideatit;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.support.v7.widget.LinearLayoutManager;
6 | import android.support.v7.widget.RecyclerView;
7 |
8 | import com.androideatit.Common.Common;
9 | import com.androideatit.Model.Request;
10 | import com.androideatit.ViewHolder.OrderViewHolder;
11 | import com.firebase.ui.database.FirebaseRecyclerAdapter;
12 | import com.google.firebase.database.DatabaseReference;
13 | import com.google.firebase.database.FirebaseDatabase;
14 |
15 | public class OrderStatus extends AppCompatActivity {
16 |
17 | public RecyclerView recyclerView;
18 | public RecyclerView.LayoutManager layoutManager;
19 |
20 | FirebaseRecyclerAdapter adapter;
21 |
22 | FirebaseDatabase database;
23 | DatabaseReference requests;
24 |
25 | @Override
26 | protected void onCreate(Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | setContentView(R.layout.activity_order_status);
29 |
30 | //Firebase
31 | database = FirebaseDatabase.getInstance();
32 | requests = database.getReference("Requests");
33 |
34 | recyclerView = findViewById(R.id.listOrders);
35 | recyclerView.setHasFixedSize(true);
36 | layoutManager = new LinearLayoutManager(this);
37 | recyclerView.setLayoutManager(layoutManager);
38 |
39 | loadOrders(Common.currentUser.getPhone());
40 |
41 | }
42 |
43 | private void loadOrders(String phone) {
44 | adapter = new FirebaseRecyclerAdapter(
45 | Request.class,
46 | R.layout.order_layout,
47 | OrderViewHolder.class,
48 | requests.orderByChild("phone").equalTo(phone)
49 | ) {
50 | @Override
51 | protected void populateViewHolder(OrderViewHolder viewHolder, Request model, int position) {
52 | viewHolder.txtOrderId.setText(adapter.getRef(position).getKey());
53 | viewHolder.txtOrderStatus.setText(convertCodeToStatus(model.getStatus()));
54 | viewHolder.txtOrderAddress.setText(model.getAddress());
55 | viewHolder.txtOrderphone.setText(model.getPhone());
56 |
57 | }
58 | };
59 |
60 | recyclerView.setAdapter(adapter);
61 |
62 | }
63 |
64 | private String convertCodeToStatus(String status) {
65 | if(status.equals("0"))
66 | return "Placed";
67 | else if(status.equals("1"))
68 | return "Preparing";
69 | else if(status.equals("2"))
70 | return "Packaging";
71 | else
72 | return "Food Ready";
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/app/src/main/java/com/androideatit/SignIn.java:
--------------------------------------------------------------------------------
1 | package com.androideatit;
2 |
3 | import android.app.ProgressDialog;
4 | import android.content.Intent;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.os.Bundle;
7 | import android.view.View;
8 | import android.widget.Button;
9 | import android.widget.EditText;
10 | import android.widget.Toast;
11 |
12 | import com.androideatit.Common.Common;
13 | import com.androideatit.Model.User;
14 | import com.google.firebase.database.DataSnapshot;
15 | import com.google.firebase.database.DatabaseError;
16 | import com.google.firebase.database.DatabaseReference;
17 | import com.google.firebase.database.FirebaseDatabase;
18 | import com.google.firebase.database.ValueEventListener;
19 |
20 | public class SignIn extends AppCompatActivity {
21 | EditText edtPhone, edtPassword;
22 | Button btnSignIn;
23 |
24 | @Override
25 | protected void onCreate(Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 | setContentView(R.layout.activity_sign_in);
28 |
29 | edtPhone = findViewById(R.id.edtPhone);
30 | edtPassword = findViewById(R.id.edtPassword);
31 | btnSignIn = findViewById(R.id.btnSignIn);
32 |
33 | FirebaseDatabase database = FirebaseDatabase.getInstance();
34 | final DatabaseReference table_user = database.getReference("User");
35 |
36 | btnSignIn.setOnClickListener(new View.OnClickListener() {
37 | @Override
38 | public void onClick(View v) {
39 |
40 | final ProgressDialog mDialog = new ProgressDialog(SignIn.this);
41 | mDialog.setMessage("Please Wating...");
42 | mDialog.show();
43 |
44 | table_user.addValueEventListener(new ValueEventListener() {
45 |
46 | @Override
47 | public void onDataChange(DataSnapshot dataSnapshot) {
48 |
49 | //check if user not exist in database
50 | if(dataSnapshot.child(edtPhone.getText().toString()).exists()) {
51 | //get user information
52 | mDialog.dismiss();
53 | User user = dataSnapshot.child(edtPhone.getText().toString()).getValue(User.class);
54 | user.setPhone(edtPhone.getText().toString());
55 | if (user.getPassword().equals(edtPassword.getText().toString())) {
56 |
57 | Intent homeIntent = new Intent(SignIn.this, Home.class);
58 | Common.currentUser = user;
59 | startActivity(homeIntent);
60 | finish();
61 |
62 | } else {
63 | Toast.makeText(SignIn.this, "Wrong Password !", Toast.LENGTH_SHORT).show();
64 | }
65 | }else{
66 | Toast.makeText(SignIn.this, "User not exist in Database !", Toast.LENGTH_SHORT).show();
67 | }
68 | }
69 |
70 | @Override
71 | public void onCancelled(DatabaseError databaseError) {
72 |
73 | }
74 | });
75 | }
76 | });
77 |
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/app/src/main/java/com/androideatit/SignUp.java:
--------------------------------------------------------------------------------
1 | package com.androideatit;
2 |
3 | import android.app.ProgressDialog;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.widget.Button;
8 | import android.widget.Toast;
9 |
10 | import com.androideatit.Model.User;
11 | import com.google.firebase.database.DataSnapshot;
12 | import com.google.firebase.database.DatabaseError;
13 | import com.google.firebase.database.DatabaseReference;
14 | import com.google.firebase.database.FirebaseDatabase;
15 | import com.google.firebase.database.ValueEventListener;
16 | import com.rengwuxian.materialedittext.MaterialEditText;
17 |
18 | public class SignUp extends AppCompatActivity {
19 |
20 | MaterialEditText edtPhone, edtName, edtPassword;
21 | Button btnSignUp;
22 |
23 | @Override
24 | protected void onCreate(Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | setContentView(R.layout.activity_sign_up);
27 |
28 | edtPhone = findViewById(R.id.edtPhone);
29 | edtName = findViewById(R.id.edtName);
30 | edtPassword = findViewById(R.id.edtPassword);
31 |
32 | btnSignUp = findViewById(R.id.btnSignUp);
33 |
34 | FirebaseDatabase database = FirebaseDatabase.getInstance();
35 | final DatabaseReference table_user = database.getReference("User");
36 |
37 | btnSignUp.setOnClickListener(new View.OnClickListener() {
38 | @Override
39 | public void onClick(View v) {
40 | final ProgressDialog mDialog = new ProgressDialog(SignUp.this);
41 | mDialog.setMessage("Please Wating...");
42 | mDialog.show();
43 |
44 | table_user.addValueEventListener(new ValueEventListener() {
45 | @Override
46 | public void onDataChange(DataSnapshot dataSnapshot) {
47 | //check if user not exist in database
48 | if (dataSnapshot.child(edtPhone.getText().toString()).exists()) {
49 | //get user information
50 | mDialog.dismiss();
51 | User user = dataSnapshot.child(edtPhone.getText().toString()).getValue(User.class);
52 | Toast.makeText(SignUp.this, "Phone number already registered !", Toast.LENGTH_SHORT).show();
53 |
54 | } else {
55 | mDialog.dismiss();
56 | User user = new User(edtName.getText().toString(), edtPassword.getText().toString());
57 | table_user.child(edtPhone.getText().toString()).setValue(user);
58 | Toast.makeText(SignUp.this, "Sign Up Successfully !", Toast.LENGTH_SHORT).show();
59 | finish();
60 | }
61 | }
62 | @Override
63 | public void onCancelled (DatabaseError databaseError){
64 |
65 | }
66 | });
67 | }
68 | });
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/app/src/main/java/com/androideatit/ViewHolder/CartAdapter.java:
--------------------------------------------------------------------------------
1 | package com.androideatit.ViewHolder;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.media.Image;
6 | import android.support.v7.widget.RecyclerView;
7 | import android.view.ContextMenu;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.ImageView;
12 | import android.widget.TextView;
13 |
14 | import com.amulyakhare.textdrawable.TextDrawable;
15 | import com.androideatit.Common.Common;
16 | import com.androideatit.Interface.ItemClickListener;
17 | import com.androideatit.Model.Order;
18 | import com.androideatit.R;
19 |
20 | import org.w3c.dom.Text;
21 |
22 | import java.text.NumberFormat;
23 | import java.util.ArrayList;
24 | import java.util.List;
25 | import java.util.Locale;
26 |
27 | /**
28 | * Created by 123456 on 2017/11/19.
29 | */
30 |
31 | class CartViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener,View.OnCreateContextMenuListener {
32 |
33 | public TextView txt_cart_name, txt_price;
34 | public ImageView img_cart_count;
35 |
36 | private ItemClickListener itemClickListener;
37 |
38 | public void setTxt_cart_name(TextView txt_cart_name) {
39 | this.txt_cart_name = txt_cart_name;
40 | }
41 |
42 | public CartViewHolder(View itemView){
43 | super(itemView);
44 | txt_cart_name = itemView.findViewById(R.id.cart_item_name);
45 | txt_price = itemView.findViewById(R.id.cart_item_Price);
46 | img_cart_count = itemView.findViewById(R.id.cart_item_count);
47 | itemView.setOnCreateContextMenuListener(this);
48 | }
49 |
50 | @Override
51 | public void onClick(View view){
52 |
53 | }
54 |
55 | @Override
56 | public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
57 | menu.setHeaderTitle(Common.DELETE);
58 |
59 | menu.add(0,0,getAdapterPosition(),Common.DELETE);
60 | }
61 | }
62 |
63 | public class CartAdapter extends RecyclerView.Adapter{
64 |
65 | private List listData = new ArrayList<>();
66 | private Context context;
67 |
68 | public CartAdapter(List listData, Context context){
69 | this.listData = listData;
70 | this.context = context;
71 | }
72 |
73 | @Override
74 | public CartViewHolder onCreateViewHolder(ViewGroup parent, int viewType){
75 | LayoutInflater inflater = LayoutInflater.from(context);
76 | View itemView = inflater.inflate(R.layout.cart_layout, parent, false);
77 | return new CartViewHolder(itemView);
78 | }
79 |
80 | @Override
81 | public void onBindViewHolder(CartViewHolder holder, int position) {
82 | TextDrawable drawable = TextDrawable.builder().buildRound(""+listData.get(position).getQuanlity(), Color.RED);
83 | holder.img_cart_count.setImageDrawable(drawable);
84 |
85 | Locale locale = new Locale("en","US");
86 | NumberFormat fmt = NumberFormat.getCurrencyInstance(locale);
87 | int price = (Integer.parseInt(listData.get(position).getPrice()))*(Integer.parseInt(listData.get(position).getQuanlity()));
88 | holder.txt_price.setText(fmt.format(price));
89 | holder.txt_cart_name.setText(listData.get(position).getProductName());
90 |
91 | }
92 |
93 | @Override
94 | public int getItemCount() {
95 |
96 | return listData.size();
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/app/src/main/java/com/androideatit/ViewHolder/FoodViewHolder.java:
--------------------------------------------------------------------------------
1 | package com.androideatit.ViewHolder;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import android.view.ContextMenu;
5 | import android.view.View;
6 | import android.widget.ImageView;
7 | import android.widget.TextView;
8 |
9 | import com.androideatit.Interface.ItemClickListener;
10 | import com.androideatit.R;
11 |
12 | /**
13 | * Created by 123456 on 2017/11/17.
14 | */
15 |
16 | public class FoodViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
17 |
18 | public TextView food_name;
19 | public ImageView food_image;
20 |
21 | private ItemClickListener itemClickListener;
22 |
23 | public void setItemClickListener(ItemClickListener itemClickListener) {
24 | this.itemClickListener = itemClickListener;
25 | }
26 |
27 | public FoodViewHolder(View itemView) {
28 | super(itemView);
29 |
30 | food_name =(TextView)itemView.findViewById(R.id.food_name);
31 | food_image = (ImageView)itemView.findViewById(R.id.food_image);
32 |
33 | itemView.setOnClickListener(this);
34 | }
35 |
36 | @Override
37 | public void onClick(View view) {
38 |
39 | itemClickListener.onClick(view, getAdapterPosition(), false);
40 |
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/com/androideatit/ViewHolder/MenuViewHolder.java:
--------------------------------------------------------------------------------
1 | package com.androideatit.ViewHolder;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import android.view.View;
5 | import android.widget.ImageView;
6 | import android.widget.TextView;
7 |
8 | import com.androideatit.Interface.ItemClickListener;
9 | import com.androideatit.R;
10 |
11 | /**
12 | * Created by 123456 on 2017/11/17.
13 | */
14 |
15 | public class MenuViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
16 |
17 | public TextView txtMenuName;
18 | public ImageView imageView;
19 |
20 | private ItemClickListener itemClickListener;
21 |
22 | public MenuViewHolder(View itemView){
23 | super(itemView);
24 |
25 | txtMenuName = itemView.findViewById(R.id.menu_name);
26 | imageView = itemView.findViewById(R.id.menu_image);
27 |
28 | itemView.setOnClickListener(this);
29 |
30 | }
31 |
32 | public void setItemClickListener(ItemClickListener itemClickListener) {
33 | this.itemClickListener = itemClickListener;
34 | }
35 |
36 | @Override
37 | public void onClick(View view)
38 | {
39 | itemClickListener.onClick(view, getAdapterPosition(), false);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/java/com/androideatit/ViewHolder/OrderViewHolder.java:
--------------------------------------------------------------------------------
1 | package com.androideatit.ViewHolder;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import android.view.View;
5 | import android.widget.TextView;
6 |
7 | import com.androideatit.Interface.ItemClickListener;
8 | import com.androideatit.R;
9 |
10 | /**
11 | * Created by 123456 on 2017/11/20.
12 | */
13 |
14 | public class OrderViewHolder extends RecyclerView.ViewHolder{
15 |
16 | public TextView txtOrderId, txtOrderStatus, txtOrderphone, txtOrderAddress;
17 |
18 | private ItemClickListener itemClickListener;
19 |
20 | public OrderViewHolder(View itemView){
21 | super(itemView);
22 |
23 | txtOrderAddress = itemView.findViewById(R.id.order_address);
24 | txtOrderId = itemView.findViewById(R.id.order_id);
25 | txtOrderStatus = itemView.findViewById(R.id.order_status);
26 | txtOrderphone = itemView.findViewById(R.id.order_address);
27 |
28 | }
29 |
30 | public void setItemClickListener(ItemClickListener itemClickListener){
31 | this.itemClickListener = itemClickListener;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lukchen/Android-Food-Order-Application-for-6150/1325c23c461967dcdfbbc086ec7e15803e55dd8b/app/src/main/res/drawable-hdpi/background.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lukchen/Android-Food-Order-Application-for-6150/1325c23c461967dcdfbbc086ec7e15803e55dd8b/app/src/main/res/drawable-hdpi/logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lukchen/Android-Food-Order-Application-for-6150/1325c23c461967dcdfbbc086ec7e15803e55dd8b/app/src/main/res/drawable-mdpi/background.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lukchen/Android-Food-Order-Application-for-6150/1325c23c461967dcdfbbc086ec7e15803e55dd8b/app/src/main/res/drawable-mdpi/logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_camera.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_gallery.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_manage.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_send.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_share.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_slideshow.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lukchen/Android-Food-Order-Application-for-6150/1325c23c461967dcdfbbc086ec7e15803e55dd8b/app/src/main/res/drawable-xhdpi/background.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lukchen/Android-Food-Order-Application-for-6150/1325c23c461967dcdfbbc086ec7e15803e55dd8b/app/src/main/res/drawable-xhdpi/logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lukchen/Android-Food-Order-Application-for-6150/1325c23c461967dcdfbbc086ec7e15803e55dd8b/app/src/main/res/drawable-xxhdpi/background.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lukchen/Android-Food-Order-Application-for-6150/1325c23c461967dcdfbbc086ec7e15803e55dd8b/app/src/main/res/drawable-xxhdpi/logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lukchen/Android-Food-Order-Application-for-6150/1325c23c461967dcdfbbc086ec7e15803e55dd8b/app/src/main/res/drawable-xxxhdpi/background.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lukchen/Android-Food-Order-Application-for-6150/1325c23c461967dcdfbbc086ec7e15803e55dd8b/app/src/main/res/drawable-xxxhdpi/logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_access_time_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_attach_money_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_exit_to_app_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_restaurant_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_shopping_cart_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/side_nav_bar.xml:
--------------------------------------------------------------------------------
1 |
3 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_cart.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
21 |
22 |
25 |
26 |
32 |
33 |
39 |
46 |
47 |
48 |
49 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_food_detail.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
24 |
25 |
33 |
34 |
35 |
36 |
37 |
38 |
50 |
51 |
57 |
58 |
62 |
63 |
68 |
69 |
73 |
74 |
84 |
85 |
90 |
91 |
96 |
97 |
106 |
107 |
108 |
109 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
132 |
133 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_food_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_home.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
16 |
17 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
21 |
22 |
29 |
30 |
31 |
37 |
38 |
47 |
48 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_order_status.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_sign_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
18 |
19 |
35 |
51 |
52 |
53 |
54 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_sign_up.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
18 |
19 |
35 |
36 |
51 |
67 |
68 |
69 |
70 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/app_bar_home.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
20 |
21 |
22 |
23 |
24 |
25 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/cart_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
22 |
23 |
32 |
33 |
42 |
43 |
44 |
45 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_home.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/food_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
13 |
19 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/menu_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
11 |
17 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/nav_header_home.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/order_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
22 |
23 |
32 |
33 |
42 |
43 |
52 |
53 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/activity_home_drawer.xml:
--------------------------------------------------------------------------------
1 |
2 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/home.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lukchen/Android-Food-Order-Application-for-6150/1325c23c461967dcdfbbc086ec7e15803e55dd8b/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lukchen/Android-Food-Order-Application-for-6150/1325c23c461967dcdfbbc086ec7e15803e55dd8b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lukchen/Android-Food-Order-Application-for-6150/1325c23c461967dcdfbbc086ec7e15803e55dd8b/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lukchen/Android-Food-Order-Application-for-6150/1325c23c461967dcdfbbc086ec7e15803e55dd8b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lukchen/Android-Food-Order-Application-for-6150/1325c23c461967dcdfbbc086ec7e15803e55dd8b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lukchen/Android-Food-Order-Application-for-6150/1325c23c461967dcdfbbc086ec7e15803e55dd8b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lukchen/Android-Food-Order-Application-for-6150/1325c23c461967dcdfbbc086ec7e15803e55dd8b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lukchen/Android-Food-Order-Application-for-6150/1325c23c461967dcdfbbc086ec7e15803e55dd8b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lukchen/Android-Food-Order-Application-for-6150/1325c23c461967dcdfbbc086ec7e15803e55dd8b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lukchen/Android-Food-Order-Application-for-6150/1325c23c461967dcdfbbc086ec7e15803e55dd8b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/test.xml:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lukchen/Android-Food-Order-Application-for-6150/1325c23c461967dcdfbbc086ec7e15803e55dd8b/app/src/main/res/test.xml
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303f9f
5 | #FF4081
6 |
7 | #39796b
8 | #A9d440
9 |
10 | #7f333639
11 | #0e0d0e
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 8dp
6 | 176dp
7 | 16dp
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/drawables.xml:
--------------------------------------------------------------------------------
1 |
2 | - @android:drawable/ic_menu_camera
3 | - @android:drawable/ic_menu_gallery
4 | - @android:drawable/ic_menu_slideshow
5 | - @android:drawable/ic_menu_manage
6 | - @android:drawable/ic_menu_share
7 | - @android:drawable/ic_menu_send
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AndroidEatIt
3 | ItsagoodtimeforthegreattasteofMcDonalds
4 | Home
5 |
6 | Open navigation drawer
7 | Close navigation drawer
8 |
9 | Settings
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
14 |
15 |
16 |
17 |
22 |
23 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/test/java/com/androideatit/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.androideatit;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.1.60'
5 |
6 | repositories {
7 | google()
8 | jcenter()
9 | }
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:3.0.1'
12 | classpath 'com.google.gms:google-services:3.1.0'
13 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14 |
15 | // NOTE: Do not place your application dependencies here; they belong
16 | // in the individual module build.gradle files
17 | }
18 | }
19 |
20 | allprojects {
21 | repositories {
22 | google()
23 | jcenter()
24 | }
25 | }
26 |
27 | task clean(type: Delete) {
28 | delete rootProject.buildDir
29 | }
30 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lukchen/Android-Food-Order-Application-for-6150/1325c23c461967dcdfbbc086ec7e15803e55dd8b/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Nov 16 18:18:28 EST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------