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
<!-- Declaring an App is only for handsets --> | |
<compatible-screens> | |
<screen android:screenSize="small" android:screenDensity="mdpi"/> | |
<screen android:screenSize="small" android:screenDensity="hdpi"/> | |
<screen android:screenSize="small" android:screenDensity="xhdpi"/> | |
<screen android:screenSize="small" android:screenDensity="420"/> | |
<screen android:screenSize="small" android:screenDensity="480"/> | |
<screen android:screenSize="small" android:screenDensity="560"/> | |
<screen android:screenSize="small" android:screenDensity="640"/> |
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 Coffee { | |
def coffee = 0 | |
def sugar = 0 | |
def milk = 0 | |
def liquor = 0 | |
def with(sugar, milk) { | |
this.sugar = sugar | |
this.milk = milk | |
this |
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
// INCLUDES | |
// #define __INCLUDE_MANUAL | |
#ifndef __INCLUDE_MANUAL | |
#include <functional> | |
#include <algorithm> | |
#include <utility> | |
#include <cassert> | |
#include <cmath> | |
#include <ctime> | |
#include <numeric> |
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
// Base auth task | |
public abstract class AbstractAuthTask extends AsyncTask<Void, Void, Void> { | |
protected final AuthorizationFlow mAuthFlow; | |
AbstractAuthTask(final AuthorizationFlow authFlow) { | |
mAuthFlow = authFlow; | |
} | |
} |
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.content.Context; | |
import android.content.res.TypedArray; | |
import android.support.annotation.NonNull; | |
import android.support.annotation.Nullable; | |
import android.util.AttributeSet; | |
import android.view.View; | |
import android.view.ViewGroup; | |
public class DashboardWithSquaredCells extends ViewGroup { |
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 KitsuMainActivity : AppCompatActivity() { | |
private val viewModel by lazy { ViewModelProviders.of(this).get(KitsuViewModel::class.java) } | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
initFlysearch(savedInstanceState) | |
searchForResults("Android") | |
} |
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 KitsuViewModel(app: Application) : AndroidViewModel(app) { | |
private var allKitsuLiveData: LiveData<PagedList<KitsuItem>>? = null | |
val allKitsu: LiveData<PagedList<KitsuItem>> | |
get() { | |
if (null == allKitsuLiveData) { | |
allKitsuLiveData = KitsuMediaPagedListProvider.allKitsu().create(0, | |
PagedList.Config.Builder() | |
.setPageSize(PAGED_LIST_PAGE_SIZE) | |
.setInitialLoadSizeHint(PAGED_LIST_PAGE_SIZE) | |
.setEnablePlaceholders(PAGED_LIST_ENABLE_PLACEHOLDERS) |
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
object KitsuMediaPagedListProvider { | |
private val dataSource = object: KitsuLimitOffsetNetworkDataSource<KitsuItem>(KitsuRestApi) { | |
override fun convertToItems(items: KitsuResponse, size: Int): List<KitsuItem> { | |
return List(size, { index -> | |
items.data.elementAtOrElse(index, { KitsuItem(0, null, null) }) | |
}) | |
} | |
} | |
fun allKitsu(): LivePagedListProvider<Int, KitsuItem> { |
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 KitsuResponse( | |
val data: List<KitsuItem>) | |
data class KitsuItem( | |
val id: Int, | |
val type: String?, | |
val attributes: KitsuItemAttributes?) | |
data class KitsuItemAttributes( | |
val synopsis: 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
abstract class KitsuLimitOffsetNetworkDataSource<T> protected constructor( | |
val dataProvider: KitsuRestApi) : TiledDataSource<T>() { | |
var queryFilter: String = "" | |
override fun countItems(): Int = DataSource.COUNT_UNDEFINED | |
protected abstract fun convertToItems(items: KitsuResponse, size: Int): List<T> | |
override fun loadRange(startPosition: Int, loadCount: Int): List<T>? { |