HistoriqueActivity.java
1.57 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
package com.example.martin.projetv5;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ListView;
import java.util.ArrayList;
/**
* Created by martin on 18/02/2017.
*/
public class HistoriqueActivity extends AppCompatActivity implements EventAdapter.EventAdapterListener {
ArrayList<Event> listEvents = new ArrayList<>();
EventAdapter adapter = null;
ListView list = null;
Event[] tabEvents = null;
StringBDD eventBDD = null;
void addEventList(Event ev, ArrayList<Event> listP){
listP.add(ev);
adapter.notifyDataSetChanged();
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.historique_layout);
adapter = new EventAdapter(this,listEvents);
adapter.addListener(this);
list = (ListView)findViewById(R.id.list2);
list.setAdapter(adapter);
eventBDD = new StringBDD(this);
eventBDD.open();
int indMax = eventBDD.getIndiceMaxEvent();
tabEvents = new Event[indMax];
for(int j=0; j<indMax; j++){
Event ev = eventBDD.getEventWithId(indMax-j);
addEventList(ev,listEvents);
}
}
@Override
protected void onResume() {
eventBDD.open();
super.onResume();
}
@Override
protected void onPause() {
eventBDD.close();
super.onPause();
}
@Override
public void onClickButton(Event item, int position) {}
}