Commit 8cd58994 by Yannine Alvarez

Ordenar las clases por carpeta.

parent e3266de9
package com.example.ayudapy
import android.Manifest
import android.content.Entity
import android.content.Intent
import android.content.pm.PackageManager
import android.location.Location
......@@ -18,10 +17,12 @@ import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
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.example.ayudapy.api.ApiService
import com.example.ayudapy.db.PedidoSave
import com.example.ayudapy.db.pedidoDataBase
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.LocationServices
import com.google.android.gms.maps.CameraUpdateFactory
......@@ -35,9 +36,6 @@ import com.google.android.gms.maps.model.MarkerOptions
import com.google.android.material.bottomsheet.BottomSheetDialog
import kotlinx.android.synthetic.main.alert_dialog_contacto.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.Callback
import retrofit2.Response
......@@ -54,7 +52,7 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMarker
private var selectedMarker:Marker?=null
private lateinit var mDb:pedidoDataBase
private lateinit var mDb: pedidoDataBase
companion object{
......@@ -359,7 +357,8 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback, GoogleMap.OnMarker
// Initialize a new student
val pedido = Thread{
var pedidoEntity = PedidoSave()
var pedidoEntity =
PedidoSave()
pedidoEntity.id = pedidoDetalle!!.id
pedidoEntity.added = pedidoDetalle!!.added
pedidoEntity.address = pedidoDetalle!!.address
......
package com.example.ayudapy
import android.content.Intent
import android.os.Bundle
import android.view.View
import android.widget.ListAdapter
import android.widget.Toast
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_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.*
class PendienteLista : AppCompatActivity() {
private lateinit var model: PedidoViewModel
private lateinit var mDb:pedidoDataBase
private lateinit var mDb: pedidoDataBase
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.pendientes_lista)
......@@ -33,7 +31,8 @@ class PendienteLista : AppCompatActivity() {
// Observe the model
model.allPedidos.observe(this, Observer{ pedido->
// 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.graphics.ColorSpace
import android.os.Build
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import android.widget.Toast
import androidx.annotation.RequiresApi
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 java.time.LocalDate
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import java.time.format.FormatStyle
class RecyclerViewAdapter(val pedido: List<PedidoSave>)
: RecyclerView.Adapter<RecyclerViewAdapter.ViewHolder>(){
lateinit var context: Context
private lateinit var db:pedidoDataBase
private lateinit var db: pedidoDataBase
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int)
: RecyclerViewAdapter.ViewHolder {
: ViewHolder {
val v: View = LayoutInflater.from(parent.context)
.inflate(R.layout.pendientes_items,parent,false)
return ViewHolder(v)
......@@ -35,7 +32,7 @@ class RecyclerViewAdapter(val pedido: List<PedidoSave>)
@RequiresApi(Build.VERSION_CODES.O)
override fun onBindViewHolder(holder: RecyclerViewAdapter.ViewHolder, position: Int) {
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
// localDate.getDayOfMonth();
//localDate.getMonthValue();
......
package com.example.ayudapy
package com.example.ayudapy.api
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Call
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.http.GET
import retrofit2.http.Query
interface ApiPedidos {
companion object{
val instance:ApiService by lazy{
val instance: ApiService by lazy{
val builder_pedido = Retrofit.Builder()
.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.logging.HttpLoggingInterceptor
import retrofit2.Call
......@@ -37,9 +40,21 @@ interface ApiService {
companion object {
// init Retrofit base server instance
val redditClient by lazy { ApiService.invoke("https://ayudapy.org/api/v1/donationcenters/") }
val stackClient by lazy { ApiService.invoke("https://ayudapy.org/api/v1/helprequestsgeo/") }
val pedidoDetalle by lazy { ApiService.invoke("https://ayudapy.org/api/v1/helprequests/") }
val redditClient by lazy {
invoke(
"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 {
this.level = HttpLoggingInterceptor.Level.BODY
......
package com.example.ayudapy
package com.example.ayudapy.db
import androidx.lifecycle.LiveData
import androidx.room.*
import androidx.room.OnConflictStrategy.REPLACE
@Dao
interface DaoPedido {
......
package com.example.ayudapy
package com.example.ayudapy.db
import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
@Database(entities = arrayOf(PedidoSave::class), version = 1)
abstract class pedidoDataBase : RoomDatabase() {
abstract fun daoPedido():DaoPedido
abstract fun daoPedido(): DaoPedido
companion object {
private var INSTANCE: pedidoDataBase? = null
......
package com.example.ayudapy
package com.example.ayudapy.db
import androidx.room.ColumnInfo
import androidx.room.Entity
......
package com.example.ayudapy
package com.example.ayudapy.db
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
import android.app.Application
import com.example.ayudapy.db.PedidoSave
import com.example.ayudapy.db.pedidoDataBase
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()
fun insert(student:PedidoSave){
fun insert(student: PedidoSave){
db.daoPedido().insert(student)
}
fun delete(student:PedidoSave){
fun delete(student: PedidoSave){
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.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
// 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 (
......
package com.example.ayudapy
package com.example.ayudapy.model
data class PedidoDetalle (
val count: Long,
......
package com.example.ayudapy
package com.example.ayudapy.model
data class PedidosAyuda (
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