fork(1) download
  1. package com.example.foodpaal;
  2.  
  3. import android.content.Context;
  4. import android.content.Intent;
  5. import android.os.Bundle;
  6. import android.support.design.widget.NavigationView;
  7. import android.support.v4.view.GravityCompat;
  8. import android.support.v4.widget.DrawerLayout;
  9. import android.support.v7.app.ActionBarDrawerToggle;
  10. import android.support.v7.app.AppCompatActivity;
  11. import android.support.v7.widget.LinearLayoutManager;
  12. import android.support.v7.widget.RecyclerView;
  13. import android.support.v7.widget.Toolbar;
  14. import android.view.Menu;
  15. import android.view.MenuItem;
  16. import android.view.View;
  17. import android.widget.ImageView;
  18. import android.widget.TextView;
  19. import com.firebase.ui.database.FirebaseRecyclerAdapter;
  20. import com.google.firebase.database.DatabaseReference;
  21. import com.google.firebase.database.FirebaseDatabase;
  22. import com.squareup.picasso.Picasso;
  23. import android.content.res.Configuration;
  24.  
  25. public class FoodMenuActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
  26.  
  27. private RecyclerView mFoodList;
  28. private DatabaseReference mDatabase;
  29.  
  30.  
  31. @Override
  32. protected void onCreate(Bundle savedInstanceState) {
  33. super.onCreate(savedInstanceState);
  34. setContentView(R.layout.activity_foodmenu);
  35. Toolbar toolbar = findViewById(R.id.toolbar);
  36. setSupportActionBar(toolbar);
  37.  
  38. mFoodList = findViewById(R.id.foodList);
  39. mFoodList.setHasFixedSize(true);
  40. mFoodList.setLayoutManager(new LinearLayoutManager(this));
  41. mDatabase = FirebaseDatabase.getInstance().getReference().child("Item");
  42.  
  43.  
  44.  
  45. DrawerLayout drawer = findViewById(R.id.drawer_layout);
  46. ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
  47. this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
  48. drawer.addDrawerListener(toggle);
  49. toggle.syncState();
  50.  
  51. NavigationView navigationView = findViewById(R.id.nav_view);
  52. navigationView.setNavigationItemSelectedListener(this);
  53. }
  54.  
  55.  
  56. @Override
  57. protected void onStart() {
  58. super.onStart();
  59. FirebaseRecyclerAdapter<Food, FoodMenuActivity.FoodViewHolder> FBRA = new FirebaseRecyclerAdapter<Food, FoodMenuActivity.FoodViewHolder>( Food.class,
  60. R.layout.single_itemmenu,
  61. FoodMenuActivity.FoodViewHolder.class,
  62. mDatabase) {
  63. @Override
  64. protected void populateViewHolder(FoodMenuActivity.FoodViewHolder viewHolder, Food model, int position) {
  65. viewHolder.setName(model.getName());
  66. viewHolder.setPrice(model.getPrice());
  67. viewHolder.setDec(model.getDesc());
  68. viewHolder.setImage(getApplicationContext(), model.getImage());
  69.  
  70. final String food_key = getRef(position).getKey();
  71. viewHolder.mView.setOnClickListener(new View.OnClickListener() {
  72. @Override
  73. public void onClick(View v) {
  74. Intent singleFoodActivity = new Intent(FoodMenuActivity.this,SingleFoodActivity.class);
  75. singleFoodActivity.putExtra("FoodId",food_key);
  76. startActivity(singleFoodActivity);
  77. }
  78. });
  79. }
  80. };
  81. mFoodList.setAdapter(FBRA);
  82. }
  83.  
  84.  
  85. public static class FoodViewHolder extends RecyclerView.ViewHolder {
  86. View mView;
  87.  
  88. public FoodViewHolder(View itemView) {
  89. super(itemView);
  90. mView = itemView;
  91. }
  92.  
  93. public void setName(String name) {
  94. TextView food_name = (TextView) mView.findViewById(R.id.foodName);
  95. food_name.setText(name);
  96. }
  97.  
  98. public void setDec(String desc) {
  99. TextView food_desc = (TextView) mView.findViewById(R.id.foodDesc);
  100. food_desc.setText(desc);
  101. }
  102.  
  103. public void setPrice(String price) {
  104. TextView food_price = (TextView) mView.findViewById(R.id.foodPrice);
  105. food_price.setText(price);
  106. }
  107.  
  108. public void setImage(Context ctx, String image) {
  109. ImageView food_image = (ImageView) mView.findViewById(R.id.foodImage);
  110. Picasso.with(ctx).load(image).into(food_image);
  111. }
  112. }
  113.  
  114.  
  115. @Override
  116. public void onBackPressed() {
  117. DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
  118. if (drawer.isDrawerOpen(GravityCompat.START)) {
  119. drawer.closeDrawer(GravityCompat.START);
  120. } else {
  121. super.onBackPressed();
  122. }
  123. }
  124.  
  125. @Override
  126. public boolean onCreateOptionsMenu(Menu menu) {
  127. // Inflate the menu; this adds items to the action bar if it is present.
  128. getMenuInflater().inflate(R.menu.food_menu, menu);
  129. return true;
  130. }
  131.  
  132. @Override
  133. public boolean onOptionsItemSelected(MenuItem item) {
  134. // Handle action bar item clicks here. The action bar will
  135. // automatically handle clicks on the Home/Up button, so long
  136. // as you specify a parent activity in AndroidManifest.xml.
  137. int id = item.getItemId();
  138.  
  139. //noinspection SimplifiableIfStatement
  140. if (id == R.id.action_settings) {
  141. return true;
  142. }
  143.  
  144. return super.onOptionsItemSelected(item);
  145. }
  146.  
  147. @SuppressWarnings("StatementWithEmptyBody")
  148. @Override
  149. public boolean onNavigationItemSelected(MenuItem item) {
  150. // Handle navigation view item clicks here.
  151. int id = item.getItemId();
  152.  
  153. if (id == R.id.nav_menu_category) {
  154.  
  155.  
  156. } else if (id == R.id.nav_orders) {
  157. Intent menuIntent = new Intent(FoodMenuActivity.this, MyOrders.class);
  158. startActivity(menuIntent);
  159.  
  160.  
  161. } else if (id == R.id.logout) {
  162.  
  163. Intent menuIntent = new Intent(FoodMenuActivity.this, signup_form.class);
  164. startActivity(menuIntent);
  165. }
  166.  
  167.  
  168. DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
  169. drawer.closeDrawer(GravityCompat.START);
  170. return true;
  171. }
  172. }
  173.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:25: error: class FoodMenuActivity is public, should be declared in a file named FoodMenuActivity.java
