This file contains hidden or 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
| /** | |
| * Let's say we want to display a list of Animals in a RecyclerView. | |
| * The list can contain items of type Dog, Cat and Snake. | |
| */ | |
| // AdapterDelegate for Dog. | |
| fun dogAdapterDelegate(picasso : Picasso) = adapterDelegate<Dog, Animal>(R.layout.item_dog){ // Generics Types means this AdapterDelegate is used if item is instanceof Dog (whole list is List<Anmial>) | |
| // this block is run once in onCreateViewHolder. Think of it as an intializer for a ViewHolder. | |
| val name = findViewById(R.id.name) | |
| val image = findViewById(R.id.image) |
This file contains hidden or 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
| import kotlinx.coroutines.FlowPreview | |
| import kotlinx.coroutines.Job | |
| import kotlinx.coroutines.cancelAndJoin | |
| import kotlinx.coroutines.coroutineScope | |
| import kotlinx.coroutines.flow.Flow | |
| import kotlinx.coroutines.flow.collect | |
| import kotlinx.coroutines.flow.flow | |
| import kotlinx.coroutines.launch | |
| /** |
This file contains hidden or 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
| data class News( | |
| val title : String | |
| val favorite : Boolean | |
| ) |
This file contains hidden or 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 MyFormPresenter extends MviBasePresenter<MyFormView, FormViewState> { | |
| @Override | |
| public void bindIntents(){ | |
| Observable<FormViewState> state = intent( MyFormView::submitIntent) | |
| .map(formInputData -> new FormViewState( isValidName(formInputData.name), isValidEmail(formInputData.email) ) ); | |
| subscribeViewState(state, MyFormView::render) | |
| } | |
| } |
This file contains hidden or 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 FirstPageLoading implements PartialStateChanges { | |
| @Override | |
| public HomeViewState computeNewState(HomeViewState previousState) | |
| return previousState.builder() | |
| .firstPageLoading(true) | |
| .firstPageError(null) | |
| .build(); | |
| } | |
| } |
This file contains hidden or 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 FooActivity extends MviActivity<...> { | |
| @Inject FooPresenter | |
| public void onCreate(Bundle bundle){ | |
| super.onCreate(bundle); | |
| FooComponent component = DaggerFooComponent.builder() | |
| .fooModule(new FooModule(bundle)) | |
| .build(); | |
| component.inject(this); |
This file contains hidden or 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 PersonsModel { | |
| // In a real application fields would be private | |
| // and we would have getters to access them | |
| final boolean loading; | |
| final List<Person> persons; | |
| final Throwable error; | |
| public(boolean loading, List<Person> persons, Throwable error){ | |
| this.loading = loading; | |
| this.persons = persons; |
This file contains hidden or 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 com.pascalwelsch.mockito; | |
| import org.mockito.exceptions.base.MockitoException; | |
| import org.mockito.exceptions.verification.ArgumentsAreDifferent; | |
| import org.mockito.internal.debugging.LocationImpl; | |
| import org.mockito.internal.invocation.InvocationMatcher; | |
| import org.mockito.internal.junit.JUnitTool; | |
| import org.mockito.internal.reporting.SmartPrinter; | |
| import org.mockito.internal.verification.api.VerificationData; | |
| import org.mockito.internal.verification.argumentmatching.ArgumentMatchingTool; |
This file contains hidden or 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 com.usehomeroom.vasuki.data; | |
| import com.fasterxml.jackson.core.type.TypeReference; | |
| import com.fasterxml.jackson.databind.ObjectMapper; | |
| import com.fernandocejas.arrow.optional.Optional; | |
| import com.google.firebase.database.DataSnapshot; | |
| import com.google.firebase.database.DatabaseError; | |
| import com.google.firebase.database.DatabaseReference; | |
| import com.google.firebase.database.FirebaseDatabase; | |
| import com.google.firebase.database.ValueEventListener; |
This file contains hidden or 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 MyFragmentPagerAdapter extends FragmentPagerAdapter { | |
| public MyFragmentPagerAdapter(FragmentManager fm) { | |
| super(fm); | |
| } | |
| @Override public Fragment getItem(int position) { | |
| return new OverviewFragmentBuilder(1).build(); | |
| } |
NewerOlder