-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated hiding buttons to use API in NavigationView instead of option
- Loading branch information
Devota Aabel
committed
Sep 10, 2018
1 parent
12f0edb
commit 8d1c28e
Showing
17 changed files
with
502 additions
and
271 deletions.
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
23 changes: 23 additions & 0 deletions
23
...ation-ui/src/main/java/com/mapbox/services/android/navigation/ui/v5/NavigationButton.java
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,23 @@ | ||
package com.mapbox.services.android.navigation.ui.v5; | ||
|
||
import android.view.View; | ||
|
||
public interface NavigationButton { | ||
|
||
/** | ||
* Adds an onClickListener to the button | ||
* | ||
* @param onClickListener to add | ||
*/ | ||
void addOnClickListener(View.OnClickListener onClickListener); | ||
|
||
/** | ||
* Hides the widget | ||
*/ | ||
void hide(); | ||
|
||
/** | ||
* Shows the widget | ||
*/ | ||
void show(); | ||
} |
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
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
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
87 changes: 87 additions & 0 deletions
87
...rc/main/java/com/mapbox/services/android/navigation/ui/v5/instruction/FeedbackButton.java
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,87 @@ | ||
package com.mapbox.services.android.navigation.ui.v5.instruction; | ||
|
||
import android.content.Context; | ||
import android.support.constraint.ConstraintLayout; | ||
import android.support.design.widget.FloatingActionButton; | ||
import android.util.AttributeSet; | ||
import android.view.View; | ||
|
||
import com.mapbox.services.android.navigation.ui.v5.NavigationButton; | ||
import com.mapbox.services.android.navigation.ui.v5.R; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class FeedbackButton extends ConstraintLayout implements NavigationButton { | ||
private FloatingActionButton feedbackFab; | ||
private List<OnClickListener> onClickListeners; | ||
|
||
public FeedbackButton(Context context) { | ||
this(context, null); | ||
} | ||
|
||
public FeedbackButton(Context context, AttributeSet attrs) { | ||
this(context, attrs, -1); | ||
} | ||
|
||
public FeedbackButton(Context context, AttributeSet attrs, int defStyleAttr) { | ||
super(context, attrs, defStyleAttr); | ||
initialize(context); | ||
} | ||
|
||
/** | ||
* Adds an onClickListener to the button | ||
* | ||
* @param onClickListener to add | ||
*/ | ||
@Override | ||
public void addOnClickListener(OnClickListener onClickListener) { | ||
if (!onClickListeners.contains(onClickListener)) { | ||
onClickListeners.add(onClickListener); | ||
} | ||
} | ||
|
||
/** | ||
* Hides the widget | ||
*/ | ||
@Override | ||
public void hide() { | ||
setVisibility(GONE); | ||
} | ||
|
||
/** | ||
* Shows the widget | ||
*/ | ||
@Override | ||
public void show() { | ||
setVisibility(VISIBLE); | ||
} | ||
|
||
@Override | ||
protected void onFinishInflate() { | ||
super.onFinishInflate(); | ||
bind(); | ||
setupOnClickListeners(); | ||
} | ||
|
||
private void initialize(Context context) { | ||
inflate(context, R.layout.feedback_button_layout, this); | ||
} | ||
|
||
private void bind() { | ||
feedbackFab = findViewById(R.id.feedbackFab); | ||
} | ||
|
||
private void setupOnClickListeners() { | ||
onClickListeners = new ArrayList<>(); | ||
|
||
feedbackFab.setOnClickListener(new OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
for (OnClickListener onClickListener : onClickListeners) { | ||
onClickListener.onClick(view); | ||
} | ||
} | ||
}); | ||
} | ||
} |
Oops, something went wrong.