Created
January 20, 2016 15:05
-
-
Save nodoid/303be439be4177840e57 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IMediaPicker media; | |
btnTakePic.Clicked += async delegate | |
{ | |
try | |
{ | |
progressStack.IsVisible = progressStack.IsEnabled = true; | |
App.Self.Uploaded = 0; | |
var mediaFile = await media.TakePhotoAsync(new CameraMediaStorageOptions { DefaultCamera = CameraDevice.Front, MaxPixelDimension = 400 }); | |
Device.BeginInvokeOnMainThread(async () => | |
await DisplayAlert("Uploading", "Your photo is currently being uploaded to our servers. This may take some time depending on your connection speed", "OK").ContinueWith(async w => | |
{ | |
if (w.IsCompleted) | |
{ | |
filesize = (int)mediaFile.Source.Length; | |
DependencyService.Get<INetwork>().NetworkSpinner(true); | |
await SendData.HttpPost(mediaFile, App.Self.Settings.GetSetting<string>("token"), userProfile.xACCid, folderid); | |
} | |
})); | |
} | |
catch (Exception) | |
{ | |
} | |
}; | |
btnUpload.Clicked += async delegate | |
{ | |
try | |
{ | |
progressStack.IsVisible = progressStack.IsEnabled = true; | |
App.Self.Uploaded = 0; | |
var mediaFile = await media.SelectPhotoAsync(new CameraMediaStorageOptions | |
{ | |
DefaultCamera = CameraDevice.Rear, | |
MaxPixelDimension = 400 | |
}); | |
Device.BeginInvokeOnMainThread(async () => | |
await DisplayAlert("Uploading", "Your photo is currently being uploaded to our servers. This may take some time depending on your connection speed", "OK").ContinueWith(async w => | |
{ | |
if (w.IsCompleted) | |
{ | |
DependencyService.Get<INetwork>().NetworkSpinner(true); | |
filesize = (int)mediaFile.Source.Length; | |
await SendData.HttpPost(mediaFile, App.Self.Settings.GetSetting<string>("token"), userProfile.xACCid, folderid); | |
} | |
})); | |
} | |
catch (Exception) | |
{ | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment