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
7f81bfb4
Commit
7f81bfb4
authored
May 14, 2020
by
Yannine Alvarez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Agregar función room.
parent
1623ce2c
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
74 additions
and
21 deletions
+74
-21
.idea/vcs.xml
+7
-0
app/build.gradle
+6
-0
app/src/main/java/com/example/ayudapy/Dao.kt
+10
-1
app/src/main/java/com/example/ayudapy/DataBaseRoom.kt
+10
-15
app/src/main/java/com/example/ayudapy/MapsActivity.kt
+36
-5
app/src/main/java/com/example/ayudapy/Repository.kt
+5
-0
app/src/main/res/drawable-xxhdpi/icon_pendientes_checked.png
+0
-0
No files found.
.idea/vcs.xml
0 → 100644
View file @
7f81bfb4
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"VcsDirectoryMappings"
>
<mapping
directory=
""
vcs=
"Git"
/>
</component>
</project>
\ No newline at end of file
app/build.gradle
View file @
7f81bfb4
apply
plugin:
'com.android.application'
apply
plugin:
'com.android.application'
//apply plugin: 'com.android.library'
apply
plugin:
'kotlin-android'
apply
plugin:
'kotlin-android'
apply
plugin:
'kotlin-android-extensions'
apply
plugin:
'kotlin-android-extensions'
apply
plugin:
'kotlin-kapt'
apply
plugin:
'kotlin-kapt'
...
@@ -63,6 +64,7 @@ dependencies {
...
@@ -63,6 +64,7 @@ dependencies {
//implementation 'com.squareup.okio:okio:2.4.3'
//implementation 'com.squareup.okio:okio:2.4.3'
//noinspection GradleCompatible
//noinspection GradleCompatible
implementation
'com.android.support:recyclerview-v7:28.0.0'
implementation
'com.android.support:recyclerview-v7:28.0.0'
implementation
'com.squareup.picasso:picasso:2.71828'
implementation
'com.squareup.picasso:picasso:2.71828'
implementation
'androidx.cardview:cardview:1.0.0'
implementation
'androidx.cardview:cardview:1.0.0'
...
@@ -73,8 +75,12 @@ dependencies {
...
@@ -73,8 +75,12 @@ dependencies {
implementation
'android.arch.persistence.room:runtime:1.1.1'
implementation
'android.arch.persistence.room:runtime:1.1.1'
kapt
'android.arch.persistence.room:compiler:1.1.1'
kapt
'android.arch.persistence.room:compiler:1.1.1'
implementation
'org.jetbrains.anko:anko-common:0.9'
//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 @
7f81bfb4
...
@@ -9,12 +9,21 @@ interface DaoPedido {
...
@@ -9,12 +9,21 @@ interface DaoPedido {
@Query
(
"SELECT * from pedido_save"
)
@Query
(
"SELECT * from pedido_save"
)
fun
getAll
():
List
<
PedidoSave
>
fun
getAll
():
List
<
PedidoSave
>
@Insert
(
onConflict
=
REPLACE
)
@Insert
(
onConflict
=
OnConflictStrategy
.
REPLACE
)
fun
insert
(
pedido
:
PedidoSave
)
fun
insert
(
pedido
:
PedidoSave
)
@Delete
@Delete
fun
delete
(
pedido
:
PedidoSave
)
fun
delete
(
pedido
:
PedidoSave
)
}
}
/*
* @Dao
interface studentDao{
@Query("SELECT * FROM studentTbl")
fun allStudents():List<Student>
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(student:Student)
}*/
/* @Query("UPDATE pedido_save SET name =:studentName, nim =:studentNim, gender =:studentGen WHERE id =:studentId")
/* @Query("UPDATE pedido_save SET name =:studentName, nim =:studentNim, gender =:studentGen WHERE id =:studentId")
fun update(studentId: Long, studentName:String, studentNim:String, studentGen:String)*/
fun update(studentId: Long, studentName:String, studentNim:String, studentGen:String)*/
...
...
app/src/main/java/com/example/ayudapy/DataBaseRoom.kt
View file @
7f81bfb4
...
@@ -4,27 +4,21 @@ import android.content.Context
...
@@ -4,27 +4,21 @@ import android.content.Context
import
androidx.room.Database
import
androidx.room.Database
import
androidx.room.Room
import
androidx.room.Room
import
androidx.room.RoomDatabase
import
androidx.room.RoomDatabase
@Database
(
entities
=
arrayOf
(
PedidoSave
::
class
),
version
=
1
)
@Database
(
entities
=
arrayOf
(
PedidoSave
::
class
),
version
=
1
)
abstract
class
PedidoDataBase
:
RoomDatabase
()
{
abstract
class
pedidoDataBase
:
RoomDatabase
()
{
abstract
fun
daoPedido
():
DaoPedido
abstract
fun
daoPedido
():
DaoPedido
companion
object
{
companion
object
{
private
var
INSTANCE
:
PedidoDataBase
?
=
null
private
var
INSTANCE
:
pedidoDataBase
?
=
null
fun
getInstance
(
context
:
Context
):
pedidoDataBase
{
fun
getInstance
(
context
:
Context
):
PedidoDataBase
?
{
if
(
INSTANCE
==
null
)
{
if
(
INSTANCE
==
null
)
{
synchronized
(
PedidoDataBase
::
class
)
{
INSTANCE
=
Room
.
databaseBuilder
(
INSTANCE
=
Room
.
databaseBuilder
(
context
.
getApplicationContext
(),
context
,
PedidoDataBase
::
class
.
java
,
"pedidodata.db"
)
pedidoDataBase
::
class
.
java
,
"roomdb"
)
.
build
()
.
build
()
}
}
}
return
INSTANCE
as
pedidoDataBase
return
INSTANCE
}
fun
destroyInstance
()
{
INSTANCE
=
null
}
}
}
}
}
}
\ No newline at end of file
app/src/main/java/com/example/ayudapy/MapsActivity.kt
View file @
7f81bfb4
...
@@ -30,13 +30,18 @@ import com.google.android.gms.maps.model.Marker
...
@@ -30,13 +30,18 @@ import com.google.android.gms.maps.model.Marker
import
com.google.android.gms.maps.model.MarkerOptions
import
com.google.android.gms.maps.model.MarkerOptions
import
com.google.android.material.bottomsheet.BottomSheetDialog
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.*
import
kotlinx.android.synthetic.main.fragment_pedido.view.*
import
kotlinx.android.synthetic.main.fragment_pedido.view.*
import
kotlinx.android.synthetic.main.fragment_pedido.view.pedido_id
import
org.jetbrains.anko.doAsync
import
retrofit2.Call
import
retrofit2.Call
import
retrofit2.Callback
import
retrofit2.Callback
import
retrofit2.Response
import
retrofit2.Response
import
java.time.LocalDateTime
import
java.time.LocalDateTime
import
java.time.format.DateTimeFormatter
import
java.time.format.DateTimeFormatter
class
MapsActivity
:
AppCompatActivity
(),
OnMapReadyCallback
,
GoogleMap
.
OnMarkerClickListener
{
class
MapsActivity
:
AppCompatActivity
(),
OnMapReadyCallback
,
GoogleMap
.
OnMarkerClickListener
{
private
lateinit
var
mMap
:
GoogleMap
private
lateinit
var
mMap
:
GoogleMap
...
@@ -45,6 +50,9 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMarker
...
@@ -45,6 +50,9 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMarker
internal
lateinit
var
infoButton
:
Button
internal
lateinit
var
infoButton
:
Button
private
var
selectedMarker
:
Marker
?=
null
private
var
selectedMarker
:
Marker
?=
null
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
}
}
...
@@ -68,7 +76,7 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMarker
...
@@ -68,7 +76,7 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMarker
return
false
return
false
}
}
}
}
private
var
pedidoDatabase
:
PedidoDataBase
?
=
null
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
...
@@ -79,6 +87,10 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMarker
...
@@ -79,6 +87,10 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMarker
.
findFragmentById
(
R
.
id
.
map
)
as
SupportMapFragment
.
findFragmentById
(
R
.
id
.
map
)
as
SupportMapFragment
mapFragment
.
getMapAsync
(
this
)
mapFragment
.
getMapAsync
(
this
)
// Initialize the room database
mDb
=
pedidoDataBase
.
getInstance
(
applicationContext
)
fusedLocationClient
=
LocationServices
.
getFusedLocationProviderClient
(
this
)
fusedLocationClient
=
LocationServices
.
getFusedLocationProviderClient
(
this
)
//intent para mandar a la siguiente pantalla el boton
//intent para mandar a la siguiente pantalla el boton
...
@@ -120,7 +132,7 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMarker
...
@@ -120,7 +132,7 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMarker
Log
.
i
(
"Mensaje"
,
"Se tiene permiso!"
)
Log
.
i
(
"Mensaje"
,
"Se tiene permiso!"
)
}
}
pedidoDatabase
=
PedidoDataBase
.
getInstance
(
this
)
}
}
...
@@ -331,6 +343,28 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMarker
...
@@ -331,6 +343,28 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMarker
pedidoDetalle.title,pedidoDetalle.message,pedidoDetalle.name,pedidoDetalle.phone,
pedidoDetalle.title,pedidoDetalle.message,pedidoDetalle.name,pedidoDetalle.phone,
pedidoDetalle.address,pedidoDetalle.added))*/
pedidoDetalle.address,pedidoDetalle.added))*/
// Initialize a new student
val
pedido
=
PedidoSave
(
id
=
pedidoDetalle
!!
.
id
,
added
=
pedidoDetalle
!!
.
added
,
address
=
pedidoDetalle
!!
.
address
,
message
=
pedidoDetalle
!!
.
message
,
name
=
pedidoDetalle
!!
.
name
,
phone
=
pedidoDetalle
!!
.
phone
,
title
=
pedidoDetalle
!!
.
title
)
doAsync
{
//Application.database.myDAO().insertUser(user)
mDb
.
daoPedido
().
insert
(
pedido
)
}
view
.
pendiente_button
.
setBackgroundResource
(
R
.
drawable
.
icon_pendientes_checked
)
}
}
view
.
listo_button
.
setOnClickListener
{
view
.
listo_button
.
setOnClickListener
{
...
@@ -350,9 +384,6 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMarker
...
@@ -350,9 +384,6 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMarker
)
)
}
}
/* fun insertToDb(pedido:PedidoSave){
}*/
//permiso para acceder a la ubicacion del dispositvo
//permiso para acceder a la ubicacion del dispositvo
private
fun
setup
(){
private
fun
setup
(){
...
...
app/src/main/java/com/example/ayudapy/Repository.kt
0 → 100644
View file @
7f81bfb4
package
com.example.ayudapy
class
Repository
{
}
\ No newline at end of file
app/src/main/res/drawable-xxhdpi/icon_pendientes_checked.png
0 → 100644
View file @
7f81bfb4
3.21 KB
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