Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
Ayudapy
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yannine Alvarez
Ayudapy
Commits
e3266de9
Commit
e3266de9
authored
May 19, 2020
by
Yannine Alvarez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete en recycler view.
parent
794df526
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
45 additions
and
0 deletions
+45
-0
app/src/main/java/com/example/ayudapy/Dao.kt
+2
-0
app/src/main/java/com/example/ayudapy/ListaModel.kt
+4
-0
app/src/main/java/com/example/ayudapy/ListaPedidoAdapter.kt
+26
-0
app/src/main/java/com/example/ayudapy/PendienteLista.kt
+6
-0
app/src/main/java/com/example/ayudapy/Repository.kt
+4
-0
app/src/main/res/layout/pendientes_items.xml
+2
-0
app/src/main/res/values/strings.xml
+1
-0
No files found.
app/src/main/java/com/example/ayudapy/Dao.kt
View file @
e3266de9
...
...
@@ -15,6 +15,8 @@ interface DaoPedido {
@Delete
fun
delete
(
pedido
:
PedidoSave
)
}
/*
* @Dao
...
...
app/src/main/java/com/example/ayudapy/ListaModel.kt
View file @
e3266de9
...
...
@@ -12,4 +12,7 @@ class PedidoViewModel(application:Application): AndroidViewModel(application){
fun
insert
(
student
:
PedidoSave
){
db
.
daoPedido
().
insert
(
student
)
}
fun
delete
(
student
:
PedidoSave
){
db
.
daoPedido
().
delete
(
student
)
}
}
\ No newline at end of file
app/src/main/java/com/example/ayudapy/ListaPedidoAdapter.kt
View file @
e3266de9
package
com.example.ayudapy
import
android.content.Context
import
android.graphics.ColorSpace
import
android.os.Build
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.widget.TextView
import
android.widget.Toast
import
androidx.annotation.RequiresApi
import
androidx.recyclerview.widget.RecyclerView
import
kotlinx.android.synthetic.main.pendientes_items.view.*
...
...
@@ -14,9 +16,14 @@ import java.time.LocalDateTime
import
java.time.format.DateTimeFormatter
import
java.time.format.FormatStyle
class
RecyclerViewAdapter
(
val
pedido
:
List
<
PedidoSave
>)
:
RecyclerView
.
Adapter
<
RecyclerViewAdapter
.
ViewHolder
>(){
lateinit
var
context
:
Context
private
lateinit
var
db
:
pedidoDataBase
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
)
:
RecyclerViewAdapter
.
ViewHolder
{
val
v
:
View
=
LayoutInflater
.
from
(
parent
.
context
)
...
...
@@ -49,8 +56,22 @@ class RecyclerViewAdapter(val pedido: List<PedidoSave>)
holder
.
date_month
.
text
=
mes
.
toUpperCase
()
holder
.
title
.
text
=
pedido
[
position
].
title
holder
.
message_view
.
text
=
pedido
[
position
].
message
holder
.
delete_layout
.
setOnClickListener
{
//Toast.makeText(context,"clicked",Toast.LENGTH_SHORT).show()
println
(
"Hace clic "
)
// val pedido = Thread{
db
.
daoPedido
().
delete
(
pedido
[
position
])
// }
// pedido.start()
}
}
override
fun
getItemCount
():
Int
{
return
pedido
.
size
}
...
...
@@ -63,11 +84,16 @@ class RecyclerViewAdapter(val pedido: List<PedidoSave>)
return
super
.
getItemViewType
(
position
)
}
class
ViewHolder
(
itemView
:
View
):
RecyclerView
.
ViewHolder
(
itemView
){
val
date_day
=
itemView
.
date_day
val
date_month
=
itemView
.
date_month
val
title
=
itemView
.
title
val
message_view
=
itemView
.
message_view
val
delete_layout
=
itemView
.
delete_layout
}
}
app/src/main/java/com/example/ayudapy/PendienteLista.kt
View file @
e3266de9
...
...
@@ -2,16 +2,21 @@ package com.example.ayudapy
import
android.content.Intent
import
android.os.Bundle
import
android.view.View
import
android.widget.ListAdapter
import
android.widget.Toast
import
androidx.appcompat.app.AppCompatActivity
import
androidx.lifecycle.Observer
import
androidx.lifecycle.ViewModelProviders
import
androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.RecyclerView
import
kotlinx.android.synthetic.main.pendientes_items.view.*
import
kotlinx.android.synthetic.main.pendientes_lista.*
class
PendienteLista
:
AppCompatActivity
()
{
private
lateinit
var
model
:
PedidoViewModel
private
lateinit
var
mDb
:
pedidoDataBase
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
pendientes_lista
)
...
...
@@ -31,6 +36,7 @@ class PendienteLista : AppCompatActivity() {
recycler_view
.
adapter
=
RecyclerViewAdapter
(
pedido
)
})
}
}
app/src/main/java/com/example/ayudapy/Repository.kt
View file @
e3266de9
...
...
@@ -16,6 +16,10 @@ class PedidoRepository(private val pedidoDao: DaoPedido) {
pedidoDao
.
insert
(
word
)
}
@WorkerThread
fun
delete
(
word
:
PedidoSave
)
{
pedidoDao
.
delete
(
word
)
}
/* --------------- BORRAR TODOS LOS DATOS -------------- */
...
...
app/src/main/res/layout/pendientes_items.xml
View file @
e3266de9
...
...
@@ -20,10 +20,12 @@
android:foreground=
"?android:attr/selectableItemBackground"
>
<TextView
android:id=
"@+id/delete"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:padding=
"16dp"
android:text=
"@string/eliminar"
android:textColor=
"@android:color/white"
android:textSize=
"18sp"
android:textStyle=
"bold"
/>
...
...
app/src/main/res/values/strings.xml
View file @
e3266de9
...
...
@@ -4,4 +4,5 @@
<!-- TODO: Remove or change this placeholder text -->
<string
name=
"hello_blank_fragment"
>
Hello blank fragment
</string>
<string
name=
"eliminar"
>
Eliminar
</string>
</resources>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment