use of com.alexstyl.specialdates.facebook.UserCredentials in project Memento-Calendar by alexstyl.
the class FacebookFriendsIntentService method onHandleIntent.
@Override
protected void onHandleIntent(@Nullable Intent intent) {
FacebookCalendarLoader calendarLoader = new FacebookCalendarLoader();
FacebookContactFactory factory = new FacebookContactFactory(parser);
ContactEventSerialiser serialiser = new ContactEventSerialiser(factory, tracker);
FacebookBirthdaysProvider calendarFetcher = new FacebookBirthdaysProvider(calendarLoader, serialiser);
UserCredentials userCredentials = facebookUserSettings.retrieveCredentials();
if (isAnnonymous(userCredentials)) {
tracker.track(new RuntimeException("Tried to fetch events, but was anonymous"));
return;
}
CalendarURLCreator calendarURLCreator = new CalendarURLCreator(tracker);
URL calendarUrl = calendarURLCreator.createFrom(userCredentials);
FacebookFriendsPersister persister = new FacebookFriendsPersister(new AndroidPeopleEventsPersister(new EventSQLiteOpenHelper(this), marshaller, tracker));
try {
List<ContactEvent> friends = calendarFetcher.fetchCalendarFrom(calendarUrl);
persister.keepOnly(friends);
uiRefresher.refreshViews();
} catch (CalendarFetcherException e) {
tracker.track(e);
}
if (BuildConfig.DEBUG) {
notifyServiceRan();
}
}
use of com.alexstyl.specialdates.facebook.UserCredentials in project Memento-Calendar by alexstyl.
the class FacebookLogInActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AppComponent applicationModule = ((MementoApplication) getApplication()).getApplicationModule();
applicationModule.inject(this);
analytics.trackScreen(Screen.FACEBOOK_LOG_IN);
setContentView(R.layout.activity_facebook_log_in);
Toolbar toolbar = Views.findById(this, R.id.memento_toolbar);
setSupportActionBar(toolbar);
avatar = Views.findById(this, R.id.facebook_import_avatar);
helloView = Views.findById(this, R.id.facebook_import_hello);
moreText = Views.findById(this, R.id.facebook_import_description);
progress = Views.findById(this, R.id.progress);
shareButton = Views.findById(this, R.id.facebook_import_share);
shareButton.setOnClickListener(shareAppIntentOnClick());
closeButton = Views.findById(this, R.id.facebook_import_close);
closeButton.setOnClickListener(onCloseButtonPressed());
webView = Views.findById(this, R.id.facebook_import_webview);
orientationLock = new ScreenOrientationLock();
facebookFriendsScheduler = new FacebookFriendsScheduler(thisActivity(), (AlarmManager) getSystemService(ALARM_SERVICE));
webView.setCallback(facebookCallback);
UserCredentials userCredentials = facebookUserSettings.retrieveCredentials();
if (savedInstanceState == null || userCredentials.equals(UserCredentials.ANNONYMOUS)) {
new CookieResetter(CookieManager.getInstance()).clearAll();
webView.loadLogInPage();
} else {
showData(userCredentials);
}
}
Aggregations