progress bar loading time

1 have 1 button at the main xml which will link to another xml which include information from server. I include progress bar to avoid the blank screen while the system is loading the information. i already done the code as below but it's still not the things i wanted. the code below will "WAIT" for 1000 ms then only will execute the next code. how can i modify it so that the loading "WAIT TIME" will depends on the internet speed, if internet connection is slow, then the progress-bar-screen will show longer. 

    package com.android.myApps;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.os.Handler;
    import android.view.View;
    import android.widget.TextView;
    
    public class MainScr extends Activity {
    	
    	private final int WAIT_TIME = 1000;
    	
    	@Override
    	protected void onCreate(Bundle savedInstanceState)
    	{		
    		super.onCreate(savedInstanceState);		
    		setContentView(R.layout.MainScr);		
    	}	
    	
    	public void onClickCategory(View view)
        {
    		findViewById(R.id.mainSpinner1).setVisibility(View.VISIBLE);
        	new Handler().postDelayed(new Runnable(){
        		@Override
        		    public void run() {    			   		     
        	              Intent mainIntent = new Intent(MainScr.this, Category.class); 
        	              MainScr.this.startActivity(mainIntent); 
        	              MainScr.this.finish(); 
        	              } 
        		}, WAIT_TIME);
        }
    }
progress bar loading time
===


1 have 1 button at the main xml which will link to another xml which include information from server. I include progress bar to avoid the blank screen while the system is loading the information. i already done the code as below but it's still not the things i wanted. the code below will "WAIT" for 1000 ms then only will execute the next code. how can i modify it so that the loading "WAIT TIME" will depends on the internet speed, if internet connection is slow, then the progress-bar-screen will show longer. 

    package com.android.myApps;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.os.Handler;
    import android.view.View;
    import android.widget.TextView;
    
    public class MainScr extends Activity {
    	
    	private final int WAIT_TIME = 1000;
    	
    	@Override
    	protected void onCreate(Bundle savedInstanceState)
    	{		
    		super.onCreate(savedInstanceState);		
    		setContentView(R.layout.MainScr);		
    	}	
    	
    	public void onClickCategory(View view)
        {
    		findViewById(R.id.mainSpinner1).setVisibility(View.VISIBLE);
        	new Handler().postDelayed(new Runnable(){
        		@Override
        		    public void run() {    			   		     
        	              Intent mainIntent = new Intent(MainScr.this, Category.class); 
        	              MainScr.this.startActivity(mainIntent); 
        	              MainScr.this.finish(); 
        	              } 
        		}, WAIT_TIME);
        }
    }