Skip to content

Commit 0a91109

Browse files
anhanh11001iamareebjamal
authored andcommitted
feat: Add empty view for FAQ section (#1743)
Detail: - Add empty view for FAQ section - Improve empty view for event fragments Fixes: #1737
1 parent 2c7388d commit 0a91109

File tree

8 files changed

+95
-14
lines changed

8 files changed

+95
-14
lines changed

app/src/main/java/org/fossasia/openevent/general/event/EventsFragment.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import kotlinx.android.synthetic.main.fragment_events.view.locationTextView
1919
import kotlinx.android.synthetic.main.fragment_events.view.progressBar
2020
import kotlinx.android.synthetic.main.fragment_events.view.shimmerEvents
2121
import kotlinx.android.synthetic.main.fragment_events.view.swiperefresh
22-
import kotlinx.android.synthetic.main.fragment_events.view.noEventsMessage
22+
import kotlinx.android.synthetic.main.fragment_events.view.eventsEmptyView
2323
import kotlinx.android.synthetic.main.fragment_events.view.eventsNestedScrollView
2424
import org.fossasia.openevent.general.R
2525
import org.fossasia.openevent.general.ScrollToTop
@@ -203,7 +203,7 @@ class EventsFragment : Fragment(), ScrollToTop {
203203
}
204204

205205
private fun showEmptyMessage(itemCount: Int) {
206-
rootView.noEventsMessage.visibility = if (itemCount == 0) View.VISIBLE else View.GONE
206+
rootView.eventsEmptyView.visibility = if (itemCount == 0) View.VISIBLE else View.GONE
207207
}
208208

209209
override fun onStop() {

app/src/main/java/org/fossasia/openevent/general/event/faq/EventFAQFragment.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ import android.view.LayoutInflater
55
import android.view.MenuItem
66
import android.view.View
77
import android.view.ViewGroup
8-
import androidx.core.view.isVisible
98
import androidx.fragment.app.Fragment
109
import androidx.lifecycle.Observer
1110
import androidx.navigation.fragment.navArgs
1211
import androidx.recyclerview.widget.LinearLayoutManager
13-
import kotlinx.android.synthetic.main.fragment_event_faq.view.faqContainer
12+
import kotlinx.android.synthetic.main.fragment_event_faq.view.faqEmptyView
1413
import kotlinx.android.synthetic.main.fragment_event_faq.view.faqRv
1514
import org.fossasia.openevent.general.R
1615
import org.fossasia.openevent.general.about.AboutEventFragmentArgs
@@ -33,7 +32,7 @@ class EventFAQFragment : Fragment() {
3332

3433
eventFAQViewModel.eventFAQ.observe(viewLifecycleOwner, Observer {
3534
faqAdapter.addAll(it)
36-
rootView.faqContainer.isVisible = !it.isEmpty()
35+
rootView.faqEmptyView.visibility = if (it.isEmpty()) View.VISIBLE else View.GONE
3736
})
3837

3938
eventFAQViewModel.loadEventFaq(safeArgs.eventId)

app/src/main/java/org/fossasia/openevent/general/event/faq/EventFAQViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class EventFAQViewModel(private val eventService: EventService, private val reso
2121
val error: LiveData<String> = mutableError
2222

2323
fun loadEventFaq(id: Long) {
24-
if (id.equals(-1)) {
24+
if (id == -1L) {
2525
mutableError.value = Resource().getString(R.string.error_fetching_event_message)
2626
return
2727
}

app/src/main/java/org/fossasia/openevent/general/order/OrdersUnderUserFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class OrdersUnderUserFragment : Fragment(), ScrollToTop {
5555
rootView = inflater.inflate(R.layout.fragment_orders_under_user, container, false)
5656
when (safeArgs.showExpired) {
5757
true -> {
58-
setToolbar(activity, "Past Tickets")
58+
setToolbar(activity, getString(R.string.past_tickets))
5959
setHasOptionsMenu(true)
6060
navAnimGone(activity?.navigation, requireContext())
6161
}

app/src/main/res/drawable/ic_faq.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector android:height="24dp" android:viewportHeight="150.59"
2+
android:viewportWidth="150.59" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
3+
<path android:fillColor="#FF000000" android:pathData="M135.58,87.67c0,4.33 0,8.59 0,12.84 0,2.87 -0.82,5.22 -3.69,6.33s-5.09,0.2 -7.14,-1.87c-4.75,-4.82 -9.65,-9.51 -14.31,-14.42a7.73,7.73 0,0 0,-6.21 -2.63C88.18,88 72.13,88 56.07,88c-11.51,0 -17.74,-6.17 -17.75,-17.57q0,-22.2 0,-44.4c0,-10.74 6.32,-17 17.09,-17Q93.24,9 131,9c10.52,0 17,6.25 17.05,16.75 0.11,15 0,30.1 0,45.15C148.12,79.51 143.73,84.94 135.58,87.67ZM91.42,59.41c1.95,-0.52 5.24,-0.75 5.39,-1.55 0.84,-4.67 4.72,-6.21 7.71,-8.76 8.06,-6.88 6.51,-19.47 -3,-23.7A21.61,21.61 0,0 0,83 25.71a10.35,10.35 0,0 0,-6.3 8.72,3.5 3.5,0 0,0 1,2.81c2.57,1.59 8.39,-0.41 10.58,-2.54A7.76,7.76 0,0 1,94 32.59c1.57,0.26 3.53,2.4 4,4.09 1.2,4.06 -0.89,7.2 -4.07,9.73 -2.05,1.63 -4.37,3.14 -5.85,5.21a10.76,10.76 0,0 0,-1.64 6.19C86.46,58.36 89.59,58.85 91.42,59.41ZM91.74,64c-5.39,0 -5.76,0.28 -5.78,4.38s0.45,4.56 5.66,4.56c0.87,0 2,0.32 2.57,-0.09 1.14,-0.79 2.68,-1.9 2.86,-3.06C97.81,64.78 96.92,64 91.74,64Z"/>
4+
<path android:fillColor="#FF000000" android:pathData="M27.69,43.44V54.18c-2.9,0 -5.63,0 -8.35,0 -4.08,0.08 -5.75,1.67 -5.76,5.69q-0.06,22.78 0,45.56c0,3.8 1.7,5.46 5.48,5.7 1.13,0.07 2.26,0 3.39,0s2.22,0.09 3.69,0.16v12.15c3.82,-3.8 6.69,-7 10,-9.77a10.08,10.08 0,0 1,5.81 -2.44c17.19,-0.19 34.39,-0.11 51.58,-0.11 7.21,0 8.21,-1 8.21,-8.29q0,-2.21 0,-4.43l1.13,-0.8c3.14,3.33 7.4,6.22 9,10.18 0.91,2.28 -2,6.68 -4.12,9.42 -2.8,3.63 -7.17,4.77 -11.8,4.75 -16.57,0 -33.13,-0.09 -49.7,0.09a8.93,8.93 0,0 0,-5.47 2.29c-5.13,4.8 -10,9.87 -14.9,14.91 -2,2.1 -4.6,3.45 -7,1.73 -1.75,-1.26 -2.74,-3.82 -3.58,-6 -0.51,-1.31 -0.19,-3 -0.08,-4.48 0.34,-4.93 0.36,-9.12 -5.66,-11.51 -4.43,-1.76 -6.6,-6.53 -6.64,-11.48 -0.12,-16.56 -0.2,-33.13 0,-49.69a14.56,14.56 0,0 1,13 -14.32C19.68,43 23.59,43.44 27.69,43.44Z"/>
5+
</vector>

app/src/main/res/layout/fragment_event_faq.xml

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools"
4-
android:id="@+id/faqContainer"
4+
xmlns:app="http://schemas.android.com/apk/res-auto"
55
android:layout_width="match_parent"
66
android:layout_margin="@dimen/layout_margin_large"
77
android:layout_height="wrap_content"
@@ -19,4 +19,45 @@
1919
tools:itemCount="3"
2020
tools:listitem="@layout/item_faq" />
2121

22+
<LinearLayout
23+
android:id="@+id/faqEmptyView"
24+
android:layout_width="match_parent"
25+
android:layout_height="wrap_content"
26+
android:padding="@dimen/padding_large"
27+
android:orientation="vertical"
28+
tools:visibility="visible">
29+
30+
<RelativeLayout
31+
android:layout_width="@dimen/item_image_view_large"
32+
android:layout_height="@dimen/item_image_view_large"
33+
android:layout_gravity="center_horizontal"
34+
android:layout_marginTop="@dimen/layout_margin_large">
35+
36+
<ImageView
37+
android:layout_width="@dimen/item_image_view_large"
38+
android:layout_height="@dimen/item_image_view_large"
39+
android:layout_centerInParent="true"
40+
android:scaleType="centerCrop"
41+
app:srcCompat="@drawable/round_shape" />
42+
43+
<ImageView
44+
android:id="@+id/ticketImageView"
45+
android:layout_width="@dimen/item_image_view"
46+
android:layout_height="@dimen/item_image_view"
47+
android:layout_centerInParent="true"
48+
android:scaleType="centerCrop"
49+
app:srcCompat="@drawable/ic_faq"
50+
app:tint="@color/colorPrimary"/>
51+
52+
</RelativeLayout>
53+
54+
<TextView
55+
android:layout_width="wrap_content"
56+
android:layout_height="wrap_content"
57+
android:layout_gravity="center_horizontal"
58+
android:layout_marginTop="@dimen/layout_margin_extra_large"
59+
android:text="@string/no_faq_message"
60+
android:textSize="@dimen/text_size_medium" />
61+
</LinearLayout>
62+
2263
</LinearLayout>

app/src/main/res/layout/fragment_events.xml

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,47 @@
8585
<FrameLayout
8686
android:layout_width="match_parent"
8787
android:layout_height="match_parent">
88-
<TextView
89-
android:id="@+id/noEventsMessage"
90-
android:layout_width="wrap_content"
88+
<LinearLayout
89+
android:id="@+id/eventsEmptyView"
90+
android:layout_width="match_parent"
9191
android:layout_height="wrap_content"
92-
android:text="@string/no_events_message"
93-
android:layout_gravity="center"
94-
android:visibility="gone" />
92+
android:padding="@dimen/padding_large"
93+
android:orientation="vertical"
94+
android:visibility="gone"
95+
tools:visibility="visible">
96+
<RelativeLayout
97+
android:layout_width="@dimen/item_image_view_large"
98+
android:layout_height="@dimen/item_image_view_large"
99+
android:layout_gravity="center_horizontal"
100+
android:layout_marginTop="@dimen/layout_margin_large">
101+
102+
<ImageView
103+
android:layout_width="@dimen/item_image_view_large"
104+
android:layout_height="@dimen/item_image_view_large"
105+
android:layout_centerInParent="true"
106+
android:scaleType="centerCrop"
107+
app:srcCompat="@drawable/round_shape" />
108+
109+
<ImageView
110+
android:id="@+id/ticketImageView"
111+
android:layout_width="@dimen/item_image_view"
112+
android:layout_height="@dimen/item_image_view"
113+
android:layout_centerInParent="true"
114+
android:scaleType="centerCrop"
115+
app:srcCompat="@drawable/ic_baseline_event"
116+
app:tint="@color/colorPrimary"/>
117+
118+
</RelativeLayout>
119+
120+
<TextView
121+
android:layout_width="wrap_content"
122+
android:layout_height="wrap_content"
123+
android:layout_gravity="center_horizontal"
124+
android:layout_marginTop="@dimen/layout_margin_extra_large"
125+
android:text="@string/no_events_message"
126+
android:textSize="@dimen/text_size_medium" />
127+
</LinearLayout>
128+
95129
<ProgressBar
96130
android:id="@+id/progressBar"
97131
android:layout_width="wrap_content"

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
<string name="view_ticket">View</string>
119119
<string name="no_ticket_message">Not seeing your tickets? Learn more about how to find them.</string>
120120
<string name="no_past_tickets">No past tickets.</string>
121+
<string name="past_tickets">Past Tickets</string>
121122
<string name="past">Past ></string>
122123
<string name="find_my_tickets">Find my tickets</string>
123124
<string name="no_tickets_available">No tickets available!</string>
@@ -316,6 +317,7 @@
316317
<string name="feedback_submitted">Feedback submitted Successfully</string>
317318
<string name="be_the_first_to_write_a_review">Be the first to write a review</string>
318319
<string name="frequently_asked_questions">Frequently Asked Questions</string>
320+
<string name="no_faq_message">There are no frequenly asked questions for this event.</string>
319321

320322
<string name="filter_set">Filter Done</string>
321323
<string name="filter">Filter Search</string>

0 commit comments

Comments
 (0)