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 {
...
@@ -15,6 +15,8 @@ interface DaoPedido {
@Delete
@Delete
fun
delete
(
pedido
:
PedidoSave
)
fun
delete
(
pedido
:
PedidoSave
)
}
}
/*
/*
* @Dao
* @Dao
...
...
app/src/main/java/com/example/ayudapy/ListaModel.kt
View file @
e3266de9
...
@@ -12,4 +12,7 @@ class PedidoViewModel(application:Application): AndroidViewModel(application){
...
@@ -12,4 +12,7 @@ class PedidoViewModel(application:Application): AndroidViewModel(application){
fun
insert
(
student
:
PedidoSave
){
fun
insert
(
student
:
PedidoSave
){
db
.
daoPedido
().
insert
(
student
)
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
package
com.example.ayudapy
import
android.content.Context
import
android.content.Context
import
android.graphics.ColorSpace
import
android.os.Build
import
android.os.Build
import
android.view.LayoutInflater
import
android.view.LayoutInflater
import
android.view.View
import
android.view.View
import
android.view.ViewGroup
import
android.view.ViewGroup
import
android.widget.TextView
import
android.widget.TextView
import
android.widget.Toast
import
androidx.annotation.RequiresApi
import
androidx.annotation.RequiresApi
import
androidx.recyclerview.widget.RecyclerView
import
androidx.recyclerview.widget.RecyclerView
import
kotlinx.android.synthetic.main.pendientes_items.view.*
import
kotlinx.android.synthetic.main.pendientes_items.view.*
...
@@ -14,9 +16,14 @@ import java.time.LocalDateTime
...
@@ -14,9 +16,14 @@ import java.time.LocalDateTime
import
java.time.format.DateTimeFormatter
import
java.time.format.DateTimeFormatter
import
java.time.format.FormatStyle
import
java.time.format.FormatStyle
class
RecyclerViewAdapter
(
val
pedido
:
List
<
PedidoSave
>)
class
RecyclerViewAdapter
(
val
pedido
:
List
<
PedidoSave
>)
:
RecyclerView
.
Adapter
<
RecyclerViewAdapter
.
ViewHolder
>(){
:
RecyclerView
.
Adapter
<
RecyclerViewAdapter
.
ViewHolder
>(){
lateinit
var
context
:
Context
private
lateinit
var
db
:
pedidoDataBase
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
)
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
)
:
RecyclerViewAdapter
.
ViewHolder
{
:
RecyclerViewAdapter
.
ViewHolder
{
val
v
:
View
=
LayoutInflater
.
from
(
parent
.
context
)
val
v
:
View
=
LayoutInflater
.
from
(
parent
.
context
)
...
@@ -49,8 +56,22 @@ class RecyclerViewAdapter(val pedido: List<PedidoSave>)
...
@@ -49,8 +56,22 @@ class RecyclerViewAdapter(val pedido: List<PedidoSave>)
holder
.
date_month
.
text
=
mes
.
toUpperCase
()
holder
.
date_month
.
text
=
mes
.
toUpperCase
()
holder
.
title
.
text
=
pedido
[
position
].
title
holder
.
title
.
text
=
pedido
[
position
].
title
holder
.
message_view
.
text
=
pedido
[
position
].
message
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
{
override
fun
getItemCount
():
Int
{
return
pedido
.
size
return
pedido
.
size
}
}
...
@@ -63,11 +84,16 @@ class RecyclerViewAdapter(val pedido: List<PedidoSave>)
...
@@ -63,11 +84,16 @@ class RecyclerViewAdapter(val pedido: List<PedidoSave>)
return
super
.
getItemViewType
(
position
)
return
super
.
getItemViewType
(
position
)
}
}
class
ViewHolder
(
itemView
:
View
):
RecyclerView
.
ViewHolder
(
itemView
){
class
ViewHolder
(
itemView
:
View
):
RecyclerView
.
ViewHolder
(
itemView
){
val
date_day
=
itemView
.
date_day
val
date_day
=
itemView
.
date_day
val
date_month
=
itemView
.
date_month
val
date_month
=
itemView
.
date_month
val
title
=
itemView
.
title
val
title
=
itemView
.
title
val
message_view
=
itemView
.
message_view
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
...
@@ -2,16 +2,21 @@ package com.example.ayudapy
import
android.content.Intent
import
android.content.Intent
import
android.os.Bundle
import
android.os.Bundle
import
android.view.View
import
android.widget.ListAdapter
import
android.widget.Toast
import
androidx.appcompat.app.AppCompatActivity
import
androidx.appcompat.app.AppCompatActivity
import
androidx.lifecycle.Observer
import
androidx.lifecycle.Observer
import
androidx.lifecycle.ViewModelProviders
import
androidx.lifecycle.ViewModelProviders
import
androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.RecyclerView
import
androidx.recyclerview.widget.RecyclerView
import
kotlinx.android.synthetic.main.pendientes_items.view.*
import
kotlinx.android.synthetic.main.pendientes_lista.*
import
kotlinx.android.synthetic.main.pendientes_lista.*
class
PendienteLista
:
AppCompatActivity
()
{
class
PendienteLista
:
AppCompatActivity
()
{
private
lateinit
var
model
:
PedidoViewModel
private
lateinit
var
model
:
PedidoViewModel
private
lateinit
var
mDb
:
pedidoDataBase
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
pendientes_lista
)
setContentView
(
R
.
layout
.
pendientes_lista
)
...
@@ -31,6 +36,7 @@ class PendienteLista : AppCompatActivity() {
...
@@ -31,6 +36,7 @@ class PendienteLista : AppCompatActivity() {
recycler_view
.
adapter
=
RecyclerViewAdapter
(
pedido
)
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) {
...
@@ -16,6 +16,10 @@ class PedidoRepository(private val pedidoDao: DaoPedido) {
pedidoDao
.
insert
(
word
)
pedidoDao
.
insert
(
word
)
}
}
@WorkerThread
fun
delete
(
word
:
PedidoSave
)
{
pedidoDao
.
delete
(
word
)
}
/* --------------- BORRAR TODOS LOS DATOS -------------- */
/* --------------- BORRAR TODOS LOS DATOS -------------- */
...
...
app/src/main/res/layout/pendientes_items.xml
View file @
e3266de9
...
@@ -20,10 +20,12 @@
...
@@ -20,10 +20,12 @@
android:foreground=
"?android:attr/selectableItemBackground"
>
android:foreground=
"?android:attr/selectableItemBackground"
>
<TextView
<TextView
android:id=
"@+id/delete"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:layout_gravity=
"center"
android:padding=
"16dp"
android:padding=
"16dp"
android:text=
"@string/eliminar"
android:textColor=
"@android:color/white"
android:textColor=
"@android:color/white"
android:textSize=
"18sp"
android:textSize=
"18sp"
android:textStyle=
"bold"
/>
android:textStyle=
"bold"
/>
...
...
app/src/main/res/values/strings.xml
View file @
e3266de9
...
@@ -4,4 +4,5 @@
...
@@ -4,4 +4,5 @@
<!-- TODO: Remove or change this placeholder text -->
<!-- TODO: Remove or change this placeholder text -->
<string
name=
"hello_blank_fragment"
>
Hello blank fragment
</string>
<string
name=
"hello_blank_fragment"
>
Hello blank fragment
</string>
<string
name=
"eliminar"
>
Eliminar
</string>
</resources>
</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