Debian Codegraph @

tests/HwAccelerationTest/src/com/android/test/hwui/MoreNinePatchesActivity.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2010 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.hwui;
18
19 import android.app.Activity;
20 import android.content.Context;
21 import android.content.res.Resources;
22 import android.graphics.Canvas;
23 import android.graphics.drawable.Drawable;
24 import android.os.Bundle;
25 import android.view.Gravity;
26 import android.view.View;
27 import android.widget.FrameLayout;
28
29 @SuppressWarnings({"UnusedDeclaration"})
30 public class MoreNinePatchesActivity extends Activity {
31 @Override
32 protected void onCreate(Bundle savedInstanceState) {
33 super.onCreate(savedInstanceState);
34
35 FrameLayout layout = new FrameLayout(this);
36 PatchView b = new PatchView (this);
37 b.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
38 FrameLayout.LayoutParams.MATCH_PARENT, Gravity.CENTER));
39 layout.addView(b);
40 layout.setBackgroundColor(0xffffffff);
41
42 setContentView(layout);
43 }
44
45 private class PatchView extends View {
46 private final Drawable mDrawable1;
47 private final Drawable mDrawable2;
48 private final Drawable mDrawable3;
49
50 private PatchView(Context context) {
51 super(context);
52 Resources res = context.getResources();
53 mDrawable1 = res.getDrawable(R.drawable.progress_vertical_holo_dark);
54 mDrawable2 = res.getDrawable(R.drawable.scrubber_progress_vertical_holo_dark);
55 mDrawable3 = res.getDrawable(R.drawable.scrubber_vertical_primary_holo);
56 }
57
58 @Override
59 protected void onDraw(Canvas canvas) {
60 super.onDraw(canvas);
61
62 canvas.translate(100, 100);
63 mDrawable1.setBounds(0, 0, 33, 120);
64 mDrawable1.setLevel(5000);
65 mDrawable1.draw(canvas);
66
67 canvas.translate(20, 0);
68 mDrawable2.setBounds(0, 0, 33, 120);
69 mDrawable2.setLevel(5000);
70 mDrawable2.draw(canvas);
71
72 canvas.translate(20, 0);
73 mDrawable3.setBounds(0, 0, 33, 120);
74 mDrawable3.draw(canvas);
75 }
76 }
77 }