Java Code Examples for android.view.ViewGroup

The following are top voted examples for showing how to use android.view.ViewGroup. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to product more good examples.

Example 1
Project: dlna   File: PullToUpdataListView.java View source code 7 votes vote down vote up
private void measureView(View child) {
	ViewGroup.LayoutParams p = child.getLayoutParams();
	if (p == null) {
		p = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
	}
	int childWidthSpec = ViewGroup.getChildMeasureSpec(0, 0 + 0, p.width);
	int lpHeight = p.height;
	int childHeightSpec;
	if (lpHeight > 0) {
		childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight, MeasureSpec.EXACTLY);
	} else {
		childHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
	}
	child.measure(childWidthSpec, childHeightSpec);
}
 
Example 2
Project: Gui2Go   File: EditorActivity.java View source code 7 votes vote down vote up
private int FindAnchorID(String value, ViewGroup parent) {
    View anchor = null;
    // lets find the parent and anchor
    for (int i = 0; i < parent.getChildCount(); i++) {
        View v = parent.getChildAt(i);
        if (v.getTag().toString().equals(value)) {
            anchor = v;
        }
    }

    if (anchor != null) {
        return anchor.getId();
    } else {
        Toast.makeText(EditorActivity.this, "Error.", Toast.LENGTH_SHORT)
                        .show();
        return 0;
    }
}
 
Example 3
Project: Gui2Go   File: EditorActivity.java View source code 7 votes vote down vote up
public void DeleteWidget(View v) {
    if (mode != null) {
        mode.finish();
    }
    manager.removeNodeRecursively((long) v.getId());
    widgetIDs.remove((Integer) v.getId());
    widgetNames.remove(v.getTag());
    ViewGroup parent = (ViewGroup) v.getParent();
    parent.removeView(v);
    currentHighlightedID = 0; // clear selection
}
 
Example 4
Project: collect-mobile   File: CodeAttributeComponent.java View source code 7 votes vote down vote up
private void includeDescriptionsButton() {
    View inputView = toInputView();
    ViewGroup parent = (ViewGroup) inputView.getParent();
    if (parent == null)
        return;
    if (parent.findViewWithTag(DESCRIPTION_BUTTON_TAG) == null) {
        Button button = new Button(context);
        button.setTextAppearance(context, android.R.style.TextAppearance_Small);
        button.setTag(DESCRIPTION_BUTTON_TAG);
        button.setLayoutParams(new ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
        button.setText(context.getResources().getString(R.string.label_show_code_descriptions));
        button.setBackgroundDrawable(null);
        button.setPaintFlags(button.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                CodeListDescriptionDialogFragment.show(context.getSupportFragmentManager());
            }
        });
        int linkColor = new TextView(context).getLinkTextColors().getDefaultColor();
        button.setTextColor(linkColor);
        parent.addView(button);
    }
}
 
Example 5
Project: my-ministry-assistant   File: MainActivity.java View source code 6 votes vote down vote up
private void createNavDrawerItems() {
    mDrawerItemsListContainer = (ViewGroup) findViewById(R.id.navdrawer_items_list);
    if (mDrawerItemsListContainer == null) {
        return;
    }

    mNavDrawerItemViews = new View[mNavDrawerItems.size()];
    mDrawerItemsListContainer.removeAllViews();
    int i = 0;
    for (int itemId : mNavDrawerItems) {
        mNavDrawerItemViews[i] = makeNavDrawerItem(itemId, mDrawerItemsListContainer);
        mDrawerItemsListContainer.addView(mNavDrawerItemViews[i]);
        ++i;
    }
}
 
Example 6
Project: dlna   File: YouPlayerMoreDialog.java View source code 6 votes vote down vote up
public static PopupWindow show(final View view,int speed,final OnClickListener listener ){	
	final PopupWindow pw = new PopupWindow(view.getContext());
	BitmapDrawable drawable = (BitmapDrawable) view.getResources().getDrawable(R.drawable.youplayer_fullplayer_more_bg);	
	pw.setBackgroundDrawable(drawable);
	int width = 800;
	int height = 400;
       try {
           WindowManager wm = (WindowManager)view.getContext().getSystemService(Context.WINDOW_SERVICE);
           width = wm.getDefaultDisplay().getWidth();
           height = wm.getDefaultDisplay().getHeight();
       } catch (Exception e) {
           e.printStackTrace();
       }
	pw.setWidth(width*3/8);
	pw.setHeight(height*3/8);
	ViewGroup contentView = (ViewGroup) LayoutInflater.from(view.getContext()).inflate(R.layout.youplayer_fullplayer_more_view, null);
	OnClickListener clistener = new OnClickListener() {	
		@Override
		public void onClick(View v) {
			listener.onClick(v);	
			pw.dismiss();	
		}
	};
	
	int[] speeds = new int[]{
		R.drawable.youplayer_fullplayer_bottom_btn_speed08,
		R.drawable.youplayer_fullplayer_bottom_btn_speed10,
		R.drawable.youplayer_fullplayer_bottom_btn_speed15,
		R.drawable.youplayer_fullplayer_bottom_btn_speed20,
	} ;
	
	
	contentView.findViewById(R.id.fullplayer_imgb_download).setOnClickListener(clistener);
	contentView.findViewById(R.id.fullplayer_imgb_share).setOnClickListener(clistener);
	
	ImageButton img_speed = (ImageButton) contentView.findViewById(R.id.fullplayer_imgb_speed);
	img_speed.setOnClickListener(clistener);
	img_speed.setImageResource(speeds[speed]);
	
	contentView.findViewById(R.id.fullplayer_imgb_track).setOnClickListener(clistener);
	
	ImageButton img_3d = (ImageButton) contentView.findViewById(R.id.fullplayer_imgb_3d);
	img_3d.setOnClickListener(clistener);
	
	contentView.findViewById(R.id.fullplayer_btm_imgb_lock).setOnClickListener(clistener);
	
	
	pw.setContentView(contentView);

	pw.setOutsideTouchable(false);
	pw.setTouchable(true);
	pw.setFocusable(true);
	pw.showAsDropDown(view,30,0);
	
	return pw;	
}
 
Example 7
Project: BioWiki   File: ContextualUndoAdapter.java View source code 6 votes vote down vote up
@Override
public final View getView(final int position, final View convertView, final ViewGroup parent) {
    final ViewHolder vh;
    ContextualUndoView contextualUndoView = (ContextualUndoView) convertView;
    if (contextualUndoView == null) {
        contextualUndoView = new ContextualUndoView(parent.getContext(), mUndoLayoutId, mCountDownTextViewResId);
        contextualUndoView.findViewById(mUndoActionId).setOnClickListener(new UndoListener(contextualUndoView));
        vh = new ViewHolder(contextualUndoView);
    } else {
        vh = ViewHolder.getViewHolder(contextualUndoView);
    }

    View contentView = super.getView(position, contextualUndoView.getContentView(), contextualUndoView);
    contextualUndoView.updateContentView(contentView);

    long itemId = getItemId(position);
    vh.mItemId = itemId;

    if (itemId == mCurrentRemovedId) {
        contextualUndoView.displayUndo();
        long millisLeft = mAutoDeleteDelayMillis - (System.currentTimeMillis() - mDismissStartMillis);
        if (mCountDownFormatter != null) {
            contextualUndoView.updateCountDownTimer(mCountDownFormatter.getCountDownString(millisLeft));
        }
    } else {
        contextualUndoView.displayContentView();
    }

    contextualUndoView.setItemId(itemId);
    return contextualUndoView;
}
 
Example 8
Project: phonegap-geolocation   File: CordovaWebView.java View source code 6 votes vote down vote up
public void showCustomView(View view, WebChromeClient.CustomViewCallback callback) {
    // This code is adapted from the original Android Browser code, licensed under the Apache License, Version 2.0
    Log.d(TAG, "showing Custom View");
    // if a view already exists then immediately terminate the new one
    if (mCustomView != null) {
        callback.onCustomViewHidden();
        return;
    }
    
    // Store the view and its callback for later (to kill it properly)
    mCustomView = view;
    mCustomViewCallback = callback;
    
    // Add the custom view to its container.
    ViewGroup parent = (ViewGroup) this.getParent();
    parent.addView(view, COVER_SCREEN_GRAVITY_CENTER);
    
    // Hide the content view.
    this.setVisibility(View.GONE);
    
    // Finally show the custom view container.
    parent.setVisibility(View.VISIBLE);
    parent.bringToFront();
}
 
Example 9
Project: Todayinformation   File: ResideMenu.java View source code 6 votes vote down vote up
private void initValue(Activity activity){
    this.activity   = activity;
    leftMenuItems   = new ArrayList<ResideMenuItem>();
    rightMenuItems  = new ArrayList<ResideMenuItem>();
    ignoredViews    = new ArrayList<View>();
    viewDecor = (ViewGroup) activity.getWindow().getDecorView();
    viewActivity = new TouchDisableView(this.activity);

    View mContent   = viewDecor.getChildAt(0);
    viewDecor.removeViewAt(0);
    viewActivity.setContent(mContent);
    addView(viewActivity);

    ViewGroup parent = (ViewGroup) scrollViewLeftMenu.getParent();
    parent.removeView(scrollViewLeftMenu);
    parent.removeView(scrollViewRightMenu);
}
 
