forked from bradfitz/android-squeezer
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
112 additions
and
29 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
54 changes: 54 additions & 0 deletions
54
Squeezer/src/main/java/uk/org/ngo/squeezer/PlayerDropdownAdapter.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,54 @@ | ||
package uk.org.ngo.squeezer; | ||
|
||
import android.content.Context; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ArrayAdapter; | ||
import android.widget.CheckBox; | ||
import android.widget.TextView; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import java.util.List; | ||
|
||
import uk.org.ngo.squeezer.model.Player; | ||
|
||
class PlayerDropdownAdapter extends ArrayAdapter<Player> { | ||
private final Player activePlayer; | ||
private boolean continuePlayback; | ||
|
||
public PlayerDropdownAdapter(Context actionBarContext, List<Player> connectedPlayers, Player activePlayer) { | ||
super(actionBarContext, 0); | ||
add(null); | ||
addAll(connectedPlayers); | ||
this.activePlayer = activePlayer; | ||
} | ||
|
||
@Override | ||
public @NonNull View getView(int position, View convertView, @NonNull ViewGroup parent) { | ||
Player item = getItem(position); | ||
if (item == null) { | ||
View view = LayoutInflater.from(getContext()).inflate(R.layout.continue_playback, parent, false); | ||
view.setOnClickListener(v -> { | ||
continuePlayback = !continuePlayback; | ||
view.<CheckBox>findViewById(R.id.checkbox).setChecked(continuePlayback); | ||
}); | ||
return view; | ||
} else { | ||
TextView view = (TextView) LayoutInflater.from(getContext()).inflate(R.layout.dropdown_item, parent, false); | ||
view.setText(item.getName()); | ||
return view; | ||
} | ||
} | ||
|
||
@Override | ||
public boolean isEnabled(int position) { | ||
Player item = getItem(position); | ||
return !(item == null || item.equals(activePlayer)); | ||
} | ||
|
||
public boolean continuePlayback() { | ||
return continuePlayback; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<LinearLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<CheckBox | ||
android:id="@+id/checkbox" | ||
android:layout_width="wrap_content" | ||
android:layout_height="48dp" | ||
android:clickable="false" /> | ||
|
||
<TextView | ||
style="@style/SqueezerWidget.DropdownText" | ||
android:layout_weight="1" | ||
android:layout_width="0dp" | ||
android:text="@string/continue_playback"/> | ||
|
||
</LinearLayout> |
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 |
---|---|---|
@@ -1,10 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<TextView xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:ellipsize="end" | ||
android:maxLines="1" | ||
android:padding="16dp" | ||
android:textAppearance="?attr/textAppearanceSubtitle1" | ||
tools:text= "text"/> | ||
xmlns:tools="http://schemas.android.com/tools" | ||
style="@style/SqueezerWidget.DropdownText" | ||
android:layout_width="match_parent" | ||
android:padding="12dp" | ||
tools:text="text" /> |
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