mirror of
https://github.com/hmalik144/Farmr.git
synced 2026-03-18 07:25:55 +00:00
- Test suite expanded
- config.yml updated -
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package com.appttude.h_mal.farmr.base
|
||||
|
||||
import android.app.Application
|
||||
import com.appttude.h_mal.farmr.data.RepositoryImpl
|
||||
import com.appttude.h_mal.farmr.data.legacydb.LegacyDatabase
|
||||
import com.appttude.h_mal.farmr.data.prefs.PreferenceProvider
|
||||
import com.appttude.h_mal.farmr.viewmodel.ApplicationViewModelFactory
|
||||
import org.kodein.di.Kodein
|
||||
import org.kodein.di.KodeinAware
|
||||
import org.kodein.di.android.x.androidXModule
|
||||
import org.kodein.di.generic.bind
|
||||
import org.kodein.di.generic.instance
|
||||
import org.kodein.di.generic.provider
|
||||
import org.kodein.di.generic.singleton
|
||||
|
||||
abstract class BaseApplication() : Application(), KodeinAware {
|
||||
|
||||
// Kodein creation of modules to be retrieve within the app
|
||||
override val kodein = Kodein.lazy {
|
||||
import(androidXModule(this@BaseApplication))
|
||||
|
||||
bind() from singleton { createDatabase() }
|
||||
bind() from singleton { createPrefs() }
|
||||
bind() from singleton { RepositoryImpl(instance(), instance()) }
|
||||
|
||||
bind() from provider { ApplicationViewModelFactory(instance()) }
|
||||
}
|
||||
|
||||
abstract fun createDatabase(): LegacyDatabase
|
||||
abstract fun createPrefs(): PreferenceProvider
|
||||
}
|
||||
@@ -3,12 +3,13 @@ package com.appttude.h_mal.farmr.data.legacydb
|
||||
import android.content.ContentResolver
|
||||
import android.net.Uri
|
||||
import android.provider.BaseColumns
|
||||
import com.appttude.h_mal.farmr.BuildConfig
|
||||
|
||||
/**
|
||||
* Created by h_mal on 26/12/2017.
|
||||
*/
|
||||
object ShiftsContract {
|
||||
const val CONTENT_AUTHORITY = "com.appttude.h_mal.farmr"
|
||||
const val CONTENT_AUTHORITY = BuildConfig.APPLICATION_ID
|
||||
val BASE_CONTENT_URI = Uri.parse("content://$CONTENT_AUTHORITY")
|
||||
const val PATH_SHIFTS = "shifts"
|
||||
|
||||
|
||||
@@ -62,4 +62,8 @@ class PreferenceProvider(
|
||||
)
|
||||
}
|
||||
|
||||
fun clearPrefs() {
|
||||
preference.edit().clear().apply()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.appttude.h_mal.farmr.di
|
||||
|
||||
import android.app.Application
|
||||
import com.appttude.h_mal.farmr.base.BaseApplication
|
||||
import com.appttude.h_mal.farmr.data.RepositoryImpl
|
||||
import com.appttude.h_mal.farmr.data.legacydb.LegacyDatabase
|
||||
import com.appttude.h_mal.farmr.data.prefs.PreferenceProvider
|
||||
import com.appttude.h_mal.farmr.viewmodel.ApplicationViewModelFactory
|
||||
import com.appttude.h_mal.farmr.viewmodel.MainViewModel
|
||||
import org.kodein.di.Kodein
|
||||
import org.kodein.di.KodeinAware
|
||||
import org.kodein.di.android.x.androidXModule
|
||||
@@ -14,15 +13,12 @@ import org.kodein.di.generic.instance
|
||||
import org.kodein.di.generic.provider
|
||||
import org.kodein.di.generic.singleton
|
||||
|
||||
class ShiftApplication: Application(), KodeinAware {
|
||||
// Kodein creation of modules to be retrieve within the app
|
||||
override val kodein = Kodein.lazy {
|
||||
import(androidXModule(this@ShiftApplication))
|
||||
class ShiftApplication: BaseApplication() {
|
||||
|
||||
bind() from singleton { LegacyDatabase(contentResolver) }
|
||||
bind() from singleton { PreferenceProvider(this@ShiftApplication) }
|
||||
bind() from singleton { RepositoryImpl(instance(), instance()) }
|
||||
|
||||
bind() from provider { ApplicationViewModelFactory(instance()) }
|
||||
override fun createDatabase(): LegacyDatabase {
|
||||
return LegacyDatabase(contentResolver)
|
||||
}
|
||||
}
|
||||
|
||||
override fun createPrefs() = PreferenceProvider(this)
|
||||
}
|
||||
|
||||
|
||||
@@ -11,5 +11,9 @@ enum class Sortable(val label: String) {
|
||||
|
||||
companion object {
|
||||
val entries = Sortable.values()
|
||||
|
||||
fun getEnumByType(label: String): Sortable {
|
||||
return Sortable.values().first { it.label == label }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import com.appttude.h_mal.farmr.model.Success
|
||||
import com.appttude.h_mal.farmr.utils.ID
|
||||
import com.appttude.h_mal.farmr.utils.createDialog
|
||||
import com.appttude.h_mal.farmr.utils.displayToast
|
||||
import com.appttude.h_mal.farmr.utils.formatAsCurrencyString
|
||||
import com.appttude.h_mal.farmr.utils.formatToTwoDpString
|
||||
import com.appttude.h_mal.farmr.utils.hide
|
||||
import com.appttude.h_mal.farmr.utils.popBackStack
|
||||
@@ -158,8 +159,8 @@ class FragmentAddItem : BaseFragment<SubmissionViewModel>(R.layout.fragment_add_
|
||||
mUnits = units
|
||||
}
|
||||
}
|
||||
mPayRateEditText.setText(rateOfPay.formatToTwoDpString())
|
||||
mTotalPayTextView.text = totalPay.formatToTwoDpString()
|
||||
mPayRateEditText.setText(rateOfPay.formatAsCurrencyString())
|
||||
mTotalPayTextView.text = totalPay.formatAsCurrencyString()
|
||||
|
||||
calculateTotalPay()
|
||||
}
|
||||
@@ -267,7 +268,7 @@ class FragmentAddItem : BaseFragment<SubmissionViewModel>(R.layout.fragment_add_
|
||||
(mUnits ?: 0f) * mPayRate
|
||||
}
|
||||
}
|
||||
mTotalPayTextView.text = total.formatToTwoDpString()
|
||||
mTotalPayTextView.text = total.formatAsCurrencyString()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ class FragmentMain : BaseFragment<MainViewModel>(R.layout.fragment_main), BackPr
|
||||
.setSingleChoiceItems(
|
||||
groupName,
|
||||
checkedItem
|
||||
) { p0, p1 -> sort = Sortable.valueOf(groupName[p1]) }
|
||||
) { p0, p1 -> sort = Sortable.getEnumByType(groupName[p1]) }
|
||||
.setPositiveButton("Ascending") { dialog, id ->
|
||||
viewModel.setSortAndOrder(sort)
|
||||
dialog.dismiss()
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.view.View
|
||||
import android.widget.RelativeLayout
|
||||
import androidx.core.app.ActivityOptionsCompat
|
||||
@@ -16,8 +17,7 @@ class SplashScreen : Activity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_splash)
|
||||
val bundle = ActivityOptionsCompat.makeCustomAnimation(this, R.anim.hyperspace_jump, android.R.anim.fade_out).toBundle()
|
||||
val relativeLayout = findViewById<View>(R.id.splash_layout) as RelativeLayout
|
||||
|
||||
val i = Intent(this@SplashScreen, MainActivity::class.java)
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_CLEAR_TASK)
|
||||
Handler().postDelayed({
|
||||
@@ -27,11 +27,11 @@ class SplashScreen : Activity() {
|
||||
startActivity(i)
|
||||
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out)
|
||||
// finish();
|
||||
}, SPLASH_TIME_OUT.toLong())
|
||||
}, SPLASH_TIME_OUT)
|
||||
}
|
||||
|
||||
companion object {
|
||||
// Splash screen timer
|
||||
private const val SPLASH_TIME_OUT = 2000
|
||||
const val SPLASH_TIME_OUT: Long = 2000
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user