How to Add Like,Dislike button in video in android studio

 Add like and dislike button on video is a very popular function at this time, Let's add like, dislike button on the video, follow these steps:

                                                Create a new android project in android studio

                                                Type project name first_project

       How to create an android project in android studio

Add below code in AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.firstproject">

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />

<application
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.firstproject">
//Below activity name differ , as you type activity name during creating
//Below activity code is automatic generated
<activity android:name=".video_Player"/>
<activity android:name=".videos" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>


Add below code in project-level Gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.3"
classpath 'com.google.gms:google-services:4.3.10'

// classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'


// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
mavenLocal()

}
}

task clean(type: Delete) {
delete rootProject.buildDir
}


       Type below code in app-level Gradle

plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}

android {
compileSdkVersion 30
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "com.example.phoneauthentication"
minSdkVersion 19
targetSdkVersion 30
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {

implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
testImplementation 'junit:junit:'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation platform('com.google.firebase:firebase-bom:26.1.0')
implementation 'com.google.firebase:firebase-auth'

implementation 'com.github.joielechong:countrycodepicker:2.4.2'

implementation 'com.karumi:dexter:6.2.2'
implementation 'com.google.firebase:firebase-storage:20.0.0'
implementation 'com.google.firebase:firebase-messaging:22.0.0'
implementation 'com.firebaseui:firebase-ui-database:6.2.1'

implementation 'com.google.android.exoplayer:exoplayer:2.7.3'
implementation 'com.google.android.exoplayer:exoplayer-core:2.7.3'
implementation 'com.google.android.exoplayer:exoplayer-dash:2.7.3'
implementation 'com.google.android.exoplayer:exoplayer-hls:2.7.3'
implementation 'com.google.android.exoplayer:exoplayer-smoothstreaming:2.7.3'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.7.3'

implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'


}


Type below code in MainActivity.java

package com.example.first_project;

import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.SearchView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.ViewHolder;

import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.firebase.ui.database.FirebaseRecyclerAdapter;
import com.firebase.ui.database.FirebaseRecyclerOptions;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.android.material.snackbar.Snackbar;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.Query;
import com.google.firebase.messaging.FirebaseMessaging;

import java.util.HashMap;
import java.util.Random;

public class MainActivity extends AppCompatActivity {
RecyclerView recyclerView;
ProgressBar progressBar;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
recyclerView = findViewById(R.id.recyclerview);
progressBar = findViewById(R.id.mprogressbar);
recyclerView.setLayoutManager(new LinearLayoutManager(this));


FirebaseRecyclerOptions<songs> options = new FirebaseRecyclerOptions.Builder<songs>()
.setQuery(FirebaseDatabase.getInstance().getReference().child("Videos"), songs.class)
.build();
FirebaseRecyclerAdapter<songs, VideoViewHolder> firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<songs, VideoViewHolder>(options) {
@Override
protected void onBindViewHolder(@NonNull VideoViewHolder holder, int position, @NonNull songs model) {
holder.video_name.setText(model.getVideoname().toUpperCase());
String file = model.getVideourl();
String postkey = getRef(position).getKey();
assert postkey != null;
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
assert user != null;
String currentuser = user.getUid();
holder.setlikesbuttonstatus(postkey, currentuser);
holder.dislikebuttonstatus(postkey, currentuser);


// File mfile=new File(Environment.getExternalStorageDirectory()
// .getAbsolutePath());
// vh.new Compressvideo().execute("false",model.getVideourl(),mfile.getPath());

// vh.showVideo(getApplicationContext(), Uri.parse(model.getVideourl()));
Glide.with(getApplicationContext()).asBitmap().load(model.getVideourl()).into((holder).video_thumb);
holder.like_btn.setOnClickListener(v -> {
Toast.makeText(getApplicationContext(), "Play first", Toast.LENGTH_LONG).show();
});
holder.dislike_btn.setOnClickListener(v -> {
Toast.makeText(getApplicationContext(), "Play first", Toast.LENGTH_LONG).show();
});

holder.video_thumb.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String type=model.getSotype();
Intent intent = new Intent(MainActivity.this, video_Player.class);
intent.putExtra("path file", file);
intent.putExtra("song name", model.getVideoname());
intent.putExtra("song type",type);
intent.putExtra("postkey",postkey);
intent.putExtra("current user",currentuser);
startActivity(intent);


}
});
holder.video_name.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String type=model.getSotype();
Intent intent = new Intent(MainActivity.this, video_Player.class);
intent.putExtra("path file", file);
intent.putExtra("song name", model.getVideoname());
intent.putExtra("song type",type);
intent.putExtra("postkey",postkey);
intent.putExtra("current user",currentuser);
startActivity(intent);


}
});


}

