Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2way sync: Better view handling #13494

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

2way sync: Better view handling #13494

wants to merge 1 commit into from

Conversation

tobiasKaminsky
Copy link
Member

  • empty state
  • Tests written, or not not needed

- empty state

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
Copy link

Codacy

Lint

TypemasterPR
Warnings6062
Errors33

SpotBugs

CategoryBaseNew
Bad practice6363
Correctness6464
Dodgy code300300
Experimental11
Internationalization77
Multithreaded correctness66
Performance5353
Security1818
Total512512

Lint increased!

Copy link

APK file: https://www.kaminsky.me/nc-dev/android-artifacts/13494.apk

qrcode

To test this change/fix you can simply download above APK file and install and test it in parallel to your existing Nextcloud app.

@tobiasKaminsky tobiasKaminsky mentioned this pull request Sep 3, 2024
1 task

setupToolbar()
updateActionBarTitleAndHomeButtonByString(getString(R.string.drawer_synced_folders))
if (supportActionBar != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need null check, you can use this. supportActionBar?.setDisplayHomeAsUpEnabled(true)

lateinit var binding: InternalTwoWaySyncLayoutBinding

@Inject
lateinit var viewThemeUtils: ViewThemeUtils

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

binding = InternalTwoWaySyncLayoutBinding.inflate(layoutInflater)
setContentView(binding.root)

binding.list.apply {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can omit the binding prefix for emptyList.
Instead of apply, use run when there’s no need to return a modified instance at the end of the block. Use apply only when assigning to a variable.

binding.list.run {
            setEmptyView(binding.emptyList.emptyListView)

            binding.emptyList.run {
                emptyListViewHeadline.run {
                    visibility = View.VISIBLE
                    setText(R.string.internal_two_way_sync_list_empty_headline)
                }
                emptyListViewText.run {
                    visibility = View.VISIBLE
                    setText(R.string.internal_two_way_sync_text)
                }
                emptyListIcon.run {
                    visibility = View.VISIBLE
                    setImageDrawable(
                        viewThemeUtils.platform.tintDrawable(
                            context,
                            R.drawable.ic_sync,
                            ColorRole.PRIMARY
                        )
                    )
                }
            }

            adapter = InternalTwoWaySyncAdapter(fileDataStorageManager, user.get(), context).apply {
                notifyDataSetChanged()
            }
            layoutManager = LinearLayoutManager(context)
        }

Alternatively you can omit second binding as well.


binding.run {
            list.run {
                setEmptyView(binding.emptyList.emptyListView)

                emptyList.run {
                    emptyListViewHeadline.run {
                        visibility = View.VISIBLE
                        setText(R.string.internal_two_way_sync_list_empty_headline)
                    }
                    emptyListViewText.run {
                        visibility = View.VISIBLE
                        setText(R.string.internal_two_way_sync_text)
                    }
                    emptyListIcon.run {
                        visibility = View.VISIBLE
                        setImageDrawable(
                            viewThemeUtils.platform.tintDrawable(
                                context,
                                R.drawable.ic_sync,
                                ColorRole.PRIMARY
                            )
                        )
                    }
                }

                adapter = InternalTwoWaySyncAdapter(fileDataStorageManager, user.get(), context).apply {
                    notifyDataSetChanged()
                }
                layoutManager = LinearLayoutManager(context)
            }
        }

lateinit var binding: InternalTwoWaySyncLayoutBinding

@Inject
lateinit var viewThemeUtils: ViewThemeUtils

override fun onCreate(savedInstanceState: Bundle?) {
Copy link
Collaborator

@alperozturk96 alperozturk96 Sep 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add @SuppressLint("NotifyDataSetChanged") since code updates InternalTwoWaySyncAdapter items in onCreate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants