Example #1
0
 @Override
 public void run() {
   mSystemUiHider.hide();
 }
Example #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_direction);

    // region fullscreen setups
    final View controlsView = findViewById(R.id.fullscreen_content_controls);
    final View contentView = findViewById(R.id.fullscreen_content);

    // Set up an instance of SystemUiHider to control the system UI for
    // this activity.
    mSystemUiHider = SystemUiHider.getInstance(this, contentView, HIDER_FLAGS);
    mSystemUiHider.setup();
    mSystemUiHider.setOnVisibilityChangeListener(
        new SystemUiHider.OnVisibilityChangeListener() {
          // Cached values.
          int mControlsHeight;
          int mShortAnimTime;

          @Override
          @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
          public void onVisibilityChange(boolean visible) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
              // If the ViewPropertyAnimator API is available
              // (Honeycomb MR2 and later), use it to animate the
              // in-layout UI controls at the bottom of the
              // screen.
              if (mControlsHeight == 0) {
                mControlsHeight = controlsView.getHeight();
              }
              if (mShortAnimTime == 0) {
                mShortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);
              }
              controlsView
                  .animate()
                  .translationY(visible ? 0 : mControlsHeight)
                  .setDuration(mShortAnimTime);
            } else {
              // If the ViewPropertyAnimator APIs aren't
              // available, simply show or hide the in-layout UI
              // controls.
              controlsView.setVisibility(visible ? View.VISIBLE : View.GONE);
            }

            if (visible && AUTO_HIDE) {
              // Schedule a hide().
              delayedHide(AUTO_HIDE_DELAY_MILLIS);
            }
          }
        });

    // Set up the user interaction to manually show or hide the system UI.
    contentView.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            if (TOGGLE_ON_CLICK) {
              mSystemUiHider.toggle();
            } else {
              mSystemUiHider.show();
            }
          }
        });

    // Upon interacting with UI controls, delay any scheduled hide()
    // operations to prevent the jarring behavior of controls going away
    // while interacting with the UI.
    findViewById(R.id.dummy_button).setOnTouchListener(mDelayHideTouchListener);

    // endregion

    // region init sliding layout
    getPrefs();
    bindViews();
    initState();
    // endregion

    // initMap();

    // region init architectView
    this.architectView = (ArchitectView) this.findViewById(R.id.architectView);
    final ArchitectConfig config = new ArchitectConfig(Constants.WIKITUDE_SDK_KEY);
    this.architectView.onCreate(config);
    this.sensorAccuracyListener =
        new SensorAccuracyChangeListener() {
          @Override
          public void onCompassAccuracyChanged(int accuracy) {
            /* UNRELIABLE = 0, LOW = 1, MEDIUM = 2, Height = 3 */
            if (accuracy < SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM
                && DirectionActivity.this != null
                && !DirectionActivity.this.isFinishing()) {
              Toast.makeText(
                      DirectionActivity.this, R.string.compass_accuracy_low, Toast.LENGTH_LONG)
                  .show();
            }
          }
        };
    this.locationListener =
        new LocationListener() {

          @Override
          public void onStatusChanged(String provider, int status, Bundle extras) {}

          @Override
          public void onProviderEnabled(String provider) {}

          @Override
          public void onProviderDisabled(String provider) {}

          @Override
          public void onLocationChanged(final Location location) {
            if (location != null) {
              DirectionActivity.this.lastKnownLocaton = location;
              if (DirectionActivity.this.architectView != null) {
                if (location.hasAltitude()) {
                  DirectionActivity.this.architectView.setLocation(
                      location.getLatitude(),
                      location.getLongitude(),
                      location.getAltitude(),
                      location.hasAccuracy() ? location.getAccuracy() : 1000);
                } else {
                  DirectionActivity.this.architectView.setLocation(
                      location.getLatitude(),
                      location.getLongitude(),
                      location.hasAccuracy() ? location.getAccuracy() : 1000);
                }
              }
            }
          }
        };

    this.architectView.registerSensorAccuracyChangeListener(this.sensorAccuracyListener);
    this.locationProvider = new LocationProvider(this, this.locationListener);
    // endregion

    // region init search locations
    initMarkerPoints();
    // endregion

    // region init map components
    initMap();
    // Setting onclick event listener for the map
    map.setOnMapClickListener(
        new OnMapClickListener() {
          @Override
          public void onMapClick(LatLng point) {
            Log.i("LatLng Info", "Lat: " + point.latitude + "; Lng: " + point.longitude);
            /*

            // Already two locations
            if(markerPoints.size()>1){
            	markerPoints.clear();
            	map.clear();
            }

            // Adding new item to the ArrayList
            markerPoints.add(point);

            // Draws Start and Stop markers on the Google Map
            drawStartEndMarkers();

            // Checks, whether start and end locations are captured
            if(markerPoints.size() >= 2){
            	LatLng origin = markerPoints.get(0);
            	LatLng dest = markerPoints.get(1);

            	// Getting URL to the Google Directions API
            	String url = getDirectionsUrl(origin, dest);

            	DownloadTask downloadTask = new DownloadTask();

            	// Start downloading json data from Google Directions API
            	downloadTask.execute(url);
            }
             */
          }
        });
    // endregion

  }