├── E-COMMERCE ANDROID APPLICATION - VIRTUAL SALES OF FOOD -- E-Restaurant -- - Ridvan Al hourani - Graduation project.pdf ├── Images ├── CustomerApp.png ├── CustomerApp2.png ├── DeliveryApp.png ├── DeliveryApp2.png ├── ServerApp.png └── ServerApp2.png ├── README.md ├── androideatitv2client ├── Adapter │ ├── MyBestDealsAdapter.java │ ├── MyCartAdapter.java │ ├── MyCategoriesAdapter.java │ ├── MyCommentAdapter.java │ ├── MyFoodListAdapter.java │ ├── MyOrderDetailAdapter.java │ ├── MyOrdersAdapter.java │ └── MyPopularCategoriesAdapter.java ├── Callback │ ├── IBestDealCallbackListener.java │ ├── ICategoryCallbackListener.java │ ├── ICommentCallbackListener.java │ ├── ILoadOrderCallbackListener.java │ ├── ILoadTimeFromFirebaseListener.java │ ├── IPopularCallbackListener.java │ ├── IRecyclerClickListener.java │ └── MyButtonClickListener.java ├── Common │ ├── Common.java │ ├── MySwipeHelper.java │ └── SpacesItemDecoration.java ├── Database │ ├── CartDAO.java │ ├── CartDataSource.java │ ├── CartDatabase.java │ ├── CartItem.java │ └── LocalCartDataSource.java ├── EventBus │ ├── BestDealItemClick.java │ ├── CategoryClick.java │ ├── CounterCartEvent.java │ ├── FoodItemClick.java │ ├── HideFABCart.java │ ├── MenuItemBack.java │ ├── PopularCategoryClick.java │ └── UpdateItemInCart.java ├── HomeActivity.java ├── MainActivity.java ├── Model │ ├── AddonModel.java │ ├── BestDealModel.java │ ├── BraintreeToken.java │ ├── BraintreeTransaction.java │ ├── CategoryModel.java │ ├── CommentModel.java │ ├── FCMResponse.java │ ├── FCMResult.java │ ├── FCMSendData.java │ ├── FoodModel.java │ ├── OrderModel.java │ ├── PopularCategoryModel.java │ ├── RefundRequestModel.java │ ├── ShippingOrderModel.java │ ├── SizeModel.java │ ├── TokenModel.java │ ├── Transaction.java │ └── UserModel.java ├── Remote │ ├── ICloudFunctions.java │ ├── IFCMService.java │ ├── IGoogleAPI.java │ ├── RetrofitCloudClient.java │ ├── RetrofitFCMClient.java │ └── RetrofitGoogleAPIClient.java ├── TrackingOrderActivity.java ├── services │ └── MyFCMServices.java └── ui │ ├── cart │ ├── CartFragment.java │ └── CartViewModel.java │ ├── comments │ ├── CommentFragment.java │ └── CommentViewModel.java │ ├── fooddetail │ ├── FoodDetailFragment.java │ └── FoodDetailViewModel.java │ ├── foodlist │ ├── FoodListFragment.java │ └── FoodListViewModel.java │ ├── home │ ├── HomeFragment.java │ └── HomeViewModel.java │ ├── menu │ ├── MenuFragment.java │ └── MenuViewModel.java │ └── view_orders │ ├── ViewOrdersFragment.java │ └── ViewOrdersViewModel.java ├── androideatitv2server ├── Adapter │ ├── MyAddonAdapter.java │ ├── MyCategoriesAdapter.java │ ├── MyFoodListAdapter.java │ ├── MyOrderAdapter.java │ ├── MyOrderDetailAdapter.java │ ├── MyShipperAdapter.java │ ├── MyShipperSelectionAdapter.java │ └── MySizeAdapter.java ├── Callback │ ├── ICategoryCallbackListener.java │ ├── IOrderCallbackListener.java │ ├── IRecyclerClickListener.java │ ├── IShipperLoadCallbackListener.java │ ├── ISingleShippingOrderCallbackListener.java │ └── MyButtonClickListener.java ├── Common │ ├── BottomSheetOrderFragment.java │ ├── Common.java │ ├── MySwipeHelper.java │ └── SpacesItemDecoration.java ├── EventBus │ ├── AddonSizeEditEvent.java │ ├── CategoryClick.java │ ├── ChangeMenuClick.java │ ├── LoadOrderEvent.java │ ├── ToastEvent.java │ └── UpdateShipperEvent.java ├── HomeActivity.java ├── MainActivity.java ├── Model │ ├── AddonModel.java │ ├── CartItem.java │ ├── CategoryModel.java │ ├── FCMResponse.java │ ├── FCMResult.java │ ├── FCMSendData.java │ ├── FoodModel.java │ ├── OrderModel.java │ ├── SelectAddonModel.java │ ├── SelectSizeModel.java │ ├── ServerUserModel.java │ ├── ShipperModel.java │ ├── ShippingOrderModel.java │ ├── SizeModel.java │ ├── TokenModel.java │ ├── UpdateAddonModel.java │ └── UpdateSizeModel.java ├── Remote │ ├── IFCMService.java │ ├── IGoogleAPI.java │ ├── RetrofitFCMClient.java │ └── RetrofitGoogleAPIClient.java ├── SizeAddonEditActivity.java ├── TrackingOrderActivity.java ├── services │ └── MyFCMServices.java └── ui │ ├── category │ ├── CategoryFragment.java │ └── CategoryViewModel.java │ ├── food_list │ ├── FoodListFragment.java │ └── FoodListViewModel.java │ ├── order │ ├── OrderFragment.java │ └── OrderViewModel.java │ └── shipper │ ├── ShipperFragment.java │ └── ShipperViewModel.java └── androideatitv2shipper ├── Adapters └── MyShippingOrderAdapter.java ├── Callbacks └── IShippingOrderCallbackListener.java ├── Common ├── Common.java ├── LatLngInterpolator.java └── MarkerAnimation.java ├── HomeActivity.java ├── MainActivity.java ├── Model ├── CartItem.java ├── EventBus │ └── UpdateShippingOrderEvent.java ├── FCMResponse.java ├── FCMResult.java ├── FCMSendData.java ├── OrderModel.java ├── ShipperUserModel.java ├── ShippingOrderModel.java └── TokenModel.java ├── Remote ├── IFCMService.java ├── IGoogleAPI.java ├── RetrofitFCMClient.java └── RetrofitGoogleAPIClient.java ├── Services └── MyFCMServices.java ├── ShippingActivity.java └── ui ├── gallery ├── GalleryFragment.java └── GalleryViewModel.java ├── shipOrders ├── OrdersToShipFragment.java └── OrdersToShipViewModel.java └── slideshow ├── SlideshowFragment.java └── SlideshowViewModel.java /E-COMMERCE ANDROID APPLICATION - VIRTUAL SALES OF FOOD -- E-Restaurant -- - Ridvan Al hourani - Graduation project.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rhourani/E-Commerce-Resturant-Android-Java-Apps/a7c1984479511299f73f68c6bd28fa5a33969f48/E-COMMERCE ANDROID APPLICATION - VIRTUAL SALES OF FOOD -- E-Restaurant -- - Ridvan Al hourani - Graduation project.pdf -------------------------------------------------------------------------------- /Images/CustomerApp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rhourani/E-Commerce-Resturant-Android-Java-Apps/a7c1984479511299f73f68c6bd28fa5a33969f48/Images/CustomerApp.png -------------------------------------------------------------------------------- /Images/CustomerApp2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rhourani/E-Commerce-Resturant-Android-Java-Apps/a7c1984479511299f73f68c6bd28fa5a33969f48/Images/CustomerApp2.png -------------------------------------------------------------------------------- /Images/DeliveryApp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rhourani/E-Commerce-Resturant-Android-Java-Apps/a7c1984479511299f73f68c6bd28fa5a33969f48/Images/DeliveryApp.png -------------------------------------------------------------------------------- /Images/DeliveryApp2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rhourani/E-Commerce-Resturant-Android-Java-Apps/a7c1984479511299f73f68c6bd28fa5a33969f48/Images/DeliveryApp2.png -------------------------------------------------------------------------------- /Images/ServerApp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rhourani/E-Commerce-Resturant-Android-Java-Apps/a7c1984479511299f73f68c6bd28fa5a33969f48/Images/ServerApp.png -------------------------------------------------------------------------------- /Images/ServerApp2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rhourani/E-Commerce-Resturant-Android-Java-Apps/a7c1984479511299f73f68c6bd28fa5a33969f48/Images/ServerApp2.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # E-Commerce-Resturant-Android-Java-Apps 2 | 3 | 4 | In today's internet era, mobile phones are an integral part of almost every single person. 5 | And the global economic trend is focusing on the field of applications for smartphones. 6 | 7 | From the fact that I want to improve myself and advance my career on cryptology and 8 | machine learning and apply this knowledge on a tangible thing as such smartphones 9 | engineering and with a step to understand this sector more I decided to make an 10 | Android app that have a tangible value and common application such as E-shops. 11 | 12 | With the trend aiming to improve and increase the well-being of the person and 13 | increase the sales capacity of the store owners, and , out of these came the idea to 14 | design a smartphone application that aims to create a sales line between customers and 15 | restaurants, that have Additional features that make me understand the concepts of 16 | Android system more deeply and in an applying way as a first step in this major, I 17 | decided to build an E-Restaurant android application for ordering foods. 18 | 19 | THE APP AVAILABLE ON GOOGLE PLAY NOW!! FROM HERE: 20 | 21 | https://play.google.com/store/apps/details?id=com.ds.androideatitv2client 22 | 23 | In my application I tried to learn more about Android concepts and how to handle 24 | different common used scenarios, the project consists of three combined applications, 25 | to explain briefly, we have a "Customer" who wants to buy a food and this lead us to 26 | the "Restaurant" who needs to make that food to this customer and the bridge between 27 | this two is the "Delivery guy". Everyone from this three needs to handle a certain work 28 | to make the final service available. 29 | 30 | To convert this to a software solution, how it should be? Yes, three separated 31 | applications. 32 | 33 | A custom application for the Restaurant, 34 | A custom application for the customer, 35 | And a custom application for the delivery guy, 36 | 37 | Those three apps with its different features such as maps, payment methods, 38 | notification handling, databases and User Interface friendly using; will exchange 39 | information between each other and work together to provide a full-scale restaurant 40 | service operation. 41 | 42 | 43 | The applications main features are as following: 44 | 45 | The apps works on Android system version 5 and higher. 46 | 47 | Apps' best features: 48 | 49 | * 2 type of payment methods provided, Cash on delivery and credit card using third party API Braintree payment. 50 | 51 | * A friendly User interface. 52 | 53 | * Order tracking on Google map. 54 | 55 | * Notification System. 56 | 57 | * And many more basic e-commerce features you can discover while using it! 58 | 59 | 60 | 61 | You can watch the features here as well: 62 | 63 | https://youtu.be/2SWNPbWfEtY 64 | 65 | Customer Application Screenshots 66 | 67 | 68 | 69 | 70 | 71 | Server Application Screenshots 72 | 73 | 74 | 75 | 76 | 77 | Delivery Application Screenshots 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /androideatitv2client/Adapter/MyBestDealsAdapter.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Adapter; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.ImageView; 9 | import android.widget.TextView; 10 | 11 | 12 | import com.asksira.loopingviewpager.LoopingPagerAdapter; 13 | import com.bumptech.glide.Glide; 14 | import com.ds.androideatitv2client.EventBus.BestDealItemClick; 15 | import com.ds.androideatitv2client.Model.BestDealModel; 16 | import com.ds.androideatitv2client.R; 17 | 18 | import org.greenrobot.eventbus.EventBus; 19 | 20 | import java.util.List; 21 | 22 | import butterknife.BindView; 23 | import butterknife.ButterKnife; 24 | import butterknife.Unbinder; 25 | 26 | 27 | public class MyBestDealsAdapter extends LoopingPagerAdapter { 28 | 29 | @BindView(R.id.img_best_deal) 30 | ImageView img_best_deal; 31 | @BindView(R.id.txt_best_deal) 32 | TextView txt_best_deal; 33 | 34 | Unbinder unbinder; 35 | 36 | public MyBestDealsAdapter(Context context, List itemList, boolean isInfinite) { 37 | super(context, itemList, isInfinite); 38 | } 39 | 40 | @Override 41 | protected View inflateView(int viewType, ViewGroup container, int listPosition) { 42 | return LayoutInflater.from(context).inflate(R.layout.layout_best_deal_item,container,false); 43 | } 44 | 45 | @Override 46 | protected void bindView(View convertView, int listPosition, int viewType) { 47 | unbinder = ButterKnife.bind(this,convertView); 48 | //set data 49 | 50 | Glide.with(convertView).load(itemList.get(listPosition).getImage()).into(img_best_deal); 51 | txt_best_deal.setText(itemList.get(listPosition).getName()); 52 | 53 | convertView.setOnClickListener(view -> { 54 | EventBus.getDefault().postSticky(new BestDealItemClick(itemList.get(listPosition))); 55 | }); 56 | 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /androideatitv2client/Adapter/MyCartAdapter.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Adapter; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.ImageView; 8 | import android.widget.TextView; 9 | 10 | import androidx.annotation.NonNull; 11 | import androidx.recyclerview.widget.RecyclerView; 12 | 13 | import com.bumptech.glide.Glide; 14 | import com.cepheuen.elegantnumberbutton.view.ElegantNumberButton; 15 | import com.ds.androideatitv2client.Database.CartItem; 16 | import com.ds.androideatitv2client.EventBus.UpdateItemInCart; 17 | import com.ds.androideatitv2client.R; 18 | 19 | import org.greenrobot.eventbus.EventBus; 20 | 21 | import java.util.List; 22 | 23 | import butterknife.BindAnim; 24 | import butterknife.BindView; 25 | import butterknife.ButterKnife; 26 | import butterknife.Unbinder; 27 | 28 | public class MyCartAdapter extends RecyclerView.Adapter { 29 | Context context; 30 | List cartItemList; 31 | 32 | public MyCartAdapter(Context context, List cartItemList) { 33 | this.context = context; 34 | this.cartItemList = cartItemList; 35 | } 36 | 37 | @NonNull 38 | @Override 39 | public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { 40 | return new MyViewHolder(LayoutInflater.from(context).inflate(R.layout.layout_cart_item, parent, false)); 41 | } 42 | 43 | @Override 44 | public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { 45 | Glide.with(context).load(cartItemList.get(position).getFoodImage()) 46 | .into(holder.img_cart); 47 | holder.txt_food_name.setText(new StringBuilder(cartItemList.get(position).getFoodName())); 48 | holder.txt_food_price.setText(new StringBuilder("") 49 | .append(cartItemList.get(position).getFoodPrice() + cartItemList.get(position).getFoodExtraPrice())); 50 | 51 | holder.numberButton.setNumber(String.valueOf(cartItemList.get(position).getFoodQuantity())); 52 | 53 | //Event 54 | holder.numberButton.setOnValueChangeListener((view, oldValue, newValue) -> { 55 | //when user click this button we will update our database 56 | cartItemList.get(position).setFoodQuantity(newValue); 57 | EventBus.getDefault().postSticky(new UpdateItemInCart(cartItemList.get(position))); 58 | }); 59 | } 60 | 61 | @Override 62 | public int getItemCount() { 63 | return cartItemList.size(); 64 | } 65 | 66 | public CartItem getItemAtPosition(int pos) { 67 | return cartItemList.get(pos); 68 | } 69 | 70 | public class MyViewHolder extends RecyclerView.ViewHolder { 71 | 72 | private Unbinder unbinder; 73 | @BindView(R.id.img_cart) 74 | ImageView img_cart; 75 | @BindView(R.id.txt_food_price) 76 | TextView txt_food_price; 77 | @BindView(R.id.txt_food_name) 78 | TextView txt_food_name; 79 | @BindView(R.id.number_button) 80 | ElegantNumberButton numberButton; 81 | public MyViewHolder(@NonNull View itemView) { 82 | super(itemView); 83 | unbinder = ButterKnife.bind(this, itemView); 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /androideatitv2client/Adapter/MyCategoriesAdapter.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Adapter; 2 | 3 | import android.app.Notification; 4 | import android.content.Context; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.view.animation.LayoutAnimationController; 9 | import android.widget.ImageView; 10 | import android.widget.TextView; 11 | 12 | import androidx.annotation.NonNull; 13 | import androidx.recyclerview.widget.RecyclerView; 14 | 15 | import com.bumptech.glide.Glide; 16 | import com.ds.androideatitv2client.Callback.IRecyclerClickListener; 17 | import com.ds.androideatitv2client.Common.Common; 18 | import com.ds.androideatitv2client.EventBus.CategoryClick; 19 | import com.ds.androideatitv2client.Model.CategoryModel; 20 | import com.ds.androideatitv2client.R; 21 | 22 | import org.greenrobot.eventbus.EventBus; 23 | 24 | import java.util.Collection; 25 | import java.util.List; 26 | 27 | import butterknife.BindView; 28 | import butterknife.ButterKnife; 29 | import butterknife.Unbinder; 30 | 31 | public class MyCategoriesAdapter extends RecyclerView.Adapter { 32 | 33 | Context context; 34 | List categoryModelList; 35 | 36 | public MyCategoriesAdapter(Context context, List categoryModelList) { 37 | this.context = context; 38 | this.categoryModelList = categoryModelList; 39 | } 40 | 41 | @NonNull 42 | @Override 43 | public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { 44 | return new MyViewHolder(LayoutInflater.from(context) 45 | .inflate(R.layout.layout_category_item, parent, false)); 46 | } 47 | 48 | @Override 49 | public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { 50 | Glide.with(context).load(categoryModelList.get(position).getImage()).into(holder.category_image); 51 | holder.category_name.setText(new StringBuilder(categoryModelList.get(position).getName())); 52 | 53 | //Event 54 | holder.setListener((view, pos) -> { 55 | Common.categorySelected = categoryModelList.get(pos); 56 | EventBus.getDefault().postSticky(new CategoryClick(true, categoryModelList.get(pos))); 57 | }); 58 | } 59 | 60 | @Override 61 | public int getItemCount() { 62 | return categoryModelList.size(); 63 | } 64 | 65 | public List getListCategory() { 66 | return categoryModelList; 67 | } 68 | 69 | public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { 70 | Unbinder unbinder; 71 | @BindView(R.id.img_category) 72 | ImageView category_image; 73 | @BindView(R.id.txt_category) 74 | TextView category_name; 75 | 76 | IRecyclerClickListener listener; 77 | 78 | public void setListener(IRecyclerClickListener listener) { 79 | this.listener = listener; 80 | } 81 | 82 | public MyViewHolder(@NonNull View itemView) { 83 | super(itemView); 84 | unbinder = ButterKnife.bind(this,itemView); 85 | itemView.setOnClickListener(this); 86 | } 87 | 88 | @Override 89 | public void onClick(View view) { 90 | listener.onItemClickListener(view, getAdapterPosition() ); 91 | } 92 | } 93 | 94 | 95 | @Override 96 | public int getItemViewType(int position) { 97 | if(categoryModelList.size() == 1) 98 | return Common.DEFAULT_COLUMN_COUNT; 99 | else 100 | { 101 | if(categoryModelList.size() % 2 == 0) 102 | return Common.DEFAULT_COLUMN_COUNT; 103 | else 104 | return (position > 1 && position == categoryModelList.size()-1) ? Common.FULL_WIDTH_COLUMN:Common.DEFAULT_COLUMN_COUNT; 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /androideatitv2client/Adapter/MyCommentAdapter.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Adapter; 2 | 3 | import android.content.Context; 4 | import android.text.format.DateUtils; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.RatingBar; 9 | import android.widget.TextView; 10 | 11 | import androidx.annotation.NonNull; 12 | import androidx.recyclerview.widget.RecyclerView; 13 | 14 | import com.ds.androideatitv2client.Model.CommentModel; 15 | import com.ds.androideatitv2client.R; 16 | import com.google.android.gms.common.util.DataUtils; 17 | 18 | import java.util.Date; 19 | import java.util.List; 20 | 21 | import butterknife.BindView; 22 | import butterknife.ButterKnife; 23 | import butterknife.Unbinder; 24 | 25 | public class MyCommentAdapter extends RecyclerView.Adapter { 26 | 27 | Context context; 28 | List commentModelList; 29 | 30 | public MyCommentAdapter(Context context, List commentModelList) { 31 | this.context = context; 32 | this.commentModelList = commentModelList; 33 | } 34 | 35 | @NonNull 36 | @Override 37 | public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { 38 | return new MyViewHolder(LayoutInflater.from(context) 39 | .inflate(R.layout.layout_comment_item,parent,false)); 40 | } 41 | 42 | @Override 43 | public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { 44 | Long timeStamp = Long.valueOf(commentModelList.get(position).getCommentTimeStamp().get("timeStamp").toString()); 45 | holder.txt_comment_data.setText(DateUtils.getRelativeTimeSpanString(timeStamp)); 46 | holder.txt_comment.setText(commentModelList.get(position).getComment()); 47 | holder.txt_comment_name.setText(commentModelList.get(position).getName()); 48 | holder.ratingBar.setRating(commentModelList.get(position).getRatingValue()); 49 | 50 | } 51 | 52 | 53 | @Override 54 | public int getItemCount() { 55 | return commentModelList.size(); 56 | } 57 | 58 | public class MyViewHolder extends RecyclerView.ViewHolder { 59 | private Unbinder unbinder; 60 | 61 | @BindView(R.id.txt_comment_data) 62 | TextView txt_comment_data; 63 | @BindView(R.id.txt_comment) 64 | TextView txt_comment; 65 | @BindView(R.id.txt_comment_name) 66 | TextView txt_comment_name; 67 | @BindView(R.id.rating_bar) 68 | RatingBar ratingBar; 69 | public MyViewHolder(View itemView){ 70 | super(itemView); 71 | unbinder = ButterKnife.bind(this, itemView); 72 | } 73 | 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /androideatitv2client/Adapter/MyOrderDetailAdapter.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Adapter; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.ImageView; 8 | import android.widget.TextView; 9 | 10 | import androidx.annotation.NonNull; 11 | import androidx.recyclerview.widget.RecyclerView; 12 | 13 | import com.bumptech.glide.Glide; 14 | import com.ds.androideatitv2client.Callback.IRecyclerClickListener; 15 | import com.ds.androideatitv2client.Database.CartItem; 16 | import com.ds.androideatitv2client.Model.AddonModel; 17 | import com.ds.androideatitv2client.Model.SizeModel; 18 | import com.ds.androideatitv2client.R; 19 | import com.google.gson.Gson; 20 | import com.google.gson.reflect.TypeToken; 21 | 22 | import java.util.List; 23 | 24 | import butterknife.BindView; 25 | import butterknife.ButterKnife; 26 | import butterknife.Unbinder; 27 | 28 | public class MyOrderDetailAdapter extends RecyclerView.Adapter { 29 | 30 | private Context context; 31 | List cartItemList; 32 | Gson gson; 33 | 34 | public MyOrderDetailAdapter() { 35 | } 36 | 37 | public MyOrderDetailAdapter(Context context, List cartItemList) { 38 | this.context = context; 39 | this.cartItemList = cartItemList; 40 | this.gson = new Gson(); 41 | } 42 | 43 | @NonNull 44 | @Override 45 | public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { 46 | return new MyViewHolder(LayoutInflater.from(context) 47 | .inflate(R.layout.layout_order_detail_item,parent,false)); 48 | } 49 | 50 | @Override 51 | public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { 52 | Glide.with(context) 53 | .load(cartItemList.get(position).getFoodImage()) 54 | .into(holder.img_food_image); // Load default image exists in cart 55 | 56 | holder.txt_food_name.setText(new StringBuilder().append(cartItemList.get(position).getFoodName())); 57 | holder.txt_food_quantity.setText(new StringBuilder("Quantity: ").append(cartItemList.get(position).getFoodQuantity())); 58 | try{ 59 | SizeModel sizeModel = gson.fromJson(cartItemList.get(position).getFoodSize(), new TypeToken(){}.getType()); 60 | if (sizeModel != null) 61 | holder.txt_size.setText(new StringBuilder("Size: ").append(sizeModel.getName())); 62 | 63 | }catch(Exception e){} 64 | if (!cartItemList.get(position).getFoodAddon().equals("Default")) 65 | { 66 | List addonModels = gson.fromJson(cartItemList.get(position).getFoodAddon(), new TypeToken>(){}.getType()); 67 | StringBuilder addonString = new StringBuilder(); 68 | if (addonModels != null) 69 | { 70 | for (AddonModel addonModel: addonModels) 71 | addonString.append(addonModel.getName()).append(","); 72 | addonString.delete(addonString.length()-1, addonString.length()); // Remove last "," charachter 73 | holder.txt_food_add_on.setText(new StringBuilder("Addon: ").append(addonString)); 74 | } 75 | } 76 | else 77 | holder.txt_food_add_on.setText(new StringBuilder("Addon: Default")); 78 | } 79 | 80 | 81 | @Override 82 | public int getItemCount() { 83 | return cartItemList.size(); 84 | } 85 | 86 | /* public OrderModel getItemAtPosition(int pos) { 87 | return cartItemList.get(pos); 88 | }*/ 89 | 90 | /* public void removeItem(int pos) { 91 | cartItemList.remove(pos); 92 | }*/ 93 | 94 | public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { 95 | 96 | @BindView(R.id.txt_food_name) 97 | TextView txt_food_name; 98 | @BindView(R.id.txt_food_add_on) 99 | TextView txt_food_add_on; 100 | @BindView(R.id.txt_size) 101 | TextView txt_size; 102 | @BindView(R.id.txt_food_quantity) 103 | TextView txt_food_quantity; 104 | @BindView(R.id.img_food_image) 105 | ImageView img_food_image; 106 | 107 | Unbinder unbinder; 108 | 109 | IRecyclerClickListener recyclerClickListener; 110 | 111 | public void setRecyclerClickListener(IRecyclerClickListener recyclerClickListener) { 112 | this.recyclerClickListener = recyclerClickListener; 113 | } 114 | 115 | public MyViewHolder(@NonNull View itemView) { 116 | super(itemView); 117 | unbinder = ButterKnife.bind(this, itemView); 118 | //itemView.setOnClickListener(this); 119 | } 120 | 121 | @Override 122 | public void onClick(View v) { 123 | recyclerClickListener.onItemClickListener(v, getAdapterPosition()); 124 | } 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /androideatitv2client/Adapter/MyPopularCategoriesAdapter.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Adapter; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.TextView; 8 | import android.widget.Toast; 9 | 10 | import androidx.recyclerview.widget.RecyclerView; 11 | 12 | import com.bumptech.glide.Glide; 13 | import com.ds.androideatitv2client.Callback.IRecyclerClickListener; 14 | import com.ds.androideatitv2client.EventBus.PopularCategoryClick; 15 | import com.ds.androideatitv2client.Model.PopularCategoryModel; 16 | import com.ds.androideatitv2client.R; 17 | 18 | import org.greenrobot.eventbus.EventBus; 19 | 20 | import java.util.List; 21 | 22 | import butterknife.BindView; 23 | import butterknife.ButterKnife; 24 | import butterknife.Unbinder; 25 | import de.hdodenhof.circleimageview.CircleImageView; 26 | import io.reactivex.annotations.NonNull; 27 | 28 | public class MyPopularCategoriesAdapter extends RecyclerView.Adapter { 29 | 30 | Context context; 31 | List popularCategoryModelList; 32 | 33 | public MyPopularCategoriesAdapter(Context context, List popularCategoryModelList) { 34 | this.context = context; 35 | this.popularCategoryModelList = popularCategoryModelList; 36 | } 37 | 38 | @NonNull 39 | @Override 40 | public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { 41 | return new MyViewHolder(LayoutInflater.from(context) 42 | .inflate(R.layout.layout_popular_categories_item, parent, false)); 43 | } 44 | 45 | @Override 46 | public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { 47 | Glide.with(context).load(popularCategoryModelList.get(position).getImage()) 48 | .into(holder.category_image); 49 | holder.txt_category_name.setText(popularCategoryModelList.get(position).getName()); 50 | 51 | holder.setListener((view, pos) -> 52 | //Toast.makeText(context, ""+popularCategoryModelList.get(pos).getName(), Toast.LENGTH_SHORT).show() 53 | EventBus.getDefault().postSticky(new PopularCategoryClick(popularCategoryModelList.get(pos))) 54 | ); 55 | } 56 | 57 | @Override 58 | public int getItemCount() { 59 | return popularCategoryModelList.size(); 60 | } 61 | 62 | public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { 63 | Unbinder unbinder; 64 | 65 | @BindView(R.id.txt_category_name) 66 | TextView txt_category_name; 67 | @BindView(R.id.category_image) 68 | CircleImageView category_image; 69 | 70 | IRecyclerClickListener listener; 71 | 72 | public void setListener(IRecyclerClickListener listener) { 73 | this.listener = listener; 74 | } 75 | 76 | public MyViewHolder(@NonNull View itemView) { 77 | super(itemView); 78 | unbinder = ButterKnife.bind(this,itemView); 79 | itemView.setOnClickListener(this); 80 | } 81 | 82 | @Override 83 | public void onClick(View view) { 84 | listener.onItemClickListener(view, getAdapterPosition()); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /androideatitv2client/Callback/IBestDealCallbackListener.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Callback; 2 | 3 | import com.ds.androideatitv2client.Model.BestDealModel; 4 | import com.ds.androideatitv2client.Model.PopularCategoryModel; 5 | 6 | import java.util.List; 7 | 8 | public interface IBestDealCallbackListener { 9 | void onBestDealLoadSuccess(List BestDealModels); 10 | void onBestDealLoadFailed(String message); 11 | } 12 | -------------------------------------------------------------------------------- /androideatitv2client/Callback/ICategoryCallbackListener.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Callback; 2 | 3 | import com.ds.androideatitv2client.Model.CategoryModel; 4 | 5 | import java.util.List; 6 | 7 | public interface ICategoryCallbackListener { 8 | void onCategoryLoadSuccess(List categoryModelList); 9 | void onCategoryLoadFailed(String message); 10 | } 11 | -------------------------------------------------------------------------------- /androideatitv2client/Callback/ICommentCallbackListener.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Callback; 2 | 3 | import com.ds.androideatitv2client.Model.CommentModel; 4 | 5 | import java.util.List; 6 | 7 | public interface ICommentCallbackListener { 8 | void onCommentLoadSuccess(List commentModels); 9 | void onCommentLoadFailed(String message); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /androideatitv2client/Callback/ILoadOrderCallbackListener.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Callback; 2 | 3 | import com.ds.androideatitv2client.Model.OrderModel; 4 | 5 | import java.util.List; 6 | 7 | public interface ILoadOrderCallbackListener { 8 | void onLoadOrderSuccess(List orderModelList); 9 | void onLoadOrderFailed(String message); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /androideatitv2client/Callback/ILoadTimeFromFirebaseListener.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Callback; 2 | 3 | import com.ds.androideatitv2client.Model.OrderModel; 4 | 5 | public interface ILoadTimeFromFirebaseListener { 6 | void onLoadTimeSuccess(OrderModel orderModel, long estimateTimeInMs); 7 | void onLoadTimeFailed(String message); 8 | } 9 | -------------------------------------------------------------------------------- /androideatitv2client/Callback/IPopularCallbackListener.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Callback; 2 | 3 | import com.ds.androideatitv2client.Model.PopularCategoryModel; 4 | 5 | import java.util.List; 6 | 7 | public interface IPopularCallbackListener { 8 | void onPopularLoadSuccess(List popularCategoryModels); 9 | void onPopularLoadFailed(String message); 10 | } 11 | -------------------------------------------------------------------------------- /androideatitv2client/Callback/IRecyclerClickListener.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Callback; 2 | 3 | import android.view.View; 4 | 5 | public interface IRecyclerClickListener { 6 | void onItemClickListener(View view, int pos); 7 | } 8 | -------------------------------------------------------------------------------- /androideatitv2client/Callback/MyButtonClickListener.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Callback; 2 | 3 | public interface MyButtonClickListener { 4 | void onClick(int pos); 5 | 6 | } 7 | -------------------------------------------------------------------------------- /androideatitv2client/Common/SpacesItemDecoration.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Common; 2 | 3 | import android.graphics.Rect; 4 | import android.view.View; 5 | 6 | import androidx.annotation.NonNull; 7 | import androidx.recyclerview.widget.RecyclerView; 8 | 9 | public class SpacesItemDecoration extends RecyclerView.ItemDecoration { 10 | int space; 11 | 12 | public SpacesItemDecoration(int space) { 13 | this.space = space; 14 | } 15 | 16 | @Override 17 | public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { 18 | super.getItemOffsets(outRect, view, parent, state); 19 | outRect.top = outRect.bottom = outRect.left = outRect.right = space; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /androideatitv2client/Database/CartDAO.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Database; 2 | 3 | import androidx.room.Dao; 4 | import androidx.room.Delete; 5 | import androidx.room.Insert; 6 | import androidx.room.OnConflictStrategy; 7 | import androidx.room.Query; 8 | import androidx.room.Update; 9 | 10 | import java.util.List; 11 | 12 | import io.reactivex.Completable; 13 | import io.reactivex.Flowable; 14 | import io.reactivex.Single; 15 | 16 | @Dao 17 | public interface CartDAO { 18 | @Query("SELECT * FROM Cart WHERE uid=:uid") 19 | Flowable> getAllCart(String uid); 20 | 21 | @Query("SELECT SUM(foodQuantity) from Cart WHERE uid=:uid") 22 | Single countItemInCart(String uid); 23 | 24 | @Query("SELECT SUM((foodPrice+foodExtraPrice)*foodQuantity) FROM Cart WHERE uid=:uid") 25 | Single sumPriceInCart(String uid); 26 | 27 | @Query("SELECT * FROM Cart WHERE foodId=:foodId AND uid=:uid") 28 | Single getItemInCart(String foodId, String uid); 29 | 30 | @Insert(onConflict = OnConflictStrategy.REPLACE) 31 | Completable insertOrReplaceAll(CartItem... cartItems); 32 | 33 | @Update(onConflict = OnConflictStrategy.REPLACE) 34 | Single updateCartItems(CartItem cartItem); 35 | 36 | @Delete 37 | Single deleteCartItem(CartItem cartItem); 38 | 39 | @Query("DELETE FROM Cart WHERE uid=:uid") 40 | Single cleanCart(String uid); 41 | 42 | @Query("SELECT * FROM Cart WHERE foodId=:foodId AND uid=:uid AND foodSize=:foodSize AND foodAddon=:foodAddon") 43 | Single getItemWithAllOptionsInCart(String foodId, String uid, String foodSize, String foodAddon); 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /androideatitv2client/Database/CartDataSource.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Database; 2 | 3 | import androidx.room.Delete; 4 | import androidx.room.Insert; 5 | import androidx.room.OnConflictStrategy; 6 | import androidx.room.Query; 7 | import androidx.room.Update; 8 | 9 | import java.util.List; 10 | 11 | import io.reactivex.Completable; 12 | import io.reactivex.Flowable; 13 | import io.reactivex.Single; 14 | 15 | public interface CartDataSource { 16 | Flowable> getAllCart(String uid); 17 | 18 | Single countItemInCart(String uid); 19 | 20 | Single sumPriceInCart(String uid); 21 | 22 | Single getItemInCart(String foodId, String uid); 23 | 24 | Completable insertOrReplaceAll(CartItem... cartItems); 25 | 26 | Single updateCartItems(CartItem cartItem); 27 | 28 | Single deleteCartItem(CartItem cartItem); 29 | 30 | Single cleanCart(String uid); 31 | 32 | Single getItemWithAllOptionsInCart(String foodId, String uid, String foodSize, String foodAddon); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /androideatitv2client/Database/CartDatabase.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Database; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.room.Database; 6 | import androidx.room.Room; 7 | import androidx.room.RoomDatabase; 8 | 9 | @Database(version = 1,entities = CartItem.class,exportSchema = false) 10 | public abstract class CartDatabase extends RoomDatabase { 11 | public abstract CartDAO cartDAO(); 12 | private static CartDatabase instance; 13 | 14 | public static CartDatabase getInstance(Context context) { 15 | if(instance == null) 16 | instance = Room.databaseBuilder(context,CartDatabase.class,"EatItV2DB2").build(); 17 | return instance; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /androideatitv2client/Database/CartItem.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Database; 2 | 3 | 4 | import androidx.annotation.NonNull; 5 | import androidx.annotation.Nullable; 6 | import androidx.room.ColumnInfo; 7 | import androidx.room.Entity; 8 | import androidx.room.PrimaryKey; 9 | 10 | 11 | 12 | @Entity(tableName = "Cart", primaryKeys = {"uid", "foodId", "foodAddon", "foodSize"}) 13 | public class CartItem { 14 | @NonNull 15 | @ColumnInfo(name = "foodId") 16 | public String foodId; 17 | 18 | @ColumnInfo(name = "foodName") 19 | private String foodName; 20 | 21 | @ColumnInfo(name = "foodImage") 22 | private String foodImage; 23 | 24 | @ColumnInfo(name = "foodPrice") 25 | private Double foodPrice; 26 | 27 | @ColumnInfo(name = "foodQuantity") 28 | private int foodQuantity; 29 | 30 | @ColumnInfo(name = "userPhone") 31 | private String userPhone; 32 | 33 | @ColumnInfo(name = "foodExtraPrice") 34 | private Double foodExtraPrice; 35 | 36 | @NonNull 37 | @ColumnInfo(name = "foodAddon") 38 | private String foodAddon; 39 | 40 | @NonNull 41 | @ColumnInfo(name = "foodSize") 42 | private String foodSize; 43 | 44 | @NonNull 45 | @ColumnInfo(name = "uid") 46 | private String uid; 47 | 48 | 49 | @NonNull 50 | public String getFoodId() { 51 | return foodId; 52 | } 53 | 54 | public void setFoodId(@NonNull String foodId) { 55 | this.foodId = foodId; 56 | } 57 | 58 | public String getFoodName() { 59 | return foodName; 60 | } 61 | 62 | public void setFoodName(String foodName) { 63 | this.foodName = foodName; 64 | } 65 | 66 | public String getFoodImage() { 67 | return foodImage; 68 | } 69 | 70 | public void setFoodImage(String foodImage) { 71 | this.foodImage = foodImage; 72 | } 73 | 74 | public Double getFoodPrice() { 75 | return foodPrice; 76 | } 77 | 78 | public void setFoodPrice(Double foodPrice) { 79 | this.foodPrice = foodPrice; 80 | } 81 | 82 | public int getFoodQuantity() { 83 | return foodQuantity; 84 | } 85 | 86 | public void setFoodQuantity(int foodQuantity) { 87 | this.foodQuantity = foodQuantity; 88 | } 89 | 90 | public String getUserPhone() { 91 | return userPhone; 92 | } 93 | 94 | public void setUserPhone(String userPhone) { 95 | this.userPhone = userPhone; 96 | } 97 | 98 | public Double getFoodExtraPrice() { 99 | return foodExtraPrice; 100 | } 101 | 102 | public void setFoodExtraPrice(Double foodExtraPrice) { 103 | this.foodExtraPrice = foodExtraPrice; 104 | } 105 | 106 | public String getFoodAddon() { 107 | return foodAddon; 108 | } 109 | 110 | public void setFoodAddon(String foodAddon) { 111 | this.foodAddon = foodAddon; 112 | } 113 | 114 | public String getFoodSize() { 115 | return foodSize; 116 | } 117 | 118 | public void setFoodSize(String foodSize) { 119 | this.foodSize = foodSize; 120 | } 121 | 122 | public String getUid() { 123 | return uid; 124 | } 125 | 126 | public void setUid(String uid) { 127 | this.uid = uid; 128 | } 129 | 130 | @Override 131 | public boolean equals(@Nullable Object obj) { 132 | if(obj == this) 133 | return true; 134 | if(!(obj instanceof CartItem)) 135 | return false; 136 | CartItem cartItem = (CartItem)obj; 137 | 138 | return cartItem.getFoodId().equals(this.foodId) && 139 | cartItem.getFoodAddon().equals(this.foodAddon) && 140 | cartItem.getFoodSize().equals(this.foodSize); 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /androideatitv2client/Database/LocalCartDataSource.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Database; 2 | 3 | import java.util.List; 4 | 5 | import io.reactivex.Completable; 6 | import io.reactivex.Flowable; 7 | import io.reactivex.Single; 8 | 9 | public class LocalCartDataSource implements CartDataSource { 10 | 11 | 12 | private CartDAO cartDAO; 13 | 14 | public LocalCartDataSource(CartDAO cartDAO) { 15 | this.cartDAO = cartDAO; 16 | } 17 | 18 | @Override 19 | public Flowable> getAllCart(String uid) { 20 | return cartDAO.getAllCart(uid); 21 | } 22 | 23 | @Override 24 | public Single countItemInCart(String uid) { 25 | return cartDAO.countItemInCart(uid); 26 | } 27 | 28 | @Override 29 | public Single sumPriceInCart(String uid) { 30 | return cartDAO.sumPriceInCart(uid); 31 | } 32 | 33 | @Override 34 | public Single getItemInCart(String foodId, String uid) { 35 | return cartDAO.getItemInCart(foodId,uid); 36 | } 37 | 38 | @Override 39 | public Completable insertOrReplaceAll(CartItem... cartItems) { 40 | return cartDAO.insertOrReplaceAll(cartItems); 41 | } 42 | 43 | @Override 44 | public Single updateCartItems(CartItem cartItem) { 45 | return cartDAO.updateCartItems(cartItem); 46 | } 47 | 48 | @Override 49 | public Single deleteCartItem(CartItem cartItem) { 50 | return cartDAO.deleteCartItem(cartItem); 51 | } 52 | 53 | @Override 54 | public Single cleanCart(String uid) { 55 | return cartDAO.cleanCart(uid); 56 | } 57 | 58 | @Override 59 | public Single getItemWithAllOptionsInCart(String foodId, String uid, String foodSize, String foodAddon) { 60 | return cartDAO.getItemWithAllOptionsInCart(uid,foodId,foodSize,foodAddon); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /androideatitv2client/EventBus/BestDealItemClick.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.EventBus; 2 | 3 | import com.ds.androideatitv2client.Model.BestDealModel; 4 | 5 | public class BestDealItemClick { 6 | private BestDealModel bestDealModel; 7 | 8 | public BestDealItemClick(BestDealModel bestDealModel) { 9 | this.bestDealModel = bestDealModel; 10 | } 11 | 12 | public BestDealModel getBestDealModel() { 13 | return bestDealModel; 14 | } 15 | 16 | public void setBestDealModel(BestDealModel bestDealModel) { 17 | this.bestDealModel = bestDealModel; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /androideatitv2client/EventBus/CategoryClick.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.EventBus; 2 | 3 | import com.ds.androideatitv2client.Model.CategoryModel; 4 | 5 | public class CategoryClick { 6 | private boolean success; 7 | private CategoryModel categoryModel; 8 | 9 | public CategoryClick(boolean success, CategoryModel categoryModel) { 10 | this.success = success; 11 | this.categoryModel = categoryModel; 12 | } 13 | 14 | public boolean isSuccess() { 15 | return success; 16 | } 17 | 18 | public void setSuccess(boolean success) { 19 | this.success = success; 20 | } 21 | 22 | public CategoryModel getCategoryModel() { 23 | return categoryModel; 24 | } 25 | 26 | public void setCategoryModel(CategoryModel categoryModel) { 27 | this.categoryModel = categoryModel; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /androideatitv2client/EventBus/CounterCartEvent.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.EventBus; 2 | 3 | public class CounterCartEvent { 4 | private boolean success; 5 | 6 | public CounterCartEvent(boolean success) { 7 | this.success = success; 8 | } 9 | 10 | public boolean isSuccess() { 11 | return success; 12 | } 13 | 14 | public void setSuccess(boolean success) { 15 | this.success = success; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /androideatitv2client/EventBus/FoodItemClick.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.EventBus; 2 | 3 | import com.ds.androideatitv2client.Model.FoodModel; 4 | 5 | public class FoodItemClick { 6 | private boolean success; 7 | private FoodModel foodModel; 8 | 9 | public FoodItemClick(boolean success, FoodModel foodModel) { 10 | this.success = success; 11 | this.foodModel = foodModel; 12 | } 13 | 14 | public boolean isSuccess() { 15 | return success; 16 | } 17 | 18 | public void setSuccess(boolean success) { 19 | this.success = success; 20 | } 21 | 22 | public FoodModel getFoodModel() { 23 | return foodModel; 24 | } 25 | 26 | public void setFoodModel(FoodModel foodModel) { 27 | this.foodModel = foodModel; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /androideatitv2client/EventBus/HideFABCart.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.EventBus; 2 | 3 | public class HideFABCart { 4 | private boolean hidden; 5 | 6 | public HideFABCart(boolean hidden) { 7 | this.hidden = hidden; 8 | } 9 | 10 | public boolean isHidden() { 11 | return hidden; 12 | } 13 | 14 | public void setHidden(boolean hidden) { 15 | this.hidden = hidden; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /androideatitv2client/EventBus/MenuItemBack.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.EventBus; 2 | 3 | public class MenuItemBack { 4 | public MenuItemBack() { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /androideatitv2client/EventBus/PopularCategoryClick.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.EventBus; 2 | 3 | import com.ds.androideatitv2client.Model.PopularCategoryModel; 4 | 5 | public class PopularCategoryClick { 6 | private PopularCategoryModel popularCategoryModel; 7 | 8 | public PopularCategoryClick(PopularCategoryModel popularCategoryModel) { 9 | this.popularCategoryModel = popularCategoryModel; 10 | } 11 | 12 | public PopularCategoryModel getPopularCategoryModel() { 13 | return popularCategoryModel; 14 | } 15 | 16 | public void setPopularCategoryModel(PopularCategoryModel popularCategoryModel) { 17 | this.popularCategoryModel = popularCategoryModel; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /androideatitv2client/EventBus/UpdateItemInCart.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.EventBus; 2 | 3 | import com.ds.androideatitv2client.Database.CartItem; 4 | 5 | public class UpdateItemInCart { 6 | private CartItem cartItem; 7 | 8 | public UpdateItemInCart(CartItem cartItem) { 9 | this.cartItem = cartItem; 10 | } 11 | 12 | public CartItem getCartItem() { 13 | return cartItem; 14 | } 15 | 16 | public void setCartItem(CartItem cartItem) { 17 | this.cartItem = cartItem; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /androideatitv2client/Model/AddonModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Model; 2 | 3 | public class AddonModel { 4 | private String name; 5 | private Long price; 6 | 7 | public AddonModel() { 8 | } 9 | 10 | public String getName() { 11 | return name; 12 | } 13 | 14 | public void setName(String name) { 15 | this.name = name; 16 | } 17 | 18 | public Long getPrice() { 19 | return price; 20 | } 21 | 22 | public void setPrice(Long price) { 23 | this.price = price; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /androideatitv2client/Model/BestDealModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Model; 2 | 3 | public class BestDealModel { 4 | private String menu_id,food_id,name,image; 5 | 6 | public BestDealModel() { 7 | } 8 | 9 | public BestDealModel(String menu_id, String food_id, String name, String image) { 10 | this.menu_id = menu_id; 11 | this.food_id = food_id; 12 | this.name = name; 13 | this.image = image; 14 | } 15 | 16 | public String getMenu_id() { 17 | return menu_id; 18 | } 19 | 20 | public void setMenu_id(String menu_id) { 21 | this.menu_id = menu_id; 22 | } 23 | 24 | public String getFood_id() { 25 | return food_id; 26 | } 27 | 28 | public void setFood_id(String food_id) { 29 | this.food_id = food_id; 30 | } 31 | 32 | public String getName() { 33 | return name; 34 | } 35 | 36 | public void setName(String name) { 37 | this.name = name; 38 | } 39 | 40 | public String getImage() { 41 | return image; 42 | } 43 | 44 | public void setImage(String image) { 45 | this.image = image; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /androideatitv2client/Model/BraintreeToken.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Model; 2 | 3 | public class BraintreeToken { 4 | private boolean error; 5 | private String token; 6 | 7 | public BraintreeToken() { 8 | } 9 | 10 | public boolean isError() { 11 | return error; 12 | } 13 | 14 | public void setError(boolean error) { 15 | this.error = error; 16 | } 17 | 18 | public String getToken() { 19 | return token; 20 | } 21 | 22 | public void setToken(String token) { 23 | this.token = token; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /androideatitv2client/Model/BraintreeTransaction.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Model; 2 | 3 | public class BraintreeTransaction { 4 | private boolean success; 5 | private Transaction transaction; 6 | 7 | public BraintreeTransaction() { 8 | } 9 | 10 | public boolean isSuccess() { 11 | return success; 12 | } 13 | 14 | public void setSuccess(boolean success) { 15 | this.success = success; 16 | } 17 | 18 | public Transaction getTransaction() { 19 | return transaction; 20 | } 21 | 22 | public void setTransaction(Transaction transaction) { 23 | this.transaction = transaction; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /androideatitv2client/Model/CategoryModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Model; 2 | 3 | import java.util.List; 4 | 5 | public class CategoryModel { 6 | private String menu_id,name,image; 7 | List foods; 8 | 9 | public CategoryModel() { 10 | } 11 | 12 | public String getMenu_id() { 13 | return menu_id; 14 | } 15 | 16 | public void setMenu_id(String menu_id) { 17 | this.menu_id = menu_id; 18 | } 19 | 20 | public String getName() { 21 | return name; 22 | } 23 | 24 | public void setName(String name) { 25 | this.name = name; 26 | } 27 | 28 | public String getImage() { 29 | return image; 30 | } 31 | 32 | public void setImage(String image) { 33 | this.image = image; 34 | } 35 | 36 | public List getFoods() { 37 | return foods; 38 | } 39 | 40 | public void setFoods(List foods) { 41 | this.foods = foods; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /androideatitv2client/Model/CommentModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Model; 2 | 3 | import java.util.Map; 4 | 5 | import javax.xml.namespace.QName; 6 | 7 | public class CommentModel { 8 | private float ratingValue; 9 | private String comment, name, uid; 10 | private Map commentTimeStamp; 11 | 12 | public CommentModel() { 13 | } 14 | 15 | public float getRatingValue() { 16 | return ratingValue; 17 | } 18 | 19 | public void setRatingValue(float ratingValue) { 20 | this.ratingValue = ratingValue; 21 | } 22 | 23 | public String getComment() { 24 | return comment; 25 | } 26 | 27 | public void setComment(String comment) { 28 | this.comment = comment; 29 | } 30 | 31 | public String getName() { 32 | return name; 33 | } 34 | 35 | public void setName(String name) { 36 | this.name = name; 37 | } 38 | 39 | public String getUid() { 40 | return uid; 41 | } 42 | 43 | public void setUid(String uid) { 44 | this.uid = uid; 45 | } 46 | 47 | public Map getCommentTimeStamp() { 48 | return commentTimeStamp; 49 | } 50 | 51 | public void setCommentTimeStamp(Map commentTimeStamp) { 52 | this.commentTimeStamp = commentTimeStamp; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /androideatitv2client/Model/FCMResponse.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Model; 2 | 3 | import java.util.List; 4 | 5 | public class FCMResponse { 6 | private long multicast_id; 7 | private int success, failure, canonical_ids; 8 | private List results; 9 | private long message_id; 10 | 11 | public FCMResponse() { 12 | } 13 | 14 | public long getMulticast_id() { 15 | return multicast_id; 16 | } 17 | 18 | public void setMulticast_id(long multicast_id) { 19 | this.multicast_id = multicast_id; 20 | } 21 | 22 | public int getSuccess() { 23 | return success; 24 | } 25 | 26 | public void setSuccess(int success) { 27 | this.success = success; 28 | } 29 | 30 | public int getFailure() { 31 | return failure; 32 | } 33 | 34 | public void setFailure(int failure) { 35 | this.failure = failure; 36 | } 37 | 38 | public int getCanonical_ids() { 39 | return canonical_ids; 40 | } 41 | 42 | public void setCanonical_ids(int canonical_ids) { 43 | this.canonical_ids = canonical_ids; 44 | } 45 | 46 | public List getResults() { 47 | return results; 48 | } 49 | 50 | public void setResults(List results) { 51 | this.results = results; 52 | } 53 | 54 | public long getMessage_id() { 55 | return message_id; 56 | } 57 | 58 | public void setMessage_id(long message_id) { 59 | this.message_id = message_id; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /androideatitv2client/Model/FCMResult.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Model; 2 | 3 | public class FCMResult { 4 | private String message_id; 5 | 6 | public FCMResult() { 7 | } 8 | 9 | public FCMResult(String message_id) { 10 | this.message_id = message_id; 11 | } 12 | 13 | public String getMessage_id() { 14 | return message_id; 15 | } 16 | 17 | public void setMessage_id(String message_id) { 18 | this.message_id = message_id; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /androideatitv2client/Model/FCMSendData.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Model; 2 | 3 | import java.util.Map; 4 | 5 | public class FCMSendData { 6 | private String to; 7 | private Map data; 8 | 9 | public FCMSendData() { 10 | } 11 | 12 | public FCMSendData(String to, Map data) { 13 | this.to = to; 14 | this.data = data; 15 | } 16 | 17 | public String getTo() { 18 | return to; 19 | } 20 | 21 | public void setTo(String to) { 22 | this.to = to; 23 | } 24 | 25 | public Map getData() { 26 | return data; 27 | } 28 | 29 | public void setData(Map data) { 30 | this.data = data; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /androideatitv2client/Model/FoodModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Model; 2 | 3 | import java.util.List; 4 | 5 | public class FoodModel { 6 | private String key; 7 | private String name,image,id,description; 8 | private Long price; 9 | private List addon; 10 | private List size; 11 | private Double ratingValue; 12 | private Long ratingCount; 13 | 14 | 15 | private List userSelectedAddon; 16 | private SizeModel userSelectedSize; 17 | 18 | public FoodModel() { 19 | 20 | } 21 | 22 | public String getName() { 23 | return name; 24 | } 25 | 26 | public String getImage() { 27 | return image; 28 | } 29 | 30 | public String getId() { 31 | return id; 32 | } 33 | 34 | public String getDescription() { 35 | return description; 36 | } 37 | 38 | public Long getPrice() { 39 | return price; 40 | } 41 | 42 | public List getAddon() { 43 | return addon; 44 | } 45 | 46 | public List getSize() { 47 | return size; 48 | } 49 | 50 | public String getKey() { 51 | return key; 52 | } 53 | 54 | public void setKey(String key) { 55 | this.key = key; 56 | } 57 | 58 | public Double getRatingValue() { 59 | return ratingValue; 60 | } 61 | 62 | public void setRatingValue(Double ratingValue) { 63 | this.ratingValue = ratingValue; 64 | } 65 | 66 | public Long getRatingCount() { 67 | return ratingCount; 68 | } 69 | 70 | public void setRatingCount(Long ratingCount) { 71 | this.ratingCount = ratingCount; 72 | } 73 | 74 | public List getUserSelectedAddon() { 75 | return userSelectedAddon; 76 | } 77 | 78 | public void setUserSelectedAddon(List userSelectedAddon) { 79 | this.userSelectedAddon = userSelectedAddon; 80 | } 81 | 82 | public SizeModel getUserSelectedSize() { 83 | return userSelectedSize; 84 | } 85 | 86 | public void setUserSelectedSize(SizeModel userSelectedSize) { 87 | this.userSelectedSize = userSelectedSize; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /androideatitv2client/Model/OrderModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Model; 2 | 3 | import com.ds.androideatitv2client.Database.CartItem; 4 | 5 | import java.util.List; 6 | 7 | public class OrderModel { 8 | private String key,userId, userName, userPhone,shippingAddress,comment, transactionId; 9 | private double lat,lng,totalPayment,finalPayment; 10 | private boolean cod; 11 | private int discount; 12 | private List cartItemList; 13 | private long createDate; 14 | private String orderNumber; 15 | private int orderStatus; 16 | 17 | public OrderModel() { 18 | } 19 | 20 | public String getUserId() { 21 | return userId; 22 | } 23 | 24 | public void setUserId(String userId) { 25 | this.userId = userId; 26 | } 27 | 28 | public String getUserName() { 29 | return userName; 30 | } 31 | 32 | public void setUserName(String userName) { 33 | this.userName = userName; 34 | } 35 | 36 | public String getUserPhone() { 37 | return userPhone; 38 | } 39 | 40 | public void setUserPhone(String userPhone) { 41 | this.userPhone = userPhone; 42 | } 43 | 44 | public String getShippingAddress() { 45 | return shippingAddress; 46 | } 47 | 48 | public void setShippingAddress(String shippingAddress) { 49 | this.shippingAddress = shippingAddress; 50 | } 51 | 52 | public String getComment() { 53 | return comment; 54 | } 55 | 56 | public void setComment(String comment) { 57 | this.comment = comment; 58 | } 59 | 60 | public String getTransactionId() { 61 | return transactionId; 62 | } 63 | 64 | public void setTransactionId(String transactionId) { 65 | this.transactionId = transactionId; 66 | } 67 | 68 | public double getLat() { 69 | return lat; 70 | } 71 | 72 | public void setLat(double lat) { 73 | this.lat = lat; 74 | } 75 | 76 | public double getLng() { 77 | return lng; 78 | } 79 | 80 | public void setLng(double lng) { 81 | this.lng = lng; 82 | } 83 | 84 | public double getTotalPayment() { 85 | return totalPayment; 86 | } 87 | 88 | public void setTotalPayment(double totalPayment) { 89 | this.totalPayment = totalPayment; 90 | } 91 | 92 | public double getFinalPayment() { 93 | return finalPayment; 94 | } 95 | 96 | public void setFinalPayment(double finalPayment) { 97 | this.finalPayment = finalPayment; 98 | } 99 | 100 | public boolean isCod() { 101 | return cod; 102 | } 103 | 104 | public void setCod(boolean cod) { 105 | this.cod = cod; 106 | } 107 | 108 | public int getDiscount() { 109 | return discount; 110 | } 111 | 112 | public void setDiscount(int discount) { 113 | this.discount = discount; 114 | } 115 | 116 | public List getCartItemList() { 117 | return cartItemList; 118 | } 119 | 120 | public void setCartItemList(List cartItemList) { 121 | this.cartItemList = cartItemList; 122 | } 123 | 124 | public long getCreateDate() { 125 | return createDate; 126 | } 127 | 128 | public void setCreateDate(long createDate) { 129 | this.createDate = createDate; 130 | } 131 | 132 | public String getOrderNumber() { 133 | return orderNumber; 134 | } 135 | 136 | public void setOrderNumber(String orderNumber) { 137 | this.orderNumber = orderNumber; 138 | } 139 | 140 | public int getOrderStatus() { 141 | return orderStatus; 142 | } 143 | 144 | public void setOrderStatus(int orderStatus) { 145 | this.orderStatus = orderStatus; 146 | } 147 | 148 | public String getKey() { 149 | return key; 150 | } 151 | 152 | public void setKey(String key) { 153 | this.key = key; 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /androideatitv2client/Model/PopularCategoryModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Model; 2 | 3 | public class PopularCategoryModel { 4 | private String menu_id,food_id,name,image; 5 | 6 | public PopularCategoryModel(){ 7 | 8 | } 9 | 10 | public PopularCategoryModel(String menu_id, String food_id, String name, String image) { 11 | this.menu_id = menu_id; 12 | this.food_id = food_id; 13 | this.name = name; 14 | this.image = image; 15 | } 16 | 17 | public String getMenu_id() { 18 | return menu_id; 19 | } 20 | 21 | public void setMenu_id(String menu_id) { 22 | this.menu_id = menu_id; 23 | } 24 | 25 | public String getFood_id() { 26 | return food_id; 27 | } 28 | 29 | public void setFood_id(String food_id) { 30 | this.food_id = food_id; 31 | } 32 | 33 | public String getName() { 34 | return name; 35 | } 36 | 37 | public void setName(String name) { 38 | this.name = name; 39 | } 40 | 41 | public String getImage() { 42 | return image; 43 | } 44 | 45 | public void setImage(String image) { 46 | this.image = image; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /androideatitv2client/Model/RefundRequestModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Model; 2 | 3 | public class RefundRequestModel { 4 | private String name, phone, cardName,cardNumber, cardExp; 5 | private boolean isDone; 6 | private double amount; 7 | 8 | public RefundRequestModel() { 9 | } 10 | 11 | public String getName() { 12 | return name; 13 | } 14 | 15 | public void setName(String name) { 16 | this.name = name; 17 | } 18 | 19 | public String getPhone() { 20 | return phone; 21 | } 22 | 23 | public void setPhone(String phone) { 24 | this.phone = phone; 25 | } 26 | 27 | public String getCardName() { 28 | return cardName; 29 | } 30 | 31 | public void setCardName(String cardName) { 32 | this.cardName = cardName; 33 | } 34 | 35 | public String getCardExp() { 36 | return cardExp; 37 | } 38 | 39 | public void setCardExp(String cardExp) { 40 | this.cardExp = cardExp; 41 | } 42 | 43 | public boolean isDone() { 44 | return isDone; 45 | } 46 | 47 | public void setDone(boolean done) { 48 | isDone = done; 49 | } 50 | 51 | public String getCardNumber() { 52 | return cardNumber; 53 | } 54 | 55 | public void setCardNumber(String cardNumber) { 56 | this.cardNumber = cardNumber; 57 | } 58 | 59 | public double getAmount() { 60 | return amount; 61 | } 62 | 63 | public void setAmount(double amount) { 64 | this.amount = amount; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /androideatitv2client/Model/ShippingOrderModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Model; 2 | 3 | 4 | public class ShippingOrderModel { 5 | private String key, shipperPhone, shipperName; 6 | private double currentLat, currentLng; 7 | private OrderModel orderModel; 8 | private boolean isStartTrip; 9 | 10 | public ShippingOrderModel() { 11 | } 12 | 13 | public String getKey() { 14 | return key; 15 | } 16 | 17 | public void setKey(String key) { 18 | this.key = key; 19 | } 20 | 21 | public String getShipperPhone() { 22 | return shipperPhone; 23 | } 24 | 25 | 26 | 27 | public void setShipperPhone(String shipperPhone) { 28 | this.shipperPhone = shipperPhone; 29 | } 30 | 31 | public String getShipperName() { 32 | return shipperName; 33 | } 34 | 35 | public void setShipperName(String shipperName) { 36 | this.shipperName = shipperName; 37 | } 38 | 39 | public double getCurrentLat() { 40 | return currentLat; 41 | } 42 | 43 | public void setCurrentLat(double currentLat) { 44 | this.currentLat = currentLat; 45 | } 46 | 47 | public double getCurrentLng() { 48 | return currentLng; 49 | } 50 | 51 | public void setCurrentLng(double currentLng) { 52 | this.currentLng = currentLng; 53 | } 54 | 55 | public OrderModel getOrderModel() { 56 | return orderModel; 57 | } 58 | 59 | public void setOrderModel(OrderModel orderModel) { 60 | this.orderModel = orderModel; 61 | } 62 | 63 | public boolean isStartTrip() { 64 | return isStartTrip; 65 | } 66 | 67 | public void setStartTrip(boolean startTrip) { 68 | isStartTrip = startTrip; 69 | } 70 | } 71 | 72 | -------------------------------------------------------------------------------- /androideatitv2client/Model/SizeModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Model; 2 | 3 | public class SizeModel { 4 | private String name; 5 | private Long price; 6 | 7 | public SizeModel() { 8 | } 9 | 10 | public String getName() { 11 | return name; 12 | } 13 | 14 | public void setName(String name) { 15 | this.name = name; 16 | } 17 | 18 | public Long getPrice() { 19 | return price; 20 | } 21 | 22 | public void setPrice(Long price) { 23 | this.price = price; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /androideatitv2client/Model/TokenModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Model; 2 | 3 | public class TokenModel { 4 | private String phone, token; 5 | 6 | public TokenModel() { 7 | } 8 | 9 | public TokenModel(String phone, String token) { 10 | this.phone = phone; 11 | this.token = token; 12 | } 13 | 14 | public String getPhone() { 15 | return phone; 16 | } 17 | 18 | public void setPhone(String phone) { 19 | this.phone = phone; 20 | } 21 | 22 | public String getToken() { 23 | return token; 24 | } 25 | 26 | public void setToken(String token) { 27 | this.token = token; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /androideatitv2client/Model/Transaction.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Model; 2 | 3 | public class Transaction { 4 | private String id, status, type, currencyIsoCode, amount, merchantAccountId, subMerchantAccountId; 5 | private String masterMerchantAccountId, orderId, createAt, updateAt; 6 | 7 | public Transaction() { 8 | } 9 | 10 | public String getId() { 11 | return id; 12 | } 13 | 14 | public void setId(String id) { 15 | this.id = id; 16 | } 17 | 18 | public String getStatus() { 19 | return status; 20 | } 21 | 22 | public void setStatus(String status) { 23 | this.status = status; 24 | } 25 | 26 | public String getType() { 27 | return type; 28 | } 29 | 30 | public void setType(String type) { 31 | this.type = type; 32 | } 33 | 34 | public String getCurrencyIsoCode() { 35 | return currencyIsoCode; 36 | } 37 | 38 | public void setCurrencyIsoCode(String currencyIsoCode) { 39 | this.currencyIsoCode = currencyIsoCode; 40 | } 41 | 42 | public String getAmount() { 43 | return amount; 44 | } 45 | 46 | public void setAmount(String amount) { 47 | this.amount = amount; 48 | } 49 | 50 | public String getMerchantAccountId() { 51 | return merchantAccountId; 52 | } 53 | 54 | public void setMerchantAccountId(String merchantAccountId) { 55 | this.merchantAccountId = merchantAccountId; 56 | } 57 | 58 | public String getSubMerchantAccountId() { 59 | return subMerchantAccountId; 60 | } 61 | 62 | public void setSubMerchantAccountId(String subMerchantAccountId) { 63 | this.subMerchantAccountId = subMerchantAccountId; 64 | } 65 | 66 | public String getMasterMerchantAccountId() { 67 | return masterMerchantAccountId; 68 | } 69 | 70 | public void setMasterMerchantAccountId(String masterMerchantAccountId) { 71 | this.masterMerchantAccountId = masterMerchantAccountId; 72 | } 73 | 74 | public String getOrderId() { 75 | return orderId; 76 | } 77 | 78 | public void setOrderId(String orderId) { 79 | this.orderId = orderId; 80 | } 81 | 82 | public String getCreateAt() { 83 | return createAt; 84 | } 85 | 86 | public void setCreateAt(String createAt) { 87 | this.createAt = createAt; 88 | } 89 | 90 | public String getUpdateAt() { 91 | return updateAt; 92 | } 93 | 94 | public void setUpdateAt(String updateAt) { 95 | this.updateAt = updateAt; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /androideatitv2client/Model/UserModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Model; 2 | 3 | public class UserModel { 4 | private String uid,name, address,phone; 5 | private double lat,lng; 6 | 7 | public UserModel() { 8 | } 9 | 10 | public UserModel(String uid, String name, String address, String phone,double lat,double lng) { 11 | this.uid = uid; 12 | this.name = name; 13 | this.address = address; 14 | this.phone = phone; 15 | this.lat = lat; 16 | this.lng = lng; 17 | 18 | } 19 | 20 | public String getUid() { 21 | return uid; 22 | } 23 | 24 | public void setUid(String uid) { 25 | this.uid = uid; 26 | } 27 | 28 | public String getName() { 29 | return name; 30 | } 31 | 32 | public void setName(String name) { 33 | this.name = name; 34 | } 35 | 36 | public String getAddress() { 37 | return address; 38 | } 39 | 40 | public void setAddress(String address) { 41 | this.address = address; 42 | } 43 | 44 | public String getPhone() { 45 | return phone; 46 | } 47 | 48 | public void setPhone(String phone) { 49 | this.phone = phone; 50 | } 51 | 52 | public double getLat() { 53 | return lat; 54 | } 55 | 56 | public void setLat(double lat) { 57 | this.lat = lat; 58 | } 59 | 60 | public double getLng() { 61 | return lng; 62 | } 63 | 64 | public void setLng(double lng) { 65 | this.lng = lng; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /androideatitv2client/Remote/ICloudFunctions.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Remote; 2 | 3 | import com.ds.androideatitv2client.Model.BraintreeToken; 4 | import com.ds.androideatitv2client.Model.BraintreeTransaction; 5 | 6 | import java.util.Map; 7 | 8 | import io.reactivex.Observable; 9 | import okhttp3.ResponseBody; 10 | import retrofit2.http.Field; 11 | import retrofit2.http.FormUrlEncoded; 12 | import retrofit2.http.GET; 13 | import retrofit2.http.HeaderMap; 14 | import retrofit2.http.POST; 15 | 16 | public interface ICloudFunctions { 17 | @GET("token") 18 | Observable getToken (@HeaderMap Map headers); 19 | 20 | @POST("checkout") 21 | @FormUrlEncoded 22 | Observable submitPayment ( 23 | @HeaderMap Map headers, 24 | @Field("amount") double amount, 25 | @Field("payment_method_nonce") String nonce); 26 | } 27 | -------------------------------------------------------------------------------- /androideatitv2client/Remote/IFCMService.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Remote; 2 | 3 | import com.ds.androideatitv2client.Model.FCMResponse; 4 | import com.ds.androideatitv2client.Model.FCMSendData; 5 | 6 | import io.reactivex.Observable; 7 | import retrofit2.http.Body; 8 | import retrofit2.http.Headers; 9 | import retrofit2.http.POST; 10 | 11 | public interface IFCMService { 12 | @Headers({ 13 | "Content-Type:application/json", 14 | "Authorization:key=AAAAKK2HWaQ:APA91bGDvCgZvaQFUB1kg17PWD5WCl7qlzBx2rh9-y8EylcI7IOE44qfIScmrZxZosLi1a_DzmXal0uXmsQexLyiBwLtHOG5ffvhIyJg1110uZsT-gdSrzO3PF71IEUNi7Ark6OY4a8I" 15 | }) 16 | @POST("fcm/send") 17 | Observable sendNotification(@Body FCMSendData body); 18 | } 19 | -------------------------------------------------------------------------------- /androideatitv2client/Remote/IGoogleAPI.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Remote; 2 | 3 | import io.reactivex.Observable; 4 | import retrofit2.http.GET; 5 | import retrofit2.http.Query; 6 | 7 | public interface IGoogleAPI { 8 | @GET("maps/api/directions/json") 9 | Observable getDirections( 10 | @Query("mode") String mode, 11 | @Query("transit_routing_preference") String transit_routing, 12 | @Query("origin") String from, 13 | @Query("destination") String to, 14 | @Query("key") String key); 15 | } 16 | 17 | -------------------------------------------------------------------------------- /androideatitv2client/Remote/RetrofitCloudClient.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Remote; 2 | 3 | import retrofit2.Retrofit; 4 | import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; 5 | import retrofit2.converter.gson.GsonConverterFactory; 6 | 7 | public class RetrofitCloudClient { 8 | private static Retrofit instance; 9 | public static Retrofit getInstance(){ 10 | if(instance == null) 11 | instance = new Retrofit.Builder() 12 | .baseUrl("https://us-central1-androideatitv2client-3f83d.cloudfunctions.net/widgets/") 13 | .addConverterFactory(GsonConverterFactory.create()) 14 | .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) 15 | .build(); 16 | return instance; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /androideatitv2client/Remote/RetrofitFCMClient.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Remote; 2 | 3 | import retrofit2.Retrofit; 4 | import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; 5 | import retrofit2.converter.gson.GsonConverterFactory; 6 | 7 | public class RetrofitFCMClient { 8 | private static Retrofit instance; 9 | public static Retrofit getInstance(){ 10 | if(instance == null) 11 | instance = new Retrofit.Builder() 12 | .baseUrl("https://fcm.googleapis.com/") 13 | .addConverterFactory(GsonConverterFactory.create()) 14 | .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) 15 | .build(); 16 | return instance; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /androideatitv2client/Remote/RetrofitGoogleAPIClient.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.Remote; 2 | 3 | 4 | import retrofit2.Retrofit; 5 | import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; 6 | import retrofit2.converter.scalars.ScalarsConverterFactory; 7 | 8 | public class RetrofitGoogleAPIClient { 9 | private static Retrofit instance; 10 | 11 | public static Retrofit getInstance(){ 12 | return instance == null ? new Retrofit.Builder() 13 | .baseUrl("https://maps.googleapis.com/") 14 | .addConverterFactory(ScalarsConverterFactory.create()) 15 | .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) 16 | .build() : instance; 17 | 18 | } 19 | } -------------------------------------------------------------------------------- /androideatitv2client/services/MyFCMServices.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.services; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | import com.ds.androideatitv2client.Common.Common; 6 | import com.google.firebase.messaging.FirebaseMessagingService; 7 | import com.google.firebase.messaging.RemoteMessage; 8 | 9 | import java.util.Map; 10 | import java.util.Random; 11 | 12 | public class MyFCMServices extends FirebaseMessagingService { 13 | @Override 14 | public void onMessageReceived(@NonNull RemoteMessage remoteMessage) { 15 | Map dataRecv = remoteMessage.getData(); 16 | if (dataRecv != null) 17 | { 18 | Common.showNotification(this, new Random().nextInt(), 19 | dataRecv.get(Common.NOTI_TITLE), 20 | dataRecv.get(Common.NOTI_CONTENT), 21 | null); 22 | } 23 | } 24 | 25 | @Override 26 | public void onNewToken(@NonNull String s) { 27 | super.onNewToken(s); 28 | Common.updateToken(this,s); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /androideatitv2client/ui/cart/CartViewModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.ui.cart; 2 | 3 | 4 | import android.content.Context; 5 | 6 | import androidx.lifecycle.LiveData; 7 | import androidx.lifecycle.MutableLiveData; 8 | import androidx.lifecycle.ViewModel; 9 | 10 | import com.ds.androideatitv2client.Common.Common; 11 | import com.ds.androideatitv2client.Database.CartDataSource; 12 | import com.ds.androideatitv2client.Database.CartDatabase; 13 | import com.ds.androideatitv2client.Database.CartItem; 14 | import com.ds.androideatitv2client.Database.LocalCartDataSource; 15 | 16 | import java.util.List; 17 | 18 | import io.reactivex.android.schedulers.AndroidSchedulers; 19 | import io.reactivex.disposables.CompositeDisposable; 20 | import io.reactivex.schedulers.Schedulers; 21 | 22 | public class CartViewModel extends ViewModel { 23 | 24 | private CompositeDisposable compositeDisposable; 25 | private CartDataSource cartDataSource; 26 | private MutableLiveData> mutableLiveDataCartItem; 27 | 28 | public CartViewModel() { 29 | compositeDisposable = new CompositeDisposable(); 30 | } 31 | 32 | public void initCartDataSource(Context context) 33 | { 34 | cartDataSource = new LocalCartDataSource(CartDatabase.getInstance(context).cartDAO()); 35 | } 36 | 37 | public void onStop() 38 | { 39 | compositeDisposable.clear(); 40 | } 41 | 42 | public MutableLiveData> getMutableLiveDataCartItem() { 43 | if(mutableLiveDataCartItem == null) 44 | mutableLiveDataCartItem = new MutableLiveData<>(); 45 | getAllCartItems(); 46 | return mutableLiveDataCartItem; 47 | } 48 | 49 | private void getAllCartItems() { 50 | compositeDisposable.add(cartDataSource.getAllCart(Common.currentUser.getUid()) 51 | .subscribeOn(Schedulers.io()) 52 | .observeOn(AndroidSchedulers.mainThread()) 53 | .subscribe(cartItems -> { 54 | mutableLiveDataCartItem.setValue(cartItems); 55 | }, throwable -> { 56 | mutableLiveDataCartItem.setValue(null); 57 | })); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /androideatitv2client/ui/comments/CommentFragment.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.ui.comments; 2 | 3 | import android.app.AlertDialog; 4 | import android.os.Bundle; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.Toast; 9 | 10 | import androidx.annotation.NonNull; 11 | import androidx.annotation.Nullable; 12 | import androidx.lifecycle.ViewModelProvider; 13 | import androidx.lifecycle.ViewModelProviders; 14 | import androidx.recyclerview.widget.DividerItemDecoration; 15 | import androidx.recyclerview.widget.LinearLayoutManager; 16 | import androidx.recyclerview.widget.RecyclerView; 17 | 18 | import com.ds.androideatitv2client.Adapter.MyCommentAdapter; 19 | import com.ds.androideatitv2client.Callback.ICommentCallbackListener; 20 | import com.ds.androideatitv2client.Common.Common; 21 | import com.ds.androideatitv2client.Model.CommentModel; 22 | import com.ds.androideatitv2client.R; 23 | import com.google.android.material.bottomsheet.BottomSheetDialogFragment; 24 | import com.google.firebase.database.DataSnapshot; 25 | import com.google.firebase.database.DatabaseError; 26 | import com.google.firebase.database.FirebaseDatabase; 27 | import com.google.firebase.database.ValueEventListener; 28 | 29 | import org.w3c.dom.Comment; 30 | 31 | import java.util.ArrayList; 32 | import java.util.List; 33 | 34 | import butterknife.BindView; 35 | import butterknife.ButterKnife; 36 | import butterknife.Unbinder; 37 | import dmax.dialog.SpotsDialog; 38 | 39 | public class CommentFragment extends BottomSheetDialogFragment implements ICommentCallbackListener { 40 | 41 | private CommentViewModel commentViewModel; 42 | private Unbinder unbinder; 43 | 44 | @BindView(R.id.recycler_comment) 45 | RecyclerView recycler_comment; 46 | 47 | AlertDialog dialog; 48 | ICommentCallbackListener listener; 49 | 50 | public CommentFragment() { 51 | listener = this; 52 | } 53 | 54 | private static CommentFragment instance; 55 | 56 | public static CommentFragment getInstance() { 57 | if(instance == null ) 58 | instance = new CommentFragment(); 59 | return instance; 60 | } 61 | 62 | @Nullable 63 | @Override 64 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 65 | View itemView = LayoutInflater.from(getContext()) 66 | .inflate(R.layout.bottom_sheet_comment_fragment, container,false); 67 | unbinder = ButterKnife.bind(this, itemView); 68 | initViews(); 69 | loadCommentsFromFirebase(); 70 | 71 | commentViewModel.getMutableLiveDataFoodList().observe(this, commentModels -> { 72 | MyCommentAdapter adapter = new MyCommentAdapter(getContext(), commentModels); 73 | recycler_comment.setAdapter(adapter); 74 | }); 75 | return itemView; 76 | } 77 | 78 | private void loadCommentsFromFirebase() { 79 | dialog.show(); 80 | List commentModels = new ArrayList<>(); 81 | FirebaseDatabase.getInstance().getReference(Common.COMMENT_REF) 82 | .child(Common.selectedFood.getId()) 83 | .orderByChild("serverTimeStamp") 84 | .limitToLast(100) 85 | .addListenerForSingleValueEvent(new ValueEventListener() { 86 | @Override 87 | public void onDataChange(@NonNull DataSnapshot dataSnapshot) { 88 | for (DataSnapshot commentSnapShot : dataSnapshot.getChildren()) 89 | { 90 | CommentModel commentModel = commentSnapShot.getValue(CommentModel.class); 91 | commentModels.add(commentModel); 92 | } 93 | listener.onCommentLoadSuccess(commentModels); 94 | } 95 | 96 | @Override 97 | public void onCancelled(@NonNull DatabaseError databaseError) { 98 | listener.onCommentLoadFailed(databaseError.getMessage()); 99 | } 100 | }); 101 | } 102 | 103 | private void initViews() { 104 | commentViewModel = ViewModelProviders.of(this).get(CommentViewModel.class); 105 | dialog = new SpotsDialog.Builder().setContext(getContext()).setCancelable(false).build(); 106 | 107 | recycler_comment.setHasFixedSize(true); 108 | LinearLayoutManager layoutManager = new LinearLayoutManager(getContext(), RecyclerView.VERTICAL, true); 109 | recycler_comment.setLayoutManager(layoutManager); 110 | recycler_comment.addItemDecoration(new DividerItemDecoration(getContext(), layoutManager.getOrientation())); 111 | 112 | } 113 | 114 | @Override 115 | public void onCommentLoadSuccess(List commentModels) { 116 | dialog.dismiss(); 117 | commentViewModel.setCommentList(commentModels); 118 | 119 | } 120 | 121 | @Override 122 | public void onCommentLoadFailed(String message) { 123 | dialog.dismiss(); 124 | Toast.makeText(getContext(), message, Toast.LENGTH_SHORT).show(); 125 | 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /androideatitv2client/ui/comments/CommentViewModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.ui.comments; 2 | 3 | import androidx.lifecycle.MutableLiveData; 4 | import androidx.lifecycle.ViewModel; 5 | 6 | import com.ds.androideatitv2client.Model.CommentModel; 7 | import com.ds.androideatitv2client.Model.FoodModel; 8 | 9 | import java.util.List; 10 | 11 | public class CommentViewModel extends ViewModel { 12 | private MutableLiveData> mutableLiveDataFoodList; 13 | 14 | public CommentViewModel() { 15 | mutableLiveDataFoodList = new MutableLiveData<>(); 16 | } 17 | 18 | public MutableLiveData> getMutableLiveDataFoodList() { 19 | return mutableLiveDataFoodList; 20 | } 21 | 22 | public void setCommentList(List commentList) 23 | { 24 | mutableLiveDataFoodList.setValue(commentList); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /androideatitv2client/ui/fooddetail/FoodDetailViewModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.ui.fooddetail; 2 | 3 | import androidx.lifecycle.LiveData; 4 | import androidx.lifecycle.MutableLiveData; 5 | import androidx.lifecycle.ViewModel; 6 | 7 | import com.ds.androideatitv2client.Common.Common; 8 | import com.ds.androideatitv2client.Model.CommentModel; 9 | import com.ds.androideatitv2client.Model.FoodModel; 10 | 11 | import java.util.List; 12 | 13 | public class FoodDetailViewModel extends ViewModel { 14 | 15 | private MutableLiveData mutableLiveDataFood; 16 | private MutableLiveData mutableLiveDataComment; 17 | 18 | public void setCommentModel(CommentModel commentModel) 19 | { 20 | if(mutableLiveDataComment != null) 21 | mutableLiveDataComment.setValue(commentModel); 22 | } 23 | 24 | public MutableLiveData getMutableLiveDataComment() { 25 | return mutableLiveDataComment; 26 | } 27 | 28 | public FoodDetailViewModel() { 29 | mutableLiveDataComment = new MutableLiveData<>(); 30 | } 31 | 32 | public MutableLiveData getMutableLiveDataFood() { 33 | if(mutableLiveDataFood == null) 34 | mutableLiveDataFood = new MutableLiveData<>(); 35 | mutableLiveDataFood.setValue(Common.selectedFood); 36 | return mutableLiveDataFood; 37 | } 38 | 39 | public void setFoodModel(FoodModel foodModel) { 40 | if(mutableLiveDataFood != null) 41 | mutableLiveDataFood.setValue(foodModel); 42 | } 43 | } -------------------------------------------------------------------------------- /androideatitv2client/ui/foodlist/FoodListViewModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.ui.foodlist; 2 | 3 | import androidx.lifecycle.LiveData; 4 | import androidx.lifecycle.MutableLiveData; 5 | import androidx.lifecycle.ViewModel; 6 | 7 | import com.ds.androideatitv2client.Common.Common; 8 | import com.ds.androideatitv2client.Model.FoodModel; 9 | 10 | import java.util.List; 11 | 12 | public class FoodListViewModel extends ViewModel { 13 | 14 | private MutableLiveData> mutableLiveDataFoodList; 15 | 16 | public FoodListViewModel() { 17 | 18 | } 19 | 20 | public MutableLiveData> getMutableLiveDataFoodList() { 21 | if(mutableLiveDataFoodList == null) 22 | mutableLiveDataFoodList = new MutableLiveData<>(); 23 | mutableLiveDataFoodList.setValue(Common.categorySelected.getFoods()); 24 | return mutableLiveDataFoodList; 25 | } 26 | } -------------------------------------------------------------------------------- /androideatitv2client/ui/home/HomeFragment.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.ui.home; 2 | 3 | import android.os.Bundle; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.view.animation.AnimationSet; 8 | import android.view.animation.AnimationUtils; 9 | import android.view.animation.LayoutAnimationController; 10 | import android.widget.TextView; 11 | 12 | import androidx.annotation.NonNull; 13 | import androidx.annotation.Nullable; 14 | import androidx.fragment.app.Fragment; 15 | import androidx.lifecycle.Observer; 16 | import androidx.lifecycle.ViewModelProviders; 17 | import androidx.recyclerview.widget.LinearLayoutManager; 18 | import androidx.recyclerview.widget.RecyclerView; 19 | 20 | import com.asksira.loopingviewpager.LoopingViewPager; 21 | import com.ds.androideatitv2client.Adapter.MyBestDealsAdapter; 22 | import com.ds.androideatitv2client.Adapter.MyPopularCategoriesAdapter; 23 | import com.ds.androideatitv2client.R; 24 | 25 | import butterknife.BindDimen; 26 | import butterknife.BindView; 27 | import butterknife.ButterKnife; 28 | import butterknife.Unbinder; 29 | 30 | public class HomeFragment extends Fragment { 31 | 32 | private HomeViewModel homeViewModel; 33 | 34 | Unbinder unbinder; 35 | 36 | @BindView(R.id.recycler_popular) 37 | RecyclerView recycler_popular; 38 | @BindView(R.id.viewpager) 39 | LoopingViewPager viewPager; 40 | 41 | LayoutAnimationController layoutAnimationController; 42 | 43 | 44 | 45 | public View onCreateView(@NonNull LayoutInflater inflater, 46 | ViewGroup container, Bundle savedInstanceState) { 47 | homeViewModel = 48 | ViewModelProviders.of(this).get(HomeViewModel.class); 49 | View root = inflater.inflate(R.layout.fragment_home, container, false); 50 | unbinder = ButterKnife.bind(this, root); 51 | init(); 52 | homeViewModel.getPopularList().observe(this,popularCategoryModels -> { 53 | 54 | //create Adapter 55 | MyPopularCategoriesAdapter adapter = new MyPopularCategoriesAdapter(getContext(), popularCategoryModels); 56 | recycler_popular.setAdapter(adapter); 57 | recycler_popular.setLayoutAnimation(layoutAnimationController); 58 | }); 59 | 60 | homeViewModel.getBestDealList().observe(this,bestDealModels -> { 61 | MyBestDealsAdapter adapter = new MyBestDealsAdapter(getContext(), bestDealModels, true); 62 | viewPager.setAdapter(adapter); 63 | }); 64 | return root; 65 | } 66 | 67 | private void init() { 68 | layoutAnimationController = AnimationUtils.loadLayoutAnimation(getContext(),R.anim.layout_item_from_left); 69 | recycler_popular.setHasFixedSize(true); 70 | recycler_popular.setLayoutManager(new LinearLayoutManager(getContext(),RecyclerView.HORIZONTAL,false)); 71 | } 72 | 73 | @Override 74 | public void onResume(){ 75 | super.onResume(); 76 | viewPager.resumeAutoScroll(); 77 | } 78 | 79 | @Override 80 | public void onPause(){ 81 | viewPager.pauseAutoScroll(); 82 | super.onPause(); 83 | } 84 | } -------------------------------------------------------------------------------- /androideatitv2client/ui/home/HomeViewModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.ui.home; 2 | 3 | import androidx.lifecycle.LiveData; 4 | import androidx.lifecycle.MutableLiveData; 5 | import androidx.lifecycle.ViewModel; 6 | 7 | import com.ds.androideatitv2client.Callback.IBestDealCallbackListener; 8 | import com.ds.androideatitv2client.Callback.IPopularCallbackListener; 9 | import com.ds.androideatitv2client.Common.Common; 10 | import com.ds.androideatitv2client.Model.BestDealModel; 11 | import com.ds.androideatitv2client.Model.PopularCategoryModel; 12 | import com.google.firebase.database.DataSnapshot; 13 | import com.google.firebase.database.DatabaseError; 14 | import com.google.firebase.database.DatabaseReference; 15 | import com.google.firebase.database.FirebaseDatabase; 16 | import com.google.firebase.database.ValueEventListener; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | import io.reactivex.annotations.NonNull; 22 | 23 | public class HomeViewModel extends ViewModel implements IPopularCallbackListener, IBestDealCallbackListener { 24 | 25 | private MutableLiveData> popularList; 26 | private MutableLiveData> bestDealList; 27 | private MutableLiveData messageError; 28 | private IPopularCallbackListener popularCallbackListener; 29 | private IBestDealCallbackListener bestDealCallbackListener; 30 | 31 | public HomeViewModel() { 32 | popularCallbackListener = this; 33 | bestDealCallbackListener = this; 34 | } 35 | 36 | public MutableLiveData> getBestDealList() { 37 | if(bestDealList == null) 38 | { 39 | bestDealList = new MutableLiveData<>(); 40 | messageError = new MutableLiveData<>(); 41 | loadBestDealList(); 42 | } 43 | return bestDealList; 44 | } 45 | 46 | private void loadBestDealList() { 47 | List tempList = new ArrayList<>(); 48 | DatabaseReference bestDealRef = FirebaseDatabase.getInstance().getReference(Common.BEST_DEALS_REF); 49 | bestDealRef.addListenerForSingleValueEvent(new ValueEventListener() { 50 | @Override 51 | public void onDataChange(@NonNull DataSnapshot dataSnapshot) { 52 | for(DataSnapshot itemSnapShot:dataSnapshot.getChildren()) 53 | { 54 | BestDealModel model = itemSnapShot.getValue(BestDealModel.class); 55 | tempList.add(model); 56 | } 57 | bestDealCallbackListener.onBestDealLoadSuccess(tempList); 58 | } 59 | 60 | @Override 61 | public void onCancelled(@NonNull DatabaseError databaseError) { 62 | bestDealCallbackListener.onBestDealLoadFailed(databaseError.getMessage()); 63 | } 64 | }); 65 | } 66 | 67 | public MutableLiveData> getPopularList() { 68 | if(popularList == null) 69 | { 70 | popularList = new MutableLiveData<>(); 71 | messageError = new MutableLiveData<>(); 72 | loadPopularList(); 73 | } 74 | return popularList; 75 | } 76 | 77 | private void loadPopularList() { 78 | List tempList = new ArrayList<>(); 79 | DatabaseReference popularRef = FirebaseDatabase.getInstance().getReference(Common.POPULAR_CATEGORY_REF); 80 | popularRef.addListenerForSingleValueEvent(new ValueEventListener() { 81 | @Override 82 | public void onDataChange(@NonNull DataSnapshot dataSnapshot) { 83 | for(DataSnapshot itemSnapShot:dataSnapshot.getChildren()) 84 | { 85 | PopularCategoryModel model = itemSnapShot.getValue(PopularCategoryModel.class); 86 | tempList.add(model); 87 | } 88 | popularCallbackListener.onPopularLoadSuccess(tempList); 89 | } 90 | @Override 91 | public void onCancelled(@NonNull DatabaseError databaseError) { 92 | popularCallbackListener.onPopularLoadFailed(databaseError.getMessage()); 93 | } 94 | }); 95 | } 96 | 97 | public MutableLiveData getMessageError() { 98 | return messageError; 99 | } 100 | 101 | @Override 102 | public void onPopularLoadSuccess(List popularCategoryModels) { 103 | popularList.setValue(popularCategoryModels); 104 | } 105 | 106 | @Override 107 | public void onPopularLoadFailed(String message) { 108 | messageError.setValue(message); 109 | } 110 | 111 | @Override 112 | public void onBestDealLoadSuccess(List BestDealModels) { 113 | bestDealList.setValue(BestDealModels); 114 | } 115 | 116 | @Override 117 | public void onBestDealLoadFailed(String message) { 118 | messageError.setValue(message); 119 | } 120 | } -------------------------------------------------------------------------------- /androideatitv2client/ui/menu/MenuViewModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.ui.menu; 2 | 3 | import androidx.annotation.NonNull; 4 | import androidx.lifecycle.LiveData; 5 | import androidx.lifecycle.MutableLiveData; 6 | import androidx.lifecycle.ViewModel; 7 | 8 | import com.ds.androideatitv2client.Callback.ICategoryCallbackListener; 9 | import com.ds.androideatitv2client.Common.Common; 10 | import com.ds.androideatitv2client.Model.CategoryModel; 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 | 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | public class MenuViewModel extends ViewModel implements ICategoryCallbackListener { 21 | 22 | private MutableLiveData> categoryListMutable; 23 | private MutableLiveData messageError = new MutableLiveData<>(); 24 | private ICategoryCallbackListener categoryCallbackListener; 25 | 26 | 27 | public MenuViewModel() { 28 | categoryCallbackListener = this; 29 | 30 | } 31 | 32 | public MutableLiveData> getCategoryListMultable() { 33 | if(categoryListMutable == null) 34 | { 35 | categoryListMutable = new MutableLiveData<>(); 36 | messageError = new MutableLiveData<>(); 37 | loadCategories(); 38 | } 39 | return categoryListMutable; 40 | } 41 | 42 | public void loadCategories() { 43 | List tempList = new ArrayList<>(); 44 | DatabaseReference categoryRef = FirebaseDatabase.getInstance().getReference(Common.CATEGORY_REF); 45 | categoryRef.addListenerForSingleValueEvent(new ValueEventListener() { 46 | @Override 47 | public void onDataChange(@NonNull DataSnapshot dataSnapshot) { 48 | for(DataSnapshot itemSnapShot:dataSnapshot.getChildren()) 49 | { 50 | CategoryModel categoryModel = itemSnapShot.getValue(CategoryModel.class); 51 | categoryModel.setMenu_id(itemSnapShot.getKey()); 52 | tempList.add(categoryModel); 53 | } 54 | categoryCallbackListener.onCategoryLoadSuccess(tempList); 55 | } 56 | 57 | @Override 58 | public void onCancelled(@NonNull DatabaseError databaseError) { 59 | categoryCallbackListener.onCategoryLoadFailed(databaseError.getMessage()); 60 | } 61 | }); 62 | } 63 | 64 | public MutableLiveData getMessageError() { 65 | return messageError; 66 | } 67 | 68 | @Override 69 | public void onCategoryLoadSuccess(List categoryModelList) { 70 | categoryListMutable.setValue(categoryModelList); 71 | } 72 | 73 | @Override 74 | public void onCategoryLoadFailed(String message) { 75 | messageError.setValue(message); 76 | } 77 | } -------------------------------------------------------------------------------- /androideatitv2client/ui/view_orders/ViewOrdersViewModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2client.ui.view_orders; 2 | 3 | import androidx.lifecycle.MutableLiveData; 4 | import androidx.lifecycle.ViewModel; 5 | 6 | import com.ds.androideatitv2client.Model.OrderModel; 7 | 8 | import java.util.List; 9 | 10 | public class ViewOrdersViewModel extends ViewModel { 11 | 12 | private MutableLiveData> mutableLiveDataOrderList; 13 | 14 | public ViewOrdersViewModel() { 15 | mutableLiveDataOrderList = new MutableLiveData<>(); 16 | } 17 | 18 | public MutableLiveData> getMutableLiveDataOrderList() { 19 | return mutableLiveDataOrderList; 20 | } 21 | 22 | public void setMutableLiveDataOrderList(List orderModelList) { 23 | this.mutableLiveDataOrderList.setValue(orderModelList); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /androideatitv2server/Adapter/MyAddonAdapter.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Adapter; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.ImageView; 8 | import android.widget.TextView; 9 | 10 | import androidx.annotation.NonNull; 11 | import androidx.recyclerview.widget.RecyclerView; 12 | 13 | import com.ds.androideatitv2server.Callback.IRecyclerClickListener; 14 | import com.ds.androideatitv2server.Model.AddonModel; 15 | import com.ds.androideatitv2server.Model.SelectAddonModel; 16 | import com.ds.androideatitv2server.Model.SelectSizeModel; 17 | import com.ds.androideatitv2server.Model.SizeModel; 18 | import com.ds.androideatitv2server.Model.UpdateAddonModel; 19 | import com.ds.androideatitv2server.Model.UpdateSizeModel; 20 | import com.ds.androideatitv2server.R; 21 | 22 | import org.greenrobot.eventbus.EventBus; 23 | 24 | import java.util.List; 25 | 26 | import butterknife.BindView; 27 | import butterknife.ButterKnife; 28 | import butterknife.Unbinder; 29 | 30 | public class MyAddonAdapter extends RecyclerView.Adapter { 31 | 32 | Context context; 33 | List addonModels; 34 | UpdateAddonModel updateAddonModel; 35 | int editPos; 36 | 37 | public MyAddonAdapter(Context context, List addonModels) { 38 | this.context = context; 39 | this.addonModels = addonModels; 40 | editPos= -1; 41 | updateAddonModel = new UpdateAddonModel(); 42 | } 43 | 44 | @NonNull 45 | @Override 46 | public MyAddonAdapter.MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { 47 | return new MyAddonAdapter.MyViewHolder(LayoutInflater.from(context) 48 | .inflate(R.layout.layout_size_addon_display, parent, false)); 49 | } 50 | 51 | @Override 52 | public void onBindViewHolder(@NonNull MyAddonAdapter.MyViewHolder holder, int position) { 53 | holder.txt_name.setText(addonModels.get(position).getName()); 54 | holder.txt_price.setText(String.valueOf(addonModels.get(position).getPrice())); 55 | 56 | //Event 57 | holder.img_delete.setOnClickListener(view -> { 58 | //Delete item 59 | addonModels.remove(position); 60 | notifyItemRemoved(position); 61 | updateAddonModel.setAddonModels(addonModels); // Set for event 62 | EventBus.getDefault().postSticky(updateAddonModel); // Send event 63 | }); 64 | 65 | holder.setListener((view, pos) -> { 66 | editPos = position; 67 | EventBus.getDefault().postSticky(new SelectAddonModel(addonModels.get(pos))); 68 | 69 | }); 70 | 71 | } 72 | 73 | @Override 74 | public int getItemCount() { 75 | return addonModels.size(); 76 | } 77 | 78 | public void addNewSize(AddonModel addonModel) { 79 | addonModels.add(addonModel); 80 | notifyItemInserted(addonModels.size()-1); 81 | updateAddonModel.setAddonModels(addonModels); 82 | EventBus.getDefault().postSticky(updateAddonModel); 83 | } 84 | 85 | public void editSize(AddonModel addonModel) { 86 | if(editPos != -1) 87 | { 88 | addonModels.set(editPos, addonModel); 89 | notifyItemChanged(editPos); 90 | editPos = -1; // Reset variables after success 91 | 92 | // Send updates 93 | updateAddonModel.setAddonModels(addonModels); 94 | EventBus.getDefault().postSticky(updateAddonModel); 95 | 96 | } 97 | } 98 | 99 | public class MyViewHolder extends RecyclerView.ViewHolder { 100 | 101 | @BindView(R.id.txt_name) 102 | TextView txt_name; 103 | @BindView(R.id.txt_price) 104 | TextView txt_price; 105 | @BindView(R.id.img_delete) 106 | ImageView img_delete; 107 | 108 | Unbinder unbinder; 109 | 110 | IRecyclerClickListener listener; 111 | 112 | public void setListener(IRecyclerClickListener listener){ 113 | this.listener = listener; 114 | } 115 | 116 | public MyViewHolder(@NonNull View itemview) { 117 | super(itemview); 118 | unbinder = ButterKnife.bind(this, itemview); 119 | itemview.setOnClickListener(view -> listener 120 | .onItemClickListener(view, getAdapterPosition())); 121 | } 122 | } 123 | 124 | } 125 | -------------------------------------------------------------------------------- /androideatitv2server/Adapter/MyCategoriesAdapter.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Adapter; 2 | 3 | 4 | import android.content.Context; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.ImageView; 9 | import android.widget.TextView; 10 | 11 | import androidx.annotation.NonNull; 12 | import androidx.recyclerview.widget.RecyclerView; 13 | 14 | import com.bumptech.glide.Glide; 15 | import com.ds.androideatitv2server.Callback.IRecyclerClickListener; 16 | import com.ds.androideatitv2server.Common.Common; 17 | import com.ds.androideatitv2server.EventBus.CategoryClick; 18 | import com.ds.androideatitv2server.Model.CategoryModel; 19 | import com.ds.androideatitv2server.R; 20 | 21 | import org.greenrobot.eventbus.EventBus; 22 | 23 | import java.util.List; 24 | 25 | import butterknife.BindView; 26 | import butterknife.ButterKnife; 27 | import butterknife.Unbinder; 28 | 29 | public class MyCategoriesAdapter extends RecyclerView.Adapter { 30 | 31 | Context context; 32 | List categoryModelList; 33 | 34 | public MyCategoriesAdapter(Context context, List categoryModelList) { 35 | this.context = context; 36 | this.categoryModelList = categoryModelList; 37 | } 38 | 39 | @NonNull 40 | @Override 41 | public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { 42 | return new MyViewHolder(LayoutInflater.from(context) 43 | .inflate(R.layout.layout_category_item, parent, false)); 44 | } 45 | 46 | @Override 47 | public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { 48 | Glide.with(context).load(categoryModelList.get(position).getImage()).into(holder.category_image); 49 | holder.category_name.setText(new StringBuilder(categoryModelList.get(position).getName())); 50 | 51 | //Event 52 | holder.setListener((view, pos) -> { 53 | Common.categorySelected = categoryModelList.get(pos); 54 | EventBus.getDefault().postSticky(new CategoryClick(true, categoryModelList.get(pos))); 55 | }); 56 | } 57 | 58 | @Override 59 | public int getItemCount() { 60 | return categoryModelList.size(); 61 | } 62 | 63 | public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { 64 | Unbinder unbinder; 65 | @BindView(R.id.img_category) 66 | ImageView category_image; 67 | @BindView(R.id.txt_category) 68 | TextView category_name; 69 | 70 | IRecyclerClickListener listener; 71 | 72 | public void setListener(IRecyclerClickListener listener) { 73 | this.listener = listener; 74 | } 75 | 76 | public MyViewHolder(@NonNull View itemView) { 77 | super(itemView); 78 | unbinder = ButterKnife.bind(this,itemView); 79 | itemView.setOnClickListener(this); 80 | } 81 | 82 | @Override 83 | public void onClick(View view) { 84 | listener.onItemClickListener(view, getAdapterPosition() ); 85 | } 86 | } 87 | 88 | 89 | @Override 90 | public int getItemViewType(int position) { 91 | if(categoryModelList.size() == 1) 92 | return Common.DEFAULT_COLUMN_COUNT; 93 | else 94 | { 95 | if(categoryModelList.size() % 2 == 0) 96 | return Common.DEFAULT_COLUMN_COUNT; 97 | else 98 | return (position > 1 && position == categoryModelList.size()-1) ? Common.FULL_WIDTH_COLUMN:Common.DEFAULT_COLUMN_COUNT; 99 | } 100 | } 101 | } 102 | 103 | -------------------------------------------------------------------------------- /androideatitv2server/Adapter/MyFoodListAdapter.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Adapter; 2 | 3 | 4 | import android.content.Context; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.ImageView; 9 | import android.widget.TextView; 10 | import android.widget.Toast; 11 | 12 | import androidx.annotation.NonNull; 13 | import androidx.recyclerview.widget.RecyclerView; 14 | 15 | import com.bumptech.glide.Glide; 16 | import com.ds.androideatitv2server.Callback.IRecyclerClickListener; 17 | import com.ds.androideatitv2server.Common.Common; 18 | import com.ds.androideatitv2server.Model.FoodModel; 19 | import com.ds.androideatitv2server.R; 20 | 21 | import org.greenrobot.eventbus.EventBus; 22 | 23 | import java.util.List; 24 | 25 | import butterknife.BindView; 26 | import butterknife.ButterKnife; 27 | import butterknife.Unbinder; 28 | 29 | public class MyFoodListAdapter extends RecyclerView.Adapter { 30 | 31 | private Context context; 32 | private List foodModelList; 33 | 34 | public MyFoodListAdapter(Context context, List foodModelList) { 35 | this.context = context; 36 | this.foodModelList = foodModelList; 37 | } 38 | 39 | @NonNull 40 | @Override 41 | public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { 42 | return new MyViewHolder(LayoutInflater.from(context) 43 | .inflate(R.layout.layout_food_item, parent, false)); 44 | } 45 | 46 | @Override 47 | public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { 48 | Glide.with(context).load(foodModelList.get(position).getImage()).into(holder.img_food_image); 49 | holder.txt_food_price.setText(new StringBuilder("$") 50 | .append(foodModelList.get(position).getPrice())); 51 | holder.txt_food_name.setText(new StringBuilder("") 52 | .append(foodModelList.get(position).getName())); 53 | 54 | //Event 55 | holder.setListener((view, pos) -> { 56 | Common.selectedFood = foodModelList.get(pos); 57 | Common.selectedFood.setKey(String.valueOf(pos)); 58 | }); 59 | 60 | } 61 | 62 | @Override 63 | public int getItemCount() { 64 | return foodModelList.size(); 65 | } 66 | 67 | public FoodModel getItemAtPosition(int pos) { 68 | return foodModelList.get(pos); 69 | } 70 | 71 | public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { 72 | private Unbinder unbinder; 73 | @BindView(R.id.txt_food_name) 74 | TextView txt_food_name; 75 | @BindView(R.id.txt_food_price) 76 | TextView txt_food_price; 77 | @BindView(R.id.img_food_image) 78 | ImageView img_food_image; 79 | 80 | IRecyclerClickListener listener; 81 | 82 | public void setListener(IRecyclerClickListener listener) { 83 | this.listener = listener; 84 | } 85 | 86 | public MyViewHolder(@NonNull View itemView) 87 | { 88 | super(itemView); 89 | unbinder = ButterKnife.bind(this, itemView); 90 | itemView.setOnClickListener(this); 91 | } 92 | 93 | @Override 94 | public void onClick(View view) { 95 | listener.onItemClickListener(view, getAdapterPosition()); 96 | } 97 | } 98 | } 99 | 100 | -------------------------------------------------------------------------------- /androideatitv2server/Adapter/MyShipperAdapter.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Adapter; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.CompoundButton; 8 | import android.widget.TextView; 9 | 10 | import androidx.annotation.NonNull; 11 | import androidx.appcompat.widget.SwitchCompat; 12 | import androidx.recyclerview.widget.RecyclerView; 13 | 14 | import com.ds.androideatitv2server.EventBus.UpdateShipperEvent; 15 | import com.ds.androideatitv2server.Model.ShipperModel; 16 | import com.ds.androideatitv2server.R; 17 | 18 | import org.greenrobot.eventbus.EventBus; 19 | 20 | import java.util.List; 21 | 22 | import butterknife.BindView; 23 | import butterknife.ButterKnife; 24 | import butterknife.Unbinder; 25 | 26 | public class MyShipperAdapter extends RecyclerView.Adapter { 27 | 28 | Context context; 29 | List shipperModelList; 30 | 31 | public MyShipperAdapter(Context context, List shipperModelList) { 32 | this.context = context; 33 | this.shipperModelList = shipperModelList; 34 | } 35 | 36 | @NonNull 37 | @Override 38 | public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { 39 | View itemView= LayoutInflater.from(context).inflate(R.layout.layout_shipper, parent, false); 40 | return new MyViewHolder(itemView); 41 | } 42 | 43 | @Override 44 | public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { 45 | holder.txt_name.setText(new StringBuilder(shipperModelList.get(position).getName())); 46 | holder.txt_phone.setText(new StringBuilder(shipperModelList.get(position).getPhone())); 47 | holder.btn_enable.setChecked(shipperModelList.get(position).isActive()); 48 | 49 | holder.btn_enable.setOnCheckedChangeListener((buttonView, isChecked) -> { 50 | EventBus.getDefault().postSticky(new UpdateShipperEvent(shipperModelList.get(position),isChecked)); 51 | }); 52 | } 53 | 54 | @Override 55 | public int getItemCount() { 56 | return shipperModelList.size(); 57 | } 58 | 59 | public class MyViewHolder extends RecyclerView.ViewHolder { 60 | private Unbinder unbinder; 61 | 62 | @BindView(R.id.txt_name) 63 | TextView txt_name; 64 | @BindView(R.id.txt_phone) 65 | TextView txt_phone; 66 | @BindView(R.id.btn_enable) 67 | SwitchCompat btn_enable; 68 | 69 | public MyViewHolder(@NonNull View itemView) { 70 | super(itemView); 71 | unbinder = ButterKnife.bind(this, itemView); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /androideatitv2server/Adapter/MyShipperSelectionAdapter.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Adapter; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.ImageView; 8 | import android.widget.TextView; 9 | 10 | import androidx.annotation.NonNull; 11 | import androidx.recyclerview.widget.RecyclerView; 12 | 13 | import com.ds.androideatitv2server.Callback.IRecyclerClickListener; 14 | import com.ds.androideatitv2server.EventBus.UpdateShipperEvent; 15 | import com.ds.androideatitv2server.Model.ShipperModel; 16 | import com.ds.androideatitv2server.R; 17 | 18 | import org.greenrobot.eventbus.EventBus; 19 | 20 | import java.util.List; 21 | 22 | import butterknife.BindView; 23 | import butterknife.ButterKnife; 24 | import butterknife.Unbinder; 25 | 26 | public class MyShipperSelectionAdapter extends RecyclerView.Adapter { 27 | 28 | private Context context; 29 | List shipperModelList; 30 | private ImageView lastCheckedImageView = null; 31 | private ShipperModel selectedShipper = null; 32 | 33 | public MyShipperSelectionAdapter(Context context, List shipperModelList) { 34 | this.context = context; 35 | this.shipperModelList = shipperModelList; 36 | } 37 | 38 | @NonNull 39 | @Override 40 | public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { 41 | View itemView = LayoutInflater.from(context).inflate(R.layout.layout_shipper_selected, parent, false); 42 | return new MyViewHolder(itemView); 43 | } 44 | 45 | @Override 46 | public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { 47 | holder.txt_name.setText(new StringBuilder(shipperModelList.get(position).getName())); 48 | holder.txt_phone.setText(new StringBuilder(shipperModelList.get(position).getPhone())); 49 | holder.setiRecyclerClickListener(((view, pos) -> { 50 | if (lastCheckedImageView != null) 51 | lastCheckedImageView.setImageResource(0); 52 | holder.img_checked.setImageResource(R.drawable.ic_baseline_check_24); 53 | lastCheckedImageView = holder.img_checked; 54 | selectedShipper = shipperModelList.get(pos); 55 | })); 56 | } 57 | 58 | public ShipperModel getSelectedShipper() { 59 | return selectedShipper; 60 | } 61 | 62 | @Override 63 | public int getItemCount() { 64 | return shipperModelList.size(); 65 | } 66 | 67 | public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { 68 | private Unbinder unbinder; 69 | 70 | @BindView(R.id.txt_name) 71 | TextView txt_name; 72 | @BindView(R.id.txt_phone) 73 | TextView txt_phone; 74 | @BindView(R.id.img_checked) 75 | ImageView img_checked; 76 | 77 | IRecyclerClickListener iRecyclerClickListener; 78 | 79 | public void setiRecyclerClickListener(IRecyclerClickListener iRecyclerClickListener) { 80 | this.iRecyclerClickListener = iRecyclerClickListener; 81 | } 82 | 83 | public MyViewHolder(@NonNull View itemView) { 84 | super(itemView); 85 | unbinder = ButterKnife.bind(this,itemView); 86 | itemView.setOnClickListener(this); 87 | } 88 | 89 | @Override 90 | public void onClick(View v) { 91 | iRecyclerClickListener.onItemClickListener(v, getAdapterPosition()); 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /androideatitv2server/Adapter/MySizeAdapter.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Adapter; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.ImageView; 8 | import android.widget.TextView; 9 | 10 | import androidx.annotation.NonNull; 11 | import androidx.recyclerview.widget.RecyclerView; 12 | 13 | import com.ds.androideatitv2server.Callback.IRecyclerClickListener; 14 | import com.ds.androideatitv2server.Model.SelectSizeModel; 15 | import com.ds.androideatitv2server.Model.SizeModel; 16 | import com.ds.androideatitv2server.Model.UpdateSizeModel; 17 | import com.ds.androideatitv2server.R; 18 | 19 | import org.greenrobot.eventbus.EventBus; 20 | 21 | import java.util.List; 22 | 23 | import butterknife.BindView; 24 | import butterknife.ButterKnife; 25 | import butterknife.Unbinder; 26 | 27 | public class MySizeAdapter extends RecyclerView.Adapter { 28 | 29 | Context context; 30 | List sizeModelList; 31 | UpdateSizeModel updateSizeModel; 32 | int editPos; 33 | 34 | public MySizeAdapter(Context context, List sizeModelList) { 35 | this.context = context; 36 | this.sizeModelList = sizeModelList; 37 | editPos = -1; 38 | updateSizeModel = new UpdateSizeModel(); 39 | } 40 | 41 | @NonNull 42 | @Override 43 | public MySizeAdapter.MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { 44 | return new MyViewHolder(LayoutInflater.from(context) 45 | .inflate(R.layout.layout_size_addon_display, parent, false)); 46 | } 47 | 48 | @Override 49 | public void onBindViewHolder(@NonNull MySizeAdapter.MyViewHolder holder, int position) { 50 | holder.txt_name.setText(sizeModelList.get(position).getName()); 51 | holder.txt_price.setText(String.valueOf(sizeModelList.get(position).getPrice())); 52 | 53 | //Event 54 | holder.img_delete.setOnClickListener(view -> { 55 | //Delete item 56 | sizeModelList.remove(position); 57 | notifyItemRemoved(position); 58 | updateSizeModel.setSizeModelList(sizeModelList); // Set for event 59 | EventBus.getDefault().postSticky(updateSizeModel); // Send event 60 | }); 61 | 62 | holder.setListener((view, pos) -> { 63 | editPos = position; 64 | EventBus.getDefault().postSticky(new SelectSizeModel(sizeModelList.get(pos))); 65 | 66 | }); 67 | 68 | } 69 | 70 | @Override 71 | public int getItemCount() { 72 | return sizeModelList.size(); 73 | } 74 | 75 | public void addNewSize(SizeModel sizeModel) { 76 | sizeModelList.add(sizeModel); 77 | notifyItemInserted(sizeModelList.size()-1); 78 | updateSizeModel.setSizeModelList(sizeModelList); 79 | EventBus.getDefault().postSticky(updateSizeModel); 80 | } 81 | 82 | public void editSize(SizeModel sizeModel) { 83 | if(editPos != -1) 84 | { 85 | sizeModelList.set(editPos, sizeModel); 86 | notifyItemChanged(editPos); 87 | editPos = -1; // Reset variables after success 88 | 89 | // Send updates 90 | updateSizeModel.setSizeModelList(sizeModelList); 91 | EventBus.getDefault().postSticky(updateSizeModel); 92 | 93 | } 94 | } 95 | 96 | public class MyViewHolder extends RecyclerView.ViewHolder { 97 | 98 | @BindView(R.id.txt_name) 99 | TextView txt_name; 100 | @BindView(R.id.txt_price) 101 | TextView txt_price; 102 | @BindView(R.id.img_delete) 103 | ImageView img_delete; 104 | 105 | Unbinder unbinder; 106 | 107 | IRecyclerClickListener listener; 108 | 109 | public void setListener(IRecyclerClickListener listener){ 110 | this.listener = listener; 111 | } 112 | 113 | public MyViewHolder(@NonNull View itemview) { 114 | super(itemview); 115 | unbinder = ButterKnife.bind(this, itemview); 116 | itemview.setOnClickListener(view -> listener 117 | .onItemClickListener(view, getAdapterPosition())); 118 | } 119 | } 120 | 121 | } 122 | -------------------------------------------------------------------------------- /androideatitv2server/Callback/ICategoryCallbackListener.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Callback; 2 | 3 | import com.ds.androideatitv2server.Model.CategoryModel; 4 | 5 | import java.util.List; 6 | 7 | public interface ICategoryCallbackListener { 8 | void onCategoryLoadSuccess(List categoryModelList); 9 | void onCategoryLoadFailed(String message); 10 | } 11 | -------------------------------------------------------------------------------- /androideatitv2server/Callback/IOrderCallbackListener.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Callback; 2 | 3 | import com.ds.androideatitv2server.Model.OrderModel; 4 | 5 | import java.util.List; 6 | 7 | public interface IOrderCallbackListener { 8 | void onOrderLoadSuccess(List orderModelList); 9 | void onOrderLoadFailed(String message); 10 | } 11 | -------------------------------------------------------------------------------- /androideatitv2server/Callback/IRecyclerClickListener.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Callback; 2 | 3 | import android.view.View; 4 | 5 | public interface IRecyclerClickListener { 6 | void onItemClickListener(View view, int pos); 7 | } 8 | -------------------------------------------------------------------------------- /androideatitv2server/Callback/IShipperLoadCallbackListener.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Callback; 2 | 3 | import android.widget.Button; 4 | import android.widget.RadioButton; 5 | 6 | import androidx.appcompat.app.AlertDialog; 7 | 8 | import com.ds.androideatitv2server.Model.OrderModel; 9 | import com.ds.androideatitv2server.Model.ShipperModel; 10 | 11 | import java.util.List; 12 | 13 | import butterknife.ButterKnife; 14 | 15 | public interface IShipperLoadCallbackListener { 16 | void onShipperLoadSuccess(List shipperModelList); 17 | void onShipperLoadSuccess(int pos, OrderModel orderModel, List shipperModels, 18 | AlertDialog dialog, 19 | Button btn_ok, Button btn_cancel, 20 | RadioButton rdi_shipping, RadioButton rdi_shipped, RadioButton rdi_cancelled, RadioButton rdi_delete, RadioButton rdi_restore_placed); 21 | void onShipperLoadFailed(String message); 22 | } 23 | -------------------------------------------------------------------------------- /androideatitv2server/Callback/ISingleShippingOrderCallbackListener.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Callback; 2 | 3 | import com.ds.androideatitv2server.Model.ShippingOrderModel; 4 | 5 | public interface ISingleShippingOrderCallbackListener { 6 | void onSingleShippingOrderLoadSuccess(ShippingOrderModel shippingOrderModel); 7 | } 8 | -------------------------------------------------------------------------------- /androideatitv2server/Callback/MyButtonClickListener.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Callback; 2 | 3 | public interface MyButtonClickListener { 4 | void onClick(int pos); 5 | } 6 | -------------------------------------------------------------------------------- /androideatitv2server/Common/BottomSheetOrderFragment.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Common; 2 | 3 | import android.os.Bundle; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | 8 | import androidx.annotation.NonNull; 9 | import androidx.annotation.Nullable; 10 | 11 | import com.ds.androideatitv2server.EventBus.LoadOrderEvent; 12 | import com.ds.androideatitv2server.R; 13 | import com.google.android.material.bottomsheet.BottomSheetDialogFragment; 14 | 15 | import org.greenrobot.eventbus.EventBus; 16 | 17 | import butterknife.ButterKnife; 18 | import butterknife.OnClick; 19 | import butterknife.Unbinder; 20 | 21 | public class BottomSheetOrderFragment extends BottomSheetDialogFragment { 22 | 23 | @OnClick(R.id.placed_filter) 24 | public void onPlacedFilterClick() 25 | { 26 | EventBus.getDefault().postSticky(new LoadOrderEvent(0)); 27 | dismiss(); 28 | } 29 | 30 | @OnClick(R.id.shipping_filter) 31 | public void onShippingFilterClick() 32 | { 33 | EventBus.getDefault().postSticky(new LoadOrderEvent(1)); 34 | dismiss(); 35 | } 36 | 37 | @OnClick(R.id.shipped_filter) 38 | public void onShippedFilterClick() 39 | { 40 | EventBus.getDefault().postSticky(new LoadOrderEvent(2)); 41 | dismiss(); 42 | } 43 | 44 | @OnClick(R.id.cancelled_filter) 45 | public void onCancelledFilterClick() 46 | { 47 | EventBus.getDefault().postSticky(new LoadOrderEvent(-1)); 48 | dismiss(); 49 | } 50 | private Unbinder unbinder; 51 | 52 | private static BottomSheetOrderFragment instance; 53 | 54 | public static BottomSheetOrderFragment getInstance() { 55 | return instance == null ? new BottomSheetOrderFragment() : instance; 56 | } 57 | 58 | public BottomSheetOrderFragment() { 59 | } 60 | 61 | @Override 62 | public void onCreate(@Nullable Bundle savedInstanceState) { 63 | super.onCreate(savedInstanceState); 64 | } 65 | 66 | @Nullable 67 | @Override 68 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 69 | View itemView = inflater.inflate(R.layout.fragment_order_filter, container, false); 70 | 71 | unbinder = ButterKnife.bind(this, itemView); 72 | return itemView; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /androideatitv2server/Common/SpacesItemDecoration.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Common; 2 | 3 | import android.graphics.Rect; 4 | import android.view.View; 5 | 6 | import androidx.annotation.NonNull; 7 | import androidx.recyclerview.widget.RecyclerView; 8 | 9 | public class SpacesItemDecoration extends RecyclerView.ItemDecoration { 10 | int space; 11 | 12 | public SpacesItemDecoration(int space) { 13 | this.space = space; 14 | } 15 | 16 | @Override 17 | public void getItemOffsets(@NonNull Rect outRect, @NonNull View view, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) { 18 | super.getItemOffsets(outRect, view, parent, state); 19 | outRect.top = outRect.bottom = outRect.left = outRect.right = space; 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /androideatitv2server/EventBus/AddonSizeEditEvent.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.EventBus; 2 | 3 | public class AddonSizeEditEvent { 4 | private boolean addon; 5 | private int pos; 6 | 7 | public AddonSizeEditEvent(boolean addon, int pos) { 8 | this.addon = addon; 9 | this.pos = pos; 10 | } 11 | 12 | public boolean isAddon() { 13 | return addon; 14 | } 15 | 16 | public void setAddon(boolean addon) { 17 | this.addon = addon; 18 | } 19 | 20 | public int getPos() { 21 | return pos; 22 | } 23 | 24 | public void setPos(int pos) { 25 | this.pos = pos; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /androideatitv2server/EventBus/CategoryClick.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.EventBus; 2 | 3 | import com.ds.androideatitv2server.Model.CategoryModel; 4 | 5 | public class CategoryClick { 6 | private boolean success; 7 | private CategoryModel categoryModel; 8 | 9 | public CategoryClick(boolean success, CategoryModel categoryModel) { 10 | this.success = success; 11 | this.categoryModel = categoryModel; 12 | } 13 | 14 | public boolean isSuccess() { 15 | return success; 16 | } 17 | 18 | public void setSuccess(boolean success) { 19 | this.success = success; 20 | } 21 | 22 | public CategoryModel getCategoryModel() { 23 | return categoryModel; 24 | } 25 | 26 | public void setCategoryModel(CategoryModel categoryModel) { 27 | this.categoryModel = categoryModel; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /androideatitv2server/EventBus/ChangeMenuClick.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.EventBus; 2 | 3 | public class ChangeMenuClick { 4 | private boolean isFromFoodList; 5 | 6 | public ChangeMenuClick(boolean isFromFoodList) { 7 | this.isFromFoodList = isFromFoodList; 8 | } 9 | 10 | public boolean isFromFoodList() { 11 | return isFromFoodList; 12 | } 13 | 14 | public void setFromFoodList(boolean fromFoodList) { 15 | isFromFoodList = fromFoodList; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /androideatitv2server/EventBus/LoadOrderEvent.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.EventBus; 2 | 3 | public class LoadOrderEvent { 4 | private int status; 5 | 6 | public LoadOrderEvent(int status) { 7 | this.status = status; 8 | } 9 | 10 | public int getStatus() { 11 | return status; 12 | } 13 | 14 | public void setStatus(int status) { 15 | this.status = status; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /androideatitv2server/EventBus/ToastEvent.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.EventBus; 2 | 3 | public class ToastEvent { 4 | private boolean isUpdate; 5 | private boolean isFromFoodlist; 6 | 7 | 8 | public ToastEvent(boolean isUpdate, boolean isFromFoodlist) { 9 | this.isUpdate = isUpdate; 10 | this.isFromFoodlist = isFromFoodlist; 11 | } 12 | 13 | public boolean isUpdate() { 14 | return isUpdate; 15 | } 16 | 17 | public void setUpdate(boolean update) { 18 | isUpdate = update; 19 | } 20 | 21 | public boolean isFromFoodlist() { 22 | return isFromFoodlist; 23 | } 24 | 25 | public void setFromFoodlist(boolean fromFoodlist) { 26 | isFromFoodlist = fromFoodlist; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /androideatitv2server/EventBus/UpdateShipperEvent.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.EventBus; 2 | 3 | import com.ds.androideatitv2server.Model.ShipperModel; 4 | 5 | public class UpdateShipperEvent { 6 | private ShipperModel shipperModel; 7 | private boolean active; 8 | 9 | public UpdateShipperEvent(ShipperModel shipperModel, boolean active) { 10 | this.shipperModel = shipperModel; 11 | this.active = active; 12 | } 13 | 14 | public ShipperModel getShipperModel() { 15 | return shipperModel; 16 | } 17 | 18 | public void setShipperModel(ShipperModel shipperModel) { 19 | this.shipperModel = shipperModel; 20 | } 21 | 22 | public boolean isActive() { 23 | return active; 24 | } 25 | 26 | public void setActive(boolean active) { 27 | this.active = active; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /androideatitv2server/Model/AddonModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Model; 2 | 3 | public class AddonModel { 4 | private String name; 5 | private Long price; 6 | 7 | public AddonModel() { 8 | } 9 | 10 | public String getName() { 11 | return name; 12 | } 13 | 14 | public void setName(String name) { 15 | this.name = name; 16 | } 17 | 18 | public Long getPrice() { 19 | return price; 20 | } 21 | 22 | public void setPrice(Long price) { 23 | this.price = price; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /androideatitv2server/Model/CartItem.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Model; 2 | 3 | 4 | import androidx.annotation.NonNull; 5 | 6 | 7 | public class CartItem { 8 | 9 | public String foodId; 10 | 11 | private String foodName; 12 | 13 | 14 | private String foodImage; 15 | 16 | 17 | private Double foodPrice; 18 | 19 | 20 | private int foodQuantity; 21 | 22 | private String userPhone; 23 | 24 | private Double foodExtraPrice; 25 | 26 | private String foodAddon; 27 | 28 | private String foodSize; 29 | 30 | private String uid; 31 | 32 | 33 | @NonNull 34 | public String getFoodId() { 35 | return foodId; 36 | } 37 | 38 | public void setFoodId(@NonNull String foodId) { 39 | this.foodId = foodId; 40 | } 41 | 42 | public String getFoodName() { 43 | return foodName; 44 | } 45 | 46 | public void setFoodName(String foodName) { 47 | this.foodName = foodName; 48 | } 49 | 50 | public String getFoodImage() { 51 | return foodImage; 52 | } 53 | 54 | public void setFoodImage(String foodImage) { 55 | this.foodImage = foodImage; 56 | } 57 | 58 | public Double getFoodPrice() { 59 | return foodPrice; 60 | } 61 | 62 | public void setFoodPrice(Double foodPrice) { 63 | this.foodPrice = foodPrice; 64 | } 65 | 66 | public int getFoodQuantity() { 67 | return foodQuantity; 68 | } 69 | 70 | public void setFoodQuantity(int foodQuantity) { 71 | this.foodQuantity = foodQuantity; 72 | } 73 | 74 | public String getUserPhone() { 75 | return userPhone; 76 | } 77 | 78 | public void setUserPhone(String userPhone) { 79 | this.userPhone = userPhone; 80 | } 81 | 82 | public Double getFoodExtraPrice() { 83 | return foodExtraPrice; 84 | } 85 | 86 | public void setFoodExtraPrice(Double foodExtraPrice) { 87 | this.foodExtraPrice = foodExtraPrice; 88 | } 89 | 90 | public String getFoodAddon() { 91 | return foodAddon; 92 | } 93 | 94 | public void setFoodAddon(String foodAddon) { 95 | this.foodAddon = foodAddon; 96 | } 97 | 98 | public String getFoodSize() { 99 | return foodSize; 100 | } 101 | 102 | public void setFoodSize(String foodSize) { 103 | this.foodSize = foodSize; 104 | } 105 | 106 | public String getUid() { 107 | return uid; 108 | } 109 | 110 | public void setUid(String uid) { 111 | this.uid = uid; 112 | } 113 | } -------------------------------------------------------------------------------- /androideatitv2server/Model/CategoryModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Model; 2 | 3 | import java.util.List; 4 | 5 | public class CategoryModel { 6 | private String menu_id,name,image; 7 | List foods; 8 | 9 | public CategoryModel() { 10 | } 11 | 12 | public String getMenu_id() { 13 | return menu_id; 14 | } 15 | 16 | public void setMenu_id(String menu_id) { 17 | this.menu_id = menu_id; 18 | } 19 | 20 | public String getName() { 21 | return name; 22 | } 23 | 24 | public void setName(String name) { 25 | this.name = name; 26 | } 27 | 28 | public String getImage() { 29 | return image; 30 | } 31 | 32 | public void setImage(String image) { 33 | this.image = image; 34 | } 35 | 36 | public List getFoods() { 37 | return foods; 38 | } 39 | 40 | public void setFoods(List foods) { 41 | this.foods = foods; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /androideatitv2server/Model/FCMResponse.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Model; 2 | 3 | 4 | import java.util.List; 5 | 6 | public class FCMResponse { 7 | private long multicast_id; 8 | private int success, failure, canonical_ids; 9 | private List results; 10 | private long message_id; 11 | 12 | public FCMResponse() { 13 | } 14 | 15 | public long getMulticast_id() { 16 | return multicast_id; 17 | } 18 | 19 | public void setMulticast_id(long multicast_id) { 20 | this.multicast_id = multicast_id; 21 | } 22 | 23 | public int getSuccess() { 24 | return success; 25 | } 26 | 27 | public void setSuccess(int success) { 28 | this.success = success; 29 | } 30 | 31 | public int getFailure() { 32 | return failure; 33 | } 34 | 35 | public void setFailure(int failure) { 36 | this.failure = failure; 37 | } 38 | 39 | public int getCanonical_ids() { 40 | return canonical_ids; 41 | } 42 | 43 | public void setCanonical_ids(int canonical_ids) { 44 | this.canonical_ids = canonical_ids; 45 | } 46 | 47 | public List getResults() { 48 | return results; 49 | } 50 | 51 | public void setResults(List results) { 52 | this.results = results; 53 | } 54 | 55 | public long getMessage_id() { 56 | return message_id; 57 | } 58 | 59 | public void setMessage_id(long message_id) { 60 | this.message_id = message_id; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /androideatitv2server/Model/FCMResult.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Model; 2 | 3 | public class FCMResult { 4 | private String message_id; 5 | 6 | public FCMResult() { 7 | } 8 | 9 | public String getMessage_id() { 10 | return message_id; 11 | } 12 | 13 | public void setMessage_id(String message_id) { 14 | this.message_id = message_id; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /androideatitv2server/Model/FCMSendData.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Model; 2 | 3 | import java.util.Map; 4 | 5 | public class FCMSendData { 6 | 7 | private String to; 8 | private Map data; 9 | 10 | public FCMSendData(String to, Map data) { 11 | this.to = to; 12 | this.data = data; 13 | } 14 | 15 | public String getTo() { 16 | return to; 17 | } 18 | 19 | public void setTo(String to) { 20 | this.to = to; 21 | } 22 | 23 | public Map getData() { 24 | return data; 25 | } 26 | 27 | public void setData(Map data) { 28 | this.data = data; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /androideatitv2server/Model/FoodModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Model; 2 | 3 | import java.util.List; 4 | 5 | public class FoodModel { 6 | private String key; 7 | private String name,image,id,description; 8 | private Long price; 9 | private List addon; 10 | private List size; 11 | private Double ratingValue; 12 | private Long ratingCount; 13 | 14 | //For Cart 15 | private List userSelectedAddon; 16 | private SizeModel userSelectedSize; 17 | 18 | //For Search 19 | private int positionInList = -1; 20 | 21 | public FoodModel() { 22 | 23 | } 24 | 25 | public String getName() { 26 | return name; 27 | } 28 | 29 | public String getImage() { 30 | return image; 31 | } 32 | 33 | public String getId() { 34 | return id; 35 | } 36 | 37 | public String getDescription() { 38 | return description; 39 | } 40 | 41 | public Long getPrice() { 42 | return price; 43 | } 44 | 45 | public List getAddon() { 46 | return addon; 47 | } 48 | 49 | public List getSize() { 50 | return size; 51 | } 52 | 53 | public String getKey() { 54 | return key; 55 | } 56 | 57 | public void setKey(String key) { 58 | this.key = key; 59 | } 60 | 61 | public Double getRatingValue() { 62 | return ratingValue; 63 | } 64 | 65 | public void setRatingValue(Double ratingValue) { 66 | this.ratingValue = ratingValue; 67 | } 68 | 69 | public Long getRatingCount() { 70 | return ratingCount; 71 | } 72 | 73 | public void setRatingCount(Long ratingCount) { 74 | this.ratingCount = ratingCount; 75 | } 76 | 77 | public List getUserSelectedAddon() { 78 | return userSelectedAddon; 79 | } 80 | 81 | public void setUserSelectedAddon(List userSelectedAddon) { 82 | this.userSelectedAddon = userSelectedAddon; 83 | } 84 | 85 | public SizeModel getUserSelectedSize() { 86 | return userSelectedSize; 87 | } 88 | 89 | public void setUserSelectedSize(SizeModel userSelectedSize) { 90 | this.userSelectedSize = userSelectedSize; 91 | } 92 | 93 | public void setName(String name) { 94 | this.name = name; 95 | } 96 | 97 | public void setImage(String image) { 98 | this.image = image; 99 | } 100 | 101 | public void setId(String id) { 102 | this.id = id; 103 | } 104 | 105 | public void setDescription(String description) { 106 | this.description = description; 107 | } 108 | 109 | public void setPrice(Long price) { 110 | this.price = price; 111 | } 112 | 113 | public void setAddon(List addon) { 114 | this.addon = addon; 115 | } 116 | 117 | public void setSize(List size) { 118 | this.size = size; 119 | } 120 | 121 | //this takes the position odthe food after searching 122 | public int getPositionInList() { 123 | return positionInList; 124 | } 125 | 126 | public void setPositionInList(int positionInList) { 127 | this.positionInList = positionInList; 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /androideatitv2server/Model/OrderModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Model; 2 | 3 | 4 | import java.util.List; 5 | 6 | public class OrderModel { 7 | private String key; 8 | private String userId, userName, userPhone,shippingAddress,comment, transactionId; 9 | private double lat,lng,totalPayment,finalPayment; 10 | private boolean cod; 11 | private int discount; 12 | private List cartItemList; 13 | private long createDate; 14 | private String orderNumber; 15 | private int orderStatus; 16 | 17 | public OrderModel() { 18 | } 19 | 20 | public String getKey() { 21 | return key; 22 | } 23 | 24 | public void setKey(String key) { 25 | this.key = key; 26 | } 27 | 28 | public String getUserId() { 29 | return userId; 30 | } 31 | 32 | public void setUserId(String userId) { 33 | this.userId = userId; 34 | } 35 | 36 | public String getUserName() { 37 | return userName; 38 | } 39 | 40 | public void setUserName(String userName) { 41 | this.userName = userName; 42 | } 43 | 44 | public String getUserPhone() { 45 | return userPhone; 46 | } 47 | 48 | public void setUserPhone(String userPhone) { 49 | this.userPhone = userPhone; 50 | } 51 | 52 | public String getShippingAddress() { 53 | return shippingAddress; 54 | } 55 | 56 | public void setShippingAddress(String shippingAddress) { 57 | this.shippingAddress = shippingAddress; 58 | } 59 | 60 | public String getComment() { 61 | return comment; 62 | } 63 | 64 | public void setComment(String comment) { 65 | this.comment = comment; 66 | } 67 | 68 | public String getTransactionId() { 69 | return transactionId; 70 | } 71 | 72 | public void setTransactionId(String transactionId) { 73 | this.transactionId = transactionId; 74 | } 75 | 76 | public double getLat() { 77 | return lat; 78 | } 79 | 80 | public void setLat(double lat) { 81 | this.lat = lat; 82 | } 83 | 84 | public double getLng() { 85 | return lng; 86 | } 87 | 88 | public void setLng(double lng) { 89 | this.lng = lng; 90 | } 91 | 92 | public double getTotalPayment() { 93 | return totalPayment; 94 | } 95 | 96 | public void setTotalPayment(double totalPayment) { 97 | this.totalPayment = totalPayment; 98 | } 99 | 100 | public double getFinalPayment() { 101 | return finalPayment; 102 | } 103 | 104 | public void setFinalPayment(double finalPayment) { 105 | this.finalPayment = finalPayment; 106 | } 107 | 108 | public boolean isCod() { 109 | return cod; 110 | } 111 | 112 | public void setCod(boolean cod) { 113 | this.cod = cod; 114 | } 115 | 116 | public int getDiscount() { 117 | return discount; 118 | } 119 | 120 | public void setDiscount(int discount) { 121 | this.discount = discount; 122 | } 123 | 124 | public List getCartItemList() { 125 | return cartItemList; 126 | } 127 | 128 | public void setCartItemList(List cartItemList) { 129 | this.cartItemList = cartItemList; 130 | } 131 | 132 | public long getCreateDate() { 133 | return createDate; 134 | } 135 | 136 | public void setCreateDate(long createDate) { 137 | this.createDate = createDate; 138 | } 139 | 140 | public String getOrderNumber() { 141 | return orderNumber; 142 | } 143 | 144 | public void setOrderNumber(String orderNumber) { 145 | this.orderNumber = orderNumber; 146 | } 147 | 148 | public int getOrderStatus() { 149 | return orderStatus; 150 | } 151 | 152 | public void setOrderStatus(int orderStatus) { 153 | this.orderStatus = orderStatus; 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /androideatitv2server/Model/SelectAddonModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Model; 2 | 3 | public class SelectAddonModel { 4 | private AddonModel addonModel; 5 | 6 | public SelectAddonModel(AddonModel addonModel) { 7 | this.addonModel = addonModel; 8 | } 9 | 10 | public AddonModel getAddonModel() { 11 | return addonModel; 12 | } 13 | 14 | public void setAddonModel(AddonModel addonModel) { 15 | this.addonModel = addonModel; 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /androideatitv2server/Model/SelectSizeModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Model; 2 | 3 | public class SelectSizeModel { 4 | private SizeModel sizeModel; 5 | 6 | public SelectSizeModel(SizeModel sizeModel) { 7 | this.sizeModel = sizeModel; 8 | } 9 | 10 | public SizeModel getSizeModel() { 11 | return sizeModel; 12 | } 13 | 14 | public void setSizeModel(SizeModel sizeModel) { 15 | this.sizeModel = sizeModel; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /androideatitv2server/Model/ServerUserModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Model; 2 | 3 | public class ServerUserModel { 4 | private String uid, name, phone; 5 | private boolean active; 6 | 7 | public ServerUserModel() { 8 | } 9 | 10 | public ServerUserModel(String uid, String name, String phone, boolean active) { 11 | this.uid = uid; 12 | this.name = name; 13 | this.phone = phone; 14 | this.active = active; 15 | } 16 | 17 | public String getUid() { 18 | return uid; 19 | } 20 | 21 | public void setUid(String uid) { 22 | this.uid = uid; 23 | } 24 | 25 | public String getName() { 26 | return name; 27 | } 28 | 29 | public void setName(String name) { 30 | this.name = name; 31 | } 32 | 33 | public String getPhone() { 34 | return phone; 35 | } 36 | 37 | public void setPhone(String phone) { 38 | this.phone = phone; 39 | } 40 | 41 | public boolean isActive() { 42 | return active; 43 | } 44 | 45 | public void setActive(boolean active) { 46 | this.active = active; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /androideatitv2server/Model/ShipperModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Model; 2 | 3 | public class ShipperModel { 4 | private String key,uid,phone,name; 5 | private boolean active; 6 | 7 | public ShipperModel() { 8 | } 9 | 10 | public String getKey() { 11 | return key; 12 | } 13 | 14 | public void setKey(String key) { 15 | this.key = key; 16 | } 17 | 18 | public String getUid() { 19 | return uid; 20 | } 21 | 22 | public void setUid(String uid) { 23 | this.uid = uid; 24 | } 25 | 26 | public String getPhone() { 27 | return phone; 28 | } 29 | 30 | public void setPhone(String phone) { 31 | this.phone = phone; 32 | } 33 | 34 | public String getName() { 35 | return name; 36 | } 37 | 38 | public void setName(String name) { 39 | this.name = name; 40 | } 41 | 42 | public boolean isActive() { 43 | return active; 44 | } 45 | 46 | public void setActive(boolean active) { 47 | this.active = active; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /androideatitv2server/Model/ShippingOrderModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Model; 2 | 3 | public class ShippingOrderModel { 4 | private String key; 5 | private String shipperPhone, shipperName; 6 | private double currentLat, currentLng; 7 | private OrderModel orderModel; 8 | private boolean isStartTrip; 9 | 10 | public ShippingOrderModel() { 11 | } 12 | 13 | public String getKey() { 14 | return key; 15 | } 16 | 17 | public void setKey(String key) { 18 | this.key = key; 19 | } 20 | 21 | public String getShipperPhone() { 22 | return shipperPhone; 23 | } 24 | 25 | public void setShipperPhone(String shipperPhone) { 26 | this.shipperPhone = shipperPhone; 27 | } 28 | 29 | public String getShipperName() { 30 | return shipperName; 31 | } 32 | 33 | public void setShipperName(String shipperName) { 34 | this.shipperName = shipperName; 35 | } 36 | 37 | public double getCurrentLat() { 38 | return currentLat; 39 | } 40 | 41 | public void setCurrentLat(double currentLat) { 42 | this.currentLat = currentLat; 43 | } 44 | 45 | public double getCurrentLng() { 46 | return currentLng; 47 | } 48 | 49 | public void setCurrentLng(double currentLng) { 50 | this.currentLng = currentLng; 51 | } 52 | 53 | public OrderModel getOrderModel() { 54 | return orderModel; 55 | } 56 | 57 | public void setOrderModel(OrderModel orderModel) { 58 | this.orderModel = orderModel; 59 | } 60 | 61 | public boolean isStartTrip() { 62 | return isStartTrip; 63 | } 64 | 65 | public void setStartTrip(boolean startTrip) { 66 | isStartTrip = startTrip; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /androideatitv2server/Model/SizeModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Model; 2 | 3 | public class SizeModel { 4 | private String name; 5 | private Long price; 6 | 7 | public SizeModel() { 8 | } 9 | 10 | public String getName() { 11 | return name; 12 | } 13 | 14 | public void setName(String name) { 15 | this.name = name; 16 | } 17 | 18 | public Long getPrice() { 19 | return price; 20 | } 21 | 22 | public void setPrice(Long price) { 23 | this.price = price; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /androideatitv2server/Model/TokenModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Model; 2 | 3 | 4 | public class TokenModel { 5 | private String phone, token; 6 | private boolean serverToken, shipperToken; 7 | 8 | public TokenModel() { 9 | } 10 | 11 | public TokenModel(String phone, String token, boolean serverToken, boolean shipperToken) { 12 | this.phone = phone; 13 | this.token = token; 14 | this.serverToken = serverToken; 15 | this.shipperToken = shipperToken; 16 | } 17 | 18 | public String getPhone() { 19 | return phone; 20 | } 21 | 22 | public void setPhone(String phone) { 23 | this.phone = phone; 24 | } 25 | 26 | public String getToken() { 27 | return token; 28 | } 29 | 30 | public void setToken(String token) { 31 | this.token = token; 32 | } 33 | 34 | public boolean isServerToken() { 35 | return serverToken; 36 | } 37 | 38 | public void setServerToken(boolean serverToken) { 39 | this.serverToken = serverToken; 40 | } 41 | 42 | public boolean isShipperToken() { 43 | return shipperToken; 44 | } 45 | 46 | public void setShipperToken(boolean shipperToken) { 47 | this.shipperToken = shipperToken; 48 | } 49 | } 50 | 51 | -------------------------------------------------------------------------------- /androideatitv2server/Model/UpdateAddonModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Model; 2 | 3 | import java.util.List; 4 | 5 | public class UpdateAddonModel { 6 | private List addonModels; 7 | 8 | public UpdateAddonModel() { 9 | } 10 | 11 | public List getAddonModels() { 12 | return addonModels; 13 | } 14 | 15 | public void setAddonModels(List addonModels) { 16 | this.addonModels = addonModels; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /androideatitv2server/Model/UpdateSizeModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Model; 2 | 3 | import java.util.List; 4 | 5 | public class UpdateSizeModel { 6 | private List sizeModelList; 7 | 8 | public UpdateSizeModel() { 9 | } 10 | 11 | public UpdateSizeModel(List sizeModelList) { 12 | this.sizeModelList = sizeModelList; 13 | } 14 | 15 | public List getSizeModelList() { 16 | return sizeModelList; 17 | } 18 | 19 | public void setSizeModelList(List sizeModelList) { 20 | this.sizeModelList = sizeModelList; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /androideatitv2server/Remote/IFCMService.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Remote; 2 | 3 | import com.ds.androideatitv2server.Model.FCMResponse; 4 | import com.ds.androideatitv2server.Model.FCMSendData; 5 | 6 | import io.reactivex.Observable; 7 | import retrofit2.http.Body; 8 | import retrofit2.http.Headers; 9 | import retrofit2.http.POST; 10 | 11 | public interface IFCMService { 12 | @Headers({ 13 | "Content-Type:application/json", 14 | "Authorization:key=AAAAKK2HWaQ:APA91bGDvCgZvaQFUB1kg17PWD5WCl7qlzBx2rh9-y8EylcI7IOE44qfIScmrZxZosLi1a_DzmXal0uXmsQexLyiBwLtHOG5ffvhIyJg1110uZsT-gdSrzO3PF71IEUNi7Ark6OY4a8I" 15 | }) 16 | @POST("fcm/send") 17 | Observable sendNotification(@Body FCMSendData body); 18 | } 19 | 20 | -------------------------------------------------------------------------------- /androideatitv2server/Remote/IGoogleAPI.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Remote; 2 | 3 | import io.reactivex.Observable; 4 | import retrofit2.http.GET; 5 | import retrofit2.http.Query; 6 | 7 | public interface IGoogleAPI { 8 | @GET("maps/api/directions/json") 9 | Observable getDirections( 10 | @Query("mode") String mode, 11 | @Query("transit_routing_preference") String transit_routing, 12 | @Query("origin") String from, 13 | @Query("destination") String to, 14 | @Query("key") String key); 15 | } 16 | 17 | -------------------------------------------------------------------------------- /androideatitv2server/Remote/RetrofitFCMClient.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Remote; 2 | 3 | import retrofit2.Retrofit; 4 | import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; 5 | import retrofit2.converter.gson.GsonConverterFactory; 6 | 7 | public class RetrofitFCMClient { 8 | private static Retrofit instance; 9 | public static Retrofit getInstance(){ 10 | 11 | 12 | 13 | if(instance == null) 14 | instance = new Retrofit.Builder() 15 | .baseUrl("https://fcm.googleapis.com/") 16 | .addConverterFactory(GsonConverterFactory.create()) 17 | .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) 18 | .build(); 19 | return instance; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /androideatitv2server/Remote/RetrofitGoogleAPIClient.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.Remote; 2 | 3 | 4 | import retrofit2.Retrofit; 5 | import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; 6 | import retrofit2.converter.scalars.ScalarsConverterFactory; 7 | 8 | public class RetrofitGoogleAPIClient { 9 | private static Retrofit instance; 10 | 11 | public static Retrofit getInstance(){ 12 | return instance == null ? new Retrofit.Builder() 13 | .baseUrl("https://maps.googleapis.com/") 14 | .addConverterFactory(ScalarsConverterFactory.create()) 15 | .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) 16 | .build() : instance; 17 | 18 | } 19 | } -------------------------------------------------------------------------------- /androideatitv2server/services/MyFCMServices.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.services; 2 | 3 | import android.content.Intent; 4 | 5 | import androidx.annotation.NonNull; 6 | 7 | import com.ds.androideatitv2server.Common.Common; 8 | import com.ds.androideatitv2server.MainActivity; 9 | import com.google.firebase.messaging.FirebaseMessagingService; 10 | import com.google.firebase.messaging.RemoteMessage; 11 | 12 | import java.util.Map; 13 | import java.util.Random; 14 | 15 | public class MyFCMServices extends FirebaseMessagingService { 16 | 17 | @Override 18 | public void onMessageReceived(@NonNull RemoteMessage remoteMessage) { 19 | Map dataRecv = remoteMessage.getData(); 20 | if (dataRecv != null) 21 | { 22 | if (dataRecv.get(Common.NOTI_TITLE).equals("New Order")) 23 | { 24 | /* 25 | * Here we need to Mcall ainActivity cuz we must assign value for Common.currentUser 26 | * so we must call MainActivity to do that, if we directly called HomeActivity the will get crashing 27 | * due of Common.currentUser only be assigned in MainActivity AFTER LOGIN 28 | * */ 29 | 30 | Intent intent = new Intent(this, MainActivity.class); 31 | intent.putExtra(Common.IS_OPEN_ACTIVITY_NEW_ORDER, true); // Using extra to detect if app opened from notification 32 | Common.showNotification(this, new Random().nextInt(), 33 | dataRecv.get(Common.NOTI_TITLE), 34 | dataRecv.get(Common.NOTI_CONTENT), 35 | intent); 36 | 37 | } 38 | else 39 | { 40 | Common.showNotification(this, new Random().nextInt(), 41 | dataRecv.get(Common.NOTI_TITLE), 42 | dataRecv.get(Common.NOTI_CONTENT), 43 | null); 44 | } 45 | 46 | } 47 | } 48 | 49 | @Override 50 | public void onNewToken(@NonNull String s) { 51 | super.onNewToken(s); 52 | Common.updateToken(this,s,true, false); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /androideatitv2server/ui/category/CategoryViewModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.ui.category; 2 | 3 | import androidx.annotation.NonNull; 4 | import androidx.lifecycle.MutableLiveData; 5 | import androidx.lifecycle.ViewModel; 6 | 7 | import com.ds.androideatitv2server.Callback.ICategoryCallbackListener; 8 | import com.ds.androideatitv2server.Common.Common; 9 | import com.ds.androideatitv2server.Model.CategoryModel; 10 | import com.google.firebase.database.DataSnapshot; 11 | import com.google.firebase.database.DatabaseError; 12 | import com.google.firebase.database.DatabaseReference; 13 | import com.google.firebase.database.FirebaseDatabase; 14 | import com.google.firebase.database.ValueEventListener; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | public class CategoryViewModel extends ViewModel implements ICategoryCallbackListener { 20 | 21 | private MutableLiveData> categoryListMutable; 22 | private MutableLiveData messageError = new MutableLiveData<>(); 23 | private ICategoryCallbackListener categoryCallbackListener; 24 | 25 | public CategoryViewModel() { 26 | categoryCallbackListener = this; 27 | } 28 | 29 | public MutableLiveData> getCategoryListMultable() { 30 | if(categoryListMutable == null) 31 | { 32 | categoryListMutable = new MutableLiveData<>(); 33 | messageError = new MutableLiveData<>(); 34 | loadCategories(); 35 | } 36 | return categoryListMutable; 37 | } 38 | 39 | public void loadCategories() { 40 | List tempList = new ArrayList<>(); 41 | DatabaseReference categoryRef = FirebaseDatabase.getInstance().getReference(Common.CATEGORY_REF); 42 | categoryRef.addListenerForSingleValueEvent(new ValueEventListener() { 43 | @Override 44 | public void onDataChange(@NonNull DataSnapshot dataSnapshot) { 45 | for(DataSnapshot itemSnapShot:dataSnapshot.getChildren()) 46 | { 47 | CategoryModel categoryModel = itemSnapShot.getValue(CategoryModel.class); 48 | categoryModel.setMenu_id(itemSnapShot.getKey()); 49 | tempList.add(categoryModel); 50 | } 51 | categoryCallbackListener.onCategoryLoadSuccess(tempList); 52 | } 53 | 54 | @Override 55 | public void onCancelled(@NonNull DatabaseError databaseError) { 56 | categoryCallbackListener.onCategoryLoadFailed(databaseError.getMessage()); 57 | } 58 | }); 59 | } 60 | 61 | public MutableLiveData getMessageError() { 62 | return messageError; 63 | } 64 | 65 | 66 | @Override 67 | public void onCategoryLoadSuccess(List categoryModelList) { 68 | categoryListMutable.setValue(categoryModelList); 69 | } 70 | 71 | @Override 72 | public void onCategoryLoadFailed(String message) { 73 | messageError.setValue(message); 74 | } 75 | } -------------------------------------------------------------------------------- /androideatitv2server/ui/food_list/FoodListViewModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.ui.food_list; 2 | 3 | import androidx.lifecycle.LiveData; 4 | import androidx.lifecycle.MutableLiveData; 5 | import androidx.lifecycle.ViewModel; 6 | 7 | import com.ds.androideatitv2server.Common.Common; 8 | import com.ds.androideatitv2server.Model.FoodModel; 9 | 10 | import java.util.List; 11 | 12 | public class FoodListViewModel extends ViewModel { 13 | 14 | private MutableLiveData> mutableLiveDataFoodList; 15 | 16 | public FoodListViewModel() { 17 | 18 | } 19 | 20 | public MutableLiveData> getMutableLiveDataFoodList() { 21 | if(mutableLiveDataFoodList == null) 22 | mutableLiveDataFoodList = new MutableLiveData<>(); 23 | mutableLiveDataFoodList.setValue(Common.categorySelected.getFoods()); 24 | return mutableLiveDataFoodList; 25 | } 26 | } -------------------------------------------------------------------------------- /androideatitv2server/ui/order/OrderViewModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.ui.order; 2 | 3 | import androidx.annotation.NonNull; 4 | import androidx.lifecycle.LiveData; 5 | import androidx.lifecycle.MutableLiveData; 6 | import androidx.lifecycle.ViewModel; 7 | 8 | import com.ds.androideatitv2server.Callback.IOrderCallbackListener; 9 | import com.ds.androideatitv2server.Common.Common; 10 | import com.ds.androideatitv2server.Model.OrderModel; 11 | import com.google.firebase.database.DataSnapshot; 12 | import com.google.firebase.database.DatabaseError; 13 | import com.google.firebase.database.FirebaseDatabase; 14 | import com.google.firebase.database.Query; 15 | import com.google.firebase.database.ValueEventListener; 16 | 17 | import java.util.ArrayList; 18 | import java.util.Collection; 19 | import java.util.Collections; 20 | import java.util.List; 21 | 22 | public class OrderViewModel extends ViewModel implements IOrderCallbackListener { 23 | 24 | private MutableLiveData> orderMoListMutableLiveData; 25 | private MutableLiveData messageError; 26 | 27 | private IOrderCallbackListener listener; 28 | 29 | public OrderViewModel() { 30 | orderMoListMutableLiveData = new MutableLiveData<>(); 31 | messageError = new MutableLiveData<>(); 32 | listener = this; 33 | 34 | } 35 | 36 | public MutableLiveData> getOrderMoListMutableLiveData() { 37 | loadOrderByStatus(0); 38 | return orderMoListMutableLiveData; 39 | } 40 | 41 | public void loadOrderByStatus(int status) { 42 | List tempList = new ArrayList<>(); 43 | Query orderRef = FirebaseDatabase.getInstance().getReference(Common.ORDER_REF) 44 | .orderByChild("orderStatus") 45 | .equalTo(status); 46 | orderRef.addListenerForSingleValueEvent(new ValueEventListener() { 47 | @Override 48 | public void onDataChange(@NonNull DataSnapshot dataSnapshot) { 49 | for(DataSnapshot itemSnapshot : dataSnapshot.getChildren()) 50 | { 51 | OrderModel orderModel = itemSnapshot.getValue(OrderModel.class); 52 | orderModel.setKey(itemSnapshot.getKey()); // Dont forget it 53 | orderModel.setOrderNumber(itemSnapshot.getKey()); // Dont forget it 54 | 55 | tempList.add(orderModel); 56 | } 57 | listener.onOrderLoadSuccess(tempList); 58 | } 59 | 60 | @Override 61 | public void onCancelled(@NonNull DatabaseError databaseError) { 62 | listener.onOrderLoadFailed(databaseError.getMessage()); 63 | } 64 | }); 65 | } 66 | 67 | public MutableLiveData getMessageError() { 68 | return messageError; 69 | } 70 | 71 | @Override 72 | public void onOrderLoadSuccess(List orderModelList) { 73 | if (orderModelList.size() > 0) 74 | { 75 | Collections.sort(orderModelList, (orderModel, t1) -> { 76 | if (orderModel.getCreateDate() < t1.getCreateDate()) 77 | return -1; 78 | return orderModel.getCreateDate() == t1.getCreateDate() ? 0: 1; 79 | }); 80 | } 81 | 82 | orderMoListMutableLiveData.setValue(orderModelList); 83 | } 84 | 85 | @Override 86 | public void onOrderLoadFailed(String message) { 87 | messageError.setValue(message); 88 | } 89 | } -------------------------------------------------------------------------------- /androideatitv2server/ui/shipper/ShipperViewModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2server.ui.shipper; 2 | 3 | import android.widget.Button; 4 | import android.widget.RadioButton; 5 | 6 | import androidx.annotation.NonNull; 7 | import androidx.appcompat.app.AlertDialog; 8 | import androidx.lifecycle.MutableLiveData; 9 | import androidx.lifecycle.ViewModel; 10 | 11 | import com.ds.androideatitv2server.Callback.IShipperLoadCallbackListener; 12 | import com.ds.androideatitv2server.Common.Common; 13 | import com.ds.androideatitv2server.Model.OrderModel; 14 | import com.ds.androideatitv2server.Model.ShipperModel; 15 | import com.google.firebase.database.DataSnapshot; 16 | import com.google.firebase.database.DatabaseError; 17 | import com.google.firebase.database.DatabaseReference; 18 | import com.google.firebase.database.FirebaseDatabase; 19 | import com.google.firebase.database.ValueEventListener; 20 | 21 | import java.util.ArrayList; 22 | import java.util.List; 23 | 24 | public class ShipperViewModel extends ViewModel implements IShipperLoadCallbackListener { 25 | // TODO: Implement the ViewModel 26 | private MutableLiveData messageError = new MutableLiveData<>(); 27 | private MutableLiveData> shipperMutableList; 28 | private IShipperLoadCallbackListener shipperLoadCallbackListener; 29 | 30 | public ShipperViewModel() { 31 | shipperLoadCallbackListener = this; 32 | } 33 | 34 | public MutableLiveData getMessageError() { 35 | return messageError; 36 | } 37 | 38 | public MutableLiveData> getShipperMutableList() { 39 | if (shipperMutableList == null) 40 | { 41 | shipperMutableList = new MutableLiveData<>(); 42 | loadShipper(); 43 | } 44 | return shipperMutableList; 45 | } 46 | 47 | private void loadShipper() { 48 | List tempList = new ArrayList<>(); 49 | DatabaseReference shipperRef = FirebaseDatabase.getInstance().getReference(Common.SHIPPER); 50 | 51 | shipperRef.addListenerForSingleValueEvent(new ValueEventListener() { 52 | @Override 53 | public void onDataChange(@NonNull DataSnapshot dataSnapshot) { 54 | for(DataSnapshot shipperSnapShot:dataSnapshot.getChildren()) 55 | { 56 | ShipperModel shipperModel = shipperSnapShot.getValue(ShipperModel.class); 57 | shipperModel.setKey(shipperSnapShot.getKey()); 58 | tempList.add(shipperModel); 59 | } 60 | shipperLoadCallbackListener.onShipperLoadSuccess(tempList); 61 | } 62 | 63 | @Override 64 | public void onCancelled(@NonNull DatabaseError databaseError) { 65 | shipperLoadCallbackListener.onShipperLoadFailed(databaseError.getMessage()); 66 | } 67 | }); 68 | } 69 | 70 | @Override 71 | public void onShipperLoadSuccess(List shipperModelList) { 72 | if (shipperMutableList!= null) 73 | shipperMutableList.setValue(shipperModelList); 74 | 75 | } 76 | 77 | @Override 78 | public void onShipperLoadSuccess(int pos, OrderModel orderModel, List shipperModels, AlertDialog dialog, Button btn_ok, Button btn_cancel, RadioButton rdi_shipping, RadioButton rdi_shipped, RadioButton rdi_cancelled, RadioButton rdi_delete, RadioButton rdi_restore_placed) { 79 | //Do nothing 80 | } 81 | 82 | @Override 83 | public void onShipperLoadFailed(String message) { 84 | messageError.setValue(message); 85 | } 86 | } -------------------------------------------------------------------------------- /androideatitv2shipper/Adapters/MyShippingOrderAdapter.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2shipper.Adapters; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.graphics.Color; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.ImageView; 10 | import android.widget.TextView; 11 | 12 | import androidx.annotation.NonNull; 13 | import androidx.appcompat.widget.SwitchCompat; 14 | import androidx.recyclerview.widget.RecyclerView; 15 | 16 | import com.bumptech.glide.Glide; 17 | import com.ds.androideatitv2shipper.Common.Common; 18 | import com.ds.androideatitv2shipper.Model.ShippingOrderModel; 19 | import com.ds.androideatitv2shipper.R; 20 | import com.ds.androideatitv2shipper.ShippingActivity; 21 | import com.google.android.material.button.MaterialButton; 22 | import com.google.gson.Gson; 23 | 24 | 25 | import java.text.SimpleDateFormat; 26 | import java.util.List; 27 | 28 | import butterknife.BindView; 29 | import butterknife.ButterKnife; 30 | import butterknife.Unbinder; 31 | import io.paperdb.Paper; 32 | 33 | public class MyShippingOrderAdapter extends RecyclerView.Adapter { 34 | 35 | Context context; 36 | List shippingOrderModelList; 37 | SimpleDateFormat simpleDateFormat; 38 | 39 | public MyShippingOrderAdapter(Context context, List shippingOrderModelList) { 40 | this.context = context; 41 | this.shippingOrderModelList = shippingOrderModelList; 42 | simpleDateFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); 43 | 44 | Paper.init(context); 45 | } 46 | 47 | @NonNull 48 | @Override 49 | public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { 50 | View itemView= LayoutInflater.from(context).inflate(R.layout.layout_order_shipper, parent, false); 51 | return new MyViewHolder(itemView); 52 | } 53 | 54 | @Override 55 | public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { 56 | Glide.with(context) 57 | .load(shippingOrderModelList.get(position).getOrderModel().getCartItemList() 58 | .get(0).getFoodImage()) 59 | .into(holder.img_food); 60 | holder.txt_date.setText(new StringBuilder( 61 | simpleDateFormat.format(shippingOrderModelList.get(position).getOrderModel().getCreateDate()) 62 | )); 63 | 64 | Common.setSpanStringColor("No.: ", 65 | shippingOrderModelList.get(position).getOrderModel().getKey(), 66 | holder.txt_order_number, Color.parseColor("#BA454A")); 67 | Common.setSpanStringColor("Address: ", 68 | shippingOrderModelList.get(position).getOrderModel().getShippingAddress(), 69 | holder.txt_order_address, Color.parseColor("#BA454A")); 70 | Common.setSpanStringColor("Payment: ", 71 | shippingOrderModelList.get(position).getOrderModel().getTransactionId(), 72 | holder.txt_payment, Color.parseColor("#BA454A")); 73 | 74 | //Disable button if trip already has been started 75 | if (shippingOrderModelList.get(position).isStartTrip()) 76 | { 77 | holder.btn_ship_now.setEnabled(false); 78 | } 79 | 80 | //Event 81 | holder.btn_ship_now.setOnClickListener(view -> { 82 | 83 | Paper.book().write(Common.SHIPPING_ORDER_DATA, new Gson().toJson(shippingOrderModelList.get(position))); 84 | 85 | context.startActivity(new Intent(context, ShippingActivity.class)); 86 | }); 87 | 88 | 89 | } 90 | 91 | @Override 92 | public int getItemCount() { 93 | return shippingOrderModelList.size(); 94 | } 95 | 96 | 97 | public class MyViewHolder extends RecyclerView.ViewHolder { 98 | private Unbinder unbinder; 99 | 100 | @BindView(R.id.txt_date) 101 | TextView txt_date; 102 | @BindView(R.id.txt_order_address) 103 | TextView txt_order_address; 104 | @BindView(R.id.txt_order_number) 105 | TextView txt_order_number; 106 | @BindView(R.id.txt_payment) 107 | TextView txt_payment; 108 | @BindView(R.id.img_food) 109 | ImageView img_food; 110 | @BindView(R.id.btn_ship_now) 111 | MaterialButton btn_ship_now; 112 | 113 | public MyViewHolder(@NonNull View itemView) { 114 | super(itemView); 115 | unbinder = ButterKnife.bind(this, itemView); 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /androideatitv2shipper/Callbacks/IShippingOrderCallbackListener.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2shipper.Callbacks; 2 | 3 | import com.ds.androideatitv2shipper.Model.ShippingOrderModel; 4 | 5 | import java.util.List; 6 | 7 | public interface IShippingOrderCallbackListener { 8 | void onShippingOrderLoadSuccess(List shippingOrderModelList); 9 | void onShippingOrderLoadFailed(String message); 10 | } 11 | -------------------------------------------------------------------------------- /androideatitv2shipper/Common/LatLngInterpolator.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2shipper.Common; 2 | 3 | import com.google.android.gms.maps.model.LatLng; 4 | 5 | import static java.lang.StrictMath.asin; 6 | import static java.lang.StrictMath.atan2; 7 | import static java.lang.StrictMath.cos; 8 | import static java.lang.StrictMath.pow; 9 | import static java.lang.StrictMath.sin; 10 | import static java.lang.StrictMath.sqrt; 11 | import static java.lang.StrictMath.toDegrees; 12 | import static java.lang.StrictMath.toRadians; 13 | 14 | public interface LatLngInterpolator { 15 | LatLng interpolate(float fraction, LatLng a, LatLng b); 16 | 17 | class Linear implements LatLngInterpolator { 18 | 19 | @Override 20 | public LatLng interpolate(float fraction, LatLng a, LatLng b) { 21 | double lat = (b.latitude - a.latitude) *fraction +a.latitude; 22 | double lng = (b.longitude - a.longitude) *fraction +a.longitude; 23 | 24 | return new LatLng(lat, lng); 25 | } 26 | 27 | } 28 | 29 | class LinearFixed implements LatLngInterpolator { 30 | 31 | @Override 32 | public LatLng interpolate(float fraction, LatLng a, LatLng b) { 33 | double lat = (b.latitude - a.latitude) *fraction + a.latitude; 34 | double lngDelta = b.longitude - a.longitude; 35 | if (Math.abs(lngDelta) > 180) 36 | { 37 | lngDelta -= Math.signum(lngDelta)+360; 38 | } 39 | double lng = lngDelta*fraction + a.longitude; 40 | return new LatLng(lat, lng); 41 | } 42 | } 43 | 44 | class Spherical implements LatLngInterpolator { 45 | 46 | @Override 47 | public LatLng interpolate(float fraction, LatLng from, LatLng to) { 48 | // wiki/ slerp 49 | 50 | double fromLat = toRadians(from.latitude); 51 | double fromLng = toRadians(from.longitude); 52 | double toLat = toRadians(to.latitude); 53 | double toLng = toRadians(to.longitude); 54 | double cosFromLat = cos(fromLat); 55 | double cosToLat = cos(toLat); 56 | 57 | //Computes spherical interpolation coefficients, 58 | double angle = computeAngleBetween(fromLat, fromLng, toLat, toLng); 59 | double sinAngle = sin(angle); 60 | if(sinAngle < 1E-6) 61 | return from; 62 | double a = sin((1 - fraction) * angle) / sinAngle; 63 | double b = sin(fraction * angle) / sinAngle; 64 | 65 | //Converts from polat to vector and interpolate 66 | double x = a*cosFromLat * cos(fromLng) + b*cosToLat*cos(toLng); 67 | double y = a*cosFromLat * sin(fromLng) + b*cosToLat*sin(toLng); 68 | double z = a*sin(fromLat) + b*sin(toLat); 69 | 70 | //Converts interpolated vector back to polar 71 | double lat = atan2(z, sqrt(x*x+y*y)); 72 | double lng = atan2 (y,x); 73 | 74 | 75 | return new LatLng(toDegrees(lat),toDegrees(lng)); 76 | 77 | } 78 | 79 | private double computeAngleBetween(double fromLat, double fromLng, double toLat, double toLng) { 80 | double dLat = fromLat = toLat; 81 | double dLng = fromLng = toLng; 82 | return 2*asin(sqrt(pow(sin(dLat/2),2) + cos(fromLat) * cos(toLat) 83 | *pow(sin(dLng/2),2))); 84 | 85 | } 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /androideatitv2shipper/Common/MarkerAnimation.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2shipper.Common; 2 | 3 | import android.animation.ObjectAnimator; 4 | import android.animation.TypeEvaluator; 5 | import android.animation.ValueAnimator; 6 | import android.annotation.TargetApi; 7 | import android.os.Build; 8 | import android.util.Property; 9 | import android.view.animation.Interpolator; 10 | import android.os.Handler; 11 | import android.os.SystemClock; 12 | import android.view.animation.AccelerateDecelerateInterpolator; 13 | 14 | import com.google.android.gms.maps.model.LatLng; 15 | import com.google.android.gms.maps.model.Marker; 16 | 17 | public class MarkerAnimation { 18 | public static void animateMarkerToGB(final Marker marker, 19 | LatLng finalPosition, 20 | LatLngInterpolator latLngInterpolator) 21 | { 22 | LatLng startPosition = marker.getPosition(); 23 | Handler handler = new Handler(); 24 | long start = SystemClock.uptimeMillis(); 25 | Interpolator interpolator = new AccelerateDecelerateInterpolator(); 26 | float durationInMs = 3000; // 3 sec 27 | 28 | handler.post(new Runnable() { 29 | long elapsed; 30 | float t,v; 31 | 32 | @Override 33 | public void run() { 34 | elapsed = SystemClock.uptimeMillis() - start; 35 | t=elapsed/durationInMs; 36 | v = interpolator.getInterpolation(t); 37 | 38 | marker.setPosition(latLngInterpolator.interpolate(v,startPosition,finalPosition)); 39 | 40 | //Repeat til progress is complete 41 | if (t<1) 42 | { 43 | //Post again 16ms later 44 | handler.postDelayed(this, 16); 45 | } 46 | } 47 | }); 48 | } 49 | 50 | @TargetApi(Build.VERSION_CODES.HONEYCOMB) 51 | public static void animateMarkerToHC(final Marker marker, 52 | LatLng finalPosition, 53 | LatLngInterpolator latLngInterpolator) 54 | { 55 | LatLng startLocation = marker.getPosition(); 56 | 57 | ValueAnimator valueAnimator = new ValueAnimator(); 58 | valueAnimator.addUpdateListener(animation -> { 59 | float v = animation.getAnimatedFraction(); 60 | LatLng newPostion = latLngInterpolator.interpolate(v, startLocation,finalPosition); 61 | marker.setPosition(newPostion); 62 | }); 63 | 64 | valueAnimator.setFloatValues(0,1); 65 | valueAnimator.setDuration(3000); 66 | valueAnimator.start(); 67 | } 68 | 69 | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) 70 | public static void animateMarkerToICS(final Marker marker, 71 | LatLng finalPosition, 72 | LatLngInterpolator latLngInterpolator) 73 | { 74 | TypeEvaluator TypeEvaluator = new TypeEvaluator() { 75 | @Override 76 | public LatLng evaluate(float fraction, LatLng startValue, LatLng endValue) { 77 | return latLngInterpolator.interpolate(fraction, startValue, endValue); 78 | } 79 | }; 80 | 81 | Property property = Property.of(Marker.class, LatLng.class, "position"); 82 | ObjectAnimator animator = ObjectAnimator.ofObject(marker, property, TypeEvaluator, finalPosition); 83 | animator.setDuration(30000); 84 | animator.start(); 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /androideatitv2shipper/Model/CartItem.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2shipper.Model; 2 | 3 | 4 | import androidx.annotation.NonNull; 5 | 6 | 7 | public class CartItem { 8 | 9 | public String foodId; 10 | 11 | private String foodName; 12 | 13 | 14 | private String foodImage; 15 | 16 | 17 | private Double foodPrice; 18 | 19 | 20 | private int foodQuantity; 21 | 22 | private String userPhone; 23 | 24 | private Double foodExtraPrice; 25 | 26 | private String foodAddon; 27 | 28 | private String foodSize; 29 | 30 | private String uid; 31 | 32 | 33 | @NonNull 34 | public String getFoodId() { 35 | return foodId; 36 | } 37 | 38 | public void setFoodId(@NonNull String foodId) { 39 | this.foodId = foodId; 40 | } 41 | 42 | public String getFoodName() { 43 | return foodName; 44 | } 45 | 46 | public void setFoodName(String foodName) { 47 | this.foodName = foodName; 48 | } 49 | 50 | public String getFoodImage() { 51 | return foodImage; 52 | } 53 | 54 | public void setFoodImage(String foodImage) { 55 | this.foodImage = foodImage; 56 | } 57 | 58 | public Double getFoodPrice() { 59 | return foodPrice; 60 | } 61 | 62 | public void setFoodPrice(Double foodPrice) { 63 | this.foodPrice = foodPrice; 64 | } 65 | 66 | public int getFoodQuantity() { 67 | return foodQuantity; 68 | } 69 | 70 | public void setFoodQuantity(int foodQuantity) { 71 | this.foodQuantity = foodQuantity; 72 | } 73 | 74 | public String getUserPhone() { 75 | return userPhone; 76 | } 77 | 78 | public void setUserPhone(String userPhone) { 79 | this.userPhone = userPhone; 80 | } 81 | 82 | public Double getFoodExtraPrice() { 83 | return foodExtraPrice; 84 | } 85 | 86 | public void setFoodExtraPrice(Double foodExtraPrice) { 87 | this.foodExtraPrice = foodExtraPrice; 88 | } 89 | 90 | public String getFoodAddon() { 91 | return foodAddon; 92 | } 93 | 94 | public void setFoodAddon(String foodAddon) { 95 | this.foodAddon = foodAddon; 96 | } 97 | 98 | public String getFoodSize() { 99 | return foodSize; 100 | } 101 | 102 | public void setFoodSize(String foodSize) { 103 | this.foodSize = foodSize; 104 | } 105 | 106 | public String getUid() { 107 | return uid; 108 | } 109 | 110 | public void setUid(String uid) { 111 | this.uid = uid; 112 | } 113 | } -------------------------------------------------------------------------------- /androideatitv2shipper/Model/EventBus/UpdateShippingOrderEvent.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2shipper.Model.EventBus; 2 | 3 | public class UpdateShippingOrderEvent { 4 | } 5 | -------------------------------------------------------------------------------- /androideatitv2shipper/Model/FCMResponse.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2shipper.Model; 2 | 3 | 4 | import java.util.List; 5 | 6 | public class FCMResponse { 7 | private long multicast_id; 8 | private int success, failure, canonical_ids; 9 | private List results; 10 | private long message_id; 11 | 12 | public FCMResponse() { 13 | } 14 | 15 | public long getMulticast_id() { 16 | return multicast_id; 17 | } 18 | 19 | public void setMulticast_id(long multicast_id) { 20 | this.multicast_id = multicast_id; 21 | } 22 | 23 | public int getSuccess() { 24 | return success; 25 | } 26 | 27 | public void setSuccess(int success) { 28 | this.success = success; 29 | } 30 | 31 | public int getFailure() { 32 | return failure; 33 | } 34 | 35 | public void setFailure(int failure) { 36 | this.failure = failure; 37 | } 38 | 39 | public int getCanonical_ids() { 40 | return canonical_ids; 41 | } 42 | 43 | public void setCanonical_ids(int canonical_ids) { 44 | this.canonical_ids = canonical_ids; 45 | } 46 | 47 | public List getResults() { 48 | return results; 49 | } 50 | 51 | public void setResults(List results) { 52 | this.results = results; 53 | } 54 | 55 | public long getMessage_id() { 56 | return message_id; 57 | } 58 | 59 | public void setMessage_id(long message_id) { 60 | this.message_id = message_id; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /androideatitv2shipper/Model/FCMResult.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2shipper.Model; 2 | 3 | public class FCMResult { 4 | private String message_id; 5 | 6 | public FCMResult() { 7 | } 8 | 9 | public String getMessage_id() { 10 | return message_id; 11 | } 12 | 13 | public void setMessage_id(String message_id) { 14 | this.message_id = message_id; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /androideatitv2shipper/Model/FCMSendData.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2shipper.Model; 2 | 3 | import java.util.Map; 4 | 5 | public class FCMSendData { 6 | 7 | private String to; 8 | private Map data; 9 | 10 | public FCMSendData(String to, Map data) { 11 | this.to = to; 12 | this.data = data; 13 | } 14 | 15 | public String getTo() { 16 | return to; 17 | } 18 | 19 | public void setTo(String to) { 20 | this.to = to; 21 | } 22 | 23 | public Map getData() { 24 | return data; 25 | } 26 | 27 | public void setData(Map data) { 28 | this.data = data; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /androideatitv2shipper/Model/OrderModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2shipper.Model; 2 | 3 | 4 | import java.util.List; 5 | 6 | public class OrderModel { 7 | private String key; 8 | private String userId, userName, userPhone,shippingAddress,comment, transactionId; 9 | private double lat,lng,totalPayment,finalPayment; 10 | private boolean cod; 11 | private int discount; 12 | private List cartItemList; 13 | private long createDate; 14 | private String orderNumber; 15 | private int orderStatus; 16 | 17 | public OrderModel() { 18 | } 19 | 20 | public String getKey() { 21 | return key; 22 | } 23 | 24 | public void setKey(String key) { 25 | this.key = key; 26 | } 27 | 28 | public String getUserId() { 29 | return userId; 30 | } 31 | 32 | public void setUserId(String userId) { 33 | this.userId = userId; 34 | } 35 | 36 | public String getUserName() { 37 | return userName; 38 | } 39 | 40 | public void setUserName(String userName) { 41 | this.userName = userName; 42 | } 43 | 44 | public String getUserPhone() { 45 | return userPhone; 46 | } 47 | 48 | public void setUserPhone(String userPhone) { 49 | this.userPhone = userPhone; 50 | } 51 | 52 | public String getShippingAddress() { 53 | return shippingAddress; 54 | } 55 | 56 | public void setShippingAddress(String shippingAddress) { 57 | this.shippingAddress = shippingAddress; 58 | } 59 | 60 | public String getComment() { 61 | return comment; 62 | } 63 | 64 | public void setComment(String comment) { 65 | this.comment = comment; 66 | } 67 | 68 | public String getTransactionId() { 69 | return transactionId; 70 | } 71 | 72 | public void setTransactionId(String transactionId) { 73 | this.transactionId = transactionId; 74 | } 75 | 76 | public double getLat() { 77 | return lat; 78 | } 79 | 80 | public void setLat(double lat) { 81 | this.lat = lat; 82 | } 83 | 84 | public double getLng() { 85 | return lng; 86 | } 87 | 88 | public void setLng(double lng) { 89 | this.lng = lng; 90 | } 91 | 92 | public double getTotalPayment() { 93 | return totalPayment; 94 | } 95 | 96 | public void setTotalPayment(double totalPayment) { 97 | this.totalPayment = totalPayment; 98 | } 99 | 100 | public double getFinalPayment() { 101 | return finalPayment; 102 | } 103 | 104 | public void setFinalPayment(double finalPayment) { 105 | this.finalPayment = finalPayment; 106 | } 107 | 108 | public boolean isCod() { 109 | return cod; 110 | } 111 | 112 | public void setCod(boolean cod) { 113 | this.cod = cod; 114 | } 115 | 116 | public int getDiscount() { 117 | return discount; 118 | } 119 | 120 | public void setDiscount(int discount) { 121 | this.discount = discount; 122 | } 123 | 124 | public List getCartItemList() { 125 | return cartItemList; 126 | } 127 | 128 | public void setCartItemList(List cartItemList) { 129 | this.cartItemList = cartItemList; 130 | } 131 | 132 | public long getCreateDate() { 133 | return createDate; 134 | } 135 | 136 | public void setCreateDate(long createDate) { 137 | this.createDate = createDate; 138 | } 139 | 140 | public String getOrderNumber() { 141 | return orderNumber; 142 | } 143 | 144 | public void setOrderNumber(String orderNumber) { 145 | this.orderNumber = orderNumber; 146 | } 147 | 148 | public int getOrderStatus() { 149 | return orderStatus; 150 | } 151 | 152 | public void setOrderStatus(int orderStatus) { 153 | this.orderStatus = orderStatus; 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /androideatitv2shipper/Model/ShipperUserModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2shipper.Model; 2 | 3 | public class ShipperUserModel { 4 | private String uid, name, phone; 5 | private boolean active; 6 | 7 | public ShipperUserModel() { 8 | } 9 | 10 | public ShipperUserModel(String uid, String name, String phone, boolean active) { 11 | this.uid = uid; 12 | this.name = name; 13 | this.phone = phone; 14 | this.active = active; 15 | } 16 | 17 | public String getUid() { 18 | return uid; 19 | } 20 | 21 | public void setUid(String uid) { 22 | this.uid = uid; 23 | } 24 | 25 | public String getName() { 26 | return name; 27 | } 28 | 29 | public void setName(String name) { 30 | this.name = name; 31 | } 32 | 33 | public String getPhone() { 34 | return phone; 35 | } 36 | 37 | public void setPhone(String phone) { 38 | this.phone = phone; 39 | } 40 | 41 | public boolean isActive() { 42 | return active; 43 | } 44 | 45 | public void setActive(boolean active) { 46 | this.active = active; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /androideatitv2shipper/Model/ShippingOrderModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2shipper.Model; 2 | 3 | 4 | public class ShippingOrderModel { 5 | private String key, shipperPhone, shipperName; 6 | private double currentLat, currentLng; 7 | private OrderModel orderModel; 8 | private boolean isStartTrip; 9 | 10 | public ShippingOrderModel() { 11 | } 12 | 13 | public String getKey() { 14 | return key; 15 | } 16 | 17 | public void setKey(String key) { 18 | this.key = key; 19 | } 20 | 21 | public String getShipperPhone() { 22 | return shipperPhone; 23 | } 24 | 25 | 26 | 27 | public void setShipperPhone(String shipperPhone) { 28 | this.shipperPhone = shipperPhone; 29 | } 30 | 31 | public String getShipperName() { 32 | return shipperName; 33 | } 34 | 35 | public void setShipperName(String shipperName) { 36 | this.shipperName = shipperName; 37 | } 38 | 39 | public double getCurrentLat() { 40 | return currentLat; 41 | } 42 | 43 | public void setCurrentLat(double currentLat) { 44 | this.currentLat = currentLat; 45 | } 46 | 47 | public double getCurrentLng() { 48 | return currentLng; 49 | } 50 | 51 | public void setCurrentLng(double currentLng) { 52 | this.currentLng = currentLng; 53 | } 54 | 55 | public OrderModel getOrderModel() { 56 | return orderModel; 57 | } 58 | 59 | public void setOrderModel(OrderModel orderModel) { 60 | this.orderModel = orderModel; 61 | } 62 | 63 | public boolean isStartTrip() { 64 | return isStartTrip; 65 | } 66 | 67 | public void setStartTrip(boolean startTrip) { 68 | isStartTrip = startTrip; 69 | } 70 | } 71 | 72 | -------------------------------------------------------------------------------- /androideatitv2shipper/Model/TokenModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2shipper.Model; 2 | 3 | public class TokenModel { 4 | private String phone, token; 5 | private boolean serverToken, shipperToken; 6 | 7 | public TokenModel() { 8 | } 9 | 10 | public TokenModel(String phone, String token, boolean serverToken, boolean shipperToken) { 11 | this.phone = phone; 12 | this.token = token; 13 | this.serverToken = serverToken; 14 | this.shipperToken = shipperToken; 15 | } 16 | 17 | public String getPhone() { 18 | return phone; 19 | } 20 | 21 | public void setPhone(String phone) { 22 | this.phone = phone; 23 | } 24 | 25 | public String getToken() { 26 | return token; 27 | } 28 | 29 | public void setToken(String token) { 30 | this.token = token; 31 | } 32 | 33 | public boolean isServerToken() { 34 | return serverToken; 35 | } 36 | 37 | public void setServerToken(boolean serverToken) { 38 | this.serverToken = serverToken; 39 | } 40 | 41 | public boolean isShipperToken() { 42 | return shipperToken; 43 | } 44 | 45 | public void setShipperToken(boolean shipperToken) { 46 | this.shipperToken = shipperToken; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /androideatitv2shipper/Remote/IFCMService.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2shipper.Remote; 2 | 3 | 4 | 5 | import com.ds.androideatitv2shipper.Model.FCMResponse; 6 | import com.ds.androideatitv2shipper.Model.FCMSendData; 7 | 8 | import io.reactivex.Observable; 9 | import retrofit2.http.Body; 10 | import retrofit2.http.Headers; 11 | import retrofit2.http.POST; 12 | 13 | public interface IFCMService { 14 | @Headers({ 15 | "Content-Type:application/json", 16 | "Authorization:key=AAAAKK2HWaQ:APA91bGDvCgZvaQFUB1kg17PWD5WCl7qlzBx2rh9-y8EylcI7IOE44qfIScmrZxZosLi1a_DzmXal0uXmsQexLyiBwLtHOG5ffvhIyJg1110uZsT-gdSrzO3PF71IEUNi7Ark6OY4a8I" 17 | }) 18 | @POST("fcm/send") 19 | Observable sendNotification(@Body FCMSendData body); 20 | } 21 | 22 | -------------------------------------------------------------------------------- /androideatitv2shipper/Remote/IGoogleAPI.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2shipper.Remote; 2 | 3 | import io.reactivex.Observable; 4 | 5 | import retrofit2.http.GET; 6 | import retrofit2.http.Query; 7 | 8 | public interface IGoogleAPI { 9 | @GET("maps/api/directions/json") 10 | Observable getDirections ( 11 | @Query("mode") String mode, 12 | @Query("transit_routing_preference") String transit_routing, 13 | @Query("origin") String from, 14 | @Query("destination") String to, 15 | @Query("key") String key); 16 | } 17 | 18 | -------------------------------------------------------------------------------- /androideatitv2shipper/Remote/RetrofitFCMClient.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2shipper.Remote; 2 | 3 | import retrofit2.Retrofit; 4 | import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; 5 | import retrofit2.converter.gson.GsonConverterFactory; 6 | 7 | public class RetrofitFCMClient { 8 | private static Retrofit instance; 9 | public static Retrofit getInstance(){ 10 | 11 | 12 | 13 | if(instance == null) 14 | instance = new Retrofit.Builder() 15 | .baseUrl("https://fcm.googleapis.com/") 16 | .addConverterFactory(GsonConverterFactory.create()) 17 | .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) 18 | .build(); 19 | return instance; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /androideatitv2shipper/Remote/RetrofitGoogleAPIClient.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2shipper.Remote; 2 | 3 | 4 | import retrofit2.Retrofit; 5 | import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; 6 | import retrofit2.converter.gson.GsonConverterFactory; 7 | import retrofit2.converter.scalars.ScalarsConverterFactory; 8 | 9 | public class RetrofitGoogleAPIClient { 10 | private static Retrofit instance; 11 | 12 | public static Retrofit getInstance(){ 13 | return instance == null ? new Retrofit.Builder() 14 | .baseUrl("https://maps.googleapis.com/") 15 | .addConverterFactory(ScalarsConverterFactory.create()) 16 | .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) 17 | .build() : instance; 18 | 19 | } 20 | } -------------------------------------------------------------------------------- /androideatitv2shipper/Services/MyFCMServices.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2shipper.Services; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | 6 | import com.ds.androideatitv2shipper.Common.Common; 7 | import com.ds.androideatitv2shipper.Model.EventBus.UpdateShippingOrderEvent; 8 | import com.google.firebase.messaging.FirebaseMessagingService; 9 | import com.google.firebase.messaging.RemoteMessage; 10 | 11 | import org.greenrobot.eventbus.EventBus; 12 | 13 | import java.util.Map; 14 | import java.util.Random; 15 | 16 | public class MyFCMServices extends FirebaseMessagingService { 17 | 18 | @Override 19 | public void onMessageReceived(@NonNull RemoteMessage remoteMessage) { 20 | Map dataRecv = remoteMessage.getData(); 21 | if (dataRecv != null) 22 | { 23 | Common.showNotification(this, new Random().nextInt(), 24 | dataRecv.get(Common.NOTI_TITLE), 25 | dataRecv.get(Common.NOTI_CONTENT), 26 | null); 27 | EventBus.getDefault().postSticky(new UpdateShippingOrderEvent()); // Update order list when have new order needs ship 28 | } 29 | } 30 | 31 | @Override 32 | public void onNewToken(@NonNull String s) { 33 | super.onNewToken(s); 34 | Common.updateToken(this,s, false, true); // We are in Shipper App 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /androideatitv2shipper/ui/gallery/GalleryFragment.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2shipper.ui.gallery; 2 | 3 | import android.os.Bundle; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.TextView; 8 | 9 | import androidx.annotation.NonNull; 10 | import androidx.annotation.Nullable; 11 | import androidx.fragment.app.Fragment; 12 | import androidx.lifecycle.Observer; 13 | import androidx.lifecycle.ViewModelProviders; 14 | 15 | import com.ds.androideatitv2shipper.R; 16 | 17 | public class GalleryFragment extends Fragment { 18 | 19 | private GalleryViewModel galleryViewModel; 20 | 21 | public View onCreateView(@NonNull LayoutInflater inflater, 22 | ViewGroup container, Bundle savedInstanceState) { 23 | galleryViewModel = 24 | ViewModelProviders.of(this).get(GalleryViewModel.class); 25 | View root = inflater.inflate(R.layout.fragment_gallery, container, false); 26 | final TextView textView = root.findViewById(R.id.text_gallery); 27 | galleryViewModel.getText().observe(getViewLifecycleOwner(), new Observer() { 28 | @Override 29 | public void onChanged(@Nullable String s) { 30 | textView.setText(s); 31 | } 32 | }); 33 | return root; 34 | } 35 | } -------------------------------------------------------------------------------- /androideatitv2shipper/ui/gallery/GalleryViewModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2shipper.ui.gallery; 2 | 3 | import androidx.lifecycle.LiveData; 4 | import androidx.lifecycle.MutableLiveData; 5 | import androidx.lifecycle.ViewModel; 6 | 7 | public class GalleryViewModel extends ViewModel { 8 | 9 | private MutableLiveData mText; 10 | 11 | public GalleryViewModel() { 12 | mText = new MutableLiveData<>(); 13 | mText.setValue("This is gallery fragment"); 14 | } 15 | 16 | public LiveData getText() { 17 | return mText; 18 | } 19 | } -------------------------------------------------------------------------------- /androideatitv2shipper/ui/shipOrders/OrdersToShipFragment.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2shipper.ui.shipOrders; 2 | 3 | import android.os.Bundle; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.view.animation.AnimationUtils; 8 | import android.view.animation.LayoutAnimationController; 9 | import android.widget.Toast; 10 | 11 | import androidx.annotation.NonNull; 12 | import androidx.fragment.app.Fragment; 13 | import androidx.lifecycle.ViewModelProviders; 14 | import androidx.recyclerview.widget.DividerItemDecoration; 15 | import androidx.recyclerview.widget.LinearLayoutManager; 16 | import androidx.recyclerview.widget.RecyclerView; 17 | 18 | import com.ds.androideatitv2shipper.Adapters.MyShippingOrderAdapter; 19 | import com.ds.androideatitv2shipper.Common.Common; 20 | import com.ds.androideatitv2shipper.Model.EventBus.UpdateShippingOrderEvent; 21 | import com.ds.androideatitv2shipper.R; 22 | 23 | import org.greenrobot.eventbus.EventBus; 24 | import org.greenrobot.eventbus.Subscribe; 25 | import org.greenrobot.eventbus.ThreadMode; 26 | 27 | import butterknife.BindView; 28 | import butterknife.ButterKnife; 29 | import butterknife.Unbinder; 30 | import io.reactivex.disposables.CompositeDisposable; 31 | 32 | public class OrdersToShipFragment extends Fragment { 33 | 34 | @BindView(R.id.recycler_order) 35 | RecyclerView recycler_order; 36 | 37 | 38 | private CompositeDisposable compositeDisposable = new CompositeDisposable(); 39 | 40 | Unbinder unbinder; 41 | LayoutAnimationController layoutAnimationController; 42 | MyShippingOrderAdapter adapter; 43 | 44 | private OrdersToShipViewModel ordersToShipViewModel; 45 | 46 | public View onCreateView(@NonNull LayoutInflater inflater, 47 | ViewGroup container, Bundle savedInstanceState) { 48 | ordersToShipViewModel = 49 | ViewModelProviders.of(this).get(OrdersToShipViewModel.class); 50 | View root = inflater.inflate(R.layout.fragment_home_orders_needs_shipping_list, container, false); 51 | initViews(root); 52 | ordersToShipViewModel.getMessageError().observe(this, s -> { 53 | Toast.makeText(getContext(), s, Toast.LENGTH_SHORT).show(); 54 | }); 55 | ordersToShipViewModel.getShippingOrderMutableData(Common.currentShipperUser.getPhone()).observe(this, shippingOrderModels -> { 56 | adapter = new MyShippingOrderAdapter(getContext(),shippingOrderModels); 57 | recycler_order.setAdapter(adapter); 58 | recycler_order.setLayoutAnimation(layoutAnimationController); 59 | }); 60 | return root; 61 | } 62 | 63 | private void initViews(View root) { 64 | unbinder = ButterKnife.bind(this,root); 65 | setHasOptionsMenu(false); 66 | 67 | recycler_order.setHasFixedSize(true); 68 | LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); 69 | recycler_order.setLayoutManager(layoutManager); 70 | recycler_order.addItemDecoration(new DividerItemDecoration(getContext(), layoutManager.getOrientation())); 71 | 72 | layoutAnimationController = AnimationUtils.loadLayoutAnimation(getContext(), R.anim.layout_slide_from_left); 73 | } 74 | 75 | @Override 76 | public void onStart() { 77 | super.onStart(); 78 | EventBus.getDefault().register(this); 79 | } 80 | 81 | @Override 82 | public void onStop() { 83 | super.onStop(); 84 | if (EventBus.getDefault().hasSubscriberForEvent(UpdateShippingOrderEvent.class)) 85 | EventBus.getDefault().removeStickyEvent(UpdateShippingOrderEvent.class); 86 | EventBus.getDefault().unregister(this); 87 | } 88 | 89 | @Subscribe(sticky = true, threadMode = ThreadMode.MAIN) 90 | public void onUpdateShippingOrder(UpdateShippingOrderEvent event) 91 | { 92 | ordersToShipViewModel.getShippingOrderMutableData(Common.currentShipperUser.getPhone()); //Update data 93 | } 94 | 95 | } -------------------------------------------------------------------------------- /androideatitv2shipper/ui/shipOrders/OrdersToShipViewModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2shipper.ui.shipOrders; 2 | 3 | import androidx.annotation.NonNull; 4 | import androidx.lifecycle.MutableLiveData; 5 | import androidx.lifecycle.ViewModel; 6 | 7 | import com.ds.androideatitv2shipper.Callbacks.IShippingOrderCallbackListener; 8 | import com.ds.androideatitv2shipper.Common.Common; 9 | import com.ds.androideatitv2shipper.Model.ShippingOrderModel; 10 | import com.google.firebase.database.DataSnapshot; 11 | import com.google.firebase.database.DatabaseError; 12 | import com.google.firebase.database.FirebaseDatabase; 13 | import com.google.firebase.database.Query; 14 | import com.google.firebase.database.ValueEventListener; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | public class OrdersToShipViewModel extends ViewModel implements IShippingOrderCallbackListener { 20 | 21 | private MutableLiveData> shippingOrderMutableData; 22 | private MutableLiveData messageError; 23 | 24 | private IShippingOrderCallbackListener listener; 25 | 26 | public OrdersToShipViewModel() { 27 | shippingOrderMutableData = new MutableLiveData<>(); 28 | messageError = new MutableLiveData<>(); 29 | listener = this; 30 | } 31 | 32 | public MutableLiveData getMessageError() { 33 | return messageError; 34 | } 35 | 36 | public MutableLiveData> getShippingOrderMutableData(String shippingPhone) { 37 | loadOrderByShipper(shippingPhone); 38 | return shippingOrderMutableData; 39 | } 40 | 41 | private void loadOrderByShipper(String shippingPhone) { 42 | List tempList = new ArrayList<>(); 43 | Query orderRef = FirebaseDatabase.getInstance().getReference(Common.SHIPPING_ORDER_REF) 44 | .orderByChild("shipperPhone") 45 | .equalTo(Common.currentShipperUser.getPhone()); 46 | orderRef.addListenerForSingleValueEvent(new ValueEventListener() { 47 | @Override 48 | public void onDataChange(@NonNull DataSnapshot dataSnapshot) { 49 | for (DataSnapshot orderSnapshot:dataSnapshot.getChildren()) 50 | { 51 | ShippingOrderModel shippingOrderModel = orderSnapshot.getValue(ShippingOrderModel.class); 52 | shippingOrderModel.setKey(orderSnapshot.getKey()); 53 | tempList.add(shippingOrderModel); 54 | } 55 | listener.onShippingOrderLoadSuccess(tempList); 56 | } 57 | 58 | @Override 59 | public void onCancelled(@NonNull DatabaseError error) { 60 | listener.onShippingOrderLoadFailed(error.getMessage()); 61 | } 62 | }); 63 | } 64 | 65 | @Override 66 | public void onShippingOrderLoadSuccess(List shippingOrderModelList) { 67 | shippingOrderMutableData.setValue(shippingOrderModelList); 68 | } 69 | 70 | @Override 71 | public void onShippingOrderLoadFailed(String message) { 72 | messageError.setValue(message); 73 | } 74 | } -------------------------------------------------------------------------------- /androideatitv2shipper/ui/slideshow/SlideshowFragment.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2shipper.ui.slideshow; 2 | 3 | import android.os.Bundle; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.TextView; 8 | 9 | import androidx.annotation.NonNull; 10 | import androidx.annotation.Nullable; 11 | import androidx.fragment.app.Fragment; 12 | import androidx.lifecycle.Observer; 13 | import androidx.lifecycle.ViewModelProviders; 14 | 15 | import com.ds.androideatitv2shipper.R; 16 | 17 | public class SlideshowFragment extends Fragment { 18 | 19 | private SlideshowViewModel slideshowViewModel; 20 | 21 | public View onCreateView(@NonNull LayoutInflater inflater, 22 | ViewGroup container, Bundle savedInstanceState) { 23 | slideshowViewModel = 24 | ViewModelProviders.of(this).get(SlideshowViewModel.class); 25 | View root = inflater.inflate(R.layout.fragment_slideshow, container, false); 26 | final TextView textView = root.findViewById(R.id.text_slideshow); 27 | slideshowViewModel.getText().observe(getViewLifecycleOwner(), new Observer() { 28 | @Override 29 | public void onChanged(@Nullable String s) { 30 | textView.setText(s); 31 | } 32 | }); 33 | return root; 34 | } 35 | } -------------------------------------------------------------------------------- /androideatitv2shipper/ui/slideshow/SlideshowViewModel.java: -------------------------------------------------------------------------------- 1 | package com.ds.androideatitv2shipper.ui.slideshow; 2 | 3 | import androidx.lifecycle.LiveData; 4 | import androidx.lifecycle.MutableLiveData; 5 | import androidx.lifecycle.ViewModel; 6 | 7 | public class SlideshowViewModel extends ViewModel { 8 | 9 | private MutableLiveData mText; 10 | 11 | public SlideshowViewModel() { 12 | mText = new MutableLiveData<>(); 13 | mText.setValue("This is slideshow fragment"); 14 | } 15 | 16 | public LiveData getText() { 17 | return mText; 18 | } 19 | } --------------------------------------------------------------------------------