protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); splashPresenter = new SplashPresenter(this); handler = new Handler(); startImage = FindViewById <ImageView>(Resource.Id.startImage); title = FindViewById <TextView>(Resource.Id.title); var url = StartImageShared.GetImg(this); var text = StartImageShared.GetText(this); if (url != "") { var file = new Java.IO.File(System.IO.Path.Combine(this.CacheDir.Path, url)); Picasso.With(this).Load(file).Into(startImage); title.Text = text; } else { Picasso.With(this).Load(Resource.Drawable.splash).Into(startImage); } await splashPresenter.GetStartImage(); handler.PostDelayed(() => { MainActivity.Start(this); this.Finish(); }, 3000); }
public void GetStartImageSuccess(StartImageModel img) { var file = img.img.Split('/'); var filename = file[file.Length - 1]; if (!StartImageShared.GetImg(this).Equals(filename)) { Intent intent = new Intent(this, typeof(Services.StartImageService)); intent.PutExtra("url", img.img); intent.PutExtra("text", img.text); StartService(intent); } }
public void OnBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom p1) { var file = url.Split('/'); var filename = file[file.Length - 1]; if (!StartImageShared.GetImg(this).Equals(filename)) { FileStream fstr = null; var path = this.CacheDir.Path; try { fstr = new FileStream(System.IO.Path.Combine(path, filename), FileMode.OpenOrCreate, FileAccess.Write); bitmap.Compress(Bitmap.CompressFormat.Jpeg, 100, fstr); StartImageShared.Update(this, new StartImageModel() { img = filename, text = text }); } catch (Exception e) { File.Delete(System.IO.Path.Combine(path, filename)); } finally { if (fstr != null) { fstr.Flush(); fstr.Close(); } } } else { OnDestroy(); } }