Skip to content

Commit 2fe9c67

Browse files
committed
增加Uri.toWrapper方法
1 parent 7d4ce3f commit 2fe9c67

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

rxhttp/src/main/java/rxhttp/wrapper/entity/OutputSreamWrapper.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package rxhttp.wrapper.entity
22

3+
import android.content.Context
4+
import android.net.Uri
35
import java.io.OutputStream
46

57
/**
@@ -13,4 +15,11 @@ data class OutputStreamWrapper<out T>(
1315
override fun toString(): String = "($result, $os)"
1416
}
1517

16-
fun <T> OutputStream.toWrapper(that: T): OutputStreamWrapper<T> = OutputStreamWrapper(that, this)
18+
fun <T> OutputStream.toWrapper(that: T): OutputStreamWrapper<T> = OutputStreamWrapper(that, this)
19+
20+
fun Uri.toWrapper(os: OutputStream): OutputStreamWrapper<Uri> = OutputStreamWrapper(this, os)
21+
22+
fun Uri.toWrapper(context: Context): OutputStreamWrapper<Uri> {
23+
val os = context.contentResolver.openOutputStream(this)
24+
return OutputStreamWrapper(this, os)
25+
}

0 commit comments

Comments
 (0)