Skip to content

Commit

Permalink
Merge branch 'feature/home-formatting' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
SmartToolFactory committed Sep 9, 2020
2 parents 6204a30 + c842c3a commit a9b7e9d
Show file tree
Hide file tree
Showing 23 changed files with 50 additions and 35 deletions.
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<resources>
<string name="app_name">PropertyFindAR</string>
<string name="app_name">Property FindAR</string>
<string name="title_home">Home</string>
<string name="title_favorites">Favorites</string>
<string name="title_notification">Notification</string>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.smarttoolfactory.home.adapter

import android.graphics.Color
import android.widget.ImageButton
import androidx.annotation.LayoutRes
import androidx.databinding.ViewDataBinding
Expand Down Expand Up @@ -57,12 +58,15 @@ class PropertyItemListAdapter(
onLikeButtonClick(this)

// Set image source of like button
val likeImageButton = (likeButton as? ImageButton)
val imageResource = if (isFavorite) {
R.drawable.ic_baseline_favorite_24
likeImageButton?.setColorFilter(Color.rgb(244, 81, 30))
R.drawable.ic_baseline_favorite_30
} else {
R.drawable.ic_baseline_favorite_border_24
likeImageButton?.setColorFilter(Color.rgb(41, 182, 246))
R.drawable.ic_baseline_favorite_border_30
}
(likeButton as? ImageButton)?.setImageResource(imageResource)
likeImageButton?.setImageResource(imageResource)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package com.smarttoolfactory.home.di

import androidx.fragment.app.Fragment
import com.smarttoolfactory.core.di.CoreModuleDependencies
import com.smarttoolfactory.home.propertylist.PagedPropertyListFragment
import com.smarttoolfactory.home.propertylist.PropertyListFlowFragment
import com.smarttoolfactory.home.propertylist.PropertyListRxjava3Fragment
import com.smarttoolfactory.home.propertylist.flow.PropertyListFlowFragment
import com.smarttoolfactory.home.propertylist.paged.PagedPropertyListFragment
import com.smarttoolfactory.home.propertylist.rxjava.PropertyListRxjava3Fragment
import dagger.BindsInstance
import dagger.Component

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package com.smarttoolfactory.home.di

import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider
import com.smarttoolfactory.home.viewmodel.PagedPropertyListViewModel
import com.smarttoolfactory.home.propertylist.flow.PropertyListViewModelFlow
import com.smarttoolfactory.home.propertylist.paged.PagedPropertyListViewModel
import com.smarttoolfactory.home.propertylist.rxjava.PropertyListViewModelRxJava3
import com.smarttoolfactory.home.viewmodel.PagedPropertyListViewModelFactory
import com.smarttoolfactory.home.viewmodel.PropertyListFlowViewModelFactory
import com.smarttoolfactory.home.viewmodel.PropertyListRxJava3ViewModelFactory
import com.smarttoolfactory.home.viewmodel.PropertyListViewModelFlow
import com.smarttoolfactory.home.viewmodel.PropertyListViewModelRxJava3
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.smarttoolfactory.home.viewmodel
package com.smarttoolfactory.home.propertylist

import androidx.lifecycle.LiveData
import androidx.lifecycle.ViewModel
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.smarttoolfactory.home.propertylist
package com.smarttoolfactory.home.propertylist.flow

import android.os.Bundle
import androidx.core.os.bundleOf
Expand All @@ -12,7 +12,6 @@ import com.smarttoolfactory.home.adapter.PropertyItemListAdapter
import com.smarttoolfactory.home.databinding.FragmentPropertyListBinding
import com.smarttoolfactory.home.di.DaggerHomeComponent
import com.smarttoolfactory.home.viewmodel.HomeToolbarVM
import com.smarttoolfactory.home.viewmodel.PropertyListViewModelFlow
import dagger.hilt.android.EntryPointAccessors
import javax.inject.Inject

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.smarttoolfactory.home.viewmodel
package com.smarttoolfactory.home.propertylist.flow

import androidx.hilt.lifecycle.ViewModelInject
import androidx.lifecycle.LiveData
Expand All @@ -10,6 +10,7 @@ import com.smarttoolfactory.core.viewstate.ViewState
import com.smarttoolfactory.domain.ORDER_BY_NONE
import com.smarttoolfactory.domain.model.PropertyItem
import com.smarttoolfactory.domain.usecase.GetPropertiesUseCaseFlow
import com.smarttoolfactory.home.propertylist.AbstractPropertyListVM
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.smarttoolfactory.home.propertylist
package com.smarttoolfactory.home.propertylist.paged

import android.os.Bundle
import android.widget.Toast
import androidx.core.os.bundleOf
import androidx.fragment.app.activityViewModels
import androidx.recyclerview.widget.LinearLayoutManager
Expand All @@ -14,7 +13,6 @@ import com.smarttoolfactory.home.adapter.PropertyItemListAdapter
import com.smarttoolfactory.home.databinding.FragmentPropertyListPagedBinding
import com.smarttoolfactory.home.di.DaggerHomeComponent
import com.smarttoolfactory.home.viewmodel.HomeToolbarVM
import com.smarttoolfactory.home.viewmodel.PagedPropertyListViewModel
import dagger.hilt.android.EntryPointAccessors
import javax.inject.Inject

Expand Down Expand Up @@ -143,6 +141,5 @@ class PagedPropertyListFragment :

override fun onScrollToBottom() {
viewModel.getPropertyList()
Toast.makeText(requireContext(), "BOTTOM SCROLL", Toast.LENGTH_SHORT).show()
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.smarttoolfactory.home.viewmodel
package com.smarttoolfactory.home.propertylist.paged

import androidx.hilt.lifecycle.ViewModelInject
import androidx.lifecycle.LiveData
Expand All @@ -10,6 +10,7 @@ import com.smarttoolfactory.core.viewstate.ViewState
import com.smarttoolfactory.domain.ORDER_BY_NONE
import com.smarttoolfactory.domain.model.PropertyItem
import com.smarttoolfactory.domain.usecase.GetPropertiesUseCasePaged
import com.smarttoolfactory.home.propertylist.AbstractPropertyListVM
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.smarttoolfactory.home.propertylist
package com.smarttoolfactory.home.propertylist.rxjava

import android.os.Bundle
import androidx.core.os.bundleOf
Expand All @@ -12,7 +12,6 @@ import com.smarttoolfactory.home.adapter.PropertyItemListAdapter
import com.smarttoolfactory.home.databinding.FragmentPropertyListBinding
import com.smarttoolfactory.home.di.DaggerHomeComponent
import com.smarttoolfactory.home.viewmodel.HomeToolbarVM
import com.smarttoolfactory.home.viewmodel.PropertyListViewModelRxJava3
import dagger.hilt.android.EntryPointAccessors
import javax.inject.Inject

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.smarttoolfactory.home.viewmodel
package com.smarttoolfactory.home.propertylist.rxjava

import androidx.hilt.lifecycle.ViewModelInject
import androidx.lifecycle.LiveData
Expand All @@ -10,6 +10,7 @@ import com.smarttoolfactory.core.viewstate.ViewState
import com.smarttoolfactory.domain.ORDER_BY_NONE
import com.smarttoolfactory.domain.model.PropertyItem
import com.smarttoolfactory.domain.usecase.GetPropertiesUseCaseRxJava3
import com.smarttoolfactory.home.propertylist.AbstractPropertyListVM
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.schedulers.Schedulers

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.smarttoolfactory.home.viewbindings

import android.graphics.Color
import android.view.View
import android.widget.ImageButton
import android.widget.ImageView
Expand Down Expand Up @@ -64,6 +65,12 @@ fun View.visibilityBasedOn(condition: Boolean) {
@BindingAdapter("favoriteImageSrc")
fun ImageButton.setFavoriteImageSrc(favorite: Boolean) {

if (favorite) {
setColorFilter(Color.rgb(244, 81, 30))
} else {
setColorFilter(Color.rgb(41, 182, 246))
}

val imageResource = if (favorite) R.drawable.ic_baseline_favorite_30
else R.drawable.ic_baseline_favorite_border_30

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import androidx.lifecycle.ViewModelProvider
import com.smarttoolfactory.domain.usecase.GetPropertiesUseCaseFlow
import com.smarttoolfactory.domain.usecase.GetPropertiesUseCasePaged
import com.smarttoolfactory.domain.usecase.GetPropertiesUseCaseRxJava3
import com.smarttoolfactory.home.propertylist.flow.PropertyListViewModelFlow
import com.smarttoolfactory.home.propertylist.paged.PagedPropertyListViewModel
import com.smarttoolfactory.home.propertylist.rxjava.PropertyListViewModelRxJava3
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<variable
name="viewModel"
type="com.smarttoolfactory.home.viewmodel.AbstractPropertyListVM" />
type="com.smarttoolfactory.home.propertylist.AbstractPropertyListVM" />
</data>

<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<variable
name="viewModel"
type="com.smarttoolfactory.home.viewmodel.PagedPropertyListViewModel" />
type="com.smarttoolfactory.home.propertylist.paged.PagedPropertyListViewModel" />
</data>

<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
Expand Down
9 changes: 4 additions & 5 deletions features/home/src/main/res/layout/row_property.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="140dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="4dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="6dp"
android:padding="2dp">

<androidx.cardview.widget.CardView
android:id="@+id/cvThumbnail"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="8dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="2dp"
app:cardCornerRadius="5dp"
Expand Down Expand Up @@ -103,7 +102,7 @@
android:layout_height="40dp"
android:background="#00ffffff"
android:padding="2dp"
android:src="@drawable/ic_baseline_favorite_border_24"
android:src="@drawable/ic_baseline_favorite_border_30"
android:tint="#29B6F6"
app:layout_constraintBottom_toBottomOf="@+id/tvPrice"
app:layout_constraintEnd_toEndOf="parent"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<fragment
android:id="@+id/propertyListFragment"
android:name="com.smarttoolfactory.home.propertylist.PropertyListFlowFragment"
android:name="com.smarttoolfactory.home.propertylist.flow.PropertyListFlowFragment"
android:label="Properties with Flow"
tools:layout="@layout/fragment_property_list">
</fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<fragment
android:id="@+id/propertyListFragment"
android:name="com.smarttoolfactory.home.propertylist.PagedPropertyListFragment"
android:name="com.smarttoolfactory.home.propertylist.paged.PagedPropertyListFragment"
android:label="Flow + Pagination"
tools:layout="@layout/fragment_property_list_paged" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<fragment
android:id="@+id/propertyListFragment"
android:name="com.smarttoolfactory.home.propertylist.PropertyListRxjava3Fragment"
android:name="com.smarttoolfactory.home.propertylist.rxjava.PropertyListRxjava3Fragment"
android:label="Properties with RxJava3"
tools:layout="@layout/fragment_property_list">
</fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.google.common.truth.Truth
import com.smarttoolfactory.core.viewstate.Status
import com.smarttoolfactory.domain.model.PropertyItem
import com.smarttoolfactory.domain.usecase.GetPropertiesUseCaseFlow
import com.smarttoolfactory.home.propertylist.flow.PropertyListViewModelFlow
import com.smarttoolfactory.test_utils.RESPONSE_JSON_PATH
import com.smarttoolfactory.test_utils.rule.TestCoroutineRule
import com.smarttoolfactory.test_utils.test_observer.test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import com.google.common.truth.Truth
import com.smarttoolfactory.core.viewstate.Status
import com.smarttoolfactory.domain.model.PropertyItem
import com.smarttoolfactory.domain.usecase.GetPropertiesUseCaseRxJava3
import com.smarttoolfactory.home.viewmodel.AbstractPropertyListVM.Companion.ORDER_BY_NONE
import com.smarttoolfactory.home.propertylist.AbstractPropertyListVM.Companion.ORDER_BY_NONE
import com.smarttoolfactory.home.propertylist.rxjava.PropertyListViewModelRxJava3
import com.smarttoolfactory.test_utils.RESPONSE_JSON_PATH
import com.smarttoolfactory.test_utils.rule.RxImmediateSchedulerRule
import com.smarttoolfactory.test_utils.test_observer.test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import com.smarttoolfactory.data.model.IEntity
*
* * Implements [IEntity] marker interface for mapping this database items from REST DTOs or
* to UI items
*
* * Insert order is required for getting data same order they are inserted since ordering is
* done in server side.
*/
@Entity(tableName = "property", primaryKeys = ["insert_order"])
data class PropertyEntity(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ class GetPropertiesUseCasePaged @Inject constructor(
propertyEntity.insertOrder = propertyCount + index
}
savePropertyEntities(it)
val data = getPropertyEntitiesFromLocal()
data
getPropertyEntitiesFromLocal()
}
}
}
Expand Down

0 comments on commit a9b7e9d

Please sign in to comment.