I am looking for some help....
Firstly I have a database server side with a numerous amount of locations(longs +lats)
Now there are upto a 1000 for one city alone. At the moment, my android device all the information at once. I then create 1000 itemized overlays and add them to the map view.
This in turn makes my emulator and phone run slow.
One idea I had was to zoom in on a location and then download and place a subset of the overlays on the map view.
Trouble I have with this
1. When I scroll on the map I don't know what event to register a listener to.
2. When the user zooms out I will still create the large number of itemised overlays.
My question to you guys is,
How could I overcome these problems? Or how would you go about doing this?
The solution Would be something similar to how google maps works. U c a not so detailed map when u zoom out, but when u zoom in it shows you a detailed map that reloads as you move around
I then create 1000 itemized overlays and add them to the map view.
Ummmm... please tell me that this is a typo, and you meant "1000 OverlayItems", not "1000 ItemizedOverlays".
1000 OverlayItems might be bad enough -- ItemizedOverlay isn't really designed for that many points.
When I scroll on the map I don't know what event to register a listener to.
I don't think there is a straightforward solution here. I think others have kinda reverse-engineered the touch events and are listening on those. See Android Maps get Scroll Event for more.
When the user zooms out I will still create the large number of itemised overlays.
Use a prioritization scheme. What you see with Google Maps is that only the top N items are shown, where "top" is based on some sort of priority mechanism.
Related
I have a RecyclerView with the implementation of ItemTouchHelper. I am dragging and sorting the items in RecyclerView using ItemTouchHelper.
Also I am performing different actions on different direction of swipe. If user goes from left to right (Swipe) I just Deactivate status of item. If he perform right to left swipe I activate the relevant item.
What I want:
But now here comes the change, What I want is that I need to show some icons after I perform right or left swipe. And By clicking on those icons/buttons I want to perform action then.
Problem:
Problem is as I told you I have implementation of ItemTouchHelper, then how I am doing to perform what I wanted (as described above)
How to solve this? I have seen many libraries but they have limitations, also as the app has very much things going and there are some more implementations on RecyclerView used in our app, so I really do not want to risk the rest of implementations for the sake of this..
UPDATE 1:
To clear my question more I am going to add on more. Right now My implementation is something like this. But this is not what I want. I want to show swipe menu for any type of swipe I mean either it is left or right I want to show some icons on left and right side of item
You can take iOS swipe menu as an example (see here). I want exactly same behavior in android.
You're asking the impossible: suggest a library that doesn't exist (as you have already found out).
You're asking people to also find a solution for a problem you only briefly describe. You're not providing any code whatsoever, nor any specific issue you're facing when trying to come up with a solution; you're essentially expecting magic to happen.
How can you make this better?
Provide something like: "I'm attempting to implement a swipe solution for a recycler view's row; when I try to do YYYY is happening instead. Hhere's my piece of code where I do , calculated like this , am I missing something?"
Anyway...
You claim to be using an ItemTouchHelper already, so, if you look at how a very basic one works, you'll notice that the helper will ultimately draw on the canvas directly via:
#Override
public void onChildDraw(
final Canvas canvas,
final RecyclerView recyclerView,
final RecyclerView.ViewHolder viewHolder,
final float deltaX,
final float deltaY,
final int actionState,
final boolean isCurrentlyActive) {
This is derived from the platform ItemTouchHelper.SimpleCallback. So...
If you want to implement your solutions, you'll need to implement it there to do things like stop dragging, draw the content (icons), etc.
It's not a trivial solution and getting the whole thing right is difficult; more so if you introduce "some more implementations on RecyclerView".
I hope this answer points you in the right direction, and that your next related question is more about what you've tried (and failed) to do, than a "please do this for me" scenario. (If your intentions weren't those, please apologize, but you spent 5 minutes typing this question and it would take hours/days to implement this, so set your expectations this time).
Finally, when I wrote this, I realized most people wanted iOS swipe behavior; unfortunately, said behavior is not pre-implemented (like on iOS) on Android and you have to deal with it yourself; it's not impossible nor the most difficult task on earth to do on Android, but will give you a few headaches if you're hacking RecyclerView too much.
UPDATE
You've realized now, that ItemTouchHelper has a problem. It draws on the Canvas directly, so it has no knowledge of a Layout, View, Margin, etc. These are all things that live outside the realm of the touch helper. The helper is given a canvas, and drawing capabilities and that's it.
Where does this canvas size come from?
Well, it's calculated during the layout/measure pass(es) for the RecyclerView and its views.
How do I then stop dragging "at exactly the center of the screen" then?
Pass the values to your Helper; remember that the responsibility of calculating where the middle of the screen is, is not in the TouchHelper's contract; but your Activity/Fragment does know this. Provide the information the Touch Helper needs to perform the things you want it to perform.
Revert "back" to the original position, means knowledge of what the initial state was, etc. All this information is known by the RecyclerView and beyond, not the TouchHelper.
So you'd need to measure your layouts, save some values, pass them to the touchhelper so it can operate, etc.
As you can see, the full picture starts to become more and more complicated. My advice to you is:
Try to push this feature OUT as "the platform doesn't do it it will take time, it's not worth" (the worthiness and discoverability of swipe actions is dubious at best, but it's an ubiquitous action nowadays so you may have to do it regardless).
If you really have to do this, abstract things as much as you can, create all the classes/interfaces you think you can need, even if you end up with a "MiddleScreenCalculatorDelegate" kind of thing. It will be easier to fix later, but at least have each component do a very small subset of things.
Lastly, your item touch helper will have to calculate how much offset (delta) has the view been swiped already and stop when it reaches a known threshold.
Good luck :)
p.s.: I suggest you post a different question with specific issue(s) to get better help, this answer is very unhelpful as it is. :)
I'm making a custom home screen, and I would like to give the user the ability to use live wallpapers in my launcher/home screen. Settings android:Theme.Holo.Wallpaper.NoTitleBar as my AppTheme kind of what I want, but not exactly.
There are 2 possible solutions (but please tell me if you can think of another good one);
Use android:Theme.Holo.Wallpaper.NoTitleBar as my AppTheme
Live wallpapers are shown, but the user can't interact with them. It's not great, but I'm fine with this.
Implement it in the "proper" way, so that users can interact with it.
The big problem is that I can't find how to do this anywhere. All the documentation I can find tells me how to create a live wallpaper, but not how to implement support for it in my custom home screen.
Whichever approach I take, these are 2 problems I'd incur either way and would also like a solution to;
I need to calculate the "average colour" of the wallpaper (something similar is also fine). How do I do this with a live wallpaper, if at all possible?
I need to blur the wallpaper at some point. An acceptable solution here is to just overlay it with something that has a black transparent background instead of blurring it, but ideally I'd be able to blur it (even if I could just take kind of a static screenshot of the current state of the live wallpaper so I can blur that). If I can get a static snapshot from the current state of the live wallpaper that would also solve my previous problem.
Here's what I ended up doing;
Set android:Theme.Holo.Wallpaper.NoTitleBar as the AppTheme.
Disable colour calculation when a live wallpaper is set and default to a transparent black.
Use WallpaperManager.getInstance (this.context).getWallpaperInfo () != null to detect whether a live wallpaper is set.
While you can get a screenshot of your root view, the area where the live wallpaper is shown will be transparent. So that's no good. I ended up overlaying it with a transparent black overlay so that the white text that is displayed on it is still readable.
Apparently using android:Theme.Holo.Wallpaper.NoTitleBar does not stop the user from interacting with the live wallpaper. The live wallpapers I tested with (the default ones that come with Android) just didn't allow any kind of interaction, which I didn't realise.
I hope this information is able to save someone else some time.
I would like to know what the Android implementation is of this type of scrolling that you see in the Yahoo Weather App. Here is a video example:
http://www.youtube.com/watch?v=a-q_yetkpik
Any examples or ideas on how to implement this would sincerely help this poor lost soul!
Thank you
use that library https://github.com/xgc1986/ParallaxPagerLibrary, it's very easy to use, and it worked for me
demo
You should separate two different things here:
The horizontal scrolling
As you swipe your way through the viewpager, the background moves slower than the content does.
This effect can be achieved with the ParallaxPagerLibrary
The vertical scrolling
As you swipe up, the background image blurs away, making the "swiped up" content more visible to the user. This post explains it all and also provides a library.
But if you want it even better, someone wrote a simple "clone" of this weather app https://github.com/MoshDev/LikeYahooWeather
They customized ViewPager, the widget is called WeatherViewPager that it's unfortunately unavailable, looks like a ViewPager with a sort of parallax
You may take a look at https://play.google.com/store/apps/details?id=com.desarrollodroide.repos
it's a collection of usable opensource libraries
e.g. Utils->Paralloid or Utils->ParallaxScroll
I want to develop an android app, but I'm still not that great at using xml or the eclipse wysiwyg editor to make scalable and robust interfaces!
Below is a quick concept I drew up on word of what my main game screen will consist of:
I'm currently thinking a vertical linear frame first, with a frame that doesn't change for my important stats etc., then a frame in the middle which is switched by the buttons, but I'm stuck on how to implement this.
For the centre button screen, the map screen, I am hoping to add an image of a map which can be moved around, and somehow attach invisible button objects to points in this picture, maybe with an array of squares or something?
I understand this is a pretty open question and might be difficult to answer, but if you think you can help in anyway please do.
Thanks!
There is a log of possibilities, but you can use a LinearLayout with android:orientation="vertical" and include your stats in top. For the changing screens with buttons you can use a FragmentTabHost and create different Fragment for each of your views.
Check this example with a implementation.
Regarding the map, I think the easiest option is to use Google Maps Android API v2. Here is a example to use the maps v2 and a example of how to add markers to the map.
I have been searching for a view that can handle this. What i want is to allow the users to zoom in/out of an image.
Right now i can not find any pre-built solutions for this except the WebView. One could argue that Google should actually offer this without having to resort to the WebView (That one limits the layout possibilities).
I would like to have the same built-in functionality like for iPhones/iPads.
So question is, what user-built views are there out that could handle pinch-zoom in/out of an image?
I have tested 2 different custom made solutions but neither worked as expected. One managed to re-size, but only in one direction at a time (either horizontally or vertically) and the other did not even work.
Update: It should be possible to use the solution with Android 2.3+. (Majority of the users are in that range)
I've found one very interesting few days ago. I think it's the best one I've seen. You can zoom with a double tap, pinch, has acceleration with movement, etc.
Take a look here.
There are several Android view libraries that can handle what you are looking for.
Check out these
https://github.com/chrisbanes/PhotoView
http://code.google.com/p/android-pinch/
https://github.com/jasonpolites/gesture-imageview
I achieved good results with this library: http://blog.sephiroth.it/2011/04/04/imageview-zoom-and-scroll/
It is not a total drop in replacement for imageview but it also works in a Viewpager where the Viewpager handles horizontal Swiping for page changes.
Starting with Android 3.0 (API Level 11) you can zoom every view using setScaleX(), setScaleY(), setPivotX(), setPivotY() etc., or just using setMatrix().