Search in sources :

Example 56 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project ShelterApp by farzamtn.

the class MapsMasterActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Retrieve location and camera position from saved instance state.
    if (savedInstanceState != null) {
        mLastKnownLocation = savedInstanceState.getParcelable(KEY_LOCATION);
        mCameraPosition = savedInstanceState.getParcelable(KEY_CAMERA_POSITION);
    }
    setContentView(R.layout.activity_maps_master);
    // Get Firebase auth instance
    mAuth = FirebaseAuth.getInstance();
    checkIfEmailVerified();
    // GT defaults for the first time
    if (mLastKnownLocation == null) {
        // To avoid NullPointerException
        Location GT_location = new Location("Default GT Location");
        GT_location.setLatitude(33.7756);
        GT_location.setLongitude(-84.3963);
        mLastKnownLocation = GT_location;
    }
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    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);
    model = Shelters.INSTANCE;
    // Construct a FusedLocationProviderClient.
    mFusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this);
    // Must be after shelter model is populated from the DB
    // Obtain the SupportMapFragment and get notified when the map is ready to be used.
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
}
Also used : SupportMapFragment(com.google.android.gms.maps.SupportMapFragment) NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) FloatingActionButton(android.support.design.widget.FloatingActionButton) DrawerLayout(android.support.v4.widget.DrawerLayout) Location(android.location.Location) Toolbar(android.support.v7.widget.Toolbar)

Example 57 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project OnlineCanteen by josephgunawan97.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.AppTheme);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // Initialize Navigation View
    DrawerLayout drawerLayout = findViewById(R.id.main_drawer_layout);
    ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.navigation_open, R.string.navigation_close);
    drawerLayout.addDrawerListener(drawerToggle);
    drawerToggle.syncState();
    NavigationView navigationView = findViewById(R.id.main_navigation_view);
    navigationView.setNavigationItemSelectedListener(new MainNavigationListener());
    // Get User
    firebaseAuth = FirebaseAuth.getInstance();
    user = firebaseAuth.getCurrentUser();
    // Initialize References
    databaseUsers = FirebaseDatabase.getInstance().getReference("users");
    databaseProducts = FirebaseDatabase.getInstance().getReference("products");
    databaseStore = FirebaseDatabase.getInstance().getReference("store");
    databaseWallet = FirebaseDatabase.getInstance().getReference("wallet");
    // Product List
    ArrayList<Product> productArrayList = new ArrayList<>();
    menuListAdapter = new MenuListAdapter(this, productArrayList);
    // Initialize ListView
    productListView = findViewById(R.id.list);
    productListView.setAdapter(menuListAdapter);
    // Cart Button and Click Handler
    placeOrder = findViewById(R.id.OrderButton);
    placeOrder.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            cart = menuListAdapter.getList();
            // Check empty cart
            boolean emptyCart = true;
            for (Cart c : cart) {
                if (c.getQuantity() != 0) {
                    emptyCart = false;
                    break;
                }
            }
            if (emptyCart == true) {
                // Alert dialog if there are no items in cart
                AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                builder.setMessage("You don't have any items in your cart!").setCancelable(false).setNegativeButton("Ok", new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });
                AlertDialog alert = builder.create();
                alert.setTitle("Error");
                alert.show();
            } else {
                // Remove item if qty is 0
                ArrayList<Cart> toRemove = new ArrayList<>();
                for (Cart c : cart) {
                    if (c.getQuantity() == 0) {
                        toRemove.add(c);
                    }
                }
                cart.removeAll(toRemove);
                // Go to cart
                Intent intent = new Intent(MainActivity.this, CartActivity.class);
                intent.putExtra("Cart", cart);
                intent.putExtra("Seller", menuListAdapter.getSeller());
                startActivity(intent);
            }
        }
    });
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) NavigationView(android.support.design.widget.NavigationView) DialogInterface(android.content.DialogInterface) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) ArrayList(java.util.ArrayList) Product(com.example.asus.onlinecanteen.model.Product) Intent(android.content.Intent) NavigationView(android.support.design.widget.NavigationView) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) DrawerLayout(android.support.v4.widget.DrawerLayout) MenuListAdapter(com.example.asus.onlinecanteen.adapter.MenuListAdapter) Cart(com.example.asus.onlinecanteen.model.Cart)

