2
2
3
3
import android .content .SharedPreferences ;
4
4
import android .os .Bundle ;
5
+ import android .support .v4 .view .ViewPager ;
5
6
import android .view .KeyEvent ;
6
7
import android .view .View ;
7
8
import android .widget .ArrayAdapter ;
@@ -36,7 +37,7 @@ public void onViewCreated(View view, Bundle savedInstanceState) {
36
37
37
38
final TextView textView = (TextView ) view .findViewById (R .id .favoritesReservationsText );
38
39
CharSequence text = textView .getText ();
39
- textView .setText (text .subSequence (0 ,text .length ()- 1 )+ " " + selected + ":" );
40
+ textView .setText (text .subSequence (0 , text .length () - 1 ) + " " + selected + ":" );
40
41
41
42
42
43
final ListView mListView = (ListView ) view .findViewById (R .id .favoritesReservationsList );
@@ -45,11 +46,12 @@ public void onViewCreated(View view, Bundle savedInstanceState) {
45
46
@ Override
46
47
public void run () {
47
48
final Reservations [] reservations = Requests .getReservationsOfRoom (mListView , FragmentFavoritesReservations .selected );
48
- if (reservations ==null ) return ;
49
+ if (reservations ==null || reservations . length == 0 ) return ;
49
50
if (mListView ==null ) return ;
50
51
mListView .post (new Runnable () {
51
52
@ Override
52
53
public void run () {
54
+ textView .append ("\n \t \t \t (capacité: " + reservations [0 ].getRoomRef ().getCapacity ()+")" );
53
55
//2- affichage
54
56
ArrayAdapter <String > adapter = new ArrayAdapter <String >(getActivity (),
55
57
android .R .layout .simple_list_item_1 , Globals .formatReservations (reservations , getContext (),false ));
@@ -66,7 +68,7 @@ public void run() {
66
68
@ Override
67
69
public boolean onKey (View v , int keyCode , KeyEvent event ) {
68
70
if (keyCode == KeyEvent .KEYCODE_BACK ) {
69
- ((MainActivity ) v .getContext ()). getmSectionsPagerAdapter ( ).switchFavoritesFragment ();
71
+ ((MainActivity . SectionsPagerAdapter )(( ViewPager ) v .getRootView (). findViewById ( R . id . container )). getAdapter () ).switchFavoritesFragment ();
70
72
return true ;
71
73
}
72
74
return false ;
0 commit comments