diff --git a/app/src/main/java/com/example/saar/Video/VideosFragment.java b/app/src/main/java/com/example/saar/Video/VideosFragment.java index 7400a7a..b187cec 100644 --- a/app/src/main/java/com/example/saar/Video/VideosFragment.java +++ b/app/src/main/java/com/example/saar/Video/VideosFragment.java @@ -1,21 +1,29 @@ package com.example.saar.Video; +import android.content.Intent; +import android.net.Uri; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ImageView; import com.example.saar.R; public class VideosFragment extends Fragment { + ImageView video_1, video_2; + String video1Id= "1aW5r8-d2jQ"; + String video2Id = "WdR0v0pJ4vY"; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_videos, container, false); + View rootview = inflater.inflate(R.layout.fragment_videos, container, false); + video_1 = rootview.findViewById(R.id.video_1); + video_2 = rootview.findViewById(R.id.video_2); + return rootview; } @Override @@ -23,6 +31,27 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); //you can set the title for your toolbar here for different fragments different titles getActivity().setTitle(R.string.videos); + + video_1.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + openYoutube(video1Id); + } + }); + + video_2.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + openYoutube(video2Id); + } + }); + + + } + + public void openYoutube(String videoId){ + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube://" + videoId)); + startActivity(intent); } } diff --git a/app/src/main/res/drawable/video_img1.jpg b/app/src/main/res/drawable/video_img1.jpg new file mode 100644 index 0000000..8ab2d79 Binary files /dev/null and b/app/src/main/res/drawable/video_img1.jpg differ diff --git a/app/src/main/res/drawable/video_img2.jpg b/app/src/main/res/drawable/video_img2.jpg new file mode 100644 index 0000000..03c8337 Binary files /dev/null and b/app/src/main/res/drawable/video_img2.jpg differ diff --git a/app/src/main/res/layout/fragment_videos.xml b/app/src/main/res/layout/fragment_videos.xml index d3085a4..76555e9 100644 --- a/app/src/main/res/layout/fragment_videos.xml +++ b/app/src/main/res/layout/fragment_videos.xml @@ -3,13 +3,38 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" + android:orientation="vertical" android:background="@color/fragments_activities_background_color" tools:context=".Video.VideosFragment"> - <TextView + <ScrollView android:layout_width="match_parent" - android:layout_height="match_parent" - android:gravity="center" - android:text="Videos" /> + android:layout_height="match_parent"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + + <ImageView + android:id="@+id/video_1" + android:layout_width="@dimen/width_video" + android:layout_height="@dimen/height_video" + android:layout_gravity="center_horizontal" + android:src="@drawable/video_img1" + android:layout_marginTop="@dimen/margin_big" + android:textAlignment="center" /> + + <ImageView + android:id="@+id/video_2" + android:layout_width="@dimen/width_video" + android:layout_height="@dimen/height_video" + android:layout_gravity="center_horizontal" + android:src="@drawable/video_img2" + android:layout_marginTop="@dimen/margin_big" + android:textAlignment="center" /> + </LinearLayout> + + </ScrollView> </LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 4d47216..0ee4ae8 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -86,4 +86,8 @@ <!--Donate Page--> <dimen name="donate_padding">32dp</dimen> + <!-- Video Page--> + <dimen name="width_video">300dp</dimen> + <dimen name="height_video">190dp</dimen> + </resources> \ No newline at end of file