added volume control

This commit is contained in:
badaix 2016-01-06 23:42:31 +01:00
parent ef0cd731dd
commit 86f766721d
4 changed files with 43 additions and 36 deletions

View file

@ -4,6 +4,8 @@ import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.SeekBar;
import android.widget.TextView;
@ -17,6 +19,7 @@ public class ClientInfoItem extends LinearLayout {
private TextView title;
private TextView summary;
private SeekBar volumeSeekBar;
private ClientInfo clientInfo;
public ClientInfoItem(Context context, ClientInfo clientInfo) {
@ -26,13 +29,19 @@ public class ClientInfoItem extends LinearLayout {
vi.inflate(R.layout.client_info, this);
title = (TextView) findViewById(R.id.title);
summary = (TextView) findViewById(R.id.summary);
volumeSeekBar = (SeekBar) findViewById(R.id.volumeSeekBar);
volumeSeekBar.setMax(100);
setClientInfo(clientInfo);
}
public void setClientInfo(final ClientInfo clientInfo) {
this.clientInfo = clientInfo;
title.setText(clientInfo.getName());
if (!clientInfo.getName().isEmpty())
title.setText(clientInfo.getName());
else
title.setText(clientInfo.getHost());
summary.setText(clientInfo.getMac());
volumeSeekBar.setProgress(clientInfo.getVolume().getPercent());
}
public ClientInfo getClientInfo() {

View file

@ -345,7 +345,8 @@ public class MainActivity extends ActionBarActivity implements View.OnClickListe
this.runOnUiThread(new Runnable() {
@Override
public void run() {
clientInfoAdapter.add(clientInfo);
if (clientInfo.isConnected())
clientInfoAdapter.add(clientInfo);
}
});
}
@ -360,7 +361,8 @@ public class MainActivity extends ActionBarActivity implements View.OnClickListe
this.runOnUiThread(new Runnable() {
@Override
public void run() {
clientInfoAdapter.add(clientInfo);
if (clientInfo.isConnected())
clientInfoAdapter.add(clientInfo);
}
});
}

View file

@ -77,15 +77,10 @@
android:id="@+id/button" />
<ListView
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/lvClient" />
</LinearLayout>
<TextView
android:id="@+id/section_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>

View file

@ -5,13 +5,8 @@
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeight"
android:paddingRight="?android:attr/scrollbarSize">
<ImageView
android:id="@+android:id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
android:paddingRight="?android:attr/scrollbarSize"
android:orientation="vertical">
<RelativeLayout
android:layout_width="wrap_content"
@ -22,28 +17,34 @@
android:layout_marginTop="6dip"
android:layout_weight="1">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:text="Title"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/title"
android:layout_below="@id/title"
android:maxLines="4"
android:text="Summary"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary" />
</RelativeLayout>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:text="Title"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/title"
android:layout_below="@id/title"
android:maxLines="4"
android:text="Summary"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary" />
<SeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/volumeSeekBar" />
</LinearLayout>