Skip to content

Commit

Permalink
Android clean up QueryAdapter initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
npurushe committed Jun 27, 2018
1 parent da929ec commit d325639
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
18 changes: 4 additions & 14 deletions requery-android/src/main/java/io/requery/android/QueryAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,14 @@ import java.util.concurrent.Future
* and [.getView].
*
* @param <E> entity element type
* @param type entity type
*
* @author Nikhil Purushe
</E> */
abstract class QueryAdapter<E>
/**
* Creates a new adapter instance mapped to the given type.
*
* @param type entity type
*/
@JvmOverloads protected constructor(type: Type<E>? = null) : BaseAdapter(), Closeable {
abstract class QueryAdapter<E> @JvmOverloads protected constructor(type: Type<E>? = null) : BaseAdapter(), Closeable {

private val handler: Handler
private val proxyProvider: Function<E, EntityProxy<E>>?
private val handler: Handler = Handler()
private val proxyProvider: Function<E, EntityProxy<E>>? = type?.proxyProvider
private var iterator: ResultSetIterator<E>? = null
private var createdExecutor: Boolean = false
private var executor: ExecutorService? = null
Expand All @@ -69,11 +64,6 @@ abstract class QueryAdapter<E>
*/
protected constructor(model: EntityModel, type: Class<E>) : this(model.typeOf<E>(type))

init {
proxyProvider = type?.proxyProvider
handler = Handler()
}

/**
* Call this to clean up the underlying result.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,20 @@ import java.util.concurrent.Future
* @param <VH> view holder type
*
* @author Nikhil Purushe
</VH></E> */
abstract class QueryRecyclerAdapter<E, VH : RecyclerView.ViewHolder>
/**
* Creates a new adapter instance mapped to the given type.
*
* @param type entity type
*/
abstract class QueryRecyclerAdapter<E, VH : RecyclerView.ViewHolder>
@JvmOverloads protected constructor(type: Type<E>? = null) : RecyclerView.Adapter<VH>(), Closeable {

private val handler: Handler
private val proxyProvider: Function<E, EntityProxy<E>>?
private var createdExecutor: Boolean = false
private var executor: ExecutorService? = null
private var queryFuture: Future<Result<E>>? = null

/**
* @return the underlying iterator being used or null if none
*/
protected var iterator: ResultSetIterator<E>? = null
private var createdExecutor: Boolean = false
private var executor: ExecutorService? = null
private var queryFuture: Future<Result<E>>? = null

/**
* Creates a new adapter instance.
Expand Down

0 comments on commit d325639

Please sign in to comment.