pull to refresh

This commit is contained in:
Öppen 2020-10-09 15:30:22 +01:00
parent 52969a834f
commit f671d1b52d
5 changed files with 22 additions and 12 deletions

View File

@ -52,6 +52,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0'
//ROOM DB
def room_version = "2.2.5"

View File

@ -93,6 +93,9 @@ class GemActivity : AppCompatActivity() {
history = HistoryInterface.default(this)
model.initialise(Datasource.factory(this), BookmarksDatasource.getDefault(applicationContext)){ state ->
binding.pullToRefresh.isRefreshing = false
when(state){
is GemState.AppQuery -> runOnUiThread{ showAlert("App backdoor/query not implemented yet") }
is GemState.ResponseInput -> runOnUiThread {
@ -173,11 +176,6 @@ class GemActivity : AppCompatActivity() {
startActivity(Intent.createChooser(this, null))
}
}
R.id.overflow_menu_reload -> {
val address = binding.addressEdit.text.toString()
RuntimeCache.remove(address)
model.request(address)
}
R.id.overflow_menu_history -> HistoryDialog.show(this){ historyAddress ->
model.request(historyAddress)
}
@ -190,11 +188,18 @@ class GemActivity : AppCompatActivity() {
}
}
}
binding.home.setOnClickListener {
val prefs = getSharedPreferences("oppen.tva.ui.dialogs.set_home", Context.MODE_PRIVATE)
val home = prefs.getString("home", Ariane.DEFAULT_HOME_CAPSULE)
model.request(home!!)
}
binding.pullToRefresh.setOnRefreshListener {
val address = binding.addressEdit.text.toString()
RuntimeCache.remove(address)
model.request(address)
}
}
override fun onNewIntent(intent: Intent?) {

View File

@ -137,14 +137,22 @@
</com.google.android.material.appbar.AppBarLayout>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/pull_to_refresh"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/gemtext_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:paddingTop="@dimen/default_margin"
android:paddingTop="@dimen/screen_margin"
android:paddingBottom="@dimen/default_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
/>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>

View File

@ -27,10 +27,6 @@
android:id="@+id/overflow_menu_backlinks"
android:title="@string/page_backlinks"
android:icon="@drawable/vector_link"/>
<item
android:id="@+id/overflow_menu_reload"
android:title="@string/reload"
android:icon="@drawable/vector_refresh"/>
</group>
<group android:id="@+id/other" >
<item

View File

@ -2,7 +2,7 @@
<resources>
<dimen name="default_margin">8dp</dimen>
<dimen name="default_margin_big">16dp</dimen>
<dimen name="screen_margin">16dp</dimen>
<dimen name="screen_margin">20dp</dimen>
<dimen name="button_margin">12dp</dimen>
<dimen name="default_text_size">16sp</dimen>
<dimen name="code_text_size">14sp</dimen>