Skip to content

Commit

Permalink
fix: toast to snackbar for ticket and favourite fragment (#908)
Browse files Browse the repository at this point in the history
* fix: toast to snackbar

* Update LoginFragment.kt

* Update LoginFragment.kt

* Update TicketsFragment.kt

* Update LoginFragment.kt

* Update TicketsFragment.kt

* Update strings.xml

* Update fragment_tickets.xml
  • Loading branch information
GOVINDDIXIT authored and nikit19 committed Jan 16, 2019
1 parent 5c966b0 commit 3cc95dd
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 133 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class LoginFragment : Fragment() {
setHasOptionsMenu(true)
showSnackbar()

showSnackbar()

if (loginViewModel.isLoggedIn())
redirectToMain()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.navigation.Navigation.findNavController
import com.google.android.material.snackbar.Snackbar
import kotlinx.android.synthetic.main.fragment_favorite.noLikedText
import kotlinx.android.synthetic.main.fragment_favorite.favouriteCoordinatorLayout
import kotlinx.android.synthetic.main.fragment_favorite.view.favoriteEventsRecycler
import kotlinx.android.synthetic.main.fragment_favorite.view.favoriteProgressBar
import org.fossasia.openevent.general.R
Expand Down Expand Up @@ -84,7 +85,7 @@ class FavoriteFragment : Fragment() {
favoriteEventViewModel.error
.nonNull()
.observe(this, Observer {
Toast.makeText(context, it, Toast.LENGTH_LONG).show()
Snackbar.make(favouriteCoordinatorLayout, it, Snackbar.LENGTH_LONG).show()
})

favoriteEventViewModel.progress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.core.view.isGone
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.snackbar.Snackbar
import kotlinx.android.synthetic.main.fragment_social_links.eventHostDetails
import kotlinx.android.synthetic.main.fragment_social_links.socialLinksRecycler
import kotlinx.android.synthetic.main.fragment_social_links.socialLinksCoordinatorLayout
import kotlinx.android.synthetic.main.fragment_social_links.view.progressBarSocial
import kotlinx.android.synthetic.main.fragment_social_links.view.socialLinksRecycler
import org.fossasia.openevent.general.R
Expand Down Expand Up @@ -63,7 +64,7 @@ class SocialLinksFragment : Fragment() {
socialLinksViewModel.error
.nonNull()
.observe(this, Observer {
Toast.makeText(context, it, Toast.LENGTH_LONG).show()
Snackbar.make(socialLinksCoordinatorLayout, it, Snackbar.LENGTH_LONG).show()
})

socialLinksViewModel.progress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ import android.view.LayoutInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.os.bundleOf
import androidx.core.view.isGone
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.navigation.Navigation.findNavController
import com.google.android.material.snackbar.Snackbar
import org.fossasia.openevent.general.auth.SNACKBAR_MESSAGE
import kotlinx.android.synthetic.main.fragment_tickets.ticketsCoordinatorLayout
import kotlinx.android.synthetic.main.fragment_tickets.view.eventName
import kotlinx.android.synthetic.main.fragment_tickets.view.organizerName
import kotlinx.android.synthetic.main.fragment_tickets.view.progressBarTicket
Expand Down Expand Up @@ -83,7 +86,7 @@ class TicketsFragment : Fragment() {
ticketsViewModel.error
.nonNull()
.observe(this, Observer {
Toast.makeText(context, it, Toast.LENGTH_LONG).show()
Snackbar.make(ticketsCoordinatorLayout, it, Snackbar.LENGTH_LONG).show()
})

ticketsViewModel.progressTickets
Expand Down Expand Up @@ -134,7 +137,7 @@ class TicketsFragment : Fragment() {
if (ticketsViewModel.isLoggedIn())
redirectToAttendee()
else {
Toast.makeText(context, "You need to log in first!", Toast.LENGTH_LONG).show()
Snackbar.make(ticketsCoordinatorLayout, "You need to log in first!", Snackbar.LENGTH_LONG).show()
redirectToLogin()
}
}
Expand All @@ -147,7 +150,9 @@ class TicketsFragment : Fragment() {
}

private fun redirectToLogin() {
findNavController(rootView).navigate(R.id.loginFragment, null, getAnimSlide())
val args = getString(R.string.log_in_first)
val bundle = bundleOf(SNACKBAR_MESSAGE to args)
findNavController(rootView).navigate(R.id.loginFragment, bundle, getAnimSlide())
}

private fun handleTicketSelect(id: Int, quantity: Int) {
Expand Down
10 changes: 6 additions & 4 deletions app/src/main/res/layout/fragment_favorite.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/favouriteCoordinatorLayout">

<FrameLayout
android:layout_width="match_parent"
Expand Down Expand Up @@ -51,4 +53,4 @@
</LinearLayout>
</FrameLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
52 changes: 29 additions & 23 deletions app/src/main/res/layout/fragment_social_links.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,36 @@
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<TextView
android:id="@+id/eventHostDetails"
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:visibility="gone"
android:layout_marginBottom="@dimen/layout_margin_large"
android:textColor="@color/dark_grey"
android:text="@string/event_host_details" />
android:layout_height="match_parent"
android:id="@+id/socialLinksCoordinatorLayout">

<ProgressBar
android:id="@+id/progressBarSocial"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone"
android:elevation="@dimen/card_elevation" />
<TextView
android:id="@+id/eventHostDetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:visibility="gone"
android:layout_marginBottom="@dimen/layout_margin_large"
android:textColor="@color/dark_grey"
android:text="@string/event_host_details" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/socialLinksRecycler"
android:layout_width="match_parent"
android:visibility="gone"
android:layout_marginTop="@dimen/layout_margin_extra_large"
android:layout_marginBottom="@dimen/details_header_margin_top"
android:layout_height="wrap_content"
android:scrollbars="vertical" />
<ProgressBar
android:id="@+id/progressBarSocial"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone"
android:elevation="@dimen/card_elevation" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/socialLinksRecycler"
android:layout_width="match_parent"
android:visibility="gone"
android:layout_marginTop="@dimen/layout_margin_extra_large"
android:layout_marginBottom="@dimen/details_header_margin_top"
android:layout_height="wrap_content"
android:scrollbars="vertical" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</FrameLayout>

0 comments on commit 3cc95dd

Please sign in to comment.