<commit_before>package pl.snowdog.dzialajlokalnie;


import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.NavigationView;
import android.support.design.widget.TabLayout;
import android.support.v4.view.GravityCompat;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.TextView;

import com.activeandroid.query.Select;
import com.getbase.floatingactionbutton.FloatingActionsMenu;
import com.squareup.picasso.Picasso;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.OptionsItem;
import org.androidannotations.annotations.OptionsMenu;
import org.androidannotations.annotations.ViewById;

import java.util.List;
import java.util.Locale;

import de.greenrobot.event.EventBus;
import pl.snowdog.dzialajlokalnie.adapter.FragmentAdapter;
import pl.snowdog.dzialajlokalnie.api.DlApi;
import pl.snowdog.dzialajlokalnie.events.FilterChangedEvent;
import pl.snowdog.dzialajlokalnie.events.ObjectAddedEvent;
import pl.snowdog.dzialajlokalnie.fragment.EventsFragment_;
import pl.snowdog.dzialajlokalnie.fragment.FilterFragment;
import pl.snowdog.dzialajlokalnie.fragment.FilterFragment_;
import pl.snowdog.dzialajlokalnie.fragment.IssuesFragment_;
import pl.snowdog.dzialajlokalnie.fragment.MapFragment_;
import pl.snowdog.dzialajlokalnie.gcm.NotificationAction;
import pl.snowdog.dzialajlokalnie.model.District;
import pl.snowdog.dzialajlokalnie.model.Filter;
import pl.snowdog.dzialajlokalnie.model.Session;
import pl.snowdog.dzialajlokalnie.model.User;
import pl.snowdog.dzialajlokalnie.util.CircleTransform;

@EActivity(R.layout.activity_main)
@OptionsMenu(R.menu.menu_main)
public class MainActivity extends BaseActivity {

    private static final String TAG = "MainActivity";
    @ViewById(R.id.pager)
    ViewPager mViewPager;

    @ViewById(R.id.drawer_layout)
    DrawerLayout mDrawerLayout;

    @ViewById(R.id.nav_view)
    NavigationView mNavigationView;

    @ViewById(R.id.tabs)
    TabLayout mTabLayout;

    @ViewById(R.id.fab)
    FloatingActionsMenu fab;

    @ViewById(R.id.ivAvatar)
    ImageView ivNavAvatar;

    @ViewById(R.id.tvUserName)
    TextView tvNavUserName;

    @ViewById(R.id.tvUserDistrict)
    TextView tvNavUserDistrict;


    @Click(R.id.navHeader)
    void onNavHeaderClicked() {
        if (isLoggedIn() && !DlApplication.currentSession.isFacebookSession()) {
            AddUserActivity_.intent(this).mEditedUser(getLoggedInUser()).start();
            mDrawerLayout.closeDrawers();
        } else if (DlApplication.currentSession == null){
            LoginActivity_.intent(this).start();
            mDrawerLayout.closeDrawers();
        }
    }

    @AfterViews
    protected void afterView() {

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        final ActionBar ab = getSupportActionBar();
        ab.setHomeAsUpIndicator(R.drawable.ic_menu);
        ab.setDisplayHomeAsUpEnabled(true);

        if (mNavigationView != null) {
            setupDrawerContent(mNavigationView);
        }

        if (mViewPager != null) {
            setupViewPager(mViewPager);
        }

        mTabLayout.setupWithViewPager(mViewPager);

        updateUserNavHeader();

    }

