Skip to content

Instantly share code, notes, and snippets.

View alvindizon's full-sized avatar
🎯
Focusing

Alvin Dizon alvindizon

🎯
Focusing
View GitHub Profile
@paraya3636
paraya3636 / KotlinAndroidMainApplication
Last active July 20, 2024 03:28
Kotlin Android MainApplication class for global applicationContext.
// Not object class. AndroidManifest.xml error happen.
class MainApplication : Application() {
init {
instance = this
}
companion object {
private var instance: MainApplication? = null
@cbeyls
cbeyls / MultiChoiceHelper.java
Last active October 28, 2024 18:23
Helper class to reproduce ListView's modal MultiChoice mode with a RecyclerView. Compatible with API 7+.
package be.digitalia.common.widgets;
import android.content.Context;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.support.v4.util.LongSparseArray;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.view.ActionMode;
public class ObservableTest {
@Test
public void observable_withRecursion_returnsAllObjects() {
final int maxPageNum = 15;
getIntegers(1, 5, maxPageNum)
.subscribe(System.out::println);
}
private Observable<Integer> getIntegers(final int pageStart, final int pageSize, final int maxPageNum) {
@davinctor
davinctor / RetryWithDelayTransformer.java
Last active February 3, 2020 23:39
Observable.Transformer to add retry feature to source observable if it fails. Every retry can be delayed.
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import com.petcube.android.helpers.Log;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import rx.Subscriber;
@dseerapu
dseerapu / gist:b768728b3b4ccf282c7806a3745d0347
Last active October 25, 2022 15:04
Android app inactivity timeout | Android Logout timer
public class LogOutTimerUtil {
public interface LogOutListener {
void doLogout();
}
static Timer longTimer;
static final int LOGOUT_TIME = 600000; // delay in milliseconds i.e. 5 min = 300000 ms or use timeout argument
public static synchronized void startLogoutTimer(final Context context, final LogOutListener logOutListener) {
@Pulimet
Pulimet / AdbCommands
Last active June 7, 2025 16:10
Adb useful commands list
Hi All!
I've recently launched a tool that wraps many of the commands here with a user interface. This desktop application is currently available for macOS. There's a roadmap outlining planned features for the near future.
Feel free to request any features you'd like to see, and I'll prioritize them accordingly.
One of the most important aspects of this application is that every command executed behind the scenes is displayed in a special log section. This allows you to see exactly what’s happening and learn from it.
Here's the link to the repository: https://github.com/Pulimet/ADBugger
App Description:
ADBugger is a desktop tool designed for debugging and QA of Android devices and emulators. It simplifies testing, debugging, and performance analysis by offering device management, automated testing, log analysis, and remote control capabilities. This ensures smooth app performance across various setups.
@JoseAlcerreca
JoseAlcerreca / Event.kt
Created April 26, 2018 10:25
An event wrapper for data that is exposed via a LiveData that represents an event.
/**
* Used as a wrapper for data that is exposed via a LiveData that represents an event.
*/
open class Event<out T>(private val content: T) {
var hasBeenHandled = false
private set // Allow external read but not write
/**
* Returns the content and prevents its use again.
@clxy
clxy / AppDao.java
Last active February 25, 2024 03:26
Android Room Generic Dao
import android.arch.persistence.db.SimpleSQLiteQuery;
import android.arch.persistence.db.SupportSQLiteQuery;
import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Delete;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.OnConflictStrategy;
import android.arch.persistence.room.RawQuery;
import java.lang.reflect.ParameterizedType;
import java.util.List;
@G00fY2
G00fY2 / CustomRxJava2CallAdapterFactory.java
Last active October 2, 2024 04:13
CustomRxJava2CallAdapterFactory to transform HttpExceptions to custom error
import com.google.gson.Gson;
import io.reactivex.Completable;
import io.reactivex.Flowable;
import io.reactivex.Maybe;
import io.reactivex.MaybeSource;
import io.reactivex.Observable;
import io.reactivex.ObservableSource;
import io.reactivex.Scheduler;
import io.reactivex.Single;
import java.lang.annotation.Annotation;
@volodia-chornenkyy
volodia-chornenkyy / detektGrabSubprojectsReports.groovy
Created January 17, 2020 16:27
Gradle task which gathers all Detekt reports from the subprojects and put it in the one folder "$rootDir/reports/detekt". It simplifies CI process a bit.
task detektGrabSubprojectsReports {
group = "Verification"
def detektSingleReportFolder = "$rootDir/reports/detekt"
def detektGeneralFolder = new File(detektSingleReportFolder)
detektGeneralFolder.mkdirs();
subprojects.findAll { subproject ->
def projectReportDir = "$subproject.buildDir/reports"
def detektReportFiles = [
"detekt.xml",