Commit e27b1a0d authored by 9731301's avatar 9731301

add duration with help of TimeAgo

parent dbb33fb2
......@@ -15,7 +15,10 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import com.example.mynotepad.MenuFeatures.CustomToolbarOption;
import com.example.mynotepad.MenuFeatures.CustomToolbarOptionListener;
......@@ -32,12 +35,15 @@ import java.util.ArrayList;
public class AudioListFragment extends Fragment {
private ConstraintLayout playerSheet;
private BottomSheetBehavior bottomSheetBehavior;
public static BottomSheetBehavior bottomSheetBehavior;
private RecyclerView recyclerViewRecordings;
private VoiceAdaptor recordingAdapter;
private ArrayList<MyVoice> myVoiceArrayList;
private CustomToolbarOption customToolbarOption;
private MyVoice myChosenVoice;
private ImageButton playerPlayBtn;
private TextView fileNameTv , headerTitleTv;
private SeekBar seekBar;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
......@@ -61,7 +67,10 @@ public class AudioListFragment extends Fragment {
customToolbarOption = v.findViewById(R.id.customToolbarOption);
customToolbarOption.setVisibility(View.GONE);
myVoiceArrayList = new ArrayList<>();
playerPlayBtn = v.findViewById(R.id.player_play_btn);
headerTitleTv = v.findViewById(R.id.player_header_title);
fileNameTv = v.findViewById(R.id.textView3);
seekBar = v.findViewById(R.id.seekBar);
recyclerViewRecordings = v.findViewById(R.id.recyclerView);
recyclerViewRecordings.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
......@@ -78,11 +87,11 @@ public class AudioListFragment extends Fragment {
for (int i = 0; i < files.length; i++) {
String fileName = files[i].getName();
String recordingUri = root.getAbsolutePath() + "/NotepadVoiceRecorder/Audios/" + fileName;
MyVoice myVoice = new MyVoice(recordingUri, fileName, false);
MyVoice myVoice = new MyVoice(recordingUri, fileName, false , files[i].lastModified());
myVoiceArrayList.add(myVoice);
}
}
recordingAdapter = new VoiceAdaptor(getContext(), myVoiceArrayList);
recordingAdapter = new VoiceAdaptor(getContext(), myVoiceArrayList , playerPlayBtn,fileNameTv , headerTitleTv , seekBar);
recyclerViewRecordings.setAdapter(recordingAdapter);
}
......
package com.example.mynotepad.MenuFeatures.VoiceMassages.VoiceMassagesRecyclerView;
public class MyVoice {
String Uri, fileName;
boolean isPlaying = false;
private String Uri, fileName;
private boolean isPlaying = false;
private long lastModified;
public MyVoice(String uri, String fileName, boolean isPlaying) {
public MyVoice(String uri, String fileName, boolean isPlaying , long lastModified) {
Uri = uri;
this.fileName = fileName;
this.isPlaying = isPlaying;
this.lastModified = lastModified;
}
public String getUri() {
......@@ -25,4 +27,8 @@ public class MyVoice {
public void setPlaying(boolean playing) {
this.isPlaying = playing;
}
public long getLastModified() {
return lastModified;
}
}
......@@ -5,7 +5,7 @@ import java.util.Date;
import java.util.concurrent.TimeUnit;
public class TimeAgo {
Date now = new Date();
private Date now = new Date();
public String getTimeAgo(long duration) {
long seconds = TimeUnit.MILLISECONDS.toSeconds(now.getTime() - duration);
......
<vector android:height="40dp" android:tint="#FFFFFF"
android:viewportHeight="24" android:viewportWidth="24"
android:width="40dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M6,19h4L10,5L6,5v14zM14,5v14h4L18,5h-4z"/>
</vector>
......@@ -92,7 +92,7 @@
android:id="@+id/player_play_btn"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginTop="28dp"
android:layout_marginTop="24dp"
android:background="#0035438C"
android:padding="5dp"
app:layout_constraintEnd_toEndOf="parent"
......@@ -127,6 +127,7 @@
app:srcCompat="@android:drawable/ic_media_ff" />
<SeekBar
android:id="@+id/seekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="20dp"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment