<commit_before>package com.hackgsu.fall2016.android.activities;

import android.os.Bundle;
import android.support.annotation.ColorInt;
import android.support.annotation.IdRes;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.NavigationView;
import android.support.v4.app.Fragment;
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.Menu;
import android.view.MenuItem;
import com.hackgsu.fall2016.android.R;
import com.hackgsu.fall2016.android.fragments.*;
import com.ncapdevi.fragnav.FragNavController;
import com.roughike.bottombar.BottomBar;
import com.roughike.bottombar.OnTabSelectListener;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener, OnTabSelectListener {
	private AppBarLayout      appbar;
	private BottomBar         bottomBar;
	private FragNavController fragNavController;
	private BaseFragment      lastHomeFragment;
	private Toolbar           toolbar;

	@Override
	protected void onCreate (Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		toolbar = (Toolbar) findViewById(R.id.toolbar);
		setSupportActionBar(toolbar);

		DrawerLayout          drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
		ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
		drawer.addDrawerListener(toggle);
		toggle.syncState();

		appbar = (AppBarLayout) findViewById(R.id.appbar);

		NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
		navigationView.setNavigationItemSelectedListener(this);

		final List<Fragment> fragments = new ArrayList<>();

		fragments.add(new AnnouncementsFragment());
		fragments.add(new ScheduleFragment());
		fragments.add(new FacilityMapFragment());
		fragments.add(new MentorsFragment());
		fragments.add(new SponsorsFragment());

		fragNavController = new FragNavController(getSupportFragmentManager(), R.id.fragment_frame, fragments);
		fragNavController.setNavListener(new FragNavController.NavListener() {
			@Override
			public void onTabTransaction (Fragment fragment, int index) {
				BaseFragment baseFragment = null;
				if (fragment instanceof BaseFragment) {
					baseFragment = ((BaseFragment) fragment);
				}

				if (baseFragment == null) { return; }

				if (index < 3) { lastHomeFragment = baseFragment; }
				setTitle(baseFragment.getTitle());
			}

			@Override
			public void onFragmentTransaction (Fragment fragment) {
				fragNavController.pop();
			}
		});
		fragNavController.switchTab(FragNavController.TAB1);

		bottomBar = (BottomBar) findViewById(R.id.bottomBar);
		bottomBar.setOnTabSelectListener(this);
		//		drawer.
	}

	@Override
	public void onBackPressed () {
		// TODO: 9/27/16 : Handle the case where when the user is in a fragment other than the three main fragments, instead of closing the app, it will return to home
		DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
		if (drawer.isDrawerOpen(GravityCompat.START)) {
			drawer.closeDrawer(GravityCompat.START);
		}
		else {
			super.onBackPressed();
		}
	}

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

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

		// TODO: 9/27/16 : Toggle icon and actually mute notifications
		if (id == R.id.action_mute_notifications) { return true; }

		return super.onOptionsItemSelected(item);
	}

	@SuppressWarnings ("StatementWithEmptyBody")
	@Override
	public boolean onNavigationItemSelected (MenuItem item) {
		handleAction(item.getItemId());

		DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
		drawer.closeDrawer(GravityCompat.START);
		return true;
	}

	@Override
	public void onTabSelected (@IdRes int tabId) {
		handleAction(tabId);
	}

	private void handleAction (@IdRes int id) {
		@ColorInt int color = R.color.colorPrimary;
		switch (id) {
			case R.id.nav_home:<commit_msg>Updated manifest to lock screen orientation and duplicate fragments will no longer show up<commit_after>package com.hackgsu.fall2016.android.activities;

import android.os.Bundle;
import android.support.annotation.ColorInt;
import android.support.annotation.IdRes;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.NavigationView;
import android.support.v4.app.Fragment;
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.Menu;
import android.view.MenuItem;
import com.hackgsu.fall2016.android.R;
import com.hackgsu.fall2016.android.fragments.*;
import com.ncapdevi.fragnav.FragNavController;
import com.roughike.bottombar.BottomBar;
import com.roughike.bottombar.OnTabSelectListener;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener, OnTabSelectListener {
	private AppBarLayout      appbar;
	private BottomBar         bottomBar;
	private FragNavController fragNavController;
	private BaseFragment      lastFragment;
	private BaseFragment      lastHomeFragment;
	private Toolbar           toolbar;

	@Override
	protected void onCreate (Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		toolbar = (Toolbar) findViewById(R.id.toolbar);
		setSupportActionBar(toolbar);

		DrawerLayout          drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
		ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
		drawer.addDrawerListener(toggle);
		toggle.syncState();

		appbar = (AppBarLayout) findViewById(R.id.appbar);

		NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
		navigationView.setNavigationItemSelectedListener(this);

		final List<Fragment> fragments = new ArrayList<>();

		fragments.add(new AnnouncementsFragment());
		fragments.add(new ScheduleFragment());
		fragments.add(new FacilityMapFragment());
		fragments.add(new MentorsFragment());
		fragments.add(new SponsorsFragment());

		fragNavController = new FragNavController(getSupportFragmentManager(), R.id.fragment_frame, fragments);
		fragNavController.setNavListener(new FragNavController.NavListener() {
			@Override
			public void onTabTransaction (Fragment fragment, int index) {
				BaseFragment baseFragment = null;
				if (fragment instanceof BaseFragment) {
					baseFragment = ((BaseFragment) fragment);
				}

				if (baseFragment == null) { return; }

				lastFragment = baseFragment;
				if (index < 3) { lastHomeFragment = baseFragment; }
				setTitle(baseFragment.getTitle());
			}

			@Override
			public void onFragmentTransaction (Fragment fragment) {
			}
		});
		fragNavController.switchTab(FragNavController.TAB1);

		bottomBar = (BottomBar) findViewById(R.id.bottomBar);
		bottomBar.setOnTabSelectListener(this);
		//		drawer.
	}

	@Override
	public void onBackPressed () {
		// TODO: 9/27/16 : Handle the case where when the user is in a fragment other than the three main fragments, instead of closing the app, it will return to home
		DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
		if (drawer.isDrawerOpen(GravityCompat.START)) {
			drawer.closeDrawer(GravityCompat.START);
		}
		else {
			super.onBackPressed();
		}
	}

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

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

		// TODO: 9/27/16 : Toggle icon and actually mute notifications
		if (id == R.id.action_mute_notifications) { return true; }

		return super.onOptionsItemSelected(item);
	}

	@SuppressWarnings ("StatementWithEmptyBody")
	@Override
	public boolean onNavigationItemSelected (MenuItem item) {
		handleAction(item.getItemId());

		DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
		drawer.closeDrawer(GravityCompat.START);
		return true;
	}

	@Override
	public void onTabSelected (@IdRes int tabId) {
		handleAction(tabId);
	}

	@Override
	protected void onResume () {
		super.onResume();

		getSupportFragmentManager().beginTransaction().replace(R.id.fragment_frame, lastFragment).commitNow();
	}

	private void handleAction (@IdRes int id) {
		@ColorInt int color = R.color.colorPrimary;
		switch (id) {
			case R.id.nav_home:
{'fraction_non_alphanumeric': 0.09970056559831429, 'fraction_numerical': 0.006654097815237884, 'mean_word_length': 5.197938144329897, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '1920910', 'n_tokens_mistral': 2923, 'n_tokens_neox': 2644, 'n_words': 575}