Example 58 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project Awesome-WanAndroid by JsonChao.

the class MainActivity method initEventAndData.

@Override
protected void initEventAndData() {
    initToolbar();
    initData();
    initNavigationView();
    BottomNavigationViewHelper.disableShiftMode(bottomNavigationBar);
    mDataManager.setCurrentPage(Constants.FIRST);
    bottomNavigationBar.setOnNavigationItemSelectedListener(item -> {
        switch(item.getItemId()) {
            case R.id.tab_main_pager:
                mTitleTv.setText(getString(R.string.home_pager));
                switchFragment(0);
                mMainPagerFragment.reLoad();
                mDataManager.setCurrentPage(Constants.FIRST);
                break;
            case R.id.tab_knowledge_hierarchy:
                mTitleTv.setText(getString(R.string.knowledge_hierarchy));
                switchFragment(1);
                mKnowledgeHierarchyFragment.reLoad();
                mDataManager.setCurrentPage(Constants.SECOND);
                break;
            case R.id.tab_navigation:
                switchNavigation();
                break;
            case R.id.tab_project:
                switchProject();
                break;
            default:
                break;
        }
        return true;
    });
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close) {

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            // 获取mDrawerLayout中的第一个子布局,也就是布局中的RelativeLayout
            // 获取抽屉的view
            View mContent = mDrawerLayout.getChildAt(0);
            float scale = 1 - slideOffset;
            float endScale = 0.8f + scale * 0.2f;
            float startScale = 1 - 0.3f * scale;
            // 设置左边菜单滑动后的占据屏幕大小
            drawerView.setScaleX(startScale);
            drawerView.setScaleY(startScale);
            // 设置菜单透明度
            drawerView.setAlpha(0.6f + 0.4f * (1 - scale));
            // 设置内容界面水平和垂直方向偏转量
            // 在滑动时内容界面的宽度为 屏幕宽度减去菜单界面所占宽度
            mContent.setTranslationX(drawerView.getMeasuredWidth() * (1 - scale));
            // 设置内容界面操作无效(比如有button就会点击无效)
            mContent.invalidate();
            // 设置右边菜单滑动后的占据屏幕大小
            mContent.setScaleX(endScale);
            mContent.setScaleY(endScale);
        }
    };
    toggle.syncState();
    mDrawerLayout.addDrawerListener(toggle);
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) NavigationView(android.support.design.widget.NavigationView) BindView(butterknife.BindView) View(android.view.View) BottomNavigationView(android.support.design.widget.BottomNavigationView) TextView(android.widget.TextView)

Example 59 with ActionBarDrawerToggle

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

the class OpenHABMainActivity method setupDrawer.

private void setupDrawer() {
    mDrawerLayout = findViewById(R.id.drawer_layout);
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close);
    mDrawerLayout.addDrawerListener(mDrawerToggle);
    mDrawerLayout.addDrawerListener(new DrawerLayout.SimpleDrawerListener() {

        @Override
        public void onDrawerOpened(View drawerView) {
            if (mInitState == InitState.DONE) {
                loadSitemapList(false);
            }
        }
    });
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    NavigationView drawerMenu = findViewById(R.id.left_drawer);
    drawerMenu.inflateMenu(R.menu.left_drawer);
    mDrawerMenu = drawerMenu.getMenu();
    // We only want to tint the menu icons, but not our loaded sitemap icons. NavigationView
    // unfortunately doesn't support this directly, so we tint the icon drawables manually
    // instead of letting NavigationView do it.
    mDrawerIconTintList = drawerMenu.getItemIconTintList();
    drawerMenu.setItemIconTintList(null);
    for (int i = 0; i < mDrawerMenu.size(); i++) {
        MenuItem item = mDrawerMenu.getItem(i);
        item.setIcon(applyDrawerIconTint(item.getIcon()));
    }
    drawerMenu.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            mDrawerLayout.closeDrawers();
            switch(item.getItemId()) {
                case R.id.notifications:
                    openNotifications();
                    return true;
                case R.id.settings:
                    Intent settingsIntent = new Intent(OpenHABMainActivity.this, OpenHABPreferencesActivity.class);
                    startActivityForResult(settingsIntent, SETTINGS_REQUEST_CODE);
                    return true;
                case R.id.about:
                    openAbout();
                    return true;
            }
            if (item.getGroupId() == GROUP_ID_SITEMAPS) {
                OpenHABSitemap sitemap = mSitemapList.get(item.getItemId());
                openSitemap(sitemap);
                return true;
            }
            return false;
        }
    });
}
Also used : NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) MenuItem(android.view.MenuItem) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) RecognizerIntent(android.speech.RecognizerIntent) DrawerLayout(android.support.v4.widget.DrawerLayout) RecyclerView(android.support.v7.widget.RecyclerView) NavigationView(android.support.design.widget.NavigationView) View(android.view.View) OpenHABSitemap(org.openhab.habdroid.model.OpenHABSitemap)

