Skip to content

Commit

Permalink
Merge pull request #58 from ParkSangGwon/feature/context-application
Browse files Browse the repository at this point in the history
Using application's context in ToastUtil
  • Loading branch information
ParkSangGwon authored Jan 27, 2021
2 parents e247036 + 8c20071 commit 223ff1f
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
GROUP=gun0912.ted
VERSION_NAME=1.1.5
VERSION_NAME=1.1.6
DEVELOPER_ID='gun0912'
DEVELOPER_NAME='Ted Park'
SITE_URL='https://github.com/ParkSangGwon/TedImagePicker'
Expand Down
5 changes: 5 additions & 0 deletions tedimagepicker/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
android:name=".zoom.TedImageZoomActivity"
android:theme="@style/TedImagePickerTheme.Zoom" />

<provider
android:name=".util.TedImagePickerContentProvider"
android:authorities="gun0912.tedimagepicker.provider"
android:exported="false" />

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ open class TedImagePickerBaseBuilder<out B : TedImagePickerBaseBuilder<B>>(

@SuppressLint("CheckResult")
protected fun startInternal(context: Context) {
ToastUtil.context = context
checkPermission(context)
.subscribe({ permissionResult ->
if (permissionResult.isGranted) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package gun0912.tedimagepicker.util

import android.app.Application
import android.content.ContentProvider
import android.content.ContentValues
import android.database.Cursor
import android.net.Uri

class TedImagePickerContentProvider : ContentProvider() {
override fun onCreate(): Boolean {
ToastUtil.context = context as Application
return true
}

override fun insert(uri: Uri, values: ContentValues?): Uri? {
throw UnsupportedOperationException()
}

override fun query(
uri: Uri,
projection: Array<out String>?,
selection: String?,
selectionArgs: Array<out String>?,
sortOrder: String?
): Cursor? {
throw UnsupportedOperationException()
}

override fun update(
uri: Uri,
values: ContentValues?,
selection: String?,
selectionArgs: Array<out String>?
): Int {
throw UnsupportedOperationException()
}

override fun delete(uri: Uri, selection: String?, selectionArgs: Array<out String>?): Int {
throw UnsupportedOperationException()
}

override fun getType(uri: Uri): String {
throw UnsupportedOperationException()
}
}

0 comments on commit 223ff1f

Please sign in to comment.