├── AppAndroidKotlin ├── .gitignore ├── app │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── io │ │ │ └── github │ │ │ └── adrianogba │ │ │ └── crud_kotlin │ │ │ └── ExampleInstrumentedTest.kt │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── io │ │ │ │ └── github │ │ │ │ └── adrianogba │ │ │ │ └── crud_kotlin │ │ │ │ ├── AddVeiculo.kt │ │ │ │ ├── MainActivity.kt │ │ │ │ ├── VeiculoDetalheActivity.kt │ │ │ │ ├── adapter │ │ │ │ └── VeiculoListAdapter.kt │ │ │ │ └── model │ │ │ │ └── Veiculo.kt │ │ └── res │ │ │ ├── drawable-v24 │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── drawable │ │ │ ├── ic_add_black_48px.xml │ │ │ ├── ic_done_black_48px.xml │ │ │ ├── ic_keyboard_arrow_right_black_48px.xml │ │ │ └── ic_launcher_background.xml │ │ │ ├── layout │ │ │ ├── activity_add_veiculo.xml │ │ │ ├── activity_main.xml │ │ │ ├── activity_veiculo_detalhe.xml │ │ │ └── item_veiculo.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ └── values │ │ │ ├── colors.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── test │ │ └── java │ │ └── io │ │ └── github │ │ └── adrianogba │ │ └── crud_kotlin │ │ └── ExampleUnitTest.kt ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle ├── LICENSE ├── README.md ├── WebServicePHP ├── Banco.sql ├── addVeiculo.php ├── dbConnect.php ├── deleteVeiculo.php ├── getAllVeiculos.php ├── getVeiculo.php └── updateVeiculo.php └── images ├── banco.png ├── prints.png └── webservicekotlin.png /AppAndroidKotlin/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /AppAndroidKotlin/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /AppAndroidKotlin/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | 5 | android { 6 | compileSdkVersion 30 7 | defaultConfig { 8 | applicationId "io.github.adrianogba.crud_kotlin" 9 | minSdkVersion 21 10 | targetSdkVersion 30 11 | versionCode 1 12 | versionName "1.0" 13 | testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' 14 | } 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | } 22 | 23 | dependencies { 24 | implementation fileTree(dir: 'libs', include: ['*.jar']) 25 | implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" 26 | implementation 'androidx.appcompat:appcompat:1.2.0' 27 | //implementation 'com.android.support.constraint:constraint-layout:1.0.2' 28 | testImplementation 'junit:junit:4.12' 29 | androidTestImplementation 'androidx.test.ext:junit:1.1.2' 30 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' 31 | 32 | implementation 'androidx.appcompat:appcompat:1.2.0' 33 | implementation 'com.google.android.material:material:1.3.0' 34 | implementation 'com.google.code.gson:gson:2.8.6' 35 | implementation 'com.android.volley:volley:1.2.0' 36 | implementation 'androidx.legacy:legacy-support-v4:1.0.0' 37 | } 38 | -------------------------------------------------------------------------------- /AppAndroidKotlin/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/androidTest/java/io/github/adrianogba/crud_kotlin/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package io.github.adrianogba.crud_kotlin 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().context 22 | assertEquals("io.github.adrianogba.crud_kotlin", appContext.packageName) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 14 | 15 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 28 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/java/io/github/adrianogba/crud_kotlin/AddVeiculo.kt: -------------------------------------------------------------------------------- 1 | package io.github.adrianogba.crud_kotlin 2 | 3 | import android.app.ProgressDialog 4 | import android.content.DialogInterface 5 | import android.content.Intent 6 | import android.os.Bundle 7 | import androidx.appcompat.app.AlertDialog 8 | import androidx.appcompat.app.AppCompatActivity 9 | import android.view.View 10 | import android.widget.EditText 11 | import android.widget.RelativeLayout 12 | import android.widget.TextView 13 | import android.widget.Toast 14 | 15 | import com.android.volley.AuthFailureError 16 | import com.android.volley.Request 17 | import com.android.volley.RequestQueue 18 | import com.android.volley.Response 19 | import com.android.volley.VolleyError 20 | import com.android.volley.toolbox.StringRequest 21 | import com.android.volley.toolbox.Volley 22 | import kotlinx.android.synthetic.main.activity_add_veiculo.* 23 | 24 | import java.util.HashMap 25 | 26 | class AddVeiculo : AppCompatActivity() { 27 | 28 | internal var ehnovo: String = "-1" 29 | 30 | internal lateinit var progressDialog: ProgressDialog 31 | internal lateinit var queue: RequestQueue 32 | internal var bundle: Bundle? = null 33 | 34 | //variaveis a guardar no modo edição 35 | internal lateinit var dt_cadastro: String 36 | internal lateinit var id: String 37 | internal var editar = false 38 | 39 | override fun onCreate(savedInstanceState: Bundle?) { 40 | super.onCreate(savedInstanceState) 41 | setContentView(R.layout.activity_add_veiculo) 42 | 43 | 44 | queue = Volley.newRequestQueue(this) 45 | 46 | 47 | rlEhnovo.setOnClickListener { 48 | val lista = arrayOfNulls(2) 49 | lista[0] = "Novo" 50 | lista[1] = "Usado" 51 | val builder = AlertDialog.Builder(this@AddVeiculo) 52 | builder.setTitle("O veículo é Novo ou Usado?") 53 | builder.setItems(lista) { dialogInterface, which -> 54 | if (which == 0) { 55 | txtehnovo.text = "Novo" 56 | ehnovo = "1" 57 | } else { 58 | txtehnovo.text = "Usado" 59 | ehnovo = "0" 60 | } 61 | } 62 | val alertDialog = builder.create() 63 | alertDialog.show() 64 | } 65 | 66 | btncadastrar.setOnClickListener { 67 | if (testForm()) { 68 | 69 | progressDialog = ProgressDialog(this@AddVeiculo) 70 | progressDialog.setMessage("Carregando...") 71 | progressDialog.setCancelable(false) 72 | progressDialog.show() 73 | 74 | var url = getString(R.string.webservice) + "addVeiculo.php" 75 | if (editar) { 76 | url = getString(R.string.webservice) + "updateVeiculo.php" 77 | } 78 | 79 | val stringRequest = object : StringRequest(Request.Method.POST, 80 | url, Response.Listener { response -> 81 | 82 | try { 83 | progressDialog.cancel() 84 | Toast.makeText(this@AddVeiculo, response, Toast.LENGTH_LONG).show() 85 | val i = Intent(this@AddVeiculo, MainActivity::class.java) 86 | i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) 87 | startActivity(i) 88 | 89 | } catch (e: Exception) { 90 | Toast.makeText(this@AddVeiculo, "Problemas na comuncação com o servidor.", Toast.LENGTH_SHORT).show() 91 | e.printStackTrace() 92 | progressDialog.cancel() 93 | } 94 | }, Response.ErrorListener { 95 | progressDialog.cancel() 96 | 97 | Toast.makeText(this@AddVeiculo, 98 | "Problema na comunicação com o servidor!", 99 | Toast.LENGTH_LONG).show() 100 | }) { 101 | @Throws(AuthFailureError::class) 102 | override fun getHeaders(): Map { 103 | val params = HashMap() 104 | if (editar) { 105 | params["PATH"] = "updateVeiculo" 106 | } else { 107 | params["PATH"] = "addVeiculo" 108 | } 109 | params["MARCA"] = etmarca.text.toString().trim { it <= ' ' } 110 | params["MODELO"] = etmodelo.text.toString().trim { it <= ' ' } 111 | params["PRECO"] = etpreco.text.toString().trim { it <= ' ' } 112 | params["COR"] = etcor.text.toString().trim { it <= ' ' } 113 | params["ANO"] = etano.text.toString().trim { it <= ' ' } 114 | params["DESCRICAO"] = etdescricao.text.toString().trim { it <= ' ' } 115 | params["EHNOVO"] = ehnovo 116 | if (editar) { 117 | params["ID"] = id 118 | //params.put("DT_CADASTRO", dt_cadastro); 119 | } 120 | 121 | return params 122 | } 123 | } 124 | 125 | queue.add(stringRequest) 126 | } 127 | } 128 | 129 | try { 130 | bundle = intent.extras 131 | if (bundle!!.getString("editar")!!.equals("editar", ignoreCase = true)) { 132 | 133 | editar = true 134 | 135 | etmarca.setText(bundle!!.getString("marca"), TextView.BufferType.EDITABLE) 136 | etmodelo.setText(bundle!!.getString("modelo"), TextView.BufferType.EDITABLE) 137 | etcor.setText(bundle!!.getString("cor"), TextView.BufferType.EDITABLE) 138 | etano.setText(bundle!!.getString("ano"), TextView.BufferType.EDITABLE) 139 | etpreco.setText(bundle!!.getString("preco"), TextView.BufferType.EDITABLE) 140 | etdescricao.setText(bundle!!.getString("descricao"), TextView.BufferType.EDITABLE) 141 | 142 | id = bundle!!.getString("id").toString() 143 | dt_cadastro = bundle!!.getString("dt_cadastro").toString() 144 | 145 | ehnovo = bundle!!.getString("ehnovo").toString() 146 | if (ehnovo === "1") { 147 | txtehnovo.text = "Novo" 148 | 149 | } else { 150 | txtehnovo.text = "Usado" 151 | } 152 | } 153 | 154 | } catch (e: Exception) { 155 | } 156 | 157 | } 158 | 159 | private fun testForm(): Boolean { 160 | if (etmarca.text.toString().trim { it <= ' ' }.equals("", ignoreCase = true) 161 | || etmodelo.text.toString().trim { it <= ' ' }.equals("", ignoreCase = true) 162 | || etcor.text.toString().trim { it <= ' ' }.equals("", ignoreCase = true) 163 | || etano.text.toString().trim { it <= ' ' }.equals("", ignoreCase = true) 164 | || etpreco.text.toString().trim { it <= ' ' }.equals("", ignoreCase = true) 165 | || etdescricao.text.toString().trim { it <= ' ' }.equals("", ignoreCase = true) 166 | || ehnovo === "-1") { 167 | Toast.makeText(this, "Preencha todo o formulário.", Toast.LENGTH_SHORT).show() 168 | return false 169 | } 170 | return true 171 | } 172 | } 173 | -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/java/io/github/adrianogba/crud_kotlin/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package io.github.adrianogba.crud_kotlin 2 | 3 | import android.app.ProgressDialog 4 | import android.content.Intent 5 | import androidx.appcompat.app.AppCompatActivity 6 | import android.os.Bundle 7 | 8 | import android.widget.Toast 9 | import com.android.volley.* 10 | import com.android.volley.toolbox.StringRequest 11 | import com.android.volley.toolbox.Volley 12 | import com.google.gson.Gson 13 | import com.google.gson.JsonArray 14 | import com.google.gson.JsonParser 15 | import io.github.adrianogba.crud_kotlin.adapter.VeiculoListAdapter 16 | import io.github.adrianogba.crud_kotlin.model.Veiculo 17 | import kotlinx.android.synthetic.main.activity_main.* 18 | import java.util.ArrayList 19 | import java.util.HashMap 20 | 21 | class MainActivity : AppCompatActivity() { 22 | 23 | 24 | internal lateinit var progressDialog: ProgressDialog 25 | 26 | internal var veiculosList: ArrayList = ArrayList() 27 | 28 | internal lateinit var queue: RequestQueue 29 | 30 | internal lateinit var adapter: VeiculoListAdapter 31 | 32 | private var jsonParser: JsonParser? = null 33 | private var gson: Gson? = null 34 | 35 | override fun onCreate(savedInstanceState: Bundle?) { 36 | super.onCreate(savedInstanceState) 37 | setContentView(R.layout.activity_main) 38 | 39 | jsonParser = JsonParser() 40 | gson = Gson() 41 | 42 | swipeRefresh.setOnRefreshListener { carregarLista() } 43 | 44 | btnAddVeiculo.setOnClickListener { v -> 45 | val i = Intent(v.context, AddVeiculo::class.java) 46 | v.context.startActivity(i) 47 | } 48 | 49 | progressDialog = ProgressDialog(this@MainActivity) 50 | progressDialog.setMessage("Carregando...") 51 | progressDialog.setCancelable(false) 52 | progressDialog.show() 53 | 54 | queue = Volley.newRequestQueue(this) 55 | 56 | carregarLista() 57 | 58 | } 59 | 60 | 61 | fun carregarLista() { 62 | veiculosList.clear() 63 | val stringRequest = object : StringRequest(Request.Method.POST, 64 | getString(R.string.webservice) + "getAllVeiculos.php", Response.Listener { response -> 65 | try { 66 | 67 | val mJson = jsonParser!!.parse(response) as JsonArray 68 | veiculosList = ArrayList() 69 | 70 | (0 until mJson.size()) 71 | .map { 72 | gson!!.fromJson(mJson.get(it), 73 | Veiculo::class.java) 74 | } 75 | .forEach { veiculosList.add(it) } 76 | 77 | adapter = VeiculoListAdapter(this, veiculosList) 78 | 79 | veiculosListView?.adapter = adapter 80 | adapter.notifyDataSetChanged() 81 | 82 | errormessage.text = "Sem veículos cadastrados no momento." 83 | veiculosListView.emptyView = errormessage 84 | 85 | veiculosListView.setOnItemClickListener { _, view, position, _ -> 86 | val i = Intent(view.context, VeiculoDetalheActivity::class.java) 87 | i.putExtra("id", veiculosList[position].id) 88 | view.context.startActivity(i) 89 | } 90 | 91 | progressDialog.cancel() 92 | swipeRefresh.isRefreshing = false 93 | 94 | } catch (e: Exception) { 95 | Toast.makeText(this@MainActivity, "Problemas na comuncação com o servidor.", Toast.LENGTH_SHORT).show() 96 | e.printStackTrace() 97 | progressDialog.cancel() 98 | swipeRefresh.isRefreshing = false 99 | } 100 | }, Response.ErrorListener { 101 | progressDialog.cancel() 102 | swipeRefresh.isRefreshing = false 103 | Toast.makeText(this@MainActivity, 104 | "Problema na comunicação com o servidor!", 105 | Toast.LENGTH_LONG).show() 106 | }) { 107 | @Throws(AuthFailureError::class) 108 | override fun getHeaders(): Map { 109 | val params = HashMap() 110 | params["PATH"] = "getVeiculos" 111 | 112 | return params 113 | } 114 | } 115 | queue.add(stringRequest) 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/java/io/github/adrianogba/crud_kotlin/VeiculoDetalheActivity.kt: -------------------------------------------------------------------------------- 1 | package io.github.adrianogba.crud_kotlin 2 | 3 | import android.app.ProgressDialog 4 | 5 | import android.content.Intent 6 | import android.os.Bundle 7 | import androidx.appcompat.app.AlertDialog 8 | import androidx.appcompat.app.AppCompatActivity 9 | 10 | import android.widget.Toast 11 | 12 | import com.android.volley.AuthFailureError 13 | import com.android.volley.Request 14 | import com.android.volley.RequestQueue 15 | import com.android.volley.Response 16 | 17 | import com.android.volley.toolbox.StringRequest 18 | import com.android.volley.toolbox.Volley 19 | import com.google.gson.Gson 20 | import com.google.gson.JsonArray 21 | import com.google.gson.JsonParser 22 | 23 | import java.text.SimpleDateFormat 24 | import java.util.HashMap 25 | 26 | import io.github.adrianogba.crud_kotlin.model.Veiculo 27 | import kotlinx.android.synthetic.main.activity_veiculo_detalhe.* 28 | 29 | 30 | class VeiculoDetalheActivity:AppCompatActivity() { 31 | 32 | internal lateinit var progressDialog:ProgressDialog 33 | private var jsonParser:JsonParser = JsonParser() 34 | private var gson:Gson = Gson() 35 | internal lateinit var queue:RequestQueue 36 | internal lateinit var bundle:Bundle 37 | internal lateinit var veiculo:Veiculo 38 | 39 | override fun onCreate(savedInstanceState:Bundle?) { 40 | super.onCreate(savedInstanceState) 41 | setContentView(R.layout.activity_veiculo_detalhe) 42 | 43 | bundle = intent.extras 44 | queue = Volley.newRequestQueue(this) 45 | 46 | progressDialog = ProgressDialog(this@VeiculoDetalheActivity) 47 | progressDialog.setMessage("Carregando...") 48 | progressDialog.setCancelable(false) 49 | progressDialog.show() 50 | 51 | btnvoltar.setOnClickListener { onBackPressed() } 52 | 53 | btneditar.setOnClickListener { v -> 54 | val i = Intent(v.context, AddVeiculo::class.java) 55 | i.putExtra("editar", "editar") 56 | i.putExtra("marca", veiculo.marca) 57 | i.putExtra("modelo", veiculo.modelo) 58 | i.putExtra("cor", veiculo.cor) 59 | i.putExtra("ano", veiculo.ano) 60 | i.putExtra("preco", veiculo.preco) 61 | i.putExtra("ehnovo", veiculo.ehnovo) 62 | i.putExtra("descricao", veiculo.descricao) 63 | i.putExtra("id", veiculo.id) 64 | i.putExtra("dt_cadastro", veiculo.dt_cadastro) 65 | v.context.startActivity(i) 66 | } 67 | 68 | btnremover.setOnClickListener { 69 | val lista = arrayOfNulls(2) 70 | lista[0] = "Sim" 71 | lista[1] = "Não" 72 | val builder = AlertDialog.Builder(this@VeiculoDetalheActivity) 73 | builder.setTitle("Tem certeza que deseja remover este veículo?") 74 | builder.setItems(lista) { _, which -> 75 | if (which == 0) { 76 | 77 | val stringRequest = object:StringRequest(Request.Method.POST, 78 | getString(R.string.webservice) + "deleteVeiculo.php", Response.Listener { response -> 79 | try { 80 | progressDialog.cancel() 81 | Toast.makeText(this@VeiculoDetalheActivity, response, Toast.LENGTH_LONG).show() 82 | val i = Intent(this@VeiculoDetalheActivity, MainActivity::class.java) 83 | i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) 84 | startActivity(i) 85 | } catch (e:Exception) { 86 | Toast.makeText(this@VeiculoDetalheActivity, "Problemas na comuncação com o servidor.", Toast.LENGTH_SHORT).show() 87 | e.printStackTrace() 88 | progressDialog.cancel() 89 | } 90 | }, Response.ErrorListener { 91 | progressDialog.cancel() 92 | Toast.makeText(this@VeiculoDetalheActivity, 93 | "Problema na comunicação com o servidor!", 94 | Toast.LENGTH_LONG).show() 95 | }) { 96 | @Throws(AuthFailureError::class) 97 | override fun getHeaders():Map { 98 | val params = HashMap() 99 | params["PATH"] = "deleteVeiculo" 100 | params["ID"] = bundle.getString("id") 101 | return params 102 | } 103 | } 104 | queue.add(stringRequest) 105 | } 106 | } 107 | val alertDialog = builder.create() 108 | alertDialog.show() 109 | } 110 | 111 | val stringRequest = object:StringRequest(Request.Method.POST, 112 | getString(R.string.webservice) + "getVeiculo.php", Response.Listener { response -> 113 | try { 114 | val mJson = jsonParser.parse(response) as JsonArray 115 | veiculo = gson.fromJson(mJson.get(0), Veiculo::class.java) 116 | 117 | txtmarca.text = veiculo.marca 118 | txtmodelo.text = veiculo.modelo 119 | txtcor.text = veiculo.cor 120 | txtano.text = veiculo.ano 121 | txtpreco.text = veiculo.preco 122 | txtdescricao.text = veiculo.descricao 123 | 124 | if (veiculo.ehnovo==("1")) { 125 | txtehnovo.text = "Novo" 126 | } else { 127 | txtehnovo.text = "Usado" 128 | } 129 | 130 | val formatter = SimpleDateFormat("yyyy-MM-dd hh:mm:ss") 131 | val formatterbr = SimpleDateFormat("dd/MM/yyyy 'às' hh:mm") 132 | var result = formatter.parse(veiculo.dt_cadastro) 133 | txtdt_cadastro.text = formatterbr.format(result) 134 | 135 | try { 136 | if (veiculo.dt_atualizacao.trim() != ("")) { 137 | result = formatter.parse(veiculo.dt_atualizacao) 138 | txtdt_atualizacao.text = formatterbr.format(result) 139 | } 140 | } catch (e:Exception) { 141 | e.printStackTrace() 142 | txtdt_atualizacao.text = formatterbr.format(result) 143 | } 144 | progressDialog.cancel() 145 | } catch (e:Exception) { 146 | Toast.makeText(this@VeiculoDetalheActivity, "Problemas na comuncação com o servidor.", Toast.LENGTH_SHORT).show() 147 | e.printStackTrace() 148 | progressDialog.cancel() 149 | } 150 | }, Response.ErrorListener { 151 | progressDialog.cancel() 152 | Toast.makeText(this@VeiculoDetalheActivity, 153 | "Problema na comunicação com o servidor!", 154 | Toast.LENGTH_LONG).show() 155 | }) { 156 | 157 | @Throws(AuthFailureError::class) 158 | override fun getHeaders():Map { 159 | 160 | val params = HashMap() 161 | params["PATH"] = "getVeiculoDetalhe" 162 | params["ID"] = bundle.getString("id") 163 | 164 | return params 165 | } 166 | 167 | } 168 | queue.add(stringRequest) 169 | 170 | } 171 | } 172 | -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/java/io/github/adrianogba/crud_kotlin/adapter/VeiculoListAdapter.kt: -------------------------------------------------------------------------------- 1 | package io.github.adrianogba.crud_kotlin.adapter 2 | 3 | import android.annotation.SuppressLint 4 | import android.app.Activity 5 | import android.content.Context 6 | 7 | import android.view.LayoutInflater 8 | import android.view.View 9 | import android.view.ViewGroup 10 | import android.widget.BaseAdapter 11 | import android.widget.TextView 12 | 13 | import java.util.ArrayList 14 | 15 | import io.github.adrianogba.crud_kotlin.R 16 | 17 | import io.github.adrianogba.crud_kotlin.model.Veiculo 18 | 19 | /** 20 | * Created by Adrianogba on 12/26/2017. 21 | */ 22 | 23 | class VeiculoListAdapter(private var activity: Activity, private var items: ArrayList): BaseAdapter() { 24 | 25 | private class ViewHolder(row: View?) { 26 | var txtTitle: TextView? = null 27 | 28 | init { 29 | this.txtTitle = row?.findViewById(R.id.textModelo) 30 | } 31 | } 32 | 33 | @SuppressLint("InflateParams") 34 | override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { 35 | val view: View? 36 | val viewHolder: ViewHolder 37 | if (convertView == null) { 38 | val inflater = activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater 39 | view = inflater.inflate(R.layout.item_veiculo, null) 40 | viewHolder = ViewHolder(view) 41 | view?.tag = viewHolder 42 | } else { 43 | view = convertView 44 | viewHolder = view.tag as ViewHolder 45 | } 46 | 47 | val veiculo = items[position] 48 | viewHolder.txtTitle?.text = veiculo.modelo 49 | 50 | 51 | return view as View 52 | } 53 | 54 | override fun getItem(i: Int): Veiculo { 55 | return items[i] 56 | } 57 | 58 | override fun getItemId(i: Int): Long { 59 | return i.toLong() 60 | } 61 | 62 | override fun getCount(): Int { 63 | return items.size 64 | } 65 | 66 | 67 | } -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/java/io/github/adrianogba/crud_kotlin/model/Veiculo.kt: -------------------------------------------------------------------------------- 1 | package io.github.adrianogba.crud_kotlin.model 2 | 3 | /** 4 | * Created by Adrianogba on 2/15/2018. 5 | */ 6 | 7 | class Veiculo { 8 | lateinit var id: String 9 | lateinit var marca: String 10 | lateinit var modelo: String 11 | lateinit var cor: String 12 | lateinit var ano: String 13 | lateinit var preco: String 14 | lateinit var descricao: String 15 | lateinit var ehnovo: String 16 | lateinit var dt_cadastro: String 17 | lateinit var dt_atualizacao: String 18 | } 19 | -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/res/drawable/ic_add_black_48px.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | 13 | -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/res/drawable/ic_done_black_48px.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 10 | 13 | -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/res/drawable/ic_keyboard_arrow_right_black_48px.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | 13 | -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/res/layout/activity_add_veiculo.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 22 | 23 | 30 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 48 | 49 | 53 | 54 | 58 | 67 | 68 | 78 | 83 | 84 | 85 | 90 | 99 | 109 | 114 | 115 | 116 | 121 | 130 | 140 | 145 | 146 | 147 | 152 | 161 | 173 | 178 | 179 | 180 | 185 | 194 | 206 | 211 | 212 | 213 | 218 | 227 | 237 | 242 | 243 | 244 | 250 | 258 | 267 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 15 | 23 | 24 | 25 | 26 | 27 | 28 | 33 | 37 | 38 | 39 | 40 | 47 | 48 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/res/layout/activity_veiculo_detalhe.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 12 | 13 | 21 | 22 | 23 | 24 | 25 | 26 | 32 | 33 | 37 | 38 | 42 | 50 | 59 | 64 | 65 | 66 | 71 | 79 | 88 | 93 | 94 | 95 | 100 | 108 | 117 | 122 | 123 | 124 | 129 | 137 | 146 | 151 | 152 | 153 | 158 | 166 | 175 | 180 | 181 | 182 | 187 | 196 | 207 | 212 | 213 | 214 | 219 | 227 | 236 | 241 | 242 | 243 | 248 | 256 | 265 | 270 | 271 | 272 | 277 | 285 | 294 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 314 | 315 | 323 | 331 | 332 | 333 | 334 | 342 | 350 | 351 | 352 | 360 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/res/layout/item_veiculo.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 19 | 20 | 29 | 30 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Adrianogba/android-kotlin-php-mysql/d90b6bf5d31c5200cffd99de780c55b1954e1e5d/AppAndroidKotlin/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Adrianogba/android-kotlin-php-mysql/d90b6bf5d31c5200cffd99de780c55b1954e1e5d/AppAndroidKotlin/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Adrianogba/android-kotlin-php-mysql/d90b6bf5d31c5200cffd99de780c55b1954e1e5d/AppAndroidKotlin/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Adrianogba/android-kotlin-php-mysql/d90b6bf5d31c5200cffd99de780c55b1954e1e5d/AppAndroidKotlin/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Adrianogba/android-kotlin-php-mysql/d90b6bf5d31c5200cffd99de780c55b1954e1e5d/AppAndroidKotlin/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Adrianogba/android-kotlin-php-mysql/d90b6bf5d31c5200cffd99de780c55b1954e1e5d/AppAndroidKotlin/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Adrianogba/android-kotlin-php-mysql/d90b6bf5d31c5200cffd99de780c55b1954e1e5d/AppAndroidKotlin/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Adrianogba/android-kotlin-php-mysql/d90b6bf5d31c5200cffd99de780c55b1954e1e5d/AppAndroidKotlin/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Adrianogba/android-kotlin-php-mysql/d90b6bf5d31c5200cffd99de780c55b1954e1e5d/AppAndroidKotlin/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Adrianogba/android-kotlin-php-mysql/d90b6bf5d31c5200cffd99de780c55b1954e1e5d/AppAndroidKotlin/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | CRUD-Kotlin 3 | http://192.168.1.1/WebServicePHP/ 4 | 5 | -------------------------------------------------------------------------------- /AppAndroidKotlin/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 15 | 16 |