-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from frontegg/FR-17074-fix-double-refresh-token
FR-17074 - Clear Webview when detached from window
- Loading branch information
Showing
11 changed files
with
165 additions
and
8 deletions.
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
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
64 changes: 64 additions & 0 deletions
64
embedded/src/main/java/com/frontegg/demo/ui/home/AccessTokenFragment.kt
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.frontegg.demo.ui.home | ||
|
||
import android.os.Bundle | ||
import android.util.Log | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.Fragment | ||
import androidx.lifecycle.ViewModelProvider | ||
import com.frontegg.android.FronteggAuth | ||
import com.frontegg.demo.databinding.FragmentAccessTokenBinding | ||
|
||
class AccessTokenFragment : Fragment() { | ||
|
||
private var _binding: FragmentAccessTokenBinding? = null | ||
|
||
// This property is only valid between onCreateView and | ||
// onDestroyView. | ||
private val binding get() = _binding!! | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View { | ||
val homeViewModel = ViewModelProvider(this)[HomeViewModel::class.java] | ||
|
||
_binding = FragmentAccessTokenBinding.inflate(inflater, container, false) | ||
|
||
val root: View = binding.root | ||
|
||
homeViewModel.user.observe(viewLifecycleOwner) { | ||
if (it != null) { | ||
|
||
binding.name.text = it.name | ||
binding.email.text = it.email | ||
} | ||
} | ||
|
||
homeViewModel.accesstoken.observe(viewLifecycleOwner) { | ||
|
||
// this one will be disable in background | ||
// will resume on foreground | ||
Log.w("AccessTokenFragment", "Access token (viewModel): $it") | ||
binding.accessToken.text = it | ||
} | ||
|
||
return root | ||
} | ||
|
||
override fun onResume() { | ||
super.onResume() | ||
|
||
FronteggAuth.instance.accessToken.subscribe { | ||
Log.w("AccessTokenFragment", "Access token(subscribe): ${it.value}") | ||
Log.w("AccessTokenFragment", "Access token(direct): ${FronteggAuth.instance.accessToken.value}") | ||
}; | ||
} | ||
|
||
override fun onDestroyView() { | ||
super.onDestroyView() | ||
_binding = null | ||
} | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout 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:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".ui.home.AccessTokenFragment"> | ||
|
||
<ScrollView | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
|
||
<TextView | ||
android:id="@+id/name" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="16dp" | ||
android:layout_marginTop="24dp" | ||
android:layout_marginEnd="16dp" | ||
android:hint="Full Name" | ||
android:textAlignment="textStart" | ||
android:textSize="20sp" | ||
android:textColor="@color/black" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<TextView | ||
android:id="@+id/email" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="16dp" | ||
android:layout_marginTop="8dp" | ||
android:layout_marginEnd="16dp" | ||
android:hint="Email" | ||
android:textAlignment="textStart" | ||
android:textSize="16sp" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/name" /> | ||
|
||
<TextView | ||
android:id="@+id/accessToken" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginStart="16dp" | ||
android:layout_marginTop="8dp" | ||
android:layout_marginEnd="16dp" | ||
android:hint="Access Token" | ||
android:textAlignment="textStart" | ||
android:textSize="16sp" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/email" /> | ||
</LinearLayout> | ||
</ScrollView> | ||
</androidx.constraintlayout.widget.ConstraintLayout> |
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
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