Example 60 with ActionBarDrawerToggle

use of android.support.v7.app.ActionBarDrawerToggle in project EC2018App by Manan-YMCA.

the class ContentActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.navbar_content);
    cotainer_root_frame = (RelativeLayout) findViewById(R.id.content_frame);
    // 
    dotsLayout = (LinearLayout) findViewById(R.id.layoutDots);
    drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(ContentActivity.this, drawer, null, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();
    mProgress = new ProgressDialog(ContentActivity.this);
    mProgress.setMessage("I am working");
    mProgress.setTitle("yes i am");
    mProgress.setCanceledOnTouchOutside(false);
    nav_view = (NavigationView) findViewById(R.id.nav_view);
    pdfTextView = (TextView) findViewById(R.id.tv_pdf);
    nav_view.setNavigationItemSelectedListener((NavigationView.OnNavigationItemSelectedListener) this);
    nav_view.setCheckedItem(R.id.nav_home);
    userTickets = new ArrayList<QRTicketModel>();
    databaseController = new DatabaseController(ContentActivity.this);
    mIncomingHandler = new IncomingHandler(ContentActivity.this);
    categoriesHeadingTextView = findViewById(R.id.text_viewcategories);
    viewPager = (ViewPager) findViewById(R.id.slliderview_pager);
    myViewPagerAdapter = new DashboardSlideAdapter(getSupportFragmentManager());
    viewPager.setAdapter(myViewPagerAdapter);
    viewPager.addOnPageChangeListener(viewPagerPageChangeListener);
    ImageView img = findViewById(R.id.drawerTogglebtn);
    img.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (!drawer.isDrawerOpen(GravityCompat.START)) {
                drawer.openDrawer(GravityCompat.START);
            }
        }
    });
    pdfTextView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // missing 'http://' will cause crashed
            Uri uri = Uri.parse("http://www.elementsculmyca.com/schedule");
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
        }
    });
    addBottomDots(0);
    addData();
    RecyclerView categoryRecycleview = (RecyclerView) findViewById(R.id.category_recycler_view);
    categoryRecycleview.setHasFixedSize(true);
    DashboardCategoryScrollerAdapter adapter = new DashboardCategoryScrollerAdapter(ContentActivity.this, allSampleData);
    categoryRecycleview.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
    categoryRecycleview.setAdapter(adapter);
}
Also used : NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) DashboardCategoryScrollerAdapter(com.manan.dev.ec2018app.Adapters.DashboardCategoryScrollerAdapter) DatabaseController(com.manan.dev.ec2018app.DatabaseHandler.DatabaseController) Intent(android.content.Intent) ProgressDialog(android.app.ProgressDialog) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) NavigationView(android.support.design.widget.NavigationView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) Uri(android.net.Uri) QRTicketModel(com.manan.dev.ec2018app.Models.QRTicketModel) DashboardSlideAdapter(com.manan.dev.ec2018app.Adapters.DashboardSlideAdapter) RecyclerView(android.support.v7.widget.RecyclerView) ImageView(android.widget.ImageView)

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