[android-developers] Re: Slow scrolling in Date/TimePicker using Holo theme

2011-12-16 Thread Matt H
Hi Dirk,

I had the same problem (noticed it yesterday, too, coincidentally!).
The issue is that the ScrollView is intercepting and stealing the
touch events once your finger moves outside of the Date/Time Picker
controls.

To work around this, I created sub classes of Date/TimePicker which
prevent the parent from stealing events after the initial touch down
(see below). If you use those in your layout XML instead, you should
find the problem goes away.

Hope that is useful!

Matt.


import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.ViewParent;
import android.widget.DatePicker;

public class CustomDatePicker extends DatePicker
{
public CustomDatePicker(Context context, AttributeSet attrs, int
defStyle)
{
super(context, attrs, defStyle);
}

public CustomDatePicker(Context context, AttributeSet attrs)
{
super(context, attrs);
}

public CustomDatePicker(Context context)
{
super(context);
}

@Override
public boolean onInterceptTouchEvent(MotionEvent ev)
{
/* Prevent parent controls from stealing our events once we've
gotten a touch down */
if (ev.getActionMasked() == MotionEvent.ACTION_DOWN)
{
ViewParent p = getParent();
if (p != null)
p.requestDisallowInterceptTouchEvent(true);
}

return false;
}
}

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Partial invalidation in custom Android view with hardware acceleration

2011-08-30 Thread Matt H
Hi,

I've got a custom View in my application which fills the entire
activity.

In most cases, when I want to refresh the control I call invalidate()
without any parameters.

However, in certain circumstances, where I'm only changing a small
area of the control, I call invalidate(Rect) to avoid redrawing the
entire screen. This is important because in these situations I need
the update to be as fast as possible.

This seems to work fine, however, when I enable hardware acceleration
in Honeycomb (i.e. set android:hardwareAccelerated=truein
AndroidManifest.xml), the partial redraw does not seem to work.

This can be seen if I do Log.d(FOO, canvas.getClipBounds()) in my
onDraw() method; the output simply shows that the whole control is
being updated, whereas with hardware acceleration disabled, I get the
correct region being output.

Is there any way to make partial invalidation work when using hardware
acceleraton?

Many thanks, Matt

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Trying to load a list of overlay positions from file

2011-04-17 Thread matt h
**facepalm** yeh i had my lat and longitude mixed up, thanks

On Fri, Apr 15, 2011 at 8:16 PM, TreKing treking...@gmail.com wrote:

 On Thu, Apr 14, 2011 at 2:49 PM, matt h matt...@gmail.com wrote:

 Hi, I am trying to develop an app to list the bus stops for my local
 Public Transit buses on a google map map,


 It's not Chicago is it!? =P


 Any one have any idea why my markers are not being added?


 Tip: when stuff doesn't show on the map, try zooming all the way out in
 case you've plotted it wrong 

 Walk with me here ...

 This is your format, right?:-79261518440062802511YRT
 And this is your parsing, right?: LineSplit[0]),Integer.parseInt(LineSplit[1])
 ...
 And this is your function, right?: AddOverlayItem(int intLat, int intLong
 ...
 So -79261518 is latitude, 44006280 is the longitude right?
 And this becomes -79.261518 and 44.006280, right?

 Is this a transit system for 
 Penguinshttp://maps.google.com/maps?f=qsource=s_qhl=engeocode=q=-79.261518,+44.006280aq=sll=41.896758,-87.643616sspn=0.013928,0.02032ie=UTF8ll=-84.267172,41.484375spn=169.144106,305.859375z=1
 ?
 Or for 
 Duckshttp://maps.google.com/maps?f=qsource=s_qhl=engeocode=q=44.006280,+-79.261518aq=sll=-84.267172,41.484375sspn=169.144106,305.859375ie=UTF8ll=44.292401,-80.244141spn=13.775603,20.808105z=6
 ?


 -
 TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
 transit tracking app for Android-powered devices

  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Trying to load a list of overlay positions from file

2011-04-17 Thread matt h
what do you mean one overlay per bus line?
what my app is doing is it lists all bus stops in my area, then when i tap a
marker it will open the web browser and display the times the bus comes at
for that stop.
Eventually I will parse the web page and display the times within the dialog
that pops up when the marker is clicked.

On Fri, Apr 15, 2011 at 9:04 PM, lbendlin l...@bendlin.us wrote:

 Why are you creating a new overlay for each marker? To stay with your
 story, one overlay per bus line would make much more sense.

  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Trying to load a list of overlay positions from file

2011-04-15 Thread matt h
Hi, I am trying to develop an app to list the bus stops for my local Public
Transit buses on a google map map,
but i seem to be having problem loading the overlay markers locations from a
text file

Heres the code i use to load a new overlay onto the mapview:


[CODE]
public void AddOverlayItem(int intLat, int intLong, String
strStop,String strType) {
 Toast.makeText(HelloGoogleMaps.this.getBaseContext(), intLat + , +
intLong + , + strStop + , + strType,Toast.LENGTH_SHORT).show();
 // TODO Auto-generated method stub
 ListOverlay mapOverlays = mapView.getOverlays();
 Drawable drawable = this.getResources().getDrawable(R.drawable.viva);

 if (YRT.equals(strType)) {
 drawable = this.getResources().getDrawable(R.drawable.yrt);
 }

 HelloItemizedOverlay itemizedoverlay = new
HelloItemizedOverlay(drawable,this);

 GeoPoint point = new GeoPoint(intLat,intLong);
 OverlayItem overlayitem = new OverlayItem(point, strStop, strType);

 itemizedoverlay.addOverlay(overlayitem);

 mapOverlays.add(itemizedoverlay);


}
[/CODE]


When i call the above code from a button i click from within my app all
works fine, settings get saved and marker appears on screen:

[CODE]
WriteSettings(HelloGoogleMaps.this,String.valueOf((int)(longitude*1E6))
+  +
 String.valueOf((int)(latitude*1E6)) +  +
  etStop.getText().toString() +  +
YRT);

AddOverlayItem((int)(latitude*1E6),(int)(longitude*1E6),
etStop.getText().toString(),YRT);
[/CODE]

But the problem i am having is when i call the following code at the end of
the onCreate method, my overlays do not appear:

[CODE]
public void RefreshStops() {
 // Refreshes the list of bus stop's
 //Find the directory for the SD Card using the API
 //*Don't* hardcode /sdcard
 File sdcard = Environment.getExternalStorageDirectory();

 //Get the text file
 File file = new File(sdcard,LocFile);

 try {
BufferedReader br = new BufferedReader(new FileReader(file));
String line;

while ((line = br.readLine()) != null) {
 String LineSplit[] = line.split();
 
AddOverlayItem(Integer.parseInt(LineSplit[0]),Integer.parseInt(LineSplit[1]),LineSplit[2],
LineSplit[3]);
}
 }
 catch (IOException e) {
//You'll need to add proper error handling here

Toast.makeText(HelloGoogleMaps.this.getBaseContext(),e.getMessage(),Toast.LENGTH_SHORT).show();
 }


}
[/CODE]

Contents of file being read:
longitudelatitudestopnumberbus-service

[CODE]
cat BusLoc2.txt
-79261518440062802511YRT
-79161518440062803243YRT
-79161518440062806465YRT
-7916151844006280675YRT
[/CODE]

I know the AddOverlayItem() method is being called from the RefreshStops()
method because i have put a 'toast' in the AddOverlayItem() method for debug
purposes and can see the info being passed to it correctly but for some
reason they are not appearing??

Any one have any idea why my markers are not being added?
Thanks for any help

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en