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
@Composable | |
fun StatesUI(uiState: TweetsUIState) { | |
when (uiState) { | |
is TweetsUIState.XXXXXState -> // TODO ... | |
} | |
} |
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
@ActivityScope | |
class SearchComposablesUI @Inject constructor() { | |
private var composeView: ComposeView? = null | |
private var activity: SearchTweetActivity? = null | |
fun setComposeView(composeView: ComposeView, activity: SearchTweetActivity) { | |
this.composeView = composeView | |
this.activity = activity | |
} |
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
@ActivityScope | |
class SearchStateHandler @Inject constructor(@Named("CoroutineUIScope") private val scope: CoroutineScope) { | |
private var searchComposablesUI: SearchComposablesUI? = null | |
private lateinit var stateFlow: StateFlow<TweetsUIState> | |
fun initStateFlowAndViews( | |
val stateFlow: StateFlow<TweetsUIState>, | |
val searchComposablesUI: SearchComposablesUI | |
) { |
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
public class TweetsListUIFragment extends BaseUI { | |
// ... | |
@Inject SearchComposablesUI searchComposablesUI; | |
@Inject SearchViewDelegate viewDelegate; | |
@Inject SearchStateHandler stateHandler; | |
public void initStateFlowAndViews() { | |
stateHandler.initStateFlowAndViews(viewDelegate.getStateFlow(), searchComposablesUI); |
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
<androidx.constraintlayout.widget.ConstraintLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<!-- ... --> | |
<androidx.compose.ui.platform.ComposeView | |
android:id="@+id/compose_view" | |
android:layout_marginTop="?attr/actionBarSize" |
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
public class TweetsListUIFragment extends BaseUI { | |
@Inject SearchComposablesUI searchComposablesUI; | |
@Inject SearchViewDelegate viewDelegate; | |
@Inject SearchStateHandler stateHandler; | |
@Override public View onCreateView(@NotNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | |
final View view = inflater.inflate(R.layout.fragment_search, container, false); |
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
@ActivityScope | |
class SearchViewDelegate @Inject constructor( | |
private val presenter: SearchTweetPresenter, | |
@Named("CoroutineUIScope") private val scope: CoroutineScope | |
) { | |
fun initialiseProcessingQuery(tweetsListUI: TweetsListUIFragment?) { | |
tweetsListUI?.apply { | |
initStateFlowAndViews() | |
} |
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
fun TweetsListFragmentUI.showResults(tweets: List<Tweet>) { | |
hideLoader() | |
hideError() | |
showList() | |
updateList(tweets) | |
} |
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
fun TweetsListFragmentUI.handleStates(uiState: TweetsUIState) { | |
when (uiState) { | |
is TweetsUIState.ListResultsUIState -> showResults(uiState.tweets) | |
// ... | |
} | |
} |
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
public class TweetsListUIFragment extends BaseUI { | |
// ... | |
@Inject SearchViewDelegate viewDelegate; | |
@Inject SearchStateHandler stateHandler; | |
public void initStateFlowAndViews() { | |
stateHandler.initStateFlowAndViews(viewDelegate.getStateFlow(), this); | |
stateHandler.processStateFlowCollection(); |