diff --git a/app/src/main/kotlin/jackall/moncalc/viewmodel/OverlayRegistViewModel.kt b/app/src/main/kotlin/jackall/moncalc/viewmodel/OverlayRegistViewModel.kt index d4ebbaa..cbf1c4d 100644 --- a/app/src/main/kotlin/jackall/moncalc/viewmodel/OverlayRegistViewModel.kt +++ b/app/src/main/kotlin/jackall/moncalc/viewmodel/OverlayRegistViewModel.kt @@ -1,15 +1,42 @@ package jackall.moncalc.viewmodel import android.databinding.BaseObservable +import android.databinding.ObservableInt import android.view.View +import android.widget.Toast +import jackall.moncalc.App import jackall.moncalc.Contract.MainServiceContract import jackall.moncalc.db.MonstDataRealmHelper +import jackall.moncalc.db.QuestRecordRealmHelper +import jackall.moncalc.vo.Fruit +import jackall.moncalc.vo.Grade +import jackall.moncalc.vo.QuestRecord +import jackall.moncalc.vo.Temple +import java.util.* /** * Created by matsumoto_k on 2017/11/01. */ class OverlayRegistViewModel(val mainServiceContract: MainServiceContract) : BaseObservable() { private val monstDataRealmHelper = MonstDataRealmHelper() + private val questRecordRealmHelper = QuestRecordRealmHelper() + val templeRank = ObservableInt(0) + val fruitRank = ObservableInt(0) + val gradeRank = ObservableInt(0) + + fun onClickRegist(view: View) { + questRecordRealmHelper.insert( + QuestRecord( + templeId = monstDataRealmHelper.findIdByRank(Temple::class.java, templeRank.get()), + fruitId = monstDataRealmHelper.findIdByRank(Fruit::class.java, fruitRank.get()), + gradeId = monstDataRealmHelper.findIdByRank(Grade::class.java, gradeRank.get()), + createAt = Date() + ) + ) + Toast.makeText(App.instance, "記録しました", Toast.LENGTH_LONG).show() + mainServiceContract.showMoveView() + } + fun onClickMin(view: View) { mainServiceContract.showMoveView() } @@ -20,5 +47,6 @@ fun realmInstanceClose() { monstDataRealmHelper.close() + questRecordRealmHelper.close() } } \ No newline at end of file