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
//--- | |
Observable | |
.just(1, 2, 3, 4, 5) | |
.filter(new Func1<Integer, Boolean>() { | |
@Override | |
public Boolean call(Integer integer) { | |
return integer % 2 != 0; | |
} | |
}).subscribe(new Observer<Integer>() { |
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
reduce(Math::max); |
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
reduce((int left, int right) -> Math.max(left, right)); |
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
reduce(new IntBinaryOperator() { | |
int applyAsInt(int left, int right) { | |
return Math.max(left, right); | |
} | |
}); |
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
public class MainActivity extends AppCompatActivity implements LoaderManager.LoaderCallbacks { | |
private int LOADER_ID = 1; | |
//... | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
//... | |
if (getLoaderManager().getLoader(LOADER_ID) == null) { |
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
public class ExampleTaskLoader extends AsyncTaskLoader<String> { | |
public ExampleTaskLoader(Context context) { | |
super(context); | |
onContentChanged(); | |
} | |
@Override | |
public String loadInBackground() { | |
return performBlockingTask(); |
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
//... | |
new AsyncTask<Void, Void, String>() { | |
@Override | |
protected void onPreExecute() { | |
//... | |
} | |
@Override | |
protected String doInBackground(Void... voids) { |
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
public class BackgroundService extends IntentService { | |
private static final String TAG = BackgroundService.class.getSimpleName(); | |
public BackgroundService() { | |
super(TAG ); | |
} | |
@Override | |
protected void onHandleIntent(Intent intent) { | |
blockingTask(); |
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
//... | |
final Handler handler = new Handler(); | |
final Runnable uiRunnable = new Runnable() { | |
@Override | |
public void run() { | |
mTextView.setText(mResult); | |
} | |
}; |
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
//... | |
Thread thread = new Thread(new Runnable() { | |
@Override | |
public void run() { | |
final String result = performBlockingTask(); | |
runOnUiThread(new Runnable() { | |
@Override | |
public void run() { |