-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
671 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
UMC_6th/app/src/main/java/com/example/umc_6th/LoginActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.example.umc_6th | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.example.umc_6th.databinding.ActivityLoginBinding | ||
|
||
class LoginActivity:AppCompatActivity() { | ||
|
||
lateinit var binding : ActivityLoginBinding | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding = ActivityLoginBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
|
||
binding.loginSignUpTv.setOnClickListener { | ||
startActivity(Intent(this, SignUpActivity::class.java)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
UMC_6th/app/src/main/java/com/example/umc_6th/SignUpActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.example.umc_6th | ||
|
||
import android.os.Bundle | ||
import android.util.Log | ||
import android.widget.Toast | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.example.umc_6th.databinding.ActivitySignupBinding | ||
|
||
class SignUpActivity : AppCompatActivity(){ | ||
|
||
lateinit var binding : ActivitySignupBinding | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding = ActivitySignupBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
|
||
binding.signUpSignUpBtn.setOnClickListener{ | ||
signUp() | ||
} | ||
} | ||
|
||
private fun getUser() : User{ | ||
val email : String = binding.signUpIdEt.text.toString() + "@" + binding.signUpDirectInputEt.text.toString() | ||
val pwd : String = binding.signUpPasswordEt.text.toString() | ||
|
||
return User(email, pwd) | ||
} | ||
|
||
private fun signUp() { | ||
if (binding.signUpIdEt.text.toString().isEmpty() || binding.signUpDirectInputEt.text.toString().isEmpty()){ | ||
Toast.makeText(this,"이메일 형식이 잘못되었습니다.",Toast.LENGTH_SHORT).show() | ||
return | ||
} | ||
if (binding.signUpPasswordEt.text.toString() != binding.signUpPasswordCheckEt.text.toString()){ | ||
Toast.makeText(this,"비밀번호가 일치하지 않습니다",Toast.LENGTH_SHORT).show() | ||
return | ||
} | ||
|
||
val userDB = SongDatabase.getInstance(this)!! | ||
userDB.userDao().insert(getUser()) | ||
|
||
val user = userDB.userDao().getUsers() | ||
Log.d("Sign-up",user.toString()) | ||
|
||
Toast.makeText(this,"회원가입이 완료되었습니다.",Toast.LENGTH_SHORT).show() | ||
return | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.example.umc_6th | ||
|
||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
|
||
@Entity(tableName = "UserTable") | ||
data class User( | ||
var email : String, | ||
var password : String | ||
){ | ||
@PrimaryKey(autoGenerate = true) var id : Int = 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.example.umc_6th | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Insert | ||
import androidx.room.Query | ||
|
||
@Dao | ||
interface UserDao { | ||
@Insert | ||
fun insert(user : User) | ||
|
||
@Query("SELECT * FROM UserTable") | ||
fun getUsers() : List<User> | ||
|
||
@Query("SELECT * FROM usertable WHERE email = :email AND password = :password") | ||
fun getUser(email : String ,password : String) : User? | ||
} |
Oops, something went wrong.