Beispiel #1
0
        private async void BeginLoadCover(Action <JryCover> callback)
        {
            if (callback == null)
            {
                throw new ArgumentNullException(nameof(callback));
            }
            var      coverId = this.Source.CoverId;
            JryCover cover   = null;

            if (coverId != null)
            {
                cover = await this.GetManagers().CoverManager.LoadCoverAsync(coverId);
            }
            if (cover == null)
            {
                var generater = this.AutoGenerateCoverProvider;
                if (generater == null || !await generater.GenerateAsync(this.GetManagers(), this.Source))
                {
                    return;
                }
                Debug.Assert(this.Source.CoverId != null);
                cover = await this.GetManagers().CoverManager.LoadCoverAsync(coverId);

                Debug.Assert(cover != null);
            }
            if (this.IsDelayLoad)
            {
                await Task.Yield();
            }
            this.OnLoadCoverEnd(cover);
            callback(cover);
        }
Beispiel #2
0
 public async void BeginUpdateCover()
 {
     if (this.Source.CoverId != null || await this.TryAutoAddCoverAsync())
     {
         var coverManager = JryVideoCore.Current.CurrentDataCenter.CoverManager;
         this.Cover = await coverManager.LoadCoverAsync(this.Source.CoverId);
     }
 }
Beispiel #3
0
 public Task <bool> UpgradeAsync(JryCover item)
 {
     item.CoverSourceType = default(int);
     item.DoubanId        = null;
     item.ImdbId          = null;
     item.SeriesId        = null;
     item.VideoId         = null;
     item.ActorId         = null;
     item.Uri             = null;
     return(Patch0000.TrueTask);
 }
Beispiel #4
0
        public JryCover Build(byte[] binaryData)
        {
            var cover = new JryCover()
            {
                CoverType  = this.CoverType,
                BinaryData = binaryData
            };

            cover.BuildMetaData();
            cover.Id = this.Id;
            return(cover);
        }
Beispiel #5
0
        public async Task <bool> UpgradeAsync(DataCenter dataCenter, JryCover cover)
        {
            string oldCoverId;

            switch (cover.CoverType)
            {
            case CoverType.Artist:

                break;

            case CoverType.Video:
                if (cover.VideoId == null || cover.VideoId == cover.Id)
                {
                    return(true);
                }
                oldCoverId = cover.Id;
                cover.Id   = cover.VideoId;
                await dataCenter.CoverManager.Source.InsertOrUpdateAsync(cover);

                await dataCenter.CoverManager.Source.RemoveAsync(oldCoverId);

                return(true);

            case CoverType.Background:
                if (cover.VideoId == null || JryVideoInfo.CreateBackgroundCoverId(cover.VideoId) == cover.Id)
                {
                    return(true);
                }
                oldCoverId = cover.Id;
                cover.Id   = JryVideoInfo.CreateBackgroundCoverId(cover.VideoId);
                await dataCenter.CoverManager.Source.InsertOrUpdateAsync(cover);

                await dataCenter.CoverManager.Source.RemoveAsync(oldCoverId);

                return(true);

            case CoverType.Role:

                break;
            }

            // return true to update old item, but we remove old item.
            return(false);
        }
Beispiel #6
0
 public Task<bool> UpgradeAsync(JryCover cover) => TrueTask;
Beispiel #7
0
 Task <bool> IPatch <JryCover> .UpgradeAsync(JryCover item)
 {
     throw new NotImplementedException();
 }
Beispiel #8
0
 protected override void OnLoadCoverEnd(JryCover cover)
 {
     this.OpacityData = cover?.Opacity;
     base.OnLoadCoverEnd(cover);
 }
Beispiel #9
0
 protected virtual void OnLoadCoverEnd(JryCover cover)
 {
 }
Beispiel #10
0
 public CoverRef(JryCover obj)
     : base(obj)
 {
     this.CoverType = obj.CoverType;
 }
Beispiel #11
0
 private void BuildCover(JryCover cover) => this.covers.Add(cover.Id, new CoverRef(cover));