public void OnComplete(Android.Gms.Tasks.Task task) { if (task.IsComplete) { storageReference.GetDownloadUrl().AddOnCompleteListener(downloadListener); } }
public void OnSuccess(Java.Lang.Object result) { Snackbar.Make(rootView, "User Registration was Successful", Snackbar.LengthShort).Show(); if (storageReference != null) { // Toast.MakeText(this, "Successful Upload Iamge", ToastLength.Short).Show(); storageReference.GetDownloadUrl() .AddOnSuccessListener(this); } if (!string.IsNullOrEmpty(result.ToString())) { ImgURL = result.ToString(); // Toast.MakeText(this, ImgURL, ToastLength.Short).Show(); } if (ImgURL.Contains("https")) { HashMap userMap = new HashMap(); userMap.Put("fullname", fullname); userMap.Put("email", email); userMap.Put("phone", phone); userMap.Put("ImgURL", ImgURL); DatabaseReference userReference = database.GetReference("users/" + mAuth.CurrentUser.Uid); userReference.SetValue(userMap); SaveToSharedPreference(); StartActivity(typeof(MainActivity)); Finish(); } }
public async Task <string> GetFileUrl(string filename) { var result = ""; int timeWait = 250; int countWait = 0; int maxCountWait = 20; try { var storage = Storage.DefaultInstance; StorageReference spaceNode = storage.GetReferenceFromUrl($"{_storage}/images/{filename}"); // Fetch the download Url spaceNode.GetDownloadUrl((url, error) => { if (error != null) { // Handle any errors } else { // Get the download URL for 'images/stars.jpg' result = url.ToString(); } }); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("---> Error UploadFiles " + ex.Message); countWait = maxCountWait; } do { countWait++; await System.Threading.Tasks.Task.Delay(timeWait); }while (result == "" || countWait < maxCountWait); System.Diagnostics.Debug.WriteLine("---> result = " + result); return(result); }
void ConnectViews() { Fnametext = (TextInputLayout)FindViewById(Resource.Id.fullnametext); emtext = (TextInputLayout)FindViewById(Resource.Id.emailtext); passtext = (TextInputLayout)FindViewById(Resource.Id.passwordtext); submit = (Button)FindViewById(Resource.Id.submit_btn); login = (Button)FindViewById(Resource.Id.login_btn); googlelogin = (Button)FindViewById(Resource.Id.googlelogin_btn); profimg = (ImageView)FindViewById(Resource.Id.profileiv); gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DefaultSignIn) .RequestIdToken("228992356302-n0p15tka3tqvhps5e7ra7scrs6fqg0p0.apps.googleusercontent.com") .RequestEmail().Build(); googleapiclient = new GoogleApiClient.Builder(this).AddApi(Auth.GOOGLE_SIGN_IN_API, gso).Build(); googleapiclient.Connect(); submit.Click += (sender, e) => { if (imageArray == null) { imageArray = System.IO.File.ReadAllBytes("Resources/Images/DefaultUser.png"); } storageReference = FirebaseStorage.Instance.GetReference($"users/{Fnametext.EditText.Text}_image"); storageReference.PutBytes(imageArray); storageReference.GetDownloadUrl().AddOnSuccessListener(this); HashMap map = new HashMap(); map.Put("fullname", Fnametext.EditText.Text); map.Put("email", emtext.EditText.Text); map.Put("password", passtext.EditText.Text); map.Put("profileimage", url); DocumentReference docRef = database.Collection("users").Document(); docRef.Set(map); Toast.MakeText(this, "User Registered", ToastLength.Long).Show(); FetchUserData(); }; login.Click += (sender, e) => { string loginfname = Fnametext.EditText.Text.ToString(); string loginemail = emtext.EditText.Text.ToString(); string loginpass = passtext.EditText.Text.ToString(); //listOfUser=userservice.FetchUserData("user"); //while (listOfUser.Count == 0) //{ //} foreach (var item in listOfUser) { Console.WriteLine("Fullname: " + item.Fullname); } foreach (var item in listOfUser) { if (item.Fullname.Equals(loginfname) && item.Email.Equals(loginemail) && item.password.Equals(loginpass)) { Intent secondpageintent = new Intent(this, typeof(SecondPageActivity)); secondpageintent.PutExtra("accepteduser", JsonConvert.SerializeObject(item)); StartActivity(secondpageintent); return; } } Toast.MakeText(this, "Invalid Credentials", ToastLength.Long).Show(); return; }; profimg.Click += (sender, e) => { RequestPermissions(permissionGroup, 0); var trans = SupportFragmentManager.BeginTransaction(); uploadimg = new UploadImageFragment(); uploadimg.Show(trans, "profilepicmethod"); uploadimg.uploadImage += (Bitmap bitmap, byte[] imgary) => { profimg.SetImageBitmap(bitmap); imageArray = imgary; uploadimg.Dismiss(); }; }; googlelogin.Click += (sender, e) => { var intent = Auth.GoogleSignInApi.GetSignInIntent(googleapiclient); StartActivityForResult(intent, 1); }; }
void GetProductImage(string url) { StorageReference ppref = FirebaseStorage.Instance.GetReference($"products/{url}"); ppref.GetDownloadUrl().AddOnSuccessListener(this); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Use this to return your custom view for this Fragment // return inflater.Inflate(Resource.Layout.YourFragment, container, false); var view = inflater.Inflate(Resource.Layout.SecondPageActivity, container, false); secfname = (TextView)view.FindViewById(Resource.Id.secondpagefname); secemail = (TextView)view.FindViewById(Resource.Id.secondpageemail); secpass = (TextView)view.FindViewById(Resource.Id.secondpagepassword); secid = (TextView)view.FindViewById(Resource.Id.secondid); searchbtn = (Button)view.FindViewById(Resource.Id.searcharea); openmenubtn = (Button)view.FindViewById(Resource.Id.openmenubar); secprofimg = (ImageView)view.FindViewById(Resource.Id.secondprofimg); recyclerView = (RecyclerView)view.FindViewById(Resource.Id.secondpagerecycler); searchbtn.Click += (sender, e) => { Intent searchpage = new Intent(Activity, typeof(SearchActivity)); //productpage.PutExtra("productdetail", JsonConvert.SerializeObject(selectedproduct)); StartActivity(searchpage); }; openmenubtn.Click += (sender, e) => { Intent menupage = new Intent(Activity, typeof(LandingPageActivity)); //productpage.PutExtra("productdetail", JsonConvert.SerializeObject(selectedproduct)); StartActivity(menupage); }; database = databaseservices.GetDataBase(); secfname.Text = loggedinuser.Fullname; secemail.Text = loggedinuser.Email; secpass.Text = loggedinuser.password; secid.Text = loggedinuser.ID; StorageReference ppref = FirebaseStorage.Instance.GetReference($"users/{loggedinuser.Fullname}_image"); //StorageReference pathref = ppref.Child($"users/{loggedinuser.Fullname}_image"); //StorageReference islandRef = storageRef.child("images/island.jpg"); //final long ONE_MEGABYTE = 1024 * 1024; // ppref.GetDownloadUrl().AddOnSuccessListener(Activity, this); //imgurl = imgurl.ToString(); Console.WriteLine("imgurl = " + imgurl); FetchandListen(); SetuprecyclerView(); return(view); }
//string imgurl; protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.SecondPageActivity); secfname = (TextView)FindViewById(Resource.Id.secondpagefname); secemail = (TextView)FindViewById(Resource.Id.secondpageemail); secpass = (TextView)FindViewById(Resource.Id.secondpagepassword); secid = (TextView)FindViewById(Resource.Id.secondid); searchbtn = (Button)FindViewById(Resource.Id.searcharea); openmenubtn = (Button)FindViewById(Resource.Id.openmenubar); secprofimg = (ImageView)FindViewById(Resource.Id.secondprofimg); recyclerView = (RecyclerView)FindViewById(Resource.Id.secondpagerecycler); loggedinuser = JsonConvert.DeserializeObject <User>(Intent.GetStringExtra("accepteduser")); searchbtn.Click += (sender, e) => { Intent searchpage = new Intent(this, typeof(SearchActivity)); //productpage.PutExtra("productdetail", JsonConvert.SerializeObject(selectedproduct)); StartActivity(searchpage); }; openmenubtn.Click += (sender, e) => { Intent menupage = new Intent(this, typeof(LandingPageActivity)); menupage.PutExtra("accepteduser", JsonConvert.SerializeObject(loggedinuser)); StartActivity(menupage); }; database = databaseservices.GetDataBase(); secfname.Text = loggedinuser.Fullname; secemail.Text = loggedinuser.Email; secpass.Text = loggedinuser.password; secid.Text = loggedinuser.ID; StorageReference ppref = FirebaseStorage.Instance.GetReference($"users/{loggedinuser.Fullname}_image"); //StorageReference pathref = ppref.Child($"users/{loggedinuser.Fullname}_image"); //StorageReference islandRef = storageRef.child("images/island.jpg"); //final long ONE_MEGABYTE = 1024 * 1024; // ppref.GetDownloadUrl().AddOnSuccessListener(this, this); //imgurl = imgurl.ToString(); //Console.WriteLine("imgurl = " + imgurl); //Console.WriteLine("imgurl = " + imgurl); FetchandListen(); SetuprecyclerView(); // Create your application here }