Cleanup
This commit is contained in:
parent
bcc1a1368e
commit
ffa013c7b0
@ -18,8 +18,6 @@ class LogIn : AppCompatActivity() {
|
|||||||
val view = binding.root
|
val view = binding.root
|
||||||
setContentView(view)
|
setContentView(view)
|
||||||
|
|
||||||
// supportActionBar?.hide()
|
|
||||||
|
|
||||||
mAuth = FirebaseAuth.getInstance()
|
mAuth = FirebaseAuth.getInstance()
|
||||||
|
|
||||||
binding.logInBtn.setOnClickListener{
|
binding.logInBtn.setOnClickListener{
|
||||||
|
@ -33,7 +33,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
userList = ArrayList()
|
userList = ArrayList()
|
||||||
adapter = UserAdapter()
|
adapter = UserAdapter()
|
||||||
// adapter.submitList(userList)
|
|
||||||
|
|
||||||
binding.userRecyclerView.layoutManager = LinearLayoutManager(this)
|
binding.userRecyclerView.layoutManager = LinearLayoutManager(this)
|
||||||
binding.userRecyclerView.adapter = adapter
|
binding.userRecyclerView.adapter = adapter
|
||||||
@ -49,10 +48,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
override fun onDataChange(snapshot: DataSnapshot) {
|
override fun onDataChange(snapshot: DataSnapshot) {
|
||||||
|
|
||||||
userList.clear()
|
userList.clear()
|
||||||
// for(postSnapshot in snapshot.children){
|
|
||||||
// val currentUser = postSnapshot.getValue(User::class.java)
|
|
||||||
// userList.add(currentUser!!)
|
|
||||||
// }
|
|
||||||
snapshot.children.forEach {
|
snapshot.children.forEach {
|
||||||
val currentUser = it.getValue(User::class.java)
|
val currentUser = it.getValue(User::class.java)
|
||||||
userList.add(currentUser!!)
|
userList.add(currentUser!!)
|
||||||
@ -60,7 +55,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
userList.removeAll(
|
userList.removeAll(
|
||||||
userList.filter{it.uid == mAuth.currentUser?.uid}.toSet()
|
userList.filter{it.uid == mAuth.currentUser?.uid}.toSet()
|
||||||
)
|
)
|
||||||
// userList.removeIf{it.uid == mAuth.currentUser?.uid}
|
|
||||||
adapter.submitList(userList)
|
adapter.submitList(userList)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ import com.lsm.chatapplication.databinding.ActivitySignUpBinding
|
|||||||
class SignUp : AppCompatActivity() {
|
class SignUp : AppCompatActivity() {
|
||||||
private lateinit var binding: ActivitySignUpBinding
|
private lateinit var binding: ActivitySignUpBinding
|
||||||
private lateinit var mAuth: FirebaseAuth
|
private lateinit var mAuth: FirebaseAuth
|
||||||
// private lateinit var mDbRef: DatabaseReference
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
@ -22,10 +21,8 @@ class SignUp : AppCompatActivity() {
|
|||||||
val view = binding.root
|
val view = binding.root
|
||||||
setContentView(view)
|
setContentView(view)
|
||||||
|
|
||||||
// supportActionBar?.hide()
|
|
||||||
|
|
||||||
mAuth = FirebaseAuth.getInstance()
|
mAuth = FirebaseAuth.getInstance()
|
||||||
// mDbRef = Firebase.database("https://chatapplication-4eb49-default-rtdb.europe-west1.firebasedatabase.app/").reference
|
|
||||||
|
|
||||||
binding.signUpBtn.setOnClickListener{
|
binding.signUpBtn.setOnClickListener{
|
||||||
val usrName = binding.edtUserName.text.toString()
|
val usrName = binding.edtUserName.text.toString()
|
||||||
@ -42,15 +39,12 @@ class SignUp : AppCompatActivity() {
|
|||||||
mAuth.createUserWithEmailAndPassword(email, password)
|
mAuth.createUserWithEmailAndPassword(email, password)
|
||||||
.addOnCompleteListener(this) { task ->
|
.addOnCompleteListener(this) { task ->
|
||||||
if (task.isSuccessful) {
|
if (task.isSuccessful) {
|
||||||
// Jumping to home
|
|
||||||
addUserToDatabase(name, email, mAuth.currentUser?.uid!!)
|
addUserToDatabase(name, email, mAuth.currentUser?.uid!!)
|
||||||
val intent = Intent(this@SignUp,MainActivity::class.java)
|
val intent = Intent(this@SignUp,MainActivity::class.java)
|
||||||
finish()
|
finish()
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
} else {
|
} else {
|
||||||
// Account creation error message
|
|
||||||
Toast.makeText(this@SignUp,task.exception?.toString(),Toast.LENGTH_LONG).show()
|
Toast.makeText(this@SignUp,task.exception?.toString(),Toast.LENGTH_LONG).show()
|
||||||
//Toast.makeText(this@SignUp,"Some error occurred",Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,25 +10,6 @@ import androidx.recyclerview.widget.RecyclerView
|
|||||||
import com.google.firebase.auth.FirebaseAuth
|
import com.google.firebase.auth.FirebaseAuth
|
||||||
import com.lsm.chatapplication.databinding.UserLayoutBinding
|
import com.lsm.chatapplication.databinding.UserLayoutBinding
|
||||||
|
|
||||||
//class UserAdapter(val userList: ArrayList<User>):
|
|
||||||
// RecyclerView.Adapter<UserAdapter.UserViewHolder>() {
|
|
||||||
//
|
|
||||||
// class UserViewHolder(val binding: UserLayoutBinding): RecyclerView.ViewHolder(binding.root)
|
|
||||||
//
|
|
||||||
// override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): UserViewHolder {
|
|
||||||
// return UserViewHolder(UserLayoutBinding.inflate(LayoutInflater.from(parent.context), parent, false))
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun onBindViewHolder(holder: UserViewHolder, position: Int) {
|
|
||||||
// val currentUser = userList[position]
|
|
||||||
// holder.binding.userName.text = currentUser.name
|
|
||||||
// holder.binding.itemView
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun getItemCount(): Int {
|
|
||||||
// return userList.size
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
class UserAdapter():
|
class UserAdapter():
|
||||||
ListAdapter<User,UserAdapter.UserViewHolder>(TaskDiffCallBack()){
|
ListAdapter<User,UserAdapter.UserViewHolder>(TaskDiffCallBack()){
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user