-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite details feature using view binding (#120)
- Transfer databinding to viewbinding module - Move ICharacterDetailViewModel and ICharacterDetailViewState to api module, cause it is API. - Remove LiveData from API of ICharacterDetailViewState (debatable) - Add ImageViewExtensions.kt file to provide extension to loadImage by url. Copy of databinding-adapter method Closes #100
- Loading branch information
Grigoriy Bykov
authored
May 3, 2023
1 parent
9734598
commit 4182e87
Showing
17 changed files
with
191 additions
and
173 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
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 |
---|---|---|
|
@@ -12,5 +12,7 @@ androidUtil( | |
androidx.paging, | ||
google.material, | ||
io.coil | ||
) + deps( | ||
target(":common:placeholder:res") | ||
) | ||
) |
38 changes: 38 additions & 0 deletions
38
.../src/main/java/com/stepango/blockme/common/extensions/android/util/ImageViewExtensions.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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2023 forma.tools | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.stepango.blockme.common.extensions.android.util | ||
|
||
import android.graphics.Color | ||
import android.graphics.drawable.ColorDrawable | ||
import android.widget.ImageView | ||
import androidx.annotation.DrawableRes | ||
import androidx.core.content.ContextCompat | ||
import coil.load | ||
import kotlin.random.Random | ||
|
||
fun ImageView.loadImage(url: String?, @DrawableRes placeholderId: Int? = null) { | ||
load(url) { | ||
crossfade(true) | ||
placeholder(placeholderId?.let { | ||
ContextCompat.getDrawable(context, it) | ||
} ?: run { | ||
val placeholdersColors = resources.getStringArray(R.array.placeholders) | ||
val placeholderColor = placeholdersColors[Random.nextInt(placeholdersColors.size)] | ||
ColorDrawable(Color.parseColor(placeholderColor)) | ||
}) | ||
} | ||
} |
Empty file.
8 changes: 1 addition & 7 deletions
8
...presentation/ICharacterDetailViewModel.kt → ...presentation/ICharacterDetailViewModel.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
17 changes: 0 additions & 17 deletions
17
application/feature/characters/detail/databinding/build.gradle.kts
This file was deleted.
Oops, something went wrong.
83 changes: 0 additions & 83 deletions
83
...n/feature/characters/detail/databinding/src/main/res/layout/fragment_character_detail.xml
This file was deleted.
Oops, something went wrong.
45 changes: 0 additions & 45 deletions
45
...ature/characters/detail/databinding/src/main/res/layout/view_character_detail_content.xml
This file was deleted.
Oops, something went wrong.
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
File renamed without changes.
10 changes: 10 additions & 0 deletions
10
application/feature/characters/detail/viewbinding/build.gradle.kts
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
viewBinding( | ||
packageName = "com.stepango.blockme.feature.characters.detail.viewbinding", | ||
dependencies = deps( | ||
google.material, | ||
androidx.constraintlayout, | ||
) + deps( | ||
target(":feature:characters:detail:res"), | ||
target(":core:theme:res"), | ||
) | ||
) |
Oops, something went wrong.