Java Code Examples for android.support.v4.widget.DrawerLayout#addDrawerListener()

The following examples show how to use android.support.v4.widget.DrawerLayout#addDrawerListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java    From ClipPathLayout with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    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 navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    mContainer = findViewById(R.id.fragment_container);
    RandomTransitionPathGenerator generator =
            new RandomTransitionPathGenerator(new CirclePathGenerator());
    generator.add(new OvalPathGenerator());
    generator.add(new RhombusPathGenerator());
    mTransitionAdapter = new TransitionAdapter(generator);
    mTransitionAdapter.setImmediately(true);
    mContainer.setAdapter(mTransitionAdapter);
    switchFragment(new ScrollTransitionFragment(), false);
}
 
Example 2
Source File: BaseActivity.java    From good-weather with GNU General Public License v3.0 6 votes vote down vote up
private void setupNavDrawer() {
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    if (mDrawerLayout == null) {
        return;
    }
    mDrawerToggle = new ActionBarDrawerToggle(this,
                                              mDrawerLayout,
                                              mToolbar,
                                              R.string.navigation_drawer_open,
                                              R.string.navigation_drawer_close);
    mDrawerLayout.addDrawerListener(mDrawerToggle);
    mDrawerToggle.syncState();

    if (mToolbar != null) {
        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mDrawerLayout.openDrawer(GravityCompat.START);
            }
        });
    }

    configureNavView();
}
 
Example 3
Source File: MainActivity.java    From XKik with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main); // main activity
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); // 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 navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    getSupportFragmentManager().beginTransaction().replace(R.id.contentframe, new main_fragment()).commit();

    Settings.verifyStoragePermissions(this); // make sure we can access settings


    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this)
            .build();
    ImageLoader.getInstance().init(config);
}
 
Example 4
Source File: BaseActivity.java    From privacy-friendly-weather with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if(getSupportActionBar() == null) {
        setSupportActionBar(toolbar);
    }

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

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

    selectNavigationItem(getNavigationDrawerID());

    View mainContent = findViewById(R.id.main_content);
    if (mainContent != null) {
        mainContent.setAlpha(0);
        mainContent.animate().alpha(1).setDuration(MAIN_CONTENT_FADEIN_DURATION);
    }
}
 
Example 5
Source File: BaseActivity.java    From privacy-friendly-pedometer with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (getSupportActionBar() == null) {
        setSupportActionBar(toolbar);
    }

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

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

    selectNavigationItem(getNavigationDrawerID());

    View mainContent = findViewById(R.id.main_content);
    if (mainContent != null) {
        mainContent.setAlpha(0);
        mainContent.animate().alpha(1).setDuration(MAIN_CONTENT_FADEIN_DURATION);
    }
}
 
Example 6
Source File: BaseActivity.java    From privacy-friendly-torchlight with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if(getSupportActionBar() == null) {
        setSupportActionBar(toolbar);
    }

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

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

    //selectNavigationItem(getNavigationDrawerID());

    View mainContent = findViewById(R.id.main_content);
    if (mainContent != null) {
        mainContent.setAlpha(0);
        mainContent.animate().alpha(1).setDuration(MAIN_CONTENT_FADEIN_DURATION);
    }
}
 
Example 7
Source File: BaseActivity.java    From your-local-weather with GNU General Public License v3.0 6 votes vote down vote up
private void setupNavDrawer() {
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    if (mDrawerLayout == null) {
        return;
    }
    mDrawerToggle = new ActionBarDrawerToggle(this,
                                              mDrawerLayout,
                                              mToolbar,
                                              R.string.navigation_drawer_open,
                                              R.string.navigation_drawer_close);
    mDrawerLayout.addDrawerListener(mDrawerToggle);
    mDrawerToggle.syncState();

    if (mToolbar != null) {
        mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mDrawerLayout.openDrawer(GravityCompat.START);
            }
        });
    }

    configureNavView();
}
 
