Can now display a executed query

This commit is contained in:
Johannes Schmelz 2022-01-11 20:01:24 +01:00
parent 1269f1552f
commit 9d665cf4e9
6 changed files with 28 additions and 18 deletions

View File

@ -1,3 +1,3 @@
query GetMessages{ #query GetMessages{
} #}

View File

@ -2,6 +2,7 @@ package org.ddnss.sfs.git.wdg.noise
import android.os.Bundle import android.os.Bundle
import android.view.Menu import android.view.Menu
import android.widget.TextView
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
import com.google.android.material.navigation.NavigationView import com.google.android.material.navigation.NavigationView
import androidx.navigation.findNavController import androidx.navigation.findNavController
@ -11,6 +12,7 @@ import androidx.navigation.ui.setupActionBarWithNavController
import androidx.navigation.ui.setupWithNavController import androidx.navigation.ui.setupWithNavController
import androidx.drawerlayout.widget.DrawerLayout import androidx.drawerlayout.widget.DrawerLayout
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import org.ddnss.sfs.git.wdg.noise.databinding.ActivityMainBinding import org.ddnss.sfs.git.wdg.noise.databinding.ActivityMainBinding
class MainActivity : AppCompatActivity() { class MainActivity : AppCompatActivity() {
@ -42,6 +44,18 @@ class MainActivity : AppCompatActivity() {
) )
setupActionBarWithNavController(navController, appBarConfiguration) setupActionBarWithNavController(navController, appBarConfiguration)
navView.setupWithNavController(navController) navView.setupWithNavController(navController)
getData()
}
fun getData(){
val text: TextView = findViewById<TextView>(R.id.testData)
lifecycleScope.launchWhenResumed {
val response = apolloClient.query(GetUsersQuery()).execute()
//Log.d("LaunchList", "Success ${response.data}")
text.text = response.data.toString()
}
} }
override fun onCreateOptionsMenu(menu: Menu): Boolean { override fun onCreateOptionsMenu(menu: Menu): Boolean {

View File

@ -4,6 +4,7 @@ import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
@ -20,6 +21,8 @@ class GalleryFragment : Fragment() {
// onDestroyView. // onDestroyView.
private val binding get() = _binding!! private val binding get() = _binding!!
//var text: TextView = findViewById(R.id.testData) as TextView
override fun onCreateView( override fun onCreateView(
inflater: LayoutInflater, inflater: LayoutInflater,
container: ViewGroup?, container: ViewGroup?,
@ -37,11 +40,6 @@ class GalleryFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
lifecycleScope.launchWhenResumed {
val response = apolloClient.query(GetUsersQuery()).execute()
}
} }

View File

@ -6,8 +6,5 @@ import androidx.lifecycle.ViewModel
class GalleryViewModel : ViewModel() { class GalleryViewModel : ViewModel() {
private val _text = MutableLiveData<String>().apply {
value = "This is gallery Fragment"
}
val text: LiveData<String> = _text
} }

View File

@ -6,11 +6,4 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".ui.gallery.GalleryFragment"> tools:context=".ui.gallery.GalleryFragment">
<TextView
android:id="@+id/testData"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TestData"
tools:layout_editor_absoluteX="99dp"
tools:layout_editor_absoluteY="185dp" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -6,4 +6,12 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".ui.home.HomeFragment"> tools:context=".ui.home.HomeFragment">
<TextView
android:id="@+id/testData"
android:layout_width="406dp"
android:layout_height="715dp"
android:text="TestData"
tools:layout_editor_absoluteX="2dp"
tools:layout_editor_absoluteY="3dp" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>