Скачать книгу

android.support.v7.app.AlertDialog;

      import android.view.LayoutInflater;

      import android.view.View;

      import android.support.design.widget.NavigationView;

      import android.support.v4.view.GravityCompat;

      import android.support. v4.widget. DrawerLayout;

      import android.support.v7.app.ActionBarDrawerToggle;

      import android.support. v7.app. AppCompatActivity;

      import android.support.v7.widget.Toolbar;

      import android.view.MenuItem;

      import android.Manifest;

      import android.content.Context;

      import android.content.SharedPreferences;

      import android.content.pm.PackageManager;

      import android.hardware.Sensor;

      import android.hardware.SensorEvent;

      import android.hardware.SensorManager;

      import android. location. Location;

      import android.support.annotation.NonNull;

      import android.support.annotation.Nullable;

      import android.support.v4.app.ActivityCompat;

      import android.view.ViewGroup;

      import android.view.ViewTreeObserver;

      import android.widget.ProgressBar;

      import android. widget. RadioButton;

      import android. widget. RadioGroup;

      import android.widget.Toast;

      import com.beyondar.android.fragment.BeyondarFragmentSupport;

      import com.beyondar.android.plugin. radar. RadarView;

      import com.beyondar.android.plugin. radar. RadarWorldPlugin;

      import com.beyondar.android.sensor.BeyondarSensorListener;

      import com.beyondar.android.sensor.BeyondarSensorManager;

      import com.beyondar.android. world. World;

      import com.beyondar.android. opengl. util. LowPassFilter;

      import com.google.android.gms.common.ConnectionResult;

      import com.google.android.gms.common. api. GoogleApiClient;

      import com.google.android.gms. location. LocationListener;

      import com.google.android.gms. location. LocationRequest;

      import com.google.android.gms. location. LocationServices;

      import org. json. JSONArray;

      import org. json. JSONObject;

      import java.util.Iterator;

      import java.util.LinkedHashSet;

      import java.util.Set;

      public class MainActivity extends AppCompatActivity

      implements NavigationView. OnNavigationItemSelectedListener, BeyondarSensorListener, LocationListener, GoogleApiClient.ConnectionCallbacks, GoogleApiClient. OnConnectionFailedListener {

      private BeyondarFragmentSupport mBeyondarFragment;

      private World mWorld;

      private RadarView mRadarView;

      private RadarWorldPlugin mRadarPlugin;

      private Location mCurrentLocation;

      private Context context;

      GoogleApiClient mGoogleApiClient;

      LocationRequest mLocationRequest;

      private float [] mLastAccelerometer = new float [3];

      private float [] mLastMagnetometer = new float [3];

      private float [] mR = new float [9];

      private float [] mOrientation = new float [3];

      private static boolean flagLocationUpdate=true;

      private static SharedPreferences mSettings;

      private Set <String> boLat=new LinkedHashSet ();

      private Set <String> boLon=new LinkedHashSet ();

      private static ProgressBar spinner;

      @Override

      protected void onCreate (Bundle savedInstanceState) {

      super. onCreate (savedInstanceState);

      setContentView(R.layout.activity_main);

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

      setSupportActionBar (toolbar);

      spinner = (ProgressBar)findViewById(R.id.progressBar);

      spinner.setVisibility (View. GONE);

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

      final NestedScrollView nestedScrollView = (NestedScrollView)findViewById(R.id.content_main);

      nestedScrollView.getViewTreeObserver().addOnGlobalLayoutListener (

      new ViewTreeObserver. OnGlobalLayoutListener () {

      @Override

      public void onGlobalLayout () {

      int height = nestedScrollView.getHeight ();

      int width = nestedScrollView.getWidth ();

      if (height> width) height=width;

      if (width> height) width=height;

      ViewGroup.LayoutParams params = nestedScrollView.getLayoutParams ();

      params. width=width;

      params. height=height;

      nestedScrollView.setLayoutParams (params);

      nestedScrollView.getViewTreeObserver().removeGlobalOnLayoutListener (this);

      }

      });

      context = this;

      mSettings = getSharedPreferences («APP_PREFERENCES», Context.MODE_PRIVATE);

      if (!mSettings.contains («BOLAT»)) {

      SharedPreferences. Editor editor = mSettings. edit ();

      editor. putStringSet («BOLAT», boLat);

      editor.commit ();

      }

      if(!mSettings.contains («BOLON»)) {

      SharedPreferences. Editor editor = mSettings. edit ();

      editor. putStringSet («BOLON», boLon);

      editor.commit ();

      }

      if(!mSettings.contains («CREATURES»)) {

      JSONArray creatures = new JSONArray ();

      SharedPreferences. Editor editor = mSettings. edit ();

      editor.putString("CREATURES",creatures.toString ());

      editor.commit ();

      }

      if(!mSettings.contains

Скачать книгу