Guest User

Untitled

a guest
Mar 24th, 2018
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 2.01 KB | None | 0 0
  1.  
  2.  
  3. ///// METHOD IN PRESENTER 1
  4.  
  5.     private fun mapCarsToFavorites(wishList: List<GetWishResponse>) {
  6.         carsRepository.mapCarsToFavorites(wishList, { wishItem, favorite ->
  7.             wishItem.id == favorite.id
  8.         }, { wishItem, _ ->
  9.             wishItem.is_favorite = true
  10.             wishItem
  11.         }).subscribeOn(backgroundScheduler)
  12.             .observeOn(mainScheduler)
  13.             .subscribe(
  14.                 { finalMappedWish ->
  15.                     (view as? LaunchSearchActivityView)?.openSearchDetailsActivity(
  16.                         ArrayList(finalMappedWish)
  17.                     )
  18.                     (view as? SearchHistoryFragmentView)?.openSearchDetailsActivity(
  19.                         ArrayList(finalMappedWish)
  20.                     )
  21.                 },
  22.                 { error ->
  23.                     Utils.logToCrashlytics(
  24.                         this.javaClass.simpleName,
  25.                         "Error getting Car Static Trims ${error.message}"
  26.                     )
  27.                 }
  28.             )
  29.     }
  30.  
  31.  
  32. /////// METHOD IN PRESENTER 2
  33.  
  34.     private fun mapCarsToFavorites(mappedDeals: List<HotDealsResponse>) {
  35.         carsRepository.mapCarsToFavorites(mappedDeals, { hotDeal, favorite ->
  36.             hotDeal.id == favorite.id
  37.         }, { hotDeal, _ ->
  38.             hotDeal.favorite = true
  39.             hotDeal
  40.         }).subscribeOn(backgroundScheduler)
  41.             .observeOn(mainScheduler)
  42.             .subscribe(
  43.                 { finalMappedDeal ->
  44.                     view.displayHotDeals(ArrayList(finalMappedDeal))
  45.                 },
  46.                 { error ->
  47.                     Utils.logToCrashlytics(
  48.                         this.javaClass.simpleName,
  49.                         "Error getting Car Static Trims ${error.message}"
  50.                     )
  51.                 }
  52.             )
  53.     }
  54.  
  55. When method of first presenter is called at least once, method 2 of presenter 2 starts jumping to it whenever its time to call its own similar method, and the code in both runs
Add Comment
Please, Sign In to add comment