-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaterial.java
More file actions
180 lines (165 loc) · 7.9 KB
/
material.java
File metadata and controls
180 lines (165 loc) · 7.9 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
package com.example.studyplanner;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.firebase.auth.FirebaseAuth;
public class material extends AppCompatActivity {
private FirebaseAuth mauth;
ListView listView;
String[] bookName = {"Programming in ANSI C", "Object Oriented Programming with C++","Java-The Complete Reference", "Web Engineering",
"Computer Organization and Design Arm Edition", "Fundamentals of Database System"};
String[] bookAuthor = {"Author: E Balaguruswamy", "Author: E Balaguruswamy", "Author: Herbert Schildt", "Author: Robin Nixon", "Author: David Patterson, John Hennessy", "Author: Elmasri, Navathe"};
int images[] = {R.drawable.ansic, R.drawable.cplus, R.drawable.javafinal, R.drawable.webfinal, R.drawable.comifinal, R.drawable.databasefinal};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_material);
listView = findViewById(R.id.listView);
BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_nav);
bottomNavigationView.setSelectedItemId(R.id.nav_schedule3);
MyAdapter myAdapter = new MyAdapter(this, bookName, bookAuthor, images);
listView.setAdapter(myAdapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
if(position==0){
Intent intent = new Intent(getApplicationContext(), BooksList.class);
Bundle bundle = new Bundle();
bundle.putInt("image", images[0]);
intent.putExtra("title", bookName[0]);
intent.putExtra("author", bookAuthor[0]);
intent.putExtra("position", ""+0);
startActivity(intent);
}
if(position==1){
Intent intent = new Intent(getApplicationContext(), BooksList.class);
Bundle bundle = new Bundle();
bundle.putInt("image", images[1]);
intent.putExtra("title", bookName[1]);
intent.putExtra("author", bookAuthor[1]);
intent.putExtra("position", ""+1);
startActivity(intent);
}
if(position==2){
Intent intent = new Intent(getApplicationContext(), BooksList.class);
Bundle bundle = new Bundle();
bundle.putInt("image", images[2]);
intent.putExtra("title", bookName[2]);
intent.putExtra("author", bookAuthor[2]);
intent.putExtra("position", ""+2);
startActivity(intent);
}
if(position==3){
Intent intent = new Intent(getApplicationContext(), BooksList.class);
Bundle bundle = new Bundle();
bundle.putInt("image", images[3]);
intent.putExtra("title", bookName[3]);
intent.putExtra("author", bookAuthor[3]);
intent.putExtra("position", ""+3);
startActivity(intent);
}
if(position==4){
Intent intent = new Intent(getApplicationContext(), BooksList.class);
Bundle bundle = new Bundle();
bundle.putInt("image", images[4]);
intent.putExtra("title", bookName[4]);
intent.putExtra("author", bookAuthor[4]);
intent.putExtra("position", ""+4);
startActivity(intent);
}
if(position==5){
Intent intent = new Intent(getApplicationContext(), BooksList.class);
Bundle bundle = new Bundle();
bundle.putInt("image", images[5]);
intent.putExtra("title", bookName[5]);
intent.putExtra("author", bookAuthor[5]);
intent.putExtra("position", ""+5);
startActivity(intent);
}
}
});
bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId())
{
case R.id.nav_schedule:
startActivity(new Intent(getApplicationContext()
,MainActivityHP.class));
overridePendingTransition(0,0);
return true;
case R.id.nav_schedule1:
startActivity(new Intent(getApplicationContext()
,graph.class));
overridePendingTransition(0,0);
return true;
case R.id.nav_schedule2:
startActivity(new Intent(getApplicationContext()
,Quiz.class));
overridePendingTransition(0,0);
return true;
case R.id.nav_schedule3:
return true;
}
return false;
}
});
}
class MyAdapter extends ArrayAdapter<String> {
Context context;
String bTitle[];
String bAuthor[];
int bImage[];
MyAdapter (Context c, String title[], String author[], int image[]){
super(c, R.layout.row, R.id.textView1, title);
this.context = c;
this.bTitle =title;
this.bAuthor =author;
this.bImage = image;
}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
LayoutInflater layoutInflater = (LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View row = layoutInflater.inflate(R.layout.row, parent, false);
ImageView images = row.findViewById(R.id.image);
TextView bkTitle = row.findViewById(R.id.textView1);
TextView bkAuthor = row.findViewById(R.id.textView2);
images.setImageResource(bImage[position]);
bkTitle.setText(bTitle[position]);
bkAuthor.setText(bAuthor[position]);
return row;
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.mainmenu,menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()){
case R.id.logout:
mauth.signOut();
startActivity(new Intent(getApplicationContext(),MainActivity.class));
break;
}
return super.onOptionsItemSelected(item);
}
}