Search in sources :

Example 21 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project MaterialIntroView by iammert.

the class ToolbarMenuItemActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_toolbar);
    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    //User toolbar to access the views
    ImageView ivSearch = (ImageView) toolbar.findViewById(R.id.ivToolbarSearch);
    mIvShare = (ImageView) toolbar.findViewById(R.id.ivToolbarShare);
    mIvAbout = (ImageView) toolbar.findViewById(R.id.ivToolbarAbout);
    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);
    //show the intro view
    showIntro(ivSearch, MENU_SEARCH_ID_TAG, getString(R.string.guide_setup_profile), FocusGravity.CENTER);
}
Also used : NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) ImageView(android.widget.ImageView) DrawerLayout(android.support.v4.widget.DrawerLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 22 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project MaterialIntroView by iammert.

the class ToolbarMenuItemActivity method onNavigationItemSelected.

@Override
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    switch(item.getItemId()) {
        case R.id.nav_demo:
            getSupportFragmentManager().beginTransaction().replace(R.id.container, new MainFragment()).commit();
            break;
        case R.id.nav_gravity:
            getSupportFragmentManager().beginTransaction().replace(R.id.container, new GravityFragment()).commit();
            break;
        case R.id.nav_focus:
            getSupportFragmentManager().beginTransaction().replace(R.id.container, new FocusFragment()).commit();
            break;
        case R.id.nav_recyclerview:
            getSupportFragmentManager().beginTransaction().replace(R.id.container, new RecyclerviewFragment()).commit();
            break;
        case R.id.nav_toolbar:
            startActivity(new Intent(getApplicationContext(), ToolbarMenuItemActivity.class));
            break;
        case R.id.nav_tab:
            break;
        default:
            break;
    }
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}
Also used : MainFragment(co.mobiwise.sample.fragment.MainFragment) RecyclerviewFragment(co.mobiwise.sample.fragment.RecyclerviewFragment) Intent(android.content.Intent) DrawerLayout(android.support.v4.widget.DrawerLayout) GravityFragment(co.mobiwise.sample.fragment.GravityFragment) FocusFragment(co.mobiwise.sample.fragment.FocusFragment)

Example 23 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project FadingActionBar by ManuelPeinado.

