Search in sources :

Example 41 with ViewPager

use of androidx.viewpager.widget.ViewPager in project CircleIndicator by ongakuer.

the class ChangeDrawableFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    ViewPager viewpager = view.findViewById(R.id.viewpager);
    CircleIndicator indicator = view.findViewById(R.id.indicator);
    viewpager.setAdapter(new SamplePagerAdapter());
    indicator.setViewPager(viewpager);
    view.findViewById(R.id.change_drawable_view).setOnClickListener(v -> indicator.changeIndicatorResource(R.drawable.black_radius, R.drawable.white_radius));
    view.findViewById(R.id.tint_view).setOnClickListener(v -> indicator.tintIndicator(Color.RED, Color.BLUE));
}
Also used : CircleIndicator(me.relex.circleindicator.CircleIndicator) ViewPager(androidx.viewpager.widget.ViewPager) SamplePagerAdapter(me.relex.circleindicator.sample.SamplePagerAdapter)

Example 42 with ViewPager

use of androidx.viewpager.widget.ViewPager in project SmoothRefreshLayout by dkzwm.

the class TestNestedViewPagerActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_with_nested_viewpager);
    final Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setNavigationIcon(R.drawable.arrow_back_white_72x72);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
    ViewPager viewPager = findViewById(R.id.viewPager_with_nested_pager);
    List<NestedPageWithSrlFragment> fragments = new ArrayList<>();
    for (int color : sColors) {
        fragments.add(NestedPageWithSrlFragment.newInstance(color));
    }
    ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager(), fragments);
    viewPager.setAdapter(adapter);
}
Also used : NestedPageWithSrlFragment(me.dkzwm.widget.srl.sample.ui.fragment.NestedPageWithSrlFragment) ArrayList(java.util.ArrayList) ViewPagerAdapter(me.dkzwm.widget.srl.sample.adapter.ViewPagerAdapter) View(android.view.View) ViewPager(androidx.viewpager.widget.ViewPager) Toolbar(androidx.appcompat.widget.Toolbar)

Example 43 with ViewPager

use of androidx.viewpager.widget.ViewPager in project SmoothRefreshLayout by dkzwm.

the class AutoRefreshUtil method autoLoadMore.

public void autoLoadMore(boolean atOnce, boolean autoRefreshUseSmoothScroll) {
    if (mRefreshLayout != null) {
        if (mStatus != SmoothRefreshLayout.SR_STATUS_INIT)
            return;
        if (mRefreshLayout.isNotYetInEdgeCannotMoveFooter()) {
            if (mRefreshLayout.isVerticalOrientation()) {
                ScrollCompat.flingCompat(mTargetView, mMaximumFlingVelocity);
            } else {
                if (mTargetView instanceof ViewPager) {
                    final ViewPager pager = (ViewPager) mTargetView;
                    final PagerAdapter adapter = pager.getAdapter();
                    if (adapter == null)
                        return;
                    if (adapter.getCount() <= 0)
                        return;
                    pager.setCurrentItem(adapter.getCount() - 1, true);
                } else {
                    HorizontalScrollCompat.flingCompat(mTargetView, mMaximumFlingVelocity);
                }
            }
            mNeedToTriggerLoadMore = true;
            mCachedActionAtOnce = atOnce;
            mCachedAutoRefreshUseSmoothScroll = autoRefreshUseSmoothScroll;
        } else {
            mRefreshLayout.autoLoadMore(atOnce, autoRefreshUseSmoothScroll);
            mNeedToTriggerLoadMore = false;
            mCachedActionAtOnce = false;
            mCachedAutoRefreshUseSmoothScroll = false;
        }
        ViewCompat.postOnAnimation(mRefreshLayout, this);
    }
}
Also used : ViewPager(androidx.viewpager.widget.ViewPager) PagerAdapter(androidx.viewpager.widget.PagerAdapter)

Example 44 with ViewPager

use of androidx.viewpager.widget.ViewPager in project kcanotify by antest1.

