Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ProgressBar not showing

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 .

like image 290
young_08 Avatar asked May 17 '16 10:05

young_08


2 Answers

In my case, the emulator had the Animations turned OFF in the Developer Mode and so I could not see the progress bar.

like image 80
Prabin Timsina Avatar answered Oct 01 '22 06:10

Prabin Timsina


Make your layout gone rather than invisable

like image 30
J.D. Avatar answered Oct 01 '22 06:10

J.D.