Example 8
Source File: AbstractBrowserActivity.java    From SimpleExplorer with GNU General Public License v3.0 6 votes vote down vote up
private void setupDrawer() {
    mDrawer = (ListView) findViewById(R.id.left_drawer);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar,
            R.string.drawer_open, R.string.drawer_close) {
        @Override
        public void onDrawerOpened(View drawerView) {
            supportInvalidateOptionsMenu();
        }

        @Override
        public void onDrawerClosed(View view) {
            supportInvalidateOptionsMenu();
        }
    };

    mDrawerLayout.addDrawerListener(mDrawerToggle);
}
 
Example 9
Source File: MainActivity.java    From android-mvvm with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final Toolbar toolbar = getBinding().toolbar;
    final DrawerLayout drawer = getBinding().drawerLayout;
    setSupportActionBar(toolbar);

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

    final NavigationView navigationView = getBinding().navView;
    final NavHeaderMainBinding headerBinding = NavHeaderMainBinding.bind(navigationView.getHeaderView(0));
    headerBinding.setViewModel(getViewModel());
    headerBinding.executePendingBindings();
    navigationView.setNavigationItemSelectedListener(getNavigator());
}
 
Example 10
Source File: MainActivity.java    From OpenCV-android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mCurrentContent instanceof ImageFragment) {
                ((ImageFragment) mCurrentContent).p();
            }
        }
    });

    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();

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

    mContainer = findViewById(R.id.container);
    nav(FaceFragment.newInstance());
}
 
Example 11
Source File: BaseActivity.java    From privacy-friendly-shopping-list with Apache License 2.0 5 votes vote down vote up
@Override
protected void onPostCreate(Bundle savedInstanceState)
{
    super.onPostCreate(savedInstanceState);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if ( getSupportActionBar() == null )
    {
        setSupportActionBar(toolbar);
    }

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


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

    selectNavigationItem(getNavigationDrawerID());

    View mainContent = findViewById(R.id.main_content);
    if ( mainContent != null )
    {
        mainContent.setAlpha(0);
        mainContent.animate().alpha(1).setDuration(MAIN_CONTENT_FADEIN_DURATION);
    }
}
 
Example 12
Source File: MDMainActivity.java    From AndroidDigIn with Apache License 2.0 5 votes vote down vote up
@Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if(versionCheck())finish();
//        setContentView(R.layout.activity_md_main);
        setContentView(R.layout.activity_md_main_with_parallax);
        mRootDrawer = (DrawerLayout) findViewById(R.id.root_drawer);
        mCoordinar = (CoordinatorLayout) findViewById(R.id.coordinar);
//        mViewpager = (ViewPager) findViewById(R.id.viewpager);
        //设置数据才能执行下面的mTabLayout.setupWithViewPager
//        mViewpager.setAdapter(new FragAdapter(getSupportFragmentManager()));
        mToolbar = (Toolbar) findViewById(R.id.toolbar);
        mToolbar.setTitle("MD Demo from H");
        setSupportActionBar(mToolbar);

        mNaviView = (NavigationView) findViewById(R.id.navView);
        NaviItemListener naviItemListener = new NaviItemListener();
        mNaviView.setNavigationItemSelectedListener(naviItemListener);
        mNaviView.getHeaderView(0).setOnClickListener(naviItemListener);
        mFab = (FloatingActionButton) findViewById(R.id.fab);
        mFab.setOnClickListener(this);

        //当没有使用DrawableLayout的时候可以使用这种方式为按钮修改图标
//        final ActionBar ab = getSupportActionBar();
//        ab.setHomeAsUpIndicator(R.drawable.ic_build);
//        ab.setDisplayHomeAsUpEnabled(true);

        mDrawerToggle = new ActionBarDrawerToggle(this, mRootDrawer, mToolbar,
                R.string.toggle_open, R.string.toggle_close);
