Reputation: 113
I have an issue with progressbar's visibility. Basically,I am passing a intent from activity to another activity after startActivity(intent) line I am setting the visibility of progressbar to invisible.
While,doing this I noticed that progressbar got invisible too early. I need to fix this.
Thanks in advance.
my code is as below
public void GetUserProfileDetails() {
mLoginFrom = 1;
bearer = "Bearer " + mResponseAccessToken;
RestAdapter.Builder restAdapterBuilder = new RestAdapter.Builder();
if(BuildConfig.DEBUG)
{
restAdapterBuilder.setLogLevel(RestAdapter.LogLevel.FULL);
}
RestAdapter restDetailAdapter = restAdapterBuilder.setEndpoint(FBAPI).build();
// RestAdapter restDetailAdapter = new RestAdapter.Builder().setLogLevel(RestAdapter.LogLevel.FULL).setEndpoint(FBAPI).build();
fetch_profiledetails hit_api = restDetailAdapter.create(fetch_profiledetails.class);
hit_api.fetchProfileDetails(bearer, mSuperId, new Callback<FetchDetailsPojo>() {
@Override
public void success(FetchDetailsPojo fetchDetailsPojo, Response response) {
mIsnewUser = fetchDetailsPojo.getIsNew();
PreferenceManager.getDefaultSharedPreferences(MainLoginActivity.this).edit().putBoolean(mIsNewUserKey, mIsnewUser).commit();
is_pin = fetchDetailsPojo.getIsPin();
PreferenceManager.getDefaultSharedPreferences(MainLoginActivity.this).edit().putBoolean("isPin", is_pin).commit();
mUserUpdatedProfilePic = fetchDetailsPojo.getImageUrl();
PreferenceManager.getDefaultSharedPreferences(MainLoginActivity.this).edit().putString("mupdatedprofilepic", mUserUpdatedProfilePic).commit();
PreferenceManager.getDefaultSharedPreferences(MainLoginActivity.this).edit().putInt("login", mLoginFrom).commit();
// mLoginProgressBar.setVisibility(View.INVISIBLE);
//Intent intent = new Intent(MainLoginActivity.this,ActivityUserDetail.class);
if (mIsnewUser==true){
Intent intent = new Intent(MainLoginActivity.this, ActivityUserHistory.class);
startActivity(intent);
mProgressBarLayout.setVisibility(View.INVISIBLE);
}else {
finish();
Intent intentToMain = new Intent(MainLoginActivity.this, MainActivity.class);
startActivity(intentToMain);
mProgressBarLayout.setVisibility(View.INVISIBLE);
}
}
@Override
public void failure(RetrofitError error) {
mProgressBarLayout.setVisibility(View.INVISIBLE);
}
});
}
Upvotes: 0
Views: 154
Reputation: 156
Set progress bar invisible in onStop()
of Activity
:
progressBar.setVisibility(View.INVISIBLE)
If needed in a particular case put a flag while starting new Activity
and check that flag in onStop()
.
Upvotes: 1
Reputation: 849
one way is that using post delay
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
progressBar.setVisibility(View.INVISIBLE);
}
}, TIMEINMILISECONDS);
Upvotes: 0