M
M
MVBWAW212021-06-11 15:59:22
Java
MVBWAW21, 2021-06-11 15:59:22

Fragment progressbar invisible?

I have an activity in which I open a fragment that shows streaming video. I want to show a progressbar when opening this video while the video is loading. I added a progressbar and it works as I need but when I click on the screen it completely reloads the fragment and the streaming video starts again. The question is how can I hide the progressbar after loading so that it does not update the fragment again.

@Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
       // return super.onCreateView(inflater, container, savedInstanceState);
    hideStatusBar();
        View rootView = inflater.inflate(R.layout.fragmentvideo, container, false);
        mTextureView = (TextureView) rootView.findViewById(R.id.camera_viewer);
        FrameLayout parentLayout = (FrameLayout)rootView. findViewById(R.id.camera_view_frame);
        ProgressBar progressBar = (ProgressBar) rootView.findViewById(R.id.progressBar);
        TextView backTextView = (TextView)rootView.findViewById(R.id.camera_view_back);
        backTextView.setTypeface(font);
        backTextView.setText(getActivity().getString(R.string.fa_arrow_back_icon));
        backTextView.setClickable(true);
        backTextView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                closefragment();
            }
        });
   progressBar.setVisibility(ProgressBar.VISIBLE);
        videoRect = new Rect();
        Bundle bundle = this.getArguments();
        if (getArguments() != null) {
            CameraList cameralist = getArguments().getParcelable("cameras_list");
            String uri_video1= cameralist.getUri();
            String display_name1 = cameralist.getDisplay_name();
            Log.e(TAG, "sss--->"+uri_video1+display_name1);
        }
        progressBar.setVisibility(ProgressBar.VISIBLE);
        if (uri_video != null &&  display_name !=null) {
            videoUri = uri_video;
            Log.d(TAG, "Video uri: " + videoUri);
            try {
                setMode(FragmentVideo.Mode.VIDEO);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        else {
            try {
                setMode(FragmentVideo.Mode.VIDEO_ERROR);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return rootView;
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question