-
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.
TODO * ログイン状態を判定する処理が必要 * Statusクラスは改良の余地があるかも?
- Loading branch information
Showing
14 changed files
with
134 additions
and
13 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 |
---|---|---|
@@ -1,13 +1,17 @@ | ||
package org.ageage.eggplant | ||
|
||
import android.app.Application | ||
import com.facebook.stetho.Stetho | ||
import org.ageage.eggplant.common.api.Client | ||
import org.ageage.eggplant.common.db.AppDatabase | ||
import timber.log.Timber | ||
|
||
class DebugApp : Application() { | ||
override fun onCreate() { | ||
super.onCreate() | ||
Timber.plant(Timber.DebugTree()) | ||
Client.setUp() | ||
Stetho.initializeWithDefaults(this) | ||
Client.setUp(this) | ||
AppDatabase.setUp(this) | ||
} | ||
} |
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
30 changes: 30 additions & 0 deletions
30
app/src/main/java/org/ageage/eggplant/common/db/AppDatabase.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,30 @@ | ||
package org.ageage.eggplant.common.db | ||
|
||
import android.content.Context | ||
import androidx.room.Database | ||
import androidx.room.Room | ||
import androidx.room.RoomDatabase | ||
import org.ageage.eggplant.common.db.dao.UserDao | ||
import org.ageage.eggplant.common.db.entity.User | ||
|
||
@Database(entities = [User::class], version = 1) | ||
abstract class AppDatabase : RoomDatabase() { | ||
abstract fun userDao(): UserDao | ||
|
||
companion object { | ||
|
||
private var database: AppDatabase? = null | ||
|
||
fun setUp(context: Context) { | ||
database = Room.databaseBuilder( | ||
context.applicationContext, | ||
AppDatabase::class.java, | ||
"eggplant" | ||
).build() | ||
} | ||
|
||
fun getInstance(): AppDatabase { | ||
return database ?: throw IllegalStateException("You must call setUp method at first.") | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
app/src/main/java/org/ageage/eggplant/common/db/dao/UserDao.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,11 @@ | ||
package org.ageage.eggplant.common.db.dao | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Insert | ||
import org.ageage.eggplant.common.db.entity.User | ||
|
||
@Dao | ||
interface UserDao { | ||
@Insert | ||
fun insert(user: 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
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 |
---|---|---|
|
@@ -8,5 +8,8 @@ enum class Endpoint( | |
), | ||
HATENA_STAR( | ||
"https://s.hatena.com" | ||
), | ||
HATENA_API( | ||
"https://bookmark.hatenaapis.com" | ||
) | ||
} |
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