Search in sources :

Example 61 with NavigationView

use of android.support.design.widget.NavigationView in project aplicativo by InCasa.

the class HomeActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    exibeTelaPrincipalOuSolicitaLogin();
    setContentView(R.layout.activity_home);
    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.setDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    SharedPreferences mSharedPreferences = getSharedPreferences("ServerAdress", 0);
    this.ip = mSharedPreferences.getString("servidor", " ");
    String URLTEMPERATURA = "http://" + ip + "/backend/temperaturaValor";
    String URLUMIDADE = "http://" + ip + "/backend/umidadeValor";
    getTemperatura(URLTEMPERATURA);
    getUmidade(URLUMIDADE);
    String URLGETTEMPERATURA = "http://" + ip + "/backend/temperatura/1";
    String URLGETUMIDADE = "http://" + ip + "/backend/umidade/1";
    String URLGETPRESENCA = "http://" + ip + "/backend/presenca/1";
    String URLGETLUMINOSISADE = "http://" + ip + "/backend/luminosidade/1";
    getSensorTemperatura(URLGETTEMPERATURA);
    getSensorUmidade(URLGETUMIDADE);
    getSensorPresenca(URLGETPRESENCA);
    getSensorLuminosidade(URLGETLUMINOSISADE);
    String URLGETARDUINO = "http://" + ip + "/backend/arduino/1";
    getArduino(URLGETARDUINO);
    String URLGETCELULAR = "http://" + ip + "/backend/aplicativo/1";
    getCelular(URLGETCELULAR);
    JSONObject jsonBody = new JSONObject();
    User user = User.getInstancia();
    try {
        jsonBody.put("login", user.getLogin());
        jsonBody.put("senha", user.getSenha());
    } catch (JSONException e) {
        e.printStackTrace();
    }
    String URLUSER = "http://" + ip + "/backend/getUser";
    getUser(jsonBody, URLUSER);
    String URLGETRELE1 = "http://" + ip + "/backend/rele/1";
    String URLGETRELE2 = "http://" + ip + "/backend/rele/2";
    String URLGETRELE3 = "http://" + ip + "/backend/rele/3";
    String URLGETRELE4 = "http://" + ip + "/backend/rele/4";
    getRele1(URLGETRELE1);
    getRele2(URLGETRELE2);
    getRele3(URLGETRELE3);
    getRele4(URLGETRELE4);
}
Also used : NavigationView(android.support.design.widget.NavigationView) User(model.User) JSONObject(org.json.JSONObject) SharedPreferences(android.content.SharedPreferences) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) JSONException(org.json.JSONException) DrawerLayout(android.support.v4.widget.DrawerLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 62 with NavigationView

use of android.support.design.widget.NavigationView in project coins-android by bubelov.

the class MapActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    dependencies().inject(this);
    setContentView(R.layout.activity_map);
    ButterKnife.bind(this);
    drawerHeader = navigationView.getHeaderView(0);
    avatar = ButterKnife.findById(drawerHeader, R.id.avatar);
    userName = ButterKnife.findById(drawerHeader, R.id.user_name);
    googleApiClient = new GoogleApiClient.Builder(this).addApi(LocationServices.API).addApi(Auth.GOOGLE_SIGN_IN_API).addConnectionCallbacks(new LocationApiConnectionCallbacks()).enableAutoManage(this, connectionResult -> Toast.makeText(MapActivity.this, connectionResult.getErrorMessage(), Toast.LENGTH_SHORT).show()).build();
    googleApiClient.connect();
    firstLaunch = savedInstanceState == null;
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
    bottomSheetBehavior = BottomSheetBehavior.from(placeDetails);
    bottomSheetBehavior.setState(BottomSheetBehavior.STATE_HIDDEN);
    bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {

        @Override
        public void onStateChanged(@NonNull View bottomSheet, int newState) {
            placeDetails.setFullScreen(newState == BottomSheetBehavior.STATE_EXPANDED);
        }

        @Override
        public void onSlide(@NonNull View bottomSheet, float slideOffset) {
            actionButton.setVisibility(slideOffset > 0.5f ? View.GONE : View.VISIBLE);
        }
    });
    new Handler(Looper.getMainLooper()).postDelayed(() -> bottomSheetBehavior.setPeekHeight(placeDetails.getHeaderHeight()), 1000);
    placeDetails.setCallback(new PlaceDetailsView.Callback() {

        @Override
        public void onEditPlaceClick(@NonNull Place place) {
            if (!TextUtils.isEmpty(userRepository.getUserAuthToken())) {
                EditPlaceActivity.Companion.startForResult(MapActivity.this, place.getId(), null, REQUEST_EDIT_PLACE);
            } else {
                signIn();
            }
        }

        @Override
        public void onDismissed() {
            bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
        }
    });
    toolbar.setNavigationOnClickListener(v -> drawerLayout.openDrawer(navigationView));
    toolbar.inflateMenu(R.menu.map);
    toolbar.setOnMenuItemClickListener(this);
    navigationView.setNavigationItemSelectedListener(item -> {
        switch(item.getItemId()) {
            case R.id.action_exchange_rates:
                drawerLayout.closeDrawers();
                openExchangeRatesScreen();
                return true;
            case R.id.action_notification_area:
                drawerLayout.closeDrawers();
                openNotificationAreaScreen();
                return true;
            case R.id.action_chat:
                drawerLayout.closeDrawers();
                openChat();
                return true;
            case R.id.action_settings:
                drawerLayout.closeDrawers();
                openSettingsScreen();
                return true;
        }
        return false;
    });
    drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.open, R.string.close);
    drawerLayout.addDrawerListener(drawerToggle);
    updateDrawerHeader();
}
Also used : ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) Handler(android.os.Handler) NavigationView(android.support.design.widget.NavigationView) ImageView(android.widget.ImageView) BindView(butterknife.BindView) PlaceDetailsView(com.bubelov.coins.ui.widget.PlaceDetailsView) View(android.view.View) TextView(android.widget.TextView) SupportMapFragment(com.google.android.gms.maps.SupportMapFragment) BottomSheetBehavior(android.support.design.widget.BottomSheetBehavior) PlaceDetailsView(com.bubelov.coins.ui.widget.PlaceDetailsView) Place(com.bubelov.coins.model.Place)

