firstView;
58 | if (_targetView != null) {
59 | firstView = _targetView;
60 | _targetView = null;
61 |
62 | final XulView view = firstView.get();
63 | if (view == null) {
64 | continue;
65 | }
66 | viewRender = view._render;
67 | if (viewRender == null) {
68 | continue;
69 | }
70 | } else {
71 | firstView = _stack.poll();
72 | if (firstView == null) {
73 | // finished
74 | _finished = true;
75 | if (XulManager.PERFORMANCE_BENCH) {
76 | // Log.d("BENCH!!!", "collect finished!!!");
77 | }
78 | break;
79 | }
80 | final XulView view = firstView.get();
81 | if (view == null) {
82 | continue;
83 | }
84 | viewRender = view._render;
85 | if (viewRender == null) {
86 | continue;
87 | }
88 | if (view instanceof XulArea) {
89 | XulArea area = (XulArea) view;
90 | final XulArea.XulElementArray children = area._children;
91 | final int childrenSize = children.size();
92 | final XulElement[] array = children.getArray();
93 | for (int i = 0; i < childrenSize; i++) {
94 | XulElement child = array[i];
95 | if (child instanceof XulArea) {
96 | _stack.add(((XulView) child).getWeakReference());
97 | } else if (child instanceof XulView) {
98 | _stack.add(((XulView) child).getWeakReference());
99 | }
100 | }
101 | }
102 | }
103 |
104 | if (!viewRender.doSuspendRecycle(_recycleLevel)) {
105 | continue;
106 | }
107 | _targetView = firstView;
108 | return;
109 | }
110 | if (XulManager.PERFORMANCE_BENCH) {
111 | // Log.d("BENCH!!!", String.format("collect nothing %d", XulUtils.timestamp_us() - beginTime));
112 | }
113 | return;
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/xul/src/com/caverock/androidsvg/SVGExternalFileResolver.java:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright 2013 Paul LeBeau, Cave Rock Software Ltd.
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.caverock.androidsvg;
18 |
19 | import android.graphics.Bitmap;
20 | import android.graphics.Typeface;
21 |
22 | import com.caverock.androidsvg.SVG.Style;
23 |
24 | /**
25 | * Resolver class used by the renderer when processing Text and Image elements.
26 | *
27 | * The default behaviour is to tell AndroidSVG that the reference could not be found.
28 | *
29 | * Extend this class and override the methods if you want to customise how AndroidSVG treats font and image references.
30 | */
31 |
32 | public abstract class SVGExternalFileResolver
33 | {
34 | /**
35 | * Called by renderer to resolve font references in <text> elements.
36 | *
37 | * Return a {@code Typeface} instance, or null if you want the renderer to ignore
38 | * this font and use the default Android font instead.
39 | *
40 | * Note that AndroidSVG does not attempt to cache Typeface references. If you want
41 | * them cached, for speed or memory reasons, you should do so yourself.
42 | *
43 | * @param fontFamily Font family as specified in a font-family style attribute.
44 | * @param fontWeight Font weight as specified in a font-weight style attribute.
45 | * @param fontStyle Font style as specified in a font-style style attribute.
46 | * @return an Android Typeface instance, or null
47 | */
48 | public Typeface resolveFont(String fontFamily, int fontWeight, String fontStyle)
49 | {
50 | return null;
51 | }
52 |
53 | /**
54 | * Called by renderer to resolve image file references in <image> elements.
55 | *
56 | * Return a {@code Bitmap} instance, or null if you want the renderer to ignore
57 | * this image.
58 | *
59 | * Note that AndroidSVG does not attempt to cache Bitmap references. If you want
60 | * them cached, for speed or memory reasons, you should do so yourself.
61 | *
62 | * @param filename the filename as provided in the xlink:href attribute of a <image> element.
63 | * @return an Android Bitmap object, or null if the image could not be found.
64 | */
65 | public Bitmap resolveImage(String filename)
66 | {
67 | return null;
68 | }
69 |
70 | /**
71 | * Called by renderer to determine whether a particular format is supported. In particular,
72 | * this method is used in <switch> elements when processing {@code requiredFormats}
73 | * conditionals.
74 | *
75 | * @param mimeType A MIME type (such as "image/jpeg").
76 | * @return true if your {@code resolveImage()} implementation supports this file format.
77 | */
78 | public boolean isFormatSupported(String mimeType)
79 | {
80 | return false;
81 | }
82 | }
83 |
--------------------------------------------------------------------------------