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 WordListFragment : Fragment() { | |
//... | |
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
super.onViewCreated(view, savedInstanceState) | |
mainActivityViewModel.words.observe(this, Observer { | |
meaningAdapter.submitList(it) | |
}) | |
//... | |
} | |
//... |
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 MainActivityViewModel(//...) : | |
ViewModel() { | |
//... | |
val words: MediatorLiveData<PagedList<Meaning>> = MediatorLiveData() | |
//... | |
private fun addAllWordsAndRemoveSearch() { | |
removeSearchObserver() | |
if (!mapOfLiveData.containsKey(ALL)) { | |
mapOfLiveData[ALL] = LivePagedListBuilder(dataSourceFactory, config).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 DictionaryAllWordsDataSource(//...) : | |
PositionalDataSource<Meaning>() { | |
//... | |
override fun loadRange(params: LoadRangeParams, callback: LoadRangeCallback<Meaning>) { | |
//... | |
val startPage = (params.startPosition / PAGE_SIZE) + 1 | |
if (totalPages >= startPage) { | |
val words = getWordsFromPage(startPage, startPage) | |
if (words.isEmpty()) throw NoDataException() | |
callback.onResult(words) |
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 DictionaryAllWordsDataSourceFactory( | |
private val repository: Repository, | |
private val networkState: MutableLiveData<Event<NetworkMessage>> | |
) : | |
DataSource.Factory<Int, Meaning>() { | |
override fun create(): DataSource<Int, Meaning> { | |
return DictionaryAllWordsDataSource(repository, networkState) | |
} | |
} |
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
{ | |
//... | |
//Backend Services Libraries | |
implementation 'com.squareup.retrofit2:retrofit:2.2.0' | |
implementation 'com.squareup.retrofit2:converter-moshi:2.2.0' | |
//... | |
} |
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
{ | |
//... | |
//Paging Dependency | |
implementation 'androidx.paging:paging-runtime:2.1.0' | |
//... | |
} |
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
#~/.leptonrc | |
{ | |
"theme": "dark" | |
} |
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 $1 extends $2 { | |
} | |
//$1 - Class Name | |
//$2 - Super Class Name | |
class MyWidget extends StatelessWidget { | |
} |
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
const $1({p1,p2,...,pn}): assert(condition(p1)),super(p1); | |
//$1 - Enclosing Class Name. | |
//p1...pn - Parameters to pass to the constructor. | |
const MyWidget({Key key, | |
@required this.name, | |
@required this.color, | |
@required this.iconLocation, | |
}) : assert(name != null), | |
assert(color != null), |