0% found this document useful (0 votes)
21 views8 pages

Task 11

Uploaded by

harshuajmire2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views8 pages

Task 11

Uploaded by

harshuajmire2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Task 11:- Image Slider and Video view

Build.gladle.kts:-
plugins {
alias(libs.plugins.android.application)

alias(libs.plugins.google.android.libraries.mapsplatform.secrets.gradle.plugi
n)
}

android {
namespace = "com.example.mytask1"
compileSdk = 34

defaultConfig {
applicationId = "com.example.mytask1"
minSdk = 24
targetSdk = 34
versionCode = 1
versionName = "1.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-
optimize.txt"), "proguard-rules.pro")
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
buildFeatures {
viewBinding = true
}
}

dependencies {

implementation(libs.appcompat)
implementation(libs.material)
implementation(libs.activity)
implementation(libs.constraintlayout)
implementation(libs.play.services.maps)
testImplementation(libs.junit)
androidTestImplementation(libs.ext.junit)
androidTestImplementation(libs.espresso.core)
implementation("com.airbnb.android:lottie:3.4.0")
implementation("com.github.denzcoskun:ImageSlideshow:0.1.2")
implementation ("com.github.denzcoskun:ImageSlideshow:0.1.2")

HomeFlagment.java:-
package com.example.mytask1;

import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import android.widget.VideoView;

import com.denzcoskun.imageslider.ImageSlider;
import com.denzcoskun.imageslider.constants.AnimationTypes;
import com.denzcoskun.imageslider.constants.ScaleTypes;
import com.denzcoskun.imageslider.interfaces.ItemClickListener;
import com.denzcoskun.imageslider.models.SlideModel;

import java.util.ArrayList;

public class HomeFragment extends Fragment {

ImageSlider imageSlider;
VideoFragment videoFragment = new VideoFragment();
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_home, container,
false);
imageSlider = view.findViewById(R.id.issHomeImageSlider);

ArrayList<SlideModel>slideModelArrayList = new ArrayList<>();


slideModelArrayList.add(new SlideModel(R.drawable.movie1,"AQUAMAN",
ScaleTypes.CENTER_CROP));
slideModelArrayList.add(new SlideModel(R.drawable.slide1,"Thor:Love
of Thunder", ScaleTypes.CENTER_CROP));
slideModelArrayList.add(new SlideModel(R.drawable.slide2,"",
ScaleTypes.CENTER_CROP));
slideModelArrayList.add(new SlideModel(R.drawable.slide3,"Bahubali",
ScaleTypes.CENTER_CROP));
slideModelArrayList.add(new SlideModel(R.drawable.slide4,"Avengers
End Game", ScaleTypes.CENTER_CROP));

imageSlider.setImageList(slideModelArrayList);
imageSlider.setSlideAnimation(AnimationTypes.ZOOM_IN);

imageSlider.setItemClickListener(new ItemClickListener() {
@Override
public void onItemSelected(int i) { if (i==0)
{

Toast.makeText(getContext(), "AQUAMAN", Toast.LENGTH_SHORT).show();

} if (i==1)
{

Toast.makeText(getContext(), "Thor:Love of Thunder",


Toast.LENGTH_SHORT).show();

} if (i==2)
{
Toast.makeText(getContext(), "Spider Man : No Way Home ",
Toast.LENGTH_SHORT).show();

}if (i==3)
{

Toast.makeText(getContext(), "Bahunali", Toast.LENGTH_SHORT).show();

}if (i==4)
{
Toast.makeText(getContext(), "Bahunali", Toast.LENGTH_SHORT).show();

getParentFragmentManager().beginTransaction().replace(R.id.homeFramelayout,
videoFragment)
.addToBackStack(null).commit();
}
}

@Override
public void doubleClick(int i) {

}
});
return view;
}
}

flagment_home:-
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".HomeFragment"
android:orientation="horizontal"
>

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"
android:scrollbars="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
app:cardElevation="5dp"
app:cardBackgroundColor="@color/lightwhite"
>

<com.denzcoskun.imageslider.ImageSlider
android:id="@+id/issHomeImageSlider"
android:layout_width="wrap_content"
android:layout_height="280dp"
android:layout_marginTop="20sp"
app:iss_auto_cycle="true"
app:iss_period="2000"
app:iss_delay="2000"
app:iss_text_align="CENTER"
app:iss_no_dots="false"
app:iss_selected_dot="@drawable/default_selected_dot"
app:iss_unselected_dot="@drawable/default_selected_dot"
app:iss_text_color="@color/white"

/>

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/movie1"
android:layout_marginTop="350sp"
android:layout_marginLeft="110dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AQUAMAN"
android:textSize="22dp"
android:layout_marginLeft="145dp"
android:layout_marginTop="630dp"
android:textColor="@color/black"
android:fontFamily="sans-serif-condensed"
android:textStyle="bold"/>

<ImageView
android:layout_width="188dp"
android:layout_height="wrap_content"
android:layout_marginLeft="110dp"
android:layout_marginTop="750dp"
android:src="@drawable/movie3" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Munjya"
android:textSize="22dp"
android:layout_marginLeft="170dp"
android:layout_marginTop="980dp"
android:textColor="@color/black"
android:fontFamily="sans-serif-condensed"
android:textStyle="bold"/>

<ImageView
android:layout_width="188dp"
android:layout_height="wrap_content"
android:layout_marginLeft="110dp"
android:layout_marginTop="1050dp"
android:src="@drawable/movie4" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Shaitaan"
android:textSize="22dp"
android:layout_marginLeft="170dp"
android:layout_marginTop="1335dp"
android:textColor="@color/black"
android:fontFamily="sans-serif-condensed"
android:textStyle="bold"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/movie2"
android:layout_marginTop="1410dp"
android:layout_marginLeft="110dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hanuman"
android:textSize="22dp"
android:layout_marginLeft="150dp"
android:layout_marginTop="1700dp"
android:textColor="@color/black"
android:fontFamily="sans-serif-condensed"
android:textStyle="bold"/>

</androidx.cardview.widget.CardView>
</LinearLayout>
</ScrollView>
</LinearLayout>

Videoflagment.java:-
package com.example.mytask1;

import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.MediaController;
import android.widget.VideoView;

public class VideoFragment extends Fragment {

VideoView videoView;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_video, container,
false);
videoView = view.findViewById(R.id.vvVideoVideo);

String videoPath =
"android.resource://"+getActivity().getPackageName()+"/raw/avenger";

videoView.setVideoPath(videoPath);
videoView.start();

MediaController mediaController = new MediaController(getActivity());


videoView.setMediaController(mediaController);

return view;

}
}

flagment_video:-
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".VideoFragment"
android:orientation="vertical"
>

<VideoView
android:id="@+id/vvVideoVideo"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"

/>
</LinearLayout>

Output:-

You might also like