-
Notifications
You must be signed in to change notification settings - Fork 3
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
정렬 기능 추가 #59
Open
JeongeunChoi
wants to merge
3
commits into
GDSC-PKNU-Official:CJE
Choose a base branch
from
JeongeunChoi:feature/#51
base: CJE
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
정렬 기능 추가 #59
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -10,46 +10,60 @@ import com.gdsc.todo.model.entity.MyToDoList | |
class ToDoViewModel(application: Application) : AndroidViewModel(application) { | ||
|
||
private var _myToDoSet = ArrayList<MyToDoList>() | ||
private var _sortMyToDoSet = ArrayList<MyToDoList>() | ||
|
||
val myToDoSet: List<MyToDoList> | ||
get() = _myToDoSet | ||
val sortMyToDoSet: List<MyToDoList> | ||
get() = _sortMyToDoSet | ||
var title = "" | ||
var content = "" | ||
var date = "" | ||
|
||
private val repository: ToDoRepository by lazy{ | ||
private val repository: ToDoRepository by lazy { | ||
ToDoRepository(application) | ||
} | ||
|
||
init { | ||
Log.d(TAG, "init") | ||
getAll() | ||
// _sortMyToDoSet = _myToDoSet 얕은 복사(기존 객체에 영향 O) | ||
_sortMyToDoSet.addAll(_myToDoSet) // 깊은 복사(기존 객체에 영향 X) | ||
Comment on lines
+30
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 삽질하기 좋은 개념인데 잘 이해가 되셨길ㅎㅎ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cloneable |
||
} | ||
|
||
fun getAll(){ | ||
Thread{ | ||
fun getAll() { | ||
Thread { | ||
_myToDoSet = repository.getAllToDo() as ArrayList<MyToDoList> | ||
}.start() | ||
Thread.sleep(TIME) | ||
} | ||
|
||
fun addButtonClick(){ | ||
Thread{ | ||
val newToDo = MyToDoList(title = title.toString(), content = content.toString()) | ||
fun addButtonClick() { | ||
Thread { | ||
val newToDo = MyToDoList(title = title, content = content, date = "~" + date) | ||
repository.insert(newToDo) | ||
}.start() | ||
Thread.sleep(TIME) // 있어야 제목이 저장됨(왜?) | ||
} | ||
|
||
fun deleteToDo(toDo: MyToDoList){ | ||
Thread{ | ||
fun deleteToDo(toDo: MyToDoList) { | ||
Thread { | ||
repository.delete(toDo) | ||
}.start() | ||
} | ||
|
||
fun checkEmpty() = title!="" && content!="" | ||
fun checkEmpty() = title != "" && content != "" | ||
|
||
companion object{ | ||
fun sortTitle() { | ||
_sortMyToDoSet.sortBy { it.title } | ||
} | ||
|
||
fun sortDate() { | ||
_sortMyToDoSet.sortBy { it.date } | ||
} | ||
|
||
companion object { | ||
const val TAG = "ToDoViewModel" | ||
const val TIME: Long = 1000 | ||
const val TIME: Long = 500 | ||
} | ||
} |
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,5 @@ | ||
<vector android:height="24dp" android:tint="#FFFFFF" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M3,18h6v-2L3,16v2zM3,6v2h18L21,6L3,6zM3,13h12v-2L3,11v2z"/> | ||
</vector> |
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,5 @@ | ||
<vector android:height="24dp" android:tint="#FFFFFF" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M9,11L7,11v2h2v-2zM13,11h-2v2h2v-2zM17,11h-2v2h2v-2zM19,4h-1L18,2h-2v2L8,4L8,2L6,2v2L5,4c-1.11,0 -1.99,0.9 -1.99,2L3,20c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2L21,6c0,-1.1 -0.9,-2 -2,-2zM19,20L5,20L5,9h14v11z"/> | ||
</vector> |
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,5 @@ | ||
<vector android:height="24dp" android:tint="#FFFFFF" | ||
android:viewportHeight="24" android:viewportWidth="24" | ||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M21,11h-1.5v-0.5h-2v3h2V13H21v1c0,0.55 -0.45,1 -1,1h-3c-0.55,0 -1,-0.45 -1,-1v-4c0,-0.55 0.45,-1 1,-1h3c0.55,0 1,0.45 1,1V11zM8,10v5H6.5v-1.5h-2V15H3v-5c0,-0.55 0.45,-1 1,-1h3C7.55,9 8,9.45 8,10zM6.5,10.5h-2V12h2V10.5zM13.5,12c0.55,0 1,0.45 1,1v1c0,0.55 -0.45,1 -1,1h-4V9h4c0.55,0 1,0.45 1,1v1C14.5,11.55 14.05,12 13.5,12zM11,10.5v0.75h2V10.5H11zM13,12.75h-2v0.75h2V12.75z"/> | ||
</vector> |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
앱을 재실행하지 못하고 재설치를 해야되는 에러가 생기지는 않았나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
룸 마이그레이션
SQL문을 거쳐서 마이그레이션하는 방식도 있습니다.