more changes
currently the code is in bad state
This commit is contained in:
parent
47935a1b5b
commit
42ea609e52
@ -9,7 +9,10 @@ import androidx.navigation.findNavController
|
||||
import androidx.navigation.ui.setupWithNavController
|
||||
import com.example.wikispot.*
|
||||
import com.example.wikispot.fragments.*
|
||||
import com.example.wikispot.modelClasses.JsonManager
|
||||
import com.example.wikispot.modelClasses.SettingsSaveManager
|
||||
import com.example.wikispot.modelsForAdapters.PlacePreview
|
||||
import com.example.wikispot.modelsForAdapters.PlaceSupplier
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import kotlinx.android.synthetic.main.fragment_home.*
|
||||
|
||||
@ -61,7 +64,8 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
}
|
||||
|
||||
ServerManagement.serverManager.addReceiverConnection(dataReceiver, this, "mainConnection", 0, "test0.json")
|
||||
//ServerManagement.serverManager.addReceiverConnection(dataReceiver, this, "mainConnection", 0, "test0.json")
|
||||
connectExploreFragmentAdapterModel()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
@ -85,6 +89,24 @@ class MainActivity : AppCompatActivity() {
|
||||
settingsSaveManager.loadSettings()
|
||||
}
|
||||
|
||||
private fun connectExploreFragmentAdapterModel () {
|
||||
val dataReceiver: (String) -> Unit = {data: String ->
|
||||
val json = JsonManager(this, data)
|
||||
for (i in 0 until json.getLengthOfJsonArray()) { // todo change to 1
|
||||
json.getJsonObject(i)
|
||||
json.getAttributeContent("description")
|
||||
val title = json.getAttributeContent("title")
|
||||
val shortDescription = json.getAttributeContent("description_s")
|
||||
val place = PlacePreview(title, shortDescription)
|
||||
if (!PlaceSupplier.places.contains(place)) {
|
||||
PlaceSupplier.appendPlace(place)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ServerManagement.serverManager.addReceiverConnection(dataReceiver, this, "exploreListConnection", 0, "", "GET_JSON_ARRAY")
|
||||
}
|
||||
|
||||
private fun restartAppPartially() {
|
||||
val intent = Intent(applicationContext, MainActivity::class.java)
|
||||
|
||||
|
@ -10,7 +10,7 @@ import com.example.wikispot.modelsForAdapters.PlacePreview
|
||||
import kotlinx.android.synthetic.main.explore_list_item.view.*
|
||||
|
||||
|
||||
class PlacePreviewsAdapter(private val context: Context, private val placePreviews: Array<PlacePreview>) : RecyclerView.Adapter<PlacePreviewsAdapter.MyViewHolder>() {
|
||||
class PlacePreviewsAdapter(private val context: Context, private val placePreviews: Array<PlacePreview?>) : RecyclerView.Adapter<PlacePreviewsAdapter.MyViewHolder>() {
|
||||
|
||||
inner class MyViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView){
|
||||
|
||||
|
@ -15,7 +15,7 @@ class homeFragment : Fragment(R.layout.fragment_home) {
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
loadCache()
|
||||
//loadCache()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
|
@ -157,6 +157,10 @@ class ServerManager {
|
||||
|
||||
val jsonManager = JsonManager(context, receivedString)
|
||||
if (path == "") {
|
||||
if (attributePath == "GET_JSON_ARRAY") {
|
||||
dataReceiver(jsonManager.jsonArray.toString())
|
||||
return
|
||||
}
|
||||
jsonManager.getJsonObject(serverId)
|
||||
} else {
|
||||
if (attributePath == "") {
|
||||
@ -195,7 +199,7 @@ class ServerManager {
|
||||
}
|
||||
})
|
||||
|
||||
Thread.sleep(ServerManagement.dataRequestOnAttemptWait)
|
||||
Thread.sleep(ServerManagement.receiverConnectionOnCheckWait)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ data class PlacePreview(var title: String, var description: String, var img: Ima
|
||||
|
||||
object PlaceSupplier {
|
||||
|
||||
val places = arrayOf(
|
||||
var places = arrayOf<PlacePreview?>(
|
||||
PlacePreview("Castle", "Its ruins had been repaired to stable state."),
|
||||
PlacePreview("Library", "You can find books here."),
|
||||
PlacePreview("Bakery", "You can buy bread here."),
|
||||
@ -36,4 +36,10 @@ object PlaceSupplier {
|
||||
PlacePreview("Bakery", "You can buy bread here.")
|
||||
)
|
||||
|
||||
fun appendPlace(place: PlacePreview) {
|
||||
val array = places.copyOf(places.size + 1)
|
||||
array[places.size] = place
|
||||
places = array
|
||||
}
|
||||
|
||||
}
|
@ -3,12 +3,6 @@ package com.example.wikispot
|
||||
import com.example.wikispot.modelClasses.ServerManager
|
||||
|
||||
|
||||
object ManifestRelatedVariables {
|
||||
|
||||
val REQUEST_READ_EXTERNAL = 1
|
||||
|
||||
}
|
||||
|
||||
object GeneralVariables {
|
||||
|
||||
var appRunningFirstTime = true
|
||||
@ -24,7 +18,7 @@ object IntentsKeys {
|
||||
|
||||
object ServerManagement {
|
||||
var serverManager = ServerManager()
|
||||
const val activityConnectionOnCheckWait: Long = 4000
|
||||
const val receiverConnectionOnCheckWait: Long = 20000
|
||||
const val viewConnectionOnCheckWait: Long = 5000
|
||||
const val dataRequestOnAttemptWait: Long = 2000
|
||||
const val baseUrl = "http://192.168.1.230:8000/"
|
||||
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<gradient
|
||||
android:centerX="1"
|
||||
android:startColor="#FCDD94"
|
||||
android:endColor="#C5F8AB"
|
||||
android:angle="45"
|
||||
android:type="sweep" />
|
||||
</shape>
|
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<gradient
|
||||
android:startColor="#650822"
|
||||
android:centerColor="#A7451E"
|
||||
android:endColor="#CB7715"
|
||||
android:angle="135" />
|
||||
</shape>
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<gradient
|
||||
android:centerY="0.6"
|
||||
android:startColor="#851D30"
|
||||
android:centerColor="#B45B14"
|
||||
android:endColor="#D5661F"
|
||||
android:type="linear"
|
||||
android:angle="225"/>
|
||||
</shape>
|
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<gradient
|
||||
android:startColor="#650822"
|
||||
android:centerColor="#A7451E"
|
||||
android:endColor="#CB7715"
|
||||
android:angle="135" />
|
||||
<gradient
|
||||
android:centerY="0.7"
|
||||
android:startColor="#92DD4B4B"
|
||||
android:endColor="#CD742B"
|
||||
android:type="sweep"/>
|
||||
</shape>
|
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<gradient
|
||||
android:startColor="#80FBBE17"
|
||||
android:endColor="#8039E38B"
|
||||
android:angle="45"
|
||||
android:type="linear" />
|
||||
</shape>
|
@ -16,6 +16,7 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:itemIconTint="@color/bottom_nav_bar_item_color"
|
||||
app:itemTextColor="@color/bottom_nav_bar_item_color"
|
||||
android:background="@drawable/gradient_fill_for_bottom_nav_bar"
|
||||
app:menu="@menu/main_bottom_nav_menu" />
|
||||
|
||||
<fragment
|
||||
|
@ -8,31 +8,16 @@
|
||||
tools:background="@color/exploreFragmentBackground"
|
||||
tools:context=".fragments.exploreFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Explore Fragment"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/scrollView2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="260dp"
|
||||
android:layout_height="0dp"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView"
|
||||
app:layout_constraintVertical_bias="1.0">
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/explore_recycler_view"
|
||||
@ -47,18 +32,4 @@
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50dp"
|
||||
android:scaleX="10"
|
||||
android:scaleY="0.1"
|
||||
android:src="@drawable/blank"
|
||||
android:translationY="10dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/scrollView2"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -4,22 +4,25 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/homeFragmentBg"
|
||||
tools:background="@color/homeFragmentBackground"
|
||||
android:background="@drawable/home_fragment_gradient_background"
|
||||
tools:background="@drawable/home_fragment_gradient_background"
|
||||
tools:context=".fragments.homeFragment">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/homeFragmentTextIdTest"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/text_background_gradient"
|
||||
android:padding="5dp"
|
||||
android:text="Home Fragment"
|
||||
android:textColor="@android:color/white"
|
||||
android:textColor="#fff"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold"
|
||||
android:id="@+id/homeFragmentTextIdTest"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.22000003" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -4,21 +4,24 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/mapFragmentBg"
|
||||
tools:background="@color/mapFragmentBackground"
|
||||
android:background="@drawable/map_fragment_gradient_background"
|
||||
tools:background="@drawable/map_fragment_gradient_background"
|
||||
tools:context=".fragments.mapFragment">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/text_background_gradient"
|
||||
android:padding="5dp"
|
||||
android:text="Map Fragment"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="24sp"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="26sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.23000002" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -4,23 +4,10 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/settingsFragmentBg"
|
||||
tools:background="@color/settingsFragmentBackground"
|
||||
android:background="@drawable/settings_fragment_gradient_background"
|
||||
tools:background="@drawable/settings_fragment_gradient_background"
|
||||
tools:context=".fragments.settingsFragment">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Settings Fragment"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/debugBtn"
|
||||
android:layout_width="30dp"
|
||||
@ -37,6 +24,8 @@
|
||||
android:layout_marginLeft="64dp"
|
||||
android:layout_marginTop="88dp"
|
||||
android:text="Dark theme"
|
||||
android:background="@drawable/text_background_gradient"
|
||||
android:padding="5dp"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="24sp"
|
||||
android:textStyle="bold"
|
||||
|
@ -8,22 +8,49 @@
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
|
||||
<!-- Light Theme -->
|
||||
<color name="chatFragmentBackground">#E11976D2</color>
|
||||
<color name="exploreFragmentBackground">#2EBFB2</color>
|
||||
<color name="homeFragmentBackground">#7CB342</color>
|
||||
<color name="mapFragmentBackground">#FBC02D</color>
|
||||
<color name="settingsFragmentBackground">#F57C00</color>
|
||||
<color name="bottomNavBarCheckedItemColor">#ECB269C8</color>
|
||||
<!-- Light Theme --> <!-- Pink one
|
||||
<color name="chatFragmentBackground">#E1C1ABE6</color>
|
||||
<color name="exploreFragmentBackground">#A892DE</color>
|
||||
<color name="homeFragmentBackground">#DCB59BDD</color>
|
||||
<color name="mapFragmentBackground">#D3ACD9</color>
|
||||
<color name="settingsFragmentBackground">#CEDC8AC6</color>
|
||||
<color name="bottomNavBarCheckedItemColor">#ECC87AE0</color>
|
||||
<color name="bottomNavBarRippleColor">#43E8E8E8</color>
|
||||
<color name="statusBarColor">#ECB988D7</color> -->
|
||||
<!-- Blue-Green one
|
||||
<color name="chatFragmentBackground">#E1ABD8E6</color>
|
||||
<color name="exploreFragmentBackground">#92DED8</color>
|
||||
<color name="homeFragmentBackground">#DC9BF1ED</color>
|
||||
<color name="mapFragmentBackground">#C5F2E5</color>
|
||||
<color name="settingsFragmentBackground">#CEA7F2E1</color>
|
||||
<color name="bottomNavBarCheckedItemColor">#EC37DC7C</color>
|
||||
<color name="bottomNavBarRippleColor">#43E8E8E8</color>
|
||||
<color name="statusBarColor">#EC8ECDED</color> -->
|
||||
<color name="chatFragmentBackground">#E10A1C2F</color>
|
||||
<color name="exploreFragmentBackground">#142448</color>
|
||||
<color name="homeFragmentBackground">#DC17294D</color>
|
||||
<color name="mapFragmentBackground">#10132F</color>
|
||||
<color name="settingsFragmentBackground">#CE131C33</color>
|
||||
<color name="bottomNavBarCheckedItemColor">#ECD21A1A</color>
|
||||
<color name="bottomNavBarRippleColor">#33C4BCC9</color>
|
||||
<color name="statusBarColor">#EC000000</color>
|
||||
|
||||
<!-- Dark Theme -->
|
||||
<color name="chatFragmentBackgroundDark">#422DA9</color>
|
||||
<!--<color name="chatFragmentBackgroundDark">#422DA9</color>
|
||||
<color name="exploreFragmentBackgroundDark">#5829B1</color>
|
||||
<color name="homeFragmentBackgroundDark">#6A1B9A</color>
|
||||
<color name="mapFragmentBackgroundDark">#AD1457</color>
|
||||
<color name="settingsFragmentBackgroundDark">#C62845</color>
|
||||
<color name="bottomNavBarCheckedItemColorDark">#D7BEDE</color>
|
||||
<color name="bottomNavBarRippleColorDark">#33222222</color>
|
||||
<color name="statusBarColorDark">#4527A0</color>-->
|
||||
<color name="chatFragmentBackgroundDark">#422DA9</color>
|
||||
<color name="exploreFragmentBackgroundDark">#5829B1</color>
|
||||
<color name="homeFragmentBackgroundDark">#6A1B9A</color>
|
||||
<color name="mapFragmentBackgroundDark">#AD1457</color>
|
||||
<color name="settingsFragmentBackgroundDark">#C62845</color>
|
||||
<color name="bottomNavBarCheckedItemColorDark">#FFB571</color>
|
||||
<color name="bottomNavBarRippleColorDark">#33222222</color>
|
||||
<color name="statusBarColorDark">#4527A0</color>
|
||||
|
||||
</resources>
|
@ -26,7 +26,7 @@
|
||||
<!-- Other items -->
|
||||
<item name="bottomNavigationStyle">@style/Widget.App.BottomNavigationView</item>
|
||||
|
||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
||||
<item name="android:statusBarColor" tools:targetApi="l">@color/statusBarColor</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.App.BottomNavigationView" parent="Widget.MaterialComponents.BottomNavigationView.Colored">
|
||||
@ -34,8 +34,14 @@
|
||||
</style>
|
||||
|
||||
<style name="ThemeOverlay.App.BottomNavigationView" parent="">
|
||||
<!--
|
||||
<item name="colorPrimary">#EDD9F8</item>
|
||||
<item name="colorOnPrimary">#C788EB</item>
|
||||
<item name="colorOnPrimary">#C788EB</item> -->
|
||||
<!--
|
||||
<item name="colorPrimary">#FAF1FF</item>
|
||||
<item name="colorOnPrimary">#6DBEED</item> #E4D539-->
|
||||
<item name="colorPrimary">#0A0A1F</item>
|
||||
<item name="colorOnPrimary">#320747</item>
|
||||
</style>
|
||||
|
||||
<!-- Dark theme-->
|
||||
@ -64,7 +70,7 @@
|
||||
<!-- Other items -->
|
||||
<item name="bottomNavigationStyle">@style/Widget.App.BottomNavigationViewDark</item>
|
||||
|
||||
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
|
||||
<item name="android:statusBarColor" tools:targetApi="l">@color/statusBarColorDark</item>
|
||||
</style>
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user