Add a basic map view to app
This commit is contained in:
parent
5b0bb1e862
commit
cfae237d17
|
@ -23,6 +23,10 @@ android {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||||
|
@ -35,4 +39,6 @@ dependencies {
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
|
||||||
implementation 'androidx.recyclerview:recyclerview:1.1.0'
|
implementation 'androidx.recyclerview:recyclerview:1.1.0'
|
||||||
|
implementation 'org.osmdroid:osmdroid-android:6.1.5'
|
||||||
|
implementation "androidx.preference:preference-ktx:1.1.0"
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
package="com.danilafe.fencelessgrazing">
|
package="com.danilafe.fencelessgrazing">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
|
|
|
@ -2,23 +2,34 @@ package com.danilafe.fencelessgrazing
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import androidx.preference.PreferenceManager
|
||||||
import androidx.recyclerview.widget.DividerItemDecoration
|
import androidx.recyclerview.widget.DividerItemDecoration
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import org.osmdroid.config.Configuration
|
||||||
|
import org.osmdroid.tileprovider.tilesource.TileSourceFactory
|
||||||
|
import org.osmdroid.views.MapView
|
||||||
|
|
||||||
class CollarListActivity : AppCompatActivity() {
|
class CollarListActivity : AppCompatActivity() {
|
||||||
|
|
||||||
private lateinit var token: String
|
private lateinit var token: String
|
||||||
private lateinit var summaryAdapter: CollarSummaryAdapter
|
private lateinit var summaryAdapter: CollarSummaryAdapter
|
||||||
|
private lateinit var map: MapView
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
Configuration.getInstance().load(applicationContext,
|
||||||
|
PreferenceManager.getDefaultSharedPreferences(applicationContext))
|
||||||
|
|
||||||
setContentView(R.layout.activity_collar_list)
|
setContentView(R.layout.activity_collar_list)
|
||||||
|
|
||||||
val collarList: RecyclerView = findViewById(R.id.collarSummaryList)
|
val collarList: RecyclerView = findViewById(R.id.collarSummaryList)
|
||||||
val layoutManager = LinearLayoutManager(collarList.context)
|
val layoutManager = LinearLayoutManager(collarList.context)
|
||||||
token = intent.getStringExtra("token")!!
|
token = intent.getStringExtra("token")!!
|
||||||
summaryAdapter = CollarSummaryAdapter(collarList.context, getString(R.string.apiUrl), token)
|
summaryAdapter = CollarSummaryAdapter(collarList.context, getString(R.string.apiUrl), token)
|
||||||
|
map = findViewById(R.id.map)
|
||||||
|
map.setTileSource(TileSourceFactory.MAPNIK)
|
||||||
|
|
||||||
collarList.adapter = summaryAdapter
|
collarList.adapter = summaryAdapter
|
||||||
collarList.layoutManager = layoutManager
|
collarList.layoutManager = layoutManager
|
||||||
|
@ -26,4 +37,14 @@ class CollarListActivity : AppCompatActivity() {
|
||||||
summaryAdapter.triggerRefresh()
|
summaryAdapter.triggerRefresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
map.onResume()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPause() {
|
||||||
|
super.onPause()
|
||||||
|
map.onPause()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,20 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".CollarListActivity">
|
tools:context=".CollarListActivity">
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<org.osmdroid.views.MapView
|
||||||
android:id="@+id/collarSummaryList"
|
android:id="@+id/map"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="0dp"
|
||||||
|
app:layout_constraintDimensionRatio="16:9"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/collarSummaryList"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/map"
|
||||||
|
tools:layout_editor_absoluteX="0dp" />
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue
Block a user