public class FoodMenuActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
       ^
Main.java:3: error: package android.content does not exist
import android.content.Context;
                      ^
Main.java:4: error: package android.content does not exist
import android.content.Intent;
                      ^
Main.java:5: error: package android.os does not exist
import android.os.Bundle;
                 ^
Main.java:6: error: package android.support.design.widget does not exist
import android.support.design.widget.NavigationView;
                                    ^
Main.java:7: error: package android.support.v4.view does not exist
import android.support.v4.view.GravityCompat;
                              ^
Main.java:8: error: package android.support.v4.widget does not exist
import android.support.v4.widget.DrawerLayout;
                                ^
Main.java:9: error: package android.support.v7.app does not exist
import android.support.v7.app.ActionBarDrawerToggle;
                             ^
Main.java:10: error: package android.support.v7.app does not exist
import android.support.v7.app.AppCompatActivity;
                             ^
Main.java:11: error: package android.support.v7.widget does not exist
import android.support.v7.widget.LinearLayoutManager;
                                ^
Main.java:12: error: package android.support.v7.widget does not exist
import android.support.v7.widget.RecyclerView;
                                ^
Main.java:13: error: package android.support.v7.widget does not exist
import android.support.v7.widget.Toolbar;
                                ^
Main.java:14: error: package android.view does not exist
import android.view.Menu;
                   ^
Main.java:15: error: package android.view does not exist
import android.view.MenuItem;
                   ^
Main.java:16: error: package android.view does not exist
import android.view.View;
                   ^
Main.java:17: error: package android.widget does not exist
import android.widget.ImageView;
                     ^
Main.java:18: error: package android.widget does not exist
import android.widget.TextView;
                     ^
Main.java:19: error: package com.firebase.ui.database does not exist
import com.firebase.ui.database.FirebaseRecyclerAdapter;
                               ^
