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
package com.jakewharton.utilities; | |
import android.content.Context; | |
import android.graphics.drawable.Drawable; | |
import android.preference.CheckBoxPreference; | |
import android.util.AttributeSet; | |
import android.view.View; | |
import android.widget.ImageView; | |
import com.jakewharton.wakkawallpaper.R; |
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
package org.sazabi.lib.preference; | |
import android.content.Context; | |
import android.content.res.TypedArray; | |
import android.graphics.drawable.Drawable; | |
import android.preference.Preference; |
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
// Note that a shortcut is created automagically if the app is installed via Play store. | |
// Change "APP_NAME" by your app name. *MrObvious* | |
/*Manifest file - add this */ | |
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" /> | |
/* MainActivity.java */ | |
public class MainActivity ... { | |
... | |
private SharedPreferences appSettings; |
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.SharedPreferences | |
import android.preference.PreferenceManager | |
fun Context.getDefaultSharedPreferences(): SharedPreferences { | |
return PreferenceManager.getDefaultSharedPreferences(this) | |
} | |
fun SharedPreferences.clear() { | |
edit().clear().apply() |
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 ImageView.show(imageUrl: String = "") { | |
if (imageUrl.isBlank()) return | |
if (context == null) return | |
if (context is Activity && ((context as Activity).isFinishing || (context as Activity).isDestroyed)) return | |
Glide.with(context) | |
.load(imageUrl) | |
.crossFade() |
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 RealmHelper { | |
public static <T extends RealmObject> void save(T object) { | |
Realm realm = Realm.getDefaultInstance(); | |
try { | |
realm.beginTransaction(); | |
realm.copyToRealmOrUpdate(object); | |
realm.commitTransaction(); | |
} finally { | |
realm.close(); | |
} |
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 PostsDataSource(private val scope: CoroutineScope) : | |
PageKeyedDataSource<String, RedditPost>() { | |
private val apiService = ApiClient.getClient().create(ApiService::class.java) | |
override fun loadInitial(params: LoadInitialParams<String>, callback: LoadInitialCallback<String, RedditPost>) { | |
scope.launch { | |
try { | |
val response = apiService.fetchPosts(loadSize = params.requestedLoadSize) | |
when{ | |
response.isSuccessful -> { |
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
package com.berider.app.common.utils | |
import android.app.Activity | |
import android.content.Intent | |
import android.os.Bundle | |
import android.os.Parcelable | |
import android.view.inputmethod.InputMethodManager | |
import androidx.activity.OnBackPressedCallback | |
import androidx.appcompat.app.ActionBar | |
import androidx.appcompat.app.AppCompatActivity |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.