| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.android.test.voiceinteraction; |
| 18 |
|
| 19 |
import android.annotation.Nullable; |
| 20 |
import android.content.Context; |
| 21 |
import android.util.AttributeSet; |
| 22 |
import android.view.View; |
| 23 |
import android.view.ViewStructure; |
| 24 |
import android.widget.TextView; |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
public class AsyncStructure extends TextView { |
| 30 |
public AsyncStructure(Context context, @Nullable AttributeSet attrs) { |
| 31 |
super(context, attrs); |
| 32 |
} |
| 33 |
|
| 34 |
@Override |
| 35 |
public void onProvideVirtualStructure(ViewStructure structure) { |
| 36 |
structure.setChildCount(1); |
| 37 |
final ViewStructure child = structure.asyncNewChild(0); |
| 38 |
final int width = getWidth(); |
| 39 |
final int height = getHeight(); |
| 40 |
(new Thread() { |
| 41 |
@Override |
| 42 |
public void run() { |
| 43 |
|
| 44 |
try { |
| 45 |
sleep(2000); |
| 46 |
} catch (InterruptedException e) { |
| 47 |
} |
| 48 |
child.setClassName(AsyncStructure.class.getName()); |
| 49 |
child.setVisibility(View.VISIBLE); |
| 50 |
child.setDimens(width / 4, height / 4, 0, 0, width / 2, height / 2); |
| 51 |
child.setEnabled(true); |
| 52 |
child.setContentDescription("This is some async content"); |
| 53 |
child.setText("We could have lots and lots of async text!"); |
| 54 |
child.asyncCommit(); |
| 55 |
} |
| 56 |
}).start(); |
| 57 |
} |
| 58 |
} |