blob: df47688c835a2803e502673e5fcc3a44aa787422 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/*
* Copyright 2018 Allan Wang
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ca.allanwang.kau.mediapicker
import android.os.Build
import android.os.Bundle
import androidx.annotation.RequiresApi
import ca.allanwang.kau.utils.toast
import kotlinx.android.synthetic.main.kau_activity_image_picker_overlay.*
/**
* Created by Allan Wang on 2017-07-23.
*
* Base activity for selecting images from storage
* This variant is an overlay and selects one image only before returning directly
* It is more efficient than [MediaPickerActivityBase], as all images are one layer deep
* as opposed to three layers deep
*/
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
abstract class MediaPickerActivityOverlayBase(
mediaType: MediaType,
mediaActions: List<MediaAction> = emptyList()
) : MediaPickerCore<MediaItemBasic>(mediaType, mediaActions) {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.kau_activity_image_picker_overlay)
initializeRecycler(kau_recyclerview)
MediaItemBasic.bindEvents(this, adapter.fastAdapter!!)
kau_draggable.addExitListener(this, R.transition.kau_image_exit_bottom, R.transition.kau_image_exit_top)
kau_draggable.setOnClickListener { finishAfterTransition() }
loadItems()
}
override fun finishAfterTransition() {
kau_recyclerview.stopScroll()
super.finishAfterTransition()
}
override fun onStatusChange(loaded: Boolean) {
if (!loaded) toast(R.string.kau_no_items_loaded)
}
override fun converter(model: MediaModel): MediaItemBasic = MediaItemBasic(model)
override fun onBackPressed() {
finishAfterTransition()
}
}
|