use of androidx.viewpager.widget.ViewPager in project PageIndicatorView by romandanylyk.
the class PageIndicatorView method findViewPager.
private void findViewPager(@Nullable ViewParent viewParent) {
boolean isValidParent = viewParent != null && viewParent instanceof ViewGroup && ((ViewGroup) viewParent).getChildCount() > 0;
if (!isValidParent) {
return;
}
int viewPagerId = manager.indicator().getViewPagerId();
ViewPager viewPager = findViewPager((ViewGroup) viewParent, viewPagerId);
if (viewPager != null) {
setViewPager(viewPager);
} else {
findViewPager(viewParent.getParent());
}
}
use of androidx.viewpager.widget.ViewPager in project Gadgetbridge by Freeyourgadget.
the class NonSwipeableViewPager method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_charts);
int tabFragmentToOpen = -1;
initDates();
IntentFilter filterLocal = new IntentFilter();
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);
tabFragmentToOpen = extras.getInt(EXTRA_FRAGMENT_ID);
} else {
throw new IllegalArgumentException("Must provide a device when invoking this activity");
}
enabledTabsList = fillChartsTabsList(getDevice(), this);
swipeLayout = 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.
NonSwipeableViewPager viewPager = findViewById(R.id.charts_pager);
viewPager.setAdapter(getPagerAdapter());
if (tabFragmentToOpen > -1) {
// open the tab as specified in the intent
viewPager.setCurrentItem(tabFragmentToOpen);
}
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 = findViewById(R.id.charts_date_bar);
mDateControl = 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();
}
});
Button mPrevButton = findViewById(R.id.charts_previous_day);
mPrevButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
handleButtonClicked(DATE_PREV_DAY);
}
});
Button mNextButton = findViewById(R.id.charts_next_day);
mNextButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
handleButtonClicked(DATE_NEXT_DAY);
}
});
Button mPrevWeekButton = findViewById(R.id.charts_previous_week);
mPrevWeekButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
handleButtonClicked(DATE_PREV_WEEK);
}
});
Button mNextWeekButton = findViewById(R.id.charts_next_week);
mNextWeekButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
handleButtonClicked(DATE_NEXT_WEEK);
}
});
Button mPrevMonthButton = findViewById(R.id.charts_previous_month);
mPrevMonthButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
handleButtonClicked(DATE_PREV_MONTH);
}
});
Button mNextMonthButton = findViewById(R.id.charts_next_month);
mNextMonthButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
handleButtonClicked(DATE_NEXT_MONTH);
}
});
}
use of androidx.viewpager.widget.ViewPager in project android by nextcloud.
the class FirstRunActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
enableAccountHandling = false;
super.onCreate(savedInstanceState);
setContentView(R.layout.first_run_activity);
boolean isProviderOrOwnInstallationVisible = getResources().getBoolean(R.bool.show_provider_or_own_installation);
setSlideshowSize(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE);
Button loginButton = findViewById(R.id.login);
loginButton.setBackgroundColor(getResources().getColor(R.color.login_btn_tint));
loginButton.setTextColor(getResources().getColor(R.color.primary));
loginButton.setOnClickListener(v -> {
if (getIntent().getBooleanExtra(EXTRA_ALLOW_CLOSE, false)) {
Intent authenticatorActivityIntent = new Intent(this, AuthenticatorActivity.class);
authenticatorActivityIntent.putExtra(AuthenticatorActivity.EXTRA_USE_PROVIDER_AS_WEBLOGIN, false);
startActivityForResult(authenticatorActivityIntent, FIRST_RUN_RESULT_CODE);
} else {
finish();
}
});
Button providerButton = findViewById(R.id.signup);
providerButton.setBackgroundColor(getResources().getColor(R.color.primary));
providerButton.setTextColor(getResources().getColor(R.color.login_text_color));
providerButton.setVisibility(isProviderOrOwnInstallationVisible ? View.VISIBLE : View.GONE);
providerButton.setOnClickListener(v -> {
Intent authenticatorActivityIntent = new Intent(this, AuthenticatorActivity.class);
authenticatorActivityIntent.putExtra(AuthenticatorActivity.EXTRA_USE_PROVIDER_AS_WEBLOGIN, true);
if (getIntent().getBooleanExtra(EXTRA_ALLOW_CLOSE, false)) {
startActivityForResult(authenticatorActivityIntent, FIRST_RUN_RESULT_CODE);
} else {
authenticatorActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(authenticatorActivityIntent);
}
});
TextView hostOwnServerTextView = findViewById(R.id.host_own_server);
hostOwnServerTextView.setTextColor(getResources().getColor(R.color.login_text_color));
hostOwnServerTextView.setVisibility(isProviderOrOwnInstallationVisible ? View.VISIBLE : View.GONE);
if (!isProviderOrOwnInstallationVisible) {
hostOwnServerTextView.setOnClickListener(v -> onHostYourOwnServerClick());
}
progressIndicator = findViewById(R.id.progressIndicator);
ViewPager viewPager = findViewById(R.id.contentPanel);
// Sometimes, accounts are not deleted when you uninstall the application so we'll do it now
if (onboarding.isFirstRun()) {
userAccountManager.removeAllAccounts();
}
FeaturesViewAdapter featuresViewAdapter = new FeaturesViewAdapter(getSupportFragmentManager(), getFirstRun());
progressIndicator.setNumberOfSteps(featuresViewAdapter.getCount());
viewPager.setAdapter(featuresViewAdapter);
viewPager.addOnPageChangeListener(this);
}
use of androidx.viewpager.widget.ViewPager in project SmartTabLayout by ogaclejapan.
the class DemoTabWithNotificationMarkActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_demo_tab_with_notification_mark);
final Demo demo = getDemo();
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(demo.titleResId);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ViewGroup tab = (ViewGroup) findViewById(R.id.tab);
tab.addView(LayoutInflater.from(this).inflate(demo.layoutResId, tab, false));
ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
final SmartTabLayout viewPagerTab = (SmartTabLayout) findViewById(R.id.viewpagertab);
viewPagerTab.setCustomTabView(this);
FragmentPagerItems pages = new FragmentPagerItems(this);
for (int titleResId : demo.tabs()) {
pages.add(FragmentPagerItem.of(getString(titleResId), DemoFragment.class));
}
FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(getSupportFragmentManager(), pages);
viewPager.setAdapter(adapter);
viewPagerTab.setViewPager(viewPager);
viewPagerTab.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
super.onPageSelected(position);
View tab = viewPagerTab.getTabAt(position);
View mark = tab.findViewById(R.id.custom_tab_notification_mark);
mark.setVisibility(View.GONE);
}
});
findViewById(R.id.test).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int position = Math.abs(random.nextInt()) % demo.tabs().length;
View tab = viewPagerTab.getTabAt(position);
View mark = tab.findViewById(R.id.custom_tab_notification_mark);
mark.setVisibility(View.VISIBLE);
}
});
}
use of androidx.viewpager.widget.ViewPager in project SmartTabLayout by ogaclejapan.
the class DemoRtlActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_rtl);
Demo demo = getDemo();
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle(demo.titleResId);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ViewGroup tab = (ViewGroup) findViewById(R.id.tab);
tab.addView(LayoutInflater.from(this).inflate(demo.layoutResId, tab, false));
ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
final SmartTabLayout viewPagerTab = (SmartTabLayout) findViewById(R.id.viewpagertab);
demo.setup(viewPagerTab);
FragmentPagerItems pages = new FragmentPagerItems(this);
for (int titleResId : demo.tabs()) {
pages.add(FragmentPagerItem.of(getString(titleResId), DemoFragment.class));
}
FragmentPagerItemAdapter adapter = new FragmentPagerItemAdapter(getSupportFragmentManager(), pages);
viewPager.setAdapter(adapter);
viewPagerTab.setViewPager(viewPager);
}
Aggregations