package org.edx.mobile.view;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import org.edx.mobile.R;
import org.edx.mobile.model.course.CourseComponent;
import org.edx.mobile.model.course.VideoBlockModel;
import org.edx.mobile.util.AppConstants;

public class CourseUnitOnlyOnYoutubeFragment extends CourseUnitFragment {

    public static CourseUnitOnlyOnYoutubeFragment newInstance(CourseComponent unit) {
        final CourseUnitOnlyOnYoutubeFragment fragment = new CourseUnitOnlyOnYoutubeFragment();
        final Bundle args = new Bundle();
        args.putSerializable(Router.EXTRA_COURSE_UNIT, unit);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        final View view = inflater.inflate(R.layout.fragment_course_unit_only_on_youtube, container, false);
        if (environment.getConfig().getYoutubeInAppPlayerConfig().isYoutubeEnabled()) {
            ((TextView) view.findViewById(R.id.only_youtube_available_message)).setText(R.string.assessment_needed_updating_youtube);
            view.findViewById(R.id.update_youtube_button).setVisibility(View.VISIBLE);
            view.findViewById(R.id.update_youtube_button).setOnClickListener(v -> {
                final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(AppConstants.BROWSER_PLAYSTORE_YOUTUBE_URI));
                startActivity(intent);
            });
        }

        view.findViewById(R.id.view_on_youtube_button).setOnClickListener(v -> {
            final Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(((VideoBlockModel) unit).getData().encodedVideos.youtube.url));
            startActivity(intent);
        });

        return view;
    }
}

@@ -27,63 +27,8 @@
 w;%0A%0A
-import android.content.Intent;%0Aimport android.net.Uri;%0A
 impo
@@ -344,16 +344,56 @@
 nstants;
+%0Aimport org.edx.mobile.util.BrowserUtil;
 %0A%0Apublic
@@ -1604,71 +1604,40 @@
     
-final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(
+BrowserUtil.open(getActivity(), 
 AppC
@@ -1679,48 +1679,8 @@
 URI)
-);%0A                startActivity(intent)
 ;%0A  
@@ -1801,99 +1801,40 @@
     
-final Intent intent = new Intent(Intent.ACTION_VIEW);%0A            intent.setData(Uri.parse(
+BrowserUtil.open(getActivity(), 
 ((Vi
@@ -1894,44 +1894,8 @@
 url)
-);%0A            startActivity(intent)
 ;%0A  

Use BrowserUtil method