Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a834ddd6 authored by Samuel Cheung's avatar Samuel Cheung Committed by Josh Guilfoyle
Browse files

fix bug Carousel - scroll down in list view causes activity to draw blank screen.

parent b51c4c45
Loading
Loading
Loading
Loading
+0 −13
Original line number Diff line number Diff line
@@ -156964,19 +156964,6 @@
<parameter name="isInTouchMode" type="boolean">
</parameter>
</method>
<method name="removeViewFromLayout"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="protected"
>
<parameter name="aView" type="android.view.View">
</parameter>
</method>
<method name="setCurrentTab"
 return="void"
 abstract="false"
+1 −7
Original line number Diff line number Diff line
@@ -333,6 +333,7 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1");
                // give the current tab content view a shot
                mCurrentView.requestFocus();
            }

        }
        
        //mTabContent.requestFocus(View.FOCUS_FORWARD);
@@ -701,17 +702,10 @@ mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1");
            if (mLaunchedView != null) {
                if (mCloseView) {
                    mLaunchedView.setVisibility(View.GONE);
                } else {
                    removeViewFromLayout(mLaunchedView);
                }
                }
            }

       
        }

    // Implemented by Carousel (a child class of TabHost)
    protected void removeViewFromLayout(View aView) {
       
    }
}
+23 −7
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ package com.tmobile.widget;

import com.tmobile.widget.CarouselTabWidget.CarouselTabWidgetOnItemSelectedListener;

import android.app.Activity;
import android.app.LocalActivityManager;
import android.content.Context;
import android.content.Intent;
@@ -62,6 +63,25 @@ public class Carousel extends TabHost implements OnGestureListener {

			return windowDecor;
		}
		
		public View getView(int position) {
	        String name = mTabWidget.getFilmstrip().getFilmstripItem(position)
	                    .getName();
	       
	            Activity activity = mLocalActivityManager.getActivity(name);
	            
	            if (activity != null) {
	              
	                Window window  = activity.getWindow();
	                
	                View windowDecor = (window != null) ? window.getDecorView() : null;

	                return windowDecor;
	            }
	            
	         
	            return getView(position, null, null);
	       }
	}

	public class CarouselOnItemSelectedListener extends
@@ -132,7 +152,6 @@ public class Carousel extends TabHost implements OnGestureListener {
		}

		if (mCarouselTabContentLayout != null) {
		    mCarouselTabContentLayout.setTabHost(this);
			mCarouselTabContentLayout.setAdapter(new CarouselViewAdapter());
		}
	}
@@ -167,7 +186,7 @@ public class Carousel extends TabHost implements OnGestureListener {
				return false;
			}
			
			mCarouselTabContentLayout.setSelection(newSelectedPosition, true, true);
			mCarouselTabContentLayout.setSelection(newSelectedPosition, true);
			mTabWidget.setFilmstripSelection(newSelectedPosition);
			
			return true;
@@ -211,6 +230,7 @@ public class Carousel extends TabHost implements OnGestureListener {
		}
		
		protected void dispatchKeyUpEvent() {
		   
			mTabWidget.getFilmstrip().requestFocus();
		}
		
@@ -222,8 +242,4 @@ public class Carousel extends TabHost implements OnGestureListener {
            mCarouselTabContentLayout.setSelection(index, false);
        }

		// Call carousel tab layout to remove view
		protected void removeViewFromLayout(View aView) {
		    mCarouselTabContentLayout.removeViewFromLayout(aView);
		}
}
+29 −23
Original line number Diff line number Diff line
package com.tmobile.widget;

import com.tmobile.widget.Carousel.CarouselViewAdapter;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
@@ -8,7 +10,6 @@ import android.view.ViewParent;
import android.widget.AbsoluteLayout;
import android.widget.Adapter;
import android.widget.Scroller;
import android.widget.TabHost;

public class CarouselLayout extends AbsoluteLayout {

@@ -22,6 +23,7 @@ public class CarouselLayout extends AbsoluteLayout {
        }

