Debian Codegraph @

tests/VoiceInteraction/src/com/android/test/voiceinteraction/AsyncStructure.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
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 * Test for asynchronously creating additional assist structure.
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 // Simulate taking a long time to build this.
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 }