@NonNull
@Override
public VideoViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
            //Create Layout Resource File type name singlerow
           // 
               View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.singlerow, parent, false);
return new VideoViewHolder(view);
}

};
firebaseRecyclerAdapter.startListening();
recyclerView.setAdapter(firebaseRecyclerAdapter);


}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
        //Create a new custom menu type name add_videos
        //How to create custom menu in android studio
getMenuInflater().inflate(R.menu.custom_menu, menu);
         //Type below code in add_videos
          /*
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/add_videos"
android:icon="@drawable/ic_baseline_add_circle_outline_24"
android:title="@string/add_song"
app:showAsAction="always"
/>

</menu>
*/
MenuItem searchItem = menu.findItem(R.id.add_videos);

return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
if(item.getItemId()==R.id.add_videos){
try {
pickvideo();
} catch (Exception e) {
e.printStackTrace();
}
}
return super.onOptionsItemSelected(item);
}

private void pickvideo() {
  //Create a new java addvideo
   //How to create a new java class in android studio

startActivity(new Intent(MainActivity.this, addvideo.class));
}

}


             
  
  

  
  
  
  
  
  
  Type below code in activity_main.xml
                                   <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:id="@+id/hindi_song"
android:layout_height="match_parent"
tools:context=".videos">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<ProgressBar
android:id="@+id/mprogressbar"
android:layout_width="123dp"
android:layout_height="74dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:layout_marginStart="124dp"
android:layout_marginTop="339dp"
android:layout_marginEnd="164dp"
android:layout_marginBottom="318dp"
android:foregroundGravity="center"
android:visibility="visible" />

</RelativeLayout>


Create a new activity Type name  video_Player

                                                    
                                                                               ↓

                                     Type below code in activity_video_player.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:id="@+id/Videoplayer"
android:layout_height="match_parent"
tools:context=".video_Player">


<com.google.android.exoplayer2.ui.PlayerView
android:layout_width="match_parent"
android:layout_height="260dp"
app:resize_mode="fit"
app:hide_on_touch="true"
app:show_timeout="5000"
app:surface_type="surface_view"
app:rewind_increment="10000"
app:fastforward_increment="10000"
app:use_controller="true"
app:player_layout_id="@layout/exo_simple_player_view"

app:controller_layout_id="@layout/custom_playback_view"
android:id="@+id/videoplayer"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/ldrecvi"
android:layout_width="match_parent"
android:layout_height="69dp"
android:layout_below="@id/video_name"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="0dp"
android:layout_marginTop="304dp" />

<ProgressBar
android:id="@+id/progress_bar"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginStart="170dp"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="130dp"
android:layout_marginEnd="171dp" />
<TextView
android:id="@+id/video_name"
android:layout_width="match_parent"
android:layout_marginTop="260dp"
android:textStyle="bold"
android:textSize="20sp"
android:text="@string/song_name"
android:layout_height="50dp"/>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rrecvi"
android:layout_width="match_parent"
android:layout_height="311dp"
android:layout_marginTop="421dp"
android:layout_below="@id/video_name" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

                              ↓                                       Type below code in video_player.java  

 package com.example.firstproject;

import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.content.pm.ActivityInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.firebase.ui.database.FirebaseRecyclerAdapter;
import com.firebase.ui.database.FirebaseRecyclerOptions;
import com.google.android.exoplayer2.DefaultLoadControl;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.LoadControl;
import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
import com.google.android.exoplayer2.extractor.ExtractorsFactory;
import com.google.android.exoplayer2.source.ExtractorMediaSource;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
import com.google.android.exoplayer2.trackselection.TrackSelector;
import com.google.android.exoplayer2.ui.PlayerView;
import com.google.android.exoplayer2.upstream.BandwidthMeter;
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory;
import com.google.android.material.snackbar.Snackbar;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.Query;
import com.google.firebase.database.ValueEventListener;

import java.util.Objects;

