Skip to content

Instantly share code, notes, and snippets.

View fatihhcan's full-sized avatar

Fatih Can fatihhcan

View GitHub Profile
@override
void initState() {
// TODO: implement initState
super.initState();
Geolocator.requestPermission();
}
private fun mailGonder(){
var kullanici=FirebaseAuth.getInstance().currentUser
if (kullanici != null){
kullanici.sendEmailVerification()
.addOnCompleteListener(object : OnCompleteListener<Void>{
override fun onComplete(p0: Task<Void>) {
if(p0.isSuccessful){
Toast.makeText(this@RegisterActivity,"Mailinizi kontrol edin, mailinizi onaylayın", Toast.LENGTH_SHORT).show()
}else{
Toast.makeText(this@RegisterActivity,"Mail gönderilirken sorun oluştu "+p0.exception?.message, Toast.LENGTH_SHORT).show()
private fun yeniUyeKayit(mail: String, sifre: String) {
progressBarGoster()
FirebaseAuth.getInstance().createUserWithEmailAndPassword(mail,sifre)
.addOnCompleteListener(object:OnCompleteListener<AuthResult>{
override fun onComplete(p0: Task<AuthResult>) {
if(p0.isSuccessful){
Toast.makeText(this@RegisterActivity,"Üye kaydedildi:"+FirebaseAuth.getInstance().currentUser?.email, Toast.LENGTH_SHORT).show()
mailGonder()
FirebaseAuth.getInstance().signOut()
}else{
btn_Kayit.setOnClickListener {
if(et_Mail.text.isNotEmpty() && et_Sifre.text.isNotEmpty() && et_Sifre_Tekrar.text.isNotEmpty()){
if (et_Sifre.text.toString().equals(et_Sifre_Tekrar.text.toString())){
yeniUyeKayit(et_Mail.text.toString(), et_Sifre.text.toString())
}else{
Toast.makeText(this,"Şifreler aynı değil", Toast.LENGTH_SHORT).show()
}
}else{
Toast.makeText(this,"Boş alanları doldurunuz", Toast.LENGTH_SHORT).show()
}
private fun progressBarGoster(){
progress_Login.visibility = View.VISIBLE
}
private fun progressBarGizle(){
progress_Login.visibility = View.INVISIBLE
}
override fun onStart() {
super.onStart()
FirebaseAuth.getInstance().addAuthStateListener(mAuthStateListener)
}
private fun initAuthStateListener(){
mAuthStateListener=object : FirebaseAuth.AuthStateListener{
override fun onAuthStateChanged(p0: FirebaseAuth) {
var kullanici=p0.currentUser
if (kullanici != null){
if(kullanici.isEmailVerified){
Toast.makeText(this@LoginActivity,"Mail onaylandı giriş yapabilirsiniz", Toast.LENGTH_SHORT).show()
var intent=Intent(this@LoginActivity,MainActivity::class.java)
startActivity(intent)
finish()
btn_Giris.setOnClickListener {
if (et_Mail.text.isNotEmpty() && et_Sifre.text.isNotEmpty()){
progressBarGoster()
// Firebase kütüphanesinden email ve password parametrelerine tanımladığımız edit textleri Stringe çeviriyoruz.
FirebaseAuth.getInstance().signInWithEmailAndPassword(et_Mail.text.toString(),et_Sifre.text.toString())
.addOnCompleteListener(object:OnCompleteListener<AuthResult>{
// Kullanıcı başarılı giriş yaptığında bildirim oluşturuyoruz.
override fun onComplete(p0: Task<AuthResult>) {
if(p0.isSuccessful){
progressBarGizle()
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".RegisterActivity">
<EditText
android:id="@+id/et_Mail"
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".LoginActivity">
<ImageView
android:id="@+id/imageView"