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
interface Navigator { | |
fun goToDetailsFromMain(githubRepoEntity: GithubRepoEntity) | |
fun goToUrl(url: String) | |
} |
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
@SingleActivity | |
class NavigatorImpl @Inject constructor( | |
private val androidPlaygroundActivity: AndroidPlaygroundActivity | |
): Navigator { | |
override fun goToDetailsFromMain(githubRepo: GithubRepoEntity) { | |
val action = MainFragmentDirections.actionMainFragmentToDetailsFragment(githubRepo) | |
androidPlaygroundActivity.findNavController(R.id.nav_host_fragment).navigate(action) | |
} |
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 repoClicked(githubRepoEntity: GithubRepoEntity) { | |
navigator.goToDetails(githubRepoEntity) | |
} | |
fun onGoToRepositoryClicked() { | |
navigator.goToUrl(githubRepoEntity.url) | |
} |
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 AndroidPlaygroundActivity : DaggerAppCompatActivity() |
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
abstract class BaseFragment : DaggerFragment() { | |
// Code emitted for brevity | |
} |
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 DetailsFragment : BaseFragment() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
val githubRepoEntity = arguments?.getParcelable<GithubRepoEntity>(REPOSITORY_KEY) | |
githubRepoEntity?.let { detailsViewModel.initData(it) } | |
} | |
override fun onCreateView( | |
inflater: LayoutInflater, |
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 MainFragment : BaseFragment() { | |
override fun onCreateView( | |
inflater: LayoutInflater, | |
container: ViewGroup?, | |
savedInstanceState: Bundle? | |
): View? { | |
return inflater.inflate(R.layout.fragment_main, 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
Toast.makeText(requireContext(), it.error, Toast.LENGTH_LONG).show() |
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 Fragment.requireAppCompatActivity(): AppCompatActivity { | |
return requireActivity() as? AppCompatActivity | |
?: throw IllegalStateException("Activity this fragment is attached to does not extend AppCompatActivity") | |
} | |
requireAppCompatActivity().supportActionBar?.title = it.toolbarTitle |
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
<activity android:name=".ui.AndroidPlaygroundActivity"> | |
<intent-filter> | |
<action android:name="android.intent.action.MAIN" /> | |
<category android:name="android.intent.category.LAUNCHER" /> | |
</intent-filter> | |
</activity> |
OlderNewer