Skip to content

Instantly share code, notes, and snippets.

View florent37's full-sized avatar

Florent CHAMPIGNY florent37

View GitHub Profile
@florent37
florent37 / onclick.java
Created August 14, 2015 07:34
RecyclerView.OnClick
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 February 8, 2016 12:39
Freezer ID
@Model
public class User {
String name;
}
public class UserEntity extends User implements DataBaseModel {
long _id;
public long getDatabaseModelId() {
return _id;
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();
#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){}
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);
}
[
{
"name" : "1",
"imageUrl" : "https://gist.github.com/",
"url" : "https://gist.github.com/"
}
]
@florent37
florent37 / MaterialViewPager_Todo.md
Last active July 10, 2016 18:19
TODO MaterialViewPager

#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
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());
@florent37
florent37 / recyclerview_notify.java
Last active February 24, 2017 15:48
Recyclerview notify
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);
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;