Git Product home page Git Product logo

Comments (8)

hannesa2 avatar hannesa2 commented on August 26, 2024

-sad- But with given info I can't do anything.
Does the sample from here works with your image ?

from panoramagl.

mahdizareeii avatar mahdizareeii commented on August 26, 2024

I load the image from server with coil as bitmap,
and i set it on a view and when it start setting on it, the ui freezes and i cant do anything with the other views

from panoramagl.

mahdizareeii avatar mahdizareeii commented on August 26, 2024

this is my code :

`package com.jabama.android.panoramaviewer

import android.content.Context
import android.graphics.Bitmap
import android.graphics.drawable.BitmapDrawable
import android.hardware.SensorEvent
import android.util.AttributeSet
import android.view.MotionEvent
import android.view.View
import android.view.WindowManager
import android.widget.LinearLayout
import androidx.constraintlayout.widget.ConstraintSet
import androidx.core.view.isVisible
import androidx.transition.Fade
import androidx.transition.TransitionManager
import androidx.transition.TransitionSet
import coil.ImageLoader
import coil.request.ImageRequest
import com.panoramagl.*
import com.panoramagl.utils.PLUtils
import kotlinx.android.synthetic.main.panorama_viewer.view.*
import kotlinx.coroutines.*

class PanoramaViewer @JvmOverloads constructor(
context: Context,
attributeSet: AttributeSet,
defStyleAttr: Int = 0
) : LinearLayout(context, attributeSet, defStyleAttr) {

private val plManager = PLManager(context)
private val panorama = PLSphericalPanorama()
private lateinit var properties: PanoramaProperties
private var job: Job? = null

init {
    View.inflate(context, R.layout.panorama_viewer, this)
    setupAttrs(attributeSet, defStyleAttr)
    initPanorama()
    setupArrowsClick()
}

fun loadImage(bitmap: Bitmap) {
    panorama.setImage(PLImage(bitmap, false))
    plManager.panorama = panorama
    postDelayed({
        isLoading(false)
    }, 3000)
}

fun loadImage(url: String) {
    isLoading(true)
    job = CoroutineScope(Dispatchers.IO).launch {
        ImageLoader([email protected]).also { loader ->
            ImageRequest.Builder([email protected])
                .data(url)
                .target {
                    (it as? BitmapDrawable)?.bitmap?.also { bitmap ->
                        loadImage(bitmap)
                    }
                    job = null
                }.build().also {
                    loader.execute(it)
                }
        }
    }
}

/**
 * init this in your activity or your fragment for handle touch screen and move camera
 */
fun handleOnTouch(event: MotionEvent?) {
    event ?: return
    plManager.onTouchEvent(event)
    handleScreenOnTouchEvent(event)
}

/**
 * if you want use gyroscope sensor for move camera with phone movement use this function
 */
fun handleGyroscope(event: SensorEvent) {
    plManager.onSensorChanged(event)
}

fun onConfigurationChanged() {
    val display = (context?.getSystemService(Context.WINDOW_SERVICE) as WindowManager)
    val rotation = display.defaultDisplay.rotation
    val isFullScreen = rotation != 0 && rotation != 2
    changePanoramaViewConstraint(isFullScreen)
}

/**
 * call these in your view lifecycles
 */
fun onResume() {
    plManager.onResume()
}

fun onPause() {
    plManager.onPause()
}

override fun onDetachedFromWindow() {
    job?.cancel("")
    plManager.onDestroy()
    super.onDetachedFromWindow()
}

private fun initPanorama() {
    plManager.setContentView(panorama_view)
    plManager.onCreate()
    panorama.camera.lookAt(properties.pitch, properties.raw)
    panorama.camera.rotationSensitivity = properties.motionSpeed
    if (properties.src != 0) {
        panorama.setImage(PLImage(PLUtils.getBitmap(this.context, properties.src), false))
        plManager.panorama = panorama
    }
}

private fun setupAttrs(attrs: AttributeSet, defStyleAttr: Int) {
    context.theme.obtainStyledAttributes(
        attrs,
        R.styleable.PanoramaViewer,
        defStyleAttr,
        0
    ).let {
        try {
            properties = PanoramaProperties(
                motionSpeed = it.getFloat(R.styleable.PanoramaViewer_motionSpeed, 20f),
                pitch = it.getFloat(R.styleable.PanoramaViewer_pitch, 5f),
                raw = it.getFloat(R.styleable.PanoramaViewer_raw, 0f),
                src = it.getResourceId(R.styleable.PanoramaViewer_src, 0)
            )
        } finally {
            it.recycle()
        }
    }
}

}`

from panoramagl.

hannesa2 avatar hannesa2 commented on August 26, 2024

Ok, I tried a short smoke test with your code, but
image

There is too much to do !

Please provide a compile able and running example, otherwise it's too much afford for me

from panoramagl.

mahdizareeii avatar mahdizareeii commented on August 26, 2024

ok please test this,
and if you can load o panorama image from server as bitmap and test my issue thanks
`private val plManager = PLManager(context)
private val panorama = PLSphericalPanorama()
private lateinit var properties: PanoramaProperties
private var job: Job? = null

init {
View.inflate(context, R.layout.panorama_viewer, this)
setupAttrs(attributeSet, defStyleAttr)
initPanorama()
setupArrowsClick()
}

fun loadImage(bitmap: Bitmap) {
panorama.setImage(PLImage(bitmap, false))
plManager.panorama = panorama
}

fun loadImage(url: String) {
//TODO please use any library for load image as bitmap and call loadImage(bitmap) for test my issue
}

/**

  • call these in your view lifecycles
    */
    fun onResume() {
    plManager.onResume()
    }

fun onPause() {
plManager.onPause()
}

override fun onDetachedFromWindow() {
plManager.onDestroy()
super.onDetachedFromWindow()
}

private fun initPanorama() {
plManager.setContentView(panorama_view)
plManager.onCreate()
panorama.camera.lookAt(properties.pitch, properties.raw)
panorama.camera.rotationSensitivity = properties.motionSpeed
if (properties.src != 0) {
panorama.setImage(PLImage(PLUtils.getBitmap(this.context, properties.src), false))
plManager.panorama = panorama
}
}

private fun setupAttrs(attrs: AttributeSet, defStyleAttr: Int) {
context.theme.obtainStyledAttributes(
attrs,
R.styleable.PanoramaViewer,
defStyleAttr,
0
).let {
try {
properties = PanoramaProperties(
motionSpeed = it.getFloat(R.styleable.PanoramaViewer_motionSpeed, 20f),
pitch = it.getFloat(R.styleable.PanoramaViewer_pitch, 5f),
raw = it.getFloat(R.styleable.PanoramaViewer_raw, 0f),
src = it.getResourceId(R.styleable.PanoramaViewer_src, 0)
)
} finally {
it.recycle()
}
}
}
`

from panoramagl.

hannesa2 avatar hannesa2 commented on August 26, 2024

Please provide a compile able and running example,

No quick and dirty copy&paste something. I mean eg. a pull request where you transform this sample with your code.
But I can't promise anything. You have to decide, if it makes sense for you to do it, or not ... otherwise please close this issue

from panoramagl.

stale avatar stale commented on August 26, 2024

This issue has been automatically marked as stale because it has not had recent activity. Please comment here if it is still valid so that we can reprioritize. Thank you!

from panoramagl.

stale avatar stale commented on August 26, 2024

Closing this. Please reopen if you believe it should be addressed. Thank you for your contribution.

from panoramagl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.