Skip to content

Commit

Permalink
update lib
Browse files Browse the repository at this point in the history
  • Loading branch information
dbof10 committed Mar 29, 2018
1 parent bb11fde commit 7674ee0
Show file tree
Hide file tree
Showing 36 changed files with 134 additions and 103 deletions.
6 changes: 3 additions & 3 deletions app/src/main/java/com/ctech/eaty/annotation/ConnectionType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package com.ctech.eaty.annotation
import android.net.ConnectivityManager
import android.support.annotation.IntDef

const val WIFI = ConnectivityManager.TYPE_WIFI.toLong()
const val MOBILE = ConnectivityManager.TYPE_MOBILE.toLong()
const val NONE = -1L
const val WIFI = ConnectivityManager.TYPE_WIFI
const val MOBILE = ConnectivityManager.TYPE_MOBILE
const val NONE = -1

@Retention(AnnotationRetention.SOURCE)
@IntDef(WIFI, MOBILE, NONE)
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/ctech/eaty/annotation/Lightness.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package com.ctech.eaty.annotation

import android.support.annotation.IntDef

const val IS_LIGHT = 0L
const val IS_DARK = 1L
const val LIGHTNESS_UNKNOWN = 2L
const val IS_LIGHT = 0
const val IS_DARK = 1
const val LIGHTNESS_UNKNOWN = 2

@Retention(AnnotationRetention.SOURCE)
@IntDef(IS_LIGHT, IS_DARK, LIGHTNESS_UNKNOWN)
Expand Down
14 changes: 8 additions & 6 deletions app/src/main/java/com/ctech/eaty/di/StoreModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ import okio.BufferedSource
@Module
class StoreModule {

private val PRODUCT_LIMIT = 10
private val COMMENT_LIMIT = 10
private val COLLECTION_LIMIT = 10
private val TOPIC_LIMIT = 10
private val VOTE_LIMIT = 10
private val SEARCH_LIMIT = 10
companion object {
private const val PRODUCT_LIMIT = 10
private const val COMMENT_LIMIT = 10
private const val COLLECTION_LIMIT = 10
private const val TOPIC_LIMIT = 10
private const val VOTE_LIMIT = 10
private const val SEARCH_LIMIT = 10
}

@Provides
fun providerRealmPersister(): Persister<ProductResponse, BarCode> {
Expand Down
18 changes: 8 additions & 10 deletions app/src/main/java/com/ctech/eaty/linking/UniversalLinkActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import android.support.v7.app.AppCompatActivity
import com.ctech.eaty.R
import com.ctech.eaty.di.Injectable
import com.uber.autodispose.android.lifecycle.AndroidLifecycleScopeProvider
import com.uber.autodispose.kotlin.autoDisposeWith
import com.uber.autodispose.kotlin.autoDisposable
import timber.log.Timber
import javax.inject.Inject

Expand All @@ -31,15 +31,13 @@ class UniversalLinkActivity : AppCompatActivity(), Injectable {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_loading)
universalLinkDispatcher.dispatch(intent.dataString)
.autoDisposeWith(AndroidLifecycleScopeProvider.from(this))
.subscribe(
{
finish()
},
{
Timber.e(it)
finish()
})
.autoDisposable(AndroidLifecycleScopeProvider.from(this))
.subscribe({
finish()
}, {
Timber.e(it)
finish()
})
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import com.google.firebase.messaging.RemoteMessage
class AppFirebaseMessagingService : FirebaseMessagingService() {


private val KEY_URL = "url"
companion object {
private const val KEY_URL = "url"

}

override fun onMessageReceived(remoteMessage: RemoteMessage?) {

Expand All @@ -33,8 +36,8 @@ class AppFirebaseMessagingService : FirebaseMessagingService() {
val defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
val notificationBuilder = NotificationCompat.Builder(this, channelId)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle(message.notification.title)
.setContentText(message.notification.body)
.setContentTitle(message.notification?.title)
.setContentText(message.notification?.body)
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent)
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/ctech/eaty/ui/app/AppState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package com.ctech.eaty.ui.app

import com.ctech.eaty.annotation.ConnectionType

data class AppState(@ConnectionType val connectionType: Long)
data class AppState(@ConnectionType val connectionType: Int)
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package com.ctech.eaty.ui.app.result

import com.ctech.eaty.base.redux.Result

data class NetworkChangeResult(val connectionType: Long) : Result
data class NetworkChangeResult(val connectionType: Int) : Result
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.ctech.eaty.ui.home.state.HomeState
import com.facebook.litho.Border
import com.facebook.litho.ClickEvent
import com.facebook.litho.Column
import com.facebook.litho.Component
import com.facebook.litho.ComponentContext
import com.facebook.litho.ComponentLayout
import com.facebook.litho.annotations.LayoutSpec
Expand All @@ -27,7 +28,7 @@ import com.facebook.yoga.YogaJustify
object DataSaverComponentSpec {

@OnCreateLayout
fun onCreateLayout(c: ComponentContext): ComponentLayout {
fun onCreateLayout(c: ComponentContext): Component {

return Column.create(c)
.child(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ctech.eaty.ui.home.component

import com.ctech.eaty.R
import com.facebook.litho.Column
import com.facebook.litho.Component
import com.facebook.litho.ComponentContext
import com.facebook.litho.ComponentLayout
import com.facebook.litho.Row
Expand All @@ -17,7 +18,7 @@ import com.facebook.yoga.YogaJustify
object ErrorFooterComponentSpec {

@OnCreateLayout
fun onCreateLayout(c: ComponentContext): ComponentLayout =
fun onCreateLayout(c: ComponentContext): Component =
Column.create(c)
.justifyContent(YogaJustify.CENTER)
.alignItems(YogaAlign.CENTER)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import com.facebook.litho.sections.common.SingleComponentSection
@GroupSectionSpec
object HomeFeedSectionSpec {

private val KEY_FOOTER_LOADING = "loading"
private val KEY_FOOTER_ERROR = "error"
private const val KEY_FOOTER_LOADING = "loading"
private const val KEY_FOOTER_ERROR = "error"

@OnCreateChildren
fun onCreateChildren(c: SectionContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.ctech.eaty.R
import com.ctech.eaty.base.redux.Store
import com.ctech.eaty.ui.home.model.HomeFeed
import com.ctech.eaty.ui.home.state.HomeState
import com.facebook.litho.Component
import com.facebook.litho.ComponentContext
import com.facebook.litho.ComponentLayout
import com.facebook.litho.annotations.LayoutSpec
Expand All @@ -23,7 +24,7 @@ object HomeListComponentSpec {
fun onCreateLayout(c: ComponentContext,
@Prop dataSource: List<HomeFeed>,
@Prop store: Store<HomeState>,
@Prop eventsController: RecyclerCollectionEventsController): ComponentLayout {
@Prop eventsController: RecyclerCollectionEventsController): Component {
return RecyclerCollectionComponent.create(c)
.section(
HomeFeedSection.create(SectionContext(c))
Expand All @@ -34,7 +35,7 @@ object HomeListComponentSpec {
.refreshProgressBarColorRes(R.color.colorAccent)
.disablePTR(false)
.testKey(MAIN_SCREEN)
.buildWithLayout()
.build()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ object HorizontalAdsSectionSpec {
c: SectionContext,
@FromEvent model: HorizontalAdsItemViewModel): RenderInfo {
return ViewRenderInfo.create()
.viewCreator { context ->
.viewCreator { context, _ ->
return@viewCreator HorizontalAdsView(context)
}
.viewBinder(object : SimpleViewBinder<HorizontalAdsView>() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ctech.eaty.ui.home.component

import com.ctech.eaty.R
import com.facebook.litho.Component
import com.facebook.litho.ComponentContext
import com.facebook.litho.ComponentLayout
import com.facebook.litho.Row
Expand All @@ -13,7 +14,7 @@ import com.facebook.yoga.YogaJustify
object LoadingFooterComponentSpec {

@OnCreateLayout
fun onCreateLayout(c: ComponentContext) : ComponentLayout =
fun onCreateLayout(c: ComponentContext) : Component =
Row.create(c)
.justifyContent(YogaJustify.CENTER)
.child(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.graphics.Color
import com.ctech.eaty.R
import com.ctech.eaty.ui.home.viewmodel.StickyItemViewModel
import com.facebook.litho.Column
import com.facebook.litho.Component
import com.facebook.litho.ComponentContext
import com.facebook.litho.ComponentLayout
import com.facebook.litho.annotations.LayoutSpec
Expand All @@ -17,7 +18,7 @@ import com.facebook.yoga.YogaEdge
object StickyLabelComponentSpec {

@OnCreateLayout
fun onCreateLayout(c: ComponentContext, @Prop viewModel: StickyItemViewModel): ComponentLayout =
fun onCreateLayout(c: ComponentContext, @Prop viewModel: StickyItemViewModel): Component =
Column.create(c)
.backgroundColor(Color.WHITE)
.paddingRes(YogaEdge.BOTTOM, R.dimen.content_padding_vertical)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import com.facebook.drawee.drawable.ScalingUtils
import com.facebook.imagepipeline.request.ImageRequest
import com.facebook.litho.ClickEvent
import com.facebook.litho.Column
import com.facebook.litho.Component
import com.facebook.litho.ComponentContext
import com.facebook.litho.ComponentLayout
import com.facebook.litho.annotations.FromEvent
Expand Down Expand Up @@ -46,7 +47,7 @@ object CollectionComponentSpec {
ListRecyclerConfiguration(LinearLayout.HORIZONTAL, false, ListRecyclerConfiguration.SNAP_NONE)

@OnCreateLayout
fun onCreateLayout(c: ComponentContext, @Prop collection: SuggestedCollection): ComponentLayout {
fun onCreateLayout(c: ComponentContext, @Prop collection: SuggestedCollection): Component {

val width = c.resources.getDimensionPixelSize(R.dimen.upcoming_product_width)
val controller = Fresco.newDraweeControllerBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.facebook.drawee.drawable.ScalingUtils
import com.facebook.imagepipeline.request.ImageRequest
import com.facebook.litho.ClickEvent
import com.facebook.litho.Column
import com.facebook.litho.Component
import com.facebook.litho.ComponentContext
import com.facebook.litho.ComponentLayout
import com.facebook.litho.Row
Expand All @@ -27,7 +28,7 @@ import com.facebook.yoga.YogaJustify
object CollectionProductComponentSpec {

@OnCreateLayout
fun onCreateLayout(c: ComponentContext, @Prop viewModel: ProductItemViewModel): ComponentLayout {
fun onCreateLayout(c: ComponentContext, @Prop viewModel: ProductItemViewModel): Component {

val height = c.resources.getDimensionPixelSize(R.dimen.feed_job_size)
val controller = Fresco.newDraweeControllerBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.facebook.drawee.drawable.ScalingUtils
import com.facebook.imagepipeline.request.ImageRequest
import com.facebook.litho.ClickEvent
import com.facebook.litho.Column
import com.facebook.litho.Component
import com.facebook.litho.ComponentContext
import com.facebook.litho.ComponentLayout
import com.facebook.litho.annotations.LayoutSpec
Expand All @@ -29,7 +30,7 @@ object DailyProductBodyComponentSpec {


@OnCreateLayout
fun onCreateLayout(c: ComponentContext, @Prop viewModel: ProductItemViewModel, @Prop store: Store<HomeState>): ComponentLayout {
fun onCreateLayout(c: ComponentContext, @Prop viewModel: ProductItemViewModel, @Prop store: Store<HomeState>): Component {
val height = c.resources.getDimensionPixelSize(R.dimen.feed_product_height)
val controller = Fresco.newDraweeControllerBuilder()
.setLowResImageRequest(ImageRequest.fromUri(ResizeImageUrlProvider.overrideUrl(viewModel.imageUrl, c.resources.getDimensionPixelSize(R.dimen.thumbnail_preview_size))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.ctech.eaty.R
import com.ctech.eaty.ui.comment.view.CommentActivity
import com.ctech.eaty.ui.home.viewmodel.ProductItemViewModel
import com.facebook.litho.ClickEvent
import com.facebook.litho.Component
import com.facebook.litho.ComponentContext
import com.facebook.litho.ComponentLayout
import com.facebook.litho.Row
Expand All @@ -25,7 +26,7 @@ object FooterActionComponentSpec {
@OnCreateLayout
fun onCreateLayout(c: ComponentContext,
@Prop actionResId: Int,
@Prop actionLabelResId: Int): ComponentLayout {
@Prop actionLabelResId: Int): Component {
return Row.create(c)
.child(
Image.create(c)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.support.v4.content.ContextCompat
import com.ctech.eaty.R
import com.ctech.eaty.ui.home.viewmodel.ProductItemViewModel
import com.facebook.litho.Column
import com.facebook.litho.Component
import com.facebook.litho.ComponentContext
import com.facebook.litho.ComponentLayout
import com.facebook.litho.Row
Expand All @@ -19,7 +20,7 @@ import com.facebook.yoga.YogaJustify
object FooterComponentSpec {

@OnCreateLayout
fun onCreateLayout(c: ComponentContext, @Prop viewModel: ProductItemViewModel): ComponentLayout {
fun onCreateLayout(c: ComponentContext, @Prop viewModel: ProductItemViewModel): Component {
val resources = c.resources
val interaction = Row.create(c)
.child(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.ctech.eaty.ui.user.view.UserActivity
import com.facebook.drawee.backends.pipeline.Fresco
import com.facebook.drawee.drawable.ScalingUtils
import com.facebook.litho.ClickEvent
import com.facebook.litho.Component
import com.facebook.litho.ComponentContext
import com.facebook.litho.ComponentLayout
import com.facebook.litho.Row
Expand All @@ -25,7 +26,7 @@ object HeaderComponentSpec {


@OnCreateLayout
fun onCreateLayout(c: ComponentContext, @Prop viewModel: ProductItemViewModel): ComponentLayout {
fun onCreateLayout(c: ComponentContext, @Prop viewModel: ProductItemViewModel): Component {
val controller = Fresco.newDraweeControllerBuilder()
.setUri(viewModel.userImageUrl)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.ctech.eaty.base.redux.Store
import com.ctech.eaty.ui.home.state.HomeState
import com.ctech.eaty.ui.home.viewmodel.ProductItemViewModel
import com.facebook.litho.Column
import com.facebook.litho.Component
import com.facebook.litho.ComponentContext
import com.facebook.litho.ComponentLayout
import com.facebook.litho.annotations.LayoutSpec
Expand All @@ -19,7 +20,7 @@ object ProductComponentSpec {

@OnCreateLayout
fun onCreateLayout(c: ComponentContext, @Prop viewModel: ProductItemViewModel,
@Prop store: Store<HomeState>): ComponentLayout {
@Prop store: Store<HomeState>): Component {
return Column.create(c)
.child(HeaderComponent.create(c)
.viewModel(viewModel))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.facebook.drawee.drawable.ScalingUtils
import com.facebook.imagepipeline.request.ImageRequest
import com.facebook.litho.ClickEvent
import com.facebook.litho.Column
import com.facebook.litho.Component
import com.facebook.litho.ComponentContext
import com.facebook.litho.ComponentLayout
import com.facebook.litho.Row
Expand All @@ -33,7 +34,7 @@ import com.facebook.yoga.YogaJustify
object JobComponentSpec {

@OnCreateLayout
fun onCreateLayout(c: ComponentContext, @Prop viewModel: Job): ComponentLayout {
fun onCreateLayout(c: ComponentContext, @Prop viewModel: Job): Component {

val height = c.resources.getDimensionPixelSize(R.dimen.feed_job_size)
val controller = Fresco.newDraweeControllerBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.ctech.eaty.entity.Job
import com.ctech.eaty.ui.home.model.Jobs
import com.ctech.eaty.widget.recyclerview.HorizontalSpaceItemDecoration2
import com.facebook.litho.Column
import com.facebook.litho.Component
import com.facebook.litho.ComponentContext
import com.facebook.litho.ComponentLayout
import com.facebook.litho.annotations.FromEvent
Expand Down Expand Up @@ -35,7 +36,7 @@ object JobsComponentSpec {
ListRecyclerConfiguration(LinearLayout.HORIZONTAL, false, ListRecyclerConfiguration.SNAP_NONE)

@OnCreateLayout
fun onCreateLayout(c: ComponentContext, @Prop jobs: Jobs): ComponentLayout {
fun onCreateLayout(c: ComponentContext, @Prop jobs: Jobs): Component {
return Column.create(c)
.child(
Text.create(c, 0, R.style.Text_Body2)
Expand Down

0 comments on commit 7674ee0

Please sign in to comment.