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
/** | |
* Fast Campus 안드로이드 앱 개발 입문 캠프 | |
* Java for Android (by mindwing) | |
* [5일차] 강의노트 | |
* 도전과제3 - 주어진 라인수만큼 직각삼각형 모양 출력 | |
*/ | |
public class D5_Challenge_3 { | |
public static void main(String[] args) { | |
} | |
} |
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 AgeraActivity extends Activity | |
implements Receiver<Bitmap>, Updatable { | |
private static final ExecutorService NETWORK_EXECUTOR = | |
newSingleThreadExecutor(); | |
private static final ExecutorService DECODE_EXECUTOR = | |
newSingleThreadExecutor(); | |
private static final String BACKGROUND_BASE_URL = | |
"http://www.gravatar.com/avatar/4df6f4fe5976df17deeea19443d4429d?s="; | |
private Repository<Result<Bitmap>> background; |
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 MyUpdatableActivity extends Activity implements Updatable { | |
private Observable observable; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
observable = new MyObservable(); | |
} | |
@Override |
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
// For type clarity only, the following are smaller, reused operators: | |
Function<String, DataBlob> urlToBlob = …; | |
Function<DataBlob, List<ItemBlob>> blobToItemBlobs = …; | |
Predicate<ItemBlob> activeOnly = …; | |
Function<ItemBlob, UiModel> itemBlobToUiModel = …; | |
Function<List<UiModel>, List<UiModel>> sortByDateDesc = …; | |
Function<String, List<UiModel>> urlToUiModels = | |
Functions.functionFrom(String.class) | |
.apply(urlToBlob) |
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 ViewClickedObservable extends BaseObservable | |
implements View.OnClickListener { | |
@Override | |
public void onClick(View v) { | |
dispatchUpdate(); | |
} | |
} |
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 final class MyListenable extends SomeBaseClass implements Observable { | |
private final UpdateDispatcher updateDispatcher; | |
public MyListenable() { | |
// Original constructor code here... | |
updateDispatcher = Observables.updateDispatcher(new Bridge()); | |
} | |
// Original class body here... including: |
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 NetworkCallingSupplier implements Supplier<Result<ResponseBlob>> { | |
private final RequestBlob request = …; | |
@Override | |
public Result<ResponseBlob> get() { | |
try { | |
ResponseBlob blob = networkStack.execute(request); // blocking call | |
return Result.success(blob); | |
} catch (Throwable e) { | |
return Result.failure(e); |
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
// MutableRepository<RequestBlob> requestVariable = | |
// mutableRepository(firstRequest); | |
// OR: | |
MutableRepository<Result<RequestBlob>> requestVariable = | |
mutableRepository(Result.<RequestBlob>absent()); |
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 NetworkCallingFunction | |
implements Function<RequestBlob, Result<ResponseBlob>> { | |
@Override | |
public Result<ResponseBlob> apply(RequestBlob request) { | |
try { | |
ResponseBlob blob = networkStack.execute(request); | |
return Result.success(blob); | |
} catch (Throwable e) { | |
return Result.failure(e); | |
} |
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
Result<ResponseBlob> noResponse = Result.absent(); | |
Function<Throwable, Result<ResponseBlob>> withNoResponse = | |
Functions.staticFunction(noResponse); | |
Repository<Result<ResponseBlob>> responseRepository = | |
Repositories.repositoryWithInitialValue(noResponse) | |
.observe(requestVariable) | |
.onUpdatesPerLoop() | |
// .getFrom(requestVariable) if it does not supply Result, OR: | |
.attemptGetFrom(requestVariable).orEnd(withNoResponse) | |
.goTo(networkingExecutor) |