├── .gitignore
├── README.md
├── app
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── pl
│ │ └── kitek
│ │ └── gallery
│ │ ├── App.kt
│ │ ├── data
│ │ ├── DataSource.kt
│ │ └── GalleryItem.kt
│ │ └── ui
│ │ ├── ImageActivity.kt
│ │ ├── MainActivity.kt
│ │ ├── adapter
│ │ ├── ImageGridAdapter.kt
│ │ └── ImagePagerAdapter.kt
│ │ └── view
│ │ └── AspectRatioImageView.kt
│ └── res
│ ├── layout
│ ├── activity_gallery.xml
│ └── activity_main.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-mdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.png
│ └── ic_launcher_round.png
│ ├── values-v21
│ ├── bools.xml
│ └── styles.xml
│ └── values
│ ├── bools.xml
│ ├── colors.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── img
└── 76Zrp8.gif
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # Intellij
36 | *.iml
37 | .idea/
38 |
39 | # Keystore files
40 | *.jks
41 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # android-gallery
2 |
3 | Shared element transition example with RecyclerView and ViewPager.
4 |
5 | 
6 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 |
5 | android {
6 | compileSdkVersion 25
7 | buildToolsVersion "25.0.3"
8 | defaultConfig {
9 | applicationId "pl.kitek.gallery"
10 | minSdkVersion 16
11 | targetSdkVersion 25
12 | versionCode 1
13 | versionName "1.0"
14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | }
23 |
24 | androidExtensions {
25 | experimental = true
26 | }
27 |
28 | dependencies {
29 | compile fileTree(dir: 'libs', include: ['*.jar'])
30 |
31 | compile 'com.android.support:appcompat-v7:25.3.1'
32 | compile 'com.android.support:recyclerview-v7:25.3.1'
33 | compile 'com.squareup.picasso:picasso:2.5.2'
34 | compile 'com.jakewharton.timber:timber:4.5.1'
35 |
36 | compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
37 | }
38 | repositories {
39 | mavenCentral()
40 | }
41 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/kitek/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/java/pl/kitek/gallery/App.kt:
--------------------------------------------------------------------------------
1 | package pl.kitek.gallery
2 |
3 | import android.app.Application
4 | import timber.log.Timber
5 |
6 | class App : Application() {
7 |
8 | override fun onCreate() {
9 | super.onCreate()
10 | if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree())
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/java/pl/kitek/gallery/data/DataSource.kt:
--------------------------------------------------------------------------------
1 | package pl.kitek.gallery.data
2 |
3 | object DataSource {
4 | val ITEMS = listOf(
5 | GalleryItem(1, "https://scontent-waw1-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/c0.135.1080.1080/18013872_288536731586657_5612673016283529216_n.jpg", "https://scontent-waw1-1.cdninstagram.com/t51.2885-15/e35/18013872_288536731586657_5612673016283529216_n.jpg"),
6 | GalleryItem(2, "https://scontent-waw1-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/17934699_280999612324497_650897260007129088_n.jpg", "https://scontent-waw1-1.cdninstagram.com/t51.2885-15/e35/17934699_280999612324497_650897260007129088_n.jpg"),
7 | GalleryItem(3, "https://scontent-waw1-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/17076375_1872277209709531_2063681319862272000_n.jpg", "https://instagram.fwaw3-1.fna.fbcdn.net/t51.2885-15/e35/17076375_1872277209709531_2063681319862272000_n.jpg"),
8 | GalleryItem(4, "http://img4.garnek.pl/amin.garnek.pl/031/020/31020757_200.0.jpg", "http://img4.garnek.pl/a.garnek.pl/031/020/31020757_800.0.jpg/dexter.jpg"),
9 | GalleryItem(5, "https://scontent-waw1-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/17437692_1876320475976725_4049229896050802688_n.jpg", "https://scontent-waw1-1.cdninstagram.com/t51.2885-15/e35/17437692_1876320475976725_4049229896050802688_n.jpg"),
10 | GalleryItem(6, "https://scontent-waw1-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/17268188_1837956546454261_7231620059012005888_n.jpg", "https://scontent-waw1-1.cdninstagram.com/t51.2885-15/e35/17268188_1837956546454261_7231620059012005888_n.jpg"),
11 | GalleryItem(7, "https://scontent-waw1-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/17333058_141271439729879_7742634108248915968_n.jpg", "https://scontent-waw1-1.cdninstagram.com/t51.2885-15/e35/17333058_141271439729879_7742634108248915968_n.jpg"),
12 | GalleryItem(8, "https://scontent-waw1-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/17076675_1838152899767537_7940441863608074240_n.jpg", "https://scontent-waw1-1.cdninstagram.com/t51.2885-15/e35/17076675_1838152899767537_7940441863608074240_n.jpg")
13 | )
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/java/pl/kitek/gallery/data/GalleryItem.kt:
--------------------------------------------------------------------------------
1 | package pl.kitek.gallery.data
2 |
3 | data class GalleryItem(
4 | val id: Int,
5 | val thumbnailURL: String,
6 | val fullURL: String) {
7 |
8 | companion object {
9 | fun transitionName(id: Int) = "item_$id"
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/java/pl/kitek/gallery/ui/ImageActivity.kt:
--------------------------------------------------------------------------------
1 | package pl.kitek.gallery.ui
2 |
3 | import android.app.Activity
4 | import android.content.Intent
5 | import android.os.Bundle
6 | import android.support.v4.app.ActivityCompat
7 | import android.support.v4.app.SharedElementCallback
8 | import android.support.v4.view.ViewCompat
9 | import android.support.v4.view.ViewPager
10 | import android.support.v7.app.AppCompatActivity
11 | import android.view.MenuItem
12 | import android.view.View
13 | import kotlinx.android.synthetic.main.activity_gallery.*
14 | import pl.kitek.gallery.R
15 | import pl.kitek.gallery.data.DataSource
16 | import pl.kitek.gallery.ui.MainActivity.Companion.EXTRA_CURRENT_ALBUM_POSITION
17 | import pl.kitek.gallery.ui.MainActivity.Companion.EXTRA_STARTING_ALBUM_POSITION
18 | import pl.kitek.gallery.ui.adapter.ImagePagerAdapter
19 |
20 | class ImageActivity : AppCompatActivity() {
21 |
22 | private var isReturning: Boolean = false
23 | private var startingPosition: Int = 0
24 | private var currentPosition: Int = 0
25 | private var imagePagerAdapter: ImagePagerAdapter? = null
26 |
27 | private val enterElementCallback: SharedElementCallback = object : SharedElementCallback() {
28 | override fun onMapSharedElements(names: MutableList, sharedElements: MutableMap) {
29 | if (isReturning) {
30 | val sharedElement = imagePagerAdapter?.getView(currentPosition)
31 |
32 | if (startingPosition != currentPosition) {
33 | names.clear()
34 | names.add(ViewCompat.getTransitionName(sharedElement))
35 |
36 | sharedElements.clear()
37 | sharedElements.put(ViewCompat.getTransitionName(sharedElement), sharedElement!!)
38 | }
39 | }
40 | }
41 | }
42 |
43 | override fun onCreate(savedInstanceState: Bundle?) {
44 | super.onCreate(savedInstanceState)
45 | setContentView(R.layout.activity_gallery)
46 | ActivityCompat.postponeEnterTransition(this)
47 | ActivityCompat.setEnterSharedElementCallback(this, enterElementCallback)
48 | setupToolBar()
49 |
50 | val index = DataSource.ITEMS.indexOfFirst { it.id == intent.getIntExtra(ITEM_ID, 0) }
51 | startingPosition = if (index > 0) index else 0
52 | currentPosition = savedInstanceState?.getInt(SAVED_CURRENT_PAGE_POSITION) ?: startingPosition
53 |
54 | imagePagerAdapter = ImagePagerAdapter(this, DataSource.ITEMS, currentPosition)
55 | viewPager.adapter = imagePagerAdapter
56 | viewPager.currentItem = currentPosition
57 | viewPager.addOnPageChangeListener(object : ViewPager.SimpleOnPageChangeListener() {
58 | override fun onPageSelected(position: Int) {
59 | currentPosition = position
60 | }
61 | })
62 | }
63 |
64 | override fun onSaveInstanceState(outState: Bundle?) {
65 | super.onSaveInstanceState(outState)
66 | outState?.putInt(SAVED_CURRENT_PAGE_POSITION, currentPosition)
67 | }
68 |
69 | override fun finishAfterTransition() {
70 | isReturning = true
71 | val data = Intent()
72 | data.putExtra(EXTRA_STARTING_ALBUM_POSITION, startingPosition)
73 | data.putExtra(EXTRA_CURRENT_ALBUM_POSITION, currentPosition)
74 | setResult(Activity.RESULT_OK, data)
75 | super.finishAfterTransition()
76 | }
77 |
78 | override fun onOptionsItemSelected(item: MenuItem?): Boolean {
79 | item?.let {
80 | when (it.itemId) {
81 | android.R.id.home -> {
82 | supportFinishAfterTransition()
83 | return true
84 | }
85 | else -> {
86 | }
87 | }
88 | }
89 | return super.onOptionsItemSelected(item)
90 | }
91 |
92 | private fun setupToolBar() {
93 | setSupportActionBar(toolbar)
94 | supportActionBar?.apply {
95 | title = ""
96 | setHomeButtonEnabled(true)
97 | setDisplayHomeAsUpEnabled(true)
98 | elevation = 0f
99 | }
100 | }
101 |
102 | companion object {
103 | const val ITEM_ID = "itemId"
104 |
105 | private const val SAVED_CURRENT_PAGE_POSITION = "current_page_position"
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/app/src/main/java/pl/kitek/gallery/ui/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package pl.kitek.gallery.ui
2 |
3 | import android.content.Intent
4 | import android.os.Build
5 | import android.os.Bundle
6 | import android.support.v4.app.ActivityCompat
7 | import android.support.v4.app.ActivityOptionsCompat
8 | import android.support.v4.app.SharedElementCallback
9 | import android.support.v4.util.Pair
10 | import android.support.v4.view.ViewCompat
11 | import android.support.v7.app.AppCompatActivity
12 | import android.support.v7.widget.DividerItemDecoration
13 | import android.support.v7.widget.GridLayoutManager
14 | import android.view.View
15 | import android.view.ViewTreeObserver
16 | import kotlinx.android.synthetic.main.activity_main.*
17 | import pl.kitek.gallery.R
18 | import pl.kitek.gallery.data.DataSource
19 | import pl.kitek.gallery.data.GalleryItem
20 | import pl.kitek.gallery.ui.adapter.ImageGridAdapter
21 |
22 |
23 | class MainActivity : AppCompatActivity(), ImageGridAdapter.OnItemClickListener {
24 |
25 | private var reenterState: Bundle? = null
26 |
27 | private val exitElementCallback = object : SharedElementCallback() {
28 | override fun onMapSharedElements(names: MutableList, sharedElements: MutableMap) {
29 | if (reenterState != null) {
30 | val startingPosition = reenterState!!.getInt(EXTRA_STARTING_ALBUM_POSITION)
31 | val currentPosition = reenterState!!.getInt(EXTRA_CURRENT_ALBUM_POSITION)
32 | if (startingPosition != currentPosition) {
33 | // Current element has changed, need to override previous exit transitions
34 | val newTransitionName = GalleryItem.transitionName(DataSource.ITEMS[currentPosition].id)
35 | val newSharedElement = imagesRv.findViewWithTag(newTransitionName)
36 | if (newSharedElement != null) {
37 | names.clear()
38 | names.add(newTransitionName)
39 |
40 | sharedElements.clear()
41 | sharedElements.put(newTransitionName, newSharedElement)
42 | }
43 | }
44 | reenterState = null
45 | }
46 | }
47 | }
48 |
49 | override fun onCreate(savedInstanceState: Bundle?) {
50 | super.onCreate(savedInstanceState)
51 | setContentView(R.layout.activity_main)
52 | setSupportActionBar(toolbar)
53 | ActivityCompat.setExitSharedElementCallback(this, exitElementCallback)
54 |
55 | imagesRv.setHasFixedSize(true)
56 | imagesRv.layoutManager = GridLayoutManager(this, 2)
57 | imagesRv.adapter = ImageGridAdapter(DataSource.ITEMS, this)
58 | imagesRv.addItemDecoration(DividerItemDecoration(this, DividerItemDecoration.VERTICAL))
59 | imagesRv.addItemDecoration(DividerItemDecoration(this, DividerItemDecoration.HORIZONTAL))
60 | }
61 |
62 | override fun onClick(item: GalleryItem, view: View) {
63 | val intent = Intent(this, ImageActivity::class.java)
64 | intent.putExtra(ImageActivity.ITEM_ID, item.id)
65 |
66 | var bundle: Bundle? = null
67 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
68 | val p1 = Pair.create(view, ViewCompat.getTransitionName(view))
69 | bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(this, p1).toBundle()
70 | }
71 | // Open detail activity with shared element transition
72 | startActivity(intent, bundle)
73 | }
74 |
75 | override fun onActivityReenter(resultCode: Int, data: Intent) {
76 | super.onActivityReenter(resultCode, data)
77 | reenterState = Bundle(data.extras)
78 | reenterState?.let {
79 | val startingPosition = it.getInt(EXTRA_STARTING_ALBUM_POSITION)
80 | val currentPosition = it.getInt(EXTRA_CURRENT_ALBUM_POSITION)
81 | if (startingPosition != currentPosition) imagesRv.scrollToPosition(currentPosition)
82 | ActivityCompat.postponeEnterTransition(this)
83 |
84 | imagesRv.viewTreeObserver.addOnPreDrawListener(object : ViewTreeObserver.OnPreDrawListener {
85 | override fun onPreDraw(): Boolean {
86 | imagesRv.viewTreeObserver.removeOnPreDrawListener(this)
87 | ActivityCompat.startPostponedEnterTransition(this@MainActivity)
88 | return true
89 | }
90 | })
91 | }
92 | }
93 |
94 | companion object {
95 | const val EXTRA_STARTING_ALBUM_POSITION = "extra_starting_item_position"
96 | const val EXTRA_CURRENT_ALBUM_POSITION = "extra_current_item_position"
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/app/src/main/java/pl/kitek/gallery/ui/adapter/ImageGridAdapter.kt:
--------------------------------------------------------------------------------
1 | package pl.kitek.gallery.ui.adapter
2 |
3 | import android.support.v4.view.ViewCompat
4 | import android.support.v7.widget.RecyclerView
5 | import android.view.View
6 | import android.view.ViewGroup
7 | import android.widget.ImageView
8 | import com.squareup.picasso.Picasso
9 | import pl.kitek.gallery.data.GalleryItem
10 | import pl.kitek.gallery.ui.adapter.ImageGridAdapter.ViewHolder
11 | import pl.kitek.gallery.ui.view.AspectRatioImageView
12 |
13 | class ImageGridAdapter(val items: List,
14 | val onItemClickListener: OnItemClickListener? = null) : RecyclerView.Adapter() {
15 |
16 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = ViewHolder(parent)
17 |
18 | override fun onBindViewHolder(holder: ViewHolder?, position: Int) {
19 | (holder as ViewHolder).bind(items[position], onItemClickListener)
20 | }
21 |
22 | override fun getItemCount() = items.size
23 |
24 | class ViewHolder(parent: ViewGroup) : RecyclerView.ViewHolder(
25 | AspectRatioImageView(parent.context)
26 | .apply { scaleType = ImageView.ScaleType.CENTER_CROP }) {
27 |
28 | fun bind(item: GalleryItem, onItemClickListener: OnItemClickListener?) {
29 | itemView.setOnClickListener({ onItemClickListener?.onClick(item, it) })
30 | itemView.tag = GalleryItem.transitionName(item.id)
31 | ViewCompat.setTransitionName(itemView, GalleryItem.transitionName(item.id))
32 | Picasso.with(itemView.context).load(item.thumbnailURL).into(itemView as ImageView)
33 | }
34 | }
35 |
36 | interface OnItemClickListener {
37 | fun onClick(item: GalleryItem, view: View)
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/pl/kitek/gallery/ui/adapter/ImagePagerAdapter.kt:
--------------------------------------------------------------------------------
1 | package pl.kitek.gallery.ui.adapter
2 |
3 | import android.app.Activity
4 | import android.support.v4.app.ActivityCompat
5 | import android.support.v4.view.PagerAdapter
6 | import android.support.v4.view.ViewCompat
7 | import android.util.SparseArray
8 | import android.view.View
9 | import android.view.ViewGroup
10 | import android.view.ViewTreeObserver
11 | import android.widget.ImageView
12 | import com.squareup.picasso.Callback
13 | import com.squareup.picasso.Picasso
14 | import pl.kitek.gallery.data.GalleryItem
15 |
16 | class ImagePagerAdapter(
17 | private val activity: Activity,
18 | private val items: List,
19 | private val currentPos: Int) : PagerAdapter() {
20 |
21 |
22 | private val views = SparseArray(items.size)
23 |
24 | override fun instantiateItem(collection: ViewGroup, position: Int): Any {
25 | val item = items[position]
26 | val imageView = ImageView(collection.context)
27 | ViewCompat.setTransitionName(imageView, GalleryItem.transitionName(item.id))
28 | views.put(position, imageView)
29 |
30 | Picasso.with(collection.context)
31 | .load(item.fullURL)
32 | .noFade()
33 | .into(imageView, object : Callback {
34 | override fun onSuccess() {
35 | if (position == currentPos) {
36 | imageView.viewTreeObserver.addOnPreDrawListener(object : ViewTreeObserver.OnPreDrawListener {
37 | override fun onPreDraw(): Boolean {
38 | imageView.viewTreeObserver.removeOnPreDrawListener(this)
39 | ActivityCompat.startPostponedEnterTransition(activity)
40 | return true
41 | }
42 | })
43 | }
44 | }
45 |
46 | override fun onError() {
47 | ActivityCompat.startPostponedEnterTransition(activity)
48 | }
49 | })
50 |
51 | collection.addView(imageView)
52 | return imageView
53 | }
54 |
55 | override fun destroyItem(collection: ViewGroup, position: Int, view: Any) {
56 | views.removeAt(position)
57 | collection.removeView(view as View)
58 | }
59 |
60 | override fun isViewFromObject(view: View?, `object`: Any?) = view === `object`
61 | override fun getCount() = items.size
62 | fun getView(position: Int): View? = views.get(position)
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/app/src/main/java/pl/kitek/gallery/ui/view/AspectRatioImageView.kt:
--------------------------------------------------------------------------------
1 | package pl.kitek.gallery.ui.view
2 |
3 | import android.content.Context
4 | import android.util.AttributeSet
5 | import android.widget.ImageView
6 |
7 | class AspectRatioImageView @JvmOverloads constructor(
8 | context: Context,
9 | attrs: AttributeSet? = null,
10 | defStyle: Int = 0) : ImageView(context, attrs, defStyle) {
11 |
12 | var measureOnceListener: OnMeasureListener? = null
13 | private var widthRatio = 1f
14 |
15 | override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
16 | super.onMeasure(widthMeasureSpec, heightMeasureSpec)
17 | val width = measuredWidth
18 | val height = Math.round(width * widthRatio)
19 | setMeasuredDimension(width, height)
20 |
21 | measureOnceListener?.onViewMeasure(width, height)
22 | measureOnceListener = null
23 | }
24 |
25 | interface OnMeasureListener {
26 | fun onViewMeasure(width: Int, height: Int)
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_gallery.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
17 |
18 |
19 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kitek/android-gallery/a55405b5d9de40df97717f5a280e83ff9564272e/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kitek/android-gallery/a55405b5d9de40df97717f5a280e83ff9564272e/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kitek/android-gallery/a55405b5d9de40df97717f5a280e83ff9564272e/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kitek/android-gallery/a55405b5d9de40df97717f5a280e83ff9564272e/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kitek/android-gallery/a55405b5d9de40df97717f5a280e83ff9564272e/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kitek/android-gallery/a55405b5d9de40df97717f5a280e83ff9564272e/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kitek/android-gallery/a55405b5d9de40df97717f5a280e83ff9564272e/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kitek/android-gallery/a55405b5d9de40df97717f5a280e83ff9564272e/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kitek/android-gallery/a55405b5d9de40df97717f5a280e83ff9564272e/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kitek/android-gallery/a55405b5d9de40df97717f5a280e83ff9564272e/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/bools.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | true
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/values/bools.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | false
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Gallery
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.1.4-3'
5 | repositories {
6 | jcenter()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:2.3.3'
10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11 |
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | jcenter()
20 | }
21 | }
22 |
23 | task clean(type: Delete) {
24 | delete rootProject.buildDir
25 | }
26 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kitek/android-gallery/a55405b5d9de40df97717f5a280e83ff9564272e/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri May 12 15:50:42 CEST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/img/76Zrp8.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kitek/android-gallery/a55405b5d9de40df97717f5a280e83ff9564272e/img/76Zrp8.gif
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------