Search in sources :

Example 1 with IKlyphFragment

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);
        }
    }
}
Also used : IKlyphFragment(com.abewy.android.apps.klyph.fragment.IKlyphFragment) FragmentTransaction(android.app.FragmentTransaction) PackageManager(android.content.pm.PackageManager) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) Bundle(android.os.Bundle) Intent(android.content.Intent) LoginFragment(com.abewy.android.apps.klyph.fragment.LoginFragment) Fragment(android.app.Fragment) IKlyphFragment(com.abewy.android.apps.klyph.fragment.IKlyphFragment)

Example 2 with IKlyphFragment

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;
}
Also used : IKlyphFragment(com.abewy.android.apps.klyph.fragment.IKlyphFragment) ImageView(android.widget.ImageView) View(android.view.View) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) TextPaint(android.text.TextPaint)

Aggregations

IKlyphFragment (com.abewy.android.apps.klyph.fragment.IKlyphFragment)2 Fragment (android.app.Fragment)1 FragmentTransaction (android.app.FragmentTransaction)1 Intent (android.content.Intent)1 PackageManager (android.content.pm.PackageManager)1 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)1 Bundle (android.os.Bundle)1 TextPaint (android.text.TextPaint)1 View (android.view.View)1 AbsListView (android.widget.AbsListView)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 LoginFragment (com.abewy.android.apps.klyph.fragment.LoginFragment)1