View MyFragment.java
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 MyFragment | |
extends Fragment { | |
public MyFragment() { | |
super(R.layout.my_fragment); | |
} | |
private int selectedIndex = 0; | |
private FirstFragment firstFragment; |
View ByteArrayConverterFactory.java
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
import java.io.IOException; | |
import java.lang.annotation.Annotation; | |
import java.lang.reflect.Type; | |
import javax.annotation.Nullable; | |
import okhttp3.MediaType; | |
import okhttp3.RequestBody; | |
import okhttp3.ResponseBody; | |
import retrofit2.Converter; |
View MainActivity.kt
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 MainActivity : AppCompatActivity() { | |
private lateinit var swipeFragment: SwipeFragment | |
private lateinit var favoritesFragment: FavoritesFragment | |
private lateinit var newsFragment: NewsFragment | |
private val fragments: Array<out Fragment> get() = arrayOf(swipeFragment, favoritesFragment, newsFragment) | |
private fun selectFragment(selectedFragment: Fragment) { | |
var transaction = supportFragmentManager.beginTransaction() | |
fragments.forEachIndexed { index, fragment -> |
View FirestoreLiveData.kt
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
inline fun <reified T> Query.asLiveData(noinline onError: ((Throwable) -> Unit) = {}): FirestoreQueryLiveData<T> { | |
return FirestoreQueryLiveData(this, T::class.java, onError) | |
} | |
inline fun <reified T> DocumentReference.asLiveData(noinline onError: ((Throwable) -> Unit) = {}): FirestoreDocumentLiveData<T> { | |
return FirestoreDocumentLiveData(this, T::class.java, onError) | |
} | |
class FirestoreQueryLiveData<T>( | |
private val query: Query, |
View CustomFragmentContainerView.java
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
import android.animation.LayoutTransition; | |
import android.content.Context; | |
import android.graphics.Canvas; | |
import android.os.Build; | |
import android.util.AttributeSet; | |
import android.view.View; | |
import android.view.ViewGroup; | |
import android.view.WindowInsets; | |
import android.widget.FrameLayout; |
View LoginViewModel.kt
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 onLoginClicked() { | |
val username = // ... | |
navigationDispatcher.emit { navController -> | |
navController.navigate( | |
LoggedOutGraphDirections.loggedOutToLoggedIn(username)) | |
} | |
} | |
} |
View LoginViewModel.kt
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 LoginViewModel @ViewModelInject constructor( | |
private val navigationDispatcher: NavigationDispatcher, | |
@Assisted private val savedStateHandle: SavedStateHandle | |
) : ViewModel() { | |
fun onRegisterClicked() { | |
navigationDispatcher.emit { navController -> | |
navController.navigate(R.id.logged_out_to_registration) | |
} | |
} | |
} |
View MainActivity.kt
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
@AndroidEntryPoint | |
class MainActivity : AppCompatActivity() { | |
@Inject | |
lateinit var navigationDispatcher: NavigationDispatcher | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
navigationDispatcher.navigationCommands.observe(this) { command -> |
NewerOlder