Skip to content

Instantly share code, notes, and snippets.

🤔
Fighting Proguard

Gabor Varadi Zhuinden

🤔
Fighting Proguard
Block or report user

Report or block Zhuinden

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View InvertViewLayout.kt
package com.davidmedenjak.overlappinginvertview
import android.content.Context
import android.graphics.*
import android.util.AttributeSet
import android.view.View
import android.widget.FrameLayout
class InvertViewLayout(context: Context, attrs: AttributeSet? = null) : FrameLayout(context, attrs) {
@Zhuinden
Zhuinden / monarchy-article-room.java
Last active Dec 22, 2017
Monarchy article: Room
View monarchy-article-room.java
@Query("SELECT * FROM " + Task.TABLE_NAME +
" ORDER BY " + Task.COLUMN_DATE + " ASC ")
LiveData<List<Task>> tasksSortedByDate();
tasksSortedByDate().observe(this, (newTasks) -> {
adapter.updateData(newTasks);
});
@Zhuinden
Zhuinden / monarchy-article-realm.java
Last active Dec 22, 2017
Monarchy article: RealmResults
View monarchy-article-realm.java
RealmResults<Task> tasksSortedByDate = realm.where(Task.class)
.findAllSorted(TaskFields.DATE, Sort.ASCENDING);
tasksSortedByDate.addChangeListener((newTasks) -> {
adapter.updateData(newTasks);
});
@Zhuinden
Zhuinden / monarchy-managed.java
Last active Dec 22, 2017
Monarchy 3: Managed
View monarchy-managed.java
public class MainActivity
extends AppCompatActivity {
ManagedDogAdapter managedDogAdapter;
LiveData<Monarchy.ManagedChangeSet<RealmDog>> changes;
Observer<Monarchy.ManagedChangeSet<RealmDog>> observer =
changes -> {
managedDogAdapter.updateData(changes);
};
View monarchy-mapped.java
public class MainActivity
extends AppCompatActivity {
MappedDogAdapter mappedDogAdapter;
LiveData<List<Dog>> dogs;
Observer<List<Dog>> observer = dogs -> {
mappedDogAdapter.updateData(dogs);
};
@BindView(R.id.recycler_view)
@Zhuinden
Zhuinden / monarchy-example.java
Last active Dec 22, 2017
Monarchy 1: live data + realm
View monarchy-example.java
LiveData<List<Dog>> results = monarchy.findAllMappedWithChanges(
realm -> realm.where(RealmDog.class),
realmDog -> Dog.create(realmDog.getName())); // `Dog` is immutable
results.observe(this, (dogs) -> {
adapter.updateData(dogs);
});
@Zhuinden
Zhuinden / auto-generated-kotlin.kt
Created Oct 14, 2017
Auto-generated Kotlin @Inject constructor vs style proposition
View auto-generated-kotlin.kt
@Singleton
class EventDao @Inject
constructor(databaseManager: DatabaseManager, table: EventTable, private val sportDao: SportDao, private val locationDao: LocationDao) : BaseDao<Event>(databaseManager, table) {
@Zhuinden
Zhuinden / kotlin-wtf.kt
Created Oct 14, 2017
Tinkering with Kotlin's infix
View kotlin-wtf.kt
class ResultRobot {
fun isSuccess() : Boolean = true;
infix fun validate(function: ResultRobot.() -> Unit) : ResultRobot {
return apply {
function.invoke(this)
};
}
}
@Zhuinden
Zhuinden / task-view-model.java
Last active Jul 29, 2017
MVVM sample: reactive data access example
View task-view-model.java
public class TasksViewModel
extends BaseObservable
implements Observer<List<Task>> {
@Inject
TasksViewModel(...) {
//...
}
private LiveResults<Task> liveResults;
@Zhuinden
Zhuinden / task-detail-view-model.java
Last active Mar 4, 2018
MVVM sample: TaskDetailViewModel
View task-detail-view-model.java
// UNSCOPED
public class TaskDetailViewModel
extends SingleTaskViewModel {
private final Backstack backstack;
private final MessageQueue messageQueue;
@Inject
TaskDetailViewModel(Context context, TasksRepository tasksRepository,
Backstack backstack, MessageQueue messageQueue) {
super(context, tasksRepository);
You can’t perform that action at this time.