Search in sources :

Example 11 with SupportMapFragment

use of com.google.android.gms.maps.SupportMapFragment in project Remindy by abicelis.

the class PlaceActivity method onConnected.

/**
     * Builds the map when the Google Play services client is successfully connected.
     */
@Override
public void onConnected(Bundle connectionHint) {
    // Get the SupportMapFragment and request notification
    // when the map is ready to be used.
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.activity_place_map);
    mapFragment.getMapAsync(this);
}
Also used : SupportMapFragment(com.google.android.gms.maps.SupportMapFragment)

Example 12 with SupportMapFragment

use of com.google.android.gms.maps.SupportMapFragment 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)

Aggregations

SupportMapFragment (com.google.android.gms.maps.SupportMapFragment)12 View (android.view.View)3 LatLng (com.google.android.gms.maps.model.LatLng)3 TextView (android.widget.TextView)2 Activity (android.app.Activity)1 Intent (android.content.Intent)1 Handler (android.os.Handler)1 Nullable (android.support.annotation.Nullable)1 BottomSheetBehavior (android.support.design.widget.BottomSheetBehavior)1 NavigationView (android.support.design.widget.NavigationView)1 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)1 Toolbar (android.support.v7.widget.Toolbar)1 Window (android.view.Window)1 ImageView (android.widget.ImageView)1 BindView (butterknife.BindView)1 Place (com.bubelov.coins.model.Place)1 PlaceDetailsView (com.bubelov.coins.ui.widget.PlaceDetailsView)1 AdListener (com.google.android.gms.ads.AdListener)1 AdRequest (com.google.android.gms.ads.AdRequest)1 InterstitialAd (com.google.android.gms.ads.InterstitialAd)1