Przeglądaj źródła

Pagina display info de planta

jose.caraballo11 3 lat temu
rodzic
commit
d5074db07c

+ 23
- 0
Planta_Display/AndroidManifest.xml Wyświetl plik

@@ -0,0 +1,23 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
+    package="com.example.trefletest">
4
+
5
+    <uses-permission android:name="android.permission.INTERNET"/>
6
+
7
+    <application
8
+        android:allowBackup="true"
9
+        android:icon="@mipmap/ic_launcher"
10
+        android:label="@string/app_name"
11
+        android:roundIcon="@mipmap/ic_launcher_round"
12
+        android:supportsRtl="true"
13
+        android:theme="@style/AppTheme">
14
+        <activity android:name=".MainActivity">
15
+            <intent-filter>
16
+                <action android:name="android.intent.action.MAIN" />
17
+
18
+                <category android:name="android.intent.category.LAUNCHER" />
19
+            </intent-filter>
20
+        </activity>
21
+    </application>
22
+
23
+</manifest>

+ 468
- 0
Planta_Display/Plant.kt Wyświetl plik

@@ -0,0 +1,468 @@
1
+package com.example.trefletest.models
2
+import com.google.gson.annotations.SerializedName
3
+
4
+
5
+data class Plant(
6
+    @SerializedName("data")
7
+    val `data`: Data,
8
+    @SerializedName("meta")
9
+    val meta: Meta
10
+) {
11
+    data class Data(
12
+        @SerializedName("author")
13
+        val author: String,
14
+        @SerializedName("bibliography")
15
+        val bibliography: String,
16
+        @SerializedName("common_name")
17
+        val commonName: Any?,
18
+        @SerializedName("family")
19
+        val family: Family,
20
+        @SerializedName("family_common_name")
21
+        val familyCommonName: Any?,
22
+        @SerializedName("forms")
23
+        val forms: List<Any>,
24
+        @SerializedName("genus")
25
+        val genus: Genus,
26
+        @SerializedName("genus_id")
27
+        val genusId: Int,
28
+        @SerializedName("hybrids")
29
+        val hybrids: List<Any>,
30
+        @SerializedName("id")
31
+        val id: Int,
32
+        @SerializedName("image_url")
33
+        val imageUrl: String,
34
+        @SerializedName("links")
35
+        val links: Links,
36
+        @SerializedName("main_species")
37
+        val mainSpecies: MainSpecies,
38
+        @SerializedName("main_species_id")
39
+        val mainSpeciesId: Int,
40
+        @SerializedName("observations")
41
+        val observations: String,
42
+        @SerializedName("scientific_name")
43
+        val scientificName: String,
44
+        @SerializedName("slug")
45
+        val slug: String,
46
+        @SerializedName("sources")
47
+        val sources: List<Source>,
48
+        @SerializedName("species")
49
+        val species: List<Specy>,
50
+        @SerializedName("subspecies")
51
+        val subspecies: List<Any>,
52
+        @SerializedName("subvarieties")
53
+        val subvarieties: List<Any>,
54
+        @SerializedName("varieties")
55
+        val varieties: List<Any>,
56
+        @SerializedName("vegetable")
57
+        val vegetable: Boolean,
58
+        @SerializedName("year")
59
+        val year: Int
60
+    ) {
61
+        data class Family(
62
+            @SerializedName("common_name")
63
+            val commonName: Any?,
64
+            @SerializedName("id")
65
+            val id: Int,
66
+            @SerializedName("links")
67
+            val links: Links,
68
+            @SerializedName("name")
69
+            val name: String,
70
+            @SerializedName("slug")
71
+            val slug: String
72
+        ) {
73
+            data class Links(
74
+                @SerializedName("division_order")
75
+                val divisionOrder: String,
76
+                @SerializedName("genus")
77
+                val genus: String,
78
+                @SerializedName("self")
79
+                val self: String
80
+            )
81
+        }
82
+
83
+        data class Genus(
84
+            @SerializedName("id")
85
+            val id: Int,
86
+            @SerializedName("links")
87
+            val links: Links,
88
+            @SerializedName("name")
89
+            val name: String,
90
+            @SerializedName("slug")
91
+            val slug: String
92
+        ) {
93
+            data class Links(
94
+                @SerializedName("family")
95
+                val family: String,
96
+                @SerializedName("plants")
97
+                val plants: String,
98
+                @SerializedName("self")
99
+                val self: String,
100
+                @SerializedName("species")
101
+                val species: String
102
+            )
103
+        }
104
+
105
+        data class Links(
106
+            @SerializedName("genus")
107
+            val genus: String,
108
+            @SerializedName("self")
109
+            val self: String,
110
+            @SerializedName("species")
111
+            val species: String
112
+        )
113
+
114
+        data class MainSpecies(
115
+            @SerializedName("author")
116
+            val author: String,
117
+            @SerializedName("bibliography")
118
+            val bibliography: String,
119
+            @SerializedName("common_name")
120
+            val commonName: Any?,
121
+            @SerializedName("common_names")
122
+            val commonNames: CommonNames,
123
+            @SerializedName("distribution")
124
+            val distribution: Distribution,
125
+            @SerializedName("distributions")
126
+            val distributions: Distributions,
127
+            @SerializedName("duration")
128
+            val duration: Any?,
129
+            @SerializedName("edible")
130
+            val edible: Boolean,
131
+            @SerializedName("edible_part")
132
+            val ediblePart: Any?,
133
+            @SerializedName("family")
134
+            val family: String,
135
+            @SerializedName("family_common_name")
136
+            val familyCommonName: Any?,
137
+            @SerializedName("flower")
138
+            val flower: Flower,
139
+            @SerializedName("foliage")
140
+            val foliage: Foliage,
141
+            @SerializedName("fruit_or_seed")
142
+            val fruitOrSeed: FruitOrSeed,
143
+            @SerializedName("genus")
144
+            val genus: String,
145
+            @SerializedName("genus_id")
146
+            val genusId: Int,
147
+            @SerializedName("growth")
148
+            val growth: Growth,
149
+            @SerializedName("id")
150
+            val id: Int,
151
+            @SerializedName("image_url")
152
+            val imageUrl: String,
153
+            @SerializedName("images")
154
+            val images: Images,
155
+            @SerializedName("links")
156
+            val links: Links,
157
+            @SerializedName("observations")
158
+            val observations: String,
159
+            @SerializedName("rank")
160
+            val rank: String,
161
+            @SerializedName("scientific_name")
162
+            val scientificName: String,
163
+            @SerializedName("slug")
164
+            val slug: String,
165
+            @SerializedName("sources")
166
+            val sources: List<Source>,
167
+            @SerializedName("specifications")
168
+            val specifications: Specifications,
169
+            @SerializedName("status")
170
+            val status: String,
171
+            @SerializedName("synonyms")
172
+            val synonyms: List<Any>,
173
+            @SerializedName("vegetable")
174
+            val vegetable: Boolean,
175
+            @SerializedName("year")
176
+            val year: Int
177
+        ) {
178
+            class CommonNames(
179
+            )
180
+
181
+            data class Distribution(
182
+                @SerializedName("native")
183
+                val native: List<String>
184
+            )
185
+
186
+            data class Distributions(
187
+                @SerializedName("native")
188
+                val native: List<Native>
189
+            ) {
190
+                data class Native(
191
+                    @SerializedName("id")
192
+                    val id: Int,
193
+                    @SerializedName("links")
194
+                    val links: Links,
195
+                    @SerializedName("name")
196
+                    val name: String,
197
+                    @SerializedName("slug")
198
+                    val slug: String,
199
+                    @SerializedName("species_count")
200
+                    val speciesCount: Int,
201
+                    @SerializedName("tdwg_code")
202
+                    val tdwgCode: String,
203
+                    @SerializedName("tdwg_level")
204
+                    val tdwgLevel: Int
205
+                ) {
206
+                    data class Links(
207
+                        @SerializedName("plants")
208
+                        val plants: String,
209
+                        @SerializedName("self")
210
+                        val self: String,
211
+                        @SerializedName("species")
212
+                        val species: String
213
+                    )
214
+                }
215
+            }
216
+
217
+            data class Flower(
218
+                @SerializedName("color")
219
+                val color: Any?,
220
+                @SerializedName("conspicuous")
221
+                val conspicuous: Any?
222
+            )
223
+
224
+            data class Foliage(
225
+                @SerializedName("color")
226
+                val color: Any?,
227
+                @SerializedName("leaf_retention")
228
+                val leafRetention: Any?,
229
+                @SerializedName("texture")
230
+                val texture: Any?
231
+            )
232
+
233
+            data class FruitOrSeed(
234
+                @SerializedName("color")
235
+                val color: Any?,
236
+                @SerializedName("conspicuous")
237
+                val conspicuous: Any?,
238
+                @SerializedName("seed_persistence")
239
+                val seedPersistence: Any?,
240
+                @SerializedName("shape")
241
+                val shape: Any?
242
+            )
243
+
244
+            data class Growth(
245
+                @SerializedName("atmospheric_humidity")
246
+                val atmosphericHumidity: Any?,
247
+                @SerializedName("bloom_months")
248
+                val bloomMonths: Any?,
249
+                @SerializedName("days_to_harvest")
250
+                val daysToHarvest: Any?,
251
+                @SerializedName("description")
252
+                val description: Any?,
253
+                @SerializedName("fruit_months")
254
+                val fruitMonths: Any?,
255
+                @SerializedName("growth_months")
256
+                val growthMonths: Any?,
257
+                @SerializedName("light")
258
+                val light: Any?,
259
+                @SerializedName("maximum_precipitation")
260
+                val maximumPrecipitation: MaximumPrecipitation,
261
+                @SerializedName("maximum_temperature")
262
+                val maximumTemperature: MaximumTemperature,
263
+                @SerializedName("minimum_precipitation")
264
+                val minimumPrecipitation: MinimumPrecipitation,
265
+                @SerializedName("minimum_root_depth")
266
+                val minimumRootDepth: MinimumRootDepth,
267
+                @SerializedName("minimum_temperature")
268
+                val minimumTemperature: MinimumTemperature,
269
+                @SerializedName("ph_maximum")
270
+                val phMaximum: Any?,
271
+                @SerializedName("ph_minimum")
272
+                val phMinimum: Any?,
273
+                @SerializedName("row_spacing")
274
+                val rowSpacing: RowSpacing,
275
+                @SerializedName("soil_humidity")
276
+                val soilHumidity: Any?,
277
+                @SerializedName("soil_nutriments")
278
+                val soilNutriments: Any?,
279
+                @SerializedName("soil_salinity")
280
+                val soilSalinity: Any?,
281
+                @SerializedName("soil_texture")
282
+                val soilTexture: Any?,
283
+                @SerializedName("sowing")
284
+                val sowing: Any?,
285
+                @SerializedName("spread")
286
+                val spread: Spread
287
+            ) {
288
+                data class MaximumPrecipitation(
289
+                    @SerializedName("mm")
290
+                    val mm: Any?
291
+                )
292
+
293
+                data class MaximumTemperature(
294
+                    @SerializedName("deg_c")
295
+                    val degC: Any?,
296
+                    @SerializedName("deg_f")
297
+                    val degF: Any?
298
+                )
299
+
300
+                data class MinimumPrecipitation(
301
+                    @SerializedName("mm")
302
+                    val mm: Any?
303
+                )
304
+
305
+                data class MinimumRootDepth(
306
+                    @SerializedName("cm")
307
+                    val cm: Any?
308
+                )
309
+
310
+                data class MinimumTemperature(
311
+                    @SerializedName("deg_c")
312
+                    val degC: Any?,
313
+                    @SerializedName("deg_f")
314
+                    val degF: Any?
315
+                )
316
+
317
+                data class RowSpacing(
318
+                    @SerializedName("cm")
319
+                    val cm: Any?
320
+                )
321
+
322
+                data class Spread(
323
+                    @SerializedName("cm")
324
+                    val cm: Any?
325
+                )
326
+            }
327
+
328
+            data class Images(
329
+                @SerializedName("bark")
330
+                val bark: List<Any>,
331
+                @SerializedName("flower")
332
+                val flower: List<Flower>,
333
+                @SerializedName("fruit")
334
+                val fruit: List<Any>,
335
+                @SerializedName("habit")
336
+                val habit: List<Any>,
337
+                @SerializedName("leaf")
338
+                val leaf: List<Any>,
339
+                @SerializedName("other")
340
+                val other: List<Any>
341
+            ) {
342
+                data class Flower(
343
+                    @SerializedName("copyright")
344
+                    val copyright: String,
345
+                    @SerializedName("id")
346
+                    val id: Int,
347
+                    @SerializedName("image_url")
348
+                    val imageUrl: String
349
+                )
350
+            }
351
+
352
+            data class Links(
353
+                @SerializedName("genus")
354
+                val genus: String,
355
+                @SerializedName("plant")
356
+                val plant: String,
357
+                @SerializedName("self")
358
+                val self: String
359
+            )
360
+
361
+            data class Source(
362
+                @SerializedName("citation")
363
+                val citation: String?,
364
+                @SerializedName("id")
365
+                val id: String,
366
+                @SerializedName("last_update")
367
+                val lastUpdate: String,
368
+                @SerializedName("name")
369
+                val name: String,
370
+                @SerializedName("url")
371
+                val url: String
372
+            )
373
+
374
+            data class Specifications(
375
+                @SerializedName("average_height")
376
+                val averageHeight: AverageHeight,
377
+                @SerializedName("growth_form")
378
+                val growthForm: Any?,
379
+                @SerializedName("growth_habit")
380
+                val growthHabit: Any?,
381
+                @SerializedName("growth_rate")
382
+                val growthRate: Any?,
383
+                @SerializedName("ligneous_type")
384
+                val ligneousType: Any?,
385
+                @SerializedName("maximum_height")
386
+                val maximumHeight: MaximumHeight,
387
+                @SerializedName("nitrogen_fixation")
388
+                val nitrogenFixation: Any?,
389
+                @SerializedName("shape_and_orientation")
390
+                val shapeAndOrientation: Any?,
391
+                @SerializedName("toxicity")
392
+                val toxicity: Any?
393
+            ) {
394
+                data class AverageHeight(
395
+                    @SerializedName("cm")
396
+                    val cm: Any?
397
+                )
398
+
399
+                data class MaximumHeight(
400
+                    @SerializedName("cm")
401
+                    val cm: Any?
402
+                )
403
+            }
404
+        }
405
+
406
+        data class Source(
407
+            @SerializedName("citation")
408
+            val citation: String?,
409
+            @SerializedName("id")
410
+            val id: String,
411
+            @SerializedName("last_update")
412
+            val lastUpdate: String,
413
+            @SerializedName("name")
414
+            val name: String,
415
+            @SerializedName("url")
416
+            val url: String
417
+        )
418
+
419
+        data class Specy(
420
+            @SerializedName("author")
421
+            val author: String,
422
+            @SerializedName("bibliography")
423
+            val bibliography: String,
424
+            @SerializedName("common_name")
425
+            val commonName: Any?,
426
+            @SerializedName("family")
427
+            val family: String,
428
+            @SerializedName("family_common_name")
429
+            val familyCommonName: Any?,
430
+            @SerializedName("genus")
431
+            val genus: String,
432
+            @SerializedName("genus_id")
433
+            val genusId: Int,
434
+            @SerializedName("id")
435
+            val id: Int,
436
+            @SerializedName("image_url")
437
+            val imageUrl: String,
438
+            @SerializedName("links")
439
+            val links: Links,
440
+            @SerializedName("rank")
441
+            val rank: String,
442
+            @SerializedName("scientific_name")
443
+            val scientificName: String,
444
+            @SerializedName("slug")
445
+            val slug: String,
446
+            @SerializedName("status")
447
+            val status: String,
448
+            @SerializedName("synonyms")
449
+            val synonyms: List<Any>,
450
+            @SerializedName("year")
451
+            val year: Int
452
+        ) {
453
+            data class Links(
454
+                @SerializedName("genus")
455
+                val genus: String,
456
+                @SerializedName("plant")
457
+                val plant: String,
458
+                @SerializedName("self")
459
+                val self: String
460
+            )
461
+        }
462
+    }
463
+
464
+    data class Meta(
465
+        @SerializedName("last_modified")
466
+        val lastModified: String
467
+    )
468
+}

