use of com.abewy.android.apps.klyph.fragment.IKlyphFragment in project Klyph by jonathangerbaud.
the class MainActivity method updateContent.
private void updateContent(int selection) {
if (selection != oldSelection) {
Bundle bundle = new Bundle();
bundle.putString(KlyphBundleExtras.ELEMENT_ID, KlyphSession.getSessionUserId());
String className = classes.get(selection);
if (className.equals("com.abewy.android.apps.klyph.fragment.Chat")) {
PackageManager pm = getPackageManager();
try {
pm.getPackageInfo(MESSENGER_PACKAGE_NAME, PackageManager.GET_ACTIVITIES);
Intent intent = getPackageManager().getLaunchIntentForPackage(MESSENGER_PACKAGE_NAME);
startActivity(intent);
} catch (NameNotFoundException e) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(MESSENGER_PLAY_STORE_URI));
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
startActivity(intent);
}
} else {
if (selection < navAdapter.getCount())
setTitle(navAdapter.getItem(selection));
else
setTitle(KlyphSession.getSessionUserName());
Fragment fragment = Fragment.instantiate(MainActivity.this, className, bundle);
if (previousFragment != null)
previousFragment.onSetToBack(this);
FragmentTransaction tx = getFragmentManager().beginTransaction();
tx.replace(R.id.main, fragment, FRAGMENT_TAG);
tx.commitAllowingStateLoss();
((IKlyphFragment) fragment).onSetToFront(this);
previousFragment = (IKlyphFragment) fragment;
navAdapter.setSelectedPosition(selection);
navAdapter.notifyDataSetChanged();
oldSelection = selection;
if (notificationsFragment != null)
notificationsFragment.setHasOptionsMenu(false);
}
}
}
use of com.abewy.android.apps.klyph.fragment.IKlyphFragment in project Klyph by jonathangerbaud.
the class ProfileActivity method getScrollY.
public int getScrollY() {
IKlyphFragment f = (IKlyphFragment) ((FragmentPagerAdapter) getPagerAdapter()).getItem(getViewPager().getCurrentItem());
if (f == null || f.getListView() == null)
return 0;
listPadding = f.getListView().getPaddingTop();
View c = f.getListView().getChildAt(0);
if (c == null) {
return 0;
}
int firstVisiblePosition = f.getListView().getFirstVisiblePosition();
int top = c.getTop();
int headerHeight = 0;
if (firstVisiblePosition >= 1) {
headerHeight = fakeHeaderHeight;
}
// Log.d("UserActivity", "getScrollY: " + top + " " + headerHeight);
return -top + firstVisiblePosition * c.getHeight() + headerHeight + listPadding;
}
Aggregations