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
dc67dd59
Commit
dc67dd59
authored
May 18, 2020
by
Yannine Alvarez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Agregar repository, model, adapter para recyclerview.
parent
12dbd616
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
202 additions
and
7 deletions
+202
-7
app/build.gradle
+10
-0
app/src/main/java/com/example/ayudapy/Dao.kt
+3
-2
app/src/main/java/com/example/ayudapy/ListaModel.kt
+16
-0
app/src/main/java/com/example/ayudapy/ListaPedidoAdapter.kt
+46
-0
app/src/main/java/com/example/ayudapy/MapsActivity.kt
+9
-2
app/src/main/java/com/example/ayudapy/PendienteLista.kt
+23
-1
app/src/main/java/com/example/ayudapy/Repository.kt
+61
-1
app/src/main/res/layout/pendientes_items.xml
+6
-1
app/src/main/res/values/colors.xml
+4
-0
app/src/main/res/values/styles.xml
+24
-0
No files found.
app/build.gradle
View file @
dc67dd59
...
@@ -79,6 +79,16 @@ dependencies {
...
@@ -79,6 +79,16 @@ dependencies {
implementation
'com.chauthai.swipereveallayout:swipe-reveal-layout:1.4.1'
implementation
'com.chauthai.swipereveallayout:swipe-reveal-layout:1.4.1'
// ViewModel and LiveData
def
lifecycle_version
=
"2.0.0"
implementation
"androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
// // COROUTINES
// api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$rootProject.coroutines"
// api "org.jetbrains.kotlinx:kotlinx-coroutines-android:$rootProject.coroutines"
//implementation "android.arch.lifecycle:extensions:1.1.1"
//implementation "android.arch.lifecycle:extensions:1.1.1"
//implementation "android.arch.persistence.room:runtime:1.0.0-rc1"
//implementation "android.arch.persistence.room:runtime:1.0.0-rc1"
//kapt "android.arch.persistence.room:compiler:1.0.0-rc1"
//kapt "android.arch.persistence.room:compiler:1.0.0-rc1"
...
...
app/src/main/java/com/example/ayudapy/Dao.kt
View file @
dc67dd59
...
@@ -6,8 +6,9 @@ import androidx.room.OnConflictStrategy.REPLACE
...
@@ -6,8 +6,9 @@ import androidx.room.OnConflictStrategy.REPLACE
@Dao
@Dao
interface
DaoPedido
{
interface
DaoPedido
{
@Query
(
"SELECT * from pedido_save"
)
fun
getAll
():
List
<
PedidoSave
>
@Query
(
"SELECT * FROM pedido_save"
)
fun
getAll
():
LiveData
<
List
<
PedidoSave
>>
@Insert
(
onConflict
=
OnConflictStrategy
.
REPLACE
)
@Insert
(
onConflict
=
OnConflictStrategy
.
REPLACE
)
fun
insert
(
pedido
:
PedidoSave
)
fun
insert
(
pedido
:
PedidoSave
)
...
...
app/src/main/java/com/example/ayudapy/ListaModel.kt
0 → 100644
View file @
dc67dd59
package
com.example.ayudapy
import
androidx.lifecycle.AndroidViewModel
import
androidx.lifecycle.LiveData
import
android.app.Application
class
PedidoViewModel
(
application
:
Application
):
AndroidViewModel
(
application
){
private
val
db
:
pedidoDataBase
=
pedidoDataBase
.
getInstance
(
application
)
internal
val
allPedidos
:
LiveData
<
List
<
PedidoSave
>>
=
db
.
daoPedido
().
getAll
()
fun
insert
(
student
:
PedidoSave
){
db
.
daoPedido
().
insert
(
student
)
}
}
\ No newline at end of file
app/src/main/java/com/example/ayudapy/ListaPedidoAdapter.kt
0 → 100644
View file @
dc67dd59
package
com.example.ayudapy
import
android.content.Context
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.widget.TextView
import
androidx.recyclerview.widget.RecyclerView
import
kotlinx.android.synthetic.main.pendientes_items.view.*
class
RecyclerViewAdapter
(
val
pedido
:
List
<
PedidoSave
>)
:
RecyclerView
.
Adapter
<
RecyclerViewAdapter
.
ViewHolder
>(){
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
)
:
RecyclerViewAdapter
.
ViewHolder
{
val
v
:
View
=
LayoutInflater
.
from
(
parent
.
context
)
.
inflate
(
R
.
layout
.
pendientes_items
,
parent
,
false
)
return
ViewHolder
(
v
)
}
override
fun
onBindViewHolder
(
holder
:
RecyclerViewAdapter
.
ViewHolder
,
position
:
Int
)
{
holder
.
date_day
.
text
=
pedido
[
position
].
added
holder
.
title
.
text
=
pedido
[
position
].
title
holder
.
message_view
.
text
=
pedido
[
position
].
message
}
override
fun
getItemCount
():
Int
{
return
pedido
.
size
}
override
fun
getItemId
(
position
:
Int
):
Long
{
return
super
.
getItemId
(
position
)
}
override
fun
getItemViewType
(
position
:
Int
):
Int
{
return
super
.
getItemViewType
(
position
)
}
class
ViewHolder
(
itemView
:
View
):
RecyclerView
.
ViewHolder
(
itemView
){
val
date_day
=
itemView
.
date_day
val
title
=
itemView
.
title
val
message_view
=
itemView
.
message_view
}
}
app/src/main/java/com/example/ayudapy/MapsActivity.kt
View file @
dc67dd59
...
@@ -18,6 +18,10 @@ import androidx.appcompat.app.AlertDialog
...
@@ -18,6 +18,10 @@ import androidx.appcompat.app.AlertDialog
import
androidx.appcompat.app.AppCompatActivity
import
androidx.appcompat.app.AppCompatActivity
import
androidx.core.app.ActivityCompat
import
androidx.core.app.ActivityCompat
import
androidx.core.content.ContextCompat
import
androidx.core.content.ContextCompat
import
androidx.lifecycle.Observer
import
androidx.lifecycle.ViewModelProviders
import
androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.RecyclerView
import
com.google.android.gms.location.FusedLocationProviderClient
import
com.google.android.gms.location.FusedLocationProviderClient
import
com.google.android.gms.location.LocationServices
import
com.google.android.gms.location.LocationServices
import
com.google.android.gms.maps.CameraUpdateFactory
import
com.google.android.gms.maps.CameraUpdateFactory
...
@@ -32,6 +36,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialog
...
@@ -32,6 +36,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialog
import
kotlinx.android.synthetic.main.alert_dialog_contacto.view.*
import
kotlinx.android.synthetic.main.alert_dialog_contacto.view.*
import
kotlinx.android.synthetic.main.fragment_pedido.view.*
import
kotlinx.android.synthetic.main.fragment_pedido.view.*
import
kotlinx.android.synthetic.main.info.*
import
kotlinx.android.synthetic.main.info.*
import
kotlinx.android.synthetic.main.pendientes_lista.*
import
org.jetbrains.anko.doAsync
import
org.jetbrains.anko.doAsync
import
retrofit2.Call
import
retrofit2.Call
import
retrofit2.Callback
import
retrofit2.Callback
...
@@ -51,6 +56,7 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMarker
...
@@ -51,6 +56,7 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMarker
private
lateinit
var
mDb
:
pedidoDataBase
private
lateinit
var
mDb
:
pedidoDataBase
companion
object
{
companion
object
{
private
const
val
LOCATION_PERMISSION_REQUEST_CODE
=
1
private
const
val
LOCATION_PERMISSION_REQUEST_CODE
=
1
}
}
...
@@ -124,6 +130,7 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMarker
...
@@ -124,6 +130,7 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMarker
//agregar permiso para llamar
//agregar permiso para llamar
val
permissionCheck
:
Int
=
ContextCompat
.
checkSelfPermission
(
val
permissionCheck
:
Int
=
ContextCompat
.
checkSelfPermission
(
this
,
Manifest
.
permission
.
CALL_PHONE
this
,
Manifest
.
permission
.
CALL_PHONE
...
@@ -363,12 +370,12 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMarker
...
@@ -363,12 +370,12 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMarker
mDb
.
daoPedido
().
insert
(
pedidoEntity
)
mDb
.
daoPedido
().
insert
(
pedidoEntity
)
mDb
.
daoPedido
().
getAll
().
forEach
()
/*
mDb.daoPedido().getAll().forEach()
{
{
Log.i("Fetch Records", "Id: ${it.id}")
Log.i("Fetch Records", "Id: ${it.id}")
println("Name es de pedido: ${it.name}")
println("Name es de pedido: ${it.name}")
}
}
*/
}
}
pedido
.
start
()
pedido
.
start
()
...
...
app/src/main/java/com/example/ayudapy/PendienteLista.kt
View file @
dc67dd59
...
@@ -3,12 +3,34 @@ package com.example.ayudapy
...
@@ -3,12 +3,34 @@ package com.example.ayudapy
import
android.content.Intent
import
android.content.Intent
import
android.os.Bundle
import
android.os.Bundle
import
androidx.appcompat.app.AppCompatActivity
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_lista.*
class
PendienteLista
:
AppCompatActivity
()
{
class
PendienteLista
:
AppCompatActivity
()
{
private
lateinit
var
model
:
PedidoViewModel
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
)
val
intento
:
Intent
=
intent
// Get the view model
model
=
ViewModelProviders
.
of
(
this
).
get
(
PedidoViewModel
::
class
.
java
)
// Specify layout for recycler view
val
linearLayoutManager
=
LinearLayoutManager
(
this
,
RecyclerView
.
VERTICAL
,
false
)
recycler_view
.
layoutManager
=
linearLayoutManager
// Observe the model
model
.
allPedidos
.
observe
(
this
,
Observer
{
pedido
->
// Data bind the recycler view
recycler_view
.
adapter
=
RecyclerViewAdapter
(
pedido
)
})
}
}
}
}
app/src/main/java/com/example/ayudapy/Repository.kt
View file @
dc67dd59
package
com.example.ayudapy
package
com.example.ayudapy
class
Repository
{
import
android.os.AsyncTask
import
androidx.annotation.WorkerThread
import
androidx.lifecycle.LiveData
// Declares the DAO as a private property in the constructor. Pass in the DAO
// instead of the whole database, because you only need access to the DAO
class
PedidoRepository
(
private
val
pedidoDao
:
DaoPedido
)
{
val
allPedidos
:
LiveData
<
List
<
PedidoSave
>>
=
pedidoDao
.
getAll
()
@WorkerThread
fun
insert
(
word
:
PedidoSave
)
{
pedidoDao
.
insert
(
word
)
}
/* --------------- BORRAR TODOS LOS DATOS -------------- */
/*fun deleteAll() {
deleteAllWordsAsyncTask(wordDao).execute()
}*/
/* private class deleteAllWordsAsyncTask internal constructor(private val mAsyncTaskDao: DaoPedido) :
AsyncTask<Void, Void, Void>() {
override fun doInBackground(vararg voids: Void): Void? {
mAsyncTaskDao.delete()
return null
}
}*/
/* ---------------- BORRAR UN SOLO DATO ---------------- */
/* fun deleteWord(word: PedidoSave) {
deleteWordAsyncTask(wordDao).execute(word)
}
private class deleteWordAsyncTask internal constructor(private val mAsyncTaskDao: DaoPedido) :
AsyncTask<PedidoSave, Void, Void>() {
override fun doInBackground(vararg params: PedidoSave): Void? {
mAsyncTaskDao.delete(params[0])
return null
}
}*/
/* -------------- ACTUALIZAR UN SOLO DATO ----------------
fun update(word: Word) {
updateWordAsyncTask(wordDao).execute(word)
}
private class updateWordAsyncTask internal constructor(private val mAsyncTaskDao: WordDao) :
AsyncTask<Word, Void, Void>() {
override fun doInBackground(vararg params: Word?): Void? {
mAsyncTaskDao.update(params[0]!!)
return null
}
}*/
}
}
\ No newline at end of file
app/src/main/res/layout/pendientes_items.xml
View file @
dc67dd59
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
xmlns:tools=
"http://schemas.android.com/tools"
android:id=
"@+id/swipe_layout"
android:id=
"@+id/swipe_layout"
android:background=
"#FFFFFF"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"100dp"
android:layout_height=
"100dp"
app:dragEdge=
"right"
app:dragEdge=
"right"
...
@@ -32,6 +33,7 @@
...
@@ -32,6 +33,7 @@
android:id=
"@+id/front_layout"
android:id=
"@+id/front_layout"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"#FFFFFF"
android:paddingStart=
"8dp"
android:paddingStart=
"8dp"
android:paddingEnd=
"8dp"
>
android:paddingEnd=
"8dp"
>
...
@@ -39,6 +41,7 @@
...
@@ -39,6 +41,7 @@
android:id=
"@+id/card_view"
android:id=
"@+id/card_view"
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"#FFFFFF"
android:clickable=
"true"
android:clickable=
"true"
android:focusable=
"true"
android:focusable=
"true"
android:foreground=
"?android:attr/selectableItemBackground"
android:foreground=
"?android:attr/selectableItemBackground"
...
@@ -51,7 +54,8 @@
...
@@ -51,7 +54,8 @@
<RelativeLayout
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
android:layout_height=
"match_parent"
android:background=
"#FFFFFF"
>
<LinearLayout
<LinearLayout
android:id=
"@+id/llDate"
android:id=
"@+id/llDate"
...
@@ -112,6 +116,7 @@
...
@@ -112,6 +116,7 @@
android:layout_below=
"@id/title"
android:layout_below=
"@id/title"
android:layout_marginTop=
"4dp"
android:layout_marginTop=
"4dp"
android:layout_toEndOf=
"@id/view"
android:layout_toEndOf=
"@id/view"
android:textColor=
"@color/colorPrimary"
android:ellipsize=
"end"
android:ellipsize=
"end"
android:maxLines=
"2"
android:maxLines=
"2"
tools:text=
"Message"
/>
tools:text=
"Message"
/>
...
...
app/src/main/res/values/colors.xml
View file @
dc67dd59
...
@@ -5,4 +5,8 @@
...
@@ -5,4 +5,8 @@
<color
name=
"colorAccent"
>
#03DAC5
</color>
<color
name=
"colorAccent"
>
#03DAC5
</color>
<color
name=
"colorBlancoTransparente"
>
#33FFFFFF
</color>
<color
name=
"colorBlancoTransparente"
>
#33FFFFFF
</color>
<color
name=
"light_gray"
>
#CCC
</color>
<color
name=
"light_gray"
>
#CCC
</color>
<color
name=
"colorAccentDark"
>
#009A9B
</color>
<color
name=
"pink"
>
#FD5C7F
</color>
<color
name=
"red"
>
#f44336
</color>
<color
name=
"green"
>
#388E3C
</color>
</resources>
</resources>
app/src/main/res/values/styles.xml
View file @
dc67dd59
...
@@ -13,5 +13,29 @@
...
@@ -13,5 +13,29 @@
<item
name=
"cornerRadius"
>
12dp
</item>
<item
name=
"cornerRadius"
>
12dp
</item>
</style>
</style>
<style
name=
"BaseAppTheme"
parent=
"AppTheme"
/>
<style
name=
"CustomBottomSheetDialog"
parent=
"@style/ThemeOverlay.MaterialComponents.BottomSheetDialog"
>
<item
name=
"bottomSheetStyle"
>
@style/CustomBottomSheet
</item>
</style>
<style
name=
"CustomBottomSheet"
parent=
"Widget.MaterialComponents.BottomSheet.Modal"
>
<item
name=
"shapeAppearance"
>
@style/BottomSheetShapeAppearance
</item>
</style>
<style
name=
"BottomSheetShapeAppearance"
>
<item
name=
"cornerFamily"
>
rounded
</item>
<item
name=
"cornerSize"
>
12dp
</item>
</style>
<style
name=
"BottomDialogFragmentBar"
>
<item
name=
"android:layout_width"
>
80dp
</item>
<item
name=
"android:layout_height"
>
4dp
</item>
<item
name=
"android:layout_marginTop"
>
16dp
</item>
<item
name=
"android:background"
>
@drawable/background_round
</item>
</style>
</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