Skip to content

Commit

Permalink
Merge pull request #32 from virresh/logout
Browse files Browse the repository at this point in the history
Logout Implemented
  • Loading branch information
virresh authored Nov 6, 2019
2 parents a09a177 + 4999ce3 commit 42f67f7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.SearchView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;
import androidx.cardview.widget.CardView;
import androidx.core.view.MenuItemCompat;

import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
Expand Down Expand Up @@ -118,4 +122,22 @@ else if(url!=null){
} );

}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_dashboard, menu);
return super.onCreateOptionsMenu(menu);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();

if (id == R.id.action_logout) {
FirebaseAuth.getInstance().signOut();
Intent signOutIntent = new Intent(this, SignInActivity.class);
startActivity(signOutIntent);
finish();
}
return super.onOptionsItemSelected(item);
}
}
9 changes: 9 additions & 0 deletions app/src/main/res/menu/menu_dashboard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_logout"
android:title="Logout"
app:showAsAction="never" />

</menu>

0 comments on commit 42f67f7

Please sign in to comment.