Raw service with bindings

Categories: ANDROID like

public class Request2Service extends Service { public static final int MSG_REGISTER_WATCHER = -1; public static final int MSG_UNREGISTER_WATCHER = -2; private ArrayList<Messenger> clients = new ArrayList<>(); private Messenger clientMessenger = new Messenger(new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case MSG_REGISTER_WATCHER: if (!clients.contains(msg.replyTo)) { clients.add(msg.replyTo); } break; case MSG_UNREGISTER_WATCHER: if (clients.contains(msg.replyTo)) […]

Example how to hide and show floating action button while scrolling the list (code not optimized well)

Categories: ANDROID like

//this example is for recyclerView but it can be used somewhere else recyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); } @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); if (dy > 0) { hideFab(); } else if (dy < 0) { showFab(); } } […]