-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from teresaholfeld/cleanup
Cleanup
- Loading branch information
Showing
15 changed files
with
572 additions
and
645 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,35 @@ | ||
apply plugin: 'com.android.application' | ||
apply plugin: 'kotlin-android' | ||
|
||
android { | ||
compileSdkVersion 28 | ||
buildToolsVersion '28.0.3' | ||
defaultConfig { | ||
applicationId "jp.shts.android.storyprogressbar" | ||
minSdkVersion 15 | ||
targetSdkVersion 28 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
compileSdkVersion 28 | ||
buildToolsVersion '28.0.3' | ||
defaultConfig { | ||
applicationId "com.teresaholfeld.stories.app" | ||
minSdkVersion 15 | ||
targetSdkVersion 28 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation project(':library') | ||
implementation 'com.android.support:appcompat-v7:28.0.0' | ||
implementation 'com.android.support.constraint:constraint-layout:1.1.3' | ||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { | ||
exclude group: 'com.android.support', module: 'support-annotations' | ||
}) | ||
implementation project(':library') | ||
implementation 'com.android.support:appcompat-v7:28.0.0' | ||
implementation 'com.android.support.constraint:constraint-layout:1.1.3' | ||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { | ||
exclude group: 'com.android.support', module: 'support-annotations' | ||
}) | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
} | ||
repositories { | ||
mavenCentral() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
app/src/main/java/com/teresaholfeld/stories/app/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package com.teresaholfeld.stories.app | ||
|
||
import android.os.Bundle | ||
import android.support.v7.app.AppCompatActivity | ||
import android.view.MotionEvent | ||
import android.view.View | ||
import android.view.WindowManager | ||
import android.widget.ImageView | ||
import com.teresaholfeld.stories.StoriesProgressView | ||
|
||
class MainActivity : AppCompatActivity(), StoriesProgressView.StoriesListener { | ||
|
||
private var storiesProgressView: StoriesProgressView? = null | ||
private var image: ImageView? = null | ||
|
||
private var counter = 0 | ||
private val resources = intArrayOf( | ||
R.drawable.sample1, | ||
R.drawable.sample2, | ||
R.drawable.sample3, | ||
R.drawable.sample4, | ||
R.drawable.sample5, | ||
R.drawable.sample6 | ||
) | ||
|
||
private val durations = longArrayOf(500L, 1000L, 1500L, 4000L, 5000L, 1000) | ||
|
||
private var pressTime = 0L | ||
private var limit = 500L | ||
|
||
private val onTouchListener = View.OnTouchListener { v, event -> | ||
when (event.action) { | ||
MotionEvent.ACTION_DOWN -> { | ||
pressTime = System.currentTimeMillis() | ||
storiesProgressView!!.pause() | ||
return@OnTouchListener false | ||
} | ||
MotionEvent.ACTION_UP -> { | ||
val now = System.currentTimeMillis() | ||
storiesProgressView!!.resume() | ||
return@OnTouchListener limit < now - pressTime | ||
} | ||
} | ||
false | ||
} | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN) | ||
setContentView(R.layout.activity_main) | ||
|
||
storiesProgressView = findViewById<View>(R.id.stories) as StoriesProgressView | ||
storiesProgressView!!.setStoriesCount(PROGRESS_COUNT) | ||
storiesProgressView!!.setStoryDuration(3000L) | ||
// or | ||
// storiesProgressView.setStoriesCountWithDurations(durations); | ||
storiesProgressView!!.setStoriesListener(this) | ||
// storiesProgressView.startStories(); | ||
counter = 2 | ||
storiesProgressView!!.startStories(counter) | ||
|
||
image = findViewById<View>(R.id.image) as ImageView | ||
image!!.setImageResource(resources[counter]) | ||
|
||
// bind reverse view | ||
val reverse = findViewById<View>(R.id.reverse) | ||
reverse.setOnClickListener { storiesProgressView!!.reverse() } | ||
reverse.setOnTouchListener(onTouchListener) | ||
|
||
// bind skip view | ||
val skip = findViewById<View>(R.id.skip) | ||
skip.setOnClickListener { storiesProgressView!!.skip() } | ||
skip.setOnTouchListener(onTouchListener) | ||
} | ||
|
||
override fun onNext() { | ||
image!!.setImageResource(resources[++counter]) | ||
} | ||
|
||
override fun onPrev() { | ||
if (counter - 1 < 0) return | ||
image!!.setImageResource(resources[--counter]) | ||
} | ||
|
||
override fun onComplete() {} | ||
|
||
override fun onDestroy() { | ||
// Very important ! | ||
storiesProgressView!!.destroy() | ||
super.onDestroy() | ||
} | ||
|
||
companion object { | ||
private const val PROGRESS_COUNT = 6 | ||
} | ||
} |
114 changes: 0 additions & 114 deletions
114
app/src/main/java/jp/shts/android/storyprogressbar/MainActivity.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.