generated from IN-SOPT-ANDROID/in-sopt-android-template
-
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
14 changed files
with
377 additions
and
226 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.sopt.sample.entity | ||
|
||
import java.io.Serializable | ||
|
||
data class User( | ||
val id: String, | ||
val pwd: String, | ||
val mbti: String | ||
) : Serializable |
8 changes: 2 additions & 6 deletions
8
app/src/main/java/org/sopt/sample/presentation/home/HomeActivity.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
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
33 changes: 33 additions & 0 deletions
33
app/src/main/java/org/sopt/sample/presentation/login/SignInViewModel.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,33 @@ | ||
package org.sopt.sample.presentation.login | ||
|
||
import androidx.lifecycle.LiveData | ||
import androidx.lifecycle.MutableLiveData | ||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.viewModelScope | ||
import kotlinx.coroutines.launch | ||
import org.sopt.sample.entity.User | ||
|
||
class SignInViewModel : ViewModel() { | ||
private val _userInfo = MutableLiveData<User>() | ||
val userInfo: LiveData<User> = _userInfo | ||
|
||
private val _id = MutableLiveData<String>() | ||
val id: LiveData<String> = _id | ||
|
||
private val _pwd = MutableLiveData<String>() | ||
val pwd: LiveData<String> = _pwd | ||
|
||
private val _successLogin = MutableLiveData(false) | ||
val successLogin: LiveData<Boolean> = _successLogin | ||
|
||
fun loginOnClick() { | ||
viewModelScope.launch { | ||
_successLogin.value = | ||
id.value == userInfo.value?.id && pwd.value == userInfo.value?.pwd | ||
} | ||
} | ||
|
||
fun setUserInfo(user: User) { | ||
_userInfo.value = user | ||
} | ||
} |
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
26 changes: 26 additions & 0 deletions
26
app/src/main/java/org/sopt/sample/presentation/login/SignUpViewModel.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,26 @@ | ||
package org.sopt.sample.presentation.login | ||
|
||
import androidx.lifecycle.LiveData | ||
import androidx.lifecycle.MutableLiveData | ||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.viewModelScope | ||
import kotlinx.coroutines.launch | ||
|
||
class SignUpViewModel : ViewModel() { | ||
private val _id = MutableLiveData<String>() | ||
val id: LiveData<String> = _id | ||
|
||
private val _pwd = MutableLiveData<String>() | ||
val pwd: LiveData<String> = _pwd | ||
|
||
private val _mbti = MutableLiveData<String>() | ||
val mbti: LiveData<String> = _mbti | ||
|
||
private val _successSignUp = MutableLiveData<Boolean>() | ||
|
||
fun signUpOnClick() { | ||
viewModelScope.launch { | ||
//if (id.value?.length in 6..10) | ||
} | ||
} | ||
} |
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,8 @@ | ||
package org.sopt.sample.util | ||
|
||
import android.content.Context | ||
import android.widget.Toast | ||
|
||
fun Context.showToast(msg: String) { | ||
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show() | ||
} |
19 changes: 19 additions & 0 deletions
19
app/src/main/java/org/sopt/sample/util/binding/BaseActivity.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,19 @@ | ||
package org.sopt.sample.util.binding | ||
|
||
import android.os.Bundle | ||
import androidx.annotation.LayoutRes | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.databinding.DataBindingUtil | ||
import androidx.databinding.ViewDataBinding | ||
|
||
abstract class BaseActivity<T : ViewDataBinding>( | ||
@LayoutRes private val layoutRes: Int | ||
) : AppCompatActivity() { | ||
protected lateinit var binding: T | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding = DataBindingUtil.setContentView(this, layoutRes) | ||
binding.lifecycleOwner = this | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
app/src/main/java/org/sopt/sample/util/binding/BaseFragment.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,33 @@ | ||
package org.sopt.sample.util.binding | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.annotation.LayoutRes | ||
import androidx.databinding.DataBindingUtil | ||
import androidx.databinding.ViewDataBinding | ||
import androidx.fragment.app.Fragment | ||
import org.sopt.sample.R | ||
|
||
abstract class BaseFragment<T : ViewDataBinding>( | ||
@LayoutRes private val layoutRes: Int | ||
) : Fragment() { | ||
private var _binding: T? = null | ||
val binding get() = _binding ?: error(getString(R.string.binding_error)) | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
_binding = DataBindingUtil.inflate(inflater, layoutRes, container, false) | ||
binding.lifecycleOwner = viewLifecycleOwner | ||
return binding.root | ||
} | ||
|
||
override fun onDestroyView() { | ||
super.onDestroyView() | ||
_binding = null | ||
} | ||
} |
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 |
---|---|---|
@@ -1,40 +1,47 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
<layout 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=".presentation.home.HomeActivity"> | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<ImageView | ||
android:id="@+id/iv_home_profile" | ||
android:layout_width="100dp" | ||
android:layout_height="0dp" | ||
android:layout_marginTop="50dp" | ||
android:src="@drawable/img_profile" | ||
app:layout_constraintDimensionRatio="1:1" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
<data> | ||
|
||
<TextView | ||
android:id="@+id/tv_home_name" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="12dp" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/iv_home_profile" | ||
tools:text="이름 : 이영주" /> | ||
</data> | ||
|
||
<TextView | ||
android:id="@+id/tv_home_mbti" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="12dp" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/tv_home_name" | ||
tools:text="MBTI : ISFP" /> | ||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".presentation.home.HomeActivity"> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
<ImageView | ||
android:id="@+id/iv_home_profile" | ||
android:layout_width="100dp" | ||
android:layout_height="0dp" | ||
android:layout_marginTop="50dp" | ||
android:src="@drawable/img_profile" | ||
app:layout_constraintDimensionRatio="1:1" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<TextView | ||
android:id="@+id/tv_home_name" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="12dp" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/iv_home_profile" | ||
tools:text="이름 : 이영주" /> | ||
|
||
<TextView | ||
android:id="@+id/tv_home_mbti" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="12dp" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/tv_home_name" | ||
tools:text="MBTI : ISFP" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</layout> |
Oops, something went wrong.