use of android.support.v4.view.ViewPager in project JieCaoVideoPlayer by lipangit.
the class ListViewViewpagerActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_listview_viewpager);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setDisplayUseLogoEnabled(false);
getSupportActionBar().setTitle("ViewPagerAndListView");
List<View> listViews = new ArrayList<>();
ListView listView1 = (ListView) getLayoutInflater().inflate(R.layout.layout_list, null);
ListView listView2 = (ListView) getLayoutInflater().inflate(R.layout.layout_list, null);
ListView listView3 = (ListView) getLayoutInflater().inflate(R.layout.layout_list, null);
listView1.setAdapter(new VideoListAdapter(this, 0));
listView2.setAdapter(new VideoListAdapter(this, 1));
listView3.setAdapter(new VideoListAdapter(this, 2));
listViews.add(listView1);
listViews.add(listView2);
listViews.add(listView3);
MyAdapter myAdapter = new MyAdapter(listViews);
ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager);
viewPager.setAdapter(myAdapter);
viewPager.setOnPageChangeListener(this);
}
use of android.support.v4.view.ViewPager in project Android-ParallaxHeaderViewPager by kmshack.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mMinHeaderHeight = getResources().getDimensionPixelSize(R.dimen.min_header_height);
mHeaderHeight = getResources().getDimensionPixelSize(R.dimen.header_height);
mMinHeaderTranslation = -mMinHeaderHeight;
setContentView(R.layout.activity_main);
mHeader = findViewById(R.id.header);
info = (TextView) findViewById(R.id.info);
mPagerSlidingTabStrip = (PagerSlidingTabStrip) findViewById(R.id.tabs);
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setOffscreenPageLimit(4);
mPagerAdapter = new PagerAdapter(getSupportFragmentManager());
mPagerAdapter.setTabHolderScrollingContent(this);
mViewPager.setAdapter(mPagerAdapter);
mPagerSlidingTabStrip.setViewPager(mViewPager);
mPagerSlidingTabStrip.setOnPageChangeListener(this);
mLastY = 0;
}
use of android.support.v4.view.ViewPager in project Talon-for-Twitter by klinker24.
the class MainActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
UpdateUtils.checkUpdate(this);
MainActivity.sendHandler = new Handler();
context = this;
sContext = this;
sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", 0);
DrawerActivity.settings = AppSettings.getInstance(context);
try {
requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
} catch (Exception e) {
}
sharedPrefs.edit().putBoolean("refresh_me", getIntent().getBooleanExtra("from_notification", false)).commit();
setUpTheme();
setUpWindow();
setContentView(R.layout.main_activity);
mViewPager = (ViewPager) findViewById(R.id.pager);
setUpDrawer(0, getResources().getString(R.string.timeline));
MainActivity.sendLayout = (LinearLayout) findViewById(R.id.send_layout);
MainActivity.sendHandler.postDelayed(showSend, 1000);
MainActivity.sendButton = (ImageButton) findViewById(R.id.send_button);
MainActivity.sendButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent compose = new Intent(context, ComposeActivity.class);
startActivity(compose);
}
});
actionBar = getActionBar();
if (!settings.isTwitterLoggedIn) {
Intent login = new Intent(context, LoginActivity.class);
startActivity(login);
}
mSectionsPagerAdapter = new TimelinePagerAdapter(getFragmentManager(), context, sharedPrefs, getIntent().getBooleanExtra("from_launcher", false));
int currAccount = sharedPrefs.getInt("current_account", 1);
int defaultPage = sharedPrefs.getInt("default_timeline_page_" + currAccount, 0);
actionBar.setTitle(mSectionsPagerAdapter.getPageTitle(defaultPage));
mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
public void onPageScrollStateChanged(int state) {
}
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
if (!actionBar.isShowing()) {
actionBar.show();
if (translucent) {
statusBar.setVisibility(View.VISIBLE);
}
}
MainActivity.sendHandler.post(showSend);
}
public void onPageSelected(int position) {
String title = "" + mSectionsPagerAdapter.getPageTitle(position);
MainDrawerArrayAdapter.setCurrent(context, position);
drawerList.invalidateViews();
actionBar.setTitle(title);
}
});
mViewPager.setAdapter(mSectionsPagerAdapter);
mViewPager.setOverScrollMode(View.OVER_SCROLL_NEVER);
mViewPager.setCurrentItem(defaultPage);
MainDrawerArrayAdapter.setCurrent(this, defaultPage);
drawerList.invalidateViews();
if (getIntent().getBooleanExtra("from_launcher", false)) {
actionBar.setTitle(mSectionsPagerAdapter.getPageTitle(getIntent().getIntExtra("launcher_page", 0)));
}
mViewPager.setOffscreenPageLimit(TimelinePagerAdapter.MAX_EXTRA_PAGES);
if (getIntent().getBooleanExtra("tutorial", false) && !sharedPrefs.getBoolean("done_tutorial", false)) {
getIntent().putExtra("tutorial", false);
sharedPrefs.edit().putBoolean("done_tutorial", true).commit();
registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
try {
Log.v("tutorial_activity", "close drawer");
mDrawerLayout.closeDrawer(Gravity.LEFT);
unregisterReceiver(this);
} catch (Exception e) {
e.printStackTrace();
}
}
}, new IntentFilter(TutorialActivity.ACTION_CLOSE_DRAWER));
registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
try {
Log.v("tutorial_activity", "open drawer");
mDrawerLayout.openDrawer(Gravity.LEFT);
unregisterReceiver(this);
} catch (Exception e) {
e.printStackTrace();
}
}
}, new IntentFilter(TutorialActivity.ACTION_OPEN_DRAWER));
registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
try {
Log.v("tutorial_activity", "page left");
mViewPager.setCurrentItem(mViewPager.getCurrentItem() - 1, true);
unregisterReceiver(this);
} catch (Exception e) {
e.printStackTrace();
}
}
}, new IntentFilter(TutorialActivity.ACTION_PAGE_LEFT));
registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
try {
Log.v("tutorial_activity", "page right");
mViewPager.setCurrentItem(mViewPager.getCurrentItem() + 1, true);
unregisterReceiver(this);
} catch (Exception e) {
e.printStackTrace();
}
}
}, new IntentFilter(TutorialActivity.ACTION_PAGE_RIGHT));
startActivity(new Intent(context, TutorialActivity.class));
overridePendingTransition(0, 0);
}
setLauncherPage();
if (getIntent().getBooleanExtra("from_drawer", false)) {
mViewPager.setCurrentItem(getIntent().getIntExtra("page_to_open", 1));
}
}
use of android.support.v4.view.ViewPager in project Talon-for-Twitter by klinker24.
the class SettingsActivityOld method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
overridePendingTransition(R.anim.slide_in_left, R.anim.activity_zoom_exit);
AppSettings.invalidate();
setUpTheme();
setContentView(R.layout.settings_main);
DrawerArrayAdapter.current = 0;
linkItems = new String[] { getResources().getString(R.string.get_help_settings), getResources().getString(R.string.other_apps), getResources().getString(R.string.whats_new), getResources().getString(R.string.rate_it) };
settingsItems = new String[] { getResources().getString(R.string.ui_settings), getResources().getString(R.string.timelines_settings), getResources().getString(R.string.sync_settings), getResources().getString(R.string.notification_settings), getResources().getString(R.string.browser_settings), getResources().getString(R.string.advanced_settings), getResources().getString(R.string.memory_manage) };
sharedPrefs = getSharedPreferences("com.klinker.android.twitter_world_preferences", 0);
if (sharedPrefs.getBoolean("version_1.20_1", true)) {
// necessary because i didnt start out by using sets
boolean led = sharedPrefs.getBoolean("led", true);
boolean sound = sharedPrefs.getBoolean("sound", true);
boolean vibrate = sharedPrefs.getBoolean("vibrate", true);
boolean wakeScreen = sharedPrefs.getBoolean("wake", true);
boolean timelineNot = sharedPrefs.getBoolean("timeline_notifications", true);
boolean mentionsNot = sharedPrefs.getBoolean("mentions_notifications", true);
boolean dmsNot = sharedPrefs.getBoolean("direct_message_notifications", true);
boolean favoritesNot = sharedPrefs.getBoolean("favorite_notifications", true);
boolean retweetNot = sharedPrefs.getBoolean("retweet_notifications", true);
boolean followersNot = sharedPrefs.getBoolean("follower_notifications", true);
Set<String> alert = sharedPrefs.getStringSet("alert_types", new HashSet<String>());
alert.clear();
if (vibrate) {
alert.add("1");
}
if (led) {
alert.add("2");
}
if (wakeScreen) {
alert.add("3");
}
if (sound) {
alert.add("4");
}
sharedPrefs.edit().putStringSet("alert_types", alert).commit();
Set<String> timeline = sharedPrefs.getStringSet("timeline_set", new HashSet<String>());
timeline.clear();
if (timelineNot) {
timeline.add("1");
}
if (mentionsNot) {
timeline.add("2");
}
if (dmsNot) {
timeline.add("3");
}
sharedPrefs.edit().putStringSet("timeline_set", timeline).commit();
Set<String> interactions = sharedPrefs.getStringSet("interactions_set", new HashSet<String>());
interactions.clear();
if (favoritesNot) {
interactions.add("1");
}
if (retweetNot) {
interactions.add("2");
}
if (followersNot) {
interactions.add("3");
}
sharedPrefs.edit().putStringSet("interactions_set", interactions).commit();
sharedPrefs.edit().putBoolean("version_1.20_1", false).commit();
recreate();
}
mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager(), this, otherList);
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mSectionsPagerAdapter);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START);
otherList = (ListView) findViewById(R.id.other_list);
settingsList = (ListView) findViewById(R.id.settings_list);
mDrawer = (LinearLayout) findViewById(R.id.drawer);
// Set the adapter for the list view
otherList.setAdapter(new DrawerArrayAdapter(this, new ArrayList<String>(Arrays.asList(linkItems))));
settingsList.setAdapter(new DrawerArrayAdapter(this, new ArrayList<String>(Arrays.asList(settingsItems))));
// Set the list's click listener
settingsList.setOnItemClickListener(new SettingsDrawerClickListener(this, mDrawerLayout, settingsList, mViewPager, mDrawer));
otherList.setOnItemClickListener(new SettingsLinkDrawerClickListener(this, mDrawerLayout, otherList, mViewPager, mDrawer));
findViewById(R.id.settingsLinks).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
switchToSettingsList(true);
settingsLinksActive = true;
findViewById(R.id.settingsSelector).setVisibility(View.VISIBLE);
findViewById(R.id.otherSelector).setVisibility(View.INVISIBLE);
}
});
findViewById(R.id.otherLinks).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
switchToSettingsList(false);
settingsLinksActive = false;
findViewById(R.id.settingsSelector).setVisibility(View.INVISIBLE);
findViewById(R.id.otherSelector).setVisibility(View.VISIBLE);
}
});
if (settingsLinksActive) {
settingsList.setVisibility(View.VISIBLE);
otherList.setVisibility(View.GONE);
findViewById(R.id.settingsSelector).setVisibility(View.VISIBLE);
findViewById(R.id.otherSelector).setVisibility(View.INVISIBLE);
} else {
settingsList.setVisibility(View.GONE);
otherList.setVisibility(View.VISIBLE);
findViewById(R.id.settingsSelector).setVisibility(View.INVISIBLE);
findViewById(R.id.otherSelector).setVisibility(View.VISIBLE);
}
TypedArray a = getTheme().obtainStyledAttributes(new int[] { R.attr.drawerIcon });
int resource = a.getResourceId(0, 0);
a.recycle();
mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */
mDrawerLayout, /* DrawerLayout object */
resource, /* nav drawer icon to replace 'Up' caret */
R.string.app_name, /* "open drawer" description */
R.string.app_name);
mDrawerLayout.setDrawerListener(mDrawerToggle);
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);
userKnows = sharedPrefs.getBoolean("user_knows_navigation_drawer", false);
mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
public void onPageScrollStateChanged(int state) {
}
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
public void onPageSelected(int position) {
DrawerArrayAdapter.current = position;
otherList.invalidateViews();
settingsList.invalidateViews();
}
});
if (!userKnows) {
mDrawerLayout.openDrawer(mDrawer);
}
HoloTextView createdBy = (HoloTextView) findViewById(R.id.created_by);
HoloTextView versionNumber = (HoloTextView) findViewById(R.id.version_number);
try {
String versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
String text = getResources().getString(R.string.created_by) + " Luke Klinker";
String text2 = getResources().getString(R.string.version) + " " + versionName;
createdBy.setText(text);
versionNumber.setText(text2);
} catch (Exception e) {
String text = getResources().getString(R.string.created_by) + " Luke Klinker";
String text2 = getResources().getString(R.string.version) + " 0.00";
createdBy.setText(text);
versionNumber.setText(text2);
}
LinearLayout description = (LinearLayout) findViewById(R.id.created_by_layout);
description.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/developer?id=Klinker+Apps")));
}
});
mDrawerLayout.openDrawer(Gravity.START);
}
use of android.support.v4.view.ViewPager in project StatusBarUtil by laobie.
the class UseInFragmentActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_use_in_fragment);
mVpHome = (ViewPager) findViewById(R.id.vp_home);
mBottomNavigationBar = (BottomNavigationBar) findViewById(R.id.bottom_navigation_bar);
mBottomNavigationBar.addItem(new BottomNavigationItem(R.drawable.ic_favorite, "One")).addItem(new BottomNavigationItem(R.drawable.ic_gavel, "Two")).addItem(new BottomNavigationItem(R.drawable.ic_grade, "Three")).addItem(new BottomNavigationItem(R.drawable.ic_group_work, "Four")).initialise();
mBottomNavigationBar.setTabSelectedListener(new BottomNavigationBar.OnTabSelectedListener() {
@Override
public void onTabSelected(int position) {
mVpHome.setCurrentItem(position);
}
@Override
public void onTabUnselected(int position) {
}
@Override
public void onTabReselected(int position) {
}
});
mFragmentList.add(new ImageFragment());
mFragmentList.add(new SimpleFragment());
mFragmentList.add(new SimpleFragment());
mFragmentList.add(new SimpleFragment());
mVpHome.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
mBottomNavigationBar.selectTab(position);
switch(position) {
case 0:
break;
default:
Random random = new Random();
int color = 0xff000000 | random.nextInt(0xffffff);
if (mFragmentList.get(position) instanceof SimpleFragment) {
((SimpleFragment) mFragmentList.get(position)).setTvTitleBackgroundColor(color);
}
break;
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
mVpHome.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
@Override
public Fragment getItem(int position) {
return mFragmentList.get(position);
}
@Override
public int getCount() {
return mFragmentList.size();
}
});
}
Aggregations