+ 14
- 0
Planta_Display/TrefleService.kt Wyświetl plik

@@ -0,0 +1,14 @@
1
+package com.example.trefletest
2
+
3
+import com.example.trefletest.models.Plant
4
+import retrofit2.Call
5
+import retrofit2.http.GET
6
+import retrofit2.http.Path
7
+import retrofit2.http.Query
8
+
9
+interface TrefleService {
10
+    @GET("/api/v1/plants/{id}")
11
+    fun getPlants(@Path("id") id: String, @Query("token") token: String): Call<Plant>
12
+}
13
+
14
+//@Query("filter[id]") id: Int

+ 73
- 0
Planta_Display/activity_main.xml Wyświetl plik

@@ -0,0 +1,73 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+    xmlns:app="http://schemas.android.com/apk/res-auto"
4
+    xmlns:tools="http://schemas.android.com/tools"
5
+    android:id="@+id/Plant_info"
6
+    android:layout_width="match_parent"
7
+    android:layout_height="match_parent"
8
+    tools:context=".MainActivity">
9
+
10
+    <TextView
11
+        android:id="@+id/author"
12
+        android:layout_width="wrap_content"
13
+        android:layout_height="wrap_content"
14
+        android:text="@string/author"
15
+        android:textAppearance="@style/TextAppearance.AppCompat.Large"
16
+        app:layout_constraintBottom_toBottomOf="parent"
17
+        app:layout_constraintEnd_toEndOf="parent"
18
+        app:layout_constraintHorizontal_bias="0.506"
19
+        app:layout_constraintStart_toStartOf="parent"
20
+        app:layout_constraintTop_toBottomOf="@+id/year"
21
+        app:layout_constraintVertical_bias="0.239" />
22
+
23
+    <TextView
24
+        android:id="@+id/sci_name"
25
+        android:layout_width="wrap_content"
26
+        android:layout_height="wrap_content"
27
+        android:text="@string/scientific_name"
28
+        android:textAppearance="@style/TextAppearance.AppCompat.Large"
29
+        app:layout_constraintBottom_toBottomOf="parent"
30
+        app:layout_constraintEnd_toEndOf="parent"
31
+        app:layout_constraintHorizontal_bias="0.507"
32
+        app:layout_constraintStart_toStartOf="parent"
33
+        app:layout_constraintTop_toBottomOf="@+id/plant_name"
34
+        app:layout_constraintVertical_bias="0.155" />
35
+
36
+    <TextView
37
+        android:id="@+id/plant_name"
38
+        android:layout_width="wrap_content"
39
+        android:layout_height="wrap_content"
40
+        android:text="@string/plant_name"
41
+        android:textAppearance="@style/TextAppearance.AppCompat.Large"
42
+        app:layout_constraintBottom_toBottomOf="parent"
43
+        app:layout_constraintEnd_toEndOf="parent"
44
+        app:layout_constraintHorizontal_bias="0.511"
45
+        app:layout_constraintStart_toStartOf="parent"
46
+        app:layout_constraintTop_toTopOf="parent"
47
+        app:layout_constraintVertical_bias="0.57" />
48
+
49
+    <TextView
50
+        android:id="@+id/year"
51
+        android:layout_width="wrap_content"
52
+        android:layout_height="wrap_content"
53
+        android:text="@string/year"
54
+        android:textAppearance="@style/TextAppearance.AppCompat.Large"
55
+        app:layout_constraintBottom_toBottomOf="parent"
56
+        app:layout_constraintEnd_toEndOf="parent"
57
+        app:layout_constraintHorizontal_bias="0.506"
58
+        app:layout_constraintStart_toStartOf="parent"
59
+        app:layout_constraintTop_toBottomOf="@+id/sci_name"
60
+        app:layout_constraintVertical_bias="0.186" />
61
+
62
+    <ImageView
63
+        android:id="@+id/plantview"
64
+        android:layout_width="wrap_content"
65
+        android:layout_height="wrap_content"
66
+        android:contentDescription="@string/plant_display"
67
+        app:layout_constraintBottom_toTopOf="@+id/plant_name"
68
+        app:layout_constraintEnd_toEndOf="parent"
69
+        app:layout_constraintHorizontal_bias="0.498"
70
+        app:layout_constraintStart_toStartOf="parent"
71
+        app:layout_constraintTop_toTopOf="parent"
72
+        app:srcCompat="@drawable/ic_launcher_foreground" />
73
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 26
- 0
Planta_Display/build.gradle Wyświetl plik

@@ -0,0 +1,26 @@
1
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
2
+buildscript {
3
+    ext.kotlin_version = "1.4.10"
4
+    repositories {
5
+        google()
6
+        jcenter()
7
+    }
8
+    dependencies {
9
+        classpath 'com.android.tools.build:gradle:4.0.1'
10
+        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11
+
12
+        // NOTE: Do not place your application dependencies here; they belong
13
+        // in the individual module build.gradle files
14
+    }
15
+}
16
+
17
+allprojects {
18
+    repositories {
19
+        google()
20
+        jcenter()
21
+    }
22
+}
23
+
24
+task clean(type: Delete) {
25
+    delete rootProject.buildDir
26
+}