Example 10
Project: Gui2Go   File: LayoutXMLCreator.java View source code 6 votes vote down vote up
public void StartLayoutNode(ViewGroup vg, boolean isRoot)
	{
		String widgetID = vg.getTag().toString();
		String widgetType = vg.getClass().getSimpleName();
		

		LayoutParams params = vg.getLayoutParams();
		try {
			serializer.startTag(null, widgetType);

			if (isRoot) {
				serializer.attribute(null, "xmlns:android",
						"http://schemas.android.com/apk/res/android");
			}

			serializer.attribute(null, "android:id", "@+id/" + widgetID);
			AddLayoutParams(params, isRoot);

			if (vg.getParent() != null && vg.getParent().getClass() == RelativeLayout.class)
			// handle relative layout as parent
			{
				int[] rules = ((android.widget.RelativeLayout.LayoutParams) params)
						.getRules();
				AddRelativeLayoutTags(rules, vg);
			}

			// /////////////HANDLE DIFFERENT LAYOUT TYPES HERE
			if (vg.getClass() == LinearLayout.class) {
				int orientation = ((LinearLayout) vg).getOrientation();

				if (orientation == LinearLayout.VERTICAL) {
					serializer.attribute(null, "android:orientation",
							"vertical");
				} else if (orientation == LinearLayout.HORIZONTAL) {
					serializer.attribute(null, "android:orientation",
							"horizontal");
				}
			}

		} catch (Exception e) {
//			Log.e("Exception", "error occurred while creating xml file");
		}
	}
 
Example 11
Project: PhotoPhase   File: ViewPager.java View source code 6 votes vote down vote up
private Rect getChildRectInPagerCoordinates(Rect outRect, View child) {
    Rect outRectEx = outRect;
    if (outRectEx == null) {
        outRectEx = new Rect();
    }
    if (child == null) {
        outRectEx.set(0, 0, 0, 0);
        return outRectEx;
    }
    outRectEx.left = child.getLeft();
    outRectEx.right = child.getRight();
    outRectEx.top = child.getTop();
    outRectEx.bottom = child.getBottom();

    ViewParent parent = child.getParent();
    while (parent instanceof ViewGroup && parent != this) {
        final ViewGroup group = (ViewGroup) parent;
        outRectEx.left += group.getLeft();
        outRectEx.right += group.getRight();
        outRectEx.top += group.getTop();
        outRectEx.bottom += group.getBottom();

        parent = group.getParent();
    }
    return outRectEx;
}
 
Example 12
Project: TasksProject   File: SlidingMenu.java View source code 6 votes vote down vote up
public void attachToActivity(Activity activity, int slideStyle) {
	if (slideStyle != SLIDING_WINDOW && slideStyle != SLIDING_CONTENT)
		throw new IllegalArgumentException("slideStyle must be either SLIDING_WINDOW or SLIDING_CONTENT");

	if (getParent() != null)
		throw new IllegalStateException("This SlidingMenu appears to already be attached");
	
	// get the window background
	TypedArray a = activity.getTheme().obtainStyledAttributes(new int[] {android.R.attr.windowBackground});
	int background = a.getResourceId(0, 0);
	a.recycle();

	switch (slideStyle) {
	case SLIDING_WINDOW:
		ViewGroup decor = (ViewGroup) activity.getWindow().getDecorView();
		ViewGroup decorChild = (ViewGroup) decor.getChildAt(0);
		// save ActionBar themes that have transparent assets
		decorChild.setBackgroundResource(background);
		decor.removeView(decorChild);
		setContent(decorChild);
		decor.addView(this);
		break;
	case SLIDING_CONTENT:
		// take the above view out of
		View content = activity.findViewById(android.R.id.content);
		ViewGroup contentParent = (ViewGroup) content.getParent();
		contentParent.removeView(content);
		contentParent.addView(this, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
		setContent(content);
		// save people from having transparent backgrounds
		if (content.getBackground() == null)
			content.setBackgroundResource(background);
		break;
	}
}
 
Example 13
Project: BioWiki   File: ExpandableListItemAdapter.java View source code 6 votes vote down vote up
@Override
public View getView(final int position, final View convertView, final ViewGroup parent) {
    ViewGroup view = (ViewGroup) convertView;
    ViewHolder viewHolder;

    if (view == null) {
        view = createView(parent);

        viewHolder = new ViewHolder();
        viewHolder.titleParent = (ViewGroup) view.findViewById(mTitleParentResId);
        viewHolder.contentParent = (ViewGroup) view.findViewById(mContentParentResId);

        view.setTag(viewHolder);
    } else {
        viewHolder = (ViewHolder) view.getTag();
    }

    View titleView = getTitleView(position, viewHolder.titleView, viewHolder.titleParent);
    if (titleView != viewHolder.titleView) {
        viewHolder.titleParent.removeAllViews();
        viewHolder.titleParent.addView(titleView);

        if (mActionViewResId == 0) {
            view.setOnClickListener(new TitleViewOnClickListener(viewHolder.contentParent));
        } else {
            view.findViewById(mActionViewResId).setOnClickListener(new TitleViewOnClickListener(viewHolder.contentParent));
        }
    }
    viewHolder.titleView = titleView;

    View contentView = getContentView(position, viewHolder.contentView, viewHolder.contentParent);
    if (contentView != viewHolder.contentView) {
        viewHolder.contentParent.removeAllViews();
        viewHolder.contentParent.addView(contentView);
    }
    viewHolder.contentView = contentView;

    viewHolder.contentParent.setVisibility(mExpandedIds.contains(getItemId(position)) ? View.VISIBLE : View.GONE);
    viewHolder.contentParent.setTag(getItemId(position));

    ViewGroup.LayoutParams layoutParams = viewHolder.contentParent.getLayoutParams();
    layoutParams.height = LayoutParams.WRAP_CONTENT;
    viewHolder.contentParent.setLayoutParams(layoutParams);

    return view;
}
 
Example 14
Project: Gui2Go   File: ActivityManager.java View source code 6 votes vote down vote up
private ViewGroup createTempWidget(String viewType)
{
	ViewGroup newWidget = null;

	if (viewType.equals(WidgetTypes.LINEAR_TAG)) {
		newWidget = new LinearLayout(this);
	} else if (viewType.equals(WidgetTypes.RELATIVE_TAG)) {
		newWidget = new RelativeLayout(this);
	} else if (viewType.equals(WidgetTypes.FRAME_TAG)) {
		newWidget = new FrameLayout(this);
	} else if (viewType.equals(WidgetTypes.TABLE_TAG)) {
		newWidget = new TableLayout(this);
	}
	newWidget.setTag("LayoutRoot");
	LayoutParams params = new LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	newWidget.setLayoutParams(params);
	
	return newWidget;
}
 
Example 15
Project: my-ministry-assistant   File: SlideInUpAnimator.java View source code 6 votes vote down vote up
@Override
public void prepare(View target) {
    ViewGroup parent = (ViewGroup)target.getParent();
    int distance = parent.getHeight() - target.getTop();
    getAnimatorAgent().playTogether(
            ObjectAnimator.ofFloat(target, "alpha", 0, 1),
            ObjectAnimator.ofFloat(target,"translationY",distance,0)
    );
}
 
Example 16
Project: my-ministry-assistant   File: SlideOutRightAnimator.java View source code 6 votes vote down vote up
@Override
public void prepare(View target) {
    ViewGroup parent = (ViewGroup)target.getParent();
    int distance = parent.getWidth() - target.getLeft();
    getAnimatorAgent().playTogether(
            ObjectAnimator.ofFloat(target, "alpha", 1, 0),
            ObjectAnimator.ofFloat(target,"translationX",0,distance)
    );
}
 
Example 17
Project: wally   File: ImageDetailsActivity.java View source code 6 votes vote down vote up
private void setupViews() {
    scrollView = (ObservableScrollView) findViewById(R.id.image_details_scrollview);
    imageHolder = (ViewGroup) findViewById(R.id.image_details_imageview_holder);
    photoView = (ImageView) findViewById(R.id.image_details_imageview);
    buttonFullscreen = (ImageButton) findViewById(R.id.image_details_button_fullscreen);
    loader = (ProgressBar) findViewById(R.id.image_details_loader);
    textViewUploader = (TextView) findViewById(R.id.image_details_uploader);
    textViewUploadDate = (TextView) findViewById(R.id.image_details_upload_date);
    textViewSource = (TextView) findViewById(R.id.image_details_source);
    textViewResolution = (TextView) findViewById(R.id.image_details_resolution);
    textViewCategory = (TextView) findViewById(R.id.image_details_category);
    textViewRating = (TextView) findViewById(R.id.image_details_rating);
    flowLayoutTags = (FlowLayout) findViewById(R.id.image_details_tags_layout);
    buttonSetAs = (Button) findViewById(R.id.toolbar_set_as);
    buttonSave = (Button) findViewById(R.id.toolbar_save);
    toolbar = (ViewGroup) findViewById(R.id.image_details_toolbar);
    photoLayoutHolder = (ViewGroup) findViewById(R.id.image_details_photo_layout_holder);
    specsLayout = (ViewGroup) findViewById(R.id.image_details_specs);
    detailsViewGroup = findViewById(R.id.image_details_layout);

    specsLayout.setAlpha(0.0f);

    int sidePadding = getResources().getDimensionPixelSize(R.dimen.activity_details_scrollview_side_padding);
    int fabPadding = getResources().getDimensionPixelSize(R.dimen.fab_padding_positive);
    scrollView.setPadding(0, 0, 0, -fabPadding);
    specsLayout.setPadding(0, 0, 0, fabPadding);
    photoLayoutHolder.setPadding(0, 0, 0, 0);
    detailsViewGroup.setPadding(
            sidePadding,
            detailsViewGroup.getPaddingTop(),
            sidePadding,
            detailsViewGroup.getPaddingBottom()
    );
}
 
Example 18
Project: FORMWatchFace   File: CompanionWatchFaceConfigActivity.java View source code 6 votes vote down vote up
private void updatePreviewView(Theme theme, ViewGroup clockContainerView, FormClockView clockView) {
    if (theme == Themes.MUZEI_THEME) {
        if (mMuzeiLoadedArtwork != null) {
            ((ImageView) clockContainerView.findViewById(R.id.background_image))
                    .setImageBitmap(mMuzeiLoadedArtwork.bitmap);
            clockView.setColors(
                    mMuzeiLoadedArtwork.color1,
                    mMuzeiLoadedArtwork.color2,
                    Color.WHITE);
        }
        clockContainerView.setBackgroundColor(Color.BLACK);
    } else {
        ((ImageView) clockContainerView.findViewById(R.id.background_image))
                .setImageDrawable(null);
        final Resources res = getResources();
        clockView.setColors(
                res.getColor(theme.lightRes),
                res.getColor(theme.midRes),
                Color.WHITE);
        clockContainerView.setBackgroundColor(
                res.getColor(theme.darkRes));
    }
}
 
Example 19
Project: nptornews   File: NewsTopicActivity.java View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  ViewGroup container = (ViewGroup) findViewById(R.id.Content);
  ViewGroup.inflate(this, R.layout.news_topics, container);
  listView = (ListView) findViewById(R.id.topic_list);
  listView.setOnItemClickListener(this);

  initializeList();
}
 
