Search in sources :

Example 1 with PagerTabStrip

use of android.support.v4.view.PagerTabStrip in project Gadgetbridge by Freeyourgadget.

the class ChartsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_charts);
    initDates();
    IntentFilter filterLocal = new IntentFilter();
    filterLocal.addAction(GBApplication.ACTION_QUIT);
    filterLocal.addAction(GBDevice.ACTION_DEVICE_CHANGED);
    LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, filterLocal);
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        mGBDevice = extras.getParcelable(GBDevice.EXTRA_DEVICE);
    } else {
        throw new IllegalArgumentException("Must provide a device when invoking this activity");
    }
    swipeLayout = (SwipeRefreshLayout) findViewById(R.id.activity_swipe_layout);
    swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            fetchActivityData();
        }
    });
    enableSwipeRefresh(true);
    // Set up the ViewPager with the sections adapter.
    viewPager = (ViewPager) findViewById(R.id.charts_pager);
    viewPager.setAdapter(getPagerAdapter());
    viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

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

        @Override
        public void onPageSelected(int position) {
        }

        @Override
        public void onPageScrollStateChanged(int state) {
            enableSwipeRefresh(state == ViewPager.SCROLL_STATE_IDLE);
        }
    });
    dateBar = (ViewGroup) findViewById(R.id.charts_date_bar);
    mDateControl = (TextView) findViewById(R.id.charts_text_date);
    mDateControl.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            String detailedDuration = formatDetailedDuration();
            new ShowDurationDialog(detailedDuration, ChartsActivity.this).show();
        }
    });
    mPrevButton = (Button) findViewById(R.id.charts_previous);
    mPrevButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            handlePrevButtonClicked();
        }
    });
    mNextButton = (Button) findViewById(R.id.charts_next);
    mNextButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            handleNextButtonClicked();
        }
    });
    mPagerTabStrip = (PagerTabStrip) findViewById(R.id.charts_pagerTabStrip);
    LinearLayout mainLayout = (LinearLayout) findViewById(R.id.charts_main_layout);
}
Also used : IntentFilter(android.content.IntentFilter) Bundle(android.os.Bundle) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) ViewPager(android.support.v4.view.ViewPager) View(android.view.View) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout)

Example 2 with PagerTabStrip

use of android.support.v4.view.PagerTabStrip in project Carbon by ZieIony.

the class TabsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tabs);
    ViewPager pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(new PagerAdapter() {

        @Override
        public CharSequence getPageTitle(int position) {
            return "Page " + position;
        }

        public View getView(int position, ViewPager pager) {
            return new RelativeLayout(pager.getContext(), null, R.attr.carbon_cardViewStyle);
        }

        @Override
        public boolean isViewFromObject(View view, Object object) {
            return view == object;
        }

        @Override
        public int getCount() {
            return 7;
        }

        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            ViewPager pager = (ViewPager) container;
            View view = getView(position, pager);
            pager.addView(view);
            return view;
        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object view) {
            ((ViewPager) container).removeView((View) view);
        }
    });
    PagerTabStrip tabs = (PagerTabStrip) findViewById(R.id.pager_title_strip);
    tabs.setViewPager(pager);
}
Also used : ViewGroup(android.view.ViewGroup) RelativeLayout(carbon.widget.RelativeLayout) PagerTabStrip(carbon.widget.PagerTabStrip) ViewPager(carbon.widget.ViewPager) View(android.view.View) PagerAdapter(android.support.v4.view.PagerAdapter)

Example 3 with PagerTabStrip

use of android.support.v4.view.PagerTabStrip in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class AppOpsSummary method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // initialize the inflater
    mInflater = inflater;
    View rootView = mInflater.inflate(R.layout.app_ops_summary, container, false);
    mContentContainer = container;
    mRootView = rootView;
    CharSequence[] pageNames = getResources().getTextArray(R.array.app_ops_categories_cm);
    AppOpsState.OpsTemplate[] templates = AppOpsState.ALL_TEMPLATES;
    assert (pageNames.length == templates.length);
    int specificTab = -1;
    Bundle bundle = getArguments();
    if (bundle != null) {
        specificTab = Arrays.asList(pageNames).indexOf(bundle.getString("appops_tab", ""));
    }
    List<Pair<CharSequence, AppOpsState.OpsTemplate>> pageData = new ArrayList<>();
    for (int i = 0; i < pageNames.length; i++) {
        pageData.add(Pair.create(pageNames[i], templates[i]));
    }
    filterPageData(pageData, specificTab);
    mViewPager = (ViewPager) rootView.findViewById(R.id.pager);
    mAdapter = new MyPagerAdapter(getChildFragmentManager(), pageData);
    mViewPager.setAdapter(mAdapter);
    mViewPager.setOnPageChangeListener(mAdapter);
    PagerTabStrip tabs = (PagerTabStrip) rootView.findViewById(R.id.tabs);
    // HACK - https://code.google.com/p/android/issues/detail?id=213359
    ((ViewPager.LayoutParams) tabs.getLayoutParams()).isDecor = true;
    Resources.Theme theme = tabs.getContext().getTheme();
    TypedValue typedValue = new TypedValue();
    theme.resolveAttribute(android.R.attr.colorAccent, typedValue, true);
    final int colorAccent = getContext().getColor(typedValue.resourceId);
    tabs.setTabIndicatorColor(colorAccent);
    // only when the view is added.
    if (container instanceof PreferenceFrameLayout) {
        ((PreferenceFrameLayout.LayoutParams) rootView.getLayoutParams()).removeBorders = true;
    }
    mActivity = getActivity();
    return rootView;
}
Also used : Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) PreferenceFrameLayout(android.preference.PreferenceFrameLayout) View(android.view.View) ViewPager(android.support.v4.view.ViewPager) Resources(android.content.res.Resources) PagerTabStrip(android.support.v4.view.PagerTabStrip) Pair(android.util.Pair) TypedValue(android.util.TypedValue)

Aggregations

View (android.view.View)3 Bundle (android.os.Bundle)2 ViewPager (android.support.v4.view.ViewPager)2 IntentFilter (android.content.IntentFilter)1 Resources (android.content.res.Resources)1 PreferenceFrameLayout (android.preference.PreferenceFrameLayout)1 PagerAdapter (android.support.v4.view.PagerAdapter)1 PagerTabStrip (android.support.v4.view.PagerTabStrip)1 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 Pair (android.util.Pair)1 TypedValue (android.util.TypedValue)1 ViewGroup (android.view.ViewGroup)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 PagerTabStrip (carbon.widget.PagerTabStrip)1 RelativeLayout (carbon.widget.RelativeLayout)1 ViewPager (carbon.widget.ViewPager)1 ArrayList (java.util.ArrayList)1