//        mRootDrawer.setDrawerListener(mDrawerToggle);
        mRootDrawer.addDrawerListener(mDrawerToggle);
        //设置第二个
        mRootDrawer.addDrawerListener(new DrawerLayoutListener());
        //因为被拖出来的drawer遮住了,所以禁用动画
//        mDrawerToggle.setDrawerSlideAnimationEnabled(false);
        //调用这句才让图标显示出来
        mDrawerToggle.syncState();

        showFragmentByReplace(createFragment(R.id.menu_item_drawer),false);
    }
 
Example 13
Source File: MainActivity.java    From ZhihuDaily with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    setSupportActionBar(toolbar);
    initFragment();
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawer, toolbar,
            R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);
    mDrawer.addDrawerListener(toggle);
    toggle.syncState();
}
 
Example 14
Source File: GeocodeRouteActivity.java    From arcgis-runtime-demos-android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_geocode_route);
  Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);

  // inflate MapView from layout
  mMapView = (MapView) findViewById(R.id.mapView);
  mMapView.getGraphicsOverlays().add(graphicsOverlay);

  // Check permissions required for this app.
  boolean permissionCheck = ContextCompat.checkSelfPermission(GeocodeRouteActivity.this, permission[0]) ==
      PackageManager.PERMISSION_GRANTED;

  if (!permissionCheck) {
    // If permissions are not already granted, request permission from the user.
    ActivityCompat.requestPermissions(GeocodeRouteActivity.this, permission, requestCode);
  } else {
    // if permission was already granted, set up offline map, geocoding and routing functionality
    setupOfflineMap();
  }

  FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
  fab.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
      solveRoute();
    }
  });

  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);
}
 
Example 15
Source File: PlayActivity.java    From firebase-android-client with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    ListView messageHistory;
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_play);
    Toolbar 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.addDrawerListener(toggle);
    toggle.syncState();

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

    GoogleSignInOptions.Builder gsoBuilder =
            new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                    .requestIdToken(getString(R.string.default_web_client_id))
                    .requestEmail();

    GoogleSignInOptions gso = gsoBuilder.build();
    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this, this)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();

    SignInButton signInButton = findViewById(R.id.sign_in_button);
    signInButton.setSize(SignInButton.SIZE_STANDARD);
    signInButton.setOnClickListener(this);
    channelLabel = findViewById(R.id.channelLabel);
    Button signOutButton = findViewById(R.id.sign_out_button);
    signOutButton.setOnClickListener(this);

    ImageButton microphoneButton = findViewById(R.id.microphone_button);
    microphoneButton.setOnClickListener(this);

    messages = new ArrayList<>();
    messageAdapter = new SimpleAdapter(this, messages, android.R.layout.simple_list_item_2,
            new String[]{"message", "meta"},
            new int[]{android.R.id.text1, android.R.id.text2});

    messageHistory = findViewById(R.id.messageHistory);
    messageHistory.setOnItemClickListener(this);
    messageHistory.setAdapter(messageAdapter);
    messageText = findViewById(R.id.messageText);
    messageText.setOnKeyListener(this);
    fmt = new SimpleDateFormat("yy.MM.dd HH:mm z", Locale.US);

    status = findViewById(R.id.status);
}
 
Example 16
Source File: MapsActivity.java    From Self-Driving-Car with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);

    // Open an instance of the first camera and retrieve its info.
    mCamera = getCameraInstance(CAMERA_ID);
    Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
    Camera.getCameraInfo(CAMERA_ID, cameraInfo);

    // Get the rotation of the screen to adjust the preview image accordingly.
    final int displayRotation = getWindowManager().getDefaultDisplay()
            .getRotation();

    // Create the Preview view and set it as the content of this Activity.
    mPreview = new CameraPreview(this, mCamera, cameraInfo, displayRotation);


    mStorageRef = FirebaseStorage.getInstance().getReference();
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    positions = new ArrayList();
    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);
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        checkLocationPermission();
    }

    // initialize your android device sensor capabilities
    mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);

    // Obtain the SupportMapFragment and get notified when the map is ready to be used.
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapView = mapFragment.getView();
    mapFragment.getMapAsync(this);


    menuButton = (ImageButton) findViewById(R.id.menu_button);
    menuButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            drawer.openDrawer(GravityCompat.START);
        }
    });


}
 
