<commit_before>package com.blstream.studybox.components;

import android.content.Context;
import android.content.Intent;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.widget.Toast;

import com.blstream.studybox.R;
import com.blstream.studybox.activities.LoginActivity;
import com.blstream.studybox.login.LoginUtils;

public class DrawerAdapter extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {

    //TODO
    //Delete Toast messages and contexts after providing better tests for drawer

    NavigationView navigationView;
    DrawerLayout drawerLayout;
    Toolbar toolbar;
    Context context;

    public DrawerAdapter(NavigationView navigationView, DrawerLayout drawerLayout, Toolbar toolbar, Context context) {
        this.navigationView = navigationView;
        this.drawerLayout = drawerLayout;
        this.toolbar = toolbar;
        this.context = context;
    }

    public void attachDrawer() {
        navigationView.setNavigationItemSelectedListener(this);

        ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(
                this, drawerLayout, toolbar, R.string.nav_open_drawer, R.string.nav_close_drawer);
        drawerLayout.addDrawerListener(drawerToggle);
        drawerToggle.syncState();
    }

    @Override
    public boolean onNavigationItemSelected(MenuItem item) {
        item.setChecked(true);

        int id = item.getItemId();
        drawerLayout.closeDrawer(GravityCompat.START);

        switch (id) {
            case R.id.my_account:
                break;
            case R.id.my_decks:
                break;
            case R.id.create_flashcard:
                break;
            case R.id.show_deck:
                break;
            case R.id.statistics:
                break;
            case R.id.logout:
                LoginUtils.deleteUser(context);<commit_msg>DrawerAdapter doesn't extend AppCompatActivity anymore<commit_after>package com.blstream.studybox.components;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.widget.Toast;

import com.blstream.studybox.R;
import com.blstream.studybox.activities.LoginActivity;
import com.blstream.studybox.debugger.DebugHelper;
import com.blstream.studybox.login.LoginUtils;

public class DrawerAdapter implements NavigationView.OnNavigationItemSelectedListener {

    //TODO
    //Delete Toast messages after providing better tests for drawer

    private NavigationView navigationView;
    private DrawerLayout drawerLayout;
    private Toolbar toolbar;
    private Context context;
    private Activity application;

    public DrawerAdapter(NavigationView navigationView, DrawerLayout drawerLayout, Toolbar toolbar, Context context) {
        this.navigationView = navigationView;
        this.drawerLayout = drawerLayout;
        this.toolbar = toolbar;
        this.context = context;
        try {
            this.application = (Activity)context;
        } catch(ClassCastException e){
            DebugHelper.logException(e, "Unable to cast context to Activity object type", "CastException");
        }
    }

    public void attachDrawer() {
        navigationView.setNavigationItemSelectedListener(this);

        ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(
                application, drawerLayout, toolbar, R.string.nav_open_drawer, R.string.nav_close_drawer);
        drawerLayout.addDrawerListener(drawerToggle);
        drawerToggle.syncState();
    }

    @Override
    public boolean onNavigationItemSelected(MenuItem item) {
        item.setChecked(true);

        int id = item.getItemId();
        drawerLayout.closeDrawer(GravityCompat.START);

        switch (id) {
            case R.id.my_account:
                break;
            case R.id.my_decks:
                break;
            case R.id.create_flashcard:
                break;
            case R.id.show_deck:
                break;
            case R.id.statistics:
                break;
            case R.id.logout:
                LoginUtils.deleteUser(context);
{'fraction_non_alphanumeric': 0.07783272414534509, 'fraction_numerical': 0.0019350677273704579, 'mean_word_length': 2.9457167090754877, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2144259', 'n_tokens_mistral': 1261, 'n_tokens_neox': 1216, 'n_words': 257}