protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.LoggedInPanel); Settings.LoadInfos(); FindViewById<Button>(Resource.Id.btnUploadNew).Click += delegate { PickFileActivity.OnFinishAction = (path) => { try { //New Upload: Get ticket, do meta, open upload activity var info = new YouTubeUploadTask(); info.Path = path; info.Url = Settings.YouTubeHook.GetUploadSessionUrl(info.Path); Settings.YouTubeInfo = info; Settings.SaveInfos(); StartActivity(new Intent(this, typeof(YouTubeUploadActivity))); } catch (Exception e) { //Getting ticket failed, possibly because YouTubeHook is null or //its access is denied. Switch to main screen. Console.WriteLine(e.Message); StartActivity(new Intent(this, typeof(MainActivity))); } }; PickFileActivity.OnCancelAction = () => StartActivity(new Intent(this, typeof(YouTubePanelActivity))); StartActivity(new Intent(this, typeof(PickFileActivity))); }; FindViewById<Button>(Resource.Id.btnUploadResume).Visibility = (Settings.YouTubeInfo != null && !Settings.YouTubeInfo.Done) ? ViewStates.Visible : ViewStates.Gone; FindViewById<Button>(Resource.Id.btnUploadResume).Click += delegate { //Resume Upload: Open upload activity var info = Settings.YouTubeInfo; if (File.Exists(info.Path)) { StartActivity(new Intent(this, typeof(YouTubeUploadActivity))); } }; }
static void loadYouTube() { var meta = AppSettings.GetValueOrDefault("youtube_meta", string.Empty); if (meta == string.Empty) { YouTubeInfo = null; return; } XmlSerializer xs = new XmlSerializer(typeof(YouTubeUploadTask)); using (TextReader tr = new StringReader(meta)) YouTubeInfo = (YouTubeUploadTask)xs.Deserialize(tr); }