Android Open Source - utexas-utilities Blackboard Panes Activity






From Project

Back to project page utexas-utilities.

License

The source code is released under:

Apache License

If you think the Android project utexas-utilities listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.nasageek.utexasutilities.activities;
/*from  ww  w .  j  ava 2  s. co  m*/
import android.content.res.Resources;
import android.os.Bundle;
import android.support.v4.app.Fragment;

import com.actionbarsherlock.app.ActionBar;
import com.mapsaurus.paneslayout.PanesActivity;
import com.mapsaurus.paneslayout.PanesLayout;
import com.mapsaurus.paneslayout.PanesLayout.OnIndexChangedListener;
import com.mapsaurus.paneslayout.PanesSizer.PaneSizer;
import com.nasageek.utexasutilities.R;
import com.nasageek.utexasutilities.fragments.BlackboardAnnouncementsFragment;
import com.nasageek.utexasutilities.fragments.BlackboardCourseMapFragment;
import com.nasageek.utexasutilities.fragments.BlackboardDownloadableItemFragment;
import com.nasageek.utexasutilities.fragments.BlackboardExternalItemFragment;
import com.nasageek.utexasutilities.fragments.BlackboardFragment;
import com.nasageek.utexasutilities.fragments.BlackboardGradesFragment;
import com.nasageek.utexasutilities.fragments.BlackboardPagerFragment;

public class BlackboardPanesActivity extends PanesActivity implements OnIndexChangedListener {
    private ActionBar actionbar;
    private PanesLayout panes;
    private int lastCompleteIndex = 0;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        actionbar = getSupportActionBar();
        actionbar.setTitle("Blackboard");
        actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);

        if (getResources().getBoolean(com.mapsaurus.paneslayout.R.bool.largeScreen)) {
            panes = (PanesLayout) findViewById(R.id.panes);
            panes.setOnIndexChangedListener(this);
        }

        setPaneSizer(new BlackboardPaneSizer());

        // this is a requirement, not sure why, nasty crashes otherwise
        if (savedInstanceState == null) {
            setMenuFragment(BlackboardPagerFragment.newInstance());
            showMenu();
        }

        // addFragment(null, BlackboardPagerFragment.newInstance());
        // addFragment(null,
        // BlackboardCourseListFragment.newInstance("Course List"));

    }

    /*
     * @Override public boolean onOptionsItemSelected(MenuItem item) { if
     * (mDelegate.onOptionsItemSelected(item)) return true; return
     * super.onOptionsItemSelected(item); }
     */

    private class BlackboardPaneSizer implements PaneSizer {
        private static final int UNKNOWN_PANE_TYPE = -1;

        // type is the ID to the integer defining the percentage of the width of
        // the screen that a pane should occupy
        @Override
        public int getWidth(int index, int type, int parentWidth, int parentHeight) {
            Resources res = getResources();

            if (type == UNKNOWN_PANE_TYPE) {
                throw new IllegalStateException("Pane has unknown type");
            } else {
                return (int) (((double) res.getInteger(type)) / 100 * parentWidth);
            }

            /*
             * if (type == BLACKBOARD_PAGER_PANE_TYPE && index == 0) return
             * (int)
             * (((double)res.getInteger(R.integer.blackboard_pager_width_percentage
             * ))/100 * parentWidth); else if (type ==
             * BLACKBOARD_EXTERNAL_ITEM_PANE_TYPE) return (int)
             * (((double)res.getInteger
             * (R.integer.blackboard_external_item_width_percentage))/100 *
             * parentWidth); else if (type == BLACKBOARD_COURSE_MAP_PANE_TYPE)
             * return (int)
             * (((double)res.getInteger(R.integer.blackboard_other_width_percentage
             * ))/100 * parentWidth); else if (type == BLACKBOARD_) else throw
             * new IllegalStateException("Pane has unknown type");
             */

            /*
             * if (parentWidth > parentHeight) { if (type ==
             * BLACKBOARD_PAGER_PANE_TYPE && index == 0) return (int) (0.55 *
             * parentWidth); else if (type ==
             * BLACKBOARD_EXTERNAL_ITEM_PANE_TYPE) return (int) (0.55 *
             * parentWidth); else if (type == BLACKBOARD_OTHER_PANE_TYPE) return
             * (int) (0.45 * parentWidth); else throw new
             * IllegalStateException("Pane has unknown type"); } else { if (type
             * == BLACKBOARD_PAGER_PANE_TYPE && index == 0) return (int) (0.75 *
             * parentWidth); else if (type ==
             * BLACKBOARD_EXTERNAL_ITEM_PANE_TYPE) return (int) (0.75 *
             * parentWidth); else if (type == BLACKBOARD_OTHER_PANE_TYPE) return
             * (int) (0.75 * parentWidth); else throw new
             * IllegalStateException("Pane has unknown type"); }
             */
        }

        @Override
        public int getType(Object o) {
            if (o instanceof BlackboardPagerFragment) {
                return R.integer.blackboard_pager_width_percentage;
            } else if (o instanceof BlackboardExternalItemFragment) {
                return R.integer.blackboard_external_item_width_percentage;
            } else if (o instanceof BlackboardCourseMapFragment) {
                return R.integer.blackboard_course_map_width_percentage;
            } else if (o instanceof BlackboardGradesFragment
                    || o instanceof BlackboardAnnouncementsFragment
                    || o instanceof BlackboardDownloadableItemFragment) {
                return R.integer.blackboard_content_width_percentage;
            } else if (o instanceof BlackboardFragment) {
                return R.integer.blackboard_other_width_percentage;
            } else {
                return UNKNOWN_PANE_TYPE;
            }
        }

        @Override
        public boolean getFocused(Object o) {
            if (o instanceof BlackboardPagerFragment || o instanceof BlackboardExternalItemFragment) {
                return true;
            } else {
                return false;
            }
        }
    }

    // getting slightly strange data at times, look into it
    @Override
    public void onIndexChanged(int firstIndex, int lastIndex, int firstCompleteIndex,
            int lastCompleteIndex) {

        Fragment currentFragment = getFragment(lastCompleteIndex);
        if (lastCompleteIndex != this.lastCompleteIndex) {
            if (currentFragment != null) {
                this.lastCompleteIndex = lastCompleteIndex;
                for (int i = 0; i < panes.getNumPanes(); i++) {
                    if (i == lastCompleteIndex) {
                        getFragment(i).setHasOptionsMenu(true);
                    } else {
                        getFragment(i).setHasOptionsMenu(false);
                    }
                }
                if (currentFragment.isAdded()) {
                    ((OnPanesScrolledListener) currentFragment).onPanesScrolled();
                }
            }
        }
    }

    public interface OnPanesScrolledListener {
        public void onPanesScrolled();
    }
}




