image activity

This commit is contained in:
Enrique Blasco 2020-05-08 06:43:36 +02:00
parent b6ccae0f91
commit c85e9e6a18
9 changed files with 179 additions and 15 deletions

View File

@ -13,7 +13,10 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<activity android:name=".presentation.view.feature.main.activity.MainActivity"></activity>
<activity android:name=".presentation.view.feature.imageview.activity.ImageViewActivity"/>
<activity
android:name=".presentation.view.feature.main.activity.MainActivity"
android:windowSoftInputMode="stateHidden" />
<activity android:name=".presentation.view.feature.login.activity.LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

View File

@ -2,6 +2,8 @@ package es.verdnatura.presentation.common
import android.content.Context
import android.content.Intent
import android.graphics.Bitmap
import android.graphics.drawable.Drawable
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
@ -11,6 +13,8 @@ import androidx.fragment.app.FragmentActivity
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentTransaction
import com.bumptech.glide.Glide
import com.bumptech.glide.request.target.CustomTarget
import com.bumptech.glide.request.transition.Transition
inline fun FragmentManager.inTransaction(func: FragmentTransaction.() -> FragmentTransaction) =
@ -62,18 +66,18 @@ fun View.setMargins(left: Int, top: Int, right: Int, bottom: Int) {
fun ImageView.loadUrl(url: String) {
// load(url)
Glide.with(context).load(url).into(this)
// Glide.with(context)
// .asBitmap()
// .load(url)
// .into(object : CustomTarget<Bitmap>() {
//
// override fun onLoadCleared(placeholder: Drawable?) {}
//
// override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
// setImageBitmap(resource)
// }
// })
// Glide.with(context).load(url).into(this)
Glide.with(context)
.asBitmap()
.load(url)
.into(object : CustomTarget<Bitmap>() {
override fun onLoadCleared(placeholder: Drawable?) {}
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
setImageBitmap(resource)
}
})
}
inline val <reified T> T.TAG: String

View File

@ -51,8 +51,10 @@ class ItemCardAdapter (
this.item = item
if (item.isEditable){
itemImage.visibility = View.VISIBLE
itemRowLayout.setBackgroundColor(res.getColor(R.color.verdnatura_black_5))
}else{
itemImage.visibility = View.INVISIBLE
itemRowLayout.setBackgroundColor(res.getColor(R.color.verdnatura_black_9))
}
}

View File

@ -2,6 +2,7 @@ package es.verdnatura.presentation.view.feature.articulo.fragment
import android.content.Intent
import android.content.SharedPreferences
import android.view.View
import android.view.inputmethod.EditorInfo
@ -17,6 +18,7 @@ import es.verdnatura.presentation.view.component.CustomDialog
import es.verdnatura.presentation.view.feature.articulo.adapter.ItemCardAdapter
import es.verdnatura.presentation.view.feature.articulo.model.ItemCardRowVO
import es.verdnatura.presentation.view.feature.articulo.model.ItemCardVO
import es.verdnatura.presentation.view.feature.imageview.activity.ImageViewActivity
import es.verdnatura.presentation.view.feature.main.activity.MainActivity
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.fragment_item_card.*
@ -24,6 +26,9 @@ import kotlinx.android.synthetic.main.toolbar.*
class ItemCardFragment : BaseFragment<FragmentItemCardBinding,ItemCardViewModel>(ItemCardViewModel::class) {
private var urlLarge:String = ""
private var titleImage:String = ""
companion object {
fun newInstance() = ItemCardFragment()
}
@ -40,6 +45,7 @@ class ItemCardFragment : BaseFragment<FragmentItemCardBinding,ItemCardViewModel>
super.init()
}
private fun setEvents(){
edit_itemFk.requestFocus()
edit_itemFk.setOnEditorActionListener { v, actionId, event ->
@ -53,9 +59,17 @@ class ItemCardFragment : BaseFragment<FragmentItemCardBinding,ItemCardViewModel>
false
}
backButton.setOnClickListener {
activity!!.onBackPressed()
}
itemcard_image.setOnClickListener {
val i:Intent = Intent(activity,ImageViewActivity::class.java)
i.putExtra("url",urlLarge)
i.putExtra("title",titleImage)
startActivity(i)
}
}
private fun getItemCard(itemFk:String){
@ -96,7 +110,10 @@ class ItemCardFragment : BaseFragment<FragmentItemCardBinding,ItemCardViewModel>
private fun setItemCard(itemInfo:ItemCardVO){
toolbar_title.text = itemInfo.id+"-"+itemInfo.longName
titleImage = itemInfo.id+"-"+itemInfo.longName
itemcard_image.setImageDrawable(resources.getDrawable(R.drawable.loadphoto,resources.newTheme()))
itemcard_image.loadUrl(itemInfo.urlImage200)
urlLarge = itemInfo.urlImage
itemcard_tag1.text = itemInfo.size
itemcard_tag2.text = itemInfo.value5
itemcard_tag3.text = itemInfo.value6
@ -106,6 +123,7 @@ class ItemCardFragment : BaseFragment<FragmentItemCardBinding,ItemCardViewModel>
listItemsRow.add(ItemCardRowVO(title = "Disponible",value = itemInfo.available,isEditable = false))
listItemsRow.add(ItemCardRowVO(title = "Ubicado",value = itemInfo.enAltillo,isEditable = false))
//EDITABLES
listItemsRow.add(ItemCardRowVO(title = "SIN UBICAR",value = itemInfo.enNicho,isEditable = true))
listItemsRow.add(ItemCardRowVO(title = "NICHO",value = itemInfo.nicho,isEditable = true))
listItemsRow.add(ItemCardRowVO(title = "RESERVA",value = itemInfo.reserva,isEditable = true))

View File

@ -0,0 +1,31 @@
package es.verdnatura.presentation.view.feature.imageview.activity
import android.graphics.Bitmap
import android.graphics.drawable.Drawable
import androidx.appcompat.app.AppCompatActivity
import com.bumptech.glide.Glide
import com.bumptech.glide.request.target.CustomTarget
import com.bumptech.glide.request.transition.Transition
import es.verdnatura.R
import es.verdnatura.databinding.ActivityImageviewBinding
import es.verdnatura.presentation.base.BaseActivity
import es.verdnatura.presentation.common.loadUrl
import kotlinx.android.synthetic.main.activity_imageview.*
import kotlinx.android.synthetic.main.toolbar.*
class ImageViewActivity : BaseActivity<ActivityImageviewBinding>(){
override fun getLayoutId(): Int = R.layout.activity_imageview
override fun init() {
toolbar_title.text = (intent.getStringExtra("title"))
imgView.loadUrl(intent.getStringExtra("url"))
backButton.setOnClickListener {
onBackPressed()
}
}
}

View File

@ -42,6 +42,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() , OnPasillerosItemClick
else addFragment(AjustesFragment.newInstance(),R.id.main_frame_layout, AjustesFragment.TAG,false)
}
private fun haveSector() : Boolean{
val prefs: SharedPreferences = getSharedPreferences("es.verdnatura.user.prefs",0)
val sectorFk = prefs.getInt("sectorFk",-1)

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".presentation.view.feature.imageview.activity.ImageViewActivity">
<ImageView
android:id="@+id/imgView"
android:layout_width="0dp"
android:layout_height="0dp"
android:src="@drawable/loadphoto"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<include
android:id="@+id/main_toolbar"
layout="@layout/toolbar"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

View File

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
style="@style/DialogTheme"
android:layout_height="wrap_content"
android:layout_margin="@dimen/layout_margin_1"
app:cardBackgroundColor="@color/verdnatura_black_8"
app:cardCornerRadius="@dimen/dialog_radius">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/default_layout_margin">
<TextView
android:id="@+id/custom_dialog_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_margin_3"
android:layout_marginBottom="@dimen/default_layout_margin"
android:textAlignment="center"
android:textColor="@color/verdnatura_white"
android:textSize="@dimen/h6"
android:textStyle="bold"
android:visibility="gone"
tools:text="¿Estás seguro de que deseas eliminar el dispositivo de celia?"
tools:visibility="visible" />
<TextView
android:id="@+id/custom_dialog_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textColor="@color/verdnatura_white"
android:textSize="@dimen/body1"
android:visibility="gone"
tools:text="Este cambio no podrá deshacerse a no ser que vuelvas a vincular el dispositivo"
tools:visibility="visible" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textColor="@color/verdnatura_white"
android:textSize="@dimen/body1"
android:visibility="gone"
tools:hint="introduce valor"
tools:visibility="visible"
android:maxLines="1"
android:background="@color/verdnatura_brown_grey"
android:padding="@dimen/navigation_row_limit_padding"
android:layout_marginTop="@dimen/default_layout_margin"/>
<Button
android:id="@+id/custom_dialog_button_ok"
style="@style/DefaultButton.NormalButton"
android:layout_width="match_parent"
android:layout_marginTop="@dimen/default_layout_margin"
android:visibility="gone"
tools:text="Eliminar"
tools:visibility="visible" />
<Button
android:id="@+id/custom_dialog_button_ko"
style="@style/DefaultButton.TransparentButton"
android:layout_width="match_parent"
android:layout_marginTop="@dimen/default_layout_margin"
android:layout_marginBottom="@dimen/default_layout_margin"
android:visibility="gone"
tools:text="Cancelar"
tools:visibility="visible" />
</LinearLayout>
</androidx.cardview.widget.CardView>

View File

@ -1,8 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
>
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>