Example 20
Project: ABPlayer   File: PLA_ListView.java View source code 6 votes vote down vote up
/**
 * Indicates that the views created by the ListAdapter can contain focusable
 * items.
 *
 * @param itemsCanFocus true if items can get focus, false otherwise
 */
public void setItemsCanFocus(boolean itemsCanFocus) {
	mItemsCanFocus = itemsCanFocus;
	if (!itemsCanFocus) {
		setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
	}
}
 
Example 21
Project: Fairphone   File: HideFromAccessibilityHelper.java View source code 6 votes vote down vote up
private void setImportantForAccessibilityToNoHelper(View v) {
    mPreviousValues.put(v, v.getImportantForAccessibility());
    v.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);

    // Call method on children recursively
    if (v instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) v;
        vg.setOnHierarchyChangeListener(this);
        for (int i = 0; i < vg.getChildCount(); i++) {
            View child = vg.getChildAt(i);

            if (includeView(child)) {
                setImportantForAccessibilityToNoHelper(child);
            }
        }
    }
}
 
Example 22
Project: Musubi-Android   File: FragmentActivity.java View source code 6 votes vote down vote up
private void installDecor() {
    if (DEBUG) Log.d(TAG, "[installDecor]");

    if (mDecor == null) {
        if (IS_HONEYCOMB) {
            mDecor = (ViewGroup)getWindow().getDecorView();
        } else {
            mDecor = (ViewGroup)getWindow().getDecorView().findViewById(android.R.id.content);
        }
    }
    if (mContentParent == null) {
        if (IS_HONEYCOMB) {
            mContentParent = (ViewGroup)mDecor.findViewById(android.R.id.content);
        } else {
            mContentParent = generateLayout();
            mActionBarView = (ActionBarView)mDecor.findViewById(R.id.abs__action_bar);
            if (mActionBarView != null) {
                if (mActionBarView.getTitle() == null) {
                    mActionBarView.setTitle(getTitle());
                }
                if (hasFeature(Window.FEATURE_INDETERMINATE_PROGRESS)) {
                    mActionBarView.initIndeterminateProgress();
                }
            }

            // Post the panel invalidate for later; avoid application onCreateOptionsMenu
            // being called in the middle of onCreate or similar.
            mDecor.post(new Runnable() {
                @Override
                public void run() {
                    //Invalidate if the panel menu hasn't been created before this.
                    if (mSupportMenu == null) {
                        invalidateOptionsMenu();
                    }
                }
            });
        }
    }
}
 
Example 23
Project: DemoProject   File: Focus2AndroidTest.java View source code 6 votes vote down vote up
@Override
protected void setUp() throws Exception {
    super.setUp();

    mFocusFinder = FocusFinder.getInstance();

    // inflate the layout
    final Context context = getContext();
    final LayoutInflater inflater = LayoutInflater.from(context);
    mRoot = (ViewGroup) inflater.inflate(R.layout.focus_2, null);

    // manually measure it, and lay it out
    mRoot.measure(500, 500);
    mRoot.layout(0, 0, 500, 500);

    mLeftButton = (Button) mRoot.findViewById(R.id.leftButton);
    mCenterButton = (Button) mRoot.findViewById(R.id.centerButton);
    mRightButton = (Button) mRoot.findViewById(R.id.rightButton);
}
 
Example 24
Project: Yhb-2.0   File: PuffOutAnimation.java View source code 6 votes vote down vote up
@Override
public void animate() {
	ViewGroup parentView = (ViewGroup) view.getParent(), rootView = (ViewGroup) view
			.getRootView();
	while (parentView != rootView) {
		parentView.setClipChildren(false);
		parentView = (ViewGroup) parentView.getParent();
	}
	rootView.setClipChildren(false);

	final float originalScaleX = view.getScaleX(), originalScaleY = view
			.getScaleY(), originalAlpha = view.getAlpha();
	view.animate().scaleX(4f).scaleY(4f).alpha(0f)
			.setInterpolator(interpolator).setDuration(duration)
			.setListener(new AnimatorListenerAdapter() {

				@Override
				public void onAnimationEnd(Animator animation) {
					view.setVisibility(View.INVISIBLE);
					view.setScaleX(originalScaleX);
					view.setScaleY(originalScaleY);
					view.setAlpha(originalAlpha);
					if (getListener() != null) {
						getListener().onAnimationEnd(PuffOutAnimation.this);
					}
				}
			});
}
 
Example 25
Project: HoverAniamtion   File: SwipeLayout.java View source code 6 votes vote down vote up
/**
 * prevent bottom view get any touch event. Especially in LayDown mode.
 */
private void safeBottomView(){
    Status status = getOpenStatus();
    ViewGroup bottom = getBottomView();

    if(status == Status.Close){
        if(bottom.getVisibility() != INVISIBLE)
            bottom.setVisibility(INVISIBLE);
    }else {
        if(bottom.getVisibility() != VISIBLE)
            bottom.setVisibility(VISIBLE);
    }
}
 
Example 26
Project: quick-settings   File: SortableSettingsListView.java View source code 6 votes vote down vote up
public Dragger(Context context, Setting setting, ViewGroup item, MotionEvent ev) {
	
	mSetting = setting;
          int y = (int) ev.getY();
	
          mDragPointOffset = y - item.getTop();
          mCoordOffset = ((int)ev.getRawY()) - y;
          mRowHeight = item.getHeight();
	
          // enable cache
          // clear cache, otherwise we are going to have problems in donut ;)
          item.setDrawingCacheEnabled(false);
	item.setDrawingCacheEnabled(true);
	// create bitmap
	Bitmap bitmap = Bitmap.createBitmap(item.getDrawingCache());
	mBitmap = bitmap;

	// create window
          mWindowParams = new WindowManager.LayoutParams();
          
          WindowManager.LayoutParams params = mWindowParams;
          params.gravity = Gravity.TOP;
          params.alpha = 0.65f;
          params.x = 0;
          params.y = y - mDragPointOffset + mCoordOffset;

          params.height = WindowManager.LayoutParams.WRAP_CONTENT;
          params.width = WindowManager.LayoutParams.WRAP_CONTENT;
          params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                  | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
                  | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
                  | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
          params.format = PixelFormat.TRANSLUCENT;
          params.windowAnimations = 0;
          
          ImageView imageView = new ImageView(context);
          int backGroundColor = context.getResources().getColor(android.R.color.black);
          imageView.setBackgroundColor(backGroundColor);
          imageView.setImageBitmap(bitmap);

          // add view
          mWindowManager = (WindowManager) context.getSystemService("window");
          mWindowManager.addView(imageView, params);
          mImageView = imageView;
          
}
 
Example 27
Project: android-maps-utils-amap   File: IconGenerator.java View source code 6 votes vote down vote up
/**
 * Creates an icon with the current content and style.
 * <p/>
 * This method is useful if a custom view has previously been set, or if text content is not
 * applicable.
 */
public Bitmap makeIcon() {
    ViewGroup container = getContainer();

    int measureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    container.measure(measureSpec, measureSpec);

    int measuredWidth = container.getMeasuredWidth();
    int measuredHeight = container.getMeasuredHeight();

    container.layout(0, 0, measuredWidth, measuredHeight);

    if (mRotation == 1 || mRotation == 3) {
        measuredHeight = container.getMeasuredWidth();
        measuredWidth = container.getMeasuredHeight();
    }

    Bitmap r = Bitmap.createBitmap(measuredWidth, measuredHeight, Bitmap.Config.ARGB_8888);
    r.eraseColor(Color.TRANSPARENT);

    Canvas canvas = new Canvas(r);

    if (mRotation == 0) {
        // do nothing
    } else if (mRotation == 1) {
        canvas.translate(measuredWidth, 0);
        canvas.rotate(90);
    } else if (mRotation == 2) {
        canvas.rotate(180, measuredWidth / 2, measuredHeight / 2);
    } else {
        canvas.translate(0, measuredHeight);
        canvas.rotate(270);
    }
    container.draw(canvas);
    return r;
}
 
