package com.blstream.studybox;

import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
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 butterknife.Bind;
import butterknife.ButterKnife;


public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {

    @Bind(R.id.drawer_layout) DrawerLayout drawerLayout;
    @Bind(R.id.toolbar) Toolbar toolbar;
    @Bind(R.id.nav_view) NavigationView navigationView;

    private static final String TAG = MainActivity.class.getSimpleName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ButterKnife.bind(this);

        setSupportActionBar(toolbar);
        navigationView.setNavigationItemSelectedListener(this);

        ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(
                this, drawerLayout, toolbar, R.string.nav_open_drawer, R.string.nav_close_drawer);
        drawerLayout.setDrawerListener(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:
                break;
        }

        // Only for testing
        Toast.makeText(this, "Selected: " + item.getTitle(), Toast.LENGTH_SHORT).show();

        return true;
    }

    @Override
    public void onBackPressed() {
        if (drawerLayout.isDrawerOpen(GravityCompat.START)) {
            drawerLayout.closeDrawer(GravityCompat.START);
        } else {
            super.onBackPressed();
        }
    }

    /**
     * Applies custom font to every activity that overrides this method
     */
    @Override
    protected void attachBaseContext(Context newBase) {
        super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
    }
}

@@ -131,16 +131,48 @@
 ctivity;
+%0A%0Aimport retrofit.RetrofitError;
 %0Aimport 
@@ -526,16 +526,216 @@
 .Toast;%0A
+%0Aimport com.blstream.studybox.api.RequestCallback;%0Aimport com.blstream.studybox.api.RequestListener;%0Aimport com.blstream.studybox.api.RestClientManager;%0Aimport com.blstream.studybox.model.DecksList;%0A%0A
 import b
@@ -1684,24 +1684,44 @@
 yncState();%0A
+        getDecks();%0A
     %7D%0A%0A    @
@@ -2825,24 +2825,24 @@
  newBase) %7B%0A
-
         supe
@@ -2908,11 +2908,361 @@
 );%0A    %7D
+%0A%0A    public void getDecks()%7B%0A        RestClientManager.getAllDecks(Constants.API_KEY, new RequestCallback%3C%3E(new RequestListener%3CDecksList%3E() %7B%0A            @Override%0A            public void onSuccess(DecksList response) %7B%0A%0A            %7D%0A%0A            @Override%0A            public void onFailure(RetrofitError error) %7B%0A%0A            %7D%0A        %7D));%0A    %7D
 %0A%7D%0A

add getDecks method