Example 17
Source File: MainActivity.java    From cashuwallet with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);

    setContentView(R.layout.activity_main);

    Toolbar 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.addDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    navigationView.getMenu().performIdentifierAction(R.id.nav_wallet, 0);

    sync = MainApplication.app().getSync();
    List<Multiwallet> multiwallets = sync.findMultiwallets(0);
    Collections.sort(multiwallets, (Multiwallet m1, Multiwallet m2) -> m1.getCoin().getName().compareTo(m2.getCoin().getName()));
    adapter = new Adapter(multiwallets);

    RecyclerView recyclerView = findViewById(R.id.recycler_view);
    recyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
    recyclerView.addItemDecoration(new DividerItemDecoration(recyclerView.getContext(), DividerItemDecoration.VERTICAL));
    recyclerView.setAdapter(adapter);

    SwipeRefreshLayout swipeRefreshLayout = findViewById(R.id.swipe_refresh_layout);
    swipeRefreshLayout.setOnRefreshListener(() -> {
        if (!MainApplication.app().networkAvailable()) {
            Snackbar.make(recyclerView, R.string.network_not_available, Snackbar.LENGTH_LONG).show();
            swipeRefreshLayout.setRefreshing(false);
            return;
        }
        adapter.refresh();
        swipeRefreshLayout.setRefreshing(false);
    });
    swipeRefreshLayout.post(() -> adapter.refresh());

    if (MainApplication.app().requiresReconnect()) {
        new AlertDialog.Builder(this)
                .setTitle(R.string.new_version_installed)
                .setCancelable(true)
                .setMessage(R.string.info_newcoins_reset)
                .setPositiveButton(R.string.ok, null)
                .show();
    }
}
 
Example 18
Source File: MainActivity.java    From Password-Storage with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Fabric.with(this, new Crashlytics());
    setContentView(R.layout.activity_main);
    passwordDatabase = new PasswordDatabase(getApplicationContext());
    myList = getArray();
    collection = new ArrayList<>();
    accountsList = getAccounts();
    recyclerView = (RecyclerView) findViewById(R.id.listViewID);
    emptyText = (TextView)findViewById(R.id.text2);
    View header = ((NavigationView)findViewById(R.id.nav_view)).getHeaderView(0);
    email = (TextView) header.findViewById(R.id.edt_profile_email);
    profile = (ImageView) header.findViewById(R.id.img_profile_picture);
    email.setText(getIntent().getStringExtra("email"));
    adapter = new PasswordRecyclerViewAdapter(this, accountsList,  this);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(adapter);
    try{profile.setImageBitmap(passwordDatabase.getPic());
        RoundedBitmapDrawable roundedImageDrawable = createRoundedBitmapImageDrawableWithBorder(passwordDatabase.getPic());
        profile.setImageDrawable(roundedImageDrawable);}
    catch(Exception e){flag=0; profile.setImageResource(R.mipmap.ic_launcher_round);}

    profile.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showDialog();

        }
    });

    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) {
            onClickFloatingAdditionButton();
        }
    });

    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);
}
 
