Giter Site home page Giter Site logo

Comments (8)

pariharsunny avatar pariharsunny commented on May 30, 2024

Hi,

I also experienced the same issue on sony Xperia S (Android 4.0.4).

The menu buttons open nicely but gets pushed towards left the next moment.

Any help would be appreciated.

Thanks,

Sunny

from android-satellite-menu.

adgeg avatar adgeg commented on May 30, 2024

Hi Sunny,

I found a really UGLY way to fix this bug on Xperia. Indeed, I didn't find a generic way to fix this, just a special case for this device... BTW, if you really want a fix, it works.

In SatelliteMenu.java :

Modify addItems :

     public void addItems(List<SatelliteMenuItem> items) {
    // special case for Sony Xperia S (ugly, I'm sorry...)
    if(android.os.Build.MODEL.equals("LT26i")){
        theWorstHandlingOfExceptionOfAllTheTimes(items);
        return;
    }
            ....
      }

And create a new method :

 /* Special handling of a strange bug in displaying of items on Sony Xperia S.
 * Caution child, this is done nearly the worst way it could.
 * Don't try this at home ! 
 */
private void theWorstHandlingOfExceptionOfAllTheTimes(List<SatelliteMenuItem> items) {
    RelativeLayout relativeLayout = new RelativeLayout(getContext());
    // Appreciate the hard coding dimensions
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
            satelliteDistance + 100, satelliteDistance + 100);
    layoutParams.gravity = Gravity.BOTTOM;
    relativeLayout.setLayoutParams(layoutParams);

    menuItems.addAll(items);
    this.removeView(imgMain);
    float[] degrees = getDegrees(menuItems.size());
    int index = 0;
    for (SatelliteMenuItem menuItem : menuItems) {
        int finalX = SatelliteAnimationCreator.getTranslateX(degrees[index], satelliteDistance);
        int finalY = SatelliteAnimationCreator.getTranslateY(degrees[index], satelliteDistance);

        CustomView itemView = (CustomView) LayoutInflater.from(getContext()).inflate(
                R.layout.sat_item_cr, this, false);
        CustomView cloneView = (CustomView) LayoutInflater.from(getContext()).inflate(
                R.layout.sat_item_cr, this, false);
        itemView.setTag(menuItem.getId());
        cloneView.setVisibility(View.GONE);
        itemView.setVisibility(View.GONE);

        cloneView.setOnClickListener(internalItemClickListener);
        cloneView.setTag(Integer.valueOf(menuItem.getId()));
        RelativeLayout.LayoutParams layoutParamsClone = new RelativeLayout.LayoutParams(
                LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        // And again... 
        int finalYInverse = Math.abs(SatelliteAnimationCreator.getTranslateY(degrees[index],
                satelliteDistance)) - 20;
        int finalXInverse = Math.abs(SatelliteAnimationCreator.getTranslateX(degrees[index],
                satelliteDistance));
        layoutParamsClone.setMargins(finalXInverse, satelliteDistance - finalYInverse, 0, 0);
        cloneView.setLayoutParams(layoutParamsClone);
        if (menuItem.getImgResourceId() > 0) {
            itemView.setImageResource(menuItem.getImgResourceId());
            cloneView.setImageResource(menuItem.getImgResourceId());
        } else if (menuItem.getImgDrawable() != null) {
            itemView.setImageDrawable(menuItem.getImgDrawable());
            cloneView.setImageDrawable(menuItem.getImgDrawable());
        }

        Animation itemOut = SatelliteAnimationCreator.createItemOutAnimation(getContext(),
                index, expandDuration, finalX, finalY);
        Animation itemIn = SatelliteAnimationCreator.createItemInAnimation(getContext(), index,
                expandDuration, finalX, finalY);
        Animation itemClick = SatelliteAnimationCreator.createItemClickAnimation(getContext());

        menuItem.setView(itemView);
        menuItem.setCloneView(cloneView);
        menuItem.setInAnimation(itemIn);
        menuItem.setOutAnimation(itemOut);
        menuItem.setClickAnimation(itemClick);
        menuItem.setFinalX(finalX);
        menuItem.setFinalY(finalY);

        itemIn.setAnimationListener(new SatelliteAnimationListener(itemView, true,
                viewToItemMap));
        itemOut.setAnimationListener(new SatelliteAnimationListener(itemView, false,
                viewToItemMap));
        itemClick.setAnimationListener(new SatelliteItemClickAnimationListener(this, menuItem
                .getId()));

        this.addView(itemView);
        relativeLayout.addView(cloneView);
        viewToItemMap.put(itemView, menuItem);
        viewToItemMap.put(cloneView, menuItem);
        index++;
    }

    this.addView(relativeLayout);
    this.addView(imgMain);
}

Hope it will help you...

Gabriel

from android-satellite-menu.

pariharsunny avatar pariharsunny commented on May 30, 2024

Hi Gabriel,

Could please explain what kind of object is: CustomView in the below line of code:

CustomView itemView = (CustomView) LayoutInflater.from(getContext()).inflate(
R.layout.sat_item_cr, this, false);

As, the android is unable to resolve it.

Thanks,
Sunny

from android-satellite-menu.

adgeg avatar adgeg commented on May 30, 2024

Sorry, I forgot that I use my own view instead of the original ImageView.
Just use the same image view than in addItems method :

ImageView itemView = (ImageView) LayoutInflater.from(getContext())
                .inflate(R.layout.sat_item_cr, this, false);
ImageView cloneView = (ImageView) LayoutInflater.from(getContext())
                .inflate(R.layout.sat_item_cr, this, false);

Cheers,

Gabriel

from android-satellite-menu.

dwally89 avatar dwally89 commented on May 30, 2024

Hi,

I had a similar bug on an Xperia, running 4.0.4.
Changing from a FrameLayout to a RelativeLayout seemed to fix the problem for me

from android-satellite-menu.

anilari89 avatar anilari89 commented on May 30, 2024

Hi dwally,
I tried changing from FrameLayout to a RelativeLayout,but its not working.
Can you please share your code.

Thanks.

from android-satellite-menu.

sorooshstrife avatar sorooshstrife commented on May 30, 2024

Hi
I faced the same problem on Xperia Neo L. This fixed it thank you. Do you know if it's like this only on xperia devices or there are other devices that show similar behavior?
EDIT:
I was wrong. I tested it on Xperia M and it works fine. It was just my own device so I added MT25i to the black list.

from android-satellite-menu.

dosoos avatar dosoos commented on May 30, 2024

my device oppo find5t,china phone

from android-satellite-menu.

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.