Search in sources :

Example 1 with PagerSlidingTabStrip

use of net.osmand.plus.views.controls.PagerSlidingTabStrip in project Osmand by osmandapp.

the class FavoritesActivity method setTabs.

private void setTabs(List<TabItem> mTabs) {
    PagerSlidingTabStrip mSlidingTabLayout = (PagerSlidingTabStrip) findViewById(R.id.sliding_tabs);
    OsmandSettings settings = ((OsmandApplication) getApplication()).getSettings();
    ViewPager mViewPager = (ViewPager) findViewById(R.id.pager);
    Integer tabId = settings.FAVORITES_TAB.get();
    int tab = 0;
    for (int i = 0; i < mTabs.size(); i++) {
        if (mTabs.get(i).resId == tabId) {
            tab = i;
        }
    }
    tabSize = mTabs.size();
    setViewPagerAdapter(mViewPager, mTabs);
    mSlidingTabLayout.setViewPager(mViewPager);
    mViewPager.setCurrentItem(tab);
}
Also used : PagerSlidingTabStrip(net.osmand.plus.views.controls.PagerSlidingTabStrip) OsmandApplication(net.osmand.plus.OsmandApplication) ViewPager(android.support.v4.view.ViewPager) OsmandSettings(net.osmand.plus.OsmandSettings)

Example 2 with PagerSlidingTabStrip

use of net.osmand.plus.views.controls.PagerSlidingTabStrip in project Osmand by osmandapp.

the class DownloadActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    getMyApplication().applyTheme(this);
    super.onCreate(savedInstanceState);
    getMyApplication().fetchRemoteParams();
    downloadThread = getMyApplication().getDownloadThread();
    DownloadResources indexes = getDownloadThread().getIndexes();
    if (!indexes.isDownloadedFromInternet) {
        getDownloadThread().runReloadIndexFiles();
    }
    accessibilityAssistant = new AccessibilityAssistant(this);
    setContentView(R.layout.download);
    // noinspection ConstantConditions
    getSupportActionBar().setTitle(R.string.shared_string_map);
    final View downloadProgressLayout = findViewById(R.id.downloadProgressLayout);
    downloadProgressLayout.setVisibility(View.VISIBLE);
    updateDescriptionTextWithSize(this, downloadProgressLayout);
    int currentTab = DOWNLOAD_TAB_NUMBER;
    String tab = getIntent() == null || getIntent().getExtras() == null ? null : getIntent().getExtras().getString(TAB_TO_OPEN);
    if (tab != null) {
        if (tab.equals(DOWNLOAD_TAB)) {
            currentTab = DOWNLOAD_TAB_NUMBER;
        } else if (tab.equals(LOCAL_TAB)) {
            currentTab = LOCAL_TAB_NUMBER;
        } else if (tab.equals(UPDATES_TAB)) {
            currentTab = UPDATES_TAB_NUMBER;
        }
    }
    viewPager = (ViewPager) findViewById(R.id.pager);
    PagerSlidingTabStrip mSlidingTabLayout = (PagerSlidingTabStrip) findViewById(R.id.sliding_tabs);
    mTabs.add(new TabActivity.TabItem(R.string.download_tab_downloads, getString(R.string.download_tab_downloads), DownloadResourceGroupFragment.class));
    mTabs.add(new TabActivity.TabItem(R.string.download_tab_local, getString(R.string.download_tab_local), LocalIndexesFragment.class));
    mTabs.add(new TabActivity.TabItem(R.string.download_tab_updates, getString(R.string.download_tab_updates), UpdatesIndexFragment.class));
    viewPager.setAdapter(new TabActivity.OsmandFragmentPagerAdapter(getSupportFragmentManager(), mTabs));
    mSlidingTabLayout.setViewPager(viewPager);
    mSlidingTabLayout.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            accessibilityAssistant.onPageSelected(position);
            visibleBanner.updateBannerInProgress();
        }

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            accessibilityAssistant.onPageScrolled(position, positionOffset, positionOffsetPixels);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
            accessibilityAssistant.onPageScrollStateChanged(state);
        }
    });
    viewPager.setCurrentItem(currentTab);
    visibleBanner = new BannerAndDownloadFreeVersion(findViewById(R.id.mainLayout), this, true);
    if (shouldShowFreeVersionBanner(getMyApplication())) {
        visibleBanner.setUpdatingPrices(true);
    }
    startInAppHelper();
    final Intent intent = getIntent();
    if (intent != null && intent.getExtras() != null) {
        filter = intent.getExtras().getString(FILTER_KEY);
        filterCat = intent.getExtras().getString(FILTER_CAT);
        filterGroup = intent.getExtras().getString(FILTER_GROUP);
    }
}
Also used : AccessibilityAssistant(net.osmand.access.AccessibilityAssistant) PagerSlidingTabStrip(net.osmand.plus.views.controls.PagerSlidingTabStrip) UpdatesIndexFragment(net.osmand.plus.download.ui.UpdatesIndexFragment) DownloadResourceGroupFragment(net.osmand.plus.download.ui.DownloadResourceGroupFragment) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) LocalIndexesFragment(net.osmand.plus.download.ui.LocalIndexesFragment) ViewPager(android.support.v4.view.ViewPager) TabActivity(net.osmand.plus.activities.TabActivity)

