Skip to content

Commit

Permalink
fix:Content for Error fetching event (#1366)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aman Bansal committed Mar 22, 2019
1 parent 95b8235 commit 453fbe9
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1074,4 +1074,4 @@
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, \"0b3cd25764884626e03f56b0600d1c76\")"
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ import kotlinx.android.synthetic.main.content_event.view.seeMore
import kotlinx.android.synthetic.main.content_event.view.seeMoreOrganizer
import kotlinx.android.synthetic.main.fragment_event.view.eventCoordinatorLayout
import kotlinx.android.synthetic.main.fragment_event.view.buttonTickets
import kotlinx.android.synthetic.main.fragment_event.view.eventErrorCard
import kotlinx.android.synthetic.main.fragment_event.view.container
import kotlinx.android.synthetic.main.content_fetching_event_error.view.retry
import org.fossasia.openevent.general.CircleTransform
import org.fossasia.openevent.general.R
import org.fossasia.openevent.general.about.AboutEventFragmentArgs
Expand Down Expand Up @@ -98,6 +101,7 @@ class EventDetailsFragment : Fragment() {
runOnce = false

Timber.d("Fetched events of id %d", safeArgs.eventId)
showEventErrorScreen(false)
})
}

Expand All @@ -121,10 +125,14 @@ class EventDetailsFragment : Fragment() {
eventViewModel.error
.nonNull()
.observe(viewLifecycleOwner, Observer {
showEventErrorScreen(true)
Snackbar.make(rootView.eventCoordinatorLayout, it, Snackbar.LENGTH_LONG).show()
})

eventViewModel.loadEvent(safeArgs.eventId)
rootView.retry.setOnClickListener {
eventViewModel.loadEvent(safeArgs.eventId)
}

// Set toolbar title to event name
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Expand Down Expand Up @@ -383,4 +391,9 @@ class EventDetailsFragment : Fragment() {
private fun setFavoriteIcon(id: Int) {
menuActionBar?.findItem(R.id.favorite_event)?.icon = context?.let { ContextCompat.getDrawable(it, id) }
}

private fun showEventErrorScreen(show: Boolean) {
rootView.container.visibility = if (!show) View.VISIBLE else View.GONE
rootView.eventErrorCard.visibility = if (show) View.VISIBLE else View.GONE
}
}
51 changes: 51 additions & 0 deletions app/src/main/res/layout/content_fetching_event_error.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/eventErrorCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/layout_margin_medium"
app:cardBackgroundColor="@android:color/white"
app:cardCornerRadius="@dimen/card_corner_radius"
app:cardElevation="@dimen/card_elevation">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/layout_margin_extra_large"
android:orientation="vertical">

<ImageView
android:id="@+id/noInternetImageView"
android:layout_width="@dimen/item_image_view_large"
android:layout_height="@dimen/item_image_view_large"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/layout_margin_large"
android:scaleType="centerCrop"
app:srcCompat="@drawable/ic_no_internet" />

<TextView
android:id="@+id/noInternetTextview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/layout_margin_large"
android:text="@string/error_fetching_events"
android:textSize="@dimen/text_size_medium"
/>

<TextView
android:id="@+id/retry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/layout_margin_large"
android:text="@string/retry"
android:textColor="@color/colorPrimary"
style="@style/Widget.AppCompat.Button.Borderless"
tools:text="RETRY" />
</LinearLayout>

</androidx.cardview.widget.CardView>
6 changes: 5 additions & 1 deletion app/src/main/res/layout/fragment_event.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
android:id="@+id/eventCoordinatorLayout"
android:background="@android:color/white"
android:layout_height="match_parent">

<include
android:id="@+id/eventErrorCard"
layout="@layout/content_fetching_event_error"
android:visibility="gone" />
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_dodgeInsetEdges="bottom">
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-bn-rIN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<string name="whats_good">কি ভালো এটাই</string>
<string name="where">কোথায়?</string>
<string name="no_internet_message">যোগাযোগ করতে অসুবিধা হচ্ছে. পরে চেষ্টা করুন.</string>
<string name="error_fetching_events">আমরা ইভেন্ট আনতে অসুবিধা হচ্ছে। পরে আবার চেষ্টা করুন</string>
<string name="tickets_sold_out">দুঃখিত, সব টিকেট শেষ হয়ে গেছে !</string>
<string name="retry">আবার চেষ্টা করুন</string>
<string name="more_like_this">আরো এটার মতো </string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-vi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<string name="whats_good">Sự kiện thú vị tại</string>
<string name="where">Ở đâu?</string>
<string name="no_internet_message">Ứng dụng gặp sự cố kĩ thuật. Xin hãy kiểm tra lại kết nối hoặc thử lại</string>
<string name="error_fetching_events">Chúng tôi đang gặp khó khăn khi tìm nạp sự kiện. Thử lại sau.</string>
<string name="tickets_sold_out">Xin lỗi, sự kiện đã bán hết vé!</string>
<string name="retry">Thử Lại</string>
<string name="more_like_this">Sự kiện tương tự</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<string name="whats_good">What\'s good in</string>
<string name="where">where?</string>
<string name="no_internet_message">We\'re having difficulty connecting to the server. Check your connection or try again later.</string>
<string name="error_fetching_events">We\'re having difficulty fetching event. Try again later.</string>
<string name="tickets_sold_out">Sorry, All tickets for this event have been sold out!</string>
<string name="retry">RETRY</string>
<string name="more_like_this">More like this</string>
Expand Down

0 comments on commit 453fbe9

Please sign in to comment.