    protected void updateUserNavHeader() {
        if (!isLoggedIn()) {
            tvNavUserName.setText(R.string.login_or_register);
            tvNavUserDistrict.setText("");
        } else {
            User user = getLoggedInUser();
            if (user != null) {
                tvNavUserName.setText(user.getName() + " " + user.getSurname());
                District district = new Select().from(District.class).where("districtID = ?", user.getDistrictID()).executeSingle();
                if (district != null) {
                    tvNavUserDistrict.setText(district.getName());
                }

                Picasso.with(this).
                        load(String.format(DlApi.AVATAR_NORMAL_URL, user.getAvatarUri())).
                        error(R.drawable.ic_editor_insert_emoticon).
                        transform(new CircleTransform()).
                        into(ivNavAvatar);
            } else {
<commit_msg>avatar no longer stays in nav header after logout<commit_after>package pl.snowdog.dzialajlokalnie;


import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.NavigationView;
import android.support.design.widget.TabLayout;
import android.support.v4.view.GravityCompat;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.TextView;

import com.activeandroid.query.Select;
import com.getbase.floatingactionbutton.FloatingActionsMenu;
import com.squareup.picasso.Picasso;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.OptionsItem;
import org.androidannotations.annotations.OptionsMenu;
import org.androidannotations.annotations.ViewById;

import java.util.List;
import java.util.Locale;

import de.greenrobot.event.EventBus;
import pl.snowdog.dzialajlokalnie.adapter.FragmentAdapter;
import pl.snowdog.dzialajlokalnie.api.DlApi;
import pl.snowdog.dzialajlokalnie.events.FilterChangedEvent;
import pl.snowdog.dzialajlokalnie.events.ObjectAddedEvent;
import pl.snowdog.dzialajlokalnie.fragment.EventsFragment_;
import pl.snowdog.dzialajlokalnie.fragment.FilterFragment;
import pl.snowdog.dzialajlokalnie.fragment.FilterFragment_;
import pl.snowdog.dzialajlokalnie.fragment.IssuesFragment_;
import pl.snowdog.dzialajlokalnie.fragment.MapFragment_;
import pl.snowdog.dzialajlokalnie.gcm.NotificationAction;
import pl.snowdog.dzialajlokalnie.model.District;
import pl.snowdog.dzialajlokalnie.model.Filter;
import pl.snowdog.dzialajlokalnie.model.Session;
import pl.snowdog.dzialajlokalnie.model.User;
import pl.snowdog.dzialajlokalnie.util.CircleTransform;

@EActivity(R.layout.activity_main)
@OptionsMenu(R.menu.menu_main)
public class MainActivity extends BaseActivity {

    private static final String TAG = "MainActivity";
    @ViewById(R.id.pager)
    ViewPager mViewPager;

    @ViewById(R.id.drawer_layout)
    DrawerLayout mDrawerLayout;

    @ViewById(R.id.nav_view)
    NavigationView mNavigationView;

    @ViewById(R.id.tabs)
    TabLayout mTabLayout;

    @ViewById(R.id.fab)
    FloatingActionsMenu fab;

    @ViewById(R.id.ivAvatar)
    ImageView ivNavAvatar;

    @ViewById(R.id.tvUserName)
    TextView tvNavUserName;

    @ViewById(R.id.tvUserDistrict)
    TextView tvNavUserDistrict;


    @Click(R.id.navHeader)
    void onNavHeaderClicked() {
        if (isLoggedIn() && !DlApplication.currentSession.isFacebookSession()) {
            AddUserActivity_.intent(this).mEditedUser(getLoggedInUser()).start();
            mDrawerLayout.closeDrawers();
        } else if (DlApplication.currentSession == null){
            LoginActivity_.intent(this).start();
            mDrawerLayout.closeDrawers();
        }
    }

    @AfterViews
    protected void afterView() {

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        final ActionBar ab = getSupportActionBar();
        ab.setHomeAsUpIndicator(R.drawable.ic_menu);
        ab.setDisplayHomeAsUpEnabled(true);

        if (mNavigationView != null) {
            setupDrawerContent(mNavigationView);
        }

        if (mViewPager != null) {
            setupViewPager(mViewPager);
        }

        mTabLayout.setupWithViewPager(mViewPager);

        updateUserNavHeader();

    }

    protected void updateUserNavHeader() {
        if (!isLoggedIn()) {
            tvNavUserName.setText(R.string.login_or_register);
            tvNavUserDistrict.setText("");
            Picasso.with(this).
                    load(String.format(DlApi.AVATAR_NORMAL_URL, "")).
                    error(R.drawable.ic_editor_insert_emoticon).
                    transform(new CircleTransform()).
                    into(ivNavAvatar);
        } else {
            User user = getLoggedInUser();
            if (user != null) {
                tvNavUserName.setText(user.getName() + " " + user.getSurname());
                District district = new Select().from(District.class).where("districtID = ?", user.getDistrictID()).executeSingle();
                if (district != null) {
                    tvNavUserDistrict.setText(district.getName());
                }

                Picasso.with(this).
                        load(String.format(DlApi.AVATAR_NORMAL_URL, user.getAvatarUri())).
                        error(R.drawable.ic_editor_insert_emoticon).
                        transform(new CircleTransform()).
                        into(ivNavAvatar);
            } else {

{'fraction_non_alphanumeric': 0.10257234726688103, 'fraction_numerical': 0.0010718113612004287, 'mean_word_length': 3.37869544814641, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1692340', 'n_tokens_mistral': 2880, 'n_tokens_neox': 2809, 'n_words': 396}