My Relative layout has two child Rcyclerview (Invisible) and progressbar .
What i want is : Oncreate of layout , recyclerview to invisible and progress bar to show until AsyncTask(getting images from SD folder) completes and recyclerview visible and progressbar invisible .
What Happening is : My app not showing progressbar . And after asyctask completes , my recyclerview shows up .
XML :
 <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_below="@+id/view3">
                <android.support.v7.widget.RecyclerView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:paddingTop="5dp"
                    android:divider="@null"
                    android:visibility="invisible"
                    android:id="@+id/recycler_view_cameragallery"
                    android:dividerHeight="0dp"
                    android:fadingEdge="none" />
                <ProgressBar
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/progressBar_Gallery"
                    style="?android:attr/progressBarStyleLarge"
                    android:layout_centerInParent="true"
                    android:layout_gravity="center"
                    android:padding="12dp" />
            </RelativeLayout>
ActivityCode:
public View onCreateView(LayoutInflater inflater,@Nullable ViewGroup container,@Nullable Bundle savedInstanceState){
        View rootView=inflater.inflate(R.layout.camera_layout,container,false);
        rootView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
        ButterKnife.inject(this,rootView);
        init();
        initialise(rootView);
        initialiseListeners();
        listofImagesPath = new ArrayList<String>();
        new mediaScanAyscTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);}
AsyncTask
public class mediaScanAyscTask extends AsyncTask<Void,Void,Void>{
        @Override
        protected Void doInBackground(Void... params) {
            return null;
        }
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            adapter.clearApplications();
            galleryProgressBar.setVisibility(View.VISIBLE);
            galleryProgressBar.getIndeterminateDrawable().setColorFilter(Color.parseColor("#ff4081"), PorterDuff.Mode.MULTIPLY);
            cameraRecyclerView.setVisibility(View.INVISIBLE);
        }
        @Override
        protected void onPostExecute(Void aVoid) {
            listofImagesPath = RetriveCapturedImagePath();
            if(listofImagesPath!=null){
                adapter.addApplications(listofImagesPath);
            }
            galleryProgressBar.setVisibility(View.INVISIBLE);
            cameraRecyclerView.setVisibility(View.VISIBLE);
            super.onPostExecute(aVoid);
        }
    }
Please help me by highlighting where i got wrong .
In my case, the emulator had the Animations turned OFF in the Developer Mode and so I could not see the progress bar.
Make your layout gone rather than invisable
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With