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
//MainFragment is an start Destination in navigation | |
class MainFragment:Fragmnet{ | |
// Dont use private val args: MainFragmentArgs by navArgs() to get the args if you wanted to pass data to startDestination | |
//Fragmnet | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
arguments?.get("Key") |
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
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
val extras = intent.extras | |
val finalHost = NavHostFragment.create(R.navigation.main_navigation , bundleOf("Key' to "value")) | |
supportFragmentManager.beginTransaction() | |
.replace(R.id.mainNavHost, finalHost) |
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
recyclerView.setLayoutManager(new GridLayoutManager(this, numberOfColumns)); |
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
// resolve Default instance | |
get<ComponentInterface1> | |
// resolve Component1, casted as ComponentInterface1 | |
koin.bind<ComponentInterface1,Component1>() | |
// resolve all instances matching ComponentInterface1: Default, Component1 & Component2 | |
koin.getAll<ComponentInterface1>() |
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
@Dao | |
public interface MovieDao extends BaseDao<Movie> { | |
@Query("select * from Movie") | |
LiveData<List<Movie>> getAll(); | |
} |
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
... | |
HomeViewModel homeViewModel = ViewModelProviders.of(this).get(HomeViewModel.class); | |
homeViewModel.getMovies().observe(HomeActivity.this, movieList -> { | |
if (movieList != null) { | |
ArrayList<Movie> movieArrayList = new ArrayList<>(movieList); | |
homeAdapter = new HomeAdapter(HomeActivity.this, movieArrayList); | |
InfiniteScrollAdapter wrapper = InfiniteScrollAdapter.wrap(homeAdapter); | |
discreteScrollView.setAdapter(wrapper); |
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 HomeViewModel extends AndroidViewModel { | |
private MovieRepository movieRepository; | |
HomeViewModel(@NonNull Application application) { | |
super(application); | |
movieRepository = new MovieRepository(application.getApplicationContext()); | |
} | |
LiveData<List<Movie>> getMovies() { |
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 MovieRepository extends BaseRepository { | |
private MovieApi movieApi; | |
private MovieDatabaseHelper movieDatabaseHelper; | |
public MovieRepository(Context context) { | |
movieApi = getRetrofitHelper().getService(MovieApi.class); | |
movieDatabaseHelper = new MovieDatabaseHelper(context); | |
} |
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 interface MovieApi { | |
@GET("/?s=Batman&page=1&apikey=96099fe3") | |
Single<Response<SearchResult>> getMovieList(); | |
} |
NewerOlder