|
I am working with googlemap. I have implemented custom marker window, this window contains photo of the marker. I am taking the url of the photo as string and setting it into imageview with thread. However, the code is not syncronized with user. When I have clicked the marker, it shows the photo of the previeus marker that I have clicked. When I did debug, I can see that true url values are coming from background but the setting image into imageview operation is becoming late. How can I solve this problem? I have tried picasso and glide but still same problem.
@Override
public void onMapReady(GoogleMap map) {
this.infoWindow = (ViewGroup)getActivity().getLayoutInflater().inflate(R.layout.info_marker_window, null);
this.mekanfoto = (ImageView) infowindow.findViewById(R.id.mekan_foto);
googleMap = map;
if(googleMap!=null){
googleMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
@Override
public View getInfoWindow(Marker marker) {
return null;
}
@Override
public View getInfoContents(final Marker marker) {
if(mLastLocation.getLatitude()!=marker.getPosition().latitude||
mLastLocation.getLongitude()!=marker.getPosition().longitude){
customMarker = CustomMarker.getCustomMarker(listCustomMarker, marker);
final String URL = customMarker.getVenue().getFoto();
createThread(mekanfoto,URL).start();
mapWrapperLayout.setMarkerWithInfoWindow(marker, infoWindow);
return infoWindow;
}
return null;}
});
}
}
private synchronized Thread createThread(final ImageView imageView, final String URL)
{
final Bitmap[] b = new Bitmap[1];
Thread thread=new Thread(new Runnable() {
@Override
public void run() {
b[0] =download_Image(URL,imageView);
}
});
return thread;
}
public Bitmap download_Image(String url,ImageView imageview) {
URL newurl = null;
try {
newurl = new URL(url);
} catch (MalformedURLException e) {
e.printStackTrace();
}
Bitmap mIcon_val = null;
try {
URLConnection urlConnection=newurl.openConnection();
InputStream is=urlConnection.getInputStream();
mIcon_val= BitmapFactory.decodeStream(is);
} catch (Exception e) {
e.printStackTrace();
}finally {
}
imageview.setImageBitmap(mIcon_val);
return mIcon_val;
}
modified 18-Apr-17 12:31pm.
|
|
|
|
|
Having the coordinates from Android Sensor and try to calculate the distance in Excel according to:
http://andrew.hedges.name/experiments/haversine/
dlon = lon2 - lon1
dlat = lat2 - lat1
a = (sin(dlat/2))^2 + cos(lat1) * cos(lat2) * (sin(dlon/2))^2
c = 2 * atan2( sqrt(a), sqrt(1-a) )
d = R * c (where R is the radius of the Earth)
Enter my two Locations in the calculator (link above) shows me the right result, it is about 6m.
When I calculate it by Excel I get 20Km instead of 6 meters
I'm strongly assuming that I mix up rad vs. degree but I do not find where I'm wrong.
Excel trigonometric functions expect everything in rad so I adjust lon1, lon2, lat1, lat2 first into rad...
Where I could be wrong, any idea?
Thank you in advance.
N.B: I'm also not sure whether it is ok to use the sensor decimal values directly for trigonometric function, maybe this is the key Point.
[Edit]
c allways Shows me something very near PI, e.g. 3.14159145
modified 19-Jan-21 21:04pm.
|
|
|
|
|
0x01AA wrote: Where I could be wrong Just about anywhere. Does this have something to do with Android programming?
|
|
|
|
|
Yes it has and no. The Lib I'm using is Embarcardero Fire-ThisAndThat. Some of the Sensors are Android specific supported
So where you suggest to ask the question?
Sorry, but .... grrrr
AND PLEASE DO NOT MARK YOUR COMMENT AS ANSWER TO EARN POINTS!!
SILLY DOWNVOTER!
SORRY, BRUNO
modified 19-Jan-21 21:04pm.
|
|
|
|
|
0x01AA wrote: Having the coordinates from Android Sensor and try to calculate the distance in Excel according to: So where exactly is the Android code issue?
Sorry but ?
|
|
|
|
|
If you are not familar with it why you bother about it?
DOWNVOTE TWO TIMES, SORRY YOU ARE AN A*H*. Now please Report me as abuser!
modified 19-Jan-21 21:04pm.
|
|
|
|
|
0x01AA wrote: If you are not familar with it why you bother about it? Richard is more familiar with "it" than most folks here (combined). Don't fault him for you not asking the correct question.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
He is familiar with a lot of things, I agree! But as soon he is not familiar with a subject he is Stalking the one who is asking... and my Feeling is, that he is Stalking especally me.
modified 19-Jan-21 21:04pm.
|
|
|
|
|
0x01AA wrote: ...he is Stalking especally me. So he is pursuing or approaching you stealthily? Really?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
0x01AA wrote: and my Feeling is, that he is Stalking especally me. Be afraid, be very afraid.
|
|
|
|
|
0x01AA wrote: So where you suggest to ask the question? Maybe the site from where you obtained the Embarcardero Fire-ThisAndThat lib.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
0x01AA wrote: Having the coordinates from Android Sensor... What coordinates?
0x01AA wrote: ...and try to calculate the distance... From/to what?
0x01AA wrote:
Enter my two Locations in the calculator (link above) shows me the right result, it is about 6m.
When I calculate it by Excel I get 20Km instead of 6 meters So then there's a difference between the two formulas. Since you've only shown one, how could anyone possibly guess as to what is wrong?
0x01AA wrote:
I'm strongly assuming that I mix up rad vs. degree but I do not find where I'm wrong.
Excel trigonometric functions expect everything in rad so I adjust lon1, lon2, lat1, lat2 first into rad... It's either degrees or radians. If you've tried both and neither produce the correct result, then that's not the (only) problem.
0x01AA wrote:
N.B: I'm also not sure whether it is ok to use the sensor decimal values directly for trigonometric function... Are they expecting floating-point values? If so, then you must use the "decimal values."
All of this aside, where's the Android issue?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Quote: Are they expecting floating-point values? If so, then you must use the "decimal values."
Expressed in "Expressed in decimal degrees" as pointed out by the link I gave.
Quote: It's either degrees or radians
Assume, I'm quite familiar to distinguish between them;)
The curious Thing:
2.0 * ArcTan2(Sqrt(1.0 - xA), Sqrt(xA));
instead of
2.0 * ArcTan2(Sqrt(xA), Sqrt(1.0 - xA));
solved the cross check with Excel for the Moment. While the second one still is ok in c++
Why it solved it? For this I Need to bring back first trigo back into my mind.
Quote: All of this aside, where's the Android issue
Do you program for programming sake or do you even program to solve a task?
Ok, it is not Android specific, but while working with Android at the Moment, I thought I will ask this here. Now hang me higher because of this delinquency
modified 19-Jan-21 21:04pm.
|
|
|
|
|
0x01AA wrote: Why it solved it? Because the two function signatures are different. In Excel, it is:
ATAN2(x,y) and for JavaScript, it is:
ATAN2(y,x)
0x01AA wrote: Ok, it is not Android specific, but while working with Android at the Moment, I thought I will ask this here. Perhaps here would be a better choice.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
modified 29-Mar-17 10:21am.
|
|
|
|
|
Thank you for the link. I was not aware that this exists.
modified 19-Jan-21 21:04pm.
|
|
|
|
|
Actually i had created database now i want to retrive it on list items click how should i connect both of this apps please kindly give attention in this.
|
|
|
|
|
It rather depends on what database you are using, and how the data is structured.
|
|
|
|
|
we are going to develope an app that are realted to the health care.we need som ecode and features that you know and it can increase the quality of our app
|
|
|
|
|
Member 13073018 wrote: som ecode and features
Perhaps your app could extend to telepathic powers, reading the mind of anybody using it?!
Think about it... how can anybody offer any useful advice when you ask such a vague question. Please give us some information about what you want to achieve. I also suggest that unless you've developed an app or two before, don't waste your time looking to build one from random samples that you might be able to pull together. You really need to be realistic about what can be done starting from where you are.
|
|
|
|
|
So, I built this HTML5 multiplayer online game, https://SpaceBlaster.io, and now I want to put it in the Google Play Store. It already works on mobile and computer browser. Can I just slap the HTML5 code into a cordova project and it will work as an android app? How does the app know which Websocket server to connect to? Have any of you done this sort of thing before? I'm kind of at a loss as to how to proceed. I already have one cordova app in the Play Store, so I'm familiar with that routine, but that was a standalone app designed from the beginning to be just a mobile app.
I hope that all wasn't too confusing.
Thanks in advance!
You can't win.
You can't break even.
You can't quit.
You're welcome.
|
|
|
|
|
I apologize for the vague title of this thread. I am a C# developer and I am having some issues with trying to understand the way things are done in Java / Android.
private boolean EverPlayedNextLevel(final int Level){
locked = false;
String Uid = acct.getId();
DatabaseReference db = FirebaseDatabase.getInstance().getReference();
Query query = db.child("levels/uid/" + Uid + "/" + Level);
query.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
locked = ((long)dataSnapshot.getValue() == -1);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
return locked;
}
The Boolean variable locked is a class level variable. Notice that I set it to false at the beginning of the method. If I set a breakpoint at the closing brace of the onDataChange "inner" method and
((long)dataSnapshot.getValue() == -1); returns true, then locked is of course true. But the method EverPlayedNextLevel still returns false. How should I deal with this? I don't understand what is going on. I want EverPlayedNextLevel to return true if
((long)dataSnapshot.getValue() == -1); evaluates to true.
|
|
|
|
|
You are casting your number to a long. What happens when you cast -1 to a long?
Forget my word , long is signed.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
modified 23-Feb-17 15:31pm.
|
|
|
|
|
Thanks Eddy. I did do some research on Long after your comment, but yes, my comparison is working with long.
|
|
|
|
|
I'm not an Android and Java expert but it looks like onDataChange is an asynchronous function which is executed in a different thread.
Then EverPlayedNextLevel might return before locked has been set.
A quick research before hitting the post button found this very similar problem:
android - Return value from valueEventListener java - Stack Overflow[^]
|
|
|
|
|
You are correct, it's an event handler.
|
|
|
|