the class NavigationDrawerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_navigation_drawer);
    mTitle = mDrawerTitle = getTitle();
    mCityNames = getResources().getStringArray(R.array.drawer_items);
    TypedArray typedArray = getResources().obtainTypedArray(R.array.city_images);
    mCityImages = new int[typedArray.length()];
    for (int i = 0; i < typedArray.length(); ++i) {
        mCityImages[i] = typedArray.getResourceId(i, 0);
    }
    typedArray.recycle();
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) findViewById(R.id.left_drawer);
    // 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
    mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, mCityNames));
    mDrawerList.setOnItemClickListener(this);
    // enable ActionBar app icon to behave as action to toggle nav drawer
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);
    // ActionBarDrawerToggle ties together the the proper interactions
    // between the sliding drawer and the action bar app icon
    mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
    mDrawerLayout, /* DrawerLayout object */
    R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
    R.string.drawer_open, /* "open drawer" description for accessibility */
    R.string.drawer_close) {

        /* "close drawer" description for accessibility */
        public void onDrawerClosed(View view) {
            getActionBar().setTitle(mTitle);
        }

        public void onDrawerOpened(View drawerView) {
            getActionBar().setTitle(mDrawerTitle);
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    if (savedInstanceState == null) {
        selectItem(0);
    }
}
Also used : TypedArray(android.content.res.TypedArray) ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Example 24 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project storymaker by StoryMaker.

the class BaseActivity method setupDrawerLayout.

public void setupDrawerLayout() {
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerContainer = (ViewGroup) findViewById(R.id.left_drawer);
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer_white, R.string.open_drawer, R.string.close_drawer) {

        /** Called when a drawer has settled in a completely closed state. */
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            // creates call to onPrepareOptionsMenu()
            invalidateOptionsMenu();
            mDrawerOpen = false;
        }

        /** Called when a drawer has settled in a completely open state. */
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            // creates call to onPrepareOptionsMenu()
            invalidateOptionsMenu();
            mDrawerOpen = true;
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    final Activity activity = this;
    RelativeLayout llDrawerLogin = (RelativeLayout) findViewById(R.id.llLogin);
    ImageButton btnDrawerQuickCaptureVideo = (ImageButton) findViewById(R.id.btnDrawerQuickCaptureVideo);
    ImageButton btnDrawerQuickCapturePhoto = (ImageButton) findViewById(R.id.btnDrawerQuickCapturePhoto);
    ImageButton btnDrawerQuickCaptureAudio = (ImageButton) findViewById(R.id.btnDrawerQuickCaptureAudio);
    Button btnDrawerHome = (Button) findViewById(R.id.btnDrawerHome);
    Button btnDrawerCatalog = (Button) findViewById(R.id.btnDrawerCatalog);
    //        Button btnDrawerProjects =      (Button) findViewById(R.id.btnDrawerProjects);
    //Button btnDrawerAccount = (Button) findViewById(R.id.btnDrawerAccount);
    Button btnDrawerAccounts = (Button) findViewById(R.id.btnDrawerAccounts);
    Button btnDrawerExports = (Button) findViewById(R.id.btnDrawerExports);
    Button btnDrawerUploadManager = (Button) findViewById(R.id.btnDrawerUploadManager);
    Button btnDrawerSettings = (Button) findViewById(R.id.btnDrawerSettings);
    Button btnDrawerFeedback = (Button) findViewById(R.id.btnDrawerFeedback);
    TextView textViewVersion = (TextView) findViewById(R.id.textViewVersion);
    // NEW/CACHEWORD
    Button btnDrawerLock = (Button) findViewById(R.id.btnDrawerLock);
    // disable button if the user has set a pin
    SharedPreferences sp = getSharedPreferences("appPrefs", MODE_PRIVATE);
    String cachewordStatus = sp.getString("cacheword_status", "default");
    if (cachewordStatus.equals(CACHEWORD_SET)) {
        Timber.d("pin set, so remove button");
        btnDrawerLock.setVisibility(View.GONE);
    } else {
        Timber.d("no pin set, so show button");
    }
    String pkg = getPackageName();
    try {
        String versionName = getPackageManager().getPackageInfo(pkg, 0).versionName;
        int versionCode = getPackageManager().getPackageInfo(pkg, 0).versionCode;
        textViewVersion.setText("v" + versionName + " build " + versionCode);
    } catch (PackageManager.NameNotFoundException e) {
        Timber.e(e, "NameNotFoundException?");
    }
    updateSlidingMenuWithUserState();
    // Set a random profile background
    ImageView imageViewProfileBg = (ImageView) findViewById(R.id.imageViewProfileBg);
    int profileBg = (int) (Math.random() * 2);
    switch(profileBg) {
        case 0:
            imageViewProfileBg.setImageResource(R.drawable.profile_bg1);
            break;
        case 1:
            imageViewProfileBg.setImageResource(R.drawable.profile_bg2);
            break;
        case 2:
            imageViewProfileBg.setImageResource(R.drawable.profile_bg3);
            break;
    }
    llDrawerLogin.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mDrawerLayout.closeDrawers();
            Intent i = new Intent(activity, ConnectAccountActivity.class);
            activity.startActivity(i);
        }
    });
    btnDrawerHome.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mDrawerLayout.closeDrawers();
            Intent i = new Intent(activity, HomeActivity.class);
            activity.startActivity(i);
        }
    });
    btnDrawerCatalog.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mDrawerLayout.closeDrawers();
            Intent i = new Intent(activity, CatalogActivity.class);
            activity.startActivity(i);
        }
    });
    btnDrawerExports.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mDrawerLayout.closeDrawers();
            Intent i = new Intent(activity, ProjectsActivity.class);
            activity.startActivity(i);
        }
    });
    btnDrawerAccounts.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mDrawerLayout.closeDrawers();
            Intent i = new Intent(activity, AccountsActivity.class);
            activity.startActivity(i);
        }
    });
    btnDrawerUploadManager.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mDrawerLayout.closeDrawers();
            Toast.makeText(getApplicationContext(), "Not yet implemented", Toast.LENGTH_LONG).show();
        //                Intent i = new Intent(activity, AccountsActivity.class);
        //                activity.startActivity(i);
        }
    });
    btnDrawerSettings.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mDrawerLayout.closeDrawers();
            Intent i = new Intent(activity, SimplePreferences.class);
            activity.startActivity(i);
        }
    });
    btnDrawerFeedback.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mDrawerLayout.closeDrawers();
            FeedbackManager.register(activity, AppConstants.HOCKEY_APP_ID, null);
            FeedbackManager.showFeedbackActivity(activity);
        }
    });
    // NEW/CACHEWORD
    btnDrawerLock.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // if there has been no first lock, set status so user will be prompted to create a pin
            SharedPreferences sp = getSharedPreferences("appPrefs", MODE_PRIVATE);
            String cachewordStatus = sp.getString("cacheword_status", "default");
            if (cachewordStatus.equals(CACHEWORD_UNSET)) {
                // set flag so user will be prompted to create a pin
                setPin = true;
                Timber.d("set cacheword first lock flag");
            }
            mCacheWordHandler.lock();
        }
    });
}
Also used : SharedPreferences(android.content.SharedPreferences) ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) FragmentActivity(android.support.v4.app.FragmentActivity) Activity(android.app.Activity) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ImageButton(android.widget.ImageButton) PackageManager(android.content.pm.PackageManager) ImageButton(android.widget.ImageButton) Button(android.widget.Button) RelativeLayout(android.widget.RelativeLayout) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) ImageView(android.widget.ImageView)