Example 28
Project: hashtag-view   File: HashtagView.java View source code 6 votes vote down vote up
private void draw() {
    if (viewMap == null || viewMap.isEmpty()) return;
    removeAllViews();

    for (Integer key : viewMap.keySet()) {
        ViewGroup rowLayout = getRowLayout(viewMap.get(key).size());
        addView(rowLayout);
        applyDistribution(viewMap.get(key));
        rowLayout.setLayoutTransition(layoutTransition);

        for (ItemData item : viewMap.get(key)) {
            rowLayout.addView(item.view, itemLayoutParams);
        }
    }
}
 
Example 29
Project: DemoProject   File: Transition3d.java View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.animations_main_screen);

    mPhotosList = (ListView) findViewById(android.R.id.list);
    mImageView = (ImageView) findViewById(R.id.picture);
    mContainer = (ViewGroup) findViewById(R.id.container);

    // Prepare the ListView
    final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
            android.R.layout.simple_list_item_1, PHOTOS_NAMES);

    mPhotosList.setAdapter(adapter);
    mPhotosList.setOnItemClickListener(this);

    // Prepare the ImageView
    mImageView.setClickable(true);
    mImageView.setFocusable(true);
    mImageView.setOnClickListener(this);

    // Since we are caching large views, we want to keep their cache
    // between each animation
    mContainer.setPersistentDrawingCache(ViewGroup.PERSISTENT_ANIMATION_CACHE);
}
 
Example 30
Project: ExcusePro   File: DefaultHeaderTransformer.java View source code 6 votes vote down vote up
@Override
public void onViewCreated(Activity activity, View headerView) {
    // Get ProgressBar and TextView. Also set initial text on TextView
    mHeaderProgressBar = (ProgressBar) headerView.findViewById(R.id.ptr_progress);
    mHeaderTextView = (TextView) headerView.findViewById(R.id.ptr_text);

    // Apply any custom ProgressBar colors
    applyProgressBarColor();

    // Labels to display
    mPullRefreshLabel = activity.getString(R.string.pull_to_refresh_pull_label);
    mRefreshingLabel = activity.getString(R.string.pull_to_refresh_refreshing_label);
    mReleaseLabel = activity.getString(R.string.pull_to_refresh_release_label);

    // Retrieve the Action Bar size from the Activity's theme
    mContentLayout = (ViewGroup) headerView.findViewById(R.id.ptr_content);
    if (mContentLayout != null) {
        mContentLayout.getLayoutParams().height = getActionBarSize(activity);
        mContentLayout.requestLayout();
    }

    // Retrieve the Action Bar background from the Activity's theme (see #93).
    Drawable abBg = getActionBarBackground(activity);
    if (abBg != null) {
        // If we do not have a opaque background we just display a solid solid behind it
        if (abBg.getOpacity() != PixelFormat.OPAQUE) {
            View view = headerView.findViewById(R.id.ptr_text_opaque_bg);
            if (view != null) {
                view.setVisibility(View.VISIBLE);
            }
        }

        mHeaderTextView.setBackgroundDrawable(abBg);
    }

    // Retrieve the Action Bar Title Style from the Action Bar's theme
    Context abContext = headerView.getContext();
    final int titleTextStyle = getActionBarTitleStyle(abContext);
    if (titleTextStyle != 0) {
        mHeaderTextView.setTextAppearance(abContext, titleTextStyle);
    }

    // Call onReset to make sure that the View is consistent
    onReset();
}
 
Example 31
Project: jdroid   File: AnimationUtils.java View source code 6 votes vote down vote up
public static void makeViewGroupAnimation(ViewGroup viewGroup) {
	AnimationSet set = new AnimationSet(true);
	
	Animation animation = new AlphaAnimation(0.0f, 1.0f);
	animation.setDuration(50);
	set.addAnimation(animation);
	
	animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
			Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
	animation.setDuration(150);
	set.addAnimation(animation);
	
	LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f);
	viewGroup.setLayoutAnimation(controller);
}
 
Example 32
Project: WS171-frameworks-base   File: StatusBarService.java View source code 6 votes vote down vote up
View makeNotificationView(StatusBarNotification notification, ViewGroup parent) {
    NotificationData n = notification.data;
    RemoteViews remoteViews = n.contentView;
    if (remoteViews == null) {
        return null;
    }

    // create the row view
    LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(
            Context.LAYOUT_INFLATER_SERVICE);
    View row = inflater.inflate(com.android.internal.R.layout.status_bar_latest_event, parent, false);

    // bind the click event to the content area
    ViewGroup content = (ViewGroup)row.findViewById(com.android.internal.R.id.content);
    content.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
    content.setOnFocusChangeListener(mFocusChangeListener);
    PendingIntent contentIntent = n.contentIntent;
    if (contentIntent != null) {
        content.setOnClickListener(new Launcher(contentIntent, n.pkg, n.id));
    }

    View child = null;
    Exception exception = null;
    try {
        child = remoteViews.apply(mContext, content);
    }
    catch (RuntimeException e) {
        exception = e;
    }
    if (child == null) {
        Log.e(TAG, "couldn't inflate view for package " + n.pkg, exception);
        return null;
    }
    content.addView(child);

    row.setDrawingCacheEnabled(true);

    notification.view = row;
    notification.contentView = child;

    return row;
}
 
Example 33
Project: android-15   File: NavigationBarView.java View source code 6 votes vote down vote up
public void onFinishInflate() {
    mRotatedViews[Surface.ROTATION_0] = 
    mRotatedViews[Surface.ROTATION_180] = findViewById(R.id.rot0);

    mRotatedViews[Surface.ROTATION_90] = findViewById(R.id.rot90);
    
    mRotatedViews[Surface.ROTATION_270] = NAVBAR_ALWAYS_AT_RIGHT
                                            ? findViewById(R.id.rot90)
                                            : findViewById(R.id.rot270);

    for (View v : mRotatedViews) {
        // this helps avoid drawing artifacts with glowing navigation keys 
        ViewGroup group = (ViewGroup) v.findViewById(R.id.nav_buttons);
        group.setMotionEventSplittingEnabled(false);
    }
    mCurrentView = mRotatedViews[Surface.ROTATION_0];
}
 
Example 34
Project: cardslib   File: GplayCard.java View source code 6 votes vote down vote up
@Override
public void setupInnerViewElements(ViewGroup parent, View viewImage) {


    //viewImage.getLayoutParams().width = 196;
    //viewImage.getLayoutParams().height = 196;
    if (viewImage != null) {
        if (parent!=null && parent.getResources()!=null){
            DisplayMetrics metrics=parent.getResources().getDisplayMetrics();

            int base = 98;

            if (metrics!=null){
                viewImage.getLayoutParams().width = (int)(base*metrics.density);
                viewImage.getLayoutParams().height = (int)(base*metrics.density);
            }else{
                viewImage.getLayoutParams().width = 196;
                viewImage.getLayoutParams().height = 196;
            }
        }
    }

}
 
Example 35
Project: android-sdk-sources-for-api-level-23   File: ShadowHelperJbmr2.java View source code 6 votes vote down vote up
public static Object addShadow(ViewGroup shadowContainer) {
    shadowContainer.setLayoutMode(ViewGroup.LAYOUT_MODE_OPTICAL_BOUNDS);
    LayoutInflater inflater = LayoutInflater.from(shadowContainer.getContext());
    inflater.inflate(R.layout.lb_shadow, shadowContainer, true);
    ShadowImpl impl = new ShadowImpl();
    impl.mNormalShadow = shadowContainer.findViewById(R.id.lb_shadow_normal);
    impl.mFocusShadow = shadowContainer.findViewById(R.id.lb_shadow_focused);
    return impl;
}
 
Example 36
Project: sdk-support   File: FragmentTransitionCompat21.java View source code 6 votes vote down vote up
private static void captureTransitioningViews(ArrayList<View> transitioningViews, View view) {
    if (view.getVisibility() == View.VISIBLE) {
        if (view instanceof ViewGroup) {
            ViewGroup viewGroup = (ViewGroup) view;
            if (viewGroup.isTransitionGroup()) {
                transitioningViews.add(viewGroup);
            } else {
                int count = viewGroup.getChildCount();
                for (int i = 0; i < count; i++) {
                    View child = viewGroup.getChildAt(i);
                    captureTransitioningViews(transitioningViews, child);
                }
            }
        } else {
            transitioningViews.add(view);
        }
    }
}
 
Example 37
Project: Android-Scene-Transition   File: TransitionManager.java View source code 6 votes vote down vote up
/**
 * Convenience method to animate to a new scene defined by all changes within
 * the given scene root between calling this method and the next rendering frame.
 * Calling this method causes TransitionManager to capture current values in the
 * scene root and then post a request to run a transition on the next frame.
 * At that time, the new values in the scene root will be captured and changes
 * will be animated. There is no need to create a Scene; it is implied by
 * changes which take place between calling this method and the next frame when
 * the transition begins.
 *
 * <p>Calling this method several times before the next frame (for example, if
 * unrelated code also wants to make dynamic changes and run a transition on
 * the same scene root), only the first call will trigger capturing values
 * and exiting the current scene. Subsequent calls to the method with the
 * same scene root during the same frame will be ignored.</p>
 *
 * <p>Passing in <code>null</code> for the transition parameter will
 * cause the TransitionManager to use its default transition.</p>
 *
 * @param sceneRoot The root of the View hierarchy to run the transition on.
 * @param transition The transition to use for this change. A
 * value of null causes the TransitionManager to use the default transition.
 */
public static void beginDelayedTransition(final ViewGroup sceneRoot, Transition transition) {
    if (!sPendingTransitions.contains(sceneRoot) && sceneRoot.isLaidOut()) {
        if (Transition.DBG) {
            Log.d(LOG_TAG, "beginDelayedTransition: root, transition = " +
                    sceneRoot + ", " + transition);
        }
        sPendingTransitions.add(sceneRoot);
        if (transition == null) {
            transition = sDefaultTransition;
        }
        final Transition transitionClone = transition.clone();
        sceneChangeSetup(sceneRoot, transitionClone);
        Scene.setCurrentScene(sceneRoot, null);
        sceneChangeRunTransition(sceneRoot, transitionClone);
    }
}
 
