48
48
import org .fossasia .openevent .common .utils .Utils ;
49
49
import org .fossasia .openevent .core .bookmark .BookmarkStatus ;
50
50
import org .fossasia .openevent .core .bookmark .OnBookmarkSelectedListener ;
51
+ import org .fossasia .openevent .core .discount .DiscountCodesListAdapter ;
51
52
import org .fossasia .openevent .core .main .MainActivity ;
52
53
import org .fossasia .openevent .core .search .GlobalSearchAdapter ;
53
54
import org .fossasia .openevent .core .search .SearchActivity ;
54
55
import org .fossasia .openevent .core .track .session .SessionSpeakerListAdapter ;
56
+ import org .fossasia .openevent .data .DiscountCode ;
55
57
import org .fossasia .openevent .data .Event ;
56
58
import org .fossasia .openevent .data .Speaker ;
57
59
import org .fossasia .openevent .data .extras .Copyright ;
@@ -104,16 +106,22 @@ public class AboutFragment extends BaseFragment implements OnBookmarkSelectedLis
104
106
protected RecyclerView featuresSpeakersRecyclerView ;
105
107
@ BindView (R .id .logo )
106
108
protected ImageView eventLogo ;
109
+ @ BindView (R .id .discount_code_header )
110
+ protected TextView discountCodeHeader ;
111
+ @ BindView (R .id .list_discount_codes )
112
+ protected RecyclerView discountCodesRecyclerView ;
107
113
108
114
private Context context ;
109
115
private View root ;
110
116
private GlobalSearchAdapter bookMarksListAdapter ;
111
117
private SocialLinksListAdapter socialLinksListAdapter ;
112
118
private SessionSpeakerListAdapter featuredSpeakersListAdapter ;
119
+ private DiscountCodesListAdapter discountCodeListAdapter ;
113
120
114
121
private final List <Object > sessions = new ArrayList <>();
115
122
private final List <SocialLink > socialLinks = new ArrayList <>();
116
123
private final List <Speaker > featuredSpeakers = new ArrayList <>();
124
+ private final List <DiscountCode > discountCodes = new ArrayList <>();
117
125
private static final String MAP_FRAGMENT_TAG = "mapFragment" ;
118
126
119
127
private Event event ;
@@ -134,6 +142,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
134
142
setUpBookmarksRecyclerView ();
135
143
setUpSocialLinksRecyclerView ();
136
144
setUpFeaturedSpeakersRecyclerView ();
145
+ setUpDiscountCodesRecyclerView ();
137
146
138
147
eventLoc .setOnClickListener (v -> {
139
148
if (event .isValid ()) {
@@ -216,6 +225,16 @@ private void setUpFeaturedSpeakersRecyclerView() {
216
225
featuresSpeakersRecyclerView .setItemAnimator (new DefaultItemAnimator ());
217
226
}
218
227
228
+ private void setUpDiscountCodesRecyclerView () {
229
+ discountCodesRecyclerView .setVisibility (View .VISIBLE );
230
+ discountCodeListAdapter = new DiscountCodesListAdapter (discountCodes );
231
+ discountCodesRecyclerView .setLayoutManager (new LinearLayoutManager (getContext (),
232
+ LinearLayoutManager .HORIZONTAL , false ));
233
+ discountCodesRecyclerView .setNestedScrollingEnabled (false );
234
+ discountCodesRecyclerView .setAdapter (discountCodeListAdapter );
235
+ discountCodesRecyclerView .setItemAnimator (new DefaultItemAnimator ());
236
+ }
237
+
219
238
private void loadEvent (Event event ) {
220
239
if (event == null || !event .isValid ())
221
240
return ;
@@ -419,6 +438,14 @@ private void handleVisibility() {
419
438
featuredSpeakersHeader .setVisibility (View .GONE );
420
439
featuresSpeakersRecyclerView .setVisibility (View .GONE );
421
440
}
441
+
442
+ if (!discountCodes .isEmpty ()) {
443
+ discountCodeHeader .setVisibility (View .VISIBLE );
444
+ discountCodesRecyclerView .setVisibility (View .VISIBLE );
445
+ } else {
446
+ discountCodeHeader .setVisibility (View .GONE );
447
+ discountCodesRecyclerView .setVisibility (View .GONE );
448
+ }
422
449
}
423
450
424
451
private void loadData () {
@@ -437,6 +464,14 @@ private void loadData() {
437
464
featuredSpeakersListAdapter .notifyDataSetChanged ();
438
465
handleVisibility ();
439
466
});
467
+
468
+ aboutFragmentViewModel .getDiscountCodes ().observe (this , discountCodes -> {
469
+ this .discountCodes .clear ();
470
+ this .discountCodes .addAll (discountCodes );
471
+ discountCodeListAdapter .notifyDataSetChanged ();
472
+ handleVisibility ();
473
+ Timber .d ("Discount Codes are + " +discountCodes .size ());
474
+ });
440
475
}
441
476
442
477
@ Override
0 commit comments