Skip to content

Commit

Permalink
Finished library and added demo
Browse files Browse the repository at this point in the history
  • Loading branch information
mecoFarid committed Feb 28, 2023
1 parent e2ec673 commit dee38cd
Show file tree
Hide file tree
Showing 39 changed files with 156 additions and 624 deletions.
4 changes: 2 additions & 2 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 9 additions & 15 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ plugins {
}

android {
compileSdk 31
compileSdk 33

defaultConfig {
applicationId "com.mecofarid.timelineview.demo"
minSdk 21
targetSdk 31
targetSdk 33
versionCode 1
versionName "1.0"

Expand All @@ -35,19 +35,13 @@ android {
}

dependencies {

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.navigation:navigation-fragment-ktx:2.4.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.4.0'
implementation project(":timelineview")
implementation 'com.google.android.exoplayer:exoplayer-core:2.16.1'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.16.1'
implementation 'com.github.bumptech.glide:glide:4.13.0'
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.android.exoplayer:exoplayer-core:2.18.3'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.18.3'
implementation 'com.github.bumptech.glide:glide:4.14.2'
annotationProcessor 'com.github.bumptech.glide:compiler:4.13.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
9 changes: 2 additions & 7 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.MaterialComponents.DayNight.DarkActionBar">
<activity
android:name="com.mecofarid.VideoActivity"
android:exported="true" >
</activity>
android:theme="@style/Theme.MaterialComponents.DayNight.NoActionBar">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name">
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Binary file modified app/src/main/assets/video.mp4
Binary file not shown.
91 changes: 0 additions & 91 deletions app/src/main/java/com/mecofarid/VideoActivity.kt

This file was deleted.

68 changes: 38 additions & 30 deletions app/src/main/java/com/mecofarid/timelineview/demo/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,60 +1,43 @@
package com.mecofarid.timelineview.demo

import android.net.Uri
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.google.android.exoplayer2.ExoPlayer
import com.mecofarid.timelineview.TimelineView
import com.mecofarid.timelineview.demo.databinding.ActivityMainBinding
import kotlin.random.Random
import com.mecofarid.timelineview.demo.step.RECYCLERVIEW_CACHE_SIZE
import com.mecofarid.timelineview.demo.step.StepView
import com.mecofarid.timelineview.demo.step.TestStepAdapter
import com.mecofarid.timelineview.demo.step.VideoStepView
import com.mecofarid.timelineview.demo.step.VideoTestStep

class MainActivity : AppCompatActivity() {

private lateinit var binding: ActivityMainBinding

private val player: Lazy<ExoPlayer> = lazy {
ExoPlayer.Builder(this)
.setSeekBackIncrementMs(SEEK_INCREMENT)
.setSeekForwardIncrementMs(SEEK_INCREMENT)
.build()
}


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)

val middleCount = 12
val typeStatePairList = mutableListOf<Pair<TimelineView.Type, TimelineView.State>>()
typeStatePairList.add(Pair(TimelineView.Type.START, TimelineView.State.INACTIVE))
for (i in 1..middleCount){
typeStatePairList.add(Pair(TimelineView.Type.MIDDLE, TimelineView.State.INACTIVE))
}
typeStatePairList.add(Pair(TimelineView.Type.END, TimelineView.State.INACTIVE))
setupSteps()
}

val itemViewList = mutableListOf<TestStepView<*,*>>()
typeStatePairList.forEach {
if (false)
itemViewList.add(TextTestStepView(TextTestStep(type = it.first, state = it.second)))
else
itemViewList.add(
VideoTestStepView(
testStep = VideoTestStep(
type = it.first,
state = it.second,
videoPath = "file:///android_asset/video.mp4"
),
player
)
)
}
private fun setupSteps(){
val itemViewList = createSteps()
val adapter = TestStepAdapter(context = this, itemViewList, player)
var position = 0
binding.fab.setOnClickListener {
if (position < middleCount + 2)
adapter.stepIn(position)
if (position > itemViewList.lastIndex)
return@setOnClickListener

adapter.stepIn(position)
position++
}

Expand All @@ -65,6 +48,31 @@ class MainActivity : AppCompatActivity() {
}
}

private fun createSteps(): List<StepView<*, *>> {
val middleCount = 12
val typeStatePairList = mutableListOf<Pair<TimelineView.Type, TimelineView.State>>()
typeStatePairList.add(Pair(TimelineView.Type.START, TimelineView.State.INACTIVE))
for (i in 1..middleCount){
typeStatePairList.add(Pair(TimelineView.Type.MIDDLE, TimelineView.State.INACTIVE))
}
typeStatePairList.add(Pair(TimelineView.Type.END, TimelineView.State.INACTIVE))

val itemViewList = mutableListOf<StepView<*, *>>()
typeStatePairList.forEach {
itemViewList.add(
VideoStepView(
testStep = VideoTestStep(
type = it.first,
state = it.second,
videoPath = "file:///android_asset/video.mp4"
),
player
)
)
}
return itemViewList
}

override fun onDestroy() {
super.onDestroy()
player.value.apply {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mecofarid.timelineview.demo
package com.mecofarid.timelineview.demo.step

import com.mecofarid.timelineview.TimelineView

Expand Down
Loading

0 comments on commit dee38cd

Please sign in to comment.