Example 38
Project: MUtils   File: AppUtil.java View source code 6 votes vote down vote up
public static ViewGroup getParent(View v, int parentId) {
	ViewGroup p = (ViewGroup) v.getParent();
	while (true) {
		if (p == null) {
			return null;
		}
		if (p.getId() == parentId) {
			return p;
		}
		p = (ViewGroup) p.getParent();
	}
}
 
Example 39
Project: property-db   File: LayoutTransition.java View source code 6 votes vote down vote up
/**
 * This method is called by ViewGroup when a child view is about to be added to the
 * container. This callback starts the process of a transition; we grab the starting
 * values, listen for changes to all of the children of the container, and start appropriate
 * animations.
 *
 * @param parent The ViewGroup to which the View is being added.
 * @param child The View being added to the ViewGroup.
 * @param changesLayout Whether the removal will cause changes in the layout of other views
 * in the container. INVISIBLE views becoming VISIBLE will not cause changes and thus will not
 * affect CHANGE_APPEARING or CHANGE_DISAPPEARING animations.
 */
private void addChild(ViewGroup parent, View child, boolean changesLayout) {
    if (parent.getWindowVisibility() != View.VISIBLE) {
        return;
    }
    if ((mTransitionTypes & FLAG_APPEARING) == FLAG_APPEARING) {
        // Want disappearing animations to finish up before proceeding
        cancel(DISAPPEARING);
    }
    if (changesLayout && (mTransitionTypes & FLAG_CHANGE_APPEARING) == FLAG_CHANGE_APPEARING) {
        // Also, cancel changing animations so that we start fresh ones from current locations
        cancel(CHANGE_APPEARING);
        cancel(CHANGING);
    }
    if (hasListeners() && (mTransitionTypes & FLAG_APPEARING) == FLAG_APPEARING) {
        ArrayList<TransitionListener> listeners =
                (ArrayList<TransitionListener>) mListeners.clone();
        for (TransitionListener listener : listeners) {
            listener.startTransition(this, parent, child, APPEARING);
        }
    }
    if (changesLayout && (mTransitionTypes & FLAG_CHANGE_APPEARING) == FLAG_CHANGE_APPEARING) {
        runChangeTransition(parent, child, APPEARING);
    }
    if ((mTransitionTypes & FLAG_APPEARING) == FLAG_APPEARING) {
        runAppearingTransition(parent, child);
    }
}
 
Example 40
Project: googleio   File: SessionDetailFragment.java View source code 6 votes vote down vote up
private void updateLinksTab(Cursor cursor) {
    ViewGroup container = (ViewGroup) mRootView.findViewById(R.id.links_container);

    // Remove all views but the 'empty' view
    int childCount = container.getChildCount();
    if (childCount > 1) {
        container.removeViews(1, childCount - 1);
    }

    LayoutInflater inflater = getLayoutInflater(null);

    boolean hasLinks = false;
    for (int i = 0; i < SessionsQuery.LINKS_INDICES.length; i++) {
        final String url = cursor.getString(SessionsQuery.LINKS_INDICES[i]);
        if (!TextUtils.isEmpty(url)) {
            hasLinks = true;
            ViewGroup linkContainer = (ViewGroup)
                    inflater.inflate(R.layout.list_item_session_link, container, false);
            ((TextView) linkContainer.findViewById(R.id.link_text)).setText(
                    SessionsQuery.LINKS_TITLES[i]);
            final int linkTitleIndex = i;
            linkContainer.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    fireLinkEvent(SessionsQuery.LINKS_TITLES[linkTitleIndex]);
                	Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
                    startActivity(intent);
                    
                }
            });

            container.addView(linkContainer);

            // Create separator
            View separatorView = new ImageView(getActivity());
            separatorView.setLayoutParams(
                    new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                            ViewGroup.LayoutParams.WRAP_CONTENT));
            separatorView.setBackgroundResource(android.R.drawable.divider_horizontal_bright);
            container.addView(separatorView);
        }
    }

    container.findViewById(R.id.empty_links).setVisibility(hasLinks ? View.GONE : View.VISIBLE);
}
 
Example 41
Project: AndroidPlugin   File: ViewStub.java View source code 6 votes vote down vote up
/**
 * Inflates the layout resource identified by [email protected] #getLayoutResource()}
 * and replaces this StubbedView in its parent by the inflated layout
 * resource.
 * 
 * @return The inflated layout resource.
 * 
 */
public View inflate() {
    final ViewParent viewParent = getParent();

    if (viewParent != null && viewParent instanceof ViewGroup) {
        if (mLayoutResource != 0) {
            final ViewGroup parent = (ViewGroup) viewParent;
            final LayoutInflater factory;
            if (mInflater != null) {
                factory = mInflater;
            } else {
                factory = LayoutInflater.from(getContext());
            }
            final View view = factory.inflate(mLayoutResource, parent,
                    false);

            if (mInflatedId != NO_ID) {
                view.setId(mInflatedId);
            }

            final int index = parent.indexOfChild(this);
            parent.removeViewInLayout(this);

            final ViewGroup.LayoutParams layoutParams = getLayoutParams();
            if (layoutParams != null) {
                parent.addView(view, index, layoutParams);
            } else {
                parent.addView(view, index);
            }

            mInflatedViewRef = new WeakReference<View>(view);

            if (mInflateListener != null) {
                mInflateListener.onInflate(this, view);
            }

            return view;
        } else {
            throw new IllegalArgumentException(
                    "ViewStub must have a valid layoutResource");
        }
    } else {
        throw new IllegalStateException(
                "ViewStub must have a non-null ViewGroup viewParent");
    }
}
 
Example 42
Project: TourGuide   File: TourGuide.java View source code 6 votes vote down vote up
private void setupFrameLayout(){
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
    ViewGroup contentArea = (ViewGroup) mActivity.getWindow().getDecorView().findViewById(android.R.id.content);
    int [] pos = new int[2];
    contentArea.getLocationOnScreen(pos);
    // frameLayoutWithHole's coordinates are calculated taking full screen height into account
    // but we're adding it to the content area only, so we need to offset it to the same Y value of contentArea

    layoutParams.setMargins(0,-pos[1],0,0);
    contentArea.addView(mFrameLayout, layoutParams);
}
 
Example 43
Project: android_packages_apps_AeroControl   File: AppRate.java View source code 6 votes vote down vote up
private void displayViews(ViewGroup mainView) {
    activity.addContentView(mainView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));


    Animation fadeInAnimation;
    if (fromTop) {
        fadeInAnimation = AnimationUtils.loadAnimation(activity, R.anim.fade_in_from_top);
    } else {
        fadeInAnimation = AnimationUtils.loadAnimation(activity, R.anim.fade_in);
    }
    mainView.startAnimation(fadeInAnimation);

    if (onShowListener != null) onShowListener.onRateAppShowing();
}
 
Example 44
Project: android-betterpickers   File: TouchExplorationHelper.java View source code 6 votes vote down vote up
/**
 * Populates an event of the specified type with information about an item and attempts to send it up through the
 * view hierarchy.
 *
 * @param item The item for which to send an event.
 * @param eventType The type of event to send.
 * @return [email protected] true} if the event was sent successfully.
 */
public boolean sendEventForItem(T item, int eventType) {
    if (!mManager.isEnabled()) {
        return false;
    }

    final AccessibilityEvent event = getEventForItem(item, eventType);
    final ViewGroup group = (ViewGroup) mParentView.getParent();

    return group.requestSendAccessibilityEvent(mParentView, event);
}
 
Example 45
Project: property-db   File: NavigationBarView.java View source code 6 votes vote down vote up
public void setDisabledFlags(int disabledFlags, boolean force) {
    if (!force && mDisabledFlags == disabledFlags) return;

    mDisabledFlags = disabledFlags;

    final boolean disableHome = ((disabledFlags & View.STATUS_BAR_DISABLE_HOME) != 0);
    final boolean disableRecent = ((disabledFlags & View.STATUS_BAR_DISABLE_RECENT) != 0);
    final boolean disableBack = ((disabledFlags & View.STATUS_BAR_DISABLE_BACK) != 0)
            && ((mNavigationIconHints & StatusBarManager.NAVIGATION_HINT_BACK_ALT) == 0);
    final boolean disableSearch = ((disabledFlags & View.STATUS_BAR_DISABLE_SEARCH) != 0);

    if (SLIPPERY_WHEN_DISABLED) {
        setSlippery(disableHome && disableRecent && disableBack && disableSearch);
    }

    if (!mScreenOn && mCurrentView != null) {
        ViewGroup navButtons = (ViewGroup) mCurrentView.findViewById(R.id.nav_buttons);
        LayoutTransition lt = navButtons == null ? null : navButtons.getLayoutTransition();
        if (lt != null) {
            lt.disableTransitionType(
                    LayoutTransition.CHANGE_APPEARING | LayoutTransition.CHANGE_DISAPPEARING |
                    LayoutTransition.APPEARING | LayoutTransition.DISAPPEARING);
        }
    }

    getBackButton()   .setVisibility(disableBack       ? View.INVISIBLE : View.VISIBLE);
    getHomeButton()   .setVisibility(disableHome       ? View.INVISIBLE : View.VISIBLE);
    getRecentsButton().setVisibility(disableRecent     ? View.INVISIBLE : View.VISIBLE);

    getSearchLight().setVisibility((disableHome && !disableSearch) ? View.VISIBLE : View.GONE);
}
 
