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 OnGetUsersCallback { | |
void onSuccess(List<User> users); | |
void onError(); | |
} |
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 GithubApi { | |
@GET("/users") | |
Call<List<User>> getAllUsers(); | |
} |
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
buildTypes { | |
release { | |
minifyEnabled false | |
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | |
buildConfigField "String", "BASE_MOVIES_URL", '"https://api.themoviedb.org/3/"' | |
buildConfigField "String", "BASE_GITHUB_URL", '"https://api.github.com/"' | |
} | |
debug { | |
buildConfigField "String", "BASE_MOVIES_URL", '"https://api.themoviedb.org/3/"' | |
buildConfigField "String", "BASE_GITHUB_URL", '"https://api.github.com/"' |
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
@Database(entities = {Item.class}, version = 1, exportSchema = false) | |
public abstract class ItemRoomDatabase extends RoomDatabase { | |
public abstract ItemDao itemDao(); | |
private static ItemRoomDatabase INSTANCE; | |
static ItemRoomDatabase getDatabase(final Context context) { | |
if (INSTANCE == null) { | |
synchronized (ItemRoomDatabase.class) { |
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
new Handler().postDelayed(new Runnable() { | |
@Override public void run() { | |
// do what you want to do | |
} | |
}, 4000); // Delay in millis |
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
mRecyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext(), LinearLayoutManager.HORIZONTAL, 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
<?xml version="1.0" encoding="utf-8"?> | |
<shape xmlns:android="http://schemas.android.com/apk/res/android" | |
android:shape="rectangle"> | |
<gradient | |
android:angle="0" | |
android:centerColor="#1976d2" | |
android:centerX="0.1" | |
android:centerY="0.1" | |
android:endColor="#6200ea" | |
android:gradientRadius="100" |
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 SyncWorker(c: Context, wp: WorkerParameters):Worker(c, wp) { | |
override fun doWork(): Result { | |
loadData() | |
return Result.success() | |
} | |
} |
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
val syncOnlyOnce = OneTimeWorkRequestBuilder<SyncWorker>().build() | |
val syncPeriodically = PeriodicWorkRequestBuilder<SyncWorker>(1, TimeUnit.HOURS).build() | |
val periodicRefreshRequest = PeriodicWorkRequest.Builder( | |
SyncWorker::class.java, // the worker class | |
30, // repeating interval | |
TimeUnit.Minutes, | |
15, // flex interval - worker will run somehow within this period of time, but at the end of repeating interval |
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
dependencies { | |
def work_version = "2.0.1" | |
// (Java only) | |
implementation "androidx.work:work-runtime:$work_version" | |
// Kotlin + coroutines | |
implementation "androidx.work:work-runtime-ktx:$work_version" | |
// optional - RxJava2 support |
OlderNewer