-
Notifications
You must be signed in to change notification settings - Fork 557
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
fix: toast to snackbar for login work #788
Merged
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7e5d970
fix: toast to snackbar for login work
GOVINDDIXIT f30618b
fix: toast to snackbar for login work
GOVINDDIXIT f7cb744
Merge branch 'development' into development
GOVINDDIXIT 596213b
fix: toast to snackbar for login work
GOVINDDIXIT 3e86832
fix: TravisCI build failure
GOVINDDIXIT 273f686
Merge branch 'development' into development
GOVINDDIXIT 10da580
fix: TravisCI build failure
GOVINDDIXIT f2b9f6f
requested changes
GOVINDDIXIT 5d9f490
fix: TravisCI build failure
GOVINDDIXIT e4f1790
requested changes (keeping SpotlessKotlin build Succesful)
GOVINDDIXIT File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
package org.fossasia.openevent.general.auth | ||
|
||
import android.content.ActivityNotFoundException | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.net.Uri | ||
import android.os.Bundle | ||
import android.os.Handler | ||
import android.view.LayoutInflater | ||
import android.view.Menu | ||
import android.view.MenuInflater | ||
import android.view.MenuItem | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.Toast | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.coordinatorlayout.widget.CoordinatorLayout | ||
import androidx.core.view.isVisible | ||
import androidx.fragment.app.Fragment | ||
import androidx.lifecycle.Observer | ||
import com.google.android.material.snackbar.Snackbar | ||
import com.squareup.picasso.Picasso | ||
import kotlinx.android.synthetic.main.fragment_profile.view.avatar | ||
import kotlinx.android.synthetic.main.fragment_profile.view.email | ||
|
@@ -36,6 +37,7 @@ class ProfileFragment : Fragment() { | |
private val profileViewModel by viewModel<ProfileViewModel>() | ||
|
||
private lateinit var rootView: View | ||
private lateinit var CoordinatorLayout: CoordinatorLayout | ||
private var emailSettings: String? = null | ||
private val EMAIL: String = "EMAIL" | ||
|
||
|
@@ -48,23 +50,24 @@ class ProfileFragment : Fragment() { | |
startActivity(Intent(activity, MainActivity::class.java).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)) | ||
} | ||
|
||
override fun onAttach(context: Context) { | ||
super.onAttach(context) | ||
if (!profileViewModel.isLoggedIn()) { | ||
Toast.makeText(context, "You need to Login!", Toast.LENGTH_LONG).show() | ||
redirectToLogin() | ||
} | ||
} | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
rootView = inflater.inflate(R.layout.fragment_profile, container, false) | ||
CoordinatorLayout = rootView.findViewById(R.id.profileCoordinatorLayout) | ||
|
||
setHasOptionsMenu(true) | ||
|
||
if (!profileViewModel.isLoggedIn()) { | ||
Snackbar.make( | ||
CoordinatorLayout, "You need to log in first!", Snackbar.LENGTH_SHORT).show() | ||
Handler().postDelayed({ | ||
redirectToLogin() | ||
}, 1000) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strange indentation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will correct don't know why autoformat is going for this |
||
} | ||
|
||
profileViewModel.progress | ||
.nonNull() | ||
.observe(this, Observer { | ||
|
@@ -74,7 +77,8 @@ class ProfileFragment : Fragment() { | |
profileViewModel.error | ||
.nonNull() | ||
.observe(this, Observer { | ||
Toast.makeText(context, it, Toast.LENGTH_LONG).show() | ||
Snackbar.make( | ||
CoordinatorLayout, it, Snackbar.LENGTH_SHORT).show() | ||
}) | ||
|
||
profileViewModel.user | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use findViewById
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea why is this capital. Is this a class?