-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFoodListActivity2.java
More file actions
89 lines (78 loc) · 3.09 KB
/
Copy pathFoodListActivity2.java
File metadata and controls
89 lines (78 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package com.example.foodiemenu;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import java.util.ArrayList;
import java.util.List;
public class FoodListActivity2 extends AppCompatActivity {
private FoodListAdapter adapter;
private RecyclerView recyclerViewList;
private FirebaseAuth auth;
private Button logout,bill;
private ImageView cart,dashB;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_food_list2);
cart = findViewById(R.id.cart);
cart.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
Intent intent = new Intent(FoodListActivity2.this,CartActivity.class);
startActivity(intent);
}
});
dashB = findViewById(R.id.dashB);
dashB.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
Intent intent = new Intent(FoodListActivity2.this, DashboardActivity2.class);
startActivity(intent);
}
});
auth = FirebaseAuth.getInstance();
logout = findViewById(R.id.logout);
FirebaseUser user = auth.getCurrentUser();
if (user == null) {
Intent intent = new Intent(FoodListActivity2.this, LoginActivity.class);
startActivity(intent);
finish();
} else {
logout.setText(user.getEmail());
}
logout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FirebaseAuth.getInstance().signOut();
Intent intent = new Intent(FoodListActivity2.this, LoginActivity.class);
startActivity(intent);
finish();
}
});
recyclerViewList = findViewById(R.id.recyclerView);
setupRecyclerView();
populateFoodList();
}
private void populateFoodList() {
List<FoodList> foodList = new ArrayList<>();
foodList.add(new FoodList("Appetizers", "a"));
foodList.add(new FoodList("Burgers", "b"));
foodList.add(new FoodList("Chicken", "c"));
foodList.add(new FoodList("Submarine", "d"));
foodList.add(new FoodList("Beverages", "e"));
foodList.add(new FoodList("Add Ons", "f"));
adapter = new FoodListAdapter((ArrayList<FoodList>) foodList);
recyclerViewList.setAdapter(adapter);
}
private void setupRecyclerView() {
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
recyclerViewList.setLayoutManager(linearLayoutManager);
}
}