Position of progressbar











up vote
0
down vote

favorite
1












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










share|improve this question






















  • Please show what you have tried so far, so that can better understand your problem.
    – quant
    Nov 11 at 6:20















up vote
0
down vote

favorite
1












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










share|improve this question






















  • Please show what you have tried so far, so that can better understand your problem.
    – quant
    Nov 11 at 6:20













up vote
0
down vote

favorite
1









up vote
0
down vote

favorite
1






1





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










share|improve this question













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







android android-activity webview progress-bar tabbed






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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


















  • 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












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.





  1. 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








share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    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

























    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.





    1. 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








    share|improve this answer



























      up vote
      1
      down vote













      You can do this easily by following the below code and the important steps.





      1. 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








      share|improve this answer

























        up vote
        1
        down vote










        up vote
        1
        down vote









        You can do this easily by following the below code and the important steps.





        1. 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








        share|improve this answer














        You can do this easily by following the below code and the important steps.





        1. 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









        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 11 at 5:35

























        answered Nov 11 at 5:21









        hemandroid

        317




        317






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            List item for chat from Array inside array React Native

            Thiostrepton

            Caerphilly