Ejemplo n.º 1
0
        private void SetTargetTimeSliceGroup(LibraryAdapter adapter)
        {
            if (adapter == null || _timesliceGroups == null || _timesliceGroups.Count == 0)
            {
                return;
            }

            adapter.Target = _timesliceGroups.Find(p => { return(p.Id == adapter.TargetId); });

            if (adapter.Target == null)
            {
                return;
            }

            TimeSliceGroupInfo group = adapter.Target as TimeSliceGroupInfo;

            if (group == null || group.Items == null || group.Items.Length == 0)
            {
                return;
            }

            foreach (LibraryAdapter ada in group.Items)
            {
                SetTargetMessage(ada);
            }
        }
Ejemplo n.º 2
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            UserDialogs.Init(this);

            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_booklist);

            _context = await this.CreateContextAsync();

            _adapter = new LibraryAdapter(this);

            var recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView_bookList);

            recyclerView.SetAdapter(_adapter);
            _adapter.RecyclerView = recyclerView;

            recyclerView.SetLayoutManager(new LinearLayoutManager(this));

            var bookList = await _context.Books.AsNoTracking().ToListAsync();

            _adapter.AddBooks(bookList);

            FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.floatingActionButton_addBook);

            fab.Click += FabOnClick;
        }
    public static void Main()
    {
        ITarget ITarget = new LibraryAdapter();
        Library Library = new Library(ITarget);

        Library.ShowBooks();
    }
Ejemplo n.º 4
0
        private void SetTargetMessage(LibraryAdapter adapter)
        {
            if (adapter == null || _messages == null || _messages.Count == 0)
            {
                return;
            }

            adapter.Target = _messages.Find(p => { return(p.Id == adapter.TargetId); });
        }
Ejemplo n.º 5
0
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            GlobalContext  = (TabbedMainActivity)Activity;
            HasOptionsMenu = true;

            if (MAdapter == null)
            {
                MAdapter = new LibraryAdapter(Activity);
            }
        }
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            HasOptionsMenu = true;
            // Create your fragment here
            GlobalContext = (HomeActivity)Activity;

            if (MAdapter == null)
            {
                MAdapter = new LibraryAdapter(Activity);
            }
        }
Ejemplo n.º 7
0
 private void OnRedeemFiveClicked(object sender, RoutedEventArgs e)
 {
     Branch.I.RedeemRewards(5, async(changed, error) => {
         int credits = LibraryAdapter.GetPrefHelper().GetCreditCount();
         await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () => {
             List <string> lines = new List <string>();
             lines.Add("Credits count: " + credits);
             lines.Add("Error: " + (error != null ? error.GetMessage() : "no errors"));
             AddLog(lines);
         });
     });
 }
Ejemplo n.º 8
0
        public PlaylistItemControl(LibraryAdapter item, int unitWidth)
        {
            this.lblName.TextAlign   = ContentAlignment.TopCenter;
            this.lblName.BackColor   = Color.Transparent;
            this.lblName.Width       = this.Width;
            this.lblName.Dock        = DockStyle.Bottom;
            this.lblName.MouseDown  += new MouseEventHandler(lblName_MouseDown);
            this.lblName.MouseMove  += new MouseEventHandler(lblName_MouseMove);
            this.lblName.MouseHover += new EventHandler(lblName_MouseHover);
            this.lblName.MouseLeave += new EventHandler(lblName_MouseLeave);
            this.lblName.DragDrop   += new DragEventHandler(lblName_DragDrop);
            this.lblName.DragOver   += new DragEventHandler(lblName_DragOver);
            this.lblName.DragEnter  += new DragEventHandler(lblName_DragEnter);
            this.lblName.Text        = item.Target.Name;
            this.Controls.Add(lblName);

            this.Text       = "";
            this.BackColor  = ControlService.MouseLeaveColor;
            this.AllowDrop  = true;
            this.ImageAlign = ContentAlignment.TopLeft;
            this.TextAlign  = ContentAlignment.BottomCenter;
            ImageList       = Images.imageList;
            ImageIndex      = Images.GetIndex(item.Type);
            SetTitle(this.lblName.Text, item.Target.Type.ToString(), item.Target.LengthText);
            Width = item.Target.Length * unitWidth;

            _durationTxt = item.Target.LengthText;
            if (_durationTxt.Substring(0, 2) == "00")
            {
                _durationTxt = _durationTxt.Substring(3, _durationTxt.Length - 3);
            }

            Top    = 10;
            Height = 48;
            if (item.Type == LibraryType.TimeSliceGroupProxy)
            {
                TimeSliceGroupInfo group = item.Target as TimeSliceGroupInfo;
                foreach (MessageAdapterInfo adp in group.Items)
                {
                    if (adp.IsActive)
                    {
                        (item as TimeSliceGroupAdapterInfo).CurrentMessageAdapterName = adp.Name;
                        break;
                    }
                }
            }
            _playlistItem = item;
            _initRect     = new Rectangle(this.Width - 40, 8, 35, 30);
            LocalMessageBus.Subject <LibraryRenameMessage>().Observers += new ObserverHandler <LibraryRenameMessage>(OnLibraryRename);
            //LocalMessageBus.Subject<LibraryImageChangeMessage>().Observers += new ObserverHandler<LibraryImageChangeMessage>(OnLibraryImageChange);
        }
Ejemplo n.º 9
0
 public MainPage()
 {
     this.InitializeComponent();
     //
     System.Threading.Tasks.Task.Run(async() => {
         await BranchConfigManager.LoadAll();
         await LibraryAdapter.GetPrefHelper().LoadAll();
         //Branch.I.SetDebug(true);
         Branch.I.InitSession(new BranchInitCallbackWrapper(async(buo, link, error) => {
             List <string> lines = new List <string>();
             lines.Add("Init session, parameters: ");
             lines.Add("Title" + " - " + buo.Title);
             lines.Add("Link" + " - " + buo.CanonicalUrl);
             await Dispatcher.RunAsync(CoreDispatcherPriority.High, () => {
                 Debug.WriteLine(error.GetMessage());
             });
         }));
     });
 }
Ejemplo n.º 10
0
        private void SetTargetPlaylist(LibraryAdapter adapter)
        {
            if (adapter == null || _playlists == null || _playlists.Count == 0)
            {
                return;
            }

            adapter.Target = _playlists.Find(p => { return(p.Id == adapter.TargetId); });

            if (adapter.Target == null)
            {
                return;
            }

            PlaylistInfo playlist = adapter.Target as PlaylistInfo;

            if (playlist == null || playlist.Items == null || playlist.Items.Length == 0)
            {
                return;
            }

            playlist.Items.ForEach(p =>
            {
                switch (p.Type)
                {
                case LibraryType.MessageProxy:
                    SetTargetMessage(p);
                    break;

                case LibraryType.TimeSliceGroupProxy:
                    SetTargetTimeSliceGroup(p);
                    break;

                case LibraryType.PlaylistProxy:
                    SetTargetPlaylist(p);
                    break;
                }
            }
                                   );
        }
Ejemplo n.º 11
0
        private void TestData()
        {
            list = new List <PlantInfo>();

            // Item click events showed wrong results , fix later.
            list.Add(new PlantInfo("Cam", " TRung Quoc ", Resource.Drawable.icon_soilcare2));
            list.Add(new PlantInfo("Tao", " Lao ", Resource.Drawable.icon_soilcare2));
            list.Add(new PlantInfo("Buoi", " Viet Nam ", Resource.Drawable.icon_soilcare2));
            list.Add(new PlantInfo("Oi", " TRung Quoc ", Resource.Drawable.icon_soilcare2));
            list.Add(new PlantInfo("Xoai", " Thai Lan ", Resource.Drawable.icon_soilcare2));
            list.Add(new PlantInfo("Man", " Nga ", Resource.Drawable.icon_soilcare2));
            list.Add(new PlantInfo("Dao", " My ", Resource.Drawable.icon_soilcare2));
            list.Add(new PlantInfo("Nho", " Quang Binh ", Resource.Drawable.icon_soilcare2));
            list.Add(new PlantInfo("Quyt", " TRung Quoc ", Resource.Drawable.icon_soilcare2));
            list.Add(new PlantInfo("Le", " Viet Nam ", Resource.Drawable.icon_soilcare2));
            list.Add(new PlantInfo("Mang Cau", " TRung Quoc ", Resource.Drawable.icon_soilcare2));
            list.Add(new PlantInfo("Mit uot", " Han Quoc ", Resource.Drawable.icon_soilcare2));

            adapter                    = new LibraryAdapter(this, list);
            listView.Adapter           = adapter;
            listView.TextFilterEnabled = true;
        }
Ejemplo n.º 12
0
 public PlaylistItemControl(LibraryAdapter item)
 {
     this.Text = "";
 }