-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add compass view #177
Merged
Merged
Add compass view #177
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2046297
Adds basic north button to reset map rotation
ecgreb 6c03fa6
More north button updates
ecgreb 3577f9a
Update north arrow (compass) asset
ecgreb 078599d
Update tests
ecgreb 7be4e0d
Code cleanup
ecgreb 33ef9d3
Renames "north button" to "compass"
ecgreb db3ce71
Adds CompassView class and rotation animation
ecgreb af81954
Adds lazy instantiation of view properties
ecgreb 52635bc
Adds compass fade in/out
ecgreb ca8fd09
Rotate compass along shortest path to North
ecgreb 8bc68bc
Show compass in route preview and routing mode
ecgreb File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
app/src/main/kotlin/com/mapzen/erasermap/view/CompassView.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.mapzen.erasermap.view | ||
|
||
import android.content.Context | ||
import android.util.AttributeSet | ||
import android.view.LayoutInflater | ||
import android.widget.ImageView | ||
import android.widget.RelativeLayout | ||
import com.mapzen.erasermap.R | ||
|
||
public class CompassView(context: Context, attrs: AttributeSet) : RelativeLayout(context, attrs) { | ||
|
||
val background: ImageView by lazy { findViewById(R.id.background) as ImageView } | ||
val compass: ImageView by lazy { findViewById(R.id.compass) as ImageView } | ||
|
||
init { | ||
(context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater) | ||
.inflate(R.layout.view_compass, this, true) | ||
} | ||
|
||
override fun setRotation(rotation: Float) { | ||
compass.rotation = rotation | ||
if (alpha == 0f) { | ||
alpha = 1f | ||
} | ||
} | ||
|
||
public fun reset() { | ||
val newRotation = if (compass.rotation < 180) 0f else 360f | ||
compass.animate().setDuration(1000).rotation(newRotation) | ||
animate().setDuration(1000).alpha(0f).setStartDelay(1000) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay programming
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\o/