Skip to content

Commit

Permalink
➕ Sample app depend Androidx
Browse files Browse the repository at this point in the history
  • Loading branch information
Flyge committed Oct 19, 2018
1 parent 879f533 commit 46b3008
Show file tree
Hide file tree
Showing 32 changed files with 96 additions and 338 deletions.
4 changes: 4 additions & 0 deletions build_kotlin.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

androidExtensions {
experimental = true
}

dependencies{
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$KOTLIN_VERSION"

Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ FFMPEG_MEDIA_METADATA_RETRIEVER_VERSION=1.0.14
EVENT_BUS_VERSION=3.0.0
RETROFIT_VERSION=2.3.0
LEAK_CANARY_ANDROID_VERSION=1.5
FLEXBOX=0.3.2
FLEXBOX=0.3.2
ANDROIDX=0.3.1
1 change: 0 additions & 1 deletion ktx/.gitignore

This file was deleted.

26 changes: 0 additions & 26 deletions ktx/build.gradle

This file was deleted.

21 changes: 0 additions & 21 deletions ktx/proguard-rules.pro

This file was deleted.

2 changes: 0 additions & 2 deletions ktx/src/main/AndroidManifest.xml

This file was deleted.

15 changes: 0 additions & 15 deletions ktx/src/main/java/me/panpf/ktx/Dimen.kt

This file was deleted.

84 changes: 0 additions & 84 deletions ktx/src/main/java/me/panpf/ktx/Toast.kt

This file was deleted.

11 changes: 0 additions & 11 deletions ktx/src/main/java/me/panpf/ktx/View.kt

This file was deleted.

35 changes: 0 additions & 35 deletions ktx/src/main/java/me/panpf/ktx/ViewModelBinder.kt

This file was deleted.

3 changes: 0 additions & 3 deletions ktx/src/main/res/values/strings.xml

This file was deleted.

4 changes: 3 additions & 1 deletion sample-video-thumbnail/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':sketch')
implementation project(':ktx')

implementation "com.android.support:appcompat-v7:${SUPPORT_VERSION}"
implementation "com.android.support:recyclerview-v7:${SUPPORT_VERSION}"
Expand All @@ -57,6 +56,9 @@ dependencies {
implementation "me.panpf:assembly-adapter:${ASSEMBLY_ADAPTER_VERSION}"
implementation "me.panpf:assembly-adapter-ktx:${ASSEMBLY_ADAPTER_VERSION}"
implementation "me.panpf:assembly-paged-list-adapter:${ASSEMBLY_ADAPTER_VERSION}"
implementation "me.panpf:androidx-kt:${ANDROIDX}"
implementation "me.panpf:androidx-kt-args:${ANDROIDX}"
implementation "me.panpf:androidx-kt-arch:${ANDROIDX}"

implementation "com.github.wseemann:FFmpegMediaMetadataRetriever:${FFMPEG_MEDIA_METADATA_RETRIEVER_VERSION}"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ package me.panpf.sketch.sample.vt.bean
import android.content.Context
import android.support.v7.util.DiffUtil
import android.text.format.Formatter
import java.text.SimpleDateFormat
import java.util.*
import me.panpf.javaxkt.util.formatYMDHM

class VideoInfo {
var title: String? = null
Expand All @@ -21,29 +20,22 @@ class VideoInfo {
val secondsRemaining = second % 60
val minute = second / 60
val builder = StringBuilder()
if (minute <= 0) {
builder.append("00")
} else if (minute < 10) {
builder.append("0" + minute)
} else {
builder.append(minute)
when {
minute <= 0 -> builder.append("00")
minute < 10 -> builder.append("0$minute")
else -> builder.append(minute)
}

builder.append(":")

if (secondsRemaining <= 0) {
builder.append("00")
} else if (secondsRemaining < 10) {
builder.append("0" + secondsRemaining)
} else {
builder.append(secondsRemaining)
when {
secondsRemaining <= 0 -> builder.append("00")
secondsRemaining < 10 -> builder.append("0$secondsRemaining")
else -> builder.append(secondsRemaining)
}
builder.toString()
}

val tempFormattedDate: String by lazy {
SimpleDateFormat("yyyy-MM-dd HH:mm").format(Date(date))
}
val tempFormattedDate: String by lazy { date.formatYMDHM() }

fun getTempFormattedSize(context: Context): String {
if (tempFormattedSize == null) {
Expand All @@ -57,12 +49,12 @@ class VideoInfo {
}

class DiffCallback : DiffUtil.ItemCallback<VideoInfo>() {
override fun areItemsTheSame(oldItem: VideoInfo?, newItem: VideoInfo?): Boolean {
override fun areItemsTheSame(oldItem: VideoInfo, newItem: VideoInfo): Boolean {
return oldItem == newItem
}

override fun areContentsTheSame(oldItem: VideoInfo?, newItem: VideoInfo?): Boolean {
return oldItem != null && newItem != null && oldItem.path.equals(newItem.path)
override fun areContentsTheSame(oldItem: VideoInfo, newItem: VideoInfo): Boolean {
return oldItem.path.equals(newItem.path)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class VideoListDataSource constructor(context: Context,
MediaStore.Video.Media.DURATION, MediaStore.Video.Media.DATE_TAKEN,
MediaStore.Video.Media.MIME_TYPE), null, null,
MediaStore.Video.Media.DATE_TAKEN + " DESC" + " limit " + startPosition + "," + pageSize)
val list = ArrayList<VideoInfo>(cursor.count)
val list = ArrayList<VideoInfo>(cursor?.count ?: 0)
cursor?.use {
while (cursor.moveToNext()) {
val video = VideoInfo()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import android.view.View
import androidx.core.view.setPadding
import kotlinx.android.synthetic.main.fragment_recycler.*
import me.panpf.adapter.paged.AssemblyPagedListAdapter
import me.panpf.ktx.bindViewModel
import me.panpf.ktx.dp2px
import me.panpf.ktx.longToast
import me.panpf.androidxkt.arch.bindViewModel
import me.panpf.androidxkt.util.dp2px
import me.panpf.androidxkt.widget.showLongToast
import me.panpf.sketch.sample.vt.BaseFragment
import me.panpf.sketch.sample.vt.BindContentView
import me.panpf.sketch.sample.vt.R
Expand All @@ -53,7 +53,7 @@ class VideoListFragment : BaseFragment() {
startActivity(intent)
} catch (e: Throwable) {
e.printStackTrace()
longToast("Not found can play video app")
showLongToast("Not found can play video app")
}
})
setMoreItem(LoadMoreItemFactory())
Expand All @@ -63,7 +63,7 @@ class VideoListFragment : BaseFragment() {
super.onViewCreated(view, savedInstanceState)

recyclerFragment_contentRecycler.apply {
setPadding(2.dp2px(checkNotNull(context)))
setPadding(checkNotNull(context).dp2px(2))
clipToPadding = false

layoutManager = LinearLayoutManager(activity)
Expand Down
4 changes: 3 additions & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ dependencies {
implementation "me.panpf:pager-indicator:${PAGER_INDICATOR}"
implementation "me.panpf:assembly-adapter:${ASSEMBLY_ADAPTER_VERSION}"
implementation "me.panpf:assembly-adapter-ktx:${ASSEMBLY_ADAPTER_VERSION}"
implementation "me.panpf:androidx-kt:${ANDROIDX}"
implementation "me.panpf:androidx-kt-args:${ANDROIDX}"
implementation "me.panpf:androidx-kt-arch:${ANDROIDX}"

implementation project(':sketch')
normalImplementation project(':sketch-gif')
implementation project(':ktx')

debugImplementation "com.squareup.leakcanary:leakcanary-android:${LEAK_CANARY_ANDROID_VERSION}"
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:${LEAK_CANARY_ANDROID_VERSION}"
Expand Down
4 changes: 1 addition & 3 deletions sample/src/main/java/me/panpf/sketch/sample/ImageOptions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ import me.panpf.sketch.shaper.RoundRectImageShaper
import me.panpf.sketch.state.DrawableStateImage
import me.panpf.sketch.state.OldStateImage
import me.panpf.sketch.util.SketchUtils
import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy

object ImageOptions {
/**
Expand Down Expand Up @@ -159,6 +157,6 @@ object ImageOptions {
}

@IntDef(RECT, CIRCULAR_STROKE, WINDOW_BACKGROUND, ROUND_RECT, LIST_FULL)
@Retention(RetentionPolicy.SOURCE)
@Retention(AnnotationRetention.SOURCE)
annotation class Type
}
Loading

0 comments on commit 46b3008

Please sign in to comment.