public async Task <ChadderError> DownloadPicture(ChadderPicture picture)
        {
            var response = await Session.PostRequestAPI <BasicResponse <byte[]> >(Urls.DownloadBlob, picture.Id);

            if (response.Error == ChadderError.OK)
            {
                var packed = Content.Deserialize(response.Extra);
                if (packed == null)
                {
                    Insight.Track("Not a valid content");
                    return(ChadderError.INVALID_INPUT);
                }
                if (packed is ImageContent)
                {
                    var record = new ChadderSQLPicture()
                    {
                        PictureId    = picture.Id,
                        Bin          = (packed as ImageContent).BinData,
                        ToBeUploaded = false
                    };
                    await sqlDB.InsertAsync(record);

                    picture.RecordId = record.recordId;
                    return(ChadderError.OK);
                }
                else
                {
                    Insight.Track("Not a ImageContent");
                    return(ChadderError.INVALID_INPUT);
                }
            }
            return(response.Error);
        }
예제 #2
0
        public static MediaViewerFragment Create(ChadderPicture picture)
        {
            var result = new MediaViewerFragment();

            result.Arguments = new Bundle();
            result.Arguments.PutString(EXTRA_PICTURE_ID, picture.Id);
            return(result);
        }
예제 #3
0
 public override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     _picture = ChadderUI.Source.db.Pictures.FirstOrDefault(i => i.Id == Arguments.GetString(EXTRA_PICTURE_ID, null));
     if (_picture == null)
     {
         SupportFragmentManager.PopBackStack();
     }
 }
예제 #4
0
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     Picture = null;
 }