This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require("http"), | |
url = require("url"), | |
path = require("path"), | |
fs = require("fs") | |
port = process.argv[2] || 8888; | |
http.createServer(function(request, response) { | |
var uri = url.parse(request.url).pathname | |
, filename = path.join(process.cwd(), uri); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override protected void onPause() { | |
super.onPause(); | |
if (subscription != null && !subscription.isUnsubscribed()) { | |
subscription.unsubscribe(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
info = (TextView) findViewById(R.id.info); | |
swipe = new Swipe(); | |
subscription = swipe.observe() | |
.subscribeOn(Schedulers.computation()) | |
.observeOn(AndroidSchedulers.mainThread()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override public boolean dispatchTouchEvent(MotionEvent event) { | |
swipe.dispatchTouchEvent(event); | |
return super.dispatchTouchEvent(event); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
info = (TextView) findViewById(R.id.info); | |
swipe = new Swipe(); | |
swipe.addListener(new SwipeListener() { | |
@Override public void onSwipingLeft(final MotionEvent event) { | |
info.setText("SWIPING_LEFT"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find ~/ -type f -name "myfile.xml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override protected void onCreate(Bundle savedInstanceState) { | |
recyclerView = (RecyclerView) findViewById(R.id.recycler_view); | |
layoutManager = new LinearLayoutManager(this); | |
recyclerView.setHasFixedSize(true); | |
recyclerView.setLayoutManager(layoutManager); | |
// set your custom adapter | |
recyclerView.setAdapter(new MyAdapter(items)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private InfiniteScrollListener createInfiniteScrollListener() { | |
return new InfiniteScrollListener(maxItemsPerRequest, layoutManager) { | |
@Override public void onScrolledToEnd(final int firstVisibleItemPosition) { | |
// load your items here | |
// logic of loading items will be different depending on your specific use case | |
// when new items are loaded, combine old and new items, pass them to your adapter | |
// and call refreshView(...) method from InfiniteScrollListener class to refresh RecyclerView | |
refreshView(recyclerView, new MyAdapter(items), firstVisibleItemPosition); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import rx.Observable; | |
import rx.subjects.PublishSubject; | |
import rx.subjects.SerializedSubject; | |
import rx.subjects.Subject; | |
/** | |
* Simple pass-thru event bus with error handling and reconnect. | |
*/ | |
public class EventBus { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import org.androidannotations.annotations.EBean; | |
public class MyAdapter extends SimpleListAdapter<String, TextView> { | |
public MyAdapter(Context ctx) { | |
super(ctx); | |
} |