Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced room database with firebase of user #78

Merged
merged 4 commits into from
Dec 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
package org.openlake.sampoorna.data.constants

object Constants {
/**
* Firebase collections
*/
const val Users = "users"
const val Blogs = "blogs"

/**
* Shared preference constants
*/
const val Sampoorna = "sampoorna"
const val SOSMessage = "sosmessage"
const val Name = "name"
const val Username = "username"
const val Age = "age"
const val Email = "email"
const val About = "about"

}
35 changes: 0 additions & 35 deletions app/src/main/java/org/openlake/sampoorna/data/dao/UserDao.kt

This file was deleted.

28 changes: 2 additions & 26 deletions app/src/main/java/org/openlake/sampoorna/data/di/Transformer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ package org.openlake.sampoorna.data.di

import org.openlake.sampoorna.data.sources.entities.Contact
import org.openlake.sampoorna.data.sources.entities.ContactEntity
import org.openlake.sampoorna.data.sources.entities.User
import org.openlake.sampoorna.data.sources.entities.UserEntity

/*
/**
* This is a transformer class
* We cannot just use our model classes for inserting or getting data from db
* There might be a time when variables might be added or removed in model classes
* So it is always a better practice to have transformer classes
* */
*/
object Transformer {

fun convertContactModelToContactEntity(contact: Contact): ContactEntity {
Expand All @@ -28,26 +26,4 @@ object Transformer {
id = contactEntity.id
)
}

fun convertUserModelToUserEntity(user: User):UserEntity{
return UserEntity(
name = user.name,
address = null,
id = 0,
bloodGroup = null,
sosMessage = user.sosMessage,
age = null,
email = user.email
)
}

fun convertUserEntityToUserModel(userEntity: UserEntity):User{
return User(
name = userEntity.name ?: "",
sosMessage = userEntity.sosMessage ?: "",
email = userEntity.email ?: "",
uid = "",
username = ""
)
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import kotlinx.parcelize.Parcelize
@Parcelize
data class User(
val uid: String = "",
val name: String = "",
var name: String = "",
var username: String = "",
var email: String = "",
var photoUrl: String? = null,
var sosMessage: String = ""
var about: String = "",
var age: Int? = null
):Parcelable

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.ViewModelProvider
import com.google.android.material.tabs.TabLayoutMediator
import com.google.firebase.auth.FirebaseAuth
import dagger.hilt.android.AndroidEntryPoint
import org.openlake.sampoorna.R
import org.openlake.sampoorna.data.sources.entities.User
import org.openlake.sampoorna.databinding.ActivityOnboardingBinding
import org.openlake.sampoorna.presentation.MainActivity
import org.openlake.sampoorna.presentation.features.userFeatures.UserViewModel
Expand All @@ -22,12 +20,10 @@ class OnboardingActivity : AppCompatActivity() {
var onboardingViewPagerAdapter: OnboardingViewPagerAdapter? = null
private lateinit var userViewModel: UserViewModel
private lateinit var authViewModel: AuthViewModel
private lateinit var sharedPreferences: SharedPreferences

private val auth: FirebaseAuth = FirebaseAuth.getInstance()

override fun onCreate(savedInstanceState: Bundle?) {
//instantiating Shared Preferences
sharedPreferences = this.getSharedPreferences("login", Context.MODE_PRIVATE)

// As in the manifest, we have changed application theme to SplashTheme.
// Hence, we need to switch back to our main theme.
Expand All @@ -47,14 +43,11 @@ class OnboardingActivity : AppCompatActivity() {
//instantiating UserViewModel in which we will enter User
userViewModel = ViewModelProvider(this)[UserViewModel::class.java]

userViewModel.userDetails.observe(this) {
//viewpager fab button listening..
binding.goNextButton.setOnClickListener {
if(binding.slider.currentItem==3)
return@setOnClickListener
binding.goNextButton.setOnClickListener {
if(binding.slider.currentItem==3)
return@setOnClickListener

binding.slider.currentItem += 1
}
binding.slider.currentItem += 1
}

authViewModel = ViewModelProvider(this)[AuthViewModel::class.java]
Expand Down