Skip to content

Instantly share code, notes, and snippets.

View vprabhu's full-sized avatar

Vignesh Prabhu vprabhu

View GitHub Profile
**Privacy Policy**
VPDEVS built the GTimer app as
a Free app. This SERVICE is provided by
VPDEVS at no cost and is intended for use as
is.
This page is used to inform visitors regarding my
policies with the collection, use, and disclosure of Personal
Information if anyone decided to use my Service.
package com.example.firebaseAuth
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.util.Log
import android.view.View
import android.widget.Toast
import com.bumptech.glide.Glide
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
if (requestCode == RC_SIGN_IN) {
val result = Auth.GoogleSignInApi.getSignInResultFromIntent(data)
if (result.isSuccess) {
// Google Sign In was successful, authenticate with Firebase
val account = result.signInAccount
firebaseAuthWithGoogle(account!!)
} else {
private fun doLogin(){
val signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient)
startActivityForResult(signInIntent, RC_SIGN_IN)
}
public override fun onStart() {
super.onStart()
// Check if user is signed in (non-null) and update UI accordingly.
val currentUser = mAuth.currentUser
val userName = currentUser?.displayName
textView_username.text = userName
if(!userName.isNullOrEmpty()){
setLoginUIVisible(currentUser?.photoUrl)
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_login)
// initialise the FirebaseAuth instance
mAuth = FirebaseAuth.getInstance()
// Configure Google Sign In
mGoogleSignInOptions = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id))
private lateinit var mAuth: FirebaseAuth
private lateinit var mGoogleSignInOptions: GoogleSignInOptions
private lateinit var mGoogleApiClient:GoogleApiClient
<com.google.android.gms.common.SignInButton
android:id="@+id/button_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
val viewModel : TodoListViewModel = ViewModelProviders.of(this).get(TodoListViewModel::class.java)
viewModel.getAllTasksFromViewModel()?.observe(
this ,
Observer {
if (it != null) {
mTodoTaskAdapters = TodoTaskAdapters(this , it)
mTaskRecyclerView.layoutManager = LinearLayoutManager(
this.applicationContext ,
LinearLayout.VERTICAL , false)
mTaskRecyclerView.adapter = mTodoTaskAdapters
class TodoListViewModel : AndroidViewModel {
private var mTodoTaskList : LiveData<List<TodoTask>> ?= null
constructor(application: Application) : super(application) {
val appDatabase : AppDatabase? = AppDatabase.getInstance(this.getApplication())
mTodoTaskList = appDatabase?.todoTaskDao()?.getallTasks()
}
fun getAllTasksFromViewModel() : LiveData<List<TodoTask>>? {