the class ResourceLogActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_resourcelog);
    toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(getStringWithLocale(R.string.action_reslog));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
    resourceLogger = new KcaResourceLogger(getApplicationContext(), null, KCANOTIFY_RESOURCELOG_VERSION);
    KcaApiData.setDBHelper(dbHelper);
    tabLayout = findViewById(R.id.reslog_tab);
    tabLayout.addTab(tabLayout.newTab().setText(getStringWithLocale(R.string.reslog_label_resource)));
    tabLayout.addTab(tabLayout.newTab().setText(getStringWithLocale(R.string.reslog_label_consumable)));
    tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
    export_msg = findViewById(R.id.export_msg);
    viewPager = findViewById(R.id.reslog_pager);
    pageAdapter = new KcaResourceLogPageAdapter(getSupportFragmentManager());
    viewPager.setAdapter(pageAdapter);
    viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            tab_position = position;
            tabLayout.setScrollPosition(position, positionOffset, true);
            Log.e("KCA", "onPageScrolled " + position);
        }

        @Override
        public void onPageSelected(int position) {
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
    tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {

        @Override
        public void onTabSelected(TabLayout.Tab tab) {
            tab_position = tab.getPosition();
            viewPager.setCurrentItem(tab.getPosition());
        }

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {
        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {
            tab_position = tab.getPosition();
            viewPager.setCurrentItem(tab.getPosition());
        }
    });
    showhide_btn = findViewById(R.id.reslog_showhide);
    showhide_btn.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.black), PorterDuff.Mode.MULTIPLY);
    showhide_btn.setImageResource(R.mipmap.ic_arrow_down);
    showhide_btn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            is_hidden = !is_hidden;
            if (is_hidden) {
                showhide_btn.setImageResource(R.mipmap.ic_arrow_up);
            } else {
                showhide_btn.setImageResource(R.mipmap.ic_arrow_down);
            }
            pageAdapter.notifyDataSetChanged();
        }
    });
    start_date = findViewById(R.id.reslog_date_start);
    start_date.setOnClickListener(dateViewListener);
    end_date = findViewById(R.id.reslog_date_end);
    end_date.setOnClickListener(dateViewListener);
    interval_d = findViewById(R.id.reslog_interval_day);
    interval_d.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (interval_value != INTERVAL_1D) {
                interval_value = INTERVAL_1D;
                setFragmentChartInfo(interval_value);
                interval_select.setSelection(INTERVAL_1D);
            } else {
                pageAdapter.notifyDataSetChanged();
            }
        }
    });
    interval_w = findViewById(R.id.reslog_interval_week);
    interval_w.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (interval_value != INTERVAL_1W) {
                interval_value = INTERVAL_1W;
                setFragmentChartInfo(interval_value);
                interval_select.setSelection(INTERVAL_1W);
            } else {
                pageAdapter.notifyDataSetChanged();
            }
        }
    });
    interval_m = findViewById(R.id.reslog_interval_month);
    interval_m.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            if (interval_value != INTERVAL_1M) {
                interval_value = INTERVAL_1M;
                setFragmentChartInfo(interval_value);
                interval_select.setSelection(INTERVAL_1M);
            } else {
                pageAdapter.notifyDataSetChanged();
            }
        }
    });
    interval_select = findViewById(R.id.reslog_date_interval);
    final ArrayAdapter<CharSequence> interval_adapter = ArrayAdapter.createFromResource(this, R.array.time_interval_array, R.layout.spinner_item_14dp);
    interval_adapter.setDropDownViewResource(R.layout.spinner_dropdown_item_14dp);
    interval_select.setAdapter(interval_adapter);
    interval_select.setSelection(INTERVAL_1D);
    interval_select.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
            Log.e("KCA-RL", "onItemSelected");
            interval_value = position;
            setFragmentChartInfo(interval_value);
            KcaResourcelogItemAdpater.setListViewItemList(convertData(resourceLog));
            pageAdapter.notifyDataSetChanged();
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    });
    long current_time = System.currentTimeMillis();
    current_time = KcaUtils.getCurrentDateTimestamp(current_time);
    SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy", Locale.US);
    String[] time_list = dateFormat.format(new Date(current_time)).split("\\-");
    int year = Integer.parseInt(time_list[2]);
    int month = Integer.parseInt(time_list[0]);
    start_timestamp = current_time - DAY_MILLISECOND * KcaUtils.getLastDay(year, month == 1 ? 12 : month - 1);
    end_timestamp = current_time + DAY_MILLISECOND - 1;
    start_date.setText(convertMillsToDate(start_timestamp));
    end_date.setText(convertMillsToDate(end_timestamp));
    resourceLog = resourceLogger.getResourceLogInRange(start_timestamp, end_timestamp);
    KcaResourcelogItemAdpater.setListViewItemList(convertData(resourceLog));
    pageAdapter.notifyDataSetChanged();
}
Also used : ViewPager(androidx.viewpager.widget.ViewPager) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) Date(java.util.Date) DropLogActivity.convertMillsToDate(com.antest1.kcanotify.DropLogActivity.convertMillsToDate) TabLayout(com.google.android.material.tabs.TabLayout) AdapterView(android.widget.AdapterView) SimpleDateFormat(java.text.SimpleDateFormat)

Example 45 with ViewPager

use of androidx.viewpager.widget.ViewPager in project PageIndicatorView by romandanylyk.

the class HomeActivity method initViews.

@SuppressWarnings("ConstantConditions")
private void initViews() {
    HomeAdapter adapter = new HomeAdapter();
    adapter.setData(createPageList());
    final ViewPager pager = findViewById(R.id.viewPager);
    pager.setAdapter(adapter);
    pageIndicatorView = findViewById(R.id.pageIndicatorView);
}
Also used : ViewPager(androidx.viewpager.widget.ViewPager)

Aggregations

ViewPager (androidx.viewpager.widget.ViewPager)68 View (android.view.View)24 Intent (android.content.Intent)12 TabLayout (com.google.android.material.tabs.TabLayout)12 Toolbar (androidx.appcompat.widget.Toolbar)11 ViewGroup (android.view.ViewGroup)9 TextView (android.widget.TextView)9 ColorPreferences (me.ccrama.redditslide.Visuals.ColorPreferences)9 ImageView (android.widget.ImageView)8 PageNavigationView (me.majiajie.pagerbottomtabstrip.PageNavigationView)8 Bundle (android.os.Bundle)6 PagerAdapter (androidx.viewpager.widget.PagerAdapter)6 MyViewPagerAdapter (me.majiajie.pagerbottomtabstriptest.other.MyViewPagerAdapter)6 CircleIndicator (me.relex.circleindicator.CircleIndicator)6 LayoutInflater (android.view.LayoutInflater)5 Button (android.widget.Button)5 SamplePagerAdapter (me.relex.circleindicator.sample.SamplePagerAdapter)5 LinearInterpolator (android.view.animation.LinearInterpolator)4 NonNull (androidx.annotation.NonNull)4 FragmentStatePagerAdapter (androidx.fragment.app.FragmentStatePagerAdapter)4