Example 46
Project: AmazeFileManager   File: Preferences.java View source code 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    SharedPreferences Sp = PreferenceManager.getDefaultSharedPreferences(this);
    fabSkin = PreferenceUtils.getFabColor(Sp.getInt("fab_skin_color_position", 1));

    int th = Integer.parseInt(Sp.getString("theme", "0"));

    theme = th==2 ? PreferenceUtils.hourOfDay() : th;

    // setting accent theme
    if (Build.VERSION.SDK_INT >= 21) {

        switch (fabSkin) {
            case "#F44336":
                if (theme==0)
                    setTheme(R.style.pref_accent_light_red);
                else
                    setTheme(R.style.pref_accent_dark_red);
                break;

            case "#e91e63":
                if (theme==0)
                    setTheme(R.style.pref_accent_light_pink);
                else
                    setTheme(R.style.pref_accent_dark_pink);
                break;

            case "#9c27b0":
                if (theme==0)
                    setTheme(R.style.pref_accent_light_purple);
                else
                    setTheme(R.style.pref_accent_dark_purple);
                break;

            case "#673ab7":
                if (theme==0)
                    setTheme(R.style.pref_accent_light_deep_purple);
                else
                    setTheme(R.style.pref_accent_dark_deep_purple);
                break;

            case "#3f51b5":
                if (theme==0)
                    setTheme(R.style.pref_accent_light_indigo);
                else
                    setTheme(R.style.pref_accent_dark_indigo);
                break;

            case "#2196F3":
                if (theme==0)
                    setTheme(R.style.pref_accent_light_blue);
                else
                    setTheme(R.style.pref_accent_dark_blue);
                break;

            case "#03A9F4":
                if (theme==0)
                    setTheme(R.style.pref_accent_light_light_blue);
                else
                    setTheme(R.style.pref_accent_dark_light_blue);
                break;

            case "#00BCD4":
                if (theme==0)
                    setTheme(R.style.pref_accent_light_cyan);
                else
                    setTheme(R.style.pref_accent_dark_cyan);
                break;

            case "#009688":
                if (theme==0)
                    setTheme(R.style.pref_accent_light_teal);
                else
                    setTheme(R.style.pref_accent_dark_teal);
                break;

            case "#4CAF50":
                if (theme==0)
                    setTheme(R.style.pref_accent_light_green);
                else
                    setTheme(R.style.pref_accent_dark_green);
                break;

            case "#8bc34a":
                if (theme==0)
                    setTheme(R.style.pref_accent_light_light_green);
                else
                    setTheme(R.style.pref_accent_dark_light_green);
                break;

            case "#FFC107":
                if (theme==0)
                    setTheme(R.style.pref_accent_light_amber);
                else
                    setTheme(R.style.pref_accent_dark_amber);
                break;

            case "#FF9800":
                if (theme==0)
                    setTheme(R.style.pref_accent_light_orange);
                else
                    setTheme(R.style.pref_accent_dark_orange);
                break;

            case "#FF5722":
                if (theme==0)
                    setTheme(R.style.pref_accent_light_deep_orange);
                else
                    setTheme(R.style.pref_accent_dark_deep_orange);
                break;

            case "#795548":
                if (theme==0)
                    setTheme(R.style.pref_accent_light_brown);
                else
                    setTheme(R.style.pref_accent_dark_brown);
                break;

            case "#212121":
                if (theme==0)
                    setTheme(R.style.pref_accent_light_black);
                else
                    setTheme(R.style.pref_accent_dark_black);
                break;

            case "#607d8b":
                if (theme==0)
                    setTheme(R.style.pref_accent_light_blue_grey);
                else
                    setTheme(R.style.pref_accent_dark_blue_grey);
                break;

            case "#004d40":
                if (theme==0)
                    setTheme(R.style.pref_accent_light_super_su);
                else
                    setTheme(R.style.pref_accent_dark_super_su);
                break;
        }
    } else {
        if (theme==1) {
            setTheme(R.style.appCompatDark);
        } else {
            setTheme(R.style.appCompatLight);
        }
    }

    super.onCreate(savedInstanceState);
    setContentView(R.layout.prefsfrag);
    Toolbar toolbar=(Toolbar)findViewById(R.id.toolbar);
    skin = PreferenceUtils.getSkinColor(Sp.getInt("skin_color_position", 4));
    if (Build.VERSION.SDK_INT>=21) {
        ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Amaze", ((BitmapDrawable)getResources().getDrawable(R.mipmap.ic_launcher)).getBitmap(), Color.parseColor(skin));
        ((Activity)this).setTaskDescription(taskDescription);
    }
    skinStatusBar = PreferenceUtils.getStatusColor(skin);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE);
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin)));
    int sdk=Build.VERSION.SDK_INT;

    if(sdk==20 || sdk==19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(Color.parseColor(skin));

        FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.preferences).getLayoutParams();
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        p.setMargins(0, config.getStatusBarHeight(), 0, 0);
    }else if(Build.VERSION.SDK_INT>=21){
        boolean colourednavigation=Sp.getBoolean("colorednavigation",true);
        Window window =getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor((PreferenceUtils.getStatusColor(skin)));
        if(colourednavigation)
            window.setNavigationBarColor((PreferenceUtils.getStatusColor(skin)));

    }
    selectItem(0);
}
 
Example 47
Project: ExcusePro   File: ActionBarSherlockCompat.java View source code 5 votes vote down vote up
private ViewGroup generateLayout() {
    if (ActionBarSherlock.DEBUG) Log.d(TAG, "[generateLayout]");

    // Apply data from current theme.

    TypedArray a = mActivity.getTheme().obtainStyledAttributes(R.styleable.SherlockTheme);

    if (!a.hasValue(R.styleable.SherlockTheme_windowActionBar)) {
        throw new IllegalStateException("You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.");
    }

    if (a.getBoolean(R.styleable.SherlockTheme_windowNoTitle, false)) {
        requestFeature(Window.FEATURE_NO_TITLE);
    } else if (a.getBoolean(R.styleable.SherlockTheme_windowActionBar, false)) {
        // Don't allow an action bar if there is no title.
        requestFeature(Window.FEATURE_ACTION_BAR);
    }

    if (a.getBoolean(R.styleable.SherlockTheme_windowActionBarOverlay, false)) {
        requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    }

    if (a.getBoolean(R.styleable.SherlockTheme_windowActionModeOverlay, false)) {
        requestFeature(Window.FEATURE_ACTION_MODE_OVERLAY);
    }

    a.recycle();

    int layoutResource;
    if (!hasFeature(Window.FEATURE_NO_TITLE)) {
        if (hasFeature(Window.FEATURE_ACTION_BAR_OVERLAY)) {
            layoutResource = R.layout.abs__screen_action_bar_overlay;
        } else {
            layoutResource = R.layout.abs__screen_action_bar;
        }
    } else if (hasFeature(Window.FEATURE_ACTION_MODE_OVERLAY) && !hasFeature(Window.FEATURE_NO_TITLE)) {
        layoutResource = R.layout.abs__screen_simple_overlay_action_mode;
    } else {
        layoutResource = R.layout.abs__screen_simple;
    }

    if (ActionBarSherlock.DEBUG) Log.d(TAG, "[generateLayout] using screen XML " + mActivity.getResources().getString(layoutResource));
    View in = mActivity.getLayoutInflater().inflate(layoutResource, null);
    mDecor.addView(in, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));

    ViewGroup contentParent = (ViewGroup)mDecor.findViewById(R.id.abs__content);
    if (contentParent == null) {
        throw new RuntimeException("Couldn't find content container view");
    }

    //Make our new child the true content view (for fragments). VERY VOLATILE!
    mDecor.setId(View.NO_ID);
    contentParent.setId(android.R.id.content);

    if (hasFeature(Window.FEATURE_INDETERMINATE_PROGRESS)) {
        IcsProgressBar progress = getCircularProgressBar(false);
        if (progress != null) {
            progress.setIndeterminate(true);
        }
    }

    return contentParent;
}
 
Example 48
Project: Gui2Go   File: EditorActivity.java View source code 5 votes vote down vote up
public void btnClick_widgetUp(View v) {
    // this is an ugly solution due to API lacking something to change Z
    // order
    // IMPORTANT: bring to front actually puts them in the bottom
    if (currentHighlightedID != 0) {
        View target = findViewById(currentHighlightedID);
        ViewGroup parent = (ViewGroup) target.getParent();
        int position = parent.indexOfChild(target);

        LinkedList<View> viewsToFront = new LinkedList<View>();
        if (position != 0) {
            // do it in the tree
            for (int i = 0; i < treeView.getCount(); i++) {
                View viewFromTree = (View) treeView.getChildAt(i);
                if (viewFromTree != null) {
                    String treeViewTag = viewFromTree.getTag().toString();

                    if (treeViewTag.equals(String.valueOf(target.getId()))) {
                        // before moving we should save all its children
                        List<Long> children = manager
                                        .getChildren((long) target.getId());

                        manager.removeNodeRecursively((long) target.getId());
                        insertViewToTreeParentAfterTarget(target, parent,
                                        parent.getChildAt(position - 1));
                        if (children != null) {
                            // re-add all its children
                            for (int j = 0; j < children.size(); j++) {
                                View tempView = ((ViewGroup) target)
                                                .getChildAt(j);
                                manager.addAfterChild(
                                                (long) target.getId(),
                                                (long) tempView.getId(),
                                                null);
                            }
                        }
                    }
                }
            }

            // for (int i = 0; i < treeView.getCount(); i++) { // all this
            // to
            // // find the new
            // // tree view and
            // // highlight it
            // View viewFromTree = (View) treeView.getChildAt(i);
            // if (viewFromTree != null) {
            // String treeViewTag = viewFromTree.getTag().toString();
            // if (treeViewTag.equals(String.valueOf(target.getId()))) {
            // viewFromTree
            // .setBackgroundResource(R.drawable.hightlight_border);
            // }
            // }
            // }

            viewsToFront.add(parent.getChildAt(position - 1));
            for (int i = position + 1; i < parent.getChildCount(); i++) {
                // store the views we need to bring up after
                // up until the position of 2 before the target
                viewsToFront.add(parent.getChildAt(i));
            }

            // now go over the stack and put em all on top in the correct
            // order
            while (!viewsToFront.isEmpty()) {
                View temp = viewsToFront.pop();
                parent.bringChildToFront(temp);
            }
            target.requestLayout();
        }
    } else {
        Toast.makeText(this, "You must select a widget first!",
                        Toast.LENGTH_SHORT).show();
    }
}
 
