public override void ViewDidLoad() { base.ViewDidLoad(); var me = RealmUserServices.GetMe(true); var initials = (me.FirstName?.FirstOrDefault() + " " + me.LastName?.FirstOrDefault()).Trim(); CTStringAttributes attributes = new CTStringAttributes(); attributes.KerningAdjustment = -2; NSAttributedString attributedString = new NSAttributedString(initials, attributes); InititalsLabel.AttributedText = attributedString; InititalsLabel.BackgroundColor = UIColor.FromWhiteAlpha(0.9f, 1); InititalsLabel.TextColor = UIColor.Gray; InititalsLabel.Layer.MasksToBounds = true; InititalsLabel.Layer.CornerRadius = InititalsLabel.Frame.Size.Width / 2; NameLabel.Text = me.FirstName + " " + me.LastName; HandleLabel.Text = me.Handle; AddChildViewController(TableViewController); ContainerView.AddSubview(TableViewController.View); View.AddConstraint(NSLayoutConstraint.Create(TableViewController.View, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Top, 1, 0)); View.AddConstraint(NSLayoutConstraint.Create(TableViewController.View, NSLayoutAttribute.Right, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Right, 1, 0)); View.AddConstraint(NSLayoutConstraint.Create(TableViewController.View, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Bottom, 1, 0)); View.AddConstraint(NSLayoutConstraint.Create(TableViewController.View, NSLayoutAttribute.Left, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Left, 1, 0)); FooterLabel.Text = DrawerShared.GetFooterText(); }
void AnimateUserNameAndPicture(Action completed) { if (Cancelled) { return; } var me = RealmUserServices.GetMe(false); if (me == null) { return; } //todo uncomment var targetName = Strings.Onboarding.default_name;//; String.IsNullOrEmpty(me.Name) ? Strings.Onboarding.default_name : me.Name; var vc = ChildViewControllers.Where(c => c.GetType() == typeof(CardViewController)).First() as CardViewController; vc.AnimateTextUserNameLabel(targetName, 0.1, () => { vc.AddUserImage(me.RemoteProfileImageURL); completed?.Invoke(); }); }
partial void StartButtonClicked(Foundation.NSObject sender) { string firstName = FirstNameTextField.Text.Trim(); string lastName = LastNameTextField.Text.Trim(); bool allFieldsValid = ValidateAllFields(); if (!allFieldsValid) { return; } var realm = RealmManager.SharedInstance.GetRealm(null); var me = RealmUserServices.GetMe(false); realm.Write(() => { me.FirstName = firstName; me.LastName = lastName; }); SlinkUser.SetNextHandelByNameIfNecessary(); UIView.Animate(1, delegate { View.Alpha = 0; }, delegate { ApplicationExtensions.ShowOnboarding(true); }); }
void NextPage() { var me = RealmUserServices.GetMe(true); var realm = RealmManager.SharedInstance.GetRealm(null); //cache facebook image var str = "https://graph.facebook.com/" + Shared.FacebookUserId + "/picture?type=large"; var image = UIImage.LoadFromData(NSData.FromUrl(NSUrl.FromString(str))); var bytes = ImageUtils.ByteArrayFromImage(image, 50); S3Utils.UploadPhoto(bytes, me.LocalProfileImageURL, me.RemoteProfileImageURL, "Profile.png", null, null); Shared.NextPage(); UIView.Animate(1, delegate { View.Alpha = 0; }, delegate { if (String.IsNullOrEmpty(me.FirstName) || String.IsNullOrEmpty(me.LastName)) { ((LandingTabbarController)TabBarController).SetSelectedViewControllerByType(typeof(HelloViewController), false, null); } else { SlinkUser.SetNextHandelByNameIfNecessary(); ApplicationExtensions.ShowOnboarding(false); } }); }
public override void ViewDidLoad() { base.ViewDidLoad(); var me = RealmUserServices.GetMe(false); FirstNameTextField.KeyboardType = UIKeyboardType.EmailAddress; FirstNameTextField.Text = me.FirstName; FirstNameTextField.Placeholder = Strings.Basic.first_name; FirstNameTextField.AutocorrectionType = UITextAutocorrectionType.No; FirstNameTextField.EditingDidEndOnExit += (sender, e) => { FirstNameTextField.ResignFirstResponder(); }; LastNameTextField.KeyboardType = UIKeyboardType.EmailAddress; LastNameTextField.Text = me.LastName; LastNameTextField.Placeholder = Strings.Basic.last_name; LastNameTextField.AutocorrectionType = UITextAutocorrectionType.No; LastNameTextField.EditingDidEndOnExit += (sender, e) => { LastNameTextField.ResignFirstResponder(); }; ProfileImageButton.SetImageWithCustomCache(me.GetRemoteProfileImageUrlCached(), FallbackImageFileName, FallbackImageFileName, me.RemoteProfileImageURL); ProfileImageButton.Layer.MasksToBounds = true; ProfileImageButton.Layer.CornerRadius = ProfileImageButton.Frame.Size.Width / 2; ProfileImageButton.ClipsToBounds = true; ProfileImageButton.ActivityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray; SetProgressButton(SaveButton); RemoveBackBarButtonTitle(); }
public bool SaveCardIfPossible() { var card = Shared.SelectedCard; var name = card.Name; if (String.IsNullOrEmpty(name) || name.Equals(Strings.Basic.new_card, StringComparison.InvariantCultureIgnoreCase)) { ShowCardMissingNameAlert(); return(false); } if (card.Outlets.Count == 0) { ShowCardMissingOutletsAlert(); return(false); } var me = RealmUserServices.GetMe(false); var realm = RealmManager.SharedInstance.GetRealm(null); realm.Write(() => { card.Owner = me; }); return(true); }
public override void RecyclerView_ItemClick(SettingsShared.SettingsModel obj, int position) { base.RecyclerView_ItemClick(obj, position); if (obj == null || String.IsNullOrEmpty(obj.Title)) { return; } if (obj.Title.Equals(SettingsShared.navigation_item_my_outlets, StringComparison.InvariantCulture)) { ((MainActivity)Activity).AddFragmentOver(new MyOutletsRecyclerViewFragment()); return; } if (obj.Title.Equals(SettingsShared.navigation_item_edit_profile, StringComparison.InvariantCulture)) { ((MainActivity)Activity).AddFragmentOver(new EditProfileFragment()); return; } if (obj.Title.Equals(SettingsShared.navigation_item_design, StringComparison.InvariantCulture)) { Shared.DesignChanged(); int no = Shared.target.Values.Count; for (int i = 0; i < 3; i++) { //FlyingObjectsFragment flyobj = new FlyingObjectsFragment(); Console.WriteLine("=========================+++++++>" + Shared.target.Values[0]); Console.WriteLine("=========================++++++>" + Shared.target.Values[1]); Console.WriteLine("=========================++++++>" + Shared.target.Values[2]); } RecyclerView.GetAdapter().NotifyDataSetChanged(); return; } if (obj.Title.Equals(SettingsShared.navigation_item_logout, StringComparison.InvariantCulture)) { RealmUserServices.Logout(); if (Profile.CurrentProfile != null) { LoginManager.Instance.LogOut(); } var iPersistant = ServiceLocator.Instance.Resolve <IPersistantStorage>(); iPersistant.RemoveAll(); iPersistant.SetDesignType("Color"); Activity.StartActivity(typeof(LandingActivity)); return; } }
public override void ViewDidLoad() { PullToRefresh = false; base.ViewDidLoad(); AutomaticallyAdjustsScrollViewInsets = false; TableSource = new SettingsTableViewSource(); TableSource.ItemSelected += (NSIndexPath arg1, SettingsShared.SettingsModel arg2) => { if (arg2 == null || String.IsNullOrEmpty(arg2.Title)) { return; } if (arg2.Title.Equals(SettingsShared.navigation_item_my_outlets, StringComparison.InvariantCultureIgnoreCase)) { //this is used to counter the auto reload. See NewCardTableViewController Transporter.SharedInstance.RemoveObject(Transporter.NewOutletAddedTransporterKey); Transporter.SharedInstance.RemoveObject(Transporter.NewOutletAddedValueTransporterKey); ApplicationExtensions.PushViewController(new MyOutletsViewController(), true); return; } if (arg2.Title.Equals(SettingsShared.navigation_item_edit_profile, StringComparison.InvariantCultureIgnoreCase)) { ApplicationExtensions.PushViewController(new EditProfileViewController(), true); return; } if (arg2.Title.Equals(SettingsShared.navigation_item_design, StringComparison.InvariantCultureIgnoreCase)) { Shared.DesignChanged(); TableView.ReloadRows(new NSIndexPath[] { arg1 }, UITableViewRowAnimation.Automatic); return; } if (arg2.Title.Equals(SettingsShared.navigation_item_logout, StringComparison.InvariantCultureIgnoreCase)) { RealmUserServices.Logout(); if (Profile.CurrentProfile != null) { new LoginManager().LogOut(); } var iPersistant = ServiceLocator.Instance.Resolve <IPersistantStorage>(); iPersistant.RemoveAll(); ApplicationExtensions.LoadStoryboardRoot("Landing", false); return; } }; TableView.Source = TableSource; TableSource.SetItems(TableView, Shared.GetTableItems()); }
public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); var me = RealmUserServices.GetMe(true); FirstNameTextField.Text = me.FirstName; LastNameTextField.Text = me.LastName; }
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); }
void SelectImageFromGallery(string localUrl, string remoteUrl, string fileName) { if (ProfileImageButton == null) { return; } var vc = new GalleryImagePicker(); vc.Canceled += (s, e) => { vc.DismissViewController(true, null); }; vc.FinishedPickingMedia += (object s, UIImagePickerMediaPickedEventArgs e) => { switch (e.Info[UIImagePickerController.MediaType].ToString()) { case "public.image": Console.WriteLine("Image selected"); var me = RealmUserServices.GetMe(false); ProfileImageButton.SetImage(UIImage.FromBundle(FallbackImageFileName), new UIControlState()); ProfileImageButton.ShowLoadingIndicators(); UIImage originalImage = e.Info[UIImagePickerController.OriginalImage] as UIImage; var smallerImage = ImageUtils.ScaledToSize(originalImage, new CGSize(200, 200)); var bytes = ImageUtils.ByteArrayFromImage(smallerImage, 100); S3Utils.UploadPhoto(bytes, localUrl, remoteUrl, fileName, () => { SDWebImageManager.SharedManager.ImageCache.RemoveImage(me.RemoteProfileImageURL, true, null); ProfileImageButton.SetImageWithCustomCache(me.GetRemoteProfileImageUrlCached(), FallbackImageFileName, FallbackImageFileName, me.RemoteProfileImageURL); }, null); break; case "public.video": Console.WriteLine("Video selected"); break; } vc.DismissViewController(true, null); }; PresentViewController(vc, true, null); }
public override void ViewDidLoad() { base.ViewDidLoad(); NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Save, (sender, e) => { var card = GetCard(); var name = card.Name; if (String.IsNullOrEmpty(name) || name.Equals(Strings.Basic.new_card, StringComparison.InvariantCultureIgnoreCase)) { ShowCardMissingNameAlert(); return; } if (card.Outlets.Count == 0) { ShowCardMissingOutletsAlert(); return; } var me = RealmUserServices.GetMe(false); var realm = RealmManager.SharedInstance.GetRealm(null); realm.Write(() => { card.Owner = me; }); View.EndEditing(true); NavigationController.PopViewController(true); }); var topRightButtonTitle = (GetCard() == null) ? "Discard" : Strings.Basic.delete; NavigationItem.RightBarButtonItem = new UIBarButtonItem(topRightButtonTitle, UIBarButtonItemStyle.Plain, (sender, e) => { DeleteCard(); View.EndEditing(true); NavigationController.PopToRootViewController(true); }); }
public override void OnActivityResult(int requestCode, int resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); if (requestCode == SelectUserImagePhotoRequestCode && resultCode == (int)Android.App.Result.Ok) { if (data == null) { return; } using (var bitmap = MediaStore.Images.Media.GetBitmap(Activity.ContentResolver, data.Data)) { var bytes = ImageUtils.ImagetoByteArray(bitmap, 100); if (bytes == null) { return; } UserProfileImage.SetImageResource(Resource.Drawable.ic_noprofilewhite); UserProfileImage.ShowLoadingIndicators(); var me = RealmUserServices.GetMe(false); var localUrl = me.LocalProfileImageURL; var remoteUrl = me.RemoteProfileImageURL; var fileName = "Profile.png"; 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); UserProfileImage.SetImage(me.GetRemoteProfileImageUrlCached(), Resource.Drawable.ic_noprofilewhite, Resource.Drawable.ic_noprofilewhite, me.RemoteProfileImageURL, WebImageView.DefaultCircleTransformation); }); }, null); }; } }
partial void ProfileImageButtonClicked(Foundation.NSObject sender) { var isTablet = CrossDeviceInfo.Current.Idiom == Idiom.Tablet; var alertStyle = isTablet ? UIAlertControllerStyle.Alert : UIAlertControllerStyle.ActionSheet; UIAlertController AlertController = UIAlertController.Create(Strings.Alerts.select_image_source, null, alertStyle); AlertController.AddAction(UIAlertAction.Create(Strings.Alerts.user_facebook_image, UIAlertActionStyle.Default, (obj) => { var me = RealmUserServices.GetMe(false); DownloadFacebookImage(me.LocalProfileImageURL, me.RemoteProfileImageURL, "Profile.png"); })); AlertController.AddAction(UIAlertAction.Create(Strings.Alerts.select_from_gallery, UIAlertActionStyle.Default, (obj) => { var me = RealmUserServices.GetMe(false); SelectImageFromGallery(me.LocalProfileImageURL, me.RemoteProfileImageURL, "Profile.png"); })); AlertController.AddAction(UIAlertAction.Create(Strings.Basic.cancel, UIAlertActionStyle.Cancel, null)); PresentViewController(AlertController, true, null); }
partial void SaveButtonClicked(Foundation.NSObject sender) { View.EndEditing(true); string firstName = FirstNameTextField.Text.Trim(); string lastName = LastNameTextField.Text.Trim(); bool allFieldsValid = ValidateAllFields(); if (!allFieldsValid) { return; } var me = RealmUserServices.GetMe(false); me.UpdateStringProperty(() => me.FirstName, firstName); me.UpdateStringProperty(() => me.LastName, lastName); DismissIfValid(); }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { Window = new UIWindow(UIScreen.MainScreen.Bounds); // Override point for customization after application launch. // If not required for your application you can safely delete this method // Code to start the Xamarin Test Cloud Agent #if ENABLE_TEST_CLOUD //Xamarin.Calabash.Start(); #endif ServiceLocator.Instance.Add <IS3Service, S3Service>(); ServiceLocator.Instance.Add <IImageDownloader, ImageDownloader>(); ServiceLocator.Instance.Add <IPersistantStorage, PersistantStorage>(); ServiceLocator.Instance.Add <IBroadcastNotificaion, BroadCastNotificaion>(); Profile.EnableUpdatesOnAccessTokenChange(true); Settings.AppID = NotSensitive.SlinkKeys.facebook_app_id; Settings.DisplayName = NotSensitive.SlinkKeys.facebook_display_name; if (RealmUserServices.DidUserPersist()) { ApplicationExtensions.EnterApplication(false, true); } else { ApplicationExtensions.LoadStoryboardRoot("Landing", false); } SetupUnauthorizedCatcher(); PredownloadImages(); AppCenter.Start("fa06eb43-8be9-426c-97f9-42f3ab13cd3b", typeof(Analytics), typeof(Crashes)); ServiceRunner.SharedInstance.StartService <AppCenterManager>(); MobileAds.Configure("ca-app-pub-4252799872870196~2848379026"); return(true); }
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(); }
async public void OnSuccess(Java.Lang.Object result) { var loginResult = result as LoginResult; if (loginResult == null) { return; } string tokenString = AccessToken.CurrentAccessToken.Token; if (String.IsNullOrEmpty(tokenString)) { ShowAlert("3", "Token Empty"); AppCenterManager.Report("3"); return; } string userId = loginResult.AccessToken.UserId; ShowHud("Loading"); bool sucessful = await Shared.CreateUser(tokenString); if (!sucessful) { HideHud(); LoginManager.Instance.LogOut(); RealmUserServices.Logout(); AppCenterManager.Report("4"); return; } HideHud(); NextPage(); }
void DownloadFacebookImage(string localUrl, string remoteUrl, string fileName) { if (ProfileImageButton == null) { return; } var me = RealmUserServices.GetMe(false); if (me == null) { return; } var url = me.GetFacebookProfilePictureUrl(); if (url == null) { return; } ProfileImageButton.SetImage(UIImage.FromBundle(FallbackImageFileName), new UIControlState()); ProfileImageButton.ShowLoadingIndicators(); SDWebImageManager.SharedManager.ImageDownloader.DownloadImage(NSUrl.FromString(url), SDWebImageDownloaderOptions.HighPriority, null, (image, data, error, finished) => { if (image == null || error != null) { ProfileImageButton.ShowLoadingIndicators(); return; } var bytes = ImageUtils.ByteArrayFromImage(image, 100); S3Utils.UploadPhoto(bytes, localUrl, remoteUrl, fileName, () => { SDWebImageManager.SharedManager.ImageCache.RemoveImage(me.RemoteProfileImageURL, true, null); ProfileImageButton.SetImageWithCustomCache(me.GetRemoteProfileImageUrlCached(), FallbackImageFileName, FallbackImageFileName, me.RemoteProfileImageURL); }, null); }); }
void NextPage() { var me = RealmUserServices.GetMe(true); //cache facebook image var str = "https://graph.facebook.com/" + Shared.FacebookUserId + "/picture?type=large"; var image = ImageUtils.GetImageBitmapFromUrl(str); var bytes = ImageUtils.ImagetoByteArray(image, 100); S3Utils.UploadPhoto(bytes, me.LocalProfileImageURL, me.RemoteProfileImageURL, "Profile.png", null, null); Shared.NextPage(); if (String.IsNullOrEmpty(me.FirstName) || String.IsNullOrEmpty(me.LastName)) { //((LandingTabbarController)TabBarController).SetSelectedViewControllerByType(typeof(HelloViewController), false, null); } else { SlinkUser.SetNextHandelByNameIfNecessary(); Activity.StartActivity(typeof(InstructionActivity)); } }
public override void ViewDidLoad() { base.ViewDidLoad(); //if user has no cards, create their facebook one var me = RealmUserServices.GetMe(false); if (me.Cards.Count() == 0) { var outlet = me.Outlets.Where(c => c.Type.Equals(Outlet.outlet_type_facebook, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault(); if (outlet != null) { var card = Card.Create(); card.AddOutlet(outlet); var realm = RealmManager.SharedInstance.GetRealm(null); realm.Write(() => { card.Name = "Facebook Card"; card.Owner = me; }); } } NavigationItem.RightBarButtonItem = new UIBarButtonItem(Strings.Basic.skip, UIBarButtonItemStyle.Plain, (sender, e) => { Cancelled = true; removeAllSubviews(false, () => { //ApplicationExtensions.LoadStoryboardRoot("Landing", false); ApplicationExtensions.EnterApplication(false, true); }); }); }
public override void ViewDidLoad() { base.ViewDidLoad(); Profile.Notifications.ObserveDidChange((sender, e) => { if (e.NewProfile == null) { return; } Shared.FacebookFirstName = e.NewProfile.FirstName; Shared.FacebookLastName = e.NewProfile.LastName; Shared.FacebookUserId = e.NewProfile.UserID; Shared.FacebookFullName = e.NewProfile.Name; Shared.SetUserData(Shared.FacebookUserId, Shared.FacebookFirstName, Shared.FacebookLastName); }); // Set the Read and Publish permissions you want to get loginView = new LoginButton(FacebookButtonSuperview.Bounds) { LoginBehavior = LoginBehavior.Native, ReadPermissions = Shared.FacebookPermissions.ToArray() }; // Handle actions once the user is logged in loginView.Completed += async(sender, e) => { if (e == null) { return; } if (e.Result != null && e.Result.IsCancelled) { return; } if (e.Error != null) { AppCenterManager.Report(e.Error.LocalizedDescription); AppCenterManager.Report("2"); ShowAlert("Oops!", e.Error.LocalizedDescription); return; } if (e.Result.Token == null) { return; } string tokenString = e.Result.Token.TokenString; if (String.IsNullOrEmpty(tokenString)) { ShowAlert("3", "Token Empty"); AppCenterManager.Report("3"); return; } ShowHud("Loading"); bool sucessful = await Shared.CreateUser(tokenString); if (!sucessful) { HideHud(); new LoginManager().LogOut(); RealmUserServices.Logout(); AppCenterManager.Report("4"); return; } HideHud(); NextPage(); }; // Handle actions once the user is logged out loginView.LoggedOut += (s, ev) => { if (LogoutCancellationToken == null) { LogoutCancellationToken = new CancellationTokenSource(); SettingsShared.Logout(LogoutCancellationToken.Token); } }; FacebookButtonSuperview.AddSubview(loginView); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); var transaction = SupportFragmentManager.BeginTransaction(); transaction.Add(Resource.Id.under_fragment, new FlyingObjectsFragment()); transaction.Add(Resource.Id.over_fragment, new MyCardsRecyclerViewFragment()); transaction.Commit(); var footerTextView = FindViewById <TextView>(Resource.Id.footer); footerTextView.Text = DrawerShared.GetFooterText(); var navigationView = FindViewById <NavigationView>(Resource.Id.nav_view); navigationView.NavigationItemSelected += (sender, e) => { var drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout); drawer?.CloseDrawers(); if (e.MenuItem.ItemId == Resource.Id.my_cards) { AddFragmentOver(new MyCardsRecyclerViewFragment()); return; } if (e.MenuItem.ItemId == Resource.Id.discover) { // AddFragmentOver("Discover"); return; } if (e.MenuItem.ItemId == Resource.Id.connections) { //AddFragmentOver("Connections"); return; } if (e.MenuItem.ItemId == Resource.Id.settings) { AddFragmentOver(new SettingsRecyclerViewFragment()); return; } }; var itemDecorator = new DividerItemDecoration(this, DividerItemDecoration.Vertical); itemDecorator.SetDrawable(ContextCompat.GetDrawable(this, Resource.Drawable.RecyclerViewWhiteDivider)); var navMenu = (NavigationMenuView)navigationView.GetChildAt(0); navMenu.AddItemDecoration(itemDecorator); var me = RealmUserServices.GetMe(true); var headerView = navigationView.GetHeaderView(0); var innititalsTextView = headerView.FindViewById <TextView>(Resource.Id.InnititalsTextView); innititalsTextView.Text = (me.FirstName?.FirstOrDefault() + " " + me.LastName?.FirstOrDefault()).Trim(); var nameTextView = headerView.FindViewById <TextView>(Resource.Id.NameTextView); nameTextView.Text = me.Name; var handelTextView = headerView.FindViewById <TextView>(Resource.Id.HandelTextView); handelTextView.Text = me.Handle; UpdateToolbar(); mAdView = FindViewById <AdView>(Resource.Id.adView); if (ShowsAds) { var iPersistant = ServiceLocator.Instance.Resolve <IPersistantStorage>(); var facebookToken = iPersistant.GetFacebookToken(); var facebookCallback = new FacebookCallback(); facebookCallback.OnCompletedAction += (GraphResponse obj) => { if (obj == null || obj.RawResponse == null) { return; } var token = JToken.Parse(obj.RawResponse.ToString()); if (token == null) { return; } var dict = new Dictionary <string, string>(); if (token[AdKeyGender] != null) { dict.Add(AdKeyGender, token[AdKeyGender].ToString()); } if (token[AdKeyBirthday] != null) { dict.Add(AdKeyBirthday, token[AdKeyBirthday].ToString()); } ShowBanner(dict); }; var request = GraphRequest.NewMeRequest(AccessToken.CurrentAccessToken, facebookCallback); var parameters = new Bundle(); parameters.PutString("fields", "gender,birthday"); request.Parameters = parameters; request.ExecuteAsync(); } }
public override void OnActivityResult(int requestCode, int resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); if (resultCode == (int)Android.App.Result.Ok) { if (data == null) { return; } using (var bitmap = MediaStore.Images.Media.GetBitmap(Activity.ContentResolver, data.Data)) { var bytes = ImageUtils.ImagetoByteArray(bitmap, 100); if (bytes == null) { return; } var cell = RecyclerView.FindViewHolderForAdapterPosition(0) as CardCell; if (cell == null) { return; } var me = RealmUserServices.GetMe(false); if (requestCode == SelectUserImagePhotoRequestCode) { var imageView = cell.GetUserImageView(); imageView.SetImageResource(Resource.Drawable.ic_noprofilewhite); imageView.ShowLoadingIndicators(); var localUrl = Shared.SelectedCard.LocalHeaderURL; var remoteUrl = Shared.SelectedCard.RemoteHeaderURL; var fileName = "Header.png"; 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(Shared.SelectedCard.GetRemoteHeaderUrlCached(), Resource.Drawable.ic_noprofilewhite, Resource.Drawable.ic_noprofilewhite, Shared.SelectedCard.RemoteHeaderURL, WebImageView.DefaultCircleTransformation); }); }, null); return; } if (requestCode == SelectCompanyLogoPhotoRequestCode) { var imageView = cell.GetCompanyLogoImageView(); imageView.SetImageResource(Resource.Drawable.ic_buildings); imageView.ShowLoadingIndicators(); var localUrl = Shared.SelectedCard.LocalLogoURL; var remoteUrl = Shared.SelectedCard.RemoteLogoURL; var fileName = "Logo.png"; 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(Shared.SelectedCard.GetRemoteLogoUrlCached(), Resource.Drawable.ic_buildings, Resource.Drawable.ic_buildings, Shared.SelectedCard.RemoteLogoURL, WebImageView.DefaultCircleTransformation); }); }, null); return; } }; } }
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); }
if (cardBack != null) cardBack.BindDataToView(SelectedCard, Editable); PerformFlipAnimationIfNecessary(); } public void PerformFlipAnimationIfNecessary() { var cardFront = ContainerView.Subviews.Where(c => c.GetType() == typeof(CardFront)).First(); var cardBack = ContainerView.Subviews.Where(c => c.GetType() == typeof(CardBack)).First(); //animation not needed if (cardFront.Hidden == SelectedCard.IsFlipped) return; UIView.Transition(View, 0.5, UIViewAnimationOptions.TransitionFlipFromRight, () => { cardFront.Hidden = SelectedCard.IsFlipped; cardBack.Hidden = !SelectedCard.IsFlipped; }, null); } public void Flip() { if (SelectedCard == null) return; SelectedCard.Flip(); var cardFront = ContainerView.Subviews.Where(c => c.GetType() == typeof(CardFront)).First(); var cardBack = ContainerView.Subviews.Where(c => c.GetType() == typeof(CardBack)).First(); UIView.Transition(View, 0.5, UIViewAnimationOptions.TransitionFlipFromRight, () => { cardFront.Hidden = SelectedCard.IsFlipped; cardBack.Hidden = !SelectedCard.IsFlipped; }, null); } void DownloadFacebookImage(ICardView target, string localUrl, string remoteUrl, string fileName, string cacheKey) { if (target == null) return; var me = RealmUserServices.GetMe(false); if (me == null) return; var url = me.GetFacebookProfilePictureUrl(); if (url == null) return; target.ToggleLoadingIndicators(true); SDWebImageManager.SharedManager.ImageDownloader.DownloadImage(NSUrl.FromString(url), SDWebImageDownloaderOptions.HighPriority, null, (image, data, error, finished) => { if (image == null || error != null) { target.ToggleLoadingIndicators(false); return; } var bytes = ImageUtils.ByteArrayFromImage(image, 100); S3Utils.UploadPhoto(bytes, localUrl,remoteUrl, fileName, () => { SDWebImageManager.SharedManager.ImageCache.RemoveImage(cacheKey, true, null); Update(true); }, null); }); }