public void SelectImageFromGallery(WebImageView imageView, string localUrl, string remoteUrl, string fileName, int requestCode) { if (imageView == null) { return; } var intent = new Intent(); intent.SetType("image/*"); intent.SetAction(Intent.ActionGetContent); StartActivityForResult(Intent.CreateChooser(intent, "Select Photo"), requestCode); }
public override View GetView(int position, View convertView, ViewGroup parent) { var view = convertView ?? Context.LayoutInflater.Inflate(Resource.Layout.NewOutletCell, null); var model = ListItems[position]; WebImageView imgView = view.FindViewById <WebImageView>(Resource.Id.WebImageView); imgView.SetImage(model.RemoteURL, -1, -1, null, WebImageView.DefaultCircleTransformation); var textView = view.FindViewById <TextView>(Resource.Id.TextView); textView.Text = model.Type; return(view); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var me = RealmUserServices.GetMe(false); var view = inflater.Inflate(Resource.Layout.EditProfile, container, false); FirstNameEditText = view.FindViewById <EditText>(Resource.Id.FirstNameEditText); FirstNameEditText.Text = me.FirstName; FirstNameEditText.Hint = Strings.Basic.first_name; LastNameEditText = view.FindViewById <EditText>(Resource.Id.LastNameEditText); LastNameEditText.Text = me.LastName; LastNameEditText.Hint = Strings.Basic.last_name; UserProfileImage = view.FindViewById <WebImageView>(Resource.Id.WebImageView); UserProfileImage.SetImage(me.GetRemoteProfileImageUrlCached(), Resource.Drawable.ic_noprofilewhite, Resource.Drawable.ic_noprofilewhite, me.RemoteProfileImageURL, WebImageView.DefaultCircleTransformation); UserProfileImage.Click += (sender, e) => { ShowImageChooser(UserProfileImage, me.LocalProfileImageURL, me.RemoteProfileImageURL, "Profile.png", SelectUserImagePhotoRequestCode); }; var progressButton = view.FindViewById <Button>(Resource.Id.ProgressButton); progressButton.Click += (object sender, EventArgs e) => { string firstName = FirstNameEditText.Text.Trim(); string lastName = LastNameEditText.Text.Trim(); bool allFieldsValid = ValidateAllFields(); if (!allFieldsValid) { return; } me.UpdateStringProperty(() => me.FirstName, firstName); me.UpdateStringProperty(() => me.LastName, lastName); DismissIfValid(); }; return(view); }
public void ShowImageChooser(WebImageView imageView, string localUrl, string remoteUrl, string fileName, int requestCode) { var activity = Activity as MainActivity; activity?.HideKeyboard(); var me = RealmUserServices.GetMe(false); var builder = new Android.Support.V7.App.AlertDialog.Builder(Activity); builder.SetTitle(Strings.Alerts.select_image_source); builder.SetCancelable(true); builder.SetPositiveButton(Strings.Alerts.user_facebook_image, (senderAlert, args) => { DownloadFacebookImage(imageView, localUrl, remoteUrl, fileName); }); builder.SetNegativeButton(Strings.Alerts.select_from_gallery, async delegate { var storagePermission = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Storage); if (storagePermission == PermissionStatus.Granted) { SelectImageFromGallery(imageView, localUrl, remoteUrl, fileName, requestCode); } else { var dict = await CrossPermissions.Current.RequestPermissionsAsync(Permission.Storage); if (dict.ContainsKey(Permission.Storage) && dict[Permission.Storage] == PermissionStatus.Granted) { SelectImageFromGallery(imageView, localUrl, remoteUrl, fileName, requestCode); } else { //alert } } }); builder.Show(); }
public async void DownloadFacebookImage(WebImageView imageView, string localUrl, string remoteUrl, string fileName) { if (imageView == null) { return; } var me = RealmUserServices.GetMe(false); if (me == null) { return; } var url = me.GetFacebookProfilePictureUrl(); if (url == null) { return; } imageView.SetImageResource(Resource.Drawable.ic_noprofilewhite); //required to remove it here otherwise itll load form cache await ImageService.Instance.InvalidateCacheEntryAsync(me.RemoteProfileImageURL, FFImageLoading.Cache.CacheType.All, true); ImageService.Instance.LoadUrl(url).Success(async(FFImageLoading.Work.ImageInformation arg1, FFImageLoading.Work.LoadingResult arg2) => { if (arg1 == null) { return; } var image = await ImageUtils.GetImageAtPath(arg1.FilePath); if (image == null) { return; } var bytes = ImageUtils.ImagetoByteArray(image, 100); if (bytes == null) { return; } S3Utils.UploadPhoto(bytes, localUrl, remoteUrl, fileName, () => { if (Activity == null) { return; } Activity.RunOnUiThread(async() => { await ImageService.Instance.InvalidateCacheAsync(FFImageLoading.Cache.CacheType.All);//.InvalidateCacheEntryAsync(me.RemoteProfileImageURL, FFImageLoading.Cache.CacheType.All); imageView.SetImage(me.GetRemoteProfileImageUrlCached(), Resource.Drawable.ic_noprofilewhite, Resource.Drawable.ic_noprofilewhite, me.RemoteProfileImageURL, WebImageView.DefaultCircleTransformation); }); }, null); }) .Finish((FFImageLoading.Work.IScheduledWork obj) => { }) .Transform(WebImageView.DefaultCircleTransformation) .Error(exception => { imageView.ShowLoadingIndicators(); return; }) .Into(imageView); }
public ImageViewCell(View v, int height) : base(v) { ImageView = v.FindViewById <WebImageView>(Resource.Id.WebImageView); ImageView.SetMinimumHeight(height); ImageView.SetMinimumWidth(height); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var view = inflater.Inflate(Resource.Layout.Google, container, false); TitleTextView = view.FindViewById <TextView>(Resource.Id.TitleTextView); ImageView = view.FindViewById <WebImageView>(Resource.Id.ImageView); view.FindViewById(Resource.Id.sign_in_button).SetOnClickListener(this); // [START configure_signin] // Configure sign-in to request the user's ID, email address, and basic // profile. ID and basic profile are included in DEFAULT_SIGN_IN. GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn) .RequestEmail() .Build(); // [END configure_signin] // [START build_client] // Build a GoogleApiClient with access to the Google Sign-In API and the // options specified by gso. if (mGoogleApiClient == null) { mGoogleApiClient = new GoogleApiClient.Builder(Activity) .AddApi(Auth.GOOGLE_SIGN_IN_API, gso) .Build(); } // [END build_client] // [START customize_button] // Set the dimensions of the sign-in button. var signInButton = view.FindViewById <SignInButton>(Resource.Id.sign_in_button); signInButton.SetSize(SignInButton.SizeStandard); // [END customize_button] var opr = Auth.GoogleSignInApi.SilentSignIn(mGoogleApiClient); if (opr.IsDone) { // If the user's cached credentials are valid, the OptionalPendingResult will be "done" // and the GoogleSignInResult will be available instantly. //var result = opr.Get() as GoogleSignInResult; //HandleSignInResult(result); SignOut(); } else { // If the user has not previously signed in on this device or the sign-in has expired, // this asynchronous branch will attempt to sign in the user silently. Cross-device // single sign-on will occur in this branch. ShowHud(Strings.Hud.please_wait); opr.SetResultCallback(new SignInResultCallback { Fragment = this }); } return(view); }