Example 63 with NavigationView

use of android.support.design.widget.NavigationView in project MadMax by deviz92.

the class BasicActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_basic);
    View navHeader;
    mainView = (FrameLayout) findViewById(R.id.main);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    // get the item shown in the navigation drawer
    // drawerOptions = getResources().getStringArray(R.array.drawerItem);
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    navigationView = (NavigationView) findViewById(R.id.nav_view);
    fab = (FloatingActionButton) findViewById(R.id.fab);
    // Navigation view header
    navHeader = navigationView.getHeaderView(0);
    navHeader.setBackgroundColor(Color.BLUE);
    navHeader.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent intent = new Intent(BasicActivity.this, ProfileEdit.class);
            BasicActivity.this.startActivity(intent);
        }
    });
    txtName = (TextView) navHeader.findViewById(R.id.name);
    txtWebsite = (TextView) navHeader.findViewById(R.id.website);
    imgProfile = (ImageView) navHeader.findViewById(R.id.img_profile);
    // initializing navigation menu
    setUpNavigationView();
}
Also used : ProfileEdit(com.polito.mad17.madmax.activities.users.ProfileEdit) Intent(android.content.Intent) NavigationView(android.support.design.widget.NavigationView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 64 with NavigationView

use of android.support.design.widget.NavigationView in project Varis-Android by dkhmelenko.

the class MainActivity method updateMenuState.

@Override
public void updateMenuState(@Nullable String accessToken) {
    NavigationView view = (NavigationView) findViewById(R.id.navigation_view);
    Menu menu = view.getMenu();
    if (TextUtils.isEmpty(accessToken)) {
        menu.findItem(R.id.drawer_login).setVisible(true);
        menu.findItem(R.id.drawer_logout).setVisible(false);
    } else {
        menu.findItem(R.id.drawer_login).setVisible(false);
        menu.findItem(R.id.drawer_logout).setVisible(true);
    }
}
Also used : NavigationView(android.support.design.widget.NavigationView) Menu(android.view.Menu)

Example 65 with NavigationView

use of android.support.design.widget.NavigationView in project Varis-Android by dkhmelenko.

the class MainActivity method updateUserData.

@Override
public void updateUserData(User user) {
    final NavigationView view = (NavigationView) findViewById(R.id.navigation_view);
    View header = view.getHeaderView(0);
    TextView usernameView = (TextView) header.findViewById(R.id.drawer_header_username);
    TextView emailView = (TextView) header.findViewById(R.id.drawer_header_email);
    if (user != null) {
        String username = user.getLogin();
        if (!TextUtils.isEmpty(user.getName())) {
            username = String.format("%1$s (%2$s)", user.getName(), user.getLogin());
        }
        usernameView.setText(username);
        emailView.setText(user.getEmail());
    // TODO Update image, when service will provide it
    } else {
        usernameView.setText(R.string.navigation_drawer_username_placeholder);
        emailView.setText(R.string.navigation_drawer_email_placeholder);
    }
}
Also used : NavigationView(android.support.design.widget.NavigationView) TextView(android.widget.TextView) NavigationView(android.support.design.widget.NavigationView) SearchView(android.support.v7.widget.SearchView) RepositoriesView(com.khmelenko.lab.varis.view.RepositoriesView) View(android.view.View) TextView(android.widget.TextView)

Aggregations

NavigationView (android.support.design.widget.NavigationView)70 View (android.view.View)42 Toolbar (android.support.v7.widget.Toolbar)25 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)24 TextView (android.widget.TextView)21 DrawerLayout (android.support.v4.widget.DrawerLayout)17 ImageView (android.widget.ImageView)16 UiController (android.support.test.espresso.UiController)13 ViewAction (android.support.test.espresso.ViewAction)13 Menu (android.view.Menu)10 ActionBar (android.support.v7.app.ActionBar)8 Intent (android.content.Intent)7 FloatingActionButton (android.support.design.widget.FloatingActionButton)7 MenuItem (android.view.MenuItem)7 Handler (android.os.Handler)6 SearchView (android.support.v7.widget.SearchView)6 BindView (butterknife.BindView)6 FlexboxLayout (com.google.android.flexbox.FlexboxLayout)6 TabLayout (android.support.design.widget.TabLayout)5 FlakyTest (android.support.test.filters.FlakyTest)5