public class video_Player extends AppCompatActivity {
PlayerView playerView;
public SimpleExoPlayer simpleExoPlayer;
ProgressBar progressBar;
TextView mname;
RelativeLayout mprogress;
boolean flag=false;
boolean playcon=false;
FirebaseRecyclerAdapter<songs, RecyclerView.ViewHolder> mfirebaseRecyclerAdapter ;
String name ;
String path;
String type;
String postkey;
String currentuser;
RecyclerView ldrecyclerView,rrecyclerview;
CoordinatorLayout nhindi;
private static final int item_data = 0;
private static final int item_banner = 1;
boolean likechecker = false;
boolean dislikechecker = false;
ImageView like_btn, dislike_btn;
TextView like_text, dislike_text;

DatabaseReference searchDatabaseReference = FirebaseDatabase.getInstance().getReference();
DatabaseReference likereference = FirebaseDatabase.getInstance().getReference().child("Likes");
DatabaseReference dislikereference = FirebaseDatabase.getInstance().getReference().child("DisLikes");


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video__player);
progressBar = findViewById(R.id.progress_bar);
ldrecyclerView = (RecyclerView) findViewById(R.id.ldrecvi);
rrecyclerview = (RecyclerView) findViewById(R.id.rrecvi);
nhindi=findViewById(R.id.Videoplayer);
path = getIntent().getStringExtra("path file");
name = getIntent().getStringExtra("song name");
type = getIntent().getStringExtra("song type");
postkey = getIntent().getStringExtra("postkey");
currentuser = getIntent().getStringExtra("current user");

Objects.requireNonNull(getSupportActionBar()).hide();
playerView = (PlayerView) findViewById(R.id.videoplayer);
mname = findViewById(R.id.video_name);
like_btn = findViewById(R.id.like_symbol);
dislike_btn = findViewById(R.id.dislike_symbol);
like_text = findViewById(R.id.like_text);
dislike_text = findViewById(R.id.dislike_text);
ldrecyclerView.setLayoutManager(new LinearLayoutManager(this));
//Type name Videos same as when you upload video .
//How to Add video(Part-1) in FirebaseRecyclerAdapter in android studio

Query sQuery = searchDatabaseReference.child("Videos").orderByChild("videoname").equalTo(name);
FirebaseRecyclerOptions<songs> options = new FirebaseRecyclerOptions.Builder<songs>()
.setQuery(sQuery, songs.class)
.build();
  //Create a new java class type name songs ,if you do not create songs class
//Create a VideoViewHolder java class,if you do not create VideoViewHolder
//How to create a new java class in existing project in android studio
          FirebaseRecyclerAdapter<songs,VideoViewHolder> firebaseRecyclerAdapter=new FirebaseRecyclerAdapter<songs, VideoViewHolder>(options) {
              @Override
protected void onBindViewHolder(@NonNull VideoViewHolder holder, int position, @NonNull songs model) {
holder.setlikesbuttonstatus(postkey, currentuser);
holder.dislikebuttonstatus(postkey, currentuser);
holder.dislike_btn.setOnClickListener(v -> {

dislikechecker = true;
dislikereference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
// Object key=snapshot.getRef().getKey();
//String mykey=key.toString();
if (Objects.equals(dislikechecker, true)) {
assert postkey != null;
if (snapshot.child(postkey).hasChild(currentuser)) {
dislikereference.child(postkey).child(currentuser).removeValue();
/*Snackbar.make(mhindi, "Dislike removed", Snackbar.LENGTH_LONG)
.setAction("Close", v17 -> {

}).setActionTextColor(getResources().getColor(R.color.design_default_color_primary))
.show();*/

} else {
dislikereference.child(postkey).child(currentuser).setValue(true);
likereference.child(postkey).child(currentuser).removeValue();
/*Snackbar.make(mhindi, "You dislike this video", Snackbar.LENGTH_LONG)
.setAction("Close", new View.OnClickListener() {
@Override
public void onClick(View v17) {

}
}).setActionTextColor(getResources().getColor(R.color.design_default_color_primary))
.show();*/


}
dislikechecker = false;
}
}

@Override
public void onCancelled(@NonNull DatabaseError error) {

}
});

});

holder.like_btn.setOnClickListener(v -> {

likechecker = true;
likereference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
if (Objects.equals(likechecker, true)) {
// assert postkey != null;
if (snapshot.child(postkey).hasChild(currentuser)) {
likereference.child(postkey).child(currentuser).removeValue();
/*Snackbar.make(mhindi, "Remove from Liked videos", Snackbar.LENGTH_LONG)
.setAction("Close", v17 -> {

}).setActionTextColor(getResources().getColor(R.color.design_default_color_primary))
.show();*/


} else {
likereference.child(postkey).child(currentuser).setValue(true);
dislikereference.child(postkey).child(currentuser).removeValue();
/*Snackbar.make(mhindi, "Added to Liked videos", Snackbar.LENGTH_LONG)
.setAction("Close", v17 -> {

}).setActionTextColor(getResources().getColor(R.color.design_default_color_primary))
.show();*/


}
likechecker = false;
}
}

@Override
public void onCancelled(@NonNull DatabaseError error) {

}
});
});




}

