// Copyright eeGeo Ltd (2012-2015), All Rights Reserved

package com.eegeo.searchmenu;

import com.eegeo.entrypointinfrastructure.MainActivity;
import com.eegeo.searchmenu.SearchMenuResultsListAnimationConstants;

import android.annotation.SuppressLint;
import android.os.Handler;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ListView;

public class SearchResultsScrollButtonTouchDownListener implements View.OnTouchListener
{
	private ListView m_searchList = null;
    private final Handler m_handler = new Handler();
	private MainActivity m_activity;
    private float m_scaledDensity;
    
	public SearchResultsScrollButtonTouchDownListener(ListView view, MainActivity activity) 
	{
		m_searchList = view;
		m_activity = activity;
        DisplayMetrics metrics =  m_activity.getResources().getDisplayMetrics();
        m_scaledDensity = metrics.scaledDensity;
	}

    final Runnable m_action = new Runnable() 
    {
		@SuppressLint("NewApi")
		@Override public void run() {
            if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT)
            {   
            	float screenIndependentPxPerSecond = (SearchMenuResultsListAnimationConstants.SearchMenuResultsListScrollButtonSpeed * m_scaledDensity);
            	m_searchList.scrollListBy((int)(screenIndependentPxPerSecond));
            	m_searchList.setVerticalScrollBarEnabled(false);
            }
            m_handler.post(this);
        }
    };
    
	@Override
	public boolean onTouch(View v, MotionEvent event) 
	{
		switch(event.getAction()) {
			case MotionEvent.ACTION_DOWN:
				m_handler.post(m_action);
	            break;
	        case MotionEvent.ACTION_UP:
	        	m_handler.removeCallbacks(m_action);
	            break;
		}
		return false;
	}
}

@@ -674,24 +674,66 @@
 ledDensity;%0A
+    float m_screenIndependentPxPerSecond;%0A
     %0A%09public
@@ -996,16 +996,157 @@
 ensity;%0A
+        m_screenIndependentPxPerSecond = (SearchMenuResultsListAnimationConstants.SearchMenuResultsListScrollButtonSpeed * m_scaledDensity);%0A
 %09%7D%0A%0A    
@@ -1249,17 +1249,23 @@
 d run() 
-%7B
+%0A%09%09%7B%09%09%09
 %0A       
@@ -1381,144 +1381,180 @@
    %09
-float screenIndependentPxPerSecond = (SearchMenuResultsListAnimationConstants.SearchMenuResultsListScrollButtonSpeed * m_scaledDensity);
+m_searchList.scrollListBy((int)(m_screenIndependentPxPerSecond));%0A            %09m_searchList.setVerticalScrollBarEnabled(false);%0A            %7D%0A            else%0A            %7B
 %0A   
@@ -1577,33 +1577,35 @@
 chList.s
+moothS
 croll
-List
 By((int)
 (screenI
@@ -1596,17 +1596,19 @@
 By((int)
-(
+ m_
 screenIn
@@ -1631,71 +1631,11 @@
 cond
-));%0A            %09m_searchList.setVerticalScrollBarEnabled(false
+, 0
 );%0A 
@@ -1797,16 +1797,19 @@
 tion()) 
+%0A%09%09
 %7B%0A%09%09%09cas

Fix for MPLY-7377. Added scrolling functionality for android < 4.4. Not as smooth but works. Buddy: Jonty