Search in sources :

Example 61 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project android-diplicity by zond.

the class GameActivity method draw.

public void draw() {
    setTitle(gameTitle());
    setContentView(R.layout.activity_game);
    if (game == null) {
        App.firebaseCrashReport("Drawing null game");
        Toast.makeText(this, R.string.unknown_error, Toast.LENGTH_SHORT).show();
        return;
    }
    flickFrameLayout = (FlickFrameLayout) findViewById(R.id.game_content);
    flickFrameLayout.gameActivity = this;
    findViewById(R.id.flick_frame_background).setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            flickFrameLayout.onTouchEvent(motionEvent);
            return true;
        }
    });
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    final ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(new DrawerLayout.DrawerListener() {

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            toggle.onDrawerSlide(drawerView, slideOffset);
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            ((TextView) findViewById(R.id.nav_title)).setText(gameTitle());
            toggle.onDrawerOpened(drawerView);
        }

        @Override
        public void onDrawerClosed(View drawerView) {
            toggle.onDrawerClosed(drawerView);
        }

        @Override
        public void onDrawerStateChanged(int newState) {
            toggle.onDrawerStateChanged(newState);
        }
    });
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    navigationView = (NavigationView) findViewById(R.id.nav_view);
    Menu nav_Menu = navigationView.getMenu();
    if (!game.Started) {
        nav_Menu.findItem(R.id.nav_orders).setVisible(false);
        nav_Menu.findItem(R.id.nav_phases).setVisible(false);
        nav_Menu.findItem(R.id.nav_press).setVisible(false);
        nav_Menu.findItem(R.id.nav_phase_settings).setVisible(false);
        nav_Menu.findItem(R.id.nav_game_settings).setVisible(false);
    }
    if (phaseMeta == null || !phaseMeta.Resolved) {
        nav_Menu.findItem(R.id.nav_phase_result).setVisible(false);
    }
    if (!game.Finished) {
        nav_Menu.findItem(R.id.nav_game_result).setVisible(false);
    }
    if (currentView == 0) {
        currentView = R.id.nav_map;
    }
    navigateTo(currentView);
}
Also used : NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Menu(android.view.Menu) DrawerLayout(android.support.v4.widget.DrawerLayout) NavigationView(android.support.design.widget.NavigationView) UserView(se.oort.diplicity.UserView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) ScrollView(android.widget.ScrollView) MotionEvent(android.view.MotionEvent) Toolbar(android.support.v7.widget.Toolbar)

Example 62 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project Gladys-Android-App by LeptitGeek.

the class MainActivity method initialdeclarations.

public void initialdeclarations() {
    toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    DrawerLayout drawer = findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    View header = navigationView.getHeaderView(0);
    user = header.findViewById(R.id.user);
    FloatingActionButton fab_scroll_up = findViewById(R.id.fab_scroll_up);
    fab_scroll_up.animate().translationY(fab_scroll_up.getHeight() + 400).setInterpolator(new LinearInterpolator()).start();
}
Also used : NavigationView(android.support.design.widget.NavigationView) LinearInterpolator(android.view.animation.LinearInterpolator) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) FloatingActionButton(android.support.design.widget.FloatingActionButton) DrawerLayout(android.support.v4.widget.DrawerLayout) NavigationView(android.support.design.widget.NavigationView) TextView(android.widget.TextView) View(android.view.View)

Example 63 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project SpaghettiCodeHQ by CMPUT301W18T16.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.drawer_layout);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    oldTaskList = (ListView) findViewById(R.id.myTaskView);
    Button addButton = (Button) findViewById(R.id.add1);
    addButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent intent = new Intent(getApplicationContext(), AddTaskActivity.class);
            startActivity(intent);
        }
    });
    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();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
}
Also used : NavigationView(android.support.design.widget.NavigationView) FloatingActionButton(android.support.design.widget.FloatingActionButton) Button(android.widget.Button) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Intent(android.content.Intent) DrawerLayout(android.support.v4.widget.DrawerLayout) NavigationView(android.support.design.widget.NavigationView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) Toolbar(android.support.v7.widget.Toolbar)

Example 64 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project SpaghettiCodeHQ by CMPUT301W18T16.

the class TaskActivity2 method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // assumption, this is the background view
    setContentView(R.layout.task2);
    EditText bodyText = (EditText) findViewById(R.id.body);
    Button clearButton = (Button) findViewById(R.id.clear);
    Button addButton = (Button) findViewById(R.id.add);
    final ListView taskListView = (ListView) findViewById(R.id.TaskList);
    Toolbar 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();
    NavigationView navView = (NavigationView) findViewById(R.id.nav_view);
    navView.setNavigationItemSelectedListener(this);
    // listen to item clicks
    adapter = new ArrayAdapter<Task>(TaskActivity2.this, android.R.layout.activity_list_item, taskList);
    taskListView.setAdapter(adapter);
    taskListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Task task = (Task) taskListView.getAdapter().getItem(position);
            Intent intent = new Intent(TaskActivity2.this, SingleTaskActivity.class);
            startActivityForResult(intent, 0);
        }
    });
    taskListView.setAdapter(adapter);
}
Also used : EditText(android.widget.EditText) NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Intent(android.content.Intent) NavigationView(android.support.design.widget.NavigationView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ListView(android.widget.ListView) FloatingActionButton(android.support.design.widget.FloatingActionButton) Button(android.widget.Button) AdapterView(android.widget.AdapterView) DrawerLayout(android.support.v4.widget.DrawerLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 65 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project Weather-Station by Kresshy.

the class NavigationDrawerFragment method setUp.

/**
 * Users of this fragment must call this method to set up the navigation drawer interactions.
 *
 * @param fragmentId   The android:id of this fragment in its activity's layout.
 * @param drawerLayout The DrawerLayout containing this fragment's UI.
 */
public void setUp(int fragmentId, DrawerLayout drawerLayout) {
    mFragmentContainerView = getActivity().findViewById(fragmentId);
    mDrawerLayout = drawerLayout;
    // set a custom shadow that overlays the main content when the drawer opens
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    // set up the drawer's list view with items and click listener
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);
    // ActionBarDrawerToggle ties together the the proper interactions
    // between the navigation drawer and the action bar app icon.
    mDrawerToggle = new ActionBarDrawerToggle(getActivity(), /* host Activity */
    mDrawerLayout, // R.drawable.ic_drawer,             /* nav drawer image to replace 'Up' caret */
    R.string.navigation_drawer_open, /* "open drawer" description for accessibility */
    R.string.navigation_drawer_close) {

        /* "close drawer" description for accessibility */
        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            if (!isAdded()) {
                return;
            }
            // calls onPrepareOptionsMenu()
            getActivity().supportInvalidateOptionsMenu();
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            if (!isAdded()) {
                return;
            }
            if (!mUserLearnedDrawer) {
                // The user manually opened the drawer; store this flag to prevent auto-showing
                // the navigation drawer automatically in the future.
                mUserLearnedDrawer = true;
                SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
                sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply();
            }
            // calls onPrepareOptionsMenu()
            getActivity().supportInvalidateOptionsMenu();
        }
    };
    // per the navigation drawer design guidelines.
    if (!mUserLearnedDrawer && !mFromSavedInstanceState) {
        mDrawerLayout.openDrawer(mFragmentContainerView);
    }
    // Defer code dependent on restoration of previous instance state.
    mDrawerLayout.post(new Runnable() {

        @Override
        public void run() {
            mDrawerToggle.syncState();
        }
    });
    mDrawerLayout.setDrawerListener(mDrawerToggle);
}
Also used : SharedPreferences(android.content.SharedPreferences) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ActionBar(android.support.v7.app.ActionBar)

Aggregations

ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)218 View (android.view.View)153 NavigationView (android.support.design.widget.NavigationView)118 Toolbar (android.support.v7.widget.Toolbar)98 DrawerLayout (android.support.v4.widget.DrawerLayout)96 TextView (android.widget.TextView)85 AdapterView (android.widget.AdapterView)51 ImageView (android.widget.ImageView)48 ListView (android.widget.ListView)48 Intent (android.content.Intent)45 ActionBarDrawerToggle (android.support.v4.app.ActionBarDrawerToggle)35 ActionBar (android.support.v7.app.ActionBar)31 SharedPreferences (android.content.SharedPreferences)30 RecyclerView (android.support.v7.widget.RecyclerView)23 Bundle (android.os.Bundle)20 FloatingActionButton (android.support.design.widget.FloatingActionButton)20 LinearLayout (android.widget.LinearLayout)19 MenuItem (android.view.MenuItem)17 BindView (butterknife.BindView)15 ArrayList (java.util.ArrayList)15