Search in sources :

Example 1 with YourApplication

use of org.michenux.yourappidea.YourApplication in project YourAppIdea by Michenux.

the class AroundMeFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ((YourApplication) getActivity().getApplication()).inject(this);
    setRetainInstance(true);
    setHasOptionsMenu(true);
    mGoogleApiClient = new GoogleApiClient.Builder(this.getActivity()).addApi(LocationServices.API).addConnectionCallbacks(this).addOnConnectionFailedListener(this).build();
    mRequest = LocationRequest.create().setInterval(15000).setFastestInterval(5000).setSmallestDisplacement(50).setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
    mGeocoder = new Geocoder(this.getActivity(), Locale.getDefault());
    mPlaceListAdapter = new PlaceRecyclerAdapter(new ArrayList<Place>());
    if (savedInstanceState != null) {
        this.mUseLocationClient = savedInstanceState.getBoolean("useLocationClient", true);
        this.mCityName = savedInstanceState.getString("cityName");
        this.mCurrentLocation = savedInstanceState.getParcelable("currentLocation");
        this.mLocalProvider = savedInstanceState.getBoolean("localProvider", true);
    }
    if (this.mLocalProvider) {
        mPlaceProvider = new PlaceLocalProvider(this, this);
    } else {
        mPlaceProvider = new PlaceRemoteProvider(this, this);
    }
}
Also used : YourApplication(org.michenux.yourappidea.YourApplication) GoogleApiClient(com.google.android.gms.common.api.GoogleApiClient) ArrayList(java.util.ArrayList) Geocoder(android.location.Geocoder)

Example 2 with YourApplication

use of org.michenux.yourappidea.YourApplication in project YourAppIdea by Michenux.

the class TutorialSyncAdapter method onPerformSync.

@Override
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) {
    ((YourApplication) getContext().getApplicationContext()).setSyncAdapterRunning(true);
    LocalBroadcastManager.getInstance(this.getContext()).sendBroadcast(new Intent(SYNC_STARTED));
    try {
        boolean manualSync = extras.getBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, false);
        WPJsonPost newPost = retrievePosts(AppUsageUtils.getLastSync(this.getContext()), provider);
        if (BuildConfig.DEBUG) {
            Log.d(YourApplication.LOG_TAG, "tutorialSyncAdapter.onPerformSync() - manual:" + manualSync);
        }
        if (newPost != null) {
            // notification only if not manual sync
            if (!manualSync) {
                sendNotification(newPost);
            }
        } else {
            if (BuildConfig.DEBUG) {
                Log.d(YourApplication.LOG_TAG, "  no new post");
            }
        }
        if (!manualSync) {
            mSyncHelper.adjustSyncInterval(TutorialSyncAdapter.this.getContext());
        }
        AppUsageUtils.updateLastSync(TutorialSyncAdapter.this.getContext());
    } catch (ParseException e) {
        Log.e(YourApplication.LOG_TAG, "tutorialSyncAdapter.onPerformSync()", e);
        syncResult.stats.numParseExceptions++;
    } catch (InterruptedException | ExecutionException | RemoteException | OperationApplicationException e) {
        Log.e(YourApplication.LOG_TAG, "tutorialSyncAdapter.onPerformSync()", e);
        syncResult.stats.numIoExceptions++;
    } finally {
        LocalBroadcastManager.getInstance(this.getContext()).sendBroadcast(new Intent(SYNC_FINISHED));
        ((YourApplication) getContext().getApplicationContext()).setSyncAdapterRunning(false);
    }
}
Also used : YourApplication(org.michenux.yourappidea.YourApplication) WPJsonPost(org.michenux.drodrolib.wordpress.json.WPJsonPost) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) ParseException(java.text.ParseException) ExecutionException(java.util.concurrent.ExecutionException) RemoteException(android.os.RemoteException) OperationApplicationException(android.content.OperationApplicationException)

Example 3 with YourApplication

use of org.michenux.yourappidea.YourApplication in project YourAppIdea by Michenux.

the class SettingsFragment method onCreatePreferences.

@Override
public void onCreatePreferences(Bundle bundle, String rootKey) {
    ((YourApplication) getActivity().getApplication()).inject(this);
    addPreferencesFromResource(R.xml.preferences);
    PreferenceManager preferenceManager = getPreferenceManager();
    preferenceManager.getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
}
Also used : YourApplication(org.michenux.yourappidea.YourApplication) PreferenceManager(android.support.v7.preference.PreferenceManager)

Example 4 with YourApplication

use of org.michenux.yourappidea.YourApplication in project YourAppIdea by Michenux.

the class YourAppMainActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ((YourApplication) getApplication()).inject(this);
    setContentView(R.layout.main);
    // toolbar
    Toolbar toolBar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolBar);
    // For debug
    if (BuildConfig.DEBUG) {
        Log.d(YourApplication.LOG_TAG, "HashKey: " + SecurityUtils.logHashKey(this));
    }
    // app usage
    AppUsageUtils.updateLastUsedTimestamp(this);
    // init fragment
    if (savedInstanceState == null) {
        this.navController.goHomeFragment(this);
        this.navController.showWhatsNew(this);
    }
    // ads
    mAdView = (AdView) findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).addTestDevice("1174B15820BDCDE357023377AAF1D72D").addTestDevice("FB73634EFAFEF29BE7973A97B5543A4D").addTestDevice(//LG Nexus 5
    "3C4438D5DE2E7086B63C92FC5846F662").build();
    mAdView.loadAd(adRequest);
    // social networks
    mFacebookDelegate = new FacebookDelegate(mUserHelper, this);
    mFacebookDelegate.setUserSessionCallback(this);
    mGoogleAuthDelegate = new GoogleAuthDelegate(this, mUserHelper);
    mGoogleAuthDelegate.setUserSessionCallback(this);
}
Also used : YourApplication(org.michenux.yourappidea.YourApplication) AdRequest(com.google.android.gms.ads.AdRequest) FacebookDelegate(org.michenux.yourappidea.facebook.FacebookDelegate) GoogleAuthDelegate(org.michenux.drodrolib.gms.auth.GoogleAuthDelegate) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

YourApplication (org.michenux.yourappidea.YourApplication)4 PendingIntent (android.app.PendingIntent)1 Intent (android.content.Intent)1 OperationApplicationException (android.content.OperationApplicationException)1 Geocoder (android.location.Geocoder)1 RemoteException (android.os.RemoteException)1 PreferenceManager (android.support.v7.preference.PreferenceManager)1 Toolbar (android.support.v7.widget.Toolbar)1 AdRequest (com.google.android.gms.ads.AdRequest)1 GoogleApiClient (com.google.android.gms.common.api.GoogleApiClient)1 ParseException (java.text.ParseException)1 ArrayList (java.util.ArrayList)1 ExecutionException (java.util.concurrent.ExecutionException)1 GoogleAuthDelegate (org.michenux.drodrolib.gms.auth.GoogleAuthDelegate)1 WPJsonPost (org.michenux.drodrolib.wordpress.json.WPJsonPost)1 FacebookDelegate (org.michenux.yourappidea.facebook.FacebookDelegate)1