Created
November 8, 2017 05:34
-
-
Save mockiemockiz/0aa1ee7eb838ef76ed672d86a26a4164 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tigaer.inventory | |
import android.content.Intent | |
import android.os.Bundle | |
import android.support.v7.app.AppCompatActivity | |
import android.view.View | |
import kotlinx.android.synthetic.main.upload_motif_activity.* | |
import android.provider.MediaStore | |
import android.graphics.Bitmap | |
import android.net.Uri | |
import android.os.Build | |
import android.support.annotation.RequiresApi | |
import android.widget.ImageView | |
import java.io.IOException | |
class UploadMotifActivity : AppCompatActivity() { | |
private val PICK_IMAGE_MULTIPLE = 1 | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.upload_motif_activity) | |
btnAddPhots.setOnClickListener(View.OnClickListener { test() }) | |
} | |
public fun test(){ | |
val i = Intent() | |
i.type = "image/*" | |
i.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true) | |
i.action = Intent.ACTION_GET_CONTENT | |
startActivityForResult( | |
Intent.createChooser(i, "android.intent.action.SEND_MULTIPLE"), 0) | |
} | |
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN) | |
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent) { | |
super.onActivityResult(requestCode, resultCode, data) | |
// println("++count" + data.clipData?.itemCount) | |
// val selectedImage = data.clipData.getItemAt(0).uri//As of now use static position 0 use as per itemcount. | |
// var bitmap: Bitmap? = null | |
// // Uri selectedImage1 = data.getData(); | |
// try { | |
// bitmap = MediaStore.Images.Media.getBitmap(this.contentResolver, selectedImage) | |
// } catch (e: IOException) { | |
// e.printStackTrace() | |
// } | |
// | |
//// println("+++ clipdate" + selectedImage) | |
// | |
// if (data.clipData != null) { | |
// | |
// } | |
var condata: String? = "" | |
try{ | |
data.clipData | |
}catch (e: IOException) { | |
for (i in 0..(data.clipData.itemCount - 1)) { | |
val ab = data.clipData.getItemAt(i).uri.toString() + "\n" | |
val sb = StringBuilder() | |
sb.append(condata).append(ab) | |
condata = sb.toString() | |
textView2.text = sb.toString() | |
} | |
} | |
textView2.text = condata | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment