Skip to content

Instantly share code, notes, and snippets.

@florent37
florent37 / onclick.java
Created Aug 14, 2015
RecyclerView.OnClick
View onclick.java
public class OnItemClickListener(){
onItemClicked(int position, ViewHolder viewHolder);
}
recyclerView.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
GestureDetector mGestureDetector;
@Override
public boolean onInterceptTouchEvent(RecyclerView view, MotionEvent e) {
@florent37
florent37 / id.java
Last active Feb 8, 2016
Freezer ID
View id.java
@Model
public class User {
String name;
}
public class UserEntity extends User implements DataBaseModel {
long _id;
public long getDatabaseModelId() {
return _id;
View select.java
UserEntityManager userEntityManager = new UserEntityManager();
List<User> users = userEntityManager.select()
.fields(UserColumn.name, UserColumn.age)
.age().equals(3)
.asList();
List<String> usersNames = userEntityManager.select()
.field(UserColumn.name)
.asList();
View freezerasync.java
#ADD
interface Callback<T>{
void onSuccess();
void onError(T data);
}
userEntityManager.addAsync(List<User> users, new Callback<List<User>>{
void onSuccess(){}
void onError(List<User> data){}
View zelda.java
public class MyView extends FrameLayout{
@Link int color = Color.Black;
@Link("content") String content;
@Link(android.R.attr.text) String text;
public MyView(Context, Attrs){
Zelda.initialise(context, attrs);
}
View youtube_videos.json
[
{
"name" : "1",
"imageUrl" : "https://gist.github.com/",
"url" : "https://gist.github.com/"
}
]
@florent37
florent37 / MaterialViewPager_Todo.md
Last active Jul 10, 2016
TODO MaterialViewPager
View MaterialViewPager_Todo.md

#TODO

  • Add an attribute for Parallax interpolator (1.5f by default)
    MaterialViewPagerAnimator line 170
  • Add an attribute for Header margin bottom (10 dp default)
    MaterialViewPager line 163
View RxJavaSchedulersTestRule.java
public class RxJavaSchedulersTestRule implements TestRule {
@Override
public Statement apply(final Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
resetPlugins();
RxJavaPlugins.getInstance().registerSchedulersHook(new TestRxJavaSchedulersHook());
RxAndroidPlugins.getInstance().registerSchedulersHook(new TestRxAndroidSchedulersHook());
View recyclerview_notify.java
protected void notifyChange(int oldCount, int newCount) {
if (newCount == oldCount) {
notifyItemRangeChanged(0, newCount);
} else if (newCount < oldCount) {
notifyItemRangeChanged(0, newCount);
notifyItemRangeRemoved(newCount, oldCount);
} else { //newCount > oldCount
notifyItemRangeChanged(0, oldCount);
notifyItemRangeInserted(oldCount + 1, newCount);
View RxBus.java
package fr.creditagricole.cats.dcpa.bus;
import java.util.concurrent.TimeUnit;
import fr.creditagricole.cats.dcpa.bus.events.DefinirEtatClickableBoutonsEvent;
import fr.creditagricole.cats.dcpa.bus.events.Getter;
import fr.creditagricole.cats.dcpa.bus.events.ValiderModificationAutresImpotEvent;
import fr.creditagricole.cats.dcpa.data.model.PensionRetraite;
import rx.Observable;
import rx.Subscriber;