File tree Expand file tree Collapse file tree 3 files changed +27
-12
lines changed
omegatypes/src/main/java/com/omega_r/libs/omegatypes
picasso/src/main/java/com/omega_r/libs/omegatypes/picasso Expand file tree Collapse file tree 3 files changed +27
-12
lines changed Original file line number Diff line number Diff line change @@ -180,28 +180,28 @@ open class Text : Serializable {
180180
181181}
182182
183- fun TextView.setText (text : Text ) {
184- this .text = text.getString(this .resources)
183+ fun TextView.setText (text : Text ? ) {
184+ this .text = text? .getString(this .resources)
185185}
186186
187- fun EditText.setError (text : Text ) {
188- this .error = text.getString(this .resources)
187+ fun EditText.setError (text : Text ? ) {
188+ this .error = text? .getString(this .resources)
189189}
190190
191- fun EditText.setHint (text : Text ) {
192- this .hint = text.getString(this .resources)
191+ fun EditText.setHint (text : Text ? ) {
192+ this .hint = text? .getString(this .resources)
193193}
194194
195- fun Text.applyTo (textView : TextView ) {
195+ fun Text? .applyTo (textView : TextView ) {
196196 textView.setText(this )
197197}
198198
199- fun Text.applyErrorTo (editText : EditText ) {
199+ fun Text? .applyErrorTo (editText : EditText ) {
200200 editText.setError(this )
201201}
202202
203- fun Activity.setTitle (text : Text ) {
204- title = text.getString(resources)
203+ fun Activity.setTitle (text : Text ? ) {
204+ title = text? .getString(resources)
205205}
206206
207207fun Context.toast (text : Text , duration : Int = Toast .LENGTH_SHORT ): Toast {
Original file line number Diff line number Diff line change 1+ package com.omega_r.libs.omegatypes
2+
3+ /* *
4+ * Created by Anton Knyazev on 14.04.2019.
5+ */
6+ interface UrlImage {
7+
8+ val url: String
9+
10+ }
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import android.os.Looper
99import android.view.View
1010import android.widget.ImageView
1111import com.omega_r.libs.omegatypes.Image
12+ import com.omega_r.libs.omegatypes.UrlImage
1213import com.omega_r.libs.omegatypes.toInputStream
1314import com.squareup.picasso.Picasso
1415import com.squareup.picasso.Target
@@ -20,15 +21,19 @@ import java.io.InputStream
2021
2122fun Image.Companion.from (url : String ) = PicassoImage (url)
2223
23- class PicassoImage (val url : String ) : Image() {
24+ class PicassoImage (override val url : String ) : Image(), UrlImage {
2425
2526 override fun applyImage (imageView : ImageView , placeholderResId : Int ) {
2627 Picasso .get()
2728 .load(url)
2829 .apply {
2930 if (placeholderResId != 0 ) placeholder(placeholderResId)
3031 fit()
31- centerCrop()
32+ if (imageView.scaleType == ImageView .ScaleType .CENTER_INSIDE ) {
33+ centerInside()
34+ } else {
35+ centerCrop()
36+ }
3237 into(imageView)
3338 }
3439 }
You can’t perform that action at this time.
0 commit comments