Java Source Code List

com.google.maps.android.ui.MyIconGenerator.java
com.mapsaurus.paneslayout.ActivityDelegate.java
com.mapsaurus.paneslayout.FragmentLauncher.java
com.mapsaurus.paneslayout.MenuItemWrapper.java
com.mapsaurus.paneslayout.MySlidingPaneLayout.java
com.mapsaurus.paneslayout.PanesActivity.java
com.mapsaurus.paneslayout.PanesLayout.java
com.mapsaurus.paneslayout.PanesSizer.java
com.mapsaurus.paneslayout.PhoneDelegate.java
com.mapsaurus.paneslayout.SimpleScrollView.java
com.mapsaurus.paneslayout.TabletDelegate.java
com.nasageek.utexasutilities.AsyncTask.java
com.nasageek.utexasutilities.AttachmentDownloadService.java
com.nasageek.utexasutilities.AuthCookie.java
com.nasageek.utexasutilities.BlackboardDashboardXmlParser.java
com.nasageek.utexasutilities.BuildingDatabase.java
com.nasageek.utexasutilities.BuildingProvider.java
com.nasageek.utexasutilities.BuildingSaxHandler.java
com.nasageek.utexasutilities.ChangeLog.java
com.nasageek.utexasutilities.ChangeableContextTask.java
com.nasageek.utexasutilities.CourseMapSaxHandler.java
com.nasageek.utexasutilities.FixedListPreference.java
com.nasageek.utexasutilities.LoginWebViewClient.java
com.nasageek.utexasutilities.MarkerManager.java
com.nasageek.utexasutilities.MyPair.java
com.nasageek.utexasutilities.MyScrollView.java
com.nasageek.utexasutilities.PlacemarkSaxHandler.java
com.nasageek.utexasutilities.PnaAuthCookie.java
com.nasageek.utexasutilities.RouteSaxHandler.java
com.nasageek.utexasutilities.SecurePreferences.java
com.nasageek.utexasutilities.TempLoginException.java
com.nasageek.utexasutilities.UTilitiesApplication.java
com.nasageek.utexasutilities.UtdAuthCookie.java
com.nasageek.utexasutilities.Utility.java
com.nasageek.utexasutilities.WrappedViewPager.java
com.nasageek.utexasutilities.WrappingSlidingDrawer.java
com.nasageek.utexasutilities.activities.AboutMeActivity.java
com.nasageek.utexasutilities.activities.BalanceActivity.java
com.nasageek.utexasutilities.activities.BlackboardPanesActivity.java
com.nasageek.utexasutilities.activities.CampusMapActivity.java
com.nasageek.utexasutilities.activities.DataUsageActivity.java
com.nasageek.utexasutilities.activities.LoginActivity.java
com.nasageek.utexasutilities.activities.MenuActivity.java
com.nasageek.utexasutilities.activities.NutritionInfoActivity.java
com.nasageek.utexasutilities.activities.Preferences.java
com.nasageek.utexasutilities.activities.ScheduleActivity.java
com.nasageek.utexasutilities.activities.UTilitiesActivity.java
com.nasageek.utexasutilities.adapters.BBClassAdapter.java
com.nasageek.utexasutilities.adapters.CourseMapAdapter.java
com.nasageek.utexasutilities.adapters.MultiPanePagerAdapter.java
com.nasageek.utexasutilities.adapters.MyFragmentPagerAdapter.java
com.nasageek.utexasutilities.adapters.ScheduleClassAdapter.java
com.nasageek.utexasutilities.adapters.TransactionAdapter.java
com.nasageek.utexasutilities.fragments.ActionModeFragment.java
com.nasageek.utexasutilities.fragments.BlackboardAnnouncementsFragment.java
com.nasageek.utexasutilities.fragments.BlackboardCourseListFragment.java
com.nasageek.utexasutilities.fragments.BlackboardCourseMapFragment.java
com.nasageek.utexasutilities.fragments.BlackboardDashboardFragment.java
com.nasageek.utexasutilities.fragments.BlackboardDownloadableItemFragment.java
com.nasageek.utexasutilities.fragments.BlackboardExternalItemFragment.java
com.nasageek.utexasutilities.fragments.BlackboardFragment.java
com.nasageek.utexasutilities.fragments.BlackboardGradesFragment.java
com.nasageek.utexasutilities.fragments.BlackboardPagerFragment.java
com.nasageek.utexasutilities.fragments.CourseScheduleFragment.java
com.nasageek.utexasutilities.fragments.DatePickerFragment.java
com.nasageek.utexasutilities.fragments.DoubleDatePickerDialogFragment.java
com.nasageek.utexasutilities.fragments.ExamScheduleFragment.java
com.nasageek.utexasutilities.fragments.MenuFragment.java
com.nasageek.utexasutilities.fragments.NutritionInfoFragment.java
com.nasageek.utexasutilities.fragments.PickCalendarDialogFragment.java
com.nasageek.utexasutilities.fragments.TransactionsFragment.java
com.nasageek.utexasutilities.model.BBClass.java
com.nasageek.utexasutilities.model.Building.java
com.nasageek.utexasutilities.model.Classtime.java
com.nasageek.utexasutilities.model.CourseMapItem.java
com.nasageek.utexasutilities.model.FeedItem.java
com.nasageek.utexasutilities.model.Placemark.java
com.nasageek.utexasutilities.model.Transaction.java
com.nasageek.utexasutilities.model.UTClass.java
com.viewpagerindicator.MyTabPageIndicator.java