android


Webservice call on current displayed fragment viewpager?


I have view pager with 5 fragments.
On all the fragments I have 5 different web services to call.
When the app is launched all the 5 fragments web services are triggered.
Where as only the current displayed fragment's web service should be called.
How to fix this? What is the solution for it?
private void setupViewPager(ViewPager viewPager) {
ViewPagerAdapter adapter = new ViewPagerAdapter(getChildFragmentManager());
adapter.addFragment(new AppFragment1());
adapter.addFragment(new AppFragment2());
adapter.addFragment(new AppFragment3());
adapter.addFragment(new AppFragment4());
adapter.addFragment(new AppFragment5());
viewPager.setAdapter(adapter);
}
class ViewPagerAdapter extends FragmentPagerAdapter {
private final List<Fragment> mFragmentList = new ArrayList<>();
public ViewPagerAdapter(FragmentManager manager) {
super(manager);
}
#Override
public Fragment getItem(int position) {
return mFragmentList.get(position);
}
#Override
public int getCount() {
return mFragmentList.size();
}
public void addFragment(Fragment fragment) {
mFragmentList.add(fragment);
}
#Override
public CharSequence getPageTitle(int position) {
return null;
}
}

Related Links

Set animation when change position viewpager with animation
How to set the notification just send once every year?
Android launch application with custom credentials
Android : library that download many sort of files
Leakcanary -can removing weak references helps to avoid memory leaks
How to stop an observable upon click in RxAndroid?
Galaxy S6 edge touchable area
Android Horizontal Bar Chart like the one in the image
Customize theme of a single Spinner
BottomNavigationView strange inner view
Using Switch to display output
How to collide with terrain of heightmap
how to remove exclamation sign in android project in eclipse?
Can multiple phones be connected to same Arduino via Bluetooth using MIT App Inventor?
Performing network calls in activity before creating fragment
Firebase database offline capability

Categories

HOME
shell
phantom-dsl
ggplot2
rdbms
edge
carousel
aws-cli
web-hosting
polling
mql5
pcl-crypto
categorical-data
heap
siddhi
why3
radgridview
flash-player
altera
glyphicons
html5-appcache
shortest-path
cfml
delphi-xe5
interpreter
delimiter
oculus
linked-data
tpm
comparable
iis-express
tizen-tv
eviews
send
postback
mailkit
github3.py
getlasterror
fiware-cygnus
reason
google-earth-engine
z-notation
resolution
odoo-website
datacachefactory
xbmc
gitlist
yii2-api
reportservice2010
facebook-pixel
openblas
wpas
git-flow
jtree
android-instrumentation
renaming
sandcastle
usart
ng-grid
http-status-code-401
hadoop-partitioning
ikiwiki
kendo-upload
cycle2
jaunt-api
linklabel
dllimport
binomial-theorem
sapscript
jdk1.7
pyobjc
aspectj-maven-plugin
mraid
xmltype
adehabitathr
entry-point
unix-socket
lnk
twitter-bootstrap-rails
notorm
hibernate-entitymanager
light
inputmismatchexception
ice-cube
mantle
saleslogix
database-create
fitbounds
cgimage
user-tracking
landscape-portrait
entitydatasource
rmdir
load-time
office-2007
nstokenfield
murmurhash
wcf-instancing
dojo-dnd
contentpresenter

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App