Example 49
Project: OurApp   File: CaptureActivity.java View source code 5 votes vote down vote up
private void handleDecodeInternally(Result rawResult, ResultHandler resultHandler, Bitmap barcode) {
  statusView.setVisibility(View.GONE);
  viewfinderView.setVisibility(View.GONE);
  resultView.setVisibility(View.VISIBLE);

  ImageView barcodeImageView = (ImageView) findViewById(R.id.barcode_image_view);
  if (barcode == null) {
    barcodeImageView.setImageBitmap(BitmapFactory.decodeResource(getResources(),
        R.drawable.launcher_icon));
  } else {
    barcodeImageView.setImageBitmap(barcode);
  }

  TextView formatTextView = (TextView) findViewById(R.id.format_text_view);
  formatTextView.setText(rawResult.getBarcodeFormat().toString());

  TextView typeTextView = (TextView) findViewById(R.id.type_text_view);
  typeTextView.setText(resultHandler.getType().toString());

  DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
  String formattedTime = formatter.format(new Date(rawResult.getTimestamp()));
  TextView timeTextView = (TextView) findViewById(R.id.time_text_view);
  timeTextView.setText(formattedTime);


  TextView metaTextView = (TextView) findViewById(R.id.meta_text_view);
  View metaTextViewLabel = findViewById(R.id.meta_text_view_label);
  metaTextView.setVisibility(View.GONE);
  metaTextViewLabel.setVisibility(View.GONE);
  Map<ResultMetadataType,Object> metadata =
      (Map<ResultMetadataType,Object>) rawResult.getResultMetadata();
  if (metadata != null) {
    StringBuilder metadataText = new StringBuilder(20);
    for (Map.Entry<ResultMetadataType,Object> entry : metadata.entrySet()) {
      if (DISPLAYABLE_METADATA_TYPES.contains(entry.getKey())) {
        metadataText.append(entry.getValue()).append('\n');
      }
    }
    if (metadataText.length() > 0) {
      metadataText.setLength(metadataText.length() - 1);
      metaTextView.setText(metadataText);
      metaTextView.setVisibility(View.VISIBLE);
      metaTextViewLabel.setVisibility(View.VISIBLE);
    }
  }

  TextView contentsTextView = (TextView) findViewById(R.id.contents_text_view);
  CharSequence displayContents = resultHandler.getDisplayContents();
  contentsTextView.setText(displayContents);
  // Crudely scale betweeen 22 and 32 -- bigger font for shorter text
  int scaledSize = Math.max(22, 32 - displayContents.length() / 4);
  contentsTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, scaledSize);

  TextView supplementTextView = (TextView) findViewById(R.id.contents_supplement_text_view);
  supplementTextView.setText("");
  supplementTextView.setOnClickListener(null);
  if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(
      PreferencesActivity.KEY_SUPPLEMENTAL, true)) {
    SupplementalInfoRetriever.maybeInvokeRetrieval(supplementTextView, resultHandler.getResult(),
        handler, this);
  }

  int buttonCount = resultHandler.getButtonCount();
  ViewGroup buttonView = (ViewGroup) findViewById(R.id.result_button_view);
  buttonView.requestFocus();
  for (int x = 0; x < ResultHandler.MAX_BUTTON_COUNT; x++) {
    TextView button = (TextView) buttonView.getChildAt(x);
    if (x < buttonCount) {
      button.setVisibility(View.VISIBLE);
      button.setText(resultHandler.getButtonText(x));
      button.setOnClickListener(new ResultButtonListener(resultHandler, x));
    } else {
      button.setVisibility(View.GONE);
    }
  }

  if (copyToClipboard && !resultHandler.areContentsSecure()) {
    ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
    clipboard.setText(displayContents);
  }
}
 
Example 50
Project: packages_apps_camera   File: SharePopup.java View source code 5 votes vote down vote up
public SharePopup(Activity activity, Uri uri, Bitmap bitmap, int orientation,
        View previewFrame) {
    super(activity);

    mActivityOrientation = activity.getRequestedOrientation();

    // Initialize variables
    mContext = activity;
    mUri = uri;
    mMimeType = mContext.getContentResolver().getType(mUri);
    mPreviewFrame = previewFrame;
    LayoutInflater inflater = activity.getLayoutInflater();
    ViewGroup sharePopup = (ViewGroup) inflater.inflate(R.layout.share_popup, null, false);
    // This is required because popup window is full screen.
    sharePopup.setOnTouchListener(this);
    mThumbnailRotateLayout =
            (RotateLayout) sharePopup.findViewById(R.id.thumbnail_rotate_layout);
    mShareList = (GridView) sharePopup.findViewById(R.id.share_list);
    mThumbnail = (ImageView) sharePopup.findViewById(R.id.thumbnail);
    mThumbnail.setImageBitmap(bitmap);
    mImageViewFrame =
            (View) sharePopup.findViewById(R.id.thumbnail_image_frame);
    mImageViewFrame.setOnClickListener(this);


    mGotoGalleryRotate =
            (RotateLayout) sharePopup.findViewById(R.id.goto_gallery_button_rotate);
    sharePopup.findViewById(R.id.goto_gallery_button).setOnClickListener(this);

    mBitmapWidth = bitmap.getWidth();
    mBitmapHeight = bitmap.getHeight();

    // Show play button if this is a video thumbnail.
    if (mMimeType.startsWith("video/")) {
        sharePopup.findViewById(R.id.play).setVisibility(View.VISIBLE);
    }
    mBitmapWidth = bitmap.getWidth();
    mBitmapHeight = bitmap.getHeight();

    Resources res = mContext.getResources();

    // Initialize popup window size.
    mRootView = sharePopup.findViewById(R.id.root);
    LayoutParams params = mRootView.getLayoutParams();
    params.width = previewFrame.getWidth();
    params.height = previewFrame.getHeight();
    mRootView.setLayoutParams(params);

    // Initialize popup window.
    setWidth(WindowManager.LayoutParams.MATCH_PARENT);
    setHeight(WindowManager.LayoutParams.MATCH_PARENT);
    setBackgroundDrawable(new ColorDrawable());
    setContentView(sharePopup);
    setOrientation(orientation);
    setFocusable(true);
    setAnimationStyle(R.style.AnimationPopup);
    createShareMenu();
}
 
Example 51
Project: sw606f13   File: GameActivityLinearLayout.java View source code 5 votes vote down vote up
@SuppressWarnings("deprecation")
      @Override
public boolean onDrag(View hoverView, DragEvent event) {
    View draggedView = (View) event.getLocalState();
		
		switch (event.getAction()) {
			case DragEvent.ACTION_DRAG_STARTED:
			    GameActivityLinearLayout.this.requestLayout(); // this is temporary fix for drag error
				break;
	
			case DragEvent.ACTION_DRAG_ENTERED:
				// Change the background of droplayout(purely style)
				hoverView.setBackgroundDrawable(enterShape);
				hoverView.invalidate();
				break;
	
			case DragEvent.ACTION_DRAG_EXITED:
				// Change the background back when exiting droplayout(purely
				// style)
				hoverView.setBackgroundDrawable(normalShape);
				hoverView.invalidate();
				break;
	
			case DragEvent.ACTION_DROP:
				// Dropped, assigns the draggedview to the dropcontainer if
				// the container does not already contain a view.
				ViewGroup ownerContainer = (ViewGroup) draggedView.getParent();
	
				PictoFrameLayout dropContainer = (PictoFrameLayout) hoverView;
				Object tag = hoverView.getTag();
				if (tag == null) {
					ownerContainer.removeView(draggedView);
					ownerContainer.setTag(null);
					ownerContainer.invalidate();
					dropContainer.addView(draggedView);
					dropContainer.setTag("filled");
					dropContainer.invalidate();
				}
				draggedView.setVisibility(View.VISIBLE);
				draggedView.invalidate();
				break;
	
			case DragEvent.ACTION_DRAG_ENDED:
				// Makes the draggedview visible again after the view has
				// been moved or the drop wasn't valid.
				hoverView.setBackgroundDrawable(normalShape);
				hoverView.invalidate();
				if(event.getResult() == false){
					draggedView.setVisibility(View.VISIBLE);
					draggedView.invalidate();
				}
				break;
		}
		return true;
}
 
