|
@@ -15,32 +15,36 @@ import com.swago.baseswago.util.AppContext
|
|
*/
|
|
*/
|
|
object FBLogin {
|
|
object FBLogin {
|
|
private val manager = CallbackManager.Factory.create()
|
|
private val manager = CallbackManager.Factory.create()
|
|
- fun init(iFacebook: IFacebook){
|
|
|
|
- LoginManager.getInstance().registerCallback(manager,object:FacebookCallback<LoginResult>{
|
|
|
|
|
|
+ fun init(iFacebook: IFacebook) {
|
|
|
|
+ LoginManager.getInstance()
|
|
|
|
+ .registerCallback(manager, object : FacebookCallback<LoginResult> {
|
|
|
|
|
|
- override fun onSuccess(result: LoginResult?) {
|
|
|
|
- result?.apply {
|
|
|
|
- iFacebook.getToken(accessToken.token)
|
|
|
|
|
|
+ override fun onCancel() {
|
|
|
|
+ Toast.makeText(AppContext.getContext(), "Login Cancel", Toast.LENGTH_SHORT)
|
|
|
|
+ .show()
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
- override fun onCancel() {
|
|
|
|
- Toast.makeText(AppContext.getContext(), "Login Cancel", Toast.LENGTH_SHORT).show()
|
|
|
|
- }
|
|
|
|
|
|
+ override fun onError(error: FacebookException) {
|
|
|
|
+ Toast.makeText(
|
|
|
|
+ AppContext.getContext(),
|
|
|
|
+ error.message ?: "",
|
|
|
|
+ Toast.LENGTH_SHORT
|
|
|
|
+ ).show()
|
|
|
|
+ }
|
|
|
|
|
|
- override fun onError(error: FacebookException?) {
|
|
|
|
- Toast.makeText(AppContext.getContext(), error?.message?:"", Toast.LENGTH_SHORT).show()
|
|
|
|
- }
|
|
|
|
|
|
+ override fun onSuccess(result: LoginResult) {
|
|
|
|
+ iFacebook.getToken(result.accessToken.token)
|
|
|
|
+ }
|
|
|
|
|
|
- })
|
|
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- fun login(activity: LoginActivity){
|
|
|
|
|
|
+ fun login(activity: LoginActivity) {
|
|
LoginManager.getInstance().logInWithReadPermissions(activity, listOf("public_profile"))
|
|
LoginManager.getInstance().logInWithReadPermissions(activity, listOf("public_profile"))
|
|
}
|
|
}
|
|
|
|
|
|
- fun onActivityResult(requestCoe:Int, resultCode:Int, data: Intent){
|
|
|
|
- manager.onActivityResult(requestCoe,resultCode, data)
|
|
|
|
|
|
+ fun onActivityResult(requestCoe: Int, resultCode: Int, data: Intent) {
|
|
|
|
+ manager.onActivityResult(requestCoe, resultCode, data)
|
|
}
|
|
}
|
|
}
|
|
}
|