more graphql queries

This commit is contained in:
Johannes Schmelz 2022-01-04 02:34:29 +01:00
parent 67f2a6b9c5
commit 8cfe6e97fa
7 changed files with 42 additions and 56 deletions

View File

@ -12,7 +12,8 @@
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/Theme.Noise.NoActionBar">
android:theme="@style/Theme.Noise.NoActionBar"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

View File

@ -0,0 +1,10 @@
query getUsers {
users {
id
userName
displayName
activated
created
lastOnline
}
}

View File

@ -0,0 +1,10 @@
package org.dnss.sfs.git.wdg.noise
import com.apollographql.apollo3.ApolloClient
class Apollo {
val apolloClient = ApolloClient.Builder()
.serverUrl("https://noise.sfs.ddnss.org/graphql")
.build()
}

View File

@ -45,11 +45,6 @@ class MainActivity : AppCompatActivity() {
)
setupActionBarWithNavController(navController, appBarConfiguration)
navView.setupWithNavController(navController)
addButton( "a", 0xff0000)
addButton( "b", 0xff0000)
addButton( "c", 0xff0000)
addButton( "d", 0xff0000)
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
@ -63,19 +58,4 @@ class MainActivity : AppCompatActivity() {
return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp()
}
fun addButton(userName: String, color: Int) {
val contactScrollField = findViewById<LinearLayout>(R.id.linear_layout)
// = findViewById(R.id.linear_layout) as LinearLayout
val dynamicButton = Button(this)
/*dynamicButton.layoutParams = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT
)*/
dynamicButton.text = userName
dynamicButton.setBackgroundColor(Color.GREEN)
contactScrollField.addView(dynamicButton)
}
}

View File

@ -1,14 +1,14 @@
package org.dnss.sfs.git.wdg.noise.ui.gallery
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import org.dnss.sfs.git.wdg.noise.R
import androidx.lifecycle.lifecycleScope
import org.dnss.sfs.git.wdg.noise.Apollo
import org.dnss.sfs.git.wdg.noise.databinding.FragmentGalleryBinding
class GalleryFragment : Fragment() {
@ -31,13 +31,20 @@ class GalleryFragment : Fragment() {
_binding = FragmentGalleryBinding.inflate(inflater, container, false)
val root: View = binding.root
val textView: TextView = binding.textGallery
galleryViewModel.text.observe(viewLifecycleOwner, Observer {
textView.text = it
})
return root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
lifecycleScope.launchWhenResumed {
val response = Apollo.apolloClient.query(getUsers()).execute()
Log.d("getUsers", "Data:: ${response.data}")
}
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null

View File

@ -17,20 +17,4 @@
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="@navigation/mobile_navigation" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout_editor_absoluteX="206dp"
tools:layout_editor_absoluteY="241dp">
<LinearLayout
android:id="@+id/linear_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -7,16 +7,10 @@
tools:context=".ui.gallery.GalleryFragment">
<TextView
android:id="@+id/text_gallery"
android:layout_width="match_parent"
android:id="@+id/testData"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:textAlignment="center"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
android:text="TestData"
tools:layout_editor_absoluteX="99dp"
tools:layout_editor_absoluteY="185dp" />
</androidx.constraintlayout.widget.ConstraintLayout>