-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCustomAppointmentViewProvider.cs
More file actions
48 lines (40 loc) · 1.9 KB
/
CustomAppointmentViewProvider.cs
File metadata and controls
48 lines (40 loc) · 1.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
using System;
using System.Collections.Generic;
using Android.Content;
using Android.Graphics;
using Android.Util;
using Android.Views;
using DevExpress.XamarinAndroid.Scheduler.Visual.Data;
using DevExpress.XamarinForms.Scheduler;
using DevExpress.XamarinForms.Scheduler.Android;
namespace CustomMonthViewProviders.Droid {
public class CustomAppointmentViewProvider : ICachedViewProvider {
Queue<View> cache = new Queue<View>();
public void BindView(View view, ItemViewInfo viewInfo, ItemViewModel viewModel) {
CustomAppointmentView appointmentView = (CustomAppointmentView)view;
AppointmentViewInfo appointmentViewInfo = (AppointmentViewInfo)viewInfo;
appointmentView.SetBackgroundColor(new Color(viewInfo.BackColor));
appointmentView.SubjectView.Text = appointmentViewInfo.TextElementInfo.Text;
appointmentView.SubjectView.Typeface = appointmentViewInfo.TextElementInfo.Typeface;
appointmentView.SubjectView.SetTextSize(ComplexUnitType.Px, appointmentViewInfo.TextElementInfo.TextSize);
appointmentView.SubjectView.SetTextColor(new Color(appointmentViewInfo.TextElementInfo.TextColor));
}
public View CreateNewView(int logicalIndex, ItemViewInfo viewInfo, ItemViewModel viewModel, Context context) {
return new CustomAppointmentView(context);
}
public int GetStubColor(int logicalIndex, ItemViewInfo viewInfo, ItemViewModel viewModel) {
return viewInfo.BackColor;
}
public void Recycle() {
this.cache.Clear();
}
public void RecycleView(View view) {
this.cache.Enqueue(view);
}
public View RequestViewFromCache(int logicalIndex, ItemViewInfo viewInfo, ItemViewModel viewModel) {
if (this.cache.Count == 0)
return null;
return cache.Dequeue();
}
}
}