Android Open Source - taxitwin-app Taxi Twin Application






From Project

Back to project page taxitwin-app.

License

The source code is released under:

GNU General Public License

If you think the Android project taxitwin-app listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package kimle.michal.android.taxitwin.application;
//from  w ww  . j a v a 2 s  .com
import android.app.Application;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import kimle.michal.android.taxitwin.db.DbHelper;
import kimle.michal.android.taxitwin.enumerate.UserState;
import static kimle.michal.android.taxitwin.enumerate.UserState.NOT_SUBSCRIBED;
import kimle.michal.android.taxitwin.gcm.GcmHandler;
import kimle.michal.android.taxitwin.services.ServicesManagement;

public class TaxiTwinApplication extends Application {

    private static int pendingNotificationsCount = 0;
    private static UserState userState = NOT_SUBSCRIBED;
    private ServicesManagement servicesManagement;
    private LocationListener locationListener;

    @Override
    public void onCreate() {
        super.onCreate();
    }

    public void unregister() {
        LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        locationManager.removeUpdates(locationListener);
    }

    public void register() {
        servicesManagement = new ServicesManagement(this);
        locationListener = new LocationListener() {
            public void onLocationChanged(Location location) {
                locationUpdate(location);
            }

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

            public void onProviderEnabled(String provider) {
                LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
                locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 3, this);
            }

            public void onProviderDisabled(String provider) {
            }
        };
        //every 10 seconds and at least 3 meters
        LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 3, locationListener);
    }

    private void locationUpdate(Location location) {
        GcmHandler gcmHandler = new GcmHandler(this);
        gcmHandler.locationChanged(location);
    }

    public static int getPendingNotificationsCount() {
        return pendingNotificationsCount;
    }

    public static void setPendingNotificationsCount(int pendingNotifications) {
        pendingNotificationsCount = pendingNotifications;
    }

    public static UserState getUserState() {
        return userState;
    }

    public static void setUserState(UserState userState) {
        TaxiTwinApplication.userState = userState;
    }

    public static void exit(Context context) {
        GcmHandler gcmHandler = new GcmHandler(context);
        if (userState == UserState.OWNER || userState == UserState.PARTICIPANT) {
            gcmHandler.leaveTaxiTwin();
        }
        gcmHandler.unsubscribe();

        TaxiTwinApplication app = (TaxiTwinApplication) context.getApplicationContext();
        app.unregister();

        DbHelper dbHelper = new DbHelper(context);
        dbHelper.deleteTables(dbHelper.getWritableDatabase());
        android.os.Process.killProcess(android.os.Process.myPid());
    }
}




Java Source Code List

kimle.michal.android.taxitwin.activity.LauncherActivity.java
kimle.michal.android.taxitwin.activity.MainActivity.java
kimle.michal.android.taxitwin.activity.MyTaxiTwinActivity.java
kimle.michal.android.taxitwin.activity.OfferDetailActivity.java
kimle.michal.android.taxitwin.activity.ResponseDetailActivity.java
kimle.michal.android.taxitwin.activity.ResponsesActivity.java
kimle.michal.android.taxitwin.adapter.TaxiTwinPlacesAutoCompleteAdapter.java
kimle.michal.android.taxitwin.application.TaxiTwinApplication.java
kimle.michal.android.taxitwin.contentprovider.TaxiTwinContentProvider.java
kimle.michal.android.taxitwin.db.DbContract.java
kimle.michal.android.taxitwin.db.DbHelper.java
kimle.michal.android.taxitwin.dialog.alert.AddressAlertDialogFragment.java
kimle.michal.android.taxitwin.dialog.alert.GPSAlertDialogFragment.java
kimle.michal.android.taxitwin.dialog.alert.GooglePlayServicesAlertDialogFragment.java
kimle.michal.android.taxitwin.dialog.alert.InternetAlertDialogFragment.java
kimle.michal.android.taxitwin.dialog.alert.LeaveTaxiTwinAlertDialogFragment.java
kimle.michal.android.taxitwin.dialog.alert.ServicesAlertDialogFragment.java
kimle.michal.android.taxitwin.dialog.alert.TaxiTwinAlertDialogFragment.java
kimle.michal.android.taxitwin.dialog.alert.TaxiTwinNoLongerAlertDialogFragment.java
kimle.michal.android.taxitwin.dialog.error.GooglePlayServicesErrorDialogFragment.java
kimle.michal.android.taxitwin.dialog.error.OfferErrorDialogFragment.java
kimle.michal.android.taxitwin.dialog.error.PlaceErrorDialogFragment.java
kimle.michal.android.taxitwin.dialog.error.ResponseErrorDialogFragment.java
kimle.michal.android.taxitwin.entity.Place.java
kimle.michal.android.taxitwin.enumerate.UserState.java
kimle.michal.android.taxitwin.fragment.TaxiTwinListFragment.java
kimle.michal.android.taxitwin.fragment.TaxiTwinMapFragment.java
kimle.michal.android.taxitwin.gcm.GcmBroadcastReceiver.java
kimle.michal.android.taxitwin.gcm.GcmConnector.java
kimle.michal.android.taxitwin.gcm.GcmHandler.java
kimle.michal.android.taxitwin.gcm.GcmIntentService.java
kimle.michal.android.taxitwin.popup.SettingsPopup.java
kimle.michal.android.taxitwin.services.ServicesManagement.java
kimle.michal.android.taxitwin.view.TaxiTwinAutoCompleteTextView.java