Skip to content

Commit

Permalink
feat: Add videos of saar (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
atm1504 authored Jun 15, 2019
1 parent 7f39d01 commit 55190d6
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 6 deletions.
33 changes: 31 additions & 2 deletions app/src/main/java/com/example/saar/Video/VideosFragment.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,57 @@
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
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);
}

}
Binary file added app/src/main/res/drawable/video_img1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/video_img2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 29 additions & 4 deletions app/src/main/res/layout/fragment_videos.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
4 changes: 4 additions & 0 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

0 comments on commit 55190d6

Please sign in to comment.