Skip to content

Instantly share code, notes, and snippets.

View AungThiha's full-sized avatar

Aung Thiha AungThiha

View GitHub Profile
public interface PromotionService {
@GET("/promotions")
Observable<List<Promotion>> fetchPromotions();
@GET("/promotions/{promotion_id}/sales")
Observable<List<Sale>> fetchSales(@Path("promotion_id") long promotionId);
@GET("/promotions/{promotion_id}/ads")
Observable<List<Ad>> fetchAds(@Path("promotion_id") long promotionId);
public class PromotionRepository {
private PromotionService promotionService;
@Inject
public PromotionRepository(PromotionService promotionService) {
this.promotionService = promotionService;
}
public Observable<List<Promotion>> fetchPromotions(){
public class PromotionPresenter implements PromotionContract.Presenter {
PromotionContract.View view;
PromotionRepository repository;
private CompositeDisposable disposeBag;
@Inject
public PromotionPresenter(PromotionRepository repository){
this.repository = repository;
@AungThiha
AungThiha / Optional.java
Created November 21, 2018 15:20
written based on Java 8 Optional to support Android API Level lower than 24
public class Optional<M> {
/**
* Common instance for {@code empty()}.
*/
private static final Optional<?> EMPTY = new Optional<>(null);
private final M value;
public Optional(@Nullable M value) {
public interface PromotionService {
@GET("/promotions")
Observable<Response<List<Promotion>>> fetchPromotions();
@GET("/promotions/{promotion_id}/sales")
Observable<Response<List<Sale>>> fetchSales(@Path("promotion_id") long promotionId);
@GET("/promotions/{promotion_id}/ads")
Observable<Response<List<Ad>>> fetchAds(@Path("promotion_id") long promotionId);
public class PromotionRepository {
private PromotionService promotionService;
@Inject
public PromotionRepository(PromotionService promotionService) {
this.promotionService = promotionService;
}
public Observable<Optional<List<Promotion>>> fetchPromotions(){
public class PromotionPresenter implements PromotionContract.Presenter {
PromotionContract.View view;
PromotionRepository repository;
private CompositeDisposable disposeBag;
@Inject
public PromotionPresenter(PromotionRepository repository){
this.repository = repository;
import io.reactivex.android.plugins.RxAndroidPlugins
import io.reactivex.plugins.RxJavaPlugins
import io.reactivex.schedulers.Schedulers
import okhttp3.MediaType
import okhttp3.ResponseBody
import org.junit.Before
import org.junit.Test
import org.mockito.ArgumentMatchers.any
import org.mockito.Mock
import org.mockito.Mockito
@OptIn(ExperimentalMotionApi::class)
@Composable
fun RecipeDetail(
modifier: Modifier = Modifier
) {
val motionSceneContent = remember { "" }
MotionLayout(
motionScene = MotionScene(motionSceneContent),
progress = 0f,
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MyApplicationTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {