Commit 8cd58994 by Yannine Alvarez

Ordenar las clases por carpeta.

parent e3266de9
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
......
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)
}) })
......
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();
......
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/")
......
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
......
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 {
......
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
......
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
......
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
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
......
package com.example.ayudapy package com.example.ayudapy.model
data class CentroAyuda ( data class CentroAyuda (
......
package com.example.ayudapy package com.example.ayudapy.model
data class PedidoDetalle ( data class PedidoDetalle (
val count: Long, val count: Long,
......
package com.example.ayudapy package com.example.ayudapy.model
data class PedidosAyuda ( data class PedidosAyuda (
val type: String, val type: String,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment