public async void OnClick(View v) { int id = v.Id; if (id == Resource.Id.btnStart) { try { using (var client = new HttpClient()) { var bytes = await client.GetByteArrayAsync("http://gifdanceparty.giphy.com/assets/dancers/smooch.gif"); gifImageView.SetBytes(bytes); gifImageView.StartAnimation(); } } catch (Exception ex) { } } else if (id == Resource.Id.btnStop) { gifImageView.StopAnimation(); } else if (id == Resource.Id.btnBlur) { isBlur = !isBlur; } }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); gifImageView = FindViewById<GifImageView>(Resource.Id.gifImageView); btnToggle = FindViewById<Button>(Resource.Id.btnToggle); btnBlur = FindViewById<Button>(Resource.Id.btnBlur); var btnClear = FindViewById<Button>(Resource.Id.btnClear); gifImageView.OnFrameAvailableListener = this; blur = Blur.NewInstance(this); btnBlur.Click += (sender, e) => { shouldBlur = !shouldBlur; }; btnClear.Click += (sender, e) => gifImageView.Clear(); btnToggle.Click += (sender, e) => { try { if(gifImageView.IsAnimating) gifImageView.StopAnimation(); else gifImageView.StartAnimation(); } catch(Exception ex) { } }; btnBlur.Enabled = false; btnClear.Enabled = false; btnToggle.Enabled = false; try { ActionBar.Title = "Loading..."; var client = new HttpClient(); var bytes = await client.GetByteArrayAsync("http://dogoverflow.com/dRX5G8qK"); gifImageView.SetBytes(bytes); gifImageView.StartAnimation(); ActionBar.Title = "Gif!!!"; btnBlur.Enabled = true; btnClear.Enabled = true; btnToggle.Enabled = true; } catch(Exception ex) { ActionBar.Title = "error downloading"; } }
protected override async void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); if (e.PropertyName == Image.SourceProperty.PropertyName) { byte[] bytes = null; var s = Element.Source; if (s is UriImageSource) { using (var client = new HttpClient()) bytes = await client.GetByteArrayAsync(((UriImageSource)s).Uri); } else if (s is StreamImageSource) { bytes = await GetBytesFromStreamAsync(await((StreamImageSource)s).Stream(default(CancellationToken))); } else if (s is FileImageSource) { bytes = await GetBytesFromStreamAsync(File.OpenRead(((FileImageSource)s).File)); } if (bytes == null) { return; } try { _gif.StopAnimation(); _gif.SetBytes(bytes); _gif.StartAnimation(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Unable to load gif: " + ex.Message); } } }
private void Timer_Elapsed(object sender, ElapsedEventArgs e) { gifImageView.StopAnimation(); ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(context); ISharedPreferencesEditor editor = prefs.Edit(); firstActivityId = prefs.GetInt("key_firstActivityId", 8); // key 1 if (firstActivityId == 1) { StartActivity(new Intent(this, typeof(InfoStat))); } else if (firstActivityId == 2) { StartActivity(new Intent(this, typeof(CompareStat))); } else /* if (firstActivityId == 3) * { * StartActivity(new Intent(this, typeof(InfoStat))); * } * else*/ if (firstActivityId == 4) { StartActivity(new Intent(this, typeof(InfoPlane))); } else if (firstActivityId == 5) { StartActivity(new Intent(this, typeof(ComparePlane))); } else if (firstActivityId == 6) { StartActivity(new Intent(this, typeof(TheBestPlane))); } else if (firstActivityId == 7) { StartActivity(new Intent(this, typeof(InfoTank))); } else if (firstActivityId == 8) { StartActivity(new Intent(this, typeof(CompareTank))); } else if (firstActivityId == 9) { StartActivity(new Intent(this, typeof(TheBestTank))); } else if (firstActivityId == 10) { StartActivity(new Intent(this, typeof(InfoHeli))); } else if (firstActivityId == 11) { StartActivity(new Intent(this, typeof(CompareHeli))); } else if (firstActivityId == 12) { StartActivity(new Intent(this, typeof(TheBestHeli))); } else if (firstActivityId == 13) { StartActivity(new Intent(this, typeof(InfoShip))); } else if (firstActivityId == 14) { StartActivity(new Intent(this, typeof(CompareShip))); } else if (firstActivityId == 15) { StartActivity(new Intent(this, typeof(TheBestShip))); } }
public override void OnStop() { base.OnStop(); gifImageView.StopAnimation(); }
private async void GetButtonClick(object sender, EventArgs e) { FindViewById <LinearLayout>(Resource.Id.linearLayout1).Visibility = ViewStates.Gone; await Task.Run(async() => { RunOnUiThread(() => { progress.Visibility = ViewStates.Visible; progressBar1.Visibility = ViewStates.Visible; }); try { RunOnUiThread(() => { progress.Text = "Logging in...This may take 20s"; }); await f****r.LoginAsync(FindViewById <TextInputEditText>(Resource.Id.stuId).Text, FindViewById <TextInputEditText>(Resource.Id.passwd).Text, FindViewById <TextInputEditText>(Resource.Id.code).Text); RunOnUiThread(() => { progress.Text = $"Fetching course data... {0}%"; }); for (int i = 0; i < 20; i++) { for (int j = 1; j < 8; j++) { var lects = await f****r.GetDailyLectureAsync(i + 1, (DayOfWeek)(j % 7)); RunOnUiThread(() => { progress.Text = $"Fetching course data... {(int)((i * 7 + j) / 1.4)}%"; }); lectures.Add(new DailyLectures { DayOfWeek = (DayOfWeek)(j % 7), Week = i + 1, Lectures = lects }); } } RunOnUiThread(async() => { progress.Visibility = ViewStates.Gone; progressBar1.Visibility = ViewStates.Gone; var s = System.Text.Json.JsonSerializer.Serialize(lectures); await File.WriteAllTextAsync(dataPath, s); FindViewById <LinearLayout>(Resource.Id.linearLayout1).Visibility = ViewStates.Gone; await LoadListAsync(); Toast.MakeText(this, "done", ToastLength.Long).Show(); }); } catch (Exception) { RunOnUiThread(async() => { Toast.MakeText(this, $"Login Failed!", ToastLength.Long).Show(); progress.Visibility = ViewStates.Gone; progressBar1.Visibility = ViewStates.Gone; myGIFImage.Visibility = ViewStates.Gone; FindViewById <LinearLayout>(Resource.Id.linearLayout1).Visibility = ViewStates.Visible; FindViewById <LinearLayout>(Resource.Id.linearLayout1).Visibility = ViewStates.Visible; var getBttton = FindViewById <Button>(Resource.Id.getButton); var progressBar = FindViewById <ProgressBar>(Resource.Id.loadProgress); getBttton.Visibility = ViewStates.Gone; progressBar.Visibility = ViewStates.Visible; var code = FindViewById <TextInputEditText>(Resource.Id.code); code.Visibility = ViewStates.Gone; var s = await f****r.GetValidationCodeGifAsync(); myGIFImage = FindViewById <GifImageView>(Resource.Id.myGIFImage); myGIFImage.StopAnimation(); var buffer = new byte[s.Length]; await s.ReadAsync(buffer); progressBar.Visibility = ViewStates.Gone; code.Visibility = ViewStates.Visible; myGIFImage.SetBytes(buffer); myGIFImage.StartAnimation(); myGIFImage.Visibility = ViewStates.Visible; getBttton.Visibility = ViewStates.Visible; }); } }); }
protected override void OnStop() { base.OnStop(); gifImageView.StopAnimation(); }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); gifImageView = FindViewById <GifImageView>(Resource.Id.gifImageView); btnToggle = FindViewById <Button>(Resource.Id.btnToggle); btnBlur = FindViewById <Button>(Resource.Id.btnBlur); var btnClear = FindViewById <Button>(Resource.Id.btnClear); gifImageView.OnFrameAvailableListener = this; blur = Blur.NewInstance(this); btnBlur.Click += (sender, e) => { shouldBlur = !shouldBlur; }; btnClear.Click += (sender, e) => gifImageView.Clear(); btnToggle.Click += (sender, e) => { try { if (gifImageView.IsAnimating) { gifImageView.StopAnimation(); } else { gifImageView.StartAnimation(); } } catch (Exception ex) { } }; btnBlur.Enabled = false; btnClear.Enabled = false; btnToggle.Enabled = false; try { ActionBar.Title = "Loading..."; var client = new HttpClient(); var bytes = await client.GetByteArrayAsync("http://dogoverflow.com/dRX5G8qK"); gifImageView.SetBytes(bytes); gifImageView.StartAnimation(); ActionBar.Title = "Gif!!!"; btnBlur.Enabled = true; btnClear.Enabled = true; btnToggle.Enabled = true; } catch (Exception ex) { ActionBar.Title = "error downloading"; } }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); gifImageView = FindViewById<GifImageView>(Resource.Id.gifImageView); var gifImageViewTrans = FindViewById<GifImageView>(Resource.Id.gifImageView2); btnToggle = FindViewById<Button>(Resource.Id.btnToggle); btnBlur = FindViewById<Button>(Resource.Id.btnBlur); var btnClear = FindViewById<Button>(Resource.Id.btnClear); //if setting OnFrameAvailableListener you must call GC Collect() gifImageView.OnFrameAvailableListener = this; blur = Blur.NewInstance(this); btnBlur.Click += (sender, e) => { shouldBlur = !shouldBlur; }; btnClear.Click += (sender, e) => gifImageView.Clear(); btnToggle.Click += (sender, e) => { try { if(gifImageView.IsAnimating) gifImageView.StopAnimation(); else gifImageView.StartAnimation(); } catch(Exception ex) { } }; btnBlur.Enabled = false; btnClear.Enabled = false; btnToggle.Enabled = false; try { ActionBar.Title = "Loading..."; var client = new HttpClient(); var bytes = await client.GetByteArrayAsync("http://dogoverflow.com/dogs/RX5G8qK.gif"); gifImageView.SetBytes(bytes); gifImageView.StartAnimation(); bytes = await client.GetByteArrayAsync("http://25.media.tumblr.com/c99a579db3ae0fc164bf4cca148885d3/tumblr_mjgv8kEuMg1s87n79o1_400.gif"); gifImageViewTrans.SetBytes(bytes); gifImageViewTrans.StartAnimation(); ActionBar.Title = "Gif!!!"; btnBlur.Enabled = true; btnClear.Enabled = true; btnToggle.Enabled = true; } catch(Exception ex) { ActionBar.Title = "error downloading"; Toast.MakeText(this, ex.ToString(), ToastLength.Long).Show(); } }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); gifImageView = FindViewById <GifImageView>(Resource.Id.gifImageView); var gifImageViewTrans = FindViewById <GifImageView>(Resource.Id.gifImageView2); btnToggle = FindViewById <Button>(Resource.Id.btnToggle); btnBlur = FindViewById <Button>(Resource.Id.btnBlur); var btnClear = FindViewById <Button>(Resource.Id.btnClear); //if setting OnFrameAvailableListener you must call GC Collect() gifImageView.OnFrameAvailableListener = this; blur = Blur.NewInstance(this); btnBlur.Click += (sender, e) => { shouldBlur = !shouldBlur; }; btnClear.Click += (sender, e) => gifImageView.Clear(); btnToggle.Click += (sender, e) => { try { if (gifImageView.IsAnimating) { gifImageView.StopAnimation(); } else { gifImageView.StartAnimation(); } } catch (Exception ex) { } }; btnBlur.Enabled = false; btnClear.Enabled = false; btnToggle.Enabled = false; try { ActionBar.Title = "Loading..."; var client = new HttpClient(); var bytes = await client.GetByteArrayAsync("http://dogoverflow.com/dogs/RX5G8qK.gif"); gifImageView.SetBytes(bytes); gifImageView.StartAnimation(); bytes = await client.GetByteArrayAsync("http://25.media.tumblr.com/c99a579db3ae0fc164bf4cca148885d3/tumblr_mjgv8kEuMg1s87n79o1_400.gif"); gifImageViewTrans.SetBytes(bytes); gifImageViewTrans.StartAnimation(); ActionBar.Title = "Gif!!!"; btnBlur.Enabled = true; btnClear.Enabled = true; btnToggle.Enabled = true; } catch (Exception ex) { ActionBar.Title = "error downloading"; Toast.MakeText(this, ex.ToString(), ToastLength.Long).Show(); } }