Skip to content

Instantly share code, notes, and snippets.

View Kashif-E's full-sized avatar

Kashif Mehmood Kashif-E

View GitHub Profile
@Kashif-E
Kashif-E / onCreate.kt
Last active December 9, 2020 11:08
onCreate function
lateinit var link : String
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
link = "https://firebasestorage.googleapis.com/v0/b/modelviewerapp.appspot.com/o/models%2Fout.glb?alt=media&token=442d2d08-9b61-49e1-a059-e7f89a83155c"
//making a transformation system so we can interact with the 3d model
transformationSystem = TransformationSystem(resources.displayMetrics, FootprintSelectionVisualizer())
@Kashif-E
Kashif-E / RenderObject.kt
Created December 9, 2020 11:14
this function builds and loads the model from firebase and saves it into a variable
private fun renderObject() {
ModelRenderable.builder()
.setSource(
requireContext(), builder().setSource(
requireContext(),
Uri.parse(link),
SourceType.GLB
)
.setRecenterMode(RecenterMode.ROOT)
@Kashif-E
Kashif-E / onRenderableLoaded.kt
Created December 9, 2020 11:19
this function will load the renderable on to sceneview
private fun onRenderableLoaded(modelRenderable: ModelRenderable) {
modelNode = TransformableNode(transformationSystem).apply {
setParent(binding.SceneView.scene)
translationController.isEnabled = true
scaleController.isEnabled = true
scaleController.minScale=0.01f
private fun getPermission() {
Dexter.withContext(this)
.withPermission(
Manifest.permission.CAMERA
).withListener(object : MultiplePermissionsListener {
override fun onPermissionsChecked(report: MultiplePermissionsReport) {
report.let {
if (report.areAllPermissionsGranted()) {
Toast.makeText(this@MainActivity, "Permission Granted", Toast.LENGTH_SHORT).show()
private fun getPermission() {
Dexter.withContext(this)
.withPermissions(
Manifest.permission.CAMERA,
Manifest.permission.WRITE_EXTERNAL_STORAGE
).withListener(object : MultiplePermissionsListener {
override fun onPermissionsChecked(report: MultiplePermissionsReport) {
report.let {
if (report.areAllPermissionsGranted()) {
override fun onPermissionRationaleShouldBeShown(permissions: List<PermissionRequest?>?, token: PermissionToken?) {
token?.continuePermissionRequest()
}
private val itemTouchHelper by lazy {
val simpleItemTouchCallback = object : ItemTouchHelper.SimpleCallback(UP or DOWN or START or END, 0) {
override fun onMove(recyclerView: RecyclerView,
viewHolder: RecyclerView.ViewHolder,
target: RecyclerView.ViewHolder): Boolean {
//on move lets you check if an item has been moved from its position either up or down
return true
}
private val itemTouchHelper by lazy {
val simpleItemTouchCallback = object : ItemTouchHelper.SimpleCallback(UP or DOWN or START or END, 0) {
override fun onMove(recyclerView: RecyclerView,
viewHolder: RecyclerView.ViewHolder,
target: RecyclerView.ViewHolder): Boolean {
//getting the adapter
val adapter = recyclerView.adapter as MoviesAdapter
override fun onMove(recyclerView: RecyclerView,
viewHolder: RecyclerView.ViewHolder,
target: RecyclerView.ViewHolder): Boolean {
val adapter = recyclerView.adapter as MoviesAdapter
val from = viewHolder.adapterPosition
val to = target.adapterPosition
adapter.moveItemInRecyclerViewList(from, to)
adapter.notifyItemMoved(from, to)
return true
val entityExtractor =
EntityExtraction.getClient(
EntityExtractorOptions.Builder(EntityExtractorOptions.ENGLISH)
.build()
)