File tree Expand file tree Collapse file tree
core/src/main/java/com/omega_r/libs/omegaintentbuilder Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,6 +42,9 @@ object OmegaIntentBuilder {
4242 @JvmStatic
4343 fun share () = ShareIntentBuilder ()
4444
45+ @JvmStatic
46+ fun view () = ViewIntentBuilder ()
47+
4548 /* *
4649 * @return ShareIntentBuilder for creating email Intent
4750 */
Original file line number Diff line number Diff line change 1+ package com.omega_r.libs.omegaintentbuilder.builders
2+
3+ import android.content.Context
4+ import android.content.Intent
5+ import java.lang.IllegalStateException
6+
7+ class ViewIntentBuilder : BaseUriBuilder () {
8+
9+ private var mimeType: String? = null
10+
11+ fun mimeType (mimeType : String ): ViewIntentBuilder = also {
12+ this .mimeType = mimeType
13+ }
14+
15+ override fun createIntent (context : Context ): Intent {
16+ val intent = Intent (Intent .ACTION_VIEW )
17+ val uriSet = getUriSet(context)
18+ if (uriSet.size == 1 ) intent.setDataAndType(uriSet.first(), mimeType)
19+ else throw IllegalStateException (" Multiple uri not supported" )
20+ return intent
21+ }
22+
23+ }
You can’t perform that action at this time.
0 commit comments