1919import android .os .Bundle ;
2020import android .os .Handler ;
2121import android .os .Looper ;
22+ import android .util .Log ;
2223import android .view .View ;
2324import android .widget .AdapterView ;
25+ import android .widget .Button ;
2426import android .widget .CheckBox ;
27+ import android .widget .EditText ;
28+ import android .widget .LinearLayout ;
2529import android .widget .SeekBar ;
2630import android .widget .Spinner ;
2731import android .widget .TextView ;
32+ import android .widget .Toast ;
2833
2934import java .io .IOException ;
3035import java .util .Locale ;
@@ -42,6 +47,11 @@ public final class TestOutputActivity extends TestOutputActivityBase {
4247 private CheckBox mShouldSetStreamControlByAttributes ;
4348 private boolean mShouldDisableForCompressedFormat = false ;
4449
50+ private LinearLayout mFlushFromFrameLayout ;
51+ private EditText mFlushFromFrameEditText ;
52+ private Spinner mFlushFromAccuracySpinner ;
53+ private Button mFlushFromFrameButton ;
54+
4555 private class OutputSignalSpinnerListener implements android .widget .AdapterView .OnItemSelectedListener {
4656 @ Override
4757 public void onItemSelected (AdapterView <?> parent , View view , int pos , long id ) {
@@ -113,6 +123,17 @@ protected void onCreate(Bundle savedInstanceState) {
113123 mVolumeSeekBar .setOnSeekBarChangeListener (mVolumeChangeListener );
114124
115125 mShouldSetStreamControlByAttributes = (CheckBox ) findViewById (R .id .enableSetStreamControlByAttributes );
126+
127+ mFlushFromFrameLayout = (LinearLayout ) findViewById (R .id .flushFromFrameLayout );
128+ mFlushFromFrameEditText = (EditText ) findViewById (R .id .flushFromFrameEditText );
129+ mFlushFromAccuracySpinner = (Spinner ) findViewById (R .id .flushFromAccuracySpinner );
130+ mFlushFromFrameButton = (Button ) findViewById (R .id .flushFromFrameButton );
131+ mFlushFromFrameButton .setOnClickListener (new View .OnClickListener () {
132+ @ Override
133+ public void onClick (View v ) {
134+ flushFromFrame ();
135+ }
136+ });
116137 }
117138
118139 @ Override
@@ -180,6 +201,27 @@ public void startAudio() throws IOException {
180201 mOutputSignalSpinner .setEnabled (false );
181202 }
182203
204+ public void flushFromFrame () {
205+ try {
206+ int accuracy = mFlushFromAccuracySpinner .getSelectedItemPosition ();
207+ long positionInFrames = Long .parseLong (mFlushFromFrameEditText .getText ().toString ());
208+ long result = flushFromFrameNative (accuracy , positionInFrames );
209+ if (result >= 0 ) {
210+ Toast .makeText (this ,
211+ String .format ("Successfully flushed from: %d, actual flushed position: %d" ,
212+ positionInFrames , result ),
213+ Toast .LENGTH_LONG ).show ();
214+ } else {
215+ Toast .makeText (
216+ this , "Failed to flush from Frame" , Toast .LENGTH_LONG ).show ();
217+ }
218+ } catch (NumberFormatException e ) {
219+ Log .e (TAG , "Failed to flushFromFrame, the requested frame(" +
220+ mFlushFromFrameEditText .getText ().toString () + ") is invalid" );
221+ showErrorToast ("Invalid number of frames" );
222+ }
223+ }
224+
183225 public void onChannelBoxClicked (View view ) {
184226 CheckBox checkBox = (CheckBox ) view ;
185227 String text = (String ) checkBox .getText ();
0 commit comments