Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.simadanesh.isatis; import android.content.Context; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.support.v4.view.PagerAdapter; import com.simadanesh.datacontract.CityPartition; import com.simadanesh.datacontract.InspectionCode; import com.simadanesh.datacontract.Login; import com.simadanesh.datacontract.LoginResult; import com.simadanesh.datacontract.ManehCode; import com.simadanesh.datacontract.ReadingListDetail; import com.simadanesh.datacontract.ReadingListHeader; import com.simadanesh.datacontract.RegisterField; import java.util.ArrayList; import java.util.Dictionary; import java.util.Hashtable; import java.util.List; /** * * @author 8062439 */ public class CommonPlace implements LocationListener { public static LoginResult currentUser; public static Login currentLogin; public static CityPartition currentCityPartition; public static ReadingListHeader currentReadingList; public static List<ReadingListHeader> currentReadingListHeaders; public static List<ReadingListDetail> currentReadingListDetails; public static MainPage1Fragment currentMainPage1Fragment; public static MainPage2Fragment currentMainPage2Fragment; public static MainPage3Fragment currentMainPage3Fragment; public static FragMapsGoogle currentMapFragment; public static PagerAdapter mainMenuAdapter; public static List<ManehCode> manehCodes; static MainMenuActivity MainMenuActivity; static ScreenSlideActivity slideActivity; static LoginActivity loginActivity; public Location currentLocation; public static String fldStartDate = "1395/01/01"; public static String fldEndDate = "1395/12/29"; public static List<String> fldReadingAllowedTimes = new ArrayList<String>(); public static Dictionary<String, Float> fldManehAllowedPercent = new Hashtable<String, Float>(); public static int fldHighLowOkNumber = 3; public static Boolean fldPreviousDigitShow = false; public static Boolean fldPreviousDateShow = false; public static int fldDayReadingAllowedNumber = 100; public static Boolean fldAllowedCalculate = false; public static Boolean fldAllowedOnlineControl = false; public static List<String> fldManehForcedImage = new ArrayList<String>(); public static int highLowOkNumber = 3; public static float LowFactor = 0.75f; public static float highFactor = 3.2f; public static boolean isOnline = false; public static List<RegisterField> CurrentRegisterFields; public static List<InspectionCode> inspectionCodes; LocationManager locationManager = null; public void StartLocationManager(Context context) { if (locationManager == null) { locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this); locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this); } } private static CommonPlace Instance; public static CommonPlace getInstance() { if (Instance == null) { Instance = new CommonPlace(); } return Instance; } public void onLocationChanged(Location location) { Instance.currentLocation = location; } public void onStatusChanged(String provider, int status, Bundle extras) { //Toast.makeText(this, "", status) } public void onProviderEnabled(String provider) { //Toast.makeText(getContext(), "Gps turned on ", Toast.LENGTH_LONG).show(); } public void onProviderDisabled(String provider) { //Toast.makeText(getContext(), "Gps turned off ", Toast.LENGTH_LONG).show(); } }