Skip to content

Instantly share code, notes, and snippets.

View OrenBochman's full-sized avatar
🏠
Working from home

Oren Bochman OrenBochman

🏠
Working from home
  • WMF
  • 12:55 (UTC +03:00)
View GitHub Profile
@OrenBochman
OrenBochman / Search my gists.md
Last active August 28, 2024 21:07 — forked from santisbon/Search my gists.md
How to search gists

Gist Search Cheatsheet

Enter this in the search box along with your search terms:

Get all gists from the user santisbon.
user:orenbochman

Find all gists with a .yml extension.
extension:yml

@OrenBochman
OrenBochman / !!android annotation.md
Last active September 9, 2018 09:19
annotation guide
@OrenBochman
OrenBochman / !!_swipe to refresh.md
Last active September 9, 2018 15:21
android swipe to refresh
@OrenBochman
OrenBochman / !!Android_Recycler_deviders.md
Last active September 9, 2018 15:13
Adding dividers to a RecyclerView

RecyclerView - Adding Dividers

How to add deviders between recyclerview items.

Based on the book Pro Android UI.

@OrenBochman
OrenBochman / !!adding_swipe_to_dismiss.md
Last active September 9, 2018 15:22
Recycler - adding swipe to dismiss/accept

RecyclerView - Swipe to dismiss/accept

@OrenBochman
OrenBochman / !!AdaptiveFragmentUI.md
Last active September 9, 2018 15:04
Android Master Detail

Advanced Fragment Example - Master/Detail with a Strategy Factory

Implementing Master/Detail with:

  • adaptive master_detail with a handset breakpoint
  • a controller factory.
  • Interface based contract between fragment/activity/controller whie keeping them decoupled

    • main activity with implements the intererface for
@OrenBochman
OrenBochman / !!readme.md
Last active September 10, 2018 16:43
Handler - schedule periodic tasks in Android

Handler - Stub

Use a Handler to run code on a given thread after a delay or repeat tasks periodically on a thread.

  1. constructing a Handler and then
  2. "posting" Runnable code to the event message queue on the thread to be processed

Handler can communicate with UI-thread

handler.post(); handler.postAtFrontOfQueue();

@OrenBochman
OrenBochman / !!readme.md
Last active September 10, 2018 08:45
AsyncTask how-to in Android

AsyncTask

When to use this threading primitive?

  1. for short (say up to 3 seconds) background tasks that would otherwise block the UI thread
  2. thread abstraction
  3. easy implimentation
  4. easy ui communication

Caveats:

  1. not lifecycle aware
@OrenBochman
OrenBochman / !!readme.md
Last active September 10, 2018 14:44
Treads Android

Threads - in Android

UI and Worker thread access

Android does not allow to access the UI from a worker tread.

This shows how to access the UI thread from a Worker thread. The following are some methods to access the UI.thread:

  • Activity.runOnUiThread(Runnable)
@OrenBochman
OrenBochman / !!readme.md
Last active September 10, 2018 20:20
HandlerThread in Android

HandlerThread in Android

The HandlerThread is a convenience class that initiates a Looper within a Thread to process Runnable or Message objects. The Handler is used to handle the insertion of the Runnable or Message objects into the looper's queue: The Handler class supports several other ways to schedule a Message to be processed at a future time:

Queueing tasks

  • sendMessage - Pushes a message onto the end of the message queue.
  • sendMessageDelayed - Pushes a message onto the end of the message queue.