Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.egi_fcb.applicationmtq.Package_Perintah_Sholat;
- import android.content.Context;
- import android.content.Intent;
- import android.graphics.Typeface;
- import android.media.MediaPlayer;
- import android.os.Bundle;
- import android.support.v7.widget.CardView;
- import android.support.v7.widget.RecyclerView;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.view.ViewGroup;
- import android.widget.ImageView;
- import android.widget.TextView;
- import com.example.egi_fcb.applicationmtq.MainActivity;
- import com.example.egi_fcb.applicationmtq.Package_Berwudhu.Activity_Berwudhu;
- import com.example.egi_fcb.applicationmtq.Package_Hijaiyah.ClickListener;
- import com.example.egi_fcb.applicationmtq.Package_Hijaiyah_Perkenalan.Activity_Hijaiyah;
- import com.example.egi_fcb.applicationmtq.Package_Hijaiyah_Perkenalan.Activity_Hijaiyah_Jelas;
- import com.example.egi_fcb.applicationmtq.Package_Kumpulan_Doa.Farsi;
- import com.example.egi_fcb.applicationmtq.Package_Surat_Pendek.Activity_Surat_Al_Falak;
- import com.example.egi_fcb.applicationmtq.R;
- import java.io.IOException;
- import java.util.List;
- /**
- * Created by egi_fcb on 5/18/17.
- */
- public class RecyclerViewAdapter_APS extends RecyclerView.Adapter<RecyclerViewAdapter_APS.RecyclerViewHolder> {
- private ClickListener clicklistener = null;
- List<Activity_Perintah_Sholat.User> values;
- Context context1;
- MediaPlayer mediaPlayer,mediaPlayer1,mediaPlayer2,mediaPlayer3,mediaPlayer4,mediaPlayer5,mediaPlayer6,mediaPlayer7,mediaPlayer8;
- public RecyclerViewAdapter_APS(Context context, List<Activity_Perintah_Sholat.User> userInformation) {
- context1 = context;
- this.values = userInformation;
- }
- @Override
- public RecyclerViewAdapter_APS.RecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
- View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.costum_activity_perintah_sholat, parent, false);
- return new RecyclerViewHolder(view);
- }
- @Override
- public void onBindViewHolder(final RecyclerViewAdapter_APS.RecyclerViewHolder holder, final int position) {
- Typeface tf = Farsi.GetFarsiFont(context1);
- holder.textayat.setTypeface(tf);
- holder.textjudul.setText(values.get(position).getJudul());
- holder.textayat.setText(values.get(position).getAyat());
- holder.textarti.setText(values.get(position).getArti());
- holder.cardView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (position == 0) {
- if (mediaPlayer1 != null) {
- mediaPlayer1.stop();
- }else if (mediaPlayer2 != null) {
- mediaPlayer2.stop();
- }
- if (mediaPlayer3 != null) {
- mediaPlayer3.stop();
- }
- if (mediaPlayer4 != null) {
- mediaPlayer4.stop();
- }
- if (mediaPlayer5 != null) {
- mediaPlayer5.stop();
- }
- if (mediaPlayer6 != null) {
- mediaPlayer6.stop();
- }
- if (mediaPlayer7 != null) {
- mediaPlayer7.stop();
- }
- if (mediaPlayer8 != null) {
- mediaPlayer8.stop();
- }
- if (mediaPlayer != null) {
- mediaPlayer.stop();
- }
- mediaPlayer = MediaPlayer.create(context1, R.raw.qs_al_baqarah_ayat_83);
- mediaPlayer.start();
- mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
- @Override
- public void onCompletion(MediaPlayer mp) {
- holder.cardView.setEnabled(true);
- }
- });
- }else if (position == 1) {
- if (mediaPlayer != null) {
- mediaPlayer.stop();
- }
- if (mediaPlayer2 != null) {
- mediaPlayer2.stop();
- }
- if (mediaPlayer3 != null) {
- mediaPlayer3.stop();
- }
- if (mediaPlayer4 != null) {
- mediaPlayer4.stop();
- }
- if (mediaPlayer5 != null) {
- mediaPlayer5.stop();
- }
- if (mediaPlayer6 != null) {
- mediaPlayer6.stop();
- }
- if (mediaPlayer7 != null) {
- mediaPlayer7.stop();
- }
- if (mediaPlayer8 != null) {
- mediaPlayer8.stop();
- }
- if (mediaPlayer1 != null) {
- mediaPlayer1.stop();
- }
- mediaPlayer1 = MediaPlayer.create(context1, R.raw.qs_al_baqarah_ayat_110);
- mediaPlayer1.start();
- mediaPlayer1.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
- @Override
- public void onCompletion(MediaPlayer mp) {
- holder.cardView.setEnabled(true);
- }
- });
- }else if (position == 2) {
- if (mediaPlayer1 != null) {
- mediaPlayer1.stop();
- }
- if (mediaPlayer != null) {
- mediaPlayer.stop();
- }
- if (mediaPlayer3 != null) {
- mediaPlayer3.stop();
- }
- if (mediaPlayer4 != null) {
- mediaPlayer4.stop();
- }
- if (mediaPlayer5 != null) {
- mediaPlayer5.stop();
- }
- if (mediaPlayer6 != null) {
- mediaPlayer6.stop();
- }
- if (mediaPlayer7 != null) {
- mediaPlayer7.stop();
- }
- if (mediaPlayer8 != null) {
- mediaPlayer8.stop();
- }
- if (mediaPlayer2 != null) {
- mediaPlayer2.stop();
- }
- mediaPlayer2 = MediaPlayer.create(context1, R.raw.qs_an_nisa_ayat_103);
- mediaPlayer2.start();
- mediaPlayer2.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
- @Override
- public void onCompletion(MediaPlayer mp) {
- holder.cardView.setEnabled(true);
- }
- });
- }else if (position == 3) {
- if (mediaPlayer1 != null) {
- mediaPlayer1.stop();
- }
- if (mediaPlayer2 != null) {
- mediaPlayer2.stop();
- }
- if (mediaPlayer != null) {
- mediaPlayer.stop();
- }
- if (mediaPlayer4 != null) {
- mediaPlayer4.stop();
- }
- if (mediaPlayer5 != null) {
- mediaPlayer5.stop();
- }
- if (mediaPlayer6 != null) {
- mediaPlayer6.stop();
- }
- if (mediaPlayer7 != null) {
- mediaPlayer7.stop();
- }
- if (mediaPlayer8 != null) {
- mediaPlayer8.stop();
- }
- if (mediaPlayer3 != null) {
- mediaPlayer3.stop();
- }
- mediaPlayer3= MediaPlayer.create(context1, R.raw.qs_hud_ayat_114);
- mediaPlayer3.start();
- mediaPlayer3.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
- @Override
- public void onCompletion(MediaPlayer mp) {
- holder.cardView.setEnabled(true);
- }
- });
- }else if (position == 4) {
- if (mediaPlayer1 != null) {
- mediaPlayer1.stop();
- }
- if (mediaPlayer2 != null) {
- mediaPlayer2.stop();
- }
- if (mediaPlayer3 != null) {
- mediaPlayer3.stop();
- }
- if (mediaPlayer != null) {
- mediaPlayer.stop();
- }
- if (mediaPlayer5 != null) {
- mediaPlayer5.stop();
- }
- if (mediaPlayer6 != null) {
- mediaPlayer6.stop();
- }
- if (mediaPlayer7 != null) {
- mediaPlayer7.stop();
- }
- if (mediaPlayer8 != null) {
- mediaPlayer8.stop();
- }
- if (mediaPlayer4 != null) {
- mediaPlayer4.stop();
- }
- mediaPlayer4 = MediaPlayer.create(context1, R.raw.qs_ibrahim_ayat_31);
- mediaPlayer4.start();
- mediaPlayer4.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
- @Override
- public void onCompletion(MediaPlayer mp) {
- holder.cardView.setEnabled(true);
- }
- });
- }else if (position == 5) {
- if (mediaPlayer1 != null) {
- mediaPlayer1.stop();
- }
- if (mediaPlayer2 != null) {
- mediaPlayer2.stop();
- }
- if (mediaPlayer3 != null) {
- mediaPlayer3.stop();
- }
- if (mediaPlayer4 != null) {
- mediaPlayer4.stop();
- }
- if (mediaPlayer != null) {
- mediaPlayer.stop();
- }
- if (mediaPlayer6 != null) {
- mediaPlayer6.stop();
- }
- if (mediaPlayer7 != null) {
- mediaPlayer7.stop();
- }
- if (mediaPlayer8 != null) {
- mediaPlayer8.stop();
- }
- if (mediaPlayer5 != null) {
- mediaPlayer5.stop();
- }
- mediaPlayer5 = MediaPlayer.create(context1, R.raw.qs_al_isra_ayat_78);
- mediaPlayer5.start();
- mediaPlayer5.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
- @Override
- public void onCompletion(MediaPlayer mp) {
- holder.cardView.setEnabled(true);
- }
- });
- }else if (position == 6) {
- if (mediaPlayer1 != null) {
- mediaPlayer1.stop();
- }
- if (mediaPlayer2 != null) {
- mediaPlayer2.stop();
- }
- if (mediaPlayer3 != null) {
- mediaPlayer3.stop();
- }
- if (mediaPlayer4 != null) {
- mediaPlayer4.stop();
- }
- if (mediaPlayer5 != null) {
- mediaPlayer5.stop();
- }
- if (mediaPlayer != null) {
- mediaPlayer.stop();
- }
- if (mediaPlayer7 != null) {
- mediaPlayer7.stop();
- }
- if (mediaPlayer8 != null) {
- mediaPlayer8.stop();
- }
- if (mediaPlayer6 != null) {
- mediaPlayer6.stop();
- }
- mediaPlayer6 = MediaPlayer.create(context1, R.raw.qs_taha_ayat_14);
- mediaPlayer6.start();
- mediaPlayer6.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
- @Override
- public void onCompletion(MediaPlayer mp) {
- holder.cardView.setEnabled(true);
- }
- });
- }else if (position == 7) {
- if (mediaPlayer1 != null) {
- mediaPlayer1.stop();
- }
- if (mediaPlayer2 != null) {
- mediaPlayer2.stop();
- }
- if (mediaPlayer3 != null) {
- mediaPlayer3.stop();
- }
- if (mediaPlayer4 != null) {
- mediaPlayer4.stop();
- }
- if (mediaPlayer5 != null) {
- mediaPlayer5.stop();
- }
- if (mediaPlayer6 != null) {
- mediaPlayer6.stop();
- }
- if (mediaPlayer != null) {
- mediaPlayer.stop();
- }
- if (mediaPlayer8 != null) {
- mediaPlayer8.stop();
- }
- if (mediaPlayer7 != null) {
- mediaPlayer7.stop();
- }
- mediaPlayer7 = MediaPlayer.create(context1, R.raw.qs_an_nur_ayat_56);
- mediaPlayer7.start();
- mediaPlayer7.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
- @Override
- public void onCompletion(MediaPlayer mp) {
- holder.cardView.setEnabled(true);
- }
- });
- }else if (position == 8) {
- if (mediaPlayer1 != null) {
- mediaPlayer1.stop();
- }
- if (mediaPlayer2 != null) {
- mediaPlayer2.stop();
- }
- if (mediaPlayer3 != null) {
- mediaPlayer3.stop();
- }
- if (mediaPlayer4 != null) {
- mediaPlayer4.stop();
- }
- if (mediaPlayer5 != null) {
- mediaPlayer5.stop();
- }
- if (mediaPlayer6 != null) {
- mediaPlayer6.stop();
- }
- if (mediaPlayer7 != null) {
- mediaPlayer7.stop();
- }
- if (mediaPlayer != null) {
- mediaPlayer.stop();
- }
- if (mediaPlayer8 != null) {
- mediaPlayer8.stop();
- }
- mediaPlayer8 = MediaPlayer.create(context1, R.raw.qs_luqman_ayat_17);
- mediaPlayer8.start();
- mediaPlayer8.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
- @Override
- public void onCompletion(MediaPlayer mp) {
- holder.cardView.setEnabled(true);
- }
- });
- }
- }
- });
- }
- @Override
- public int getItemCount() {
- return this.values.size();
- }
- public class RecyclerViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
- TextView textayat, textarti, textjudul;
- CardView cardView;
- public RecyclerViewHolder(View itemView) {
- super(itemView);
- cardView = (CardView) itemView.findViewById(R.id.cardView);
- textayat = (TextView) itemView.findViewById(R.id.textViewayat);
- textarti = (TextView) itemView.findViewById(R.id.textViewarti);
- textjudul = (TextView) itemView.findViewById(R.id.textViewjudul);
- }
- @Override
- public void onClick(View v) {
- if (clicklistener != null) {
- clicklistener.itemClicked(v, getAdapterPosition());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement