Position of progressbar
up vote
0
down vote
favorite
I have successfully build a tabbed activity app with four tabs all working as expected. Each of tab load a web page. My problem is that I don't where to place the progressbar code for each tab some users will know that the page is loading.
Will the progressbar code be in mainactiviry of the code or each activity /fragment ?
I will appreciate all assistance and examples. Thanks in anticipation
add a comment |
up vote
0
down vote
favorite
I have successfully build a tabbed activity app with four tabs all working as expected. Each of tab load a web page. My problem is that I don't where to place the progressbar code for each tab some users will know that the page is loading.
Will the progressbar code be in mainactiviry of the code or each activity /fragment ?
I will appreciate all assistance and examples. Thanks in anticipation
Please show what you have tried so far, so that can better understand your problem.
– quant
Nov 11 at 6:20
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have successfully build a tabbed activity app with four tabs all working as expected. Each of tab load a web page. My problem is that I don't where to place the progressbar code for each tab some users will know that the page is loading.
Will the progressbar code be in mainactiviry of the code or each activity /fragment ?
I will appreciate all assistance and examples. Thanks in anticipation
I have successfully build a tabbed activity app with four tabs all working as expected. Each of tab load a web page. My problem is that I don't where to place the progressbar code for each tab some users will know that the page is loading.
Will the progressbar code be in mainactiviry of the code or each activity /fragment ?
I will appreciate all assistance and examples. Thanks in anticipation
asked Nov 11 at 3:45
Wed Nesday
1
1
Please show what you have tried so far, so that can better understand your problem.
– quant
Nov 11 at 6:20
add a comment |
Please show what you have tried so far, so that can better understand your problem.
– quant
Nov 11 at 6:20
Please show what you have tried so far, so that can better understand your problem.
– quant
Nov 11 at 6:20
Please show what you have tried so far, so that can better understand your problem.
– quant
Nov 11 at 6:20
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
You can do this easily by following the below code and the important steps.
First, create a NetworkUtils class and add the below code inside that class
public static NetworkUtils sNetworkUtils;
public static NetworkUtils getInstance() {
if (sNetworkUtils == null) {
sNetworkUtils = new NetworkUtils();
}
return sNetworkUtils;
}
public Boolean isNetworkAvailable(Context context) {
ConnectivityManager check = (ConnectivityManager) context.
getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = check.getAllNetworkInfo();
for (int i = 0; i < info.length; i++) {
if (info[i].getState() == NetworkInfo.State.CONNECTED) {
return true;
}
}
return false;
}
public static ProgressDialog getProgressDialog(Context context) {
return ProgressDialog.show(context, "", "Loading please wait..", true);
}
Here, what we are doing is! We are creating a global class and declaring the static methods. So, that it can be used anywhere in your entire project, but within the same package.
In the above code, we create a boolean method isNetworkAvailable, this method is used to check your network availability before making the API call. This approach is safe and sound to do network operations.
Use the below code to call those static methods to display a progress dialogue along with network checking.
if (NetworkUtils.getInstance().isNetworkAvailable(getApplicationContext())) {
mProgressDialog = NetworkUtils.getProgressDialog(LoginActivity.this);
loginAPI();
} else { Toast.makeText(getApplicationContext(),getString(R.string.no_network_message),
Toast.LENGTH_SHORT).show();
if (mProgressDialog != null) mProgressDialog.dismiss();
}
- In the above code snippet, we are using mProgressDialog. So initialize this mProgressDialog globally inside of your each and every fragment or Activity.
- In the place of loginAPI(), use your API call method.
- Inside of the API call, whether you are using the Volley or Retrofit. Use this method to disable the progress dialogue on failure or success of API call.
if (mProgressDialog != null) mProgressDialog.dismiss();
Please let me know, if you have any queries
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
You can do this easily by following the below code and the important steps.
First, create a NetworkUtils class and add the below code inside that class
public static NetworkUtils sNetworkUtils;
public static NetworkUtils getInstance() {
if (sNetworkUtils == null) {
sNetworkUtils = new NetworkUtils();
}
return sNetworkUtils;
}
public Boolean isNetworkAvailable(Context context) {
ConnectivityManager check = (ConnectivityManager) context.
getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = check.getAllNetworkInfo();
for (int i = 0; i < info.length; i++) {
if (info[i].getState() == NetworkInfo.State.CONNECTED) {
return true;
}
}
return false;
}
public static ProgressDialog getProgressDialog(Context context) {
return ProgressDialog.show(context, "", "Loading please wait..", true);
}
Here, what we are doing is! We are creating a global class and declaring the static methods. So, that it can be used anywhere in your entire project, but within the same package.
In the above code, we create a boolean method isNetworkAvailable, this method is used to check your network availability before making the API call. This approach is safe and sound to do network operations.
Use the below code to call those static methods to display a progress dialogue along with network checking.
if (NetworkUtils.getInstance().isNetworkAvailable(getApplicationContext())) {
mProgressDialog = NetworkUtils.getProgressDialog(LoginActivity.this);
loginAPI();
} else { Toast.makeText(getApplicationContext(),getString(R.string.no_network_message),
Toast.LENGTH_SHORT).show();
if (mProgressDialog != null) mProgressDialog.dismiss();
}
- In the above code snippet, we are using mProgressDialog. So initialize this mProgressDialog globally inside of your each and every fragment or Activity.
- In the place of loginAPI(), use your API call method.
- Inside of the API call, whether you are using the Volley or Retrofit. Use this method to disable the progress dialogue on failure or success of API call.
if (mProgressDialog != null) mProgressDialog.dismiss();
Please let me know, if you have any queries
add a comment |
up vote
1
down vote
You can do this easily by following the below code and the important steps.
First, create a NetworkUtils class and add the below code inside that class
public static NetworkUtils sNetworkUtils;
public static NetworkUtils getInstance() {
if (sNetworkUtils == null) {
sNetworkUtils = new NetworkUtils();
}
return sNetworkUtils;
}
public Boolean isNetworkAvailable(Context context) {
ConnectivityManager check = (ConnectivityManager) context.
getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = check.getAllNetworkInfo();
for (int i = 0; i < info.length; i++) {
if (info[i].getState() == NetworkInfo.State.CONNECTED) {
return true;
}
}
return false;
}
public static ProgressDialog getProgressDialog(Context context) {
return ProgressDialog.show(context, "", "Loading please wait..", true);
}
Here, what we are doing is! We are creating a global class and declaring the static methods. So, that it can be used anywhere in your entire project, but within the same package.
In the above code, we create a boolean method isNetworkAvailable, this method is used to check your network availability before making the API call. This approach is safe and sound to do network operations.
Use the below code to call those static methods to display a progress dialogue along with network checking.
if (NetworkUtils.getInstance().isNetworkAvailable(getApplicationContext())) {
mProgressDialog = NetworkUtils.getProgressDialog(LoginActivity.this);
loginAPI();
} else { Toast.makeText(getApplicationContext(),getString(R.string.no_network_message),
Toast.LENGTH_SHORT).show();
if (mProgressDialog != null) mProgressDialog.dismiss();
}
- In the above code snippet, we are using mProgressDialog. So initialize this mProgressDialog globally inside of your each and every fragment or Activity.
- In the place of loginAPI(), use your API call method.
- Inside of the API call, whether you are using the Volley or Retrofit. Use this method to disable the progress dialogue on failure or success of API call.
if (mProgressDialog != null) mProgressDialog.dismiss();
Please let me know, if you have any queries
add a comment |
up vote
1
down vote
up vote
1
down vote
You can do this easily by following the below code and the important steps.
First, create a NetworkUtils class and add the below code inside that class
public static NetworkUtils sNetworkUtils;
public static NetworkUtils getInstance() {
if (sNetworkUtils == null) {
sNetworkUtils = new NetworkUtils();
}
return sNetworkUtils;
}
public Boolean isNetworkAvailable(Context context) {
ConnectivityManager check = (ConnectivityManager) context.
getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = check.getAllNetworkInfo();
for (int i = 0; i < info.length; i++) {
if (info[i].getState() == NetworkInfo.State.CONNECTED) {
return true;
}
}
return false;
}
public static ProgressDialog getProgressDialog(Context context) {
return ProgressDialog.show(context, "", "Loading please wait..", true);
}
Here, what we are doing is! We are creating a global class and declaring the static methods. So, that it can be used anywhere in your entire project, but within the same package.
In the above code, we create a boolean method isNetworkAvailable, this method is used to check your network availability before making the API call. This approach is safe and sound to do network operations.
Use the below code to call those static methods to display a progress dialogue along with network checking.
if (NetworkUtils.getInstance().isNetworkAvailable(getApplicationContext())) {
mProgressDialog = NetworkUtils.getProgressDialog(LoginActivity.this);
loginAPI();
} else { Toast.makeText(getApplicationContext(),getString(R.string.no_network_message),
Toast.LENGTH_SHORT).show();
if (mProgressDialog != null) mProgressDialog.dismiss();
}
- In the above code snippet, we are using mProgressDialog. So initialize this mProgressDialog globally inside of your each and every fragment or Activity.
- In the place of loginAPI(), use your API call method.
- Inside of the API call, whether you are using the Volley or Retrofit. Use this method to disable the progress dialogue on failure or success of API call.
if (mProgressDialog != null) mProgressDialog.dismiss();
Please let me know, if you have any queries
You can do this easily by following the below code and the important steps.
First, create a NetworkUtils class and add the below code inside that class
public static NetworkUtils sNetworkUtils;
public static NetworkUtils getInstance() {
if (sNetworkUtils == null) {
sNetworkUtils = new NetworkUtils();
}
return sNetworkUtils;
}
public Boolean isNetworkAvailable(Context context) {
ConnectivityManager check = (ConnectivityManager) context.
getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = check.getAllNetworkInfo();
for (int i = 0; i < info.length; i++) {
if (info[i].getState() == NetworkInfo.State.CONNECTED) {
return true;
}
}
return false;
}
public static ProgressDialog getProgressDialog(Context context) {
return ProgressDialog.show(context, "", "Loading please wait..", true);
}
Here, what we are doing is! We are creating a global class and declaring the static methods. So, that it can be used anywhere in your entire project, but within the same package.
In the above code, we create a boolean method isNetworkAvailable, this method is used to check your network availability before making the API call. This approach is safe and sound to do network operations.
Use the below code to call those static methods to display a progress dialogue along with network checking.
if (NetworkUtils.getInstance().isNetworkAvailable(getApplicationContext())) {
mProgressDialog = NetworkUtils.getProgressDialog(LoginActivity.this);
loginAPI();
} else { Toast.makeText(getApplicationContext(),getString(R.string.no_network_message),
Toast.LENGTH_SHORT).show();
if (mProgressDialog != null) mProgressDialog.dismiss();
}
- In the above code snippet, we are using mProgressDialog. So initialize this mProgressDialog globally inside of your each and every fragment or Activity.
- In the place of loginAPI(), use your API call method.
- Inside of the API call, whether you are using the Volley or Retrofit. Use this method to disable the progress dialogue on failure or success of API call.
if (mProgressDialog != null) mProgressDialog.dismiss();
Please let me know, if you have any queries
edited Nov 11 at 5:35
answered Nov 11 at 5:21
hemandroid
317
317
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245660%2fposition-of-progressbar%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please show what you have tried so far, so that can better understand your problem.
– quant
Nov 11 at 6:20