-
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.
* [simba/#38] feat:: 회원가입, 로그인 구현 * [simba/#38] feat:: 회원가입, 로그인 구현2 * [simba/#38] feat:: 회원가입, 로그인 구현2 * [simba/#38] feat:: 특정 위치로 스크롤하기
- Loading branch information
Showing
22 changed files
with
1,324 additions
and
36 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
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 = "LikeTable") | ||
data class Like( | ||
var userId : Int, | ||
var albumId : Int | ||
){ | ||
@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
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
65 changes: 65 additions & 0 deletions
65
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,65 @@ | ||
package com.example.umc_6th | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.util.Log | ||
import android.widget.Toast | ||
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)) | ||
} | ||
binding.loginSignInBtn.setOnClickListener{ | ||
login() | ||
} | ||
} | ||
|
||
private fun login() { | ||
if (binding.loginIdEt.text.toString().isEmpty() || binding.loginDirectInputEt.text.toString().isEmpty()) { | ||
Toast.makeText(this, "이메일을 입력해주세요", Toast.LENGTH_SHORT).show() | ||
return | ||
} | ||
|
||
if (binding.loginPasswordEt.text.toString().isEmpty()) { | ||
Toast.makeText(this, "비밀번호를 입력해주세요", Toast.LENGTH_SHORT).show() | ||
return | ||
} | ||
|
||
val email : String = binding.loginIdEt.text.toString() + "@" + binding.loginDirectInputEt.text.toString() | ||
val pwd : String = binding.loginPasswordEt.text.toString() | ||
|
||
val songDB = SongDatabase.getInstance(this)!! | ||
val user = songDB.userDao().getUser(email, pwd) | ||
|
||
if (user != null) { | ||
Log.d("LoginActivity", user.id.toString()) | ||
saveJwt(user.id) | ||
startMainActivity() | ||
} else { | ||
Toast.makeText(this, "회원 정보가 존재하지 않습니다", Toast.LENGTH_SHORT).show() | ||
} | ||
} | ||
|
||
private fun startMainActivity() { | ||
val intent = Intent(this, MainActivity::class.java) | ||
startActivity(intent) | ||
} | ||
private fun saveJwt(jwt: Int) { | ||
val spf = getSharedPreferences("auth", MODE_PRIVATE) | ||
val editor = spf.edit() | ||
|
||
editor.putInt("jwt", jwt) | ||
editor.apply() | ||
} | ||
|
||
} |
Oops, something went wrong.