Example 3 with PagerSlidingTabStrip

use of net.osmand.plus.views.controls.PagerSlidingTabStrip in project Osmand by osmandapp.

the class SearchActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    ((OsmandApplication) getApplication()).applyTheme(this);
    super.onCreate(savedInstanceState);
    getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    long t = System.currentTimeMillis();
    setContentView(R.layout.tab_content);
    settings = ((OsmandApplication) getApplication()).getSettings();
    accessibilityAssistant = new AccessibilityAssistant(this);
    navigationInfo = new NavigationInfo((OsmandApplication) getApplication());
    showOnlyOneTab = getIntent() != null && getIntent().getBooleanExtra(SHOW_ONLY_ONE_TAB, false);
    getSupportActionBar().setTitle("");
    getSupportActionBar().setElevation(0);
    Integer tab = settings.SEARCH_TAB.get();
    if (!showOnlyOneTab) {
        ViewPager mViewPager = (ViewPager) findViewById(R.id.pager);
        PagerSlidingTabStrip mSlidingTabLayout = (PagerSlidingTabStrip) findViewById(R.id.sliding_tabs);
        List<TabItem> mTabs = new ArrayList<TabItem>();
        mTabs.add(getTabIndicator(R.string.poi, getFragment(POI_TAB_INDEX)));
        mTabs.add(getTabIndicator(R.string.address, getFragment(ADDRESS_TAB_INDEX)));
        mTabs.add(getTabIndicator(R.string.shared_string_location, getFragment(LOCATION_TAB_INDEX)));
        mTabs.add(getTabIndicator(R.string.favorite, getFragment(FAVORITES_TAB_INDEX)));
        mTabs.add(getTabIndicator(R.string.shared_string_history, getFragment(HISTORY_TAB_INDEX)));
        setViewPagerAdapter(mViewPager, mTabs);
        mSlidingTabLayout.setViewPager(mViewPager);
        mViewPager.setCurrentItem(Math.min(tab, HISTORY_TAB_INDEX));
        mSlidingTabLayout.setOnPageChangeListener(new OnPageChangeListener() {

            @Override
            public void onPageSelected(int arg0) {
                settings.SEARCH_TAB.set(arg0);
            }

            @Override
            public void onPageScrolled(int arg0, float arg1, int arg2) {
            }

            @Override
            public void onPageScrollStateChanged(int arg0) {
            }
        });
    } else {
        setContentView(R.layout.search_activity_single);
        Class<?> cl = getFragment(tab);
        try {
            getSupportFragmentManager().beginTransaction().replace(R.id.layout, (Fragment) cl.newInstance()).commit();
        } catch (InstantiationException e) {
            throw new IllegalStateException(e);
        } catch (IllegalAccessException e) {
            throw new IllegalStateException(e);
        }
    }
    setTopSpinner();
    Log.i("net.osmand", "Start on create " + (System.currentTimeMillis() - t));
    Intent intent = getIntent();
    OsmandSettings settings = ((OsmandApplication) getApplication()).getSettings();
    LatLon last = settings.getLastKnownMapLocation();
    if (intent != null) {
        double lat = intent.getDoubleExtra(SEARCH_LAT, 0);
        double lon = intent.getDoubleExtra(SEARCH_LON, 0);
        if (lat != 0 || lon != 0) {
            LatLon l = new LatLon(lat, lon);
            if (!Algorithms.objectEquals(reqSearchPoint, l)) {
                reqSearchPoint = l;
                if ((Math.abs(lat - last.getLatitude()) < 0.00001) && (Math.abs(lon - last.getLongitude()) < 0.00001)) {
                    updateSearchPoint(reqSearchPoint, getString(R.string.select_search_position) + " " + getString(R.string.search_position_map_view), false);
                } else {
                    updateSearchPoint(reqSearchPoint, getString(R.string.select_search_position) + " ", true);
                }
            }
        }
    }
    if (searchPoint == null) {
        if (!Algorithms.objectEquals(reqSearchPoint, last)) {
            reqSearchPoint = last;
            updateSearchPoint(last, getString(R.string.select_search_position) + " " + getString(R.string.search_position_map_view), false);
        }
    }
}
Also used : AccessibilityAssistant(net.osmand.access.AccessibilityAssistant) OsmandApplication(net.osmand.plus.OsmandApplication) PagerSlidingTabStrip(net.osmand.plus.views.controls.PagerSlidingTabStrip) ArrayList(java.util.ArrayList) OnPageChangeListener(android.support.v4.view.ViewPager.OnPageChangeListener) Intent(android.content.Intent) ViewPager(android.support.v4.view.ViewPager) NavigatePointFragment(net.osmand.plus.activities.NavigatePointFragment) Fragment(android.support.v4.app.Fragment) FavoritesListFragment(net.osmand.plus.activities.FavoritesListFragment) FavouritePoint(net.osmand.data.FavouritePoint) OsmandSettings(net.osmand.plus.OsmandSettings) LatLon(net.osmand.data.LatLon) NavigationInfo(net.osmand.access.NavigationInfo)

Aggregations

ViewPager (android.support.v4.view.ViewPager)3 PagerSlidingTabStrip (net.osmand.plus.views.controls.PagerSlidingTabStrip)3 Intent (android.content.Intent)2 AccessibilityAssistant (net.osmand.access.AccessibilityAssistant)2 OsmandApplication (net.osmand.plus.OsmandApplication)2 OsmandSettings (net.osmand.plus.OsmandSettings)2 Fragment (android.support.v4.app.Fragment)1 OnPageChangeListener (android.support.v4.view.ViewPager.OnPageChangeListener)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 ArrayList (java.util.ArrayList)1 NavigationInfo (net.osmand.access.NavigationInfo)1 FavouritePoint (net.osmand.data.FavouritePoint)1 LatLon (net.osmand.data.LatLon)1 FavoritesListFragment (net.osmand.plus.activities.FavoritesListFragment)1 NavigatePointFragment (net.osmand.plus.activities.NavigatePointFragment)1 TabActivity (net.osmand.plus.activities.TabActivity)1 DownloadResourceGroupFragment (net.osmand.plus.download.ui.DownloadResourceGroupFragment)1 LocalIndexesFragment (net.osmand.plus.download.ui.LocalIndexesFragment)1