Ver Fonte

Optimize

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky há 7 meses atrás
pai
commit
154d0456c6

+ 31 - 31
app/src/main/java/com/owncloud/android/ui/activity/InternalTwoWaySyncActivity.kt

@@ -7,6 +7,7 @@
 
 package com.owncloud.android.ui.activity
 
+import android.annotation.SuppressLint
 import android.os.Bundle
 import android.view.Menu
 import android.view.MenuInflater
@@ -18,53 +19,51 @@ import com.nextcloud.client.di.Injectable
 import com.owncloud.android.R
 import com.owncloud.android.databinding.InternalTwoWaySyncLayoutBinding
 import com.owncloud.android.ui.adapter.InternalTwoWaySyncAdapter
-import com.owncloud.android.utils.theme.ViewThemeUtils
-import javax.inject.Inject
 
 class InternalTwoWaySyncActivity : DrawerActivity(), Injectable {
     lateinit var binding: InternalTwoWaySyncLayoutBinding
 
-    @Inject
-    lateinit var viewThemeUtils: ViewThemeUtils
-
+    @SuppressLint("NotifyDataSetChanged")
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
 
         binding = InternalTwoWaySyncLayoutBinding.inflate(layoutInflater)
         setContentView(binding.root)
 
-        binding.list.apply {
-            setEmptyView(binding.emptyList.emptyListView)
+        binding.run {
+            list.run {
+                setEmptyView(binding.emptyList.emptyListView)
 
-            binding.emptyList.emptyListViewHeadline.apply {
-                visibility = View.VISIBLE
-                setText(R.string.internal_two_way_sync_list_empty_headline)
-            }
-            binding.emptyList.emptyListViewText.apply {
-                visibility = View.VISIBLE
-                setText(R.string.internal_two_way_sync_text)
-            }
-            binding.emptyList.emptyListIcon.apply {
-                visibility = View.VISIBLE
-                setImageDrawable(
-                    viewThemeUtils.platform.tintPrimaryDrawable(
-                        context,
-                        R.drawable.ic_sync
-                    )
-                )
-            }
+                emptyList.run {
+                    emptyListViewHeadline.apply {
+                        visibility = View.VISIBLE
+                        setText(R.string.internal_two_way_sync_list_empty_headline)
+                    }
+                    emptyList.emptyListViewText.apply {
+                        visibility = View.VISIBLE
+                        setText(R.string.internal_two_way_sync_text)
+                    }
+                    emptyList.emptyListIcon.apply {
+                        visibility = View.VISIBLE
+                        setImageDrawable(
+                            viewThemeUtils.platform.tintPrimaryDrawable(
+                                context,
+                                R.drawable.ic_sync
+                            )
+                        )
+                    }
+                }
 
-            adapter = InternalTwoWaySyncAdapter(fileDataStorageManager, user.get(), context).apply {
-                notifyDataSetChanged()
+                adapter = InternalTwoWaySyncAdapter(fileDataStorageManager, user.get(), context).apply {
+                    notifyDataSetChanged()
+                }
+                layoutManager = LinearLayoutManager(context)
             }
-            layoutManager = LinearLayoutManager(context)
         }
 
         setupToolbar()
-        updateActionBarTitleAndHomeButtonByString(getString(R.string.drawer_synced_folders))
-        if (supportActionBar != null) {
-            supportActionBar!!.setDisplayHomeAsUpEnabled(true)
-        }
+        updateActionBarTitleAndHomeButtonByString(getString(R.string.internal_two_way_sync_headline))
+        supportActionBar?.setDisplayHomeAsUpEnabled(true)
 
         addMenuProvider(
             object : MenuProvider {
@@ -77,6 +76,7 @@ class InternalTwoWaySyncActivity : DrawerActivity(), Injectable {
                             onBackPressed()
                             true
                         }
+
                         else -> false
                     }
                 }

+ 1 - 0
app/src/main/res/values/strings.xml

@@ -1250,4 +1250,5 @@
     <string name="unset_internal_two_way_sync_description">Remove folder from internal two way sync</string>
     <string name="internal_two_way_sync_list_empty_headline">No two way sync folder yet</string>
     <string name="internal_two_way_sync_text">To setup a two way sync folder, please enable it in details of desired folder.</string>
+    <string name="internal_two_way_sync_headline">Internal two way sync</string>
 </resources>