some changes
This commit is contained in:
parent
c41a2c81e9
commit
2045cb4425
@ -265,7 +265,7 @@ class MainActivity : AppCompatActivity() {
|
||||
place.img = bitmap
|
||||
}
|
||||
|
||||
ServerManagement.serverManager.getImage(imageReceiver, id, "test.png", 3)
|
||||
ServerManagement.serverManager.getImage(imageReceiver, id, json.getAttributeContentByPath("description/photo_s"), 3)
|
||||
|
||||
PlaceSupplier.appendPlace(place)
|
||||
} else {
|
||||
@ -275,7 +275,7 @@ class MainActivity : AppCompatActivity() {
|
||||
containingPlace?.img = bitmap
|
||||
}
|
||||
|
||||
ServerManagement.serverManager.getImage(imageReceiver, id, "test.png", 3)
|
||||
ServerManagement.serverManager.getImage(imageReceiver, id, json.getAttributeContentByPath("description/photo_s"), 3)
|
||||
}
|
||||
|
||||
// checking if location wasn't changed
|
||||
|
@ -49,7 +49,8 @@ class homeFragment : Fragment(R.layout.fragment_home) {
|
||||
}
|
||||
}
|
||||
|
||||
ServerManagement.serverManager.getImage(imageReceiver, json.getAttributeContent("ID").toInt(), "test0.jpg", 3)
|
||||
ServerManagement.serverManager.getImage(imageReceiver, json.getAttributeContent("ID").toInt(),
|
||||
json.getAttributeContentByPath("description/photo_b"), 3)
|
||||
|
||||
}
|
||||
} catch (e: Throwable) { println(e) }
|
||||
|
@ -65,13 +65,17 @@ class infoFragment : Fragment(R.layout.fragment_info) {
|
||||
val json = JsonManager(requireContext(), data)
|
||||
json.findJsonObjectByAttribute("ID", serverId)
|
||||
|
||||
mainImage?.let {
|
||||
mainTitle.post {
|
||||
mainTitle.text = json.getAttributeContentByPath("description/title")
|
||||
}
|
||||
}
|
||||
|
||||
mainDescription?.let {
|
||||
mainDescription.post {
|
||||
this.mainDescription.text = json.getAttributeContentByPath("description/description_s")
|
||||
}
|
||||
}
|
||||
|
||||
val imageReceiver1: (Bitmap) -> Unit = { bitmap: Bitmap ->
|
||||
mainImage.post {
|
||||
@ -84,7 +88,8 @@ class infoFragment : Fragment(R.layout.fragment_info) {
|
||||
val coordinates = json.getAttributeContent("location").split(",")
|
||||
location = LatLng(coordinates[0].toDouble(), coordinates[1].toDouble())
|
||||
|
||||
ServerManagement.serverManager.getImage(imageReceiver1, json.getAttributeContent("ID").toInt(), "test0.jpg", 2)
|
||||
ServerManagement.serverManager.getImage(imageReceiver1, json.getAttributeContent("ID").toInt(),
|
||||
json.getAttributeContentByPath("description/photo_b"), 2)
|
||||
|
||||
// getting files
|
||||
|
||||
@ -196,7 +201,8 @@ class infoFragment : Fragment(R.layout.fragment_info) {
|
||||
}
|
||||
|
||||
fun goMapFragment() {
|
||||
Navigation.findNavController(mainTitle).navigate(R.id.infoFragment_to_mapFragment)
|
||||
val action = infoFragmentDirections.infoFragmentToMapFragment(LatLng(0.toDouble(), 0.toDouble()), true)
|
||||
Navigation.findNavController(mainTitle).navigate(action)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ class mapFragment : Fragment(), GoogleMap.OnMarkerClickListener {
|
||||
|
||||
val args: mapFragmentArgs by navArgs()
|
||||
private var loadFromMapManager = true
|
||||
private var loadLastCoordinates = false
|
||||
var location: LatLng? = null
|
||||
var lastClickedMarkerTitle = ""
|
||||
|
||||
@ -46,11 +47,14 @@ class mapFragment : Fragment(), GoogleMap.OnMarkerClickListener {
|
||||
|
||||
try {
|
||||
location = args.location
|
||||
loadLastCoordinates = args.loadLastCoordinates
|
||||
loadFromMapManager = false
|
||||
} catch (e: Throwable) { println("[debug] Exception in Map Fragment while getting args: $e") }
|
||||
|
||||
if (loadFromMapManager) {
|
||||
googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(MapManagement.connectedServerPosition, 15.0F))
|
||||
} else if (loadLastCoordinates){
|
||||
googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(MapManagement.lastCoordinates, 15F))
|
||||
} else {
|
||||
googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(location, 15.0F))
|
||||
}
|
||||
@ -80,6 +84,7 @@ class mapFragment : Fragment(), GoogleMap.OnMarkerClickListener {
|
||||
for (n in PlaceSupplier.places.indices) {
|
||||
if (marker.title == PlaceSupplier.places[n]!!.title) {
|
||||
CustomBackstackVariables.infoFragmentBackDestination = "mapFragment"
|
||||
MapManagement.lastCoordinates = marker.position
|
||||
ServerManagement.selectedServerId = PlaceSupplier.places[n]!!.id!!
|
||||
val action = mapFragmentDirections.mapFragmentToInfoFragment()
|
||||
Navigation.findNavController(navControllerView).navigate(action)
|
||||
|
@ -118,6 +118,7 @@ class ServerManager {
|
||||
val bitmap = BitmapFactory.decodeStream(inputStream)
|
||||
|
||||
imageReceiver(bitmap)
|
||||
break
|
||||
} catch (e: Throwable) { println(e) }
|
||||
|
||||
ServerManagement.totalNumberOfRequestsSent += 1
|
||||
|
@ -10,6 +10,8 @@ import com.example.wikispot.modelClasses.JsonManagerLite
|
||||
import com.example.wikispot.saveString
|
||||
import com.google.android.gms.maps.model.LatLng
|
||||
import org.json.JSONArray
|
||||
import java.lang.IndexOutOfBoundsException
|
||||
import java.lang.NullPointerException
|
||||
|
||||
data class PlacePreview(var title: String, var description: String, var location: String? = null, var img: Bitmap? = null, val id: Int?=null) {
|
||||
|
||||
@ -96,10 +98,12 @@ object PlaceSupplier {
|
||||
fun saveToCache(context: Context) {
|
||||
val save = JSONArray()
|
||||
|
||||
var i = 0
|
||||
for (n in places.indices) {
|
||||
val place = places[n]
|
||||
if (getSavePermission(place)) {
|
||||
save.put(n, "${place!!.title}|||||${place.description}|||||${place.location}|||||${place.id}")
|
||||
save.put(i, "${place!!.title}|||||${place.description}|||||${place.location}|||||${place.id}")
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@ object ServerManagement {
|
||||
|
||||
object MapManagement {
|
||||
var connectedServerPosition: LatLng? = LatLng(0.toDouble(), 0.toDouble())
|
||||
var lastCoordinates = LatLng(0.toDouble(), 0.toDouble())
|
||||
}
|
||||
|
||||
|
||||
|
@ -52,6 +52,10 @@
|
||||
android:name="loadAutomatically"
|
||||
android:defaultValue="true" />
|
||||
</action>
|
||||
<argument
|
||||
android:name="loadLastCoordinates"
|
||||
app:argType="boolean"
|
||||
android:defaultValue="false" />
|
||||
</fragment>
|
||||
<fragment
|
||||
android:id="@+id/settingsFragment"
|
||||
|
Loading…
Reference in New Issue
Block a user