|
|
|
@ -7,7 +7,7 @@ import android.graphics.ColorMatrix
|
|
|
|
import android.graphics.ColorMatrixColorFilter
|
|
|
|
import android.graphics.ColorMatrixColorFilter
|
|
|
|
import android.os.Handler
|
|
|
|
import android.os.Handler
|
|
|
|
import android.os.Looper
|
|
|
|
import android.os.Looper
|
|
|
|
import android.util.Log
|
|
|
|
import android.text.format.DateUtils
|
|
|
|
import android.view.LayoutInflater
|
|
|
|
import android.view.LayoutInflater
|
|
|
|
import android.view.View
|
|
|
|
import android.view.View
|
|
|
|
import android.view.ViewGroup
|
|
|
|
import android.view.ViewGroup
|
|
|
|
@ -26,10 +26,9 @@ import com.google.android.material.button.MaterialButton
|
|
|
|
import com.google.android.material.card.MaterialCardView
|
|
|
|
import com.google.android.material.card.MaterialCardView
|
|
|
|
import com.squareup.picasso.Picasso
|
|
|
|
import com.squareup.picasso.Picasso
|
|
|
|
import java.io.File
|
|
|
|
import java.io.File
|
|
|
|
import java.text.DateFormat
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat
|
|
|
|
|
|
|
|
import java.util.*
|
|
|
|
import java.util.*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class HistoryAdapter(onItemClickListener: OnItemClickListener, activity: Activity) : ListAdapter<HistoryItem?, HistoryAdapter.ViewHolder>(AsyncDifferConfig.Builder(DIFF_CALLBACK).build()) {
|
|
|
|
class HistoryAdapter(onItemClickListener: OnItemClickListener, activity: Activity) : ListAdapter<HistoryItem?, HistoryAdapter.ViewHolder>(AsyncDifferConfig.Builder(DIFF_CALLBACK).build()) {
|
|
|
|
private val checkedItems: ArrayList<Long>
|
|
|
|
private val checkedItems: ArrayList<Long>
|
|
|
|
private val onItemClickListener: OnItemClickListener
|
|
|
|
private val onItemClickListener: OnItemClickListener
|
|
|
|
@ -88,22 +87,29 @@ class HistoryAdapter(onItemClickListener: OnItemClickListener, activity: Activit
|
|
|
|
|
|
|
|
|
|
|
|
// TIME DOWNLOADED ----------------------------------
|
|
|
|
// TIME DOWNLOADED ----------------------------------
|
|
|
|
val datetime = card.findViewById<TextView>(R.id.downloads_info_time)
|
|
|
|
val datetime = card.findViewById<TextView>(R.id.downloads_info_time)
|
|
|
|
val time = item.time
|
|
|
|
|
|
|
|
val downloadedTime: String
|
|
|
|
val relativeTime = DateUtils.getRelativeTimeSpanString(
|
|
|
|
if (time == 0L) {
|
|
|
|
item.time * 1000L,
|
|
|
|
downloadedTime = activity.getString(R.string.currently_downloading) + " " + item.type
|
|
|
|
System.currentTimeMillis(),
|
|
|
|
} else {
|
|
|
|
DateUtils.MINUTE_IN_MILLIS
|
|
|
|
val cal = Calendar.getInstance()
|
|
|
|
)
|
|
|
|
val date = Date(time * 1000L)
|
|
|
|
//
|
|
|
|
cal.time = date
|
|
|
|
// val time = item.time
|
|
|
|
val day = cal[Calendar.DAY_OF_MONTH]
|
|
|
|
// val downloadedTime: String
|
|
|
|
val month = cal.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.getDefault())
|
|
|
|
// if (time == 0L) {
|
|
|
|
val year = cal[Calendar.YEAR]
|
|
|
|
// downloadedTime = activity.getString(R.string.currently_downloading) + " " + item.type
|
|
|
|
val formatter: DateFormat = SimpleDateFormat("HH:mm", Locale.getDefault())
|
|
|
|
// } else {
|
|
|
|
val timeString = formatter.format(date)
|
|
|
|
// val cal = Calendar.getInstance()
|
|
|
|
downloadedTime = "$day $month $year - $timeString"
|
|
|
|
// val date = Date(time * 1000L)
|
|
|
|
}
|
|
|
|
// cal.time = date
|
|
|
|
datetime.text = downloadedTime
|
|
|
|
// val day = cal[Calendar.DAY_OF_MONTH]
|
|
|
|
|
|
|
|
// val month = cal.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.getDefault())
|
|
|
|
|
|
|
|
// val year = cal[Calendar.YEAR]
|
|
|
|
|
|
|
|
// val formatter: DateFormat = SimpleDateFormat("HH:mm", Locale.getDefault())
|
|
|
|
|
|
|
|
// val timeString = formatter.format(date)
|
|
|
|
|
|
|
|
// downloadedTime = "$day $month $year - $timeString"
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
datetime.text = relativeTime
|
|
|
|
|
|
|
|
|
|
|
|
// BUTTON ----------------------------------
|
|
|
|
// BUTTON ----------------------------------
|
|
|
|
val buttonLayout = card.findViewById<LinearLayout>(R.id.downloads_download_button_layout)
|
|
|
|
val buttonLayout = card.findViewById<LinearLayout>(R.id.downloads_download_button_layout)
|
|
|
|
|