Search in sources :

Example 91 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project HikingApp by wickhama.

the class MenuActivity method onCreate.

/**
 * Created by Ryley, modified by Ayla, Caleigh
 * Added for increment 1
 *
 * Part of the startup process for activities. acts like a constructor.
 *
 * Increment 1:
 *      Connects this activity to its layout
 *      Connects this activity to the toolbar and side-menu as a listener
 *          listener methods not implemented
 *
 * Increment 2:
 *      Builds the initial state for the side menu
 *      Loads files from the APK onto the file system on startup
 *
 * Increment 3:
 *      Now only loads files on *first* startup, instead of every time
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // checks if this is the first time the app has been run
    // SharedPreferences wmbPreference = PreferenceManager.getDefaultSharedPreferences(this);
    // boolean isFirstRun = wmbPreference.getBoolean(PREFERENCE_FIRST_RUN, true);
    // if (isFirstRun)
    // {
    // // Code to run once
    // SharedPreferences.Editor editor = wmbPreference.edit();
    // editor.putBoolean(PREFERENCE_FIRST_RUN, false);
    // editor.apply();
    // //Adds Files into phone storage - aw
    // initAssets.initAssets(this);
    // }
    mListeners = new HashSet<>();
    // loads the layout
    setContentView(R.layout.activity_menu);
    // uses the toolbar defined in the layout
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    // connects the side menu to the 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.addDrawerListener(toggle);
    toggle.syncState();
    // Has this activity listen for menu events
    NavigationView navigationView = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    Menu menu = navigationView.getMenu();
    // initially there is no map, so remove the options
    menu.findItem(R.id.trail_menu).getSubMenu().setGroupVisible(R.id.map_options, false);
    // create a database instance to improve load times later
    Database.getDatabase();
}
Also used : NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Menu(android.view.Menu) DrawerLayout(android.support.v4.widget.DrawerLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 92 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project HikingApp by wickhama.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG).setAction("Action", null).show();
        }
    });
    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.setDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
}
Also used : NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) FloatingActionButton(android.support.design.widget.FloatingActionButton) DrawerLayout(android.support.v4.widget.DrawerLayout) NavigationView(android.support.design.widget.NavigationView) View(android.view.View) Toolbar(android.support.v7.widget.Toolbar)

Example 93 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project BloodHub by kazijehangir.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    // get email from login activity
    request = false;
    mAuth = FirebaseAuth.getInstance();
    user = mAuth.getCurrentUser();
    if (user != null) {
        mEmail = user.getEmail();
    } else {
        super.onBackPressed();
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    fab_plus = (FloatingActionButton) findViewById(R.id.fab2);
    fab_request = (FloatingActionButton) findViewById(R.id.fab1);
    button_request = (Button) findViewById(R.id.add_blood_request);
    fab_appointment = (FloatingActionButton) findViewById(R.id.fab);
    button_appointment = (Button) findViewById(R.id.add_appointment);
    FabOpen = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fab_open);
    FabClose = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fab_close);
    FabRClockwise = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.rotate_forward);
    FabRanticlockwise = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.rotate_backward);
    // button_request.setVisibility(View.GONE);
    // button_appointment.setVisibility(View.GONE);
    fab_plus.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (isOpen) {
                fab_request.startAnimation(FabClose);
                // button_appointment.startAnimation(FabClose);
                fab_appointment.startAnimation(FabClose);
                // button_request.startAnimation(FabClose);
                button_request.setVisibility(View.GONE);
                button_appointment.setVisibility(View.GONE);
                fab_plus.startAnimation(FabRanticlockwise);
                button_request.setClickable(false);
                button_appointment.setClickable(false);
                fab_request.setClickable(false);
                fab_appointment.setClickable(false);
                isOpen = false;
            } else {
                fab_request.startAnimation(FabOpen);
                // button_request.startAnimation(FabOpen);
                // button_appointment.startAnimation(FabOpen);
                fab_appointment.startAnimation(FabOpen);
                fab_plus.startAnimation(FabRClockwise);
                button_appointment.setVisibility(View.VISIBLE);
                button_request.setVisibility(View.VISIBLE);
                button_appointment.setClickable(true);
                button_request.setClickable(true);
                fab_request.setClickable(true);
                fab_appointment.setClickable(true);
                isOpen = true;
            }
        }
    });
    fab_request.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent intent = new Intent(MainActivity.this, AddRequestActivity.class);
            intent.putExtra("mEmail", mEmail);
            startActivity(intent);
        }
    });
    button_request.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent intent = new Intent(MainActivity.this, AddRequestActivity.class);
            intent.putExtra("mEmail", mEmail);
            startActivity(intent);
        }
    });
    fab_appointment.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent intent = new Intent(MainActivity.this, AddAppointmentActivity.class);
            intent.putExtra("mEmail", mEmail);
            startActivity(intent);
        }
    });
    button_appointment.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent intent = new Intent(MainActivity.this, AddAppointmentActivity.class);
            intent.putExtra("mEmail", mEmail);
            startActivity(intent);
        }
    });
    mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    mDrawer.setDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    // Home should be selected when this activity starts
    navigationView.setCheckedItem(R.id.nav_home);
    // Insert the home fragment by replacing any existing fragment
    try {
        Fragment fragment = HomeFragment.class.newInstance();
        FragmentManager fragmentManager = getSupportFragmentManager();
        fragmentManager.beginTransaction().replace(R.id.flContent, fragment).commit();
    } catch (Exception e) {
        e.printStackTrace();
    }
    // Name and email Address should be displayed on nav-bar
    View header = navigationView.getHeaderView(0);
    TextView mNav_email = (TextView) header.findViewById(R.id.nav_header_email);
    mNav_name = (TextView) header.findViewById(R.id.nav_header_name);
    ImageView mNav_image = (ImageView) header.findViewById(R.id.nav_header_image);
    mNav_email.setText(mEmail);
    getNameFromDatabase();
    // mNav_image.setImageDrawable();
    LinearLayout lheader = (LinearLayout) header.findViewById(R.id.header);
    lheader.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent intent = new Intent(MainActivity.this, UserProfile.class);
            startActivity(intent);
        }
    });
}
Also used : NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Intent(android.content.Intent) NavigationView(android.support.design.widget.NavigationView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) Fragment(android.support.v4.app.Fragment) FragmentManager(android.support.v4.app.FragmentManager) TextView(android.widget.TextView) ImageView(android.widget.ImageView) LinearLayout(android.widget.LinearLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 94 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project BloodHub by kazijehangir.

the class MainActivityOrg method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    // get email from login activity
    mAuth = FirebaseAuth.getInstance();
    user = mAuth.getCurrentUser();
    if (user != null) {
        mEmail = user.getEmail();
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_org);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    fab_plus = (FloatingActionButton) findViewById(R.id.fab2);
    fab_request = (FloatingActionButton) findViewById(R.id.fab1);
    fab_appointment = (FloatingActionButton) findViewById(R.id.fab);
    button_request = (Button) findViewById(R.id.add_blood_request);
    button_patient = (Button) findViewById(R.id.add_patient);
    FabOpen = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fab_open);
    FabClose = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fab_close);
    FabRClockwise = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.rotate_forward);
    FabRanticlockwise = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.rotate_backward);
    fab_plus.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (isOpen) {
                fab_request.startAnimation(FabClose);
                fab_appointment.startAnimation(FabClose);
                button_request.setVisibility(View.GONE);
                button_patient.setVisibility(View.GONE);
                fab_plus.startAnimation(FabRanticlockwise);
                fab_request.setClickable(false);
                fab_appointment.setClickable(false);
                isOpen = false;
            } else {
                fab_request.startAnimation(FabOpen);
                fab_appointment.startAnimation(FabOpen);
                fab_plus.startAnimation(FabRClockwise);
                button_request.setVisibility(View.VISIBLE);
                button_patient.setVisibility(View.VISIBLE);
                fab_request.setClickable(true);
                fab_appointment.setClickable(true);
                isOpen = true;
            }
        }
    });
    fab_request.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent intent = new Intent(MainActivityOrg.this, AddPatientActivity.class);
            intent.putExtra("mEmail", mEmail);
            startActivity(intent);
        }
    });
    fab_appointment.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent intent = new Intent(MainActivityOrg.this, AddDonorActivity.class);
            intent.putExtra("mEmail", mEmail);
            startActivity(intent);
        }
    });
    button_request.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent intent = new Intent(MainActivityOrg.this, AddPatientActivity.class);
            intent.putExtra("mEmail", mEmail);
            startActivity(intent);
        }
    });
    button_patient.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent intent = new Intent(MainActivityOrg.this, AddDonorActivity.class);
            intent.putExtra("mEmail", mEmail);
            startActivity(intent);
        }
    });
    mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    mDrawer.setDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    // setupDrawerContent(navigationView);
    // Home should be selected when this activity starts
    navigationView.setCheckedItem(R.id.nav_home);
    // Insert the home fragment by replacing any existing fragment
    try {
        Fragment fragment = HomeOrgFragment.class.newInstance();
        FragmentManager fragmentManager = getSupportFragmentManager();
        fragmentManager.beginTransaction().replace(R.id.flContent, fragment).commit();
    } catch (Exception e) {
        e.printStackTrace();
    }
    // Name and email Address should be displayed on nav-bar
    View header = navigationView.getHeaderView(0);
    TextView mNav_email = (TextView) header.findViewById(R.id.nav_header_email);
    mNav_name = (TextView) header.findViewById(R.id.nav_header_name);
    ImageView mNav_image = (ImageView) header.findViewById(R.id.nav_header_image);
    mNav_email.setText(mEmail);
    getNameFromDatabase();
    // mNav_image.setImageDrawable();
    LinearLayout lheader = (LinearLayout) header.findViewById(R.id.header);
    lheader.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent intent = new Intent(MainActivityOrg.this, UserProfileOrg.class);
            intent.putExtra("mEmail", mEmail);
            startActivity(intent);
        }
    });
}
Also used : NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Intent(android.content.Intent) NavigationView(android.support.design.widget.NavigationView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) Fragment(android.support.v4.app.Fragment) FragmentManager(android.support.v4.app.FragmentManager) TextView(android.widget.TextView) ImageView(android.widget.ImageView) LinearLayout(android.widget.LinearLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 95 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project Now by XunMengWinter.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    String imgs = mPreferencesHelper.getHeadImages();
    Log.i("xyz", "imgs " + imgs);
    if (!TextUtils.isEmpty(imgs))
        mImgList = JSON.parseArray(imgs);
    setTitle("");
    toolbar = mMaterialViewPager.getToolbar();
    if (toolbar != null) {
        setSupportActionBar(toolbar);
        final ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(true);
            actionBar.setDisplayShowHomeEnabled(true);
            actionBar.setDisplayShowTitleEnabled(true);
            actionBar.setDisplayUseLogoEnabled(false);
            actionBar.setHomeButtonEnabled(true);
        }
        toolbar.setLayoutParams(new RelativeLayout.LayoutParams(toolbar.getWidth(), UIHelper.getStatusBarHeight()));
    }
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, 0, 0);
    mDrawerLayout.addDrawerListener(mDrawerToggle);
    checkIsFirst();
    initDrawer();
}
Also used : RelativeLayout(android.widget.RelativeLayout) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) 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