async ValueTask LoadAsync() { if (File.Exists(dataPath)) { await LoadListAsync(); return; } FindViewById <LinearLayout>(Resource.Id.linearLayout1).Visibility = ViewStates.Visible; var getBttton = FindViewById <Button>(Resource.Id.getButton); getBttton.Click += GetButtonClick; var progressBar = FindViewById <ProgressBar>(Resource.Id.loadProgress); progressBar.Visibility = ViewStates.Visible; var code = FindViewById <TextInputEditText>(Resource.Id.code); f****r = new HubCourseScheduleFucker.HubFucker(); var s = await f****r.GetValidationCodeGifAsync(); myGIFImage = FindViewById <GifImageView>(Resource.Id.myGIFImage); var buffer = new byte[s.Length]; await s.ReadAsync(buffer); progressBar.Visibility = ViewStates.Gone; code.Visibility = ViewStates.Visible; myGIFImage.SetBytes(buffer); myGIFImage.StartAnimation(); getBttton.Visibility = ViewStates.Visible; }
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; } }
async void GetGif(string url) { var giphy = new Giphy("dc6zaTOxFJmzC"); var gifresult = await giphy.RandomGif(new RandomParameter() { Tag = searchingText }); try { using (var client = new HttpClient()) { if (url == null) // refresh gif { this.url = "https://media.giphy.com/media/" + gifresult.Data.Id.ToString() + "/giphy.gif"; //Toast.MakeText(this, "1", ToastLength.Short).Show(); } else // load from json { this.url = url; //Toast.MakeText(this, "2", ToastLength.Short).Show(); } var bytes = await client.GetByteArrayAsync(this.url); gifImage.SetBytes(bytes); gifImage.StartAnimation(); } } catch (Exception e) { Toast.MakeText(this, "Bad connection", ToastLength.Short).Show(); } }
private void SetPlaceholder() { gifImageView = view.FindViewById <GifImageView>(Resource.Id.gif_View); var bytes = GifViewHelper.ReadAllBytes(Resources.OpenRawResource(Resource.Drawable.rewards_placeholder)); gifImageView.SetBytes(bytes); }
protected override void OnResume() { base.OnResume(); SetContentView(Resource.Layout.GIFSplash); gifImageView = FindViewById <GifImageView>(Resource.Id.gifImageViews); Stream input = Assets.Open("splash2.gif"); byte[] bytes = ConvertFileToByteArray(input); gifImageView.SetBytes(bytes); gifImageView.StartAnimation(); if ((int)Build.VERSION.SdkInt >= 23) { if (CheckSelfPermission(Manifest.Permission.AccessFineLocation) != Permission.Granted || CheckSelfPermission(Manifest.Permission.AccessCoarseLocation) != Permission.Granted) { RequestPermissions(Permissions, 0); } } var timer = new Timer { Interval = 1500, AutoReset = false, }; timer.Elapsed += Timer_Elapsed; timer.Start(); }
private async void LoadScreen() { try { using (var client = new HttpClient()) { var bytes = await client.GetByteArrayAsync("https://i.imgur.com/8q8Z0yM.gif"); gifImageView.SetBytes(bytes); gifImageView.StartAnimation(); } await Task.Delay(5000); Load(); } catch (Exception ex) { Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this); alert.SetCancelable(false); alert.SetTitle("AlarmTrip"); alert.SetMessage("Brak połączenia z internetem!\nDo prawidłowego działania aplikacji niezbędne jest połączenie z interentem."); alert.SetPositiveButton("Ok", (senderAlert, args) => { Android.OS.Process.KillProcess(Android.OS.Process.MyPid()); }); Dialog dialog = alert.Create(); dialog.Show(); Log.Info(tag, "Error: " + ex.ToString()); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here //var mainIntent = new Intent(Application.Context, typeof(MainActivity)); //if (Intent.Extras != null) // mainIntent.PutExtras(Intent.Extras); //mainIntent.SetFlags(ActivityFlags.SingleTop); //StartActivity(mainIntent); SetContentView(Resource.Layout.SplashScreen); gifImageView = FindViewById <GifImageView>(Resource.Id.gifIamgeView); Stream input = Assets.Open("splash.gif"); byte[] bytes = ConvertFileToByteArray(input); gifImageView.SetBytes(bytes); gifImageView.StartAnimation(); Timer timer = new Timer(); timer.Interval = 5000; timer.AutoReset = false; timer.Elapsed += Timer_Elapsed; timer.Start(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.SplashScreen); gifImageView = FindViewById <GifImageView>(Resource.Id.gifImageView); progressBar = FindViewById <ProgressBar>(Resource.Id.pgRefresh); var input = Assets.Open("splash_screen.gif"); var bytes = ConvertFileToByteArray(input); gifImageView.SetBytes(bytes); gifImageView.StartAnimation(); Timer timer = new Timer { Enabled = true, Interval = 3000, AutoReset = false }; timer.Elapsed += (sender, e) => { StartActivity(new Intent(this, typeof(MainActivity))); }; }
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"; } }
public void bind() { AssetManager assets = MainActivity.assets; Stream input = assets.Open("giphyPapper.gif"); byte[] bytes = ConvertFileToByteArray(input); image.SetBytes(bytes); image.StartAnimation(); }
private void StartGif(string fileName, GifImageView viewName) { byte[] bytes; Stream input = Assets.Open(fileName); using (MemoryStream ms = new MemoryStream()) { input.CopyTo(ms); bytes = ms.ToArray(); } viewName.SetBytes(bytes); viewName.StartAnimation(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.SplashScreen); gifImageView = FindViewById <GifImageView>(Resource.Id.gifImageView); Stream input = Assets.Open("splash_screen1.gif"); byte[] bytes = ConvertFileToByteArray(input); gifImageView.SetBytes(bytes); gifImageView.StartAnimation(); System.Timers.Timer timer = new System.Timers.Timer(); timer.Interval = 5000; timer.AutoReset = false; timer.Elapsed += TimerOnElapsed; timer.Start(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.SplashScreen); gifImageView = FindViewById <GifImageView>(Resource.Id.gifImageView); Stream input = Assets.Open("slidin_squares.gif"); byte[] bytes = ConvertFileToByteArray(input); gifImageView.SetBytes(bytes); gifImageView.StartAnimation(); //Wait for 6 seconds and start new Activity System.Timers.Timer timer = new System.Timers.Timer(); timer.Interval = 3000; timer.AutoReset = false; timer.Elapsed += Timer_Elapsed; timer.Start(); Toast.MakeText(this, "Logging in...", ToastLength.Long).Show(); }
private GifImageView gifImageView; //using Felipecsl.GifImageViewLibrary; protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.SplashScreen); gifImageView = FindViewById <GifImageView>(Resource.Id.gifImageView); Stream input = Assets.Open("google-gif-logo.gif"); // en la carpeta assets esta el archivo "google-gif-logo.gif" byte[] bytes = ConvertFileToByteArray(input); gifImageView.SetBytes(bytes); gifImageView.StartAnimation(); Timer timer = new Timer(); //using System.Timers; timer.Interval = 5000; timer.AutoReset = false; timer.Elapsed += Timer_Elapsed; timer.Start(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.SplashScreen); gifImageView = FindViewById <GifImageView>(Resource.Id.gifImageView); progressBar = FindViewById <ProgressBar>(Resource.Id.progressBar); Stream input = Assets.Open("mhcho.gif"); byte[] bytes = ConvertFileToByteArray(input); gifImageView.SetBytes(bytes); gifImageView.StartAnimation(); //Wait for 3 seconds and start new Activity Timer timer = new Timer(); timer.Interval = 3000; timer.AutoReset = false; timer.Elapsed += Timer_Elapsed; timer.Start(); }
protected override void OnResume() { base.OnResume(); SetContentView(Resource.Layout.GIFSplash); gifImageView = FindViewById <GifImageView>(Resource.Id.gifImageViews); Stream input = Assets.Open("splash2.gif"); byte[] bytes = ConvertFileToByteArray(input); gifImageView.SetBytes(bytes); gifImageView.StartAnimation(); var timer = new Timer { Interval = 1500, AutoReset = false, }; timer.Elapsed += Timer_Elapsed; timer.Start(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here SetContentView(Resource.Layout.ActivityLogin); m_LoginError = FindViewById <TextView>(Resource.Id.LoginError); m_UsernameView = FindViewById <EditText>(Resource.Id.LoginUser); m_PassView = FindViewById <EditText>(Resource.Id.LoginPass); Button btnLogin = FindViewById <Button>(Resource.Id.LoginBtn); m_LoadingGif = FindViewById <GifImageView>(Resource.Id.loadingCat); System.IO.Stream input = Assets.Open("progress_nc.gif"); byte[] bytes = Utils.ConvertByteArray(input); m_LoadingGif.SetBytes(bytes); m_LoadingGif.StartAnimation(); btnLogin.Click += BtnLogin_Click; }
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); } } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.SplashScreen); gifImageView = FindViewById <GifImageView>(Resource.Id.gifSplash); AssetManager assets = this.Assets; Stream input = assets.Open("splash_dragon5.gif"); byte[] bytes = ConvertFileToByteArray(input); gifImageView.SetBytes(bytes); gifImageView.StartAnimation(); //Wait for 3 seconds and start new Activity Timer timer = new Timer(); timer.Interval = 4200; timer.AutoReset = false; timer.Elapsed += Timer_Elapsed; timer.Start(); }
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 void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); context = Application.Context; #region Мова ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(context); ISharedPreferencesEditor editor = prefs.Edit(); languagesId = prefs.GetInt("key_languageId", 1); if (languagesId == 1) { LanguageCodevalue = "en"; } else if (languagesId == 2) { LanguageCodevalue = "fr"; } else if (languagesId == 3) { LanguageCodevalue = "de"; } else if (languagesId == 4) { LanguageCodevalue = "it"; } else if (languagesId == 5) { LanguageCodevalue = "es"; } else if (languagesId == 6) { LanguageCodevalue = "pt"; } else if (languagesId == 7) { LanguageCodevalue = "cs"; } else if (languagesId == 8) { LanguageCodevalue = "pl"; } else if (languagesId == 9) { LanguageCodevalue = "ru"; } else if (languagesId == 10) { LanguageCodevalue = "uk"; } else if (languagesId == 11) { LanguageCodevalue = "ja"; } else if (languagesId == 12) { LanguageCodevalue = "ko"; } Android.Content.Res.Resources res = this.Resources; DisplayMetrics Dm = res.DisplayMetrics; Android.Content.Res.Configuration conf = res.Configuration; if (LanguageCodevalue != null) { conf.SetLocale(new Locale(LanguageCodevalue)); } else { conf.SetLocale(new Locale("en")); } res.UpdateConfiguration(conf, Dm); #endregion Window.AddFlags(WindowManagerFlags.Fullscreen); SetContentView(Resource.Layout._splashScreenNew); gifImageView = FindViewById <GifImageView>(Resource.Id.gifSplashScreen); var assets1 = Assets.List(string.Empty); if (assets1.Any()) { var videoFilename = assets1.FirstOrDefault(a => a.EndsWith(".gif")); if (!string.IsNullOrWhiteSpace(videoFilename)) { var fileDescriptor = Assets.OpenFd(videoFilename); using (var input = this.Assets.Open(videoFilename, Access.Streaming)) { byte[] buffer; using (Stream s = input) { long length = fileDescriptor.Length; buffer = new byte[length]; s.Read(buffer, 0, (int)length); gifImageView.SetBytes(buffer); gifImageView.StartAnimation(); } } } } System.Timers.Timer timer = new System.Timers.Timer(); timer.Interval = 1400; timer.AutoReset = false; timer.Elapsed += Timer_Elapsed; timer.Start(); }
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(); } }
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; }); } }); }