-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include simplified list activity for comparison of technology
- Loading branch information
Showing
8 changed files
with
80 additions
and
4 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/kotlin/io/ashdavies/databinding/list/ListActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package io.ashdavies.databinding.list | ||
|
||
import android.os.Bundle | ||
import android.widget.ArrayAdapter | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.lifecycle.lifecycleScope | ||
import io.ashdavies.databinding.R | ||
import io.ashdavies.databinding.databinding.ActivityListBinding | ||
import io.ashdavies.databinding.extensions.activityBinding | ||
import io.ashdavies.databinding.repos.retrofit | ||
import io.ashdavies.databinding.services.GitHubService | ||
import kotlinx.coroutines.launch | ||
import retrofit2.create | ||
|
||
internal class ListActivity : AppCompatActivity() { | ||
|
||
private val binding: ActivityListBinding by activityBinding(R.layout.activity_list) | ||
|
||
private val service: GitHubService = retrofit.create() | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
setSupportActionBar(binding.toolbar) | ||
binding.lifecycleOwner = this | ||
|
||
lifecycleScope.launch { | ||
binding.list.adapter = ArrayAdapter(this@ListActivity, android.R.layout.simple_list_item_1, repos("Kotlin")) | ||
} | ||
} | ||
|
||
private suspend fun repos(name: String): Array<String> = service | ||
.repos("$name+in:name,description", 0, 50) | ||
.items | ||
.map { it.name } | ||
.toTypedArray() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
tools:context=".repos.RepoActivity"> | ||
|
||
<androidx.coordinatorlayout.widget.CoordinatorLayout | ||
android:id="@+id/coordinator" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<com.google.android.material.appbar.AppBarLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:fitsSystemWindows="true"> | ||
|
||
<androidx.appcompat.widget.Toolbar | ||
android:id="@+id/toolbar" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"/> | ||
|
||
</com.google.android.material.appbar.AppBarLayout> | ||
|
||
<ListView | ||
android:id="@+id/list" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:clipToPadding="false" | ||
android:paddingTop="@dimen/vertical_spacing" | ||
app:layout_behavior="@string/appbar_scrolling_view_behavior" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
tools:listitem="@android:layout/simple_list_item_1" /> | ||
|
||
</androidx.coordinatorlayout.widget.CoordinatorLayout> | ||
</layout> |