        public void scrollBy(int distance, int duration) {
             
            if (distance == 0) return;
            
            removeCallbacks(this);
@@ -67,9 +69,8 @@ public class CarouselLayout extends AbsoluteLayout {
    
    private int mOldSelectedPosition = INVALID_POSITION;
    private int mSelectedPosition = INVALID_POSITION;
    private Adapter mAdapter;
    private CarouselViewAdapter mAdapter;
    private int mScrollDuration = 0;
    private TabHost mTabHost;
    
    private ScrollerRunnable mScrollerRunnable = new ScrollerRunnable();

@@ -102,7 +103,7 @@ public class CarouselLayout extends AbsoluteLayout {
        invalidate();
    }

    public void setAdapter(Adapter adapter) {
    public void setAdapter(CarouselViewAdapter adapter) {
        if (null != mAdapter) {
            //mAdapter.unregisterDataSetObserver(mDataSetObserver);
            resetLayout();
@@ -130,28 +131,38 @@ public class CarouselLayout extends AbsoluteLayout {
    private void removeOldSelectedView() {
        if (INVALID_POSITION == mOldSelectedPosition) return;

        mOldSelectedPosition = INVALID_POSITION;
    }
        View theOldSelectedView = mAdapter.getView(mOldSelectedPosition);
        removeView(theOldSelectedView);
        
    public void removeViewFromLayout(View aView) {
        removeView(aView);
        mOldSelectedPosition = INVALID_POSITION;
    }
  
    
    private void snapToCurrentSelection() {
        mScrollerRunnable.stop();
        removeOldSelectedView();

        
        if (INVALID_POSITION != mSelectedPosition) {
            View theSelectedView = mAdapter.getView(mSelectedPosition);
            theSelectedView.setLayoutParams(new AbsoluteLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                                                                            ViewGroup.LayoutParams.FILL_PARENT, 0, 0));
            requestLayout();
            theSelectedView.setFocusable(true);
            theSelectedView.setFocusableInTouchMode(true);
            ((ViewGroup) theSelectedView).setDescendantFocusability(FOCUS_AFTER_DESCENDANTS);
            
            // Do not request focus in order to keep the focus in Gallery when it has the focus
            //theSelectedView.requestFocus();
        }
	  
    public void setSelection(int position) {
        setSelection(position, false, false);
    }
    
    public void setTabHost(TabHost aTabHost) {
        mTabHost = aTabHost;
    public void setSelection(int position) {
        setSelection(position, false);
    }
    
    public void setSelection(int position, boolean animate, boolean startActivity) {
    public void setSelection(int position, boolean animate) {
        if (position == mSelectedPosition) return;
        
        snapToCurrentSelection();
@@ -160,16 +171,10 @@ public class CarouselLayout extends AbsoluteLayout {
        if (INVALID_POSITION != mSelectedPosition) {
            int xView = 0;
            
            View theSelectedView = null;
            
            if (startActivity) {
                theSelectedView = mAdapter.getView(mSelectedPosition, null, this);
            } else {
                theSelectedView = mTabHost.getCurrentView();
            }
           
            View theSelectedView = mAdapter.getView(mSelectedPosition);
            
            if (animate && (INVALID_POSITION != mOldSelectedPosition)) {
                
                xView = (mSelectedPosition > mOldSelectedPosition) ? getWidth() : -getWidth();
                mScrollerRunnable.scrollBy(-xView, mScrollDuration);
            } else {
@@ -199,6 +204,7 @@ public class CarouselLayout extends AbsoluteLayout {
    }

    private void handleScroll(int inChangeInX) {
           
        if (getChildCount() == 0) return;
        
        for (int i = getChildCount() - 1; i >= 0; i--) {
+11 −28
Original line number Diff line number Diff line
package com.tmobile.widget;

import com.android.internal.R;
import com.tmobile.widget.Carousel.CarouselViewAdapter;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Adapter;
import android.widget.FrameLayout;
import android.widget.TabHost;

import com.android.internal.R;


public class CarouselTabContentLayout extends FrameLayout  {

	private CarouselLayout mCarouselLayout;

	
	private int mScrollDuration = SCROLL_DURATION_DEFAULT;
	private static final int SCROLL_DURATION_DEFAULT = 400;
	
@@ -32,13 +29,10 @@ public class CarouselTabContentLayout extends FrameLayout {
			int defStyle) {
		super(context, attrs, defStyle);

		
		
		setFocusable(false);
		               
		setFocusableInTouchMode(false);


        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Gallery, defStyle, 0);
        mScrollDuration = a.getInt(R.styleable.Gallery_animationDuration, SCROLL_DURATION_DEFAULT);
        a.recycle();
@@ -55,17 +49,13 @@ public class CarouselTabContentLayout extends FrameLayout {
	}
	
	public void setSelection(int position, boolean animate) {
		mCarouselLayout.setSelection(position, animate, false);
		mCarouselLayout.setSelection(position, animate);
    }
	
	public void setAdapter(Adapter adapter) {
	public void setAdapter(CarouselViewAdapter adapter) {
		mCarouselLayout.setAdapter(adapter);
	}

	public void setTabHost(TabHost aTabHost) {
	    mCarouselLayout.setTabHost(aTabHost);
	}

	@Override
	public void addView(View child, int width, int height) {
		// Do nothing
@@ -119,12 +109,13 @@ public class CarouselTabContentLayout extends FrameLayout {
	}

	@Override
	public void removeViews(int start, int count) {
	public void removeViewsInLayout(int start, int count) {
       // Do nothing
	}

	
	@Override
	public void removeViewsInLayout(int start, int count) {
	public void removeViews(int start, int count) {
		// Do nothing
	}
	
@@ -133,15 +124,7 @@ public class CarouselTabContentLayout extends FrameLayout {
	}
	
	public void setSelection(int position) {
		mCarouselLayout.setSelection(position, true, false);
	}
	
	public void setSelection(int position, boolean animate, boolean startActivity) {
        mCarouselLayout.setSelection(position, animate, startActivity);
    }
	
	protected void removeViewFromLayout(View aView) {
	    mCarouselLayout.removeViewFromLayout(aView);
		mCarouselLayout.setSelection(position, true);
	}
	
}