Skip to content

Commit

Permalink
fixed overlapping issue (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-alfresco authored Oct 17, 2022
1 parent d3a9123 commit 325baad
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 53 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
package com.alfresco.content.browse.tasks.attachments

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.util.TypedValue
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.view.isVisible
import androidx.core.view.setMargins
import androidx.recyclerview.widget.RecyclerView
import com.airbnb.epoxy.AsyncEpoxyController
import com.airbnb.mvrx.Loading
Expand All @@ -26,7 +21,6 @@ import com.alfresco.content.browse.databinding.FragmentAttachedFilesBinding
import com.alfresco.content.browse.preview.LocalPreviewActivity
import com.alfresco.content.browse.tasks.BaseDetailFragment
import com.alfresco.content.browse.tasks.detail.TaskDetailViewModel
import com.alfresco.content.browse.tasks.detail.TaskDetailViewState
import com.alfresco.content.browse.tasks.detail.executePreview
import com.alfresco.content.data.AnalyticsManager
import com.alfresco.content.data.Entry
Expand All @@ -36,7 +30,6 @@ import com.alfresco.content.listview.EntryListener
import com.alfresco.content.mimetype.MimeType
import com.alfresco.content.simpleController
import com.alfresco.ui.getDrawableForAttribute
import com.google.android.material.floatingactionbutton.FloatingActionButton

/**
* Marked as AttachedFilesFragment class
Expand Down Expand Up @@ -78,7 +71,6 @@ class AttachedFilesFragment : BaseDetailFragment(), MavericksView, EntryListener
}
}
})
viewModel.getContents()
binding.refreshLayout.setOnRefreshListener {
viewModel.getContents()
}
Expand Down Expand Up @@ -107,35 +99,17 @@ class AttachedFilesFragment : BaseDetailFragment(), MavericksView, EntryListener
}

if (state.requestContents is Success) {
binding.clParent.addView(makeFab(requireContext(), state))
binding.fabAddAttachments.visibility = View.VISIBLE
binding.fabAddAttachments.setOnClickListener {
showCreateSheet(state)
}
}

if (state.listContents.isEmpty()) requireActivity().onBackPressed()

epoxyController.requestModelBuild()
}

private fun makeFab(context: Context, state: TaskDetailViewState) =
FloatingActionButton(context).apply {
layoutParams = CoordinatorLayout.LayoutParams(
CoordinatorLayout.LayoutParams.WRAP_CONTENT,
CoordinatorLayout.LayoutParams.WRAP_CONTENT
).apply {
gravity = Gravity.BOTTOM or Gravity.END
// TODO: define margins
setMargins(
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16f, resources.displayMetrics)
.toInt()
)
}
id = R.id.fab_add_attachments
contentDescription = context.getString(R.string.text_add_attachments)
setImageResource(R.drawable.ic_add_fab)
setOnClickListener {
showCreateSheet(state)
}
}

private fun epoxyController() = simpleController(viewModel) { state ->

if (state.listContents.isNotEmpty()) {
Expand Down
48 changes: 26 additions & 22 deletions browse/src/main/res/layout/fragment_attached_files.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,34 +39,38 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">

<LinearLayout

<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/refresh_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
app:layout_behavior="com.alfresco.ui.FabAwareScrollingBehavior">

<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/refresh_layout"
android:layout_width="match_parent"
<com.airbnb.epoxy.EpoxyRecyclerView
android:id="@+id/recycler_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_behavior="com.alfresco.ui.FabAwareScrollingBehavior">
android:layout_marginTop="12dp"
android:layout_marginBottom="30dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:splitMotionEvents="false"
app:layoutManager="LinearLayoutManager"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_no_of_attachments" />

<com.airbnb.epoxy.EpoxyRecyclerView
android:id="@+id/recycler_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:paddingBottom="30dp"
android:splitMotionEvents="false"
app:layoutManager="LinearLayoutManager"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_no_of_attachments" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</LinearLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_add_attachments"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:contentDescription="@string/text_add_attachments"
android:src="@drawable/ic_add_fab" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>


Expand Down
1 change: 0 additions & 1 deletion common/src/main/res/values/ids.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="fab_create_task" type="id" />
<item name="fab_add_attachments" type="id" />
</resources>

0 comments on commit 325baad

Please sign in to comment.