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
package au.com.auspost.android.feature.postcode.model | |
import android.arch.persistence.room.ColumnInfo | |
import android.arch.persistence.room.Entity | |
import android.arch.persistence.room.PrimaryKey | |
@Entity(tableName = "branch_location") | |
data class BranchLocation(@PrimaryKey(autoGenerate = true) var id : Int, | |
@ColumnInfo(name = "postcode") var postcode : String?, | |
@ColumnInfo(name = "locality") var locality : String?, |
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
@Entity(tableName = "branch_location") | |
@SuppressLint("ParcelCreator") | |
data class BranchLocation @ParcelConstructor constructor (@PrimaryKey(autoGenerate = true) var id : Int, | |
@ColumnInfo(name = "postcode") var postcode : String?, | |
@ColumnInfo(name = "locality") var locality : String?, | |
@ColumnInfo(name = "state") var state : String?, | |
@ColumnInfo(name = "delivery") var delivery : String? = null, | |
@ColumnInfo(name = "category") var category : String?) |
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
package au.com.auspost.android.feature.postcode.service | |
import android.arch.persistence.room.Dao | |
import android.arch.persistence.room.Insert | |
import android.arch.persistence.room.OnConflictStrategy | |
import android.arch.persistence.room.Query | |
import au.com.auspost.android.feature.postcode.model.BranchLocation | |
import io.reactivex.Single | |
@Dao |
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
package au.com.auspost.android.feature.postcode.service | |
import au.com.auspost.android.AuspostDatabase | |
import javax.inject.Inject | |
import javax.inject.Singleton | |
@Singleton | |
class BranchLocationManager { | |
@Inject |
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
package au.com.auspost.android | |
import android.arch.persistence.db.SupportSQLiteDatabase | |
import android.arch.persistence.room.Room | |
import android.arch.persistence.room.migration.Migration | |
import android.content.Context | |
import android.support.annotation.VisibleForTesting | |
import io.reactivex.Observable | |
import timber.log.Timber | |
import toothpick.ProvidesSingletonInScope |
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
package au.com.auspost.android | |
import android.arch.persistence.room.Database | |
import android.arch.persistence.room.RoomDatabase | |
import au.com.auspost.android.feature.postcode.model.BranchLocation | |
import au.com.auspost.android.feature.postcode.service.BranchLocationDao | |
@Database(entities = [ | |
BranchLocation::class | |
], version = 2) |
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
package au.com.auspost.android.feature.postcode.service | |
import android.arch.core.executor.testing.InstantTaskExecutorRule | |
import android.arch.persistence.room.Room | |
import android.support.test.InstrumentationRegistry | |
import android.support.test.runner.AndroidJUnit4 | |
import au.com.auspost.android.AuspostDatabase | |
import au.com.auspost.android.feature.postcode.model.BranchLocation | |
import org.junit.After | |
import org.junit.Before |
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
class BranchLocationPageAdapter(var context: Context) : PagedListAdapter<BranchLocation, BranchLocationPageAdapter.ViewHolder>(diffCallback), FastScrollRecyclerView.SectionedAdapter { | |
override fun onBindViewHolder(holder: ViewHolder, position: Int) { | |
bindItem(holder, position) | |
} | |
fun getBranchLocation(position: Int) = getItem(position) | |
fun bindItem(holder: ViewHolder, position: Int) { | |
val obj = getItem(position) |
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
class FindPostcodeActivity : KAusPostActivity() { | |
@Inject | |
lateinit var mgr: BranchLocationManager | |
lateinit var searchText: EditText | |
lateinit var listAdapter: BranchLocationPageAdapter | |
public override fun doOnCreate(savedInstanceState: Bundle?) { |
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
@Dao | |
interface BranchLocationDao { | |
@Query("SELECT * from branch_location where postcode like :arg0 OR locality like :arg0 ORDER BY locality ASC") | |
fun pageByKeyword(arg0: String): DataSource.Factory<Int, BranchLocation> | |
} |
OlderNewer