Example 25 with DrawerLayout

use of android.support.v4.widget.DrawerLayout in project AnimeTaste by daimajia.

the class StartActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mContext = this;
    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
    mVideoList = (ListView) findViewById(R.id.videoList);
    mDrawerList = (ListView) findViewById(R.id.function_list);
    mDrawer = (LinearLayout) findViewById(R.id.drawer);
    mLayoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mCategoryList = (ListView) findViewById(R.id.category_list);
    mFooterView = mLayoutInflater.inflate(R.layout.load_item, null);
    mLoadProgress = (ProgressBar) mFooterView.findViewById(R.id.loading);
    mLoadText = (TextView) mFooterView.findViewById(R.id.load_text);
    mVideoList.addFooterView(mFooterView);
    mVideoList.setOnScrollListener(this);
    mDrawer.setOnTouchListener(this);
    View headerView = mLayoutInflater.inflate(R.layout.gallery_item, null, false);
    mVideoList.addHeaderView(headerView);
    mRecommendPager = (ViewPager) headerView.findViewById(R.id.pager);
    mRecommendPager.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            PointF downP = new PointF();
            PointF curP = new PointF();
            int act = event.getAction();
            if (act == MotionEvent.ACTION_DOWN || act == MotionEvent.ACTION_MOVE || act == MotionEvent.ACTION_UP) {
                ((ViewGroup) v).requestDisallowInterceptTouchEvent(true);
                if (downP.x == curP.x && downP.y == curP.y) {
                    return false;
                }
            }
            return false;
        }
    });
    mRecommendIndicator = (UnderlinePageIndicator) headerView.findViewById(R.id.indicator);
    if (getIntent().hasExtra("Success")) {
        init(getIntent());
    } else {
        Toast.makeText(mContext, R.string.init_failed, Toast.LENGTH_SHORT).show();
        finish();
    }
    mDrawerAapter = new SimpleAdapter(this, getDrawerItems(), R.layout.drawer_item, new String[] { "img", "title" }, new int[] { R.id.item_icon, R.id.item_name });
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_action_navigation_menu, R.string.app_name, R.string.app_name) {

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            if (mPreviousType != mType || mPreviousCategoryId != mCategoryId) {
                mCurrentPage = 1;
                mIsEnd = false;
                mVideoAdapter.removeAllData();
                mFooterView.findViewById(R.id.loading).setVisibility(View.VISIBLE);
                mFooterView.findViewById(R.id.load_text).setVisibility(View.INVISIBLE);
                triggerApiConnector();
            }
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            mPreviousType = mType;
            mPreviousCategoryId = mCategoryId;
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    mDrawerList.setAdapter(mDrawerAapter);
    mDrawerList.setOnItemClickListener(this);
    ViewUtils.setListViewHeightBasedOnChildren(mDrawerList);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayUseLogoEnabled(true);
    getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP);
    getSupportActionBar().setLogo(R.drawable.rsz_ab_icon);
    rateForUsOrCheckUpdate();
    showWhatsNew();
}
Also used : OnTouchListener(android.view.View.OnTouchListener) PointF(android.graphics.PointF) ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) SimpleAdapter(android.widget.SimpleAdapter) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) AbsListView(android.widget.AbsListView) MotionEvent(android.view.MotionEvent)

Aggregations

DrawerLayout (android.support.v4.widget.DrawerLayout)63 View (android.view.View)59 ActionBarDrawerToggle (android.support.v4.app.ActionBarDrawerToggle)33 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)22 AdapterView (android.widget.AdapterView)22 NavigationView (android.support.design.widget.NavigationView)21 ListView (android.widget.ListView)21 Intent (android.content.Intent)19 Toolbar (android.support.v7.widget.Toolbar)19 TextView (android.widget.TextView)15 ImageView (android.widget.ImageView)12 ActionBar (android.support.v7.app.ActionBar)9 SharedPreferences (android.content.SharedPreferences)8 FloatingActionButton (android.support.design.widget.FloatingActionButton)7 ViewPager (android.support.v4.view.ViewPager)6 SuppressLint (android.annotation.SuppressLint)5 TabLayout (android.support.design.widget.TabLayout)5 ArrayList (java.util.ArrayList)5 ActionBar (android.app.ActionBar)4 TypedArray (android.content.res.TypedArray)4