瀏覽代碼

Refresh screen after logout

sirekanyan 8 年之前
父節點
當前提交
db2339fbb6

+ 16 - 6
app/src/main/java/me/vadik/knigopis/MainActivity.kt

@@ -65,9 +65,14 @@ class MainActivity : AppCompatActivity(), Router {
       refreshOptionsMenu()
       refreshOptionsMenu()
     }
     }
     if (needUpdate) {
     if (needUpdate) {
-      refreshCurrentTab(currentTab)
-      navigation.selectedItemId = currentTab.itemId
+      refresh()
     }
     }
+    booksPlaceholder.setOnClickListener { refresh() }
+  }
+
+  override fun onStop() {
+    booksPlaceholder.setOnClickListener(null)
+    super.onStop()
   }
   }
 
 
   override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
   override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
@@ -88,10 +93,9 @@ class MainActivity : AppCompatActivity(), Router {
   }
   }
 
 
   private fun initNavigationView() {
   private fun initNavigationView() {
-    refreshCurrentTab(HOME_TAB)
-    navigation.selectedItemId = HOME_TAB.itemId
+    refresh(HOME_TAB)
     navigation.setOnNavigationItemSelectedListener { item ->
     navigation.setOnNavigationItemSelectedListener { item ->
-      refreshCurrentTab(CurrentTab.getByItemId(item.itemId))
+      setCurrentTab(CurrentTab.getByItemId(item.itemId))
       true
       true
     }
     }
   }
   }
@@ -108,6 +112,7 @@ class MainActivity : AppCompatActivity(), Router {
         R.id.option_login -> {
         R.id.option_login -> {
           if (auth.isAuthorized()) {
           if (auth.isAuthorized()) {
             auth.logout()
             auth.logout()
+            refresh()
           } else {
           } else {
             startActivityForResult(auth.getTokenRequest(), ULOGIN_REQUEST_CODE)
             startActivityForResult(auth.getTokenRequest(), ULOGIN_REQUEST_CODE)
           }
           }
@@ -138,7 +143,12 @@ class MainActivity : AppCompatActivity(), Router {
     }
     }
   }
   }
 
 
-  private fun refreshCurrentTab(tab: CurrentTab) {
+  private fun refresh(tab: CurrentTab = currentTab) {
+    setCurrentTab(tab)
+    navigation.selectedItemId = tab.itemId
+  }
+
+  private fun setCurrentTab(tab: CurrentTab) {
     needUpdate = false
     needUpdate = false
     fab.hide()
     fab.hide()
     currentTab = tab
     currentTab = tab

+ 6 - 3
app/src/main/res/layout/about.xml

@@ -2,14 +2,17 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     xmlns:tools="http://schemas.android.com/tools"
-    android:layout_width="wrap_content"
+    android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:layout_height="wrap_content"
     android:layout_gravity="center"
     android:layout_gravity="center"
     android:background="?android:attr/selectableItemBackground"
     android:background="?android:attr/selectableItemBackground"
     android:clickable="true"
     android:clickable="true"
     android:focusable="true"
     android:focusable="true"
     android:orientation="vertical"
     android:orientation="vertical"
-    android:padding="16dp">
+    android:paddingBottom="16dp"
+    android:paddingLeft="32dp"
+    android:paddingRight="32dp"
+    android:paddingTop="16dp">
 
 
     <ImageView
     <ImageView
         android:layout_width="40dp"
         android:layout_width="40dp"
@@ -35,7 +38,7 @@
         tools:text="1.0.0" />
         tools:text="1.0.0" />
 
 
     <LinearLayout
     <LinearLayout
-        android:layout_width="wrap_content"
+        android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_height="wrap_content"
         android:layout_gravity="center_horizontal"
         android:layout_gravity="center_horizontal"
         android:layout_marginTop="8dp"
         android:layout_marginTop="8dp"

+ 4 - 4
app/src/main/res/values-ru/strings.xml

@@ -36,10 +36,10 @@
     <string name="book_hint_notes">Примечания</string>
     <string name="book_hint_notes">Примечания</string>
 
 
     <!-- about -->
     <!-- about -->
-    <string name="about_idea">Идея: http://knigopis.com</string>
-    <string name="about_logo">Логотип: https://twitter.com</string>
-    <string name="about_developer">Разработка: vadik@sirekanyan.com</string>
-    <string name="about_designer">Дизайн: anna@sirekanyan.com</string>
+    <string name="about_idea">Идея http://knigopis.com</string>
+    <string name="about_logo">Логотип https://twitter.com</string>
+    <string name="about_developer">Разработка vadik@sirekanyan.com</string>
+    <string name="about_designer">Дизайн anna@sirekanyan.com</string>
 
 
     <!-- error -->
     <!-- error -->
     <string name="error_unauthorized">Это — Книгопись. Привет!</string>
     <string name="error_unauthorized">Это — Книгопись. Привет!</string>

+ 4 - 4
app/src/main/res/values/strings.xml

@@ -36,10 +36,10 @@
     <string name="book_hint_notes">Notes</string>
     <string name="book_hint_notes">Notes</string>
 
 
     <!-- about -->
     <!-- about -->
-    <string name="about_idea">API: http://knigopis.com</string>
-    <string name="about_logo">Logo: https://twitter.com</string>
-    <string name="about_developer">Developer: vadik@sirekanyan.com</string>
-    <string name="about_designer">Designer: anna@sirekanyan.com</string>
+    <string name="about_idea">API http://knigopis.com</string>
+    <string name="about_logo">Logo https://twitter.com</string>
+    <string name="about_developer">Developer vadik@sirekanyan.com</string>
+    <string name="about_designer">Designer anna@sirekanyan.com</string>
 
 
     <!-- error -->
     <!-- error -->
     <string name="error_loading_books">Check your network connection.</string>
     <string name="error_loading_books">Check your network connection.</string>

+ 1 - 1
app/src/main/res/values/styles.xml

@@ -16,7 +16,7 @@
 
 
     <style name="AboutItem">
     <style name="AboutItem">
         <item name="android:layout_height">wrap_content</item>
         <item name="android:layout_height">wrap_content</item>
-        <item name="android:layout_width">wrap_content</item>
+        <item name="android:layout_width">match_parent</item>
         <item name="android:autoLink">web|email</item>
         <item name="android:autoLink">web|email</item>
         <item name="android:padding">4dp</item>
         <item name="android:padding">4dp</item>
         <item name="android:textSize">14sp</item>
         <item name="android:textSize">14sp</item>