/** * Walk the tree pre-order, finding all access nodes that are candidates and adding them to the * matches list. * * @param metadata Metadata implementation * @param node Root node to search * @param matches Collection to accumulate matches in * @throws TeiidComponentException * @throws QueryMetadataException */ List<CandidateJoin> findCandidate( PlanNode root, QueryMetadataInterface metadata, AnalysisRecord analysisRecord) throws QueryMetadataException, TeiidComponentException { List<CandidateJoin> candidates = new ArrayList<CandidateJoin>(); for (PlanNode joinNode : NodeEditor.findAllNodes(root, NodeConstants.Types.JOIN, NodeConstants.Types.ACCESS)) { CandidateJoin candidate = null; for (Iterator<PlanNode> j = joinNode.getChildren().iterator(); j.hasNext(); ) { PlanNode child = j.next(); child = FrameUtil.findJoinSourceNode(child); if (child.hasBooleanProperty(NodeConstants.Info.MAKE_NOT_DEP) || !isValidJoin(joinNode, child, analysisRecord)) { continue; } if (candidate == null) { candidate = new CandidateJoin(); candidate.joinNode = joinNode; candidates.add(candidate); } if (j.hasNext()) { candidate.leftCandidate = true; } else { candidate.rightCandidate = true; } } } return candidates; }
/** * 初始化第一个GroupView * * @param group */ private void intialFirstGroupView(Group group) { List<Hot> hots = group.getHots(); List<Picture> pictures = group.getPictures(); List<Layer> layers = group.getLayers(); List<Animation> animations = group.getAnimations(); List<Video> videos = group.getVideos(); List<PictureSet> pictureSets = group.getPictureSets(); List<Slider> sliders = group.getSliders(); List<Shutter> shutters = group.getShutters(); List<Group> groups = group.getGroups(); List<Rotater> rotater = group.getRotaters(); int[] frames = FrameUtil.frame2int(group.getFrame()); if (frames[2] >= 1024 && frames[3] >= 768 && (hots.size() != 0 || layers.size() != 0 || animations.size() != 0 || videos.size() != 0 || pictureSets.size() != 0 || pictures.size() != 0 || sliders.size() != 0 || shutters.size() != 0 || groups.size() > 1 || rotater.size() != 0)) { FirstGroupView firstGroupView = new FirstGroupView(context, group, flipperPageView, this); getFrameLayout().addView(firstGroupView); firstGroup = group; } else { if (group.getGroups().size() > 0) { intialFirstGroupView(group.getGroups().get(0)); } } /*List<Hot> hots=group.getHots(); List<Picture> pictures=group.getPictures(); List<Layer> layers=group.getLayers(); List<Animation> animations=group.getAnimations(); List<Video> videos=group.getVideos(); List<PictureSet> pictureSets=group.getPictureSets(); List<Slider> sliders=group.getSliders(); List<Shutter> shutters=group.getShutters(); //List<Group> groups=group.getGroups(); if(hots.size()!=0||layers.size()!=0||animations.size()!=0||videos.size()!=0||pictureSets.size()!=0||pictures.size()!=0||sliders.size()!=0||shutters.size()!=0){ int[] frames=FrameUtil.frame2int(group.getFrame()); if(frames[2]>=1024&&frames[3]>=768){ FirstGroupView firstGroupView=new FirstGroupView(context,group,flipperPageView,this); getFrameLayout().addView(firstGroupView); firstGroup=group; return; } }else{ List<Group> groups=group.getGroups(); if(groups!=null&&groups.size()!=0){ for(Group g:groups){ intialFirstGroupView(g); } } }*/ }
public CustVideoView(final Context context, Video video) { super(context); this.context = context; this.setVideo(video); String frame = video.getFrame(); String closesOnEnd = video.getClosesOnEnd(); if (closesOnEnd != null && closesOnEnd.equalsIgnoreCase("true")) { autoClose = true; } fullscreen = video.getFullscreen(); FrameLayout.LayoutParams params; int[] frames = FrameUtil.frame2int(frame); frames = FrameUtil.autoAdjust(frames, context); // 全屏模式 if (fullscreen.equalsIgnoreCase("true")) { act = (Activity) context; Display display = act.getWindowManager().getDefaultDisplay(); int width = display.getWidth(); int height = display.getHeight(); params = new FrameLayout.LayoutParams(width, height); params.topMargin = 0; params.leftMargin = 0; setMeasuredDimension(width, height); } else { params = new FrameLayout.LayoutParams(frames[2], frames[3]); params.setMargins(frames[0], frames[1], 0, 0); } setLayoutParams(params); String path = AppConfigUtil.getAppResource(AppConfigUtil.MAGAZINE_ID) + video.getResource(); setVideoPath(path); setVisibility(View.VISIBLE); setOnCompletionListener( new OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { MagazineActivity act = (MagazineActivity) context; act.getvControllers().remove(this); if (autoClose) { setVisibility(View.INVISIBLE); showLayers(); } } }); setOnClickListener(this); }
/** * Create and return animation drawable * * @param assetsFramesPath Path to folder with animation frames relative to "assets" folder of * android application * @param defaultDuration How long in milliseconds a single frame should appear * @param oneShot Play once (true) or repeat (false) * @return AnimationDrawable instance */ public AnimationDrawable create( final String assetsFramesPath, final int defaultDuration, final boolean oneShot) { final List<String> files = assetUtil.getFileList(assetsFramesPath); final SortedMap<Integer, String> frames = frameUtil.extractFrames(files); final AnimationDrawable animationDrawable = new AnimationDrawable(); animationDrawable.setOneShot(oneShot); for (final Integer key : frames.keySet()) { final Bitmap frame = BitmapFactory.decodeStream(assetUtil.open(frames.get(key))); animationDrawable.addFrame(new BitmapDrawable(frame), defaultDuration); } return animationDrawable; }
/** * 递归构建GroupView * * @param group */ private void buildGroupView(Group group) { if (group == null) { return; } List<Group> groups = group.getGroups(); if (groups != null && groups.size() != 0) { for (Group g : groups) { String oritentation = g.getOrientation(); View groupView = null; int childCount; if (oritentation.equals(BasicView.HORIZONTAL)) { HorizontalGroupView hGroupView = new HorizontalGroupView(context, g, flipperPageView, this); childCount = hGroupView.getFrameLayout().getChildCount(); groupView = hGroupView; } else { GroupView2 vGroupView = new GroupView2(context, g, flipperPageView, this); childCount = vGroupView.getFrameLayout().getChildCount(); groupView = vGroupView; } // 如果Group里只有嵌套的Group子控件则不添加到PageView里 if (childCount != 0) { String frame = g.getFrame(); int[] frames = FrameUtil.frame2int(frame); // 如果该层Group覆盖了整个屏幕,那么就将该Group下的子控件添加到该Group下 if (getBigGroupView() != null) { ((GroupView2) getBigGroupView()).getFrameLayout().addView(groupView); } else { getFrameLayout().addView(groupView); } if (frames[0] == 0 && frames[1] == 0 && frames[2] >= 1024 && frames[3] >= 768 && oritentation.equals(BasicView.VERTICAL)) { setBigGroupView(groupView); } groupViewList.add(groupView); } else { groupView = null; } List<Group> groups_ = g.getGroups(); if (groups_ != null && groups_.size() != 0) { for (Group g_ : groups_) { buildGroupView(g_); } } } } else { if (firstGroup != group) { List<Hot> hots = group.getHots(); List<Picture> pictures = group.getPictures(); List<Layer> layers = group.getLayers(); List<Animation> animations = group.getAnimations(); List<Video> videos = group.getVideos(); List<PictureSet> pictureSets = group.getPictureSets(); List<Slider> sliders = group.getSliders(); List<Shutter> shutters = group.getShutters(); if (hots.size() != 0 || layers.size() != 0 || animations.size() != 0 || videos.size() != 0 || pictureSets.size() != 0 || pictures.size() != 0 || sliders.size() != 0 || shutters.size() != 0) { View groupView = null; String oritentation = group.getOrientation(); if (oritentation.equals(BasicView.HORIZONTAL)) { groupView = new HorizontalGroupView(context, group, flipperPageView, this); } else { groupView = new GroupView2(context, group, flipperPageView, this); } if (getBigGroupView() != null) { View bigGroupView = getBigGroupView(); if (bigGroupView instanceof HorizontalGroupView) { ((HorizontalGroupView) bigGroupView).getFrameLayout().addView(groupView); } else if (bigGroupView instanceof GroupView2) { ((GroupView2) bigGroupView).getFrameLayout().addView(groupView); } } else { getFrameLayout().addView(groupView); } groupViewList.add(groupView); } } } }
PlanNode chooseDepWithoutCosting( PlanNode rootNode1, PlanNode rootNode2, AnalysisRecord analysisRecord) throws QueryMetadataException, TeiidComponentException { PlanNode sourceNode1 = FrameUtil.findJoinSourceNode(rootNode1); PlanNode sourceNode2 = null; if (rootNode2 != null) { sourceNode2 = FrameUtil.findJoinSourceNode(rootNode2); } if (sourceNode1.hasCollectionProperty(NodeConstants.Info.ACCESS_PATTERNS)) { if (sourceNode2 != null && sourceNode2.hasCollectionProperty(NodeConstants.Info.ACCESS_PATTERNS)) { // Return null - query planning should fail because both access nodes // have unsatisfied access patterns rootNode1 .getParent() .recordDebugAnnotation( "both children have unsatisfied access patterns", null, "Neither node can be made dependent", analysisRecord, null); //$NON-NLS-1$ //$NON-NLS-2$ return null; } rootNode1.recordDebugAnnotation( "unsatisfied access pattern detected", null, "marking as dependent side of join", analysisRecord, null); //$NON-NLS-1$ //$NON-NLS-2$ return rootNode1; } else if (sourceNode2 != null && sourceNode2.hasCollectionProperty(NodeConstants.Info.ACCESS_PATTERNS)) { // Access node 2 has unsatisfied access pattern, // so try to make node 2 dependent sourceNode2.recordDebugAnnotation( "unsatisfied access pattern detected", null, "marking as dependent side of join", analysisRecord, null); //$NON-NLS-1$ //$NON-NLS-2$ return rootNode2; } // Check for hints, which over-rule heuristics if (sourceNode1.hasProperty(NodeConstants.Info.MAKE_DEP)) { sourceNode1.recordDebugAnnotation( "MAKE_DEP hint detected", null, "marking as dependent side of join", analysisRecord, null); //$NON-NLS-1$ //$NON-NLS-2$ rootNode1.setProperty(Info.MAKE_DEP, sourceNode1.getProperty(Info.MAKE_DEP)); return rootNode1; } else if (sourceNode2 != null && sourceNode2.hasProperty(NodeConstants.Info.MAKE_DEP)) { sourceNode2.recordDebugAnnotation( "MAKE_DEP hint detected", null, "marking as dependent side of join", analysisRecord, null); //$NON-NLS-1$ //$NON-NLS-2$ rootNode2.setProperty(Info.MAKE_DEP, sourceNode2.getProperty(Info.MAKE_DEP)); return rootNode2; } else if (sourceNode1.hasBooleanProperty(NodeConstants.Info.MAKE_IND) && sourceNode2 != null) { sourceNode2.recordDebugAnnotation( "MAKE_IND hint detected", null, "marking as dependent side of join", analysisRecord, null); //$NON-NLS-1$ //$NON-NLS-2$ return rootNode2; } else if (sourceNode2 != null && sourceNode2.hasBooleanProperty(NodeConstants.Info.MAKE_IND)) { sourceNode1.recordDebugAnnotation( "MAKE_IND hint detected", null, "marking as dependent side of join", analysisRecord, null); //$NON-NLS-1$ //$NON-NLS-2$ return rootNode1; } return null; }