This file contains hidden or 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.bluetooth.le.BluetoothLeScanner; | |
import android.bluetooth.le.ScanCallback; | |
import android.bluetooth.le.ScanResult; | |
import android.support.annotation.NonNull; | |
import rx.Emitter; | |
import rx.Observable; | |
import java.util.List; | |
public class RxBluetoothScanner { |
This file contains hidden or 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
public Observable<byte[]> readFile(@NonNull FileInputStream stream) { | |
final SyncOnSubscribe<FileInputStream, byte[]> fileReader = SyncOnSubscribe.createStateful( | |
() -> stream, | |
(stream, output) -> { | |
try { | |
final byte[] buffer = new byte[BUFFER_SIZE]; | |
int count = stream.read(buffer); | |
if (count < 0) { | |
output.onCompleted(); | |
} else { |
This file contains hidden or 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
public void touchEventHandler(@NotNull View view) { | |
final ConnectedObservable<MotionEvent> motionEventObservable = RxView.touches(view).publish(); | |
// Capture down events | |
final Observable<MotionEvent> downEventsObservable = motionEventObservable | |
.filter(event -> event.getAction() == MotionEvent.ACTION_DOWN); | |
// Capture up events | |
final Observable<MotionEvent> upEventsObservable = motionEventObservable | |
.filter(event -> event.getAction() == MotionEvent.ACTION_UP); | |
// Show a red circle at the position where the down event ocurred |
This file contains hidden or 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
#!/bin/bash | |
COUNT=0 | |
RENAME_FILE="enter_new_filename_%02d.png" | |
for FILE in *.png; do | |
mv "$FILE" $(printf $RENAME_FILE $COUNT) | |
let COUNT=COUNT+1 | |
done |
This file contains hidden or 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
public class MainActivity extends AppCompatActivity { | |
private static final String IMAGE_URL = "https://www.android.com/static/2016/img/logo-android-green_2x.png"; | |
private static final int MSG_SHOW_PROGRESS = 1; | |
private static final int MSG_SHOW_IMAGE = 2; | |
private ProgressBar progressIndicator; | |
private ImageView imageView; | |
private Handler handler; | |
class ImageFetcher implements Runnable { |
This file contains hidden or 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
public class MainActivity extends AppCompatActivity { | |
private static final String IMAGE_URL = "https://www.android.com/static/2016/img/logo-android-green_2x.png"; | |
private ProgressBar progressIndicator; | |
private ImageView imageView; | |
private Handler handler; | |
class ImageFetcher implements Runnable { | |
final String url; |
This file contains hidden or 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
public class MainActivity extends AppCompatActivity { | |
private static final String TAG = "Ping"; | |
private Handler handler; | |
class PingHandler extends Handler { | |
@Override | |
public void handleMessage(Message msg) { | |
Log.d(TAG, "Ping message received"); | |
} |
This file contains hidden or 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
public class MainActivity extends AppCompatActivity { | |
private static final String IMAGE_URL = "https://www.android.com/static/img/android.png"; | |
private static final int MSG_SHOW_PROGRESS = 1; | |
private static final int MSG_SHOW_IMAGE = 2; | |
private ProgressBar progressIndicator; | |
private ImageView imageView; | |
private Handler handler; |