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
data class LoginDetails(val email: String? = null, val username: String? = null) { | |
companion object { | |
val empty = LoginDetails() | |
} | |
val isPresent get() = email != null && username != 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 final class PersistedLoginDetailsRepository implements LoginDetailsRepository { | |
private static final String PREVIOUS_EMAIL_KEY = "prev_email"; | |
private static final String LOGIN_METHOD = "login_method"; | |
private final RxPaperBook persistence; | |
private final BehaviorRelay<LoginDetails> detailsRelay = BehaviorRelay.create(); | |
private final BehaviorRelay<LoginMethod> methodRelay = BehaviorRelay.create(); | |
public PersistedLoginDetailsRepository(final @NonNull RxPaperBook persistence) { |
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 final class LoginDetails { | |
private final String email; | |
private final String username; | |
public LoginDetails(@Nullable final String email, @Nullable final String username) { | |
this.email = email; | |
this.username = username; | |
} |
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
package com.squareup.kotlinpoet | |
import java.util.* | |
import javax.lang.model.element.Modifier | |
/** Operator overloads for concise building. */ | |
/** ParameterSpec operators */ | |
@JvmName("plusAssignAnnotationSpecs") |
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 SomeActivity extends AppCompatActivity implements LifecycleEmittingActivity { | |
Subject<ActivityLifecycleEvent> lifecycleEvents = BehaviorSubject.create(); | |
@Override | |
public Observable<ActivityLifecycleEvent> getLifecycleEvents() { | |
return lifecycleEvents.hide(); | |
} | |
@Override |
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 enum ActivityLifecyleEvent { | |
CREATED, | |
STARTED, | |
RESUMED, | |
PAUSED, | |
STOPED, | |
DESTROYED | |
} |
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 interface LifecycleEmittingActivity { | |
Observable<ActivityLifecycleEvent> getLifecycleEvents(); | |
} |
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 void onCreate(Bundle savedInstanceState); | |
public void onStart(); | |
public void onResume(); | |
public void onPause(); | |
public void onStop(); | |
public void onDestroy(); |
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 Single<Optional<String>> getFileAsJsonString(String fileName) { | |
return Single.just(fileToString(fileName)); | |
} | |
private Optional<String> fileToString(String fileName) { | |
try { | |
InputStream inputStream = assetManager.open(fileName); | |
return Optional.of(CharStreams.toString(new InputStreamReader( | |
inputStream, Charsets.UTF_8))); | |
} catch (IOException exception) { |
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
Completable close() { | |
return Completable.fromAction(() -> assetManager.close()); | |
} |