Example 52
Project: hci-2011-2   File: ActionBarView.java View source code 5 votes vote down vote up
public ActionBarView(final Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    mIsConstructing = true;
    LayoutInflater.from(context).inflate(R.layout.abs__action_bar, this, true);

    mNavItemSelectedListener = new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            if (mCallback != null) {
                mCallback.onNavigationItemSelected(arg2, arg3);
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            //No op
        }
    };

    setBackgroundResource(0);

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockTheme, defStyle, 0);
    final ApplicationInfo appInfo = context.getApplicationInfo();
    final PackageManager pm = context.getPackageManager();


    //// TITLE ////

    mTitleLayout = (TextView)findViewById(R.id.abs__action_bar_title);

    //Try to load title style from the theme
    final int titleTextStyle = a.getResourceId(R.styleable.SherlockTheme_abTitleTextStyle, 0);
    if (titleTextStyle != 0) {
        mTitleLayout.setTextAppearance(context, titleTextStyle);
    }

    //Try to load title from the theme
    mTitle = a.getString(R.styleable.SherlockTheme_abTitle);
    if (mTitle != null) {
        setTitle(mTitle);
    }


    //// SUBTITLE ////

    mSubtitleLayout = (TextView)findViewById(R.id.abs__action_bar_subtitle);

    //Try to load subtitle style from the theme
    final int subtitleTextStyle = a.getResourceId(R.styleable.SherlockTheme_abSubtitleTextStyle, 0);
    if (subtitleTextStyle != 0) {
        mSubtitleLayout.setTextAppearance(context, subtitleTextStyle);
    }

    //Try to load subtitle from theme
    mSubtitle = a.getString(R.styleable.SherlockTheme_abSubtitle);
    if (mSubtitle != null) {
        setSubtitle(mSubtitle);
    }


    /// HOME ////

    mHomeLayout = (ViewGroup)findViewById(R.id.abs__home_wrapper);
    final int homeLayoutResource = a.getResourceId(R.styleable.SherlockTheme_abHomeLayout, R.layout.abs__action_bar_home);
    LayoutInflater.from(context).inflate(homeLayoutResource, mHomeLayout, true);

    //Try to load the logo from the theme
    mLogo = a.getDrawable(R.styleable.SherlockTheme_abLogo);
    /*
    if ((mLogo == null) && (context instanceof Activity)) {
        //LOGO LOADING DOES NOT WORK
        //SEE: http://stackoverflow.com/questions/6105504/load-activity-and-or-application-logo-programmatically-from-manifest
        //SEE: https://groups.google.com/forum/#!topic/android-developers/UFR4l0ZwJWc
    }
    */

    //Try to load the icon from the theme
    mIcon = a.getDrawable(R.styleable.SherlockTheme_abIcon);
    if ((mIcon == null) && (context instanceof Activity)) {
        mIcon = appInfo.loadIcon(pm);
    }

    mHomeAsUpView = findViewById(R.id.abs__up);
    mIconView = (ImageView)findViewById(R.id.abs__home);


    //// NAVIGATION ////

    mSpinner = (Spinner)findViewById(R.id.abs__nav_list);
    mSpinner.setOnItemSelectedListener(mNavItemSelectedListener);

    mTabsView = (LinearLayout)findViewById(R.id.abs__nav_tabs);


    //// CUSTOM VIEW ////

    mCustomView = (FrameLayout)findViewById(R.id.abs__custom);

    //Try to load a custom view from the theme. This will NOT automatically
    //trigger the visibility of the custom layout, however.
    final int customViewResourceId = a.getResourceId(R.styleable.SherlockTheme_abCustomNavigationLayout, 0);
    if (customViewResourceId != 0) {
        mCustomNavView = LayoutInflater.from(context).inflate(customViewResourceId, mCustomView, true);
        mNavigationMode = ActionBar.NAVIGATION_MODE_STANDARD;
        setDisplayOptions(mDisplayOptions | ActionBar.DISPLAY_SHOW_CUSTOM);
    }




    mActionsView = (LinearLayout)findViewById(R.id.abs__actions);
    mDivider = a.getDrawable(R.styleable.SherlockTheme_abDivider);

    mIndeterminateProgress = (ProgressBar)findViewById(R.id.abs__iprogress);

    //Try to get the display options defined in the theme, or fall back to
    //displaying the title and home icon
    setDisplayOptions(a.getInteger(R.styleable.SherlockTheme_abDisplayOptions, DEFAULT_DISPLAY_OPTIONS));

    //Try to get the navigation defined in the theme, or, fall back to
    //use standard navigation by default
    setNavigationMode(a.getInteger(R.styleable.SherlockTheme_abNavigationMode, DEFAULT_NAVIGATION_MODE));


    //Reduce, Reuse, Recycle!
    a.recycle();
    mIsConstructing = false;

    mLogoNavItem = new ActionMenuItem(context, 0, android.R.id.home, 0, 0, mTitle);
    mHomeLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (context instanceof Activity) {
                ((Activity)context).onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, mLogoNavItem);
            }
        }
    });
    mHomeLayout.setClickable(true);
    mHomeLayout.setFocusable(true);

    reloadDisplay();
}
 
Example 53
Project: DynamicWeather   File: ObservableGridView.java View source code 5 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent ev) {
    if (mCallbacks != null) {
        switch (ev.getActionMasked()) {
            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_CANCEL:
                mIntercepted = false;
                mDragging = false;
                mCallbacks.onUpOrCancelMotionEvent(mScrollState);
                break;
            case MotionEvent.ACTION_MOVE:
                if (mPrevMoveEvent == null) {
                    mPrevMoveEvent = ev;
                }
                float diffY = ev.getY() - mPrevMoveEvent.getY();
                mPrevMoveEvent = MotionEvent.obtainNoHistory(ev);
                if (getCurrentScrollY() - diffY <= 0) {
                    // Can't scroll anymore.

                    if (mIntercepted) {
                        // Already dispatched ACTION_DOWN event to parents, so stop here.
                        return false;
                    }

                    // Apps can set the interception target other than the direct parent.
                    final ViewGroup parent;
                    if (mTouchInterceptionViewGroup == null) {
                        parent = (ViewGroup) getParent();
                    } else {
                        parent = mTouchInterceptionViewGroup;
                    }

                    // Get offset to parents. If the parent is not the direct parent,
                    // we should aggregate offsets from all of the parents.
                    float offsetX = 0;
                    float offsetY = 0;
                    for (View v = this; v != null && v != parent; v = (View) v.getParent()) {
                        offsetX += v.getLeft() - v.getScrollX();
                        offsetY += v.getTop() - v.getScrollY();
                    }
                    final MotionEvent event = MotionEvent.obtainNoHistory(ev);
                    event.offsetLocation(offsetX, offsetY);

                    if (parent.onInterceptTouchEvent(event)) {
                        mIntercepted = true;

                        // If the parent wants to intercept ACTION_MOVE events,
                        // we pass ACTION_DOWN event to the parent
                        // as if these touch events just have began now.
                        event.setAction(MotionEvent.ACTION_DOWN);

                        // Return this onTouchEvent() first and set ACTION_DOWN event for parent
                        // to the queue, to keep events sequence.
                        post(new Runnable() {
                            @Override
                            public void run() {
                                parent.dispatchTouchEvent(event);
                            }
                        });
                        return false;
                    }
                    // Even when this can't be scrolled anymore,
                    // simply returning false here may cause subView's click,
                    // so delegate it to super.
                    return super.onTouchEvent(ev);
                }
                break;
        }
    }
    return super.onTouchEvent(ev);
}
 
Example 54
Project: Yhb-2.0   File: PathAnimation.java View source code 5 votes vote down vote up
@Override
public AnimatorSet getAnimatorSet() {
	ViewGroup parentView = (ViewGroup) view.getParent(), rootView = (ViewGroup) view
			.getRootView();
	while (!parentView.equals(rootView)) {
		parentView.setClipChildren(false);
		parentView = (ViewGroup) parentView.getParent();
	}
	rootView.setClipChildren(false);

	AnimatorSet pathSet = new AnimatorSet();
	int numOfPoints = points.size();
	AnimatorSet[] pathAnimSetArray = new AnimatorSet[numOfPoints];
	List<Animator> pathAnimList = new ArrayList<Animator>();

	parentView = (ViewGroup) view.getParent();
	int parentWidth = parentView.getWidth(), parentHeight = parentView
			.getHeight(), viewWidth = view.getWidth(), viewHeight = view
			.getHeight();
	float posX, posY;
	for (int i = 0; i < numOfPoints; i++) {
		posX = (points.get(i).x / 100f * parentWidth);
		posY = (points.get(i).y / 100f * parentHeight);

		switch (anchorPoint) {
		case ANCHOR_CENTER:
			posX = posX - viewWidth / 2;
			posY = posY - viewHeight / 2;
			break;
		case ANCHOR_TOP_RIGHT:
			posX -= viewWidth;
			break;
		case ANCHOR_BOTTOM_LEFT:
			posY -= viewHeight;
			break;
		case ANCHOR_BOTTOM_RIGHT:
			posX = posX - viewWidth;
			posY = posY - viewHeight;
			break;
		default:
			break;
		}
		pathAnimSetArray[i] = new AnimatorSet();
		pathAnimSetArray[i].playTogether(
				ObjectAnimator.ofFloat(view, View.X, posX),
				ObjectAnimator.ofFloat(view, View.Y, posY));
		pathAnimList.add(pathAnimSetArray[i]);
	}

	pathSet.playSequentially(pathAnimList);
	pathSet.setInterpolator(interpolator);
	pathSet.setDuration(duration / numOfPoints);
	pathSet.addListener(new AnimatorListenerAdapter() {

		@Override
		public void onAnimationEnd(Animator animation) {
			if (getListener() != null) {
				getListener().onAnimationEnd(PathAnimation.this);
			}
		}
	});
	return pathSet;
}