use of com.facebook.UiLifecycleHelper in project phonegap-facebook-plugin by Wizcorp.
the class ConnectPlugin method initialize.
@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
// Initialize UiLifecycleHelper
uiHelper = new UiLifecycleHelper(cordova.getActivity(), null);
// Init logger
logger = AppEventsLogger.newLogger(cordova.getActivity());
int appResId = cordova.getActivity().getResources().getIdentifier("fb_app_id", "string", cordova.getActivity().getPackageName());
applicationId = cordova.getActivity().getString(appResId);
// Set up the activity result callback to this class
cordova.setActivityResultCallback(this);
// Open a session if we have one cached
Session session = new Session.Builder(cordova.getActivity()).setApplicationId(applicationId).build();
if (session.getState() == SessionState.CREATED_TOKEN_LOADED) {
Session.setActiveSession(session);
// - Create the request
Session.OpenRequest openRequest = new Session.OpenRequest(cordova.getActivity());
// - Set the status change call back
openRequest.setCallback(new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state, Exception exception) {
onSessionStateChange(state, exception);
}
});
session.openForRead(openRequest);
}
// If we have a valid open session, get user's info
if (checkActiveSession(session)) {
// Call this method to initialize the session state info
onSessionStateChange(session.getState(), null);
}
super.initialize(cordova, webView);
}
use of com.facebook.UiLifecycleHelper in project Klyph by jonathangerbaud.
the class TitledViewPagerActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
setTheme(getCustomTheme());
KlyphLocale.defineLocale(getBaseContext());
KlyphDevice.initDeviceValues(this, true);
super.onCreate(savedInstanceState);
currentTheme = getCustomTheme();
currentLocale = KlyphLocale.getDeviceLocale();
uiHelper = new UiLifecycleHelper(this, callback);
uiHelper.onCreate(savedInstanceState);
userHasDonated = KlyphPreferences.hasUserDonated();
KlyphDevice.initDeviceValues(this);
setAppIconBackToHomeEnabled(true);
displayBackArrow(true);
getViewPager().setOffscreenPageLimit(3);
setLoadingView(findViewById(R.id.progressBar));
if (!KlyphSession.isLogged()) {
logout();
} else if (Session.getActiveSession() == null) {
Session.openActiveSessionFromCache(this);
}
if (getIntent().getBooleanExtra(KlyphBundleExtras.SET_NOTIFICATION_AS_READ, false) == true) {
String id = getIntent().getStringExtra(KlyphBundleExtras.NOTIFICATION_ID);
if (id != null && id.length() > 0) {
new AsyncRequest(Query.POST_READ_NOTIFICATION, id, "", null).execute();
}
}
}
use of com.facebook.UiLifecycleHelper in project Klyph by jonathangerbaud.
the class TitledFragmentActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
setTheme(getCustomTheme());
KlyphLocale.defineLocale(getBaseContext());
super.onCreate(savedInstanceState);
currentTheme = getCustomTheme();
currentLocale = KlyphLocale.getDeviceLocale();
uiHelper = new UiLifecycleHelper(this, callback);
uiHelper.onCreate(savedInstanceState);
KlyphDevice.initDeviceValues(this);
userHasDonated = KlyphPreferences.hasUserDonated();
if (!(this instanceof MainActivity)) {
setAppIconBackToHomeEnabled(true);
displayBackArrow(true);
} else {
setAppIconBackToHomeEnabled(false);
}
if (!KlyphSession.isLogged()) {
if (!(this instanceof MainActivity))
logout();
} else if (Session.getActiveSession() == null) {
Session.openActiveSessionFromCache(this);
}
if (getIntent().getBooleanExtra(KlyphBundleExtras.SET_NOTIFICATION_AS_READ, false) == true) {
String id = getIntent().getStringExtra(KlyphBundleExtras.NOTIFICATION_ID);
if (id != null && id.length() > 0) {
new AsyncRequest(Query.POST_READ_NOTIFICATION, id, "", null).execute();
}
}
}
use of com.facebook.UiLifecycleHelper in project Klyph by jonathangerbaud.
the class LoginFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
uiHelper = new UiLifecycleHelper(getActivity(), callback);
uiHelper.onCreate(savedInstanceState);
}
use of com.facebook.UiLifecycleHelper in project Klyph by jonathangerbaud.
the class PreferencesActivity method onCreate.
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(KlyphPreferences.getPreferencesTheme());
KlyphLocale.defineLocale(getBaseContext());
super.onCreate(savedInstanceState);
uiHelper = new UiLifecycleHelper(this, callback);
uiHelper.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
final Preference p = findPreference(KlyphPreferences.PREFERENCE_IMAGE_CLEAR_CACHE);
p.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
p.setEnabled(false);
Toast.makeText(PreferencesActivity.this, R.string.preference_images_cache_clearing, Toast.LENGTH_SHORT).show();
new ClearCacheTask().execute();
return true;
}
});
setNotificationsIntervalEnabled();
refreshRingtoneSummary();
refreshInterval();
refreshAppLanguage();
refreshFbLanguage();
previousRingtone = KlyphPreferences.getNotificationRingtone();
Preference aboutPref = findPreference(ABOUT_KEY);
Preference changelogPref = findPreference(CHANGELOG_KEY);
aboutPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent intent = new Intent(PreferencesActivity.this, AboutActivity.class);
startActivity(intent);
return true;
}
});
changelogPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent intent = new Intent(PreferencesActivity.this, ChangeLogActivity.class);
startActivity(intent);
return true;
}
});
if (KlyphPreferences.arePushNotificationsAvailable() == false) {
Preference notificationSystemPref = findPreference(NOTIFICATIONS_SYSTEM);
notificationSystemPref.setEnabled(false);
notificationSystemPref.setShouldDisableView(true);
}
if (KlyphFlags.IS_PRO_VERSION == true || KlyphFlags.IS_AMAZON_VERSION == true) {
Preference buyProPref = findPreference(BUY_PRO_VERSION_KEY);
buyProPref.setEnabled(false);
buyProPref.setShouldDisableView(true);
}
/*
* Preference p = findPreference(KlyphPreferences.PREFERENCE_IMAGE_SAVE_DIRECTORY);
* p.setSummary("hi/ha/yalala");
*
* p.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
*
* @Override
* public boolean onPreferenceClick(Preference preference)
* {
* Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
* intent.setType("folder://");
* intent.addCategory(Intent.CATEGORY_OPENABLE);
*
* try {
* startActivityForResult(
* Intent.createChooser(intent, "Select a File to Upload"),
* 12);
* } catch (android.content.ActivityNotFoundException ex) {
* // Potentially direct the user to the Market with a Dialog
* Toast.makeText(PreferencesActivity.this, "Please install a File Manager.",
* Toast.LENGTH_SHORT).show();
* }
* return false;
* }
* });
*/
}
Aggregations