Example 19
Source File: MainActivity.java    From ruby-china-android with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar);
    setSupportActionBar(toolbar);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerToggle = new ActionBarDrawerToggle(
            this,
            mDrawerLayout,
            toolbar,
            R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);

    mDrawerLayout.addDrawerListener(mDrawerToggle);

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

    View headerView = mNavigationView.getHeaderView(0);
    mUserAvatarImageView = (SimpleDraweeView) headerView.findViewById(R.id.user_avatar);
    mUserNameTextView = (TextView) headerView.findViewById(R.id.user_name);
    mUserEmailTextView = (TextView) headerView.findViewById(R.id.user_email);

    turbolinksView = (TurbolinksView) findViewById(R.id.turbolinks_view);

    TurbolinksSession.getDefault(this).setDebugLoggingEnabled(true);

    WebSettings webSettings = TurbolinksSession.getDefault(this).getWebView().getSettings();
    webSettings.setUserAgentString("turbolinks-app, ruby-china, official, android");

    location = getString(R.string.root_url) + "/topics";

    TurbolinksSession.getDefault(this)
            .activity(this)
            .adapter(this)
            .view(turbolinksView)
            .visit(location);
}
 
Example 20
Source File: BrowsingActivity.java    From IslamicLibraryAndroid with GNU General Public License v3.0 4 votes vote down vote up
protected void inflateUi(@Nullable Bundle savedInstanceState) {
    setContentView(R.layout.activity_browsing);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    DrawerArrowDrawable drawerArrow = new DrawerArrowDrawable(this);
    drawerArrow.setColor(0xFFFFFF);


    toolbar.setNavigationIcon(drawerArrow);
    ActionBar supportActionBar = getSupportActionBar();
    if (supportActionBar != null) {
        supportActionBar.setDisplayHomeAsUpEnabled(true);
        supportActionBar.setDisplayShowTitleEnabled(false);
    }
    mBooksInformationDbHelper = BooksInformationDbHelper.getInstance(BrowsingActivity.this);
    appBarLayout = findViewById(R.id.appBar);

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

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


    toolbarDownloadOnlySwitch = findViewById(R.id.toolbar_downloaded_only_switch);
    navDownloadedOnlySwitch = (SwitchCompat) navigationView.getMenu().findItem(R.id.nav_item_downloaded_only).getActionView();

    SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE);
    mShouldDisplayDownloadOnly = sharedPref.getBoolean(KEY_DOWNLOADED_ONLY, false);
    setToolbarDownloadOnlySwitchNoCallBack(mShouldDisplayDownloadOnly);
    setDownloadOnlySwitchNoCallBack(mShouldDisplayDownloadOnly);

    toolbarDownloadOnlySwitch.setCheckedChangeListener(v -> switchDownloadOnlyFilter(!shouldDisplayDownloadedOnly()));
    navDownloadedOnlySwitch.setOnCheckedChangeListener((buttonView, isChecked) -> switchDownloadOnlyFilter(isChecked));

    //this is done to prevent motion of drawer when the user tries to slide thes switch
    navDownloadedOnlySwitch.setOnTouchListener((v, event) -> {
        if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
            v.getParent().requestDisallowInterceptTouchEvent(true);
        }
        return false;
    });

    View filterPagerContainer = findViewById(R.id.filter_pager_container);
    bookListContainer = findViewById(R.id.book_list_container);
    View bookInfoContainer = findViewById(R.id.book_info_container);
    FragmentManager fragmentManager = getSupportFragmentManager();


    mPaneNumber = getmumberOfpans(filterPagerContainer, bookInfoContainer);

    @Nullable
    BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);

    int oldPanNumbers = savedInstanceState == null ? 0 : savedInstanceState.getInt(NUMBER_OF_PANS_KEY);

    browsingActivityNavigationController = BrowsingActivityNavigationController.create(
            mPaneNumber,
            oldPanNumbers,
            fragmentManager,
            savedInstanceState != null,
            this,
            bottomNavigationView,
            this);
    if (browsingActivityNavigationController != null) {
        browsingActivityNavigationController.intiializePans();
        if (bottomNavigationView != null) {
            bottomNavigationView.setOnNavigationItemSelectedListener(browsingActivityNavigationController::handleButtomNavigationItem);
        }
    }

    appRateController = new AppRateController(this);

    appRateController
            .monitor()
            .showRateDialogIfMeetsConditions(this);
}