Skip to content

Commit

Permalink
Merge branch 'release/v0.9.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
djkovrik committed Mar 11, 2018
2 parents 6c06171 + 0ad9ada commit 956a655
Show file tree
Hide file tree
Showing 35 changed files with 168 additions and 147 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ dependencies {
implementation presentationDependencies.materialTypeface
implementation presentationDependencies.materialDialogs
implementation presentationDependencies.materialDialogsCommons
implementation presentationDependencies.toasty
implementation presentationDependencies.photoView
implementation presentationDependencies.tsnackbar

kapt presentationDependencies.daggerCompiler
kapt presentationDependencies.daggerAndroidCompiler
Expand Down
12 changes: 0 additions & 12 deletions app/src/main/java/com/sedsoftware/yaptalker/YapTalkerApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader
import com.mikepenz.materialdrawer.util.DrawerImageLoader
import com.sedsoftware.yaptalker.commons.CrashReportingTree
import com.sedsoftware.yaptalker.di.DaggerAppComponent
import com.sedsoftware.yaptalker.presentation.extensions.color
import com.squareup.leakcanary.LeakCanary
import com.squareup.picasso.Picasso
import dagger.android.AndroidInjector
import dagger.android.DispatchingAndroidInjector
import dagger.android.HasActivityInjector
import es.dmoral.toasty.Toasty
import timber.log.Timber
import javax.inject.Inject

Expand All @@ -43,7 +41,6 @@ class YapTalkerApp : Application(), HasActivityInjector {
DaggerAppComponent.builder().create(this).inject(this)

initTimber()
initToasty()
initMaterialDrawerImageLoader()
}

Expand All @@ -60,15 +57,6 @@ class YapTalkerApp : Application(), HasActivityInjector {
}
}

private fun initToasty() {
Toasty.Config.getInstance()
.setErrorColor(color(R.color.toastyColorError))
.setInfoColor(color(R.color.toastyColorInfo))
.setSuccessColor(color(R.color.toastyColorSuccess))
.setWarningColor(color(R.color.toastyColorWarning))
.apply()
}