Main.java:20: error: package com.google.firebase.database does not exist
import com.google.firebase.database.DatabaseReference;
                                   ^
Main.java:21: error: package com.google.firebase.database does not exist
import com.google.firebase.database.FirebaseDatabase;
                                   ^
Main.java:22: error: package com.squareup.picasso does not exist
import com.squareup.picasso.Picasso;
                           ^
Main.java:23: error: package android.content.res does not exist
import android.content.res.Configuration;
                          ^
Main.java:25: error: cannot find symbol
public class FoodMenuActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
                                      ^
  symbol: class AppCompatActivity
Main.java:25: error: package NavigationView does not exist
public class FoodMenuActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
                                                                                 ^
Main.java:27: error: cannot find symbol
    private RecyclerView mFoodList;
            ^
  symbol:   class RecyclerView
  location: class FoodMenuActivity
Main.java:28: error: cannot find symbol
    private DatabaseReference mDatabase;
            ^
  symbol:   class DatabaseReference
  location: class FoodMenuActivity
Main.java:32: error: cannot find symbol
    protected void onCreate(Bundle savedInstanceState) {
                            ^
  symbol:   class Bundle
  location: class FoodMenuActivity
Main.java:126: error: cannot find symbol
    public boolean onCreateOptionsMenu(Menu menu) {
                                       ^
  symbol:   class Menu
  location: class FoodMenuActivity
Main.java:133: error: cannot find symbol
    public boolean onOptionsItemSelected(MenuItem item) {
                                         ^
  symbol:   class MenuItem
  location: class FoodMenuActivity
Main.java:149: error: cannot find symbol
    public boolean onNavigationItemSelected(MenuItem item) {
                                            ^
  symbol:   class MenuItem
  location: class FoodMenuActivity
Main.java:85: error: package RecyclerView does not exist
    public static class FoodViewHolder extends RecyclerView.ViewHolder {
                                                           ^
Main.java:86: error: cannot find symbol
        View mView;
        ^
  symbol:   class View
  location: class FoodViewHolder
Main.java:88: error: cannot find symbol
        public FoodViewHolder(View itemView) {
                              ^
  symbol:   class View
  location: class FoodViewHolder
Main.java:108: error: cannot find symbol
        public void setImage(Context ctx, String image) {
                             ^
  symbol:   class Context
  location: class FoodViewHolder
Main.java:31: error: method does not override or implement a method from a supertype
    @Override
    ^
Main.java:33: error: cannot find symbol
        super.onCreate(savedInstanceState);
        ^
  symbol:   variable super
  location: class FoodMenuActivity
Main.java:34: error: package R does not exist
        setContentView(R.layout.activity_foodmenu);
                        ^
Main.java:35: error: cannot find symbol
        Toolbar toolbar =  findViewById(R.id.toolbar);
        ^
  symbol:   class Toolbar
  location: class FoodMenuActivity
Main.java:35: error: package R does not exist
        Toolbar toolbar =  findViewById(R.id.toolbar);
                                         ^
Main.java:38: error: package R does not exist
        mFoodList =  findViewById(R.id.foodList);
                                   ^
Main.java:40: error: cannot find symbol
        mFoodList.setLayoutManager(new LinearLayoutManager(this));
                                       ^
  symbol:   class LinearLayoutManager
  location: class FoodMenuActivity
Main.java:41: error: cannot find symbol
        mDatabase = FirebaseDatabase.getInstance().getReference().child("Item");
                    ^
  symbol:   variable FirebaseDatabase
  location: class FoodMenuActivity
Main.java:45: error: cannot find symbol
        DrawerLayout drawer =  findViewById(R.id.drawer_layout);
        ^
  symbol:   class DrawerLayout
  location: class FoodMenuActivity
Main.java:45: error: package R does not exist
        DrawerLayout drawer =  findViewById(R.id.drawer_layout);
                                             ^
Main.java:46: error: cannot find symbol
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
        ^
  symbol:   class ActionBarDrawerToggle
  location: class FoodMenuActivity
Main.java:46: error: cannot find symbol
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                                           ^
  symbol:   class ActionBarDrawerToggle
  location: class FoodMenuActivity
Main.java:47: error: package R does not exist
                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
                                        ^
Main.java:47: error: package R does not exist
                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
                                                                         ^
Main.java:51: error: cannot find symbol
        NavigationView navigationView =  findViewById(R.id.nav_view);
        ^
  symbol:   class NavigationView
  location: class FoodMenuActivity
Main.java:51: error: package R does not exist
        NavigationView navigationView =  findViewById(R.id.nav_view);
                                                       ^
Main.java:56: error: method does not override or implement a method from a supertype
    @Override
    ^
Main.java:58: error: cannot find symbol
        super.onStart();
        ^
  symbol:   variable super
  location: class FoodMenuActivity
Main.java:59: error: cannot find symbol
        FirebaseRecyclerAdapter<Food, FoodMenuActivity.FoodViewHolder> FBRA = new FirebaseRecyclerAdapter<Food, FoodMenuActivity.FoodViewHolder>( Food.class,
        ^
  symbol:   class FirebaseRecyclerAdapter
  location: class FoodMenuActivity
Main.java:59: error: cannot find symbol
        FirebaseRecyclerAdapter<Food, FoodMenuActivity.FoodViewHolder> FBRA = new FirebaseRecyclerAdapter<Food, FoodMenuActivity.FoodViewHolder>( Food.class,
                                ^
  symbol:   class Food
  location: class FoodMenuActivity
Main.java:59: error: cannot find symbol
        FirebaseRecyclerAdapter<Food, FoodMenuActivity.FoodViewHolder> FBRA = new FirebaseRecyclerAdapter<Food, FoodMenuActivity.FoodViewHolder>( Food.class,
                                                                                  ^
  symbol:   class FirebaseRecyclerAdapter
  location: class FoodMenuActivity
Main.java:59: error: cannot find symbol
        FirebaseRecyclerAdapter<Food, FoodMenuActivity.FoodViewHolder> FBRA = new FirebaseRecyclerAdapter<Food, FoodMenuActivity.FoodViewHolder>( Food.class,
                                                                                                          ^
  symbol:   class Food
  location: class FoodMenuActivity
Main.java:59: error: cannot find symbol
        FirebaseRecyclerAdapter<Food, FoodMenuActivity.FoodViewHolder> FBRA = new FirebaseRecyclerAdapter<Food, FoodMenuActivity.FoodViewHolder>( Food.class,
                                                                                                                                                  ^
  symbol:   class Food
  location: class FoodMenuActivity
Main.java:60: error: package R does not exist
                R.layout.single_itemmenu,
                 ^
Main.java:94: error: cannot find symbol
            TextView food_name = (TextView) mView.findViewById(R.id.foodName);
            ^
  symbol:   class TextView
  location: class FoodViewHolder
Main.java:94: error: cannot find symbol
            TextView food_name = (TextView) mView.findViewById(R.id.foodName);
                                  ^
  symbol:   class TextView
  location: class FoodViewHolder
Main.java:94: error: package R does not exist
            TextView food_name = (TextView) mView.findViewById(R.id.foodName);
                                                                ^
Main.java:99: error: cannot find symbol
            TextView food_desc = (TextView) mView.findViewById(R.id.foodDesc);
            ^
  symbol:   class TextView
  location: class FoodViewHolder
Main.java:99: error: cannot find symbol
            TextView food_desc = (TextView) mView.findViewById(R.id.foodDesc);
                                  ^
  symbol:   class TextView
  location: class FoodViewHolder
Main.java:99: error: package R does not exist
            TextView food_desc = (TextView) mView.findViewById(R.id.foodDesc);
                                                                ^
Main.java:104: error: cannot find symbol
            TextView food_price = (TextView) mView.findViewById(R.id.foodPrice);
            ^
  symbol:   class TextView
  location: class FoodViewHolder
Main.java:104: error: cannot find symbol
            TextView food_price = (TextView) mView.findViewById(R.id.foodPrice);
                                   ^
  symbol:   class TextView
  location: class FoodViewHolder
Main.java:104: error: package R does not exist
            TextView food_price = (TextView) mView.findViewById(R.id.foodPrice);
                                                                 ^
Main.java:109: error: cannot find symbol
            ImageView food_image = (ImageView) mView.findViewById(R.id.foodImage);
            ^
  symbol:   class ImageView
  location: class FoodViewHolder
Main.java:109: error: cannot find symbol
            ImageView food_image = (ImageView) mView.findViewById(R.id.foodImage);
                                    ^
  symbol:   class ImageView
  location: class FoodViewHolder
Main.java:109: error: package R does not exist
            ImageView food_image = (ImageView) mView.findViewById(R.id.foodImage);
                                                                   ^
Main.java:110: error: cannot find symbol
            Picasso.with(ctx).load(image).into(food_image);
            ^
  symbol:   variable Picasso
  location: class FoodViewHolder
Main.java:115: error: method does not override or implement a method from a supertype
    @Override
    ^
Main.java:117: error: cannot find symbol
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        ^
  symbol:   class DrawerLayout
  location: class FoodMenuActivity
Main.java:117: error: cannot find symbol
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
                               ^
  symbol:   class DrawerLayout
  location: class FoodMenuActivity
Main.java:117: error: package R does not exist
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
                                                           ^
Main.java:118: error: cannot find symbol
        if (drawer.isDrawerOpen(GravityCompat.START)) {
                                ^
  symbol:   variable GravityCompat
  location: class FoodMenuActivity
Main.java:119: error: cannot find symbol
            drawer.closeDrawer(GravityCompat.START);
                               ^
  symbol:   variable GravityCompat
  location: class FoodMenuActivity
Main.java:121: error: cannot find symbol
            super.onBackPressed();
            ^
  symbol:   variable super
  location: class FoodMenuActivity
Main.java:125: error: method does not override or implement a method from a supertype
    @Override
    ^
Main.java:128: error: package R does not exist
        getMenuInflater().inflate(R.menu.food_menu, menu);
                                   ^
Main.java:128: error: cannot find symbol
        getMenuInflater().inflate(R.menu.food_menu, menu);
        ^
  symbol:   method getMenuInflater()
  location: class FoodMenuActivity
Main.java:132: error: method does not override or implement a method from a supertype
    @Override
    ^
Main.java:140: error: package R does not exist
        if (id == R.id.action_settings) {
                   ^
Main.java:144: error: cannot find symbol
        return super.onOptionsItemSelected(item);
               ^
  symbol:   variable super
  location: class FoodMenuActivity
Main.java:148: error: method does not override or implement a method from a supertype
    @Override
    ^
Main.java:153: error: package R does not exist
        if (id == R.id.nav_menu_category) {
                   ^
Main.java:156: error: package R does not exist
        } else if (id == R.id.nav_orders) {
                          ^
Main.java:157: error: cannot find symbol
            Intent menuIntent = new Intent(FoodMenuActivity.this, MyOrders.class);
            ^
  symbol:   class Intent
  location: class FoodMenuActivity
Main.java:157: error: cannot find symbol
            Intent menuIntent = new Intent(FoodMenuActivity.this, MyOrders.class);
                                    ^
  symbol:   class Intent
  location: class FoodMenuActivity
Main.java:157: error: cannot find symbol
            Intent menuIntent = new Intent(FoodMenuActivity.this, MyOrders.class);
                                                                  ^
  symbol:   class MyOrders
  location: class FoodMenuActivity
Main.java:161: error: package R does not exist
        } else if (id == R.id.logout) {
                          ^
Main.java:163: error: cannot find symbol
            Intent menuIntent = new Intent(FoodMenuActivity.this, signup_form.class);
            ^
  symbol:   class Intent
  location: class FoodMenuActivity
Main.java:163: error: cannot find symbol
            Intent menuIntent = new Intent(FoodMenuActivity.this, signup_form.class);
                                    ^
  symbol:   class Intent
  location: class FoodMenuActivity
Main.java:163: error: cannot find symbol
            Intent menuIntent = new Intent(FoodMenuActivity.this, signup_form.class);
                                                                  ^
  symbol:   class signup_form
  location: class FoodMenuActivity
Main.java:168: error: cannot find symbol
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        ^
  symbol:   class DrawerLayout
  location: class FoodMenuActivity
Main.java:168: error: cannot find symbol
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
                               ^
  symbol:   class DrawerLayout
  location: class FoodMenuActivity
Main.java:168: error: package R does not exist
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
                                                           ^
Main.java:169: error: cannot find symbol
        drawer.closeDrawer(GravityCompat.START);
                           ^
  symbol:   variable GravityCompat
  location: class FoodMenuActivity
98 errors
stdout
Standard output is empty