-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
170 changed files
with
3,246 additions
and
653 deletions.
There are no files selected for viewing
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
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
Binary file not shown.
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
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
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
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
58 changes: 29 additions & 29 deletions
58
app/src/main/java/org/stepic/droid/core/presenters/DiscussionPresenter.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,44 @@ | ||
package org.stepic.droid.core.presenters | ||
|
||
import org.stepic.droid.concurrency.MainHandler | ||
import io.reactivex.Scheduler | ||
import io.reactivex.disposables.CompositeDisposable | ||
import io.reactivex.rxkotlin.plusAssign | ||
import io.reactivex.rxkotlin.subscribeBy | ||
import org.stepic.droid.core.presenters.contracts.DiscussionView | ||
import org.stepic.droid.di.comment.CommentsScope | ||
import org.stepic.droid.web.Api | ||
import java.util.concurrent.ThreadPoolExecutor | ||
import org.stepic.droid.di.qualifiers.BackgroundScheduler | ||
import org.stepic.droid.di.qualifiers.MainScheduler | ||
import org.stepik.android.domain.discussion_proxy.interactor.DiscussionProxyInteractor | ||
import javax.inject.Inject | ||
|
||
@CommentsScope | ||
class DiscussionPresenter | ||
@Inject constructor( | ||
private val threadPoolExecutor: ThreadPoolExecutor, | ||
private val mainHandler: MainHandler, | ||
private val api: Api) : PresenterBase<DiscussionView>() { | ||
@Inject | ||
constructor( | ||
private val discussionProxyInteractor: DiscussionProxyInteractor, | ||
|
||
@BackgroundScheduler | ||
private val backgroundScheduler: Scheduler, | ||
@MainScheduler | ||
private val mainScheduler: Scheduler | ||
) : PresenterBase<DiscussionView>() { | ||
private val compositeDisposable = CompositeDisposable() | ||
|
||
fun loadDiscussion(discussionId: String) { | ||
threadPoolExecutor.execute { | ||
try { | ||
val discussionProxy = api | ||
.getDiscussionProxies(discussionId) | ||
.execute() | ||
.body() | ||
?.discussionProxies!! | ||
.first() | ||
if (discussionProxy.discussions.isEmpty()) { | ||
mainHandler.post { | ||
compositeDisposable.clear() | ||
compositeDisposable += discussionProxyInteractor | ||
.getDiscussionProxy(discussionId) | ||
.subscribeOn(backgroundScheduler) | ||
.observeOn(mainScheduler) | ||
.subscribeBy( | ||
onSuccess = { discussionProxy -> | ||
if (discussionProxy.discussions.isEmpty()) { | ||
view?.onEmptyComments(discussionProxy) | ||
} | ||
} else { | ||
mainHandler.post { | ||
} else { | ||
view?.onLoaded(discussionProxy) | ||
} | ||
} | ||
} catch (exception: Exception) { | ||
mainHandler.post { | ||
view?.onInternetProblemInComments() | ||
} | ||
} | ||
} | ||
|
||
}, | ||
onError = { view?.onInternetProblemInComments() } | ||
) | ||
} | ||
|
||
} |
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package org.stepic.droid.fonts | ||
|
||
enum class FontType { | ||
regular, italic, bold, boldItalic, medium, light | ||
regular, italic, bold, boldItalic, medium, light, | ||
|
||
mono | ||
} |
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
Oops, something went wrong.