private fun initMaterialDrawerImageLoader() {
DrawerImageLoader.init(object : AbstractDrawerImageLoader() {
override fun set(imageView: ImageView?, uri: Uri?, placeholder: Drawable?, tag: String?) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
package com.sedsoftware.yaptalker.presentation.extensions

import android.support.annotation.ColorRes
import android.support.v7.app.AppCompatActivity
import android.widget.Toast
import es.dmoral.toasty.Toasty
import android.widget.TextView
import com.androidadvance.topsnackbar.TSnackbar
import com.sedsoftware.yaptalker.R

fun AppCompatActivity.toastError(message: String) {
Toasty.error(this, message, Toast.LENGTH_SHORT, true).show()
fun AppCompatActivity.snackError(message: String) {
showTopSnackbar(message, R.color.snackColorError, R.color.snackColorText)
}

fun AppCompatActivity.toastSuccess(message: String) {
Toasty.success(this, message, Toast.LENGTH_SHORT, true).show()
fun AppCompatActivity.snackSuccess(message: String) {
showTopSnackbar(message, R.color.snackColorSuccess, R.color.snackColorText)
}

fun AppCompatActivity.toastInfo(message: String) {
Toasty.info(this, message, Toast.LENGTH_SHORT, true).show()
fun AppCompatActivity.snackInfo(message: String) {
showTopSnackbar(message, R.color.snackColorInfo, R.color.snackColorText)
}

fun AppCompatActivity.toastWarning(message: String) {
Toasty.warning(this, message, Toast.LENGTH_SHORT, true).show()
fun AppCompatActivity.snackWarning(message: String) {
showTopSnackbar(message, R.color.snackColorWarning, R.color.snackColorText)
}

fun AppCompatActivity.showTopSnackbar(message: String, @ColorRes bgColor: Int, @ColorRes textColor: Int) {
TSnackbar
.make(findViewById(R.id.content_container), message, TSnackbar.LENGTH_SHORT)
.also { snackbar -> snackbar.view.setBackgroundColor(color(bgColor)) }
.also { snackbar ->
(snackbar.view.findViewById(com.androidadvance.topsnackbar.R.id.snackbar_text) as? TextView)
?.setTextColor(color(textColor))
}
.show()
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,36 @@
package com.sedsoftware.yaptalker.presentation.extensions

import android.support.annotation.ColorRes
import android.support.v4.app.Fragment
import android.widget.Toast
import es.dmoral.toasty.Toasty
import android.widget.TextView
import com.androidadvance.topsnackbar.TSnackbar
import com.sedsoftware.yaptalker.R

fun Fragment.toastError(message: String) {
context?.let { Toasty.error(it, message, Toast.LENGTH_SHORT, true).show() }
fun Fragment.snackError(message: String) {
showTopSnackbar(message, R.color.snackColorError, R.color.snackColorText)
}

fun Fragment.toastSuccess(message: String) {
context?.let { Toasty.success(it, message, Toast.LENGTH_SHORT, true).show() }
fun Fragment.snackSuccess(message: String) {
showTopSnackbar(message, R.color.snackColorSuccess, R.color.snackColorText)
}

fun Fragment.toastInfo(message: String) {
context?.let { Toasty.info(it, message, Toast.LENGTH_SHORT, true).show() }
fun Fragment.snackInfo(message: String) {
showTopSnackbar(message, R.color.snackColorInfo, R.color.snackColorText)
}

fun Fragment.toastWarning(message: String) {
context?.let { Toasty.warning(it, message, Toast.LENGTH_SHORT, true).show() }
fun Fragment.snackWarning(message: String) {
showTopSnackbar(message, R.color.snackColorWarning, R.color.snackColorText)
}

fun Fragment.showTopSnackbar(message: String, @ColorRes bgColor: Int, @ColorRes textColor: Int) {
activity?.let { activity ->
TSnackbar
.make(activity.findViewById(R.id.content_container), message, TSnackbar.LENGTH_SHORT)
.also { snackbar -> snackbar.view.setBackgroundColor(activity.color(bgColor)) }
.also { snackbar ->
(snackbar.view.findViewById(com.androidadvance.topsnackbar.R.id.snackbar_text) as? TextView)
?.setTextColor(activity.color(textColor))
}
.show()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import com.sedsoftware.yaptalker.presentation.base.enums.lifecycle.FragmentLifec
import com.sedsoftware.yaptalker.presentation.base.enums.navigation.NavigationSection
import com.sedsoftware.yaptalker.presentation.base.navigation.NavigationPanelClickListener
import com.sedsoftware.yaptalker.presentation.extensions.setIndicatorColorScheme
import com.sedsoftware.yaptalker.presentation.extensions.snackError
import com.sedsoftware.yaptalker.presentation.extensions.snackWarning
import com.sedsoftware.yaptalker.presentation.extensions.stringRes
import com.sedsoftware.yaptalker.presentation.extensions.toastError
import com.sedsoftware.yaptalker.presentation.extensions.toastWarning
import com.sedsoftware.yaptalker.presentation.features.activetopics.adapters.ActiveTopicsAdapter
import com.sedsoftware.yaptalker.presentation.features.activetopics.adapters.ActiveTopicsItemClickListener
import com.sedsoftware.yaptalker.presentation.model.YapEntity
Expand Down Expand Up @@ -71,7 +71,7 @@ class ActiveTopicsFragment : BaseFragment(), ActiveTopicsView, ActiveTopicsItemC
}

override fun showErrorMessage(message: String) {
toastError(message)
snackError(message)
}

override fun appendActiveTopicItem(topic: YapEntity) {
Expand All @@ -93,7 +93,7 @@ class ActiveTopicsFragment : BaseFragment(), ActiveTopicsView, ActiveTopicsItemC

override fun showCantLoadPageMessage(page: Int) {
context?.stringRes(R.string.navigation_page_not_available)?.let { template ->
toastWarning(String.format(Locale.getDefault(), template, page))
snackWarning(String.format(Locale.getDefault(), template, page))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import com.sedsoftware.yaptalker.commons.annotation.LayoutResource
import com.sedsoftware.yaptalker.presentation.base.BaseFragment
import com.sedsoftware.yaptalker.presentation.base.enums.lifecycle.FragmentLifecycle
import com.sedsoftware.yaptalker.presentation.base.enums.navigation.NavigationSection
import com.sedsoftware.yaptalker.presentation.extensions.snackError
import com.sedsoftware.yaptalker.presentation.extensions.snackSuccess
import com.sedsoftware.yaptalker.presentation.extensions.stringRes
import com.sedsoftware.yaptalker.presentation.extensions.toastError
import com.sedsoftware.yaptalker.presentation.extensions.toastSuccess
import com.uber.autodispose.kotlin.autoDisposable
import io.reactivex.Observable
import io.reactivex.functions.BiFunction
Expand Down Expand Up @@ -48,15 +48,15 @@ class AuthorizationFragment : BaseFragment(), AuthorizationView {
}

override fun loginSuccessMessage() {
context?.stringRes(R.string.msg_login_success)?.let { toastSuccess(it) }
context?.stringRes(R.string.msg_login_success)?.let { snackSuccess(it) }
}

override fun loginErrorMessage() {
context?.stringRes(R.string.msg_login_error)?.let { toastError(it) }
context?.stringRes(R.string.msg_login_error)?.let { snackError(it) }
}

override fun showErrorMessage(message: String) {
toastError(message)
snackError(message)
}

override fun setSignInButtonState(isEnabled: Boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import com.sedsoftware.yaptalker.presentation.base.enums.lifecycle.FragmentLifec
import com.sedsoftware.yaptalker.presentation.base.enums.navigation.NavigationSection
import com.sedsoftware.yaptalker.presentation.extensions.extractYapIds
import com.sedsoftware.yaptalker.presentation.extensions.setIndicatorColorScheme
import com.sedsoftware.yaptalker.presentation.extensions.snackError
import com.sedsoftware.yaptalker.presentation.extensions.snackInfo
import com.sedsoftware.yaptalker.presentation.extensions.stringRes
import com.sedsoftware.yaptalker.presentation.extensions.toastError
import com.sedsoftware.yaptalker.presentation.extensions.toastInfo
import com.sedsoftware.yaptalker.presentation.features.bookmarks.adapters.BookmarksAdapter
import com.sedsoftware.yaptalker.presentation.features.bookmarks.adapters.BookmarksElementsClickListener
import com.sedsoftware.yaptalker.presentation.model.YapEntity
Expand Down Expand Up @@ -67,7 +67,7 @@ class BookmarksFragment : BaseFragment(), BookmarksView, BookmarksElementsClickL
}

override fun showErrorMessage(message: String) {
toastError(message)
snackError(message)
}

override fun appendBookmarkItem(bookmark: YapEntity) {
Expand Down Expand Up @@ -95,7 +95,7 @@ class BookmarksFragment : BaseFragment(), BookmarksView, BookmarksElementsClickL
}

override fun showBookmarkDeletedMessage() {
toastInfo(getString(R.string.msg_bookmark_topic_deleted))
snackInfo(getString(R.string.msg_bookmark_topic_deleted))
}

override fun onTopicItemClick(link: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import com.sedsoftware.yaptalker.presentation.base.enums.lifecycle.FragmentLifec
import com.sedsoftware.yaptalker.presentation.base.enums.navigation.NavigationSection
import com.sedsoftware.yaptalker.presentation.base.navigation.NavigationPanelClickListener
import com.sedsoftware.yaptalker.presentation.extensions.setIndicatorColorScheme
import com.sedsoftware.yaptalker.presentation.extensions.snackError
import com.sedsoftware.yaptalker.presentation.extensions.snackWarning
import com.sedsoftware.yaptalker.presentation.extensions.stringRes
import com.sedsoftware.yaptalker.presentation.extensions.toastError
import com.sedsoftware.yaptalker.presentation.extensions.toastWarning
import com.sedsoftware.yaptalker.presentation.features.forum.adapter.ChosenForumAdapter
import com.sedsoftware.yaptalker.presentation.features.forum.adapter.ChosenForumItemClickListener
import com.sedsoftware.yaptalker.presentation.model.YapEntity
Expand Down Expand Up @@ -82,7 +82,7 @@ class ChosenForumFragment : BaseFragment(), ChosenForumView, ChosenForumItemClic
}

override fun showErrorMessage(message: String) {
toastError(message)
snackError(message)
}

override fun addTopicItem(entity: YapEntity) {
Expand All @@ -108,7 +108,7 @@ class ChosenForumFragment : BaseFragment(), ChosenForumView, ChosenForumItemClic

override fun showCantLoadPageMessage(page: Int) {
context?.stringRes(R.string.navigation_page_not_available)?.let { template ->
toastWarning(String.format(Locale.getDefault(), template, page))
snackWarning(String.format(Locale.getDefault(), template, page))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import com.sedsoftware.yaptalker.presentation.base.BaseFragment
import com.sedsoftware.yaptalker.presentation.base.enums.lifecycle.FragmentLifecycle
import com.sedsoftware.yaptalker.presentation.base.enums.navigation.NavigationSection
import com.sedsoftware.yaptalker.presentation.extensions.setIndicatorColorScheme
import com.sedsoftware.yaptalker.presentation.extensions.snackError
import com.sedsoftware.yaptalker.presentation.extensions.stringRes
import com.sedsoftware.yaptalker.presentation.extensions.toastError
import com.sedsoftware.yaptalker.presentation.features.forumslist.adapter.ForumsAdapter
import com.sedsoftware.yaptalker.presentation.features.forumslist.adapter.ForumsItemClickListener
import com.sedsoftware.yaptalker.presentation.model.YapEntity
Expand Down Expand Up @@ -64,7 +64,7 @@ class ForumsFragment : BaseFragment(), ForumsView, ForumsItemClickListener {
}

override fun showErrorMessage(message: String) {
toastError(message)
snackError(message)
}

override fun appendForumItem(item: YapEntity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ import com.arellomobile.mvp.presenter.ProvidePresenter
import com.sedsoftware.yaptalker.R
import com.sedsoftware.yaptalker.commons.annotation.LayoutResource
import com.sedsoftware.yaptalker.presentation.base.BaseActivity
import com.sedsoftware.yaptalker.presentation.extensions.snackError
import com.sedsoftware.yaptalker.presentation.extensions.snackSuccess
import com.sedsoftware.yaptalker.presentation.extensions.stringRes
import com.sedsoftware.yaptalker.presentation.extensions.toastError
import com.sedsoftware.yaptalker.presentation.extensions.toastSuccess
import com.sedsoftware.yaptalker.presentation.extensions.visibleItemPosition
import com.sedsoftware.yaptalker.presentation.features.gallery.adapter.TopicGalleryAdapter
import com.sedsoftware.yaptalker.presentation.features.gallery.adapter.TopicGalleryLoadMoreClickListener
import com.sedsoftware.yaptalker.presentation.model.YapEntity
import com.sedsoftware.yaptalker.presentation.model.base.SinglePostGalleryImageModel
import kotlinx.android.synthetic.main.activity_topic_gallery.topic_gallery
import kotlinx.android.synthetic.main.include_main_appbar_transparent.toolbar
import kotlinx.android.synthetic.main.activity_topic_gallery.*
import kotlinx.android.synthetic.main.include_main_appbar_transparent.*
import java.util.Locale
import javax.inject.Inject

Expand Down Expand Up @@ -122,7 +122,7 @@ class TopicGalleryActivity : BaseActivity(), TopicGalleryView, TopicGalleryLoadM
}

override fun showErrorMessage(message: String) {
toastError(message)
snackError(message)
}

override fun appendImages(images: List<YapEntity>) {
Expand All @@ -143,12 +143,12 @@ class TopicGalleryActivity : BaseActivity(), TopicGalleryView, TopicGalleryLoadM

override fun fileSavedMessage(filepath: String) {
String.format(Locale.getDefault(), stringRes(R.string.msg_file_saved), filepath).apply {
toastSuccess(this)
snackSuccess(this)
}
}

override fun fileNotSavedMessage() {
toastError(stringRes(R.string.msg_file_not_saved))
snackError(stringRes(R.string.msg_file_not_saved))
}

override fun onLoadMoreClicked() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ class TopicGalleryAdapter @Inject constructor(

private fun showLastLoadingIndicator() {
clearLoadingIndicators()
val newLast = SinglePostGalleryImageModel(url = items.last().url, showLoadMore = true)
items.removeAt(items.lastIndex)
items.add(newLast)
if (items.isNotEmpty()) {
val newLast = SinglePostGalleryImageModel(url = items.last().url, showLoadMore = true)
items.removeAt(items.lastIndex)
items.add(newLast)
}
}

inner class ImageViewHolder(parent: ViewGroup) :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.arellomobile.mvp.presenter.ProvidePresenter
import com.sedsoftware.yaptalker.R
import com.sedsoftware.yaptalker.commons.annotation.LayoutResource
import com.sedsoftware.yaptalker.presentation.base.BaseActivity
import com.sedsoftware.yaptalker.presentation.extensions.toastError
import com.sedsoftware.yaptalker.presentation.extensions.snackError
import kotlinx.android.synthetic.main.activity_gif_display.*
import kotlinx.android.synthetic.main.include_main_appbar.*
import timber.log.Timber
Expand Down Expand Up @@ -63,7 +63,7 @@ class GifDisplayActivity : BaseActivity(), GifDisplayView {
}

override fun showErrorMessage(message: String) {
toastError(message)
snackError(message)
}

@SuppressLint("SetJavaScriptEnabled")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import com.sedsoftware.yaptalker.R
import com.sedsoftware.yaptalker.commons.annotation.LayoutResource
import com.sedsoftware.yaptalker.presentation.base.BaseActivity
import com.sedsoftware.yaptalker.presentation.extensions.loadFromUrl
import com.sedsoftware.yaptalker.presentation.extensions.snackError
import com.sedsoftware.yaptalker.presentation.extensions.snackSuccess
import com.sedsoftware.yaptalker.presentation.extensions.stringRes
import com.sedsoftware.yaptalker.presentation.extensions.toastError
import com.sedsoftware.yaptalker.presentation.extensions.toastSuccess
import kotlinx.android.synthetic.main.activity_image_display.photo_view
import kotlinx.android.synthetic.main.include_main_appbar_transparent.toolbar
import kotlinx.android.synthetic.main.activity_image_display.*
import kotlinx.android.synthetic.main.include_main_appbar_transparent.*
import java.util.Locale
import javax.inject.Inject

Expand Down Expand Up @@ -79,17 +79,17 @@ class ImageDisplayActivity : BaseActivity(), ImageDisplayView {
}

override fun showErrorMessage(message: String) {
toastError(message)
snackError(message)
}

override fun fileSavedMessage(filepath: String) {
String.format(Locale.getDefault(), stringRes(R.string.msg_file_saved), filepath).apply {
toastSuccess(this)
snackSuccess(this)
}
}

override fun fileNotSavedMessage() {
toastError(stringRes(R.string.msg_file_not_saved))
snackError(stringRes(R.string.msg_file_not_saved))
}

override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
Expand Down
Loading

0 comments on commit 956a655

Please sign in to comment.