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
8cd58994
Commit
8cd58994
authored
May 19, 2020
by
Yannine Alvarez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ordenar las clases por carpeta.
parent
e3266de9
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
61 additions
and
50 deletions
+61
-50
app/src/main/java/com/example/ayudapy/MapsActivity.kt
+9
-10
app/src/main/java/com/example/ayudapy/PendienteLista.kt
+6
-7
app/src/main/java/com/example/ayudapy/adapter/ListaPedidoAdapter.kt
+7
-10
app/src/main/java/com/example/ayudapy/api/ApiPedidos.kt
+2
-5
app/src/main/java/com/example/ayudapy/api/ApiService.kt
+19
-4
app/src/main/java/com/example/ayudapy/db/Dao.kt
+1
-2
app/src/main/java/com/example/ayudapy/db/DataBaseRoom.kt
+3
-2
app/src/main/java/com/example/ayudapy/db/Entity.kt
+1
-1
app/src/main/java/com/example/ayudapy/db/ListaModel.kt
+7
-4
app/src/main/java/com/example/ayudapy/db/Repository.kt
+3
-2
app/src/main/java/com/example/ayudapy/model/CentroAyuda.kt
+1
-1
app/src/main/java/com/example/ayudapy/model/PedidoDetalle.kt
+1
-1
app/src/main/java/com/example/ayudapy/model/PedidosAyuda.kt
+1
-1
No files found.
app/src/main/java/com/example/ayudapy/MapsActivity.kt
View file @
8cd58994
package
com.example.ayudapy
package
com.example.ayudapy
import
android.Manifest
import
android.Manifest
import
android.content.Entity
import
android.content.Intent
import
android.content.Intent
import
android.content.pm.PackageManager
import
android.content.pm.PackageManager
import
android.location.Location
import
android.location.Location
...
@@ -18,10 +17,12 @@ import androidx.appcompat.app.AlertDialog
...
@@ -18,10 +17,12 @@ 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
com.example.ayudapy.api.ApiService
import
androidx.lifecycle.ViewModelProviders
import
com.example.ayudapy.db.PedidoSave
import
androidx.recyclerview.widget.LinearLayoutManager
import
com.example.ayudapy.db.pedidoDataBase
import
androidx.recyclerview.widget.RecyclerView
import
com.example.ayudapy.model.CentroAyuda
import
com.example.ayudapy.model.PedidosAyuda
import
com.example.ayudapy.model.Resultado
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
...
@@ -35,9 +36,6 @@ import com.google.android.gms.maps.model.MarkerOptions
...
@@ -35,9 +36,6 @@ 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.view.*
import
kotlinx.android.synthetic.main.fragment_pedido.view.*
import
kotlinx.android.synthetic.main.info.*
import
kotlinx.android.synthetic.main.pendientes_lista.*
import
org.jetbrains.anko.doAsync
import
retrofit2.Call
import
retrofit2.Call
import
retrofit2.Callback
import
retrofit2.Callback
import
retrofit2.Response
import
retrofit2.Response
...
@@ -54,7 +52,7 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMarker
...
@@ -54,7 +52,7 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMarker
private
var
selectedMarker
:
Marker
?=
null
private
var
selectedMarker
:
Marker
?=
null
private
lateinit
var
mDb
:
pedidoDataBase
private
lateinit
var
mDb
:
pedidoDataBase
companion
object
{
companion
object
{
...
@@ -359,7 +357,8 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMarker
...
@@ -359,7 +357,8 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMarker
// Initialize a new student
// Initialize a new student
val
pedido
=
Thread
{
val
pedido
=
Thread
{
var
pedidoEntity
=
PedidoSave
()
var
pedidoEntity
=
PedidoSave
()
pedidoEntity
.
id
=
pedidoDetalle
!!
.
id
pedidoEntity
.
id
=
pedidoDetalle
!!
.
id
pedidoEntity
.
added
=
pedidoDetalle
!!
.
added
pedidoEntity
.
added
=
pedidoDetalle
!!
.
added
pedidoEntity
.
address
=
pedidoDetalle
!!
.
address
pedidoEntity
.
address
=
pedidoDetalle
!!
.
address
...
...
app/src/main/java/com/example/ayudapy/PendienteLista.kt
View file @
8cd58994
package
com.example.ayudapy
package
com.example.ayudapy
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
com.example.ayudapy.adapter.RecyclerViewAdapter
import
com.example.ayudapy.db.PedidoViewModel
import
com.example.ayudapy.db.pedidoDataBase
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
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
)
...
@@ -33,7 +31,8 @@ class PendienteLista : AppCompatActivity() {
...
@@ -33,7 +31,8 @@ class PendienteLista : AppCompatActivity() {
// Observe the model
// Observe the model
model
.
allPedidos
.
observe
(
this
,
Observer
{
pedido
->
model
.
allPedidos
.
observe
(
this
,
Observer
{
pedido
->
// Data bind the recycler view
// Data bind the recycler view
recycler_view
.
adapter
=
RecyclerViewAdapter
(
pedido
)
recycler_view
.
adapter
=
RecyclerViewAdapter
(
pedido
)
})
})
...
...
app/src/main/java/com/example/ayudapy/ListaPedidoAdapter.kt
→
app/src/main/java/com/example/ayudapy/
adapter/
ListaPedidoAdapter.kt
View file @
8cd58994
package
com.example.ayudapy
package
com.example.ayudapy
.adapter
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.Toast
import
androidx.annotation.RequiresApi
import
androidx.annotation.RequiresApi
import
androidx.recyclerview.widget.RecyclerView
import
androidx.recyclerview.widget.RecyclerView
import
com.example.ayudapy.R
import
com.example.ayudapy.db.PedidoSave
import
com.example.ayudapy.db.pedidoDataBase
import
kotlinx.android.synthetic.main.pendientes_items.view.*
import
kotlinx.android.synthetic.main.pendientes_items.view.*
import
java.time.LocalDate
import
java.time.LocalDateTime
import
java.time.LocalDateTime
import
java.time.format.DateTimeFormatter
import
java.time.format.DateTimeFormatter
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
lateinit
var
context
:
Context
private
lateinit
var
db
:
pedidoDataBase
private
lateinit
var
db
:
pedidoDataBase
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
)
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
)
:
RecyclerViewAdapter
.
ViewHolder
{
:
ViewHolder
{
val
v
:
View
=
LayoutInflater
.
from
(
parent
.
context
)
val
v
:
View
=
LayoutInflater
.
from
(
parent
.
context
)
.
inflate
(
R
.
layout
.
pendientes_items
,
parent
,
false
)
.
inflate
(
R
.
layout
.
pendientes_items
,
parent
,
false
)
return
ViewHolder
(
v
)
return
ViewHolder
(
v
)
...
@@ -35,7 +32,7 @@ class RecyclerViewAdapter(val pedido: List<PedidoSave>)
...
@@ -35,7 +32,7 @@ class RecyclerViewAdapter(val pedido: List<PedidoSave>)
@RequiresApi
(
Build
.
VERSION_CODES
.
O
)
@RequiresApi
(
Build
.
VERSION_CODES
.
O
)
override
fun
onBindViewHolder
(
holder
:
RecyclerViewAdapter
.
ViewHolder
,
position
:
Int
)
{
override
fun
onBindViewHolder
(
holder
:
ViewHolder
,
position
:
Int
)
{
// localDate.getDayOfMonth();
// localDate.getDayOfMonth();
//localDate.getMonthValue();
//localDate.getMonthValue();
...
...
app/src/main/java/com/example/ayudapy/ApiPedidos.kt
→
app/src/main/java/com/example/ayudapy/
api/
ApiPedidos.kt
View file @
8cd58994
package
com.example.ayudapy
package
com.example.ayudapy
.api
import
okhttp3.OkHttpClient
import
okhttp3.OkHttpClient
import
okhttp3.logging.HttpLoggingInterceptor
import
okhttp3.logging.HttpLoggingInterceptor
import
retrofit2.Call
import
retrofit2.Retrofit
import
retrofit2.Retrofit
import
retrofit2.converter.gson.GsonConverterFactory
import
retrofit2.converter.gson.GsonConverterFactory
import
retrofit2.http.GET
import
retrofit2.http.Query
interface
ApiPedidos
{
interface
ApiPedidos
{
companion
object
{
companion
object
{
val
instance
:
ApiService
by
lazy
{
val
instance
:
ApiService
by
lazy
{
val
builder_pedido
=
Retrofit
.
Builder
()
val
builder_pedido
=
Retrofit
.
Builder
()
.
baseUrl
(
"https://ayudapy.org/api/v1/helprequestsgeo/"
)
.
baseUrl
(
"https://ayudapy.org/api/v1/helprequestsgeo/"
)
...
...
app/src/main/java/com/example/ayudapy/ApiService.kt
→
app/src/main/java/com/example/ayudapy/
api/
ApiService.kt
View file @
8cd58994
package
com.example.ayudapy
package
com.example.ayudapy
.api
import
com.example.ayudapy.model.CentroAyuda
import
com.example.ayudapy.model.PedidosAyuda
import
com.example.ayudapy.model.Resultado
import
okhttp3.OkHttpClient
import
okhttp3.OkHttpClient
import
okhttp3.logging.HttpLoggingInterceptor
import
okhttp3.logging.HttpLoggingInterceptor
import
retrofit2.Call
import
retrofit2.Call
...
@@ -37,9 +40,21 @@ interface ApiService {
...
@@ -37,9 +40,21 @@ interface ApiService {
companion
object
{
companion
object
{
// init Retrofit base server instance
// init Retrofit base server instance
val
redditClient
by
lazy
{
ApiService
.
invoke
(
"https://ayudapy.org/api/v1/donationcenters/"
)
}
val
redditClient
by
lazy
{
val
stackClient
by
lazy
{
ApiService
.
invoke
(
"https://ayudapy.org/api/v1/helprequestsgeo/"
)
}
invoke
(
val
pedidoDetalle
by
lazy
{
ApiService
.
invoke
(
"https://ayudapy.org/api/v1/helprequests/"
)
}
"https://ayudapy.org/api/v1/donationcenters/"
)
}
val
stackClient
by
lazy
{
invoke
(
"https://ayudapy.org/api/v1/helprequestsgeo/"
)
}
val
pedidoDetalle
by
lazy
{
invoke
(
"https://ayudapy.org/api/v1/helprequests/"
)
}
private
val
loggingInterceptor
=
HttpLoggingInterceptor
().
apply
{
private
val
loggingInterceptor
=
HttpLoggingInterceptor
().
apply
{
this
.
level
=
HttpLoggingInterceptor
.
Level
.
BODY
this
.
level
=
HttpLoggingInterceptor
.
Level
.
BODY
...
...
app/src/main/java/com/example/ayudapy/Dao.kt
→
app/src/main/java/com/example/ayudapy/
db/
Dao.kt
View file @
8cd58994
package
com.example.ayudapy
package
com.example.ayudapy
.db
import
androidx.lifecycle.LiveData
import
androidx.lifecycle.LiveData
import
androidx.room.*
import
androidx.room.*
import
androidx.room.OnConflictStrategy.REPLACE
@Dao
@Dao
interface
DaoPedido
{
interface
DaoPedido
{
...
...
app/src/main/java/com/example/ayudapy/DataBaseRoom.kt
→
app/src/main/java/com/example/ayudapy/
db/
DataBaseRoom.kt
View file @
8cd58994
package
com.example.ayudapy
package
com.example.ayudapy
.db
import
android.content.Context
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
...
...
app/src/main/java/com/example/ayudapy/Entity.kt
→
app/src/main/java/com/example/ayudapy/
db/
Entity.kt
View file @
8cd58994
package
com.example.ayudapy
package
com.example.ayudapy
.db
import
androidx.room.ColumnInfo
import
androidx.room.ColumnInfo
import
androidx.room.Entity
import
androidx.room.Entity
...
...
app/src/main/java/com/example/ayudapy/ListaModel.kt
→
app/src/main/java/com/example/ayudapy/
db/
ListaModel.kt
View file @
8cd58994
package
com.example.ayudapy
package
com.example.ayudapy
.db
import
androidx.lifecycle.AndroidViewModel
import
androidx.lifecycle.AndroidViewModel
import
androidx.lifecycle.LiveData
import
androidx.lifecycle.LiveData
import
android.app.Application
import
android.app.Application
import
com.example.ayudapy.db.PedidoSave
import
com.example.ayudapy.db.pedidoDataBase
class
PedidoViewModel
(
application
:
Application
):
AndroidViewModel
(
application
){
class
PedidoViewModel
(
application
:
Application
):
AndroidViewModel
(
application
){
private
val
db
:
pedidoDataBase
=
pedidoDataBase
.
getInstance
(
application
)
private
val
db
:
pedidoDataBase
=
pedidoDataBase
.
getInstance
(
application
)
internal
val
allPedidos
:
LiveData
<
List
<
PedidoSave
>>
=
db
.
daoPedido
().
getAll
()
internal
val
allPedidos
:
LiveData
<
List
<
PedidoSave
>>
=
db
.
daoPedido
().
getAll
()
fun
insert
(
student
:
PedidoSave
){
fun
insert
(
student
:
PedidoSave
){
db
.
daoPedido
().
insert
(
student
)
db
.
daoPedido
().
insert
(
student
)
}
}
fun
delete
(
student
:
PedidoSave
){
fun
delete
(
student
:
PedidoSave
){
db
.
daoPedido
().
delete
(
student
)
db
.
daoPedido
().
delete
(
student
)
}
}
}
}
\ No newline at end of file
app/src/main/java/com/example/ayudapy/Repository.kt
→
app/src/main/java/com/example/ayudapy/
db/
Repository.kt
View file @
8cd58994
package
com.example.ayudapy
package
com.example.ayudapy
.db
import
android.os.AsyncTask
import
androidx.annotation.WorkerThread
import
androidx.annotation.WorkerThread
import
androidx.lifecycle.LiveData
import
androidx.lifecycle.LiveData
import
com.example.ayudapy.db.DaoPedido
import
com.example.ayudapy.db.PedidoSave
// Declares the DAO as a private property in the constructor. Pass in the DAO
// 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
// instead of the whole database, because you only need access to the DAO
...
...
app/src/main/java/com/example/ayudapy/CentroAyuda.kt
→
app/src/main/java/com/example/ayudapy/
model/
CentroAyuda.kt
View file @
8cd58994
package
com.example.ayudapy
package
com.example.ayudapy
.model
data class
CentroAyuda
(
data class
CentroAyuda
(
...
...
app/src/main/java/com/example/ayudapy/PedidoDetalle.kt
→
app/src/main/java/com/example/ayudapy/
model/
PedidoDetalle.kt
View file @
8cd58994
package
com.example.ayudapy
package
com.example.ayudapy
.model
data class
PedidoDetalle
(
data class
PedidoDetalle
(
val
count
:
Long
,
val
count
:
Long
,
...
...
app/src/main/java/com/example/ayudapy/PedidosAyuda.kt
→
app/src/main/java/com/example/ayudapy/
model/
PedidosAyuda.kt
View file @
8cd58994
package
com.example.ayudapy
package
com.example.ayudapy
.model
data class
PedidosAyuda
(
data class
PedidosAyuda
(
val
type
:
String
,
val
type
:
String
,
...
...
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