Skip to content

Commit 8be3060

Browse files
authored
init: 업데이트를 위한 작업
2 parents 32908fd + aeebb1c commit 8be3060

18 files changed

Lines changed: 110 additions & 124 deletions

File tree

.idea/gradle.xml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ dependencies {
108108
kapt 'com.github.bumptech.glide:compiler:4.9.0'
109109

110110
// jsoup, anko
111-
implementation "org.jetbrains.anko:anko:$rootProject.anko_version"
112-
implementation 'androidx.gridlayout:gridlayout:1.0.0'
111+
// implementation "org.jetbrains.anko:anko:$rootProject.anko_version"
112+
// implementation 'androidx.gridlayout:gridlayout:1.0.0'
113113

114114
// lombok
115115
compileOnly 'org.projectlombok:lombok:1.18.8'

app/src/androidTest/java/com/seok/gfd/room/dao/SearchGithubIdDaoTest.kt renamed to app/src/androidTest/java/com/seok/gfd/room/dao/GithubIdDaoTest.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import androidx.room.Room
44
import androidx.test.ext.junit.runners.AndroidJUnit4
55
import androidx.test.platform.app.InstrumentationRegistry
66
import com.seok.gfd.room.AppDatabase
7-
import com.seok.gfd.room.entity.SearchGithubId
7+
import com.seok.gfd.room.entity.GithubId
88
import kotlinx.coroutines.runBlocking
99
import org.junit.After
1010
import org.junit.Before
@@ -14,7 +14,7 @@ import org.junit.Test
1414
import org.junit.runner.RunWith
1515

1616
@RunWith(AndroidJUnit4::class)
17-
class SearchGithubIdDaoTest {
17+
class GithubIdDaoTest {
1818
private lateinit var db : AppDatabase
1919

2020
@Before
@@ -30,23 +30,23 @@ class SearchGithubIdDaoTest {
3030

3131
@After
3232
fun closeDb() = runBlocking {
33-
db.searchGithubIdDao().deleteAll()
33+
db.githubIdDao().deleteAll()
3434
db.close()
3535
}
3636

3737
@Test
3838
fun iWantToKnowTheDatabaseIsFind() = runBlocking{
39-
val searchGithubId = SearchGithubId(gidName = "github")
39+
val searchGithubId = GithubId(githubId = "github")
4040

41-
db.searchGithubIdDao().insert(searchGithubId)
42-
var entity = db.searchGithubIdDao().selectAll("g")[0]
41+
db.githubIdDao().insert(searchGithubId)
42+
var entity = db.githubIdDao().selectAll("g")[0]
4343
assertHabitEquals(searchGithubId, entity)
4444

45-
db.searchGithubIdDao().delete(entity)
46-
assertEquals(0, db.searchGithubIdDao().selectAll("g").size)
45+
db.githubIdDao().delete(entity)
46+
assertEquals(0, db.githubIdDao().selectAll("g").size)
4747
}
4848

49-
private fun assertHabitEquals(expected: SearchGithubId, actual: SearchGithubId) {
49+
private fun assertHabitEquals(expected: GithubId, actual: GithubId) {
5050
// id 는 자동생성되므로, 검증을 위해서 id의 동일성은 무시
5151
assertEquals(expected.copy(), actual.copy())
5252
}

app/src/main/java/com/seok/gfd/adapter/ContributionsAdapter.kt

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@ import android.view.View
99
import android.view.ViewGroup
1010
import android.widget.LinearLayout
1111
import android.widget.TextView
12-
import androidx.gridlayout.widget.GridLayout
1312
import androidx.recyclerview.widget.RecyclerView
1413
import com.seok.gfd.R
1514
import com.seok.gfd.utils.Contribution
16-
import org.jetbrains.anko.backgroundColor
17-
import org.jetbrains.anko.margin
1815
import java.time.LocalDate
1916
import java.time.Month
2017

@@ -44,15 +41,15 @@ class ContributionsAdapter(list: ArrayList<Contribution>, context: Context) :
4441
var lineLayout = LinearLayout(this.context)
4542
lineLayout.orientation = LinearLayout.VERTICAL
4643
val params = LinearLayout.LayoutParams(35, 35)
47-
params.margin = 4
44+
// params.margin = 4
4845
params.gravity = Gravity.CENTER
4946
for (index in 0 until size) {
5047
var tempLayout = LinearLayout(this.context)
5148
if (index % 7 == 0) {
5249
val monthDataStr = getDayStartCount(LocalDate.parse(contribution.list!![index].date).month)
5350
lineLayout = LinearLayout(this.context)
5451
lineLayout.orientation = LinearLayout.VERTICAL
55-
tempLayout.backgroundColor = Color.WHITE
52+
// tempLayout.backgroundColor = Color.WHITE
5653
tempLayout.layoutParams = params
5754
if(monthFlag != monthDataStr){
5855
val month = TextView(this.context)
@@ -63,26 +60,26 @@ class ContributionsAdapter(list: ArrayList<Contribution>, context: Context) :
6360
}
6461
lineLayout.addView(tempLayout)
6562
tempLayout = LinearLayout(this.context)
66-
tempLayout.backgroundColor = Color.parseColor(contribution.list!![index].color)
63+
// tempLayout.backgroundColor = Color.parseColor(contribution.list!![index].color)
6764
tempLayout.layoutParams = params
6865
lineLayout.addView(tempLayout)
6966
} else {
70-
tempLayout.backgroundColor = Color.parseColor(contribution.list!![index].color)
67+
// tempLayout.backgroundColor = Color.parseColor(contribution.list!![index].color)
7168
tempLayout.layoutParams = params
7269
lineLayout.addView(tempLayout)
7370
}
7471
if (index % 7 == 0) {
75-
holder.contributionCanvas.addView(lineLayout)
72+
// holder.contributionCanvas.addView(lineLayout)
7673
}
7774
if (index == size) {
78-
holder.contributionCanvas.addView(lineLayout)
75+
// holder.contributionCanvas.addView(lineLayout)
7976
}
8077
}
8178
}
8279

8380
inner class MyViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
8481
var yearContribution: TextView = itemView.findViewById(R.id.guest_year_contribution)
85-
var contributionCanvas: GridLayout = itemView.findViewById(R.id.canvas)
82+
// var contributionCanvas: GridLayout = itemView.findViewById(R.id.canvas)
8683
}
8784

8885
private fun getDayStartCount(dayOfMonth: Month): String = when (dayOfMonth) {

app/src/main/java/com/seok/gfd/adapter/SearchGithubIdAdapter.kt renamed to app/src/main/java/com/seok/gfd/adapter/GithubIdAdapter.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,26 @@ import androidx.fragment.app.FragmentActivity
88
import androidx.lifecycle.ViewModelProviders
99
import androidx.recyclerview.widget.RecyclerView
1010
import com.seok.gfd.R
11-
import com.seok.gfd.room.entity.SearchGithubId
11+
import com.seok.gfd.room.entity.GithubId
1212
import com.seok.gfd.viewmodel.GithubIdViewModel
1313
import kotlinx.android.synthetic.main.item_search_github_id.view.*
1414

15-
class SearchGithubIdAdapter(list: ArrayList<SearchGithubId>, edtText : EditText) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
16-
private val githubIds: ArrayList<SearchGithubId> = list
15+
class GithubIdAdapter(list: ArrayList<GithubId>, edtText : EditText) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
16+
private val githubIds: ArrayList<GithubId> = list
1717
private val searchEditText = edtText
1818
private lateinit var githubIdsViewModel: GithubIdViewModel
1919

2020
inner class SearchGithubIdViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView){
21-
fun bind(searchGithubId: SearchGithubId){
22-
itemView.item_search_txt_github_id.text = searchGithubId.gidName
21+
fun bind(githubId: GithubId){
22+
itemView.item_search_txt_github_id.text = githubId.githubId
2323
itemView.item_search_img_close.setOnClickListener {
24-
githubIdsViewModel.deleteGithubId(searchGithubId)
24+
githubIdsViewModel.deleteGithubId(githubId)
2525
githubIds.removeAt(this.adapterPosition)
2626
notifyItemRemoved(this.adapterPosition)
2727
notifyDataSetChanged()
2828
}
2929
itemView.item_search_card_view.setOnClickListener {
30-
searchEditText.setText(searchGithubId.gidName)
30+
searchEditText.setText(githubId.githubId)
3131
}
3232
}
3333
}

app/src/main/java/com/seok/gfd/retrofit/repository/CommitsRepository.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import android.app.Application
44
import com.seok.gfd.database.Commits
55
import com.seok.gfd.database.CommitsDatabase
66
import com.seok.gfd.database.CommitsDatabaseDao
7-
import org.jetbrains.anko.doAsync
87

98
class CommitsRepository(application: Application) {
109
private val commitsDatabaseDao : CommitsDatabaseDao
@@ -15,6 +14,6 @@ class CommitsRepository(application: Application) {
1514
}
1615

1716
fun insert(commits: Commits){
18-
doAsync { commitsDatabaseDao.insert(commits) }
17+
1918
}
2019
}

app/src/main/java/com/seok/gfd/room/AppDatabase.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import androidx.room.Room
66
import androidx.room.RoomDatabase
77
import androidx.room.TypeConverters
88
import com.seok.gfd.room.converter.DateConverter
9-
import com.seok.gfd.room.dao.SearchGithubIdDao
10-
import com.seok.gfd.room.entity.SearchGithubId
9+
import com.seok.gfd.room.dao.GithubIdDao
10+
import com.seok.gfd.room.entity.GithubId
1111

12-
@Database(entities = [SearchGithubId::class], version = 2)
12+
@Database(entities = [GithubId::class], version = 2)
1313
@TypeConverters(DateConverter::class)
1414
abstract class AppDatabase : RoomDatabase() {
15-
abstract fun searchGithubIdDao(): SearchGithubIdDao
15+
abstract fun githubIdDao(): GithubIdDao
1616

1717
companion object {
1818
private var INSTANCE: AppDatabase? = null
@@ -22,7 +22,7 @@ abstract class AppDatabase : RoomDatabase() {
2222
synchronized(AppDatabase::class) {
2323
INSTANCE = Room.databaseBuilder(
2424
context.applicationContext,
25-
AppDatabase::class.java, "cat.db"
25+
AppDatabase::class.java, "cata.db"
2626
)
2727
.fallbackToDestructiveMigration()
2828
.build()

app/src/main/java/com/seok/gfd/room/dao/SearchGithubIdDao.kt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
package com.seok.gfd.room.dao
22

33
import androidx.room.*
4-
import com.seok.gfd.room.entity.SearchGithubId
4+
import com.seok.gfd.room.entity.GithubId
55

6-
private const val TABLE_NAME = "search_github_ids"
6+
private const val TABLE_NAME = "search_github_id"
77

88
@Dao
9-
interface SearchGithubIdDao {
9+
interface GithubIdDao {
1010
@Insert(onConflict = OnConflictStrategy.REPLACE)
11-
suspend fun insert(searchGithubId: SearchGithubId): Long
11+
suspend fun insert(githubId: GithubId): Long
1212

1313
@Delete
14-
suspend fun delete(searchGithubId: SearchGithubId)
14+
suspend fun delete(githubId: GithubId)
1515

16-
@Query("SELECT * FROM $TABLE_NAME WHERE gid_name LIKE '%' || :gidName || '%' ORDER BY created DESC")
17-
suspend fun selectAll(gidName: String): List<SearchGithubId>
16+
@Query("SELECT * FROM $TABLE_NAME WHERE github_id LIKE '%' || :githubId || '%' ORDER BY created DESC")
17+
suspend fun selectAll(githubId: String): List<GithubId>
1818

1919
@Query("SELECT * FROM $TABLE_NAME ORDER BY created DESC")
20-
suspend fun selectAll(): List<SearchGithubId>
20+
suspend fun selectAll(): List<GithubId>
21+
22+
@Query("SELECT COUNT(*) FROM $TABLE_NAME WHERE github_id = :githubId")
23+
suspend fun selectById(githubId: String): Int
2124

2225
@Query("delete from $TABLE_NAME")
2326
suspend fun deleteAll()

app/src/main/java/com/seok/gfd/room/entity/SearchGithubId.kt renamed to app/src/main/java/com/seok/gfd/room/entity/GithubId.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import androidx.room.Entity
55
import androidx.room.PrimaryKey
66
import java.util.*
77

8-
private const val TABLE_NAME = "search_github_ids"
8+
private const val TABLE_NAME = "search_github_id"
99

1010
@Entity(tableName = TABLE_NAME)
11-
data class SearchGithubId(
12-
@ColumnInfo(name = "gid_name") val gidName: String?
11+
data class GithubId(
12+
@ColumnInfo(name = "github_id") val githubId: String?
1313
) {
1414
@PrimaryKey(autoGenerate = true)
15-
var gid: Int = 0
15+
var id: Int = 0
1616
@ColumnInfo(name = "created", defaultValue = "CURRENT_TIMESTAMP")
1717
var created: Date? = Date()
1818
}

0 commit comments

Comments
 (0)