Android Open Source - boundaries-android Main Activity






From Project

Back to project page boundaries-android.

License

The source code is released under:

MIT License

If you think the Android project boundaries-android 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.contexthub.boundaries;
/* www . ja v a  2s .  com*/
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBarActivity;
import android.view.Window;

import com.astuetz.PagerSlidingTabStrip;
import com.contexthub.boundaries.fragments.AboutFragment;
import com.contexthub.boundaries.fragments.GeofenceListFragment;
import com.contexthub.boundaries.fragments.GeofencesMapFragment;

import butterknife.ButterKnife;
import butterknife.InjectView;

public class MainActivity extends ActionBarActivity {

    @InjectView(R.id.tab_strip) PagerSlidingTabStrip tabStrip;
    @InjectView(R.id.view_pager) ViewPager viewPager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
        super.onCreate(savedInstanceState);
        setProgressBarIndeterminate(true);
        setContentView(R.layout.activity_main);
        ButterKnife.inject(this);
        viewPager.setAdapter(new PagerAdapter(getSupportFragmentManager()));
        viewPager.setOffscreenPageLimit(2);
        tabStrip.setViewPager(viewPager);
    }

    class PagerAdapter extends FragmentPagerAdapter {

        private final int[] TITLES = new int[]{R.string.map, R.string.list, R.string.about};

        public PagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return getString(TITLES[position]);
        }

        @Override
        public Fragment getItem(int position) {
            switch (position) {
                case 0:
                    return new GeofencesMapFragment();
                case 1:
                    return new GeofenceListFragment();
                case 2:
                    return new AboutFragment();
            }
            return null;
        }

        @Override
        public int getCount() {
            return TITLES.length;
        }
    }
}




Java Source Code List

com.contexthub.boundaries.ApplicationTest.java
com.contexthub.boundaries.BoundariesApp.java
com.contexthub.boundaries.MainActivity.java
com.contexthub.boundaries.fragments.AboutFragment.java
com.contexthub.boundaries.fragments.GeofenceCreateDialogFragment.java
com.contexthub.boundaries.fragments.GeofenceEditDialogFragment.java
com.contexthub.boundaries.fragments.GeofenceListFragment.java
com.contexthub.boundaries.fragments.GeofenceUpdateDialogFragment.java
com.contexthub.boundaries.fragments.GeofencesMapFragment.java