Skip to content

Commit d494ac9

Browse files
author
Patrick Jackson
committed
clean up
1 parent 24fc267 commit d494ac9

23 files changed

+94
-117
lines changed

android/src/main/java/com/jackson/openlibrary/BottomNavigationDialogFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import android.view.LayoutInflater
55
import android.view.View
66
import android.view.ViewGroup
77
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
8-
import com.willowtreeapps.common.*
98
import com.willowtreeapps.common.external.AttachView
109
import com.willowtreeapps.common.external.DetachView
1110
import com.willowtreeapps.common.external.rootDispatch
1211
import com.willowtreeapps.common.ui.BottomNavSheet
12+
import com.willowtreeapps.common.ui.UiActions
1313
import kotlinx.android.synthetic.main.fragment_bottomsheet.*
1414

1515
class BottomNavigationDrawerFragment : BottomSheetDialogFragment(), BottomNavSheet {

android/src/main/java/com/jackson/openlibrary/MainActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import android.view.*
66
import androidx.appcompat.app.AppCompatActivity
77
import com.bumptech.glide.annotation.GlideModule
88
import com.bumptech.glide.module.AppGlideModule
9-
import com.willowtreeapps.common.UiActions
9+
import com.willowtreeapps.common.ui.UiActions
1010
import com.willowtreeapps.hyperion.core.Hyperion
1111
import kotlinx.android.synthetic.main.activity_main.*
1212

android/src/main/java/com/jackson/openlibrary/store/BooksAdapter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import androidx.recyclerview.widget.RecyclerView
77
import com.jackson.openlibrary.GlideApp
88
import com.jackson.openlibrary.OpenLibraryApp
99
import com.jackson.openlibrary.R
10-
import com.willowtreeapps.common.UiActions
10+
import com.willowtreeapps.common.ui.UiActions
1111
import com.willowtreeapps.common.ui.BookListItemViewState
1212
import com.willowtreeapps.common.ui.ListHeader
1313
import kotlinx.android.synthetic.main.item_book.view.*

android/src/main/java/com/jackson/openlibrary/store/CompletedFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import android.view.ViewGroup
77
import androidx.recyclerview.widget.LinearLayoutManager
88
import com.jackson.openlibrary.MainActivity
99
import com.jackson.openlibrary.R
10-
import com.willowtreeapps.common.UiActions
10+
import com.willowtreeapps.common.ui.UiActions
1111
import com.willowtreeapps.common.external.rootDispatch
1212
import com.willowtreeapps.common.ui.CompletedView
1313
import kotlinx.android.synthetic.main.fragment_completed.*

android/src/main/java/com/jackson/openlibrary/store/DetailsFragment.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ import android.os.Bundle
44
import android.view.*
55
import com.jackson.openlibrary.GlideApp
66
import com.jackson.openlibrary.MainActivity
7-
import com.jackson.openlibrary.OpenLibraryApp.Companion.dispatch
87
import com.jackson.openlibrary.R
98
import com.jackson.openlibrary.tintAllIcons
10-
import com.willowtreeapps.common.UiActions
9+
import com.willowtreeapps.common.ui.UiActions
1110
import com.willowtreeapps.common.external.rootDispatch
1211
import com.willowtreeapps.common.ui.BookDetailViewState
1312
import com.willowtreeapps.common.ui.DetailsView

android/src/main/java/com/jackson/openlibrary/store/ReadingListFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import kotlinx.coroutines.CoroutineScope
1212
import kotlinx.coroutines.Dispatchers
1313
import kotlin.coroutines.CoroutineContext
1414
import com.jackson.openlibrary.R
15-
import com.willowtreeapps.common.UiActions
15+
import com.willowtreeapps.common.ui.UiActions
1616
import com.willowtreeapps.common.external.rootDispatch
1717

1818

android/src/main/java/com/jackson/openlibrary/store/SearchFragment.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,15 @@ import android.view.LayoutInflater
77
import android.view.View
88
import android.view.ViewGroup
99
import androidx.recyclerview.widget.LinearLayoutManager
10-
import com.jackson.openlibrary.OpenLibraryApp
1110
import com.jackson.openlibrary.R
12-
import com.willowtreeapps.common.UiActions
11+
import com.willowtreeapps.common.ui.UiActions
1312
import com.willowtreeapps.common.external.rootDispatch
1413
import com.willowtreeapps.common.ui.BookListItemViewState
1514
import com.willowtreeapps.common.ui.SearchView
1615
import kotlinx.android.synthetic.main.fragment_search.*
1716
import kotlinx.android.synthetic.main.fragment_reading_list.loading_spinner
1817
import kotlinx.android.synthetic.main.fragment_reading_list.txt_error
19-
import kotlinx.coroutines.CoroutineScope
20-
import kotlinx.coroutines.Dispatchers
2118
import java.util.*
22-
import kotlin.coroutines.CoroutineContext
2319

2420
class SearchFragment : BaseLibraryViewFragment<SearchView>(), SearchView {
2521
private val adapter = BooksAdapter()

common/src/commonMain/kotlin/com/willowtreeapps/common/Actions.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import com.willowtreeapps.common.repo.Book
55
import com.willowtreeapps.common.ui.BookListItemViewState
66

77
internal sealed class Actions {
8-
9-
108
class FetchingItemsStartedAction
119
data class FetchingItemsSuccessAction(val itemsHolder: List<Book>)
1210
data class FetchingItemsFailedAction(val message: String)

common/src/commonMain/kotlin/com/willowtreeapps/common/NetworkThunks.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class NetworkThunks(private val networkContext: CoroutineContext,
1515
override val coroutineContext: CoroutineContext
1616
get() = networkContext + job
1717

18-
fun fetchBooksThunk2(query: String) = createThunk { dispatch, getState, extraArgument ->
18+
fun fetchBooksThunk(query: String) = createThunk { dispatch, getState, extraArgument ->
1919
Logger.d("Fetching Books and Feed")
2020
launch {
2121
dispatch(Actions.FetchingItemsStartedAction())

common/src/commonMain/kotlin/com/willowtreeapps/common/external/PresenterInjecter.kt

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ data class DetachView(val view: Any)
1111
data class ClearView(val view: Any)
1212

1313
/*
14-
* All views implement this interface. The PresenterFactory handles setting and removing references
15-
* to the dispatch() and a selectorBuilder.
14+
* Dispatch set by PresenterMiddleware that is same function as the store's dispatch.
15+
* It is globally accessible and value is set when createStore is called.
1616
*/
17-
interface View {
18-
//// var dispatch: Dispatcher
19-
//// var selectorBuilder: SelectorSubscriberBuilder<S>?
20-
}
17+
lateinit var rootDispatch: Dispatcher
18+
19+
/*
20+
* All views implement this interface.
21+
*/
22+
interface View
2123

2224

2325
interface PresenterProvider {
@@ -33,7 +35,6 @@ enum class ViewLifecycle {
3335

3436
data class StoreSubscriberHolder(val lifecycleState: ViewLifecycle, val subscriber: StoreSubscriber)
3537

36-
lateinit var rootDispatch: Dispatcher
3738
val presenterEnhancer: StoreEnhancer = { storeCreator: StoreCreator ->
3839
{ reducer: Reducer, initialState: Any, en: Any? ->
3940
val store = storeCreator(reducer, initialState, en)
@@ -70,7 +71,6 @@ fun presenterMiddleware(uiContext: CoroutineContext): Middleware = { store ->
7071

7172
fun attachView(view: ViewWithProvider) {
7273
Logger.d("AttachView: $view", Logger.Category.LIFECYCLE)
73-
// view.dispatch = store.dispatch
7474
//TODO is hanging onto subscription needed?
7575
if (subscription == null) {
7676
subscription = store.subscribe(::onStateChange)
@@ -175,15 +175,10 @@ fun <State : Any, V : Any> selectorSubscriberFn(store: Store, view: V, selectorS
175175
val subscriberBuilder: SelectorSubscriberBuilder<State> = SelectorSubscriberBuilder(store)
176176
subscriberBuilder.selectorSubscriberBuilderInit()
177177
selectorSubscriberMap[view] = subscriberBuilder
178-
/*
179-
view.selectorBuilder = SelectorSubscriberBuilder(store)
180-
view.selectorBuilder!!.selectorSubscriberBuilderInit()
181-
*/
182178
return {
183179
selectorSubscriberMap[view]!!.selectorList.forEach { entry ->
184180
(entry.key as Selector<State, *>).onChangeIn(store.getState() as State) { entry.value(store.getState()) }
185181
}
186182
selectorSubscriberMap[view]!!.withAnyChangeFun?.invoke()
187-
// view.selectorBuilder!!.withAnyChangeFun?.invoke()
188183
}
189184
}

0 commit comments

Comments
 (0)