@NonNull
@Override
public VideoViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.buttons, parent, false);
return new VideoViewHolder(view);
}
};
firebaseRecyclerAdapter.notifyDataSetChanged();
firebaseRecyclerAdapter.startListening();
ldrecyclerView.setAdapter(firebaseRecyclerAdapter);


// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
try {
Uri videourl = Uri.parse(path);
LoadControl loadControl = new DefaultLoadControl();
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelector trackSelector = new DefaultTrackSelector(new AdaptiveTrackSelection.Factory(bandwidthMeter));
simpleExoPlayer = ExoPlayerFactory.newSimpleInstance(video_Player.this, trackSelector, loadControl);
DefaultHttpDataSourceFactory factory = new DefaultHttpDataSourceFactory("exoplayer_video");
ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
MediaSource mediaSource = new ExtractorMediaSource(videourl, factory, extractorsFactory, null, null);
playerView.setPlayer(simpleExoPlayer);
playerView.setKeepScreenOn(true);
mname.setText(name);
simpleExoPlayer.prepare(mediaSource, true, false);
simpleExoPlayer.setPlayWhenReady(true);
// simpleExoPlayer.seekTo(currentWindow,playbackposition);
simpleExoPlayer.addListener(new Player.EventListener() {
@Override
public void onTimelineChanged(Timeline timeline, Object manifest, int reason) {

}

@Override
public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {

}

@Override
public void onLoadingChanged(boolean isLoading) {

}

@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
if (playbackState == Player.STATE_BUFFERING) {
progressBar.setVisibility(View.VISIBLE);
} else if (playbackState == Player.STATE_READY) {
progressBar.setVisibility(View.GONE);

}
}


@Override
public void onRepeatModeChanged(int repeatMode) {

}

@Override
public void onShuffleModeEnabledChanged(boolean shuffleModeEnabled) {

}

@RequiresApi(api = Build.VERSION_CODES.R)
@Override
public void onPlayerError(ExoPlaybackException error) {
simpleExoPlayer.stop();
}

@Override
public void onPositionDiscontinuity(int reason) {

}

@Override
public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {

}

@Override
public void onSeekProcessed() {

}
});
simpleExoPlayer.setPlayWhenReady(true);

} catch (Exception e) {
e.printStackTrace();
}
Query ssQuery = searchDatabaseReference.child("Videos").orderByChild("sotype").equalTo(type);
rrecyclerview.setLayoutManager(new LinearLayoutManager(video_Player.this));
FirebaseRecyclerOptions<songs> moptions = new FirebaseRecyclerOptions.Builder<songs>()
.setQuery(ssQuery, songs.class)
.build();
FirebaseRecyclerAdapter<songs,VideoViewHolder> firebaseRecyclerAdapter1=new FirebaseRecyclerAdapter<songs, VideoViewHolder>(moptions) {
@Override
protected void onBindViewHolder(@NonNull VideoViewHolder holder, int position, @NonNull songs model) {
holder.video_name.setText(model.getVideoname().toUpperCase()); Glide.with(getApplicationContext()).asBitmap().load(model.getVideourl()).into((holder).video_thumb);
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
assert user != null;
String currentuser = user.getUid();
String postkey = getRef(position).getKey();
String file = model.getVideourl();
holder.like_btn.setOnClickListener(v -> {
Toast.makeText(getApplicationContext(), "Play first", Toast.LENGTH_LONG).show();
});
holder.dislike_btn.setOnClickListener(v -> {
Toast.makeText(getApplicationContext(), "Play first", Toast.LENGTH_LONG).show();
});




}

@NonNull
@Override
public VideoViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.singlerow, parent, false);
return new VideoViewHolder(view);
}
};
// mfirebaseRecyclerAdapter = firebaseRecyclerAdapter;
firebaseRecyclerAdapter1.notifyDataSetChanged();
firebaseRecyclerAdapter1.startListening();
rrecyclerview.setAdapter(firebaseRecyclerAdapter1);

}
}
//Run and Play Video

  
  
  

  
  
  
  
  
  
  
  
  
  

Comments

Popular posts from this blog

How to authenticate mobile number in android studio

How to connect android project to Firebase

How to create a new activity in existing android project in android studio

How to Create a Custom menu in android studio

How to create android project in android studio

How to add(Part-2) Video in FirebaseRecyclerAdapter in android studio

How to download google-services.json file from firebase

How to create Layout Resource File in existing project in android studio

How to add Video(Part-1) in FirebaseRecyclerAdapter from Galllary..