• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Utils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中wei.mark.standout.Utils的典型用法代码示例。如果您正苦于以下问题:Java Utils类的具体用法?Java Utils怎么用?Java Utils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Utils类属于wei.mark.standout包,在下文中一共展示了Utils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onInterceptTouchEvent

import wei.mark.standout.Utils; //导入依赖的package包/类
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
    StandOutLayoutParams params = getLayoutParams();

    // focus window
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        if (mContext.getFocusedWindow() != this) {
            mContext.focus(id);
        }
    }

    // multitouch
    if (event.getPointerCount() >= 2 && Utils.isSet(flags, StandOutFlags.FLAG_WINDOW_PINCH_RESIZE_ENABLE) && (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_POINTER_DOWN) {
        touchInfo.scale = 1;
        touchInfo.dist = -1;
        touchInfo.firstWidth = params.width;
        touchInfo.firstHeight = params.height;
        return true;
    }

    return false;
}
 
开发者ID:tuyendt6,项目名称:WindowsNoteMaster,代码行数:23,代码来源:Window.java


示例2: addFunctionality

import wei.mark.standout.Utils; //导入依赖的package包/类
/**
 * Implement StandOut specific additional functionalities.
 * <p/>
 * <p/>
 * Currently, this method does the following:
 * <p/>
 * <p/>
 * Attach resize handles: For every View found to have id R.id.corner,
 * attach an OnTouchListener that implements resizing the window.
 *
 * @param root The view hierarchy that is part of the window.
 */
void addFunctionality(View root) {
    // corner for resize
    if (!Utils.isSet(flags, StandOutFlags.FLAG_ADD_FUNCTIONALITY_RESIZE_DISABLE)) {
        View corner = root.findViewById(R.id.corner);
        if (corner != null) {
            corner.setOnTouchListener(new OnTouchListener() {

                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    // handle dragging to move
                    boolean consumed = mContext.onTouchHandleResize(id, Window.this, v, event);

                    return consumed;
                }
            });
        }
    }
}
 
开发者ID:tuyendt6,项目名称:WindowsNoteMaster,代码行数:31,代码来源:Window.java


示例3: onInterceptTouchEvent

import wei.mark.standout.Utils; //导入依赖的package包/类
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
	StandOutLayoutParams params = getLayoutParams();

	// focus window
	if (event.getAction() == MotionEvent.ACTION_DOWN) {
		if (mContext.getFocusedWindow() != this) {
			mContext.focus(id);
		}
	}

	// multitouch
	if (event.getPointerCount() >= 2
			&& Utils.isSet(flags,
					StandOutFlags.FLAG_WINDOW_PINCH_RESIZE_ENABLE)
			&& (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_POINTER_DOWN) {
		touchInfo.scale = 1;
		touchInfo.dist = -1;
		touchInfo.firstWidth = params.width;
		touchInfo.firstHeight = params.height;
		return true;
	}

	return false;
}
 
开发者ID:fatangare,项目名称:LogcatViewer,代码行数:26,代码来源:Window.java


示例4: onInterceptTouchEvent

import wei.mark.standout.Utils; //导入依赖的package包/类
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
	StandOutLayoutParams params = getLayoutParams();

	// focus window
	if (event.getAction() == MotionEvent.ACTION_DOWN) {
		if (mContext.getFocusedWindow() != this) {
			mContext.focus(id);
		}
	}

	// multitouch
	if (event.getPointerCount() >= 2 && Utils.isSet(flags, StandOutFlags.FLAG_WINDOW_PINCH_RESIZE_ENABLE) && (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_POINTER_DOWN) {
		touchInfo.scale = 1;
		touchInfo.dist = -1;
		touchInfo.firstWidth = params.width;
		touchInfo.firstHeight = params.height;
		return true;
	}

	return false;
}
 
开发者ID:MohammadAdib,项目名称:Roundr,代码行数:23,代码来源:Window.java


示例5: addFunctionality

import wei.mark.standout.Utils; //导入依赖的package包/类
/**
 * Implement StandOut specific additional functionalities.
 * 
 * <p>
 * Currently, this method does the following:
 * 
 * <p>
 * Attach resize handles: For every View found to have id R.id.corner,
 * attach an OnTouchListener that implements resizing the window.
 * 
 * @param root
 *            The view hierarchy that is part of the window.
 */
void addFunctionality(View root) {
	// corner for resize
	if (!Utils.isSet(flags, StandOutFlags.FLAG_ADD_FUNCTIONALITY_RESIZE_DISABLE)) {
		View corner = root.findViewById(R.id.corner);
		if (corner != null) {
			corner.setOnTouchListener(new OnTouchListener() {

				@Override
				public boolean onTouch(View v, MotionEvent event) {
					// handle dragging to move
					boolean consumed = mContext.onTouchHandleResize(id, Window.this, v, event);

					return consumed;
				}
			});
		}
	}
}
 
开发者ID:tmatz,项目名称:FloatingStickies-custom,代码行数:32,代码来源:Window.java


示例6: setPosition

import wei.mark.standout.Utils; //导入依赖的package包/类
/**
 * Set the position of this window in absolute pixels.
 *
 * @param x
 * @param y
 * @param skip Don't call {@link #setPosition(int, int)} and
 *             {@link #setSize(int, int)} to avoid stack overflow.
 * @return The same Editor, useful for method chaining.
 */
private Editor setPosition(int x, int y, boolean skip) {
    if (mParams != null) {
        if (anchorX < 0 || anchorX > 1 || anchorY < 0 || anchorY > 1) {
            throw new IllegalStateException("Anchor point must be between 0 and 1, inclusive.");
        }

        // sets the x and y correctly according to anchorX and
        // anchorY
        if (x != UNCHANGED) {
            mParams.x = (int) (x - mParams.width * anchorX);
        }
        if (y != UNCHANGED) {
            mParams.y = (int) (y - mParams.height * anchorY);
        }

        if (Utils.isSet(flags, StandOutFlags.FLAG_WINDOW_EDGE_LIMITS_ENABLE)) {
            // if gravity is not TOP|LEFT throw exception
            if (mParams.gravity != (Gravity.TOP | Gravity.LEFT)) {
                throw new IllegalStateException("The window " + id + " gravity must be TOP|LEFT if FLAG_WINDOW_EDGE_LIMITS_ENABLE or FLAG_WINDOW_EDGE_TILE_ENABLE is set.");
            }

            // keep window inside edges
            mParams.x = Math.min(Math.max(mParams.x, 0), displayWidth - mParams.width);
            mParams.y = Math.min(Math.max(mParams.y, 0), displayHeight - mParams.height);
        }
    }

    return this;
}
 
开发者ID:tuyendt6,项目名称:WindowsNoteMaster,代码行数:39,代码来源:Window.java


示例7: setPosition

import wei.mark.standout.Utils; //导入依赖的package包/类
/**
 * Set the position of this window in absolute pixels. The window's
 * top-left corner will be positioned at the given x and y, unless
 * you've set a different anchor point with
 * {@link #setAnchorPoint(float, float)}.
 * 
 * Changes will not applied until you {@link #commit()}.
 * 
 * @param x
 * @param y
 * @param skip
 *            Don't call {@link #setPosition(int, int)} and
 *            {@link #setSize(int, int)} to avoid stack overflow.
 * @return The same Editor, useful for method chaining.
 */
private Editor setPosition(int x, int y, boolean skip) {
	if (mParams != null) {
		if (anchorX < 0 || anchorX > 1 || anchorY < 0 || anchorY > 1) {
			throw new IllegalStateException(
					"Anchor point must be between 0 and 1, inclusive.");
		}

		// sets the x and y correctly according to anchorX and
		// anchorY
		if (x != UNCHANGED) {
			mParams.x = (int) (x - mParams.width * anchorX);
		}
		if (y != UNCHANGED) {
			mParams.y = (int) (y - mParams.height * anchorY);
		}

		if (Utils.isSet(flags,
				StandOutFlags.FLAG_WINDOW_EDGE_LIMITS_ENABLE)) {
			// if gravity is not TOP|LEFT throw exception
			if (mParams.gravity != (Gravity.TOP | Gravity.LEFT)) {
				throw new IllegalStateException(
						"The window "
								+ id
								+ " gravity must be TOP|LEFT if FLAG_WINDOW_EDGE_LIMITS_ENABLE or FLAG_WINDOW_EDGE_TILE_ENABLE is set.");
			}

			// keep window inside edges
			mParams.x = Math.min(Math.max(mParams.x, 0), displayWidth
					- mParams.width);
			mParams.y = Math.min(Math.max(mParams.y, 0), displayHeight
					- mParams.height);
		}
	}

	return this;
}
 
开发者ID:fatangare,项目名称:LogcatViewer,代码行数:52,代码来源:Window.java


示例8: setPosition

import wei.mark.standout.Utils; //导入依赖的package包/类
/**
 * Set the position of this window in absolute pixels.
 * 
 * @param x
 * @param y
 * @param skip
 *            Don't call {@link #setPosition(int, int)} and
 *            {@link #setSize(int, int)} to avoid stack overflow.
 * @return The same Editor, useful for method chaining.
 */
private Editor setPosition(int x, int y, boolean skip) {
	if (mParams != null) {
		if (anchorX < 0 || anchorX > 1 || anchorY < 0 || anchorY > 1) {
			throw new IllegalStateException("Anchor point must be between 0 and 1, inclusive.");
		}

		// sets the x and y correctly according to anchorX and
		// anchorY
		if (x != UNCHANGED) {
			mParams.x = (int) (x - mParams.width * anchorX);
		}
		if (y != UNCHANGED) {
			mParams.y = (int) (y - mParams.height * anchorY);
		}

		if (Utils.isSet(flags, StandOutFlags.FLAG_WINDOW_EDGE_LIMITS_ENABLE)) {
			// if gravity is not TOP|LEFT throw exception
			if (mParams.gravity != (Gravity.TOP | Gravity.LEFT)) {
				throw new IllegalStateException("The window " + id + " gravity must be TOP|LEFT if FLAG_WINDOW_EDGE_LIMITS_ENABLE or FLAG_WINDOW_EDGE_TILE_ENABLE is set.");
			}

			// keep window inside edges
			mParams.x = Math.min(Math.max(mParams.x, 0), displayWidth - mParams.width);
			mParams.y = Math.min(Math.max(mParams.y, 0), displayHeight - mParams.height);
		}
	}

	return this;
}
 
开发者ID:MohammadAdib,项目名称:Roundr,代码行数:40,代码来源:Window.java


示例9: addFunctionality

import wei.mark.standout.Utils; //导入依赖的package包/类
/**
 * Implement StandOut specific additional functionalities.
 * 
 * <p>
 * Currently, this method does the following:
 * 
 * <p>
 * Attach resize handles: For every View found to have id R.id.corner,
 * attach an OnTouchListener that implements resizing the window.
 * 
 * @param root
 *            The view hierarchy that is part of the window.
 */
void addFunctionality(View root) {
	// corner for resize
	if (!Utils.isSet(flags,
			StandOutFlags.FLAG_ADD_FUNCTIONALITY_RESIZE_DISABLE)) {

	}

	// window_icon for drop down
	if (!Utils.isSet(flags,
			StandOutFlags.FLAG_ADD_FUNCTIONALITY_DROP_DOWN_DISABLE)) {

	}
}
 
开发者ID:sakchhams,项目名称:widgets,代码行数:27,代码来源:Window.java


示例10: setPosition

import wei.mark.standout.Utils; //导入依赖的package包/类
/**
 * Set the position of this window in absolute pixels.
 * 
 * @param x
 * @param y
 * @param skip
 *            Don't call {@link #setPosition(int, int)} and
 *            {@link #setSize(int, int)} to avoid stack overflow.
 * @return The same Editor, useful for method chaining.
 */
private Editor setPosition(int x, int y, boolean skip) {
	if (mParams != null) {
		if (anchorX < 0 || anchorX > 1 || anchorY < 0 || anchorY > 1) {
			throw new IllegalStateException(
					"Anchor point must be between 0 and 1, inclusive.");
		}

		// sets the x and y correctly according to anchorX and
		// anchorY
		if (x != UNCHANGED) {
			mParams.x = (int) (x - mParams.width * anchorX);
		}
		if (y != UNCHANGED) {
			mParams.y = (int) (y - mParams.height * anchorY);
		}

		if (Utils.isSet(flags,
				StandOutFlags.FLAG_WINDOW_EDGE_LIMITS_ENABLE)) {
			// if gravity is not TOP|LEFT throw exception
			if (mParams.gravity != (Gravity.TOP | Gravity.LEFT)) {
				throw new IllegalStateException(
						"The window "
								+ id
								+ " gravity must be TOP|LEFT if FLAG_WINDOW_EDGE_LIMITS_ENABLE or FLAG_WINDOW_EDGE_TILE_ENABLE is set.");
			}

			// keep window inside edges
			mParams.x = Math.min(Math.max(mParams.x, 0), displayWidth
					- mParams.width);
			mParams.y = Math.min(Math.max(mParams.y, 0), displayHeight
					- mParams.height);
		}
	}

	return this;
}
 
开发者ID:city0666,项目名称:attic-android,代码行数:47,代码来源:Window.java


示例11: onTouchEvent

import wei.mark.standout.Utils; //导入依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {
    // handle touching outside
    switch (event.getAction()) {
        case MotionEvent.ACTION_OUTSIDE:
            // unfocus window
            if (mContext.getFocusedWindow() == this) {
                mContext.unfocus(this);
            }

            // notify implementation that ACTION_OUTSIDE occurred
            mContext.onTouchBody(id, this, this, event);
            break;
    }

    // handle multitouch
    if (event.getPointerCount() >= 2 && Utils.isSet(flags, StandOutFlags.FLAG_WINDOW_PINCH_RESIZE_ENABLE)) {
        // 2 fingers or more

        float x0 = event.getX(0);
        float y0 = event.getY(0);
        float x1 = event.getX(1);
        float y1 = event.getY(1);

        double dist = Math.sqrt(Math.pow(x0 - x1, 2) + Math.pow(y0 - y1, 2));

        switch (event.getAction() & MotionEvent.ACTION_MASK) {
            case MotionEvent.ACTION_MOVE:
                if (touchInfo.dist == -1) {
                    touchInfo.dist = dist;
                }
                touchInfo.scale *= dist / touchInfo.dist;
                touchInfo.dist = dist;

                // scale the window with anchor point set to middle
                edit().setAnchorPoint(.5f, .5f).setSize((int) (touchInfo.firstWidth * touchInfo.scale), (int) (touchInfo.firstHeight * touchInfo.scale)).commit();
                break;
        }
    }

    return true;
}
 
开发者ID:tuyendt6,项目名称:WindowsNoteMaster,代码行数:43,代码来源:Window.java


示例12: onFocus

import wei.mark.standout.Utils; //导入依赖的package包/类
/**
 * Request or remove the focus from this window.
 *
 * @param focus Whether we want to gain or lose focus.
 * @return True if focus changed successfully, false if it failed.
 */
public boolean onFocus(boolean focus) {
    if (!Utils.isSet(flags, StandOutFlags.FLAG_WINDOW_FOCUSABLE_DISABLE)) {
        // window is focusable

        if (focus == focused) {
            // window already focused/unfocused
            return false;
        }

        focused = focus;

        // alert callbacks and cancel if instructed
        if (mContext.onFocusChange(id, this, focus)) {
            Log.d(TAG, "Window " + id + " focus change " + (focus ? "(true)" : "(false)") + " cancelled by implementation.");
            focused = !focus;
            return false;
        }

        if (!Utils.isSet(flags, StandOutFlags.FLAG_WINDOW_FOCUS_INDICATOR_DISABLE)) {
            // change visual state
            View content = findViewById(R.id.content);
            if (focus) {
                // gaining focus
                // content.setBackgroundResource(R.drawable.border_focused);
            } else {
                // losing focus
                if (Utils.isSet(flags, StandOutFlags.FLAG_DECORATION_SYSTEM)) {
                    // system decorations
                    // content.setBackgroundResource(R.drawable.border);
                } else {
                    // no decorations
                    content.setBackgroundResource(0);
                }
            }
        }

        // set window manager params
        StandOutLayoutParams params = getLayoutParams();
        params.setFocusFlag(focus);
        mContext.updateViewLayout(id, params);

        if (focus) {
            mContext.setFocusedWindow(this);
        } else {
            if (mContext.getFocusedWindow() == this) {
                mContext.setFocusedWindow(null);
            }
        }

        return true;
    }
    return false;
}
 
开发者ID:tuyendt6,项目名称:WindowsNoteMaster,代码行数:60,代码来源:Window.java


示例13: setSize

import wei.mark.standout.Utils; //导入依赖的package包/类
/**
 * Set the size of this window in absolute pixels.
 *
 * @param width
 * @param height
 * @param skip   Don't call {@link #setPosition(int, int)} to avoid stack
 *               overflow.
 * @return The same Editor, useful for method chaining.
 */
private Editor setSize(int width, int height, boolean skip) {
    if (mParams != null) {
        if (anchorX < 0 || anchorX > 1 || anchorY < 0 || anchorY > 1) {
            throw new IllegalStateException("Anchor point must be between 0 and 1, inclusive.");
        }

        int lastWidth = mParams.width;
        int lastHeight = mParams.height;

        if (width != UNCHANGED) {
            mParams.width = width;
        }
        if (height != UNCHANGED) {
            mParams.height = height;
        }

        // set max width/height
        int maxWidth = mParams.maxWidth;
        int maxHeight = mParams.maxHeight;

        if (Utils.isSet(flags, StandOutFlags.FLAG_WINDOW_EDGE_LIMITS_ENABLE)) {
            maxWidth = (int) Math.min(maxWidth, displayWidth);
            maxHeight = (int) Math.min(maxHeight, displayHeight);
        }

        // keep window between min and max
        mParams.width = Math.min(Math.max(mParams.width, mParams.minWidth), maxWidth);
        mParams.height = Math.min(Math.max(mParams.height, mParams.minHeight), maxHeight);

        // keep window in aspect ratio
        if (Utils.isSet(flags, StandOutFlags.FLAG_WINDOW_ASPECT_RATIO_ENABLE)) {
            int ratioWidth = (int) (mParams.height * touchInfo.ratio);
            int ratioHeight = (int) (mParams.width / touchInfo.ratio);
            if (ratioHeight >= mParams.minHeight && ratioHeight <= mParams.maxHeight) {
                // width good adjust height
                mParams.height = ratioHeight;
            } else {
                // height good adjust width
                mParams.width = ratioWidth;
            }
        }

        if (!skip) {
            // set position based on anchor point
            setPosition((int) (mParams.x + lastWidth * anchorX), (int) (mParams.y + lastHeight * anchorY));
        }
    }

    return this;
}
 
开发者ID:tuyendt6,项目名称:WindowsNoteMaster,代码行数:60,代码来源:Window.java


示例14: Window

import wei.mark.standout.Utils; //导入依赖的package包/类
public Window(final StandOutWindow context, final int id) {
	super(context);
	context.setTheme(context.getThemeStyle());

	mContext = context;
	mLayoutInflater = LayoutInflater.from(context);

	this.cls = context.getClass();
	this.id = id;
	this.originalParams = context.getParams(id, this);
	this.flags = context.getFlags(id);
	this.touchInfo = new TouchInfo();
	touchInfo.ratio = (float) originalParams.width / originalParams.height;
	this.data = new Bundle();
	DisplayMetrics metrics = mContext.getResources()
			.getDisplayMetrics();
	displayWidth = metrics.widthPixels;
	displayHeight = (int) (metrics.heightPixels - 25 * metrics.density);

	// create the window contents
	View content;
	FrameLayout body;

	if (Utils.isSet(flags, StandOutFlags.FLAG_DECORATION_SYSTEM)) {
		// requested system window decorations
		content = getSystemDecorations();
		body = (FrameLayout) content.findViewById(R.id.body);
	} else {
		// did not request decorations. will provide own implementation
		content = new FrameLayout(context);
		content.setId(R.id.content);
		body = (FrameLayout) content;
	}

	addView(content);

	body.setOnTouchListener(new OnTouchListener() {

		@Override
		public boolean onTouch(View v, MotionEvent event) {
			// pass all touch events to the implementation
			boolean consumed = false;

			// handle move and bring to front
			consumed = context.onTouchHandleMove(id, Window.this, v, event)
					|| consumed;

			// alert implementation
			consumed = context.onTouchBody(id, Window.this, v, event)
					|| consumed;

			return consumed;
		}
	});

	// attach the view corresponding to the id from the
	// implementation
	context.createAndAttachView(id, body);

	// make sure the implementation attached the view
	if (body.getChildCount() == 0) {
		throw new RuntimeException(
				"You must attach your view to the given frame in createAndAttachView()");
	}

	// implement StandOut specific workarounds
	if (!Utils.isSet(flags,
			StandOutFlags.FLAG_FIX_COMPATIBILITY_ALL_DISABLE)) {
		fixCompatibility(body);
	}
	// implement StandOut specific additional functionality
	if (!Utils.isSet(flags,
			StandOutFlags.FLAG_ADD_FUNCTIONALITY_ALL_DISABLE)) {
		addFunctionality(body);
	}

	// attach the existing tag from the frame to the window
	setTag(body.getTag());
}
 
开发者ID:fatangare,项目名称:LogcatViewer,代码行数:80,代码来源:Window.java


示例15: onTouchEvent

import wei.mark.standout.Utils; //导入依赖的package包/类
@Override
public boolean onTouchEvent(MotionEvent event) {
	// handle touching outside
	switch (event.getAction()) {
		case MotionEvent.ACTION_OUTSIDE:
			// unfocus window
			if (mContext.getFocusedWindow() == this) {
				mContext.unfocus(this);
			}

			// notify implementation that ACTION_OUTSIDE occurred
			mContext.onTouchBody(id, this, this, event);
			break;
	}

	// handle multitouch
	if (event.getPointerCount() >= 2
			&& Utils.isSet(flags,
					StandOutFlags.FLAG_WINDOW_PINCH_RESIZE_ENABLE)) {
		// 2 fingers or more

		float x0 = event.getX(0);
		float y0 = event.getY(0);
		float x1 = event.getX(1);
		float y1 = event.getY(1);

		double dist = Math
				.sqrt(Math.pow(x0 - x1, 2) + Math.pow(y0 - y1, 2));

		switch (event.getAction() & MotionEvent.ACTION_MASK) {
			case MotionEvent.ACTION_MOVE:
				if (touchInfo.dist == -1) {
					touchInfo.dist = dist;
				}
				touchInfo.scale *= dist / touchInfo.dist;
				touchInfo.dist = dist;

				// scale the window with anchor point set to middle
				edit().setAnchorPoint(.5f, .5f)
						.setSize(
								(int) (touchInfo.firstWidth * touchInfo.scale),
								(int) (touchInfo.firstHeight * touchInfo.scale))
						.commit();
				break;
		}
		mContext.onResize(id, this, this, event);
	}

	return true;
}
 
开发者ID:fatangare,项目名称:LogcatViewer,代码行数:51,代码来源:Window.java


示例16: onFocus

import wei.mark.standout.Utils; //导入依赖的package包/类
/**
 * Request or remove the focus from this window.
 * 
 * @param focus
 *            Whether we want to gain or lose focus.
 * @return True if focus changed successfully, false if it failed.
 */
public boolean onFocus(boolean focus) {
	if (!Utils.isSet(flags, StandOutFlags.FLAG_WINDOW_FOCUSABLE_DISABLE)) {
		// window is focusable

		if (focus == focused) {
			// window already focused/unfocused
			return false;
		}

		focused = focus;

		// alert callbacks and cancel if instructed
		if (mContext.onFocusChange(id, this, focus)) {
			Log.d(TAG, "Window " + id + " focus change "
					+ (focus ? "(true)" : "(false)")
					+ " cancelled by implementation.");
			focused = !focus;
			return false;
		}

		if (!Utils.isSet(flags,
				StandOutFlags.FLAG_WINDOW_FOCUS_INDICATOR_DISABLE)) {
			// change visual state
			View content = findViewById(R.id.content);
			if (focus) {
				// gaining focus
				content.setBackgroundResource( android.R.color.holo_green_dark);
			} else {
				// losing focus
				if (Utils
						.isSet(flags, StandOutFlags.FLAG_DECORATION_SYSTEM)) {
					// system decorations
					content.setBackgroundResource(android.R.color.holo_green_dark);
				} else {
					// no decorations
					content.setBackgroundResource(0);
				}
			}
		}

		// set window manager params
		StandOutLayoutParams params = getLayoutParams();
		params.setFocusFlag(focus);
		mContext.updateViewLayout(id, params);

		if (focus) {
			mContext.setFocusedWindow(this);
		} else {
			if (mContext.getFocusedWindow() == this) {
				mContext.setFocusedWindow(null);
			}
		}

		return true;
	}
	return false;
}
 
开发者ID:fatangare,项目名称:LogcatViewer,代码行数:65,代码来源:Window.java


示例17: setSize

import wei.mark.standout.Utils; //导入依赖的package包/类
/**
 * Set the size of this window in absolute pixels. The window will
 * expand and shrink around the top-left corner, unless you've set a
 * different anchor point with {@link #setAnchorPoint(float, float)}.
 * 
 * Changes will not applied until you {@link #commit()}.
 * 
 * @param width
 * @param height
 * @param skip
 *            Don't call {@link #setPosition(int, int)} to avoid stack
 *            overflow.
 * @return The same Editor, useful for method chaining.
 */
private Editor setSize(int width, int height, boolean skip) {
	if (mParams != null) {
		if (anchorX < 0 || anchorX > 1 || anchorY < 0 || anchorY > 1) {
			throw new IllegalStateException(
					"Anchor point must be between 0 and 1, inclusive.");
		}

		int lastWidth = mParams.width;
		int lastHeight = mParams.height;

		if (width != UNCHANGED) {
			mParams.width = width;
		}
		if (height != UNCHANGED) {
			mParams.height = height;
		}

		// set max width/height
		int maxWidth = mParams.maxWidth;
		int maxHeight = mParams.maxHeight;

		if (Utils.isSet(flags,
				StandOutFlags.FLAG_WINDOW_EDGE_LIMITS_ENABLE)) {
			maxWidth = Math.min(maxWidth, displayWidth);
			maxHeight = Math.min(maxHeight, displayHeight);
		}

		// keep window between min and max
		mParams.width = Math.min(
				Math.max(mParams.width, mParams.minWidth), maxWidth);
		mParams.height = Math.min(
				Math.max(mParams.height, mParams.minHeight), maxHeight);

		// keep window in aspect ratio
		if (Utils.isSet(flags,
				StandOutFlags.FLAG_WINDOW_ASPECT_RATIO_ENABLE)) {
			int ratioWidth = (int) (mParams.height * touchInfo.ratio);
			int ratioHeight = (int) (mParams.width / touchInfo.ratio);
			if (ratioHeight >= mParams.minHeight
					&& ratioHeight <= mParams.maxHeight) {
				// width good adjust height
				mParams.height = ratioHeight;
			} else {
				// height good adjust width
				mParams.width = ratioWidth;
			}
		}

		if (!skip) {
			// set position based on anchor point
			setPosition((int) (mParams.x + lastWidth * anchorX),
					(int) (mParams.y + lastHeight * anchorY));
		}
	}

	return this;
}
 
开发者ID:fatangare,项目名称:LogcatViewer,代码行数:72,代码来源:Window.java


示例18: onFocus

import wei.mark.standout.Utils; //导入依赖的package包/类
/**
 * Request or remove the focus from this window.
 * 
 * @param focus
 *            Whether we want to gain or lose focus.
 * @return True if focus changed successfully, false if it failed.
 */
public boolean onFocus(boolean focus) {
	if (!Utils.isSet(flags, StandOutFlags.FLAG_WINDOW_FOCUSABLE_DISABLE)) {
		// window is focusable

		if (focus == focused) {
			// window already focused/unfocused
			return false;
		}

		focused = focus;

		// alert callbacks and cancel if instructed
		if (mContext.onFocusChange(id, this, focus)) {
			Log.d(TAG, "Window " + id + " focus change "
					+ (focus ? "(true)" : "(false)")
					+ " cancelled by implementation.");
			focused = !focus;
			return false;
		}

		if (!Utils.isSet(flags,
				StandOutFlags.FLAG_WINDOW_FOCUS_INDICATOR_DISABLE)) {
			// change visual state
			View content = findViewById(R.id.content);
			if (focus) {
				// gaining focus
				content.setBackgroundResource(R.drawable.border_focused);
			} else {
				// losing focus
				if (Utils
						.isSet(flags, StandOutFlags.FLAG_DECORATION_SYSTEM)) {
					// system decorations
					content.setBackgroundResource(R.drawable.border);
				} else {
					// no decorations
					content.setBackgroundResource(0);
				}
			}
		}

		// set window manager params
		StandOutLayoutParams params = getLayoutParams();
		params.setFocusFlag(focus);
		mContext.updateViewLayout(id, params);

		if (focus) {
			mContext.setFocusedWindow(this);
		} else {
			if (mContext.getFocusedWindow() == this) {
				mContext.setFocusedWindow(null);
			}
		}

		return true;
	}
	return false;
}
 
开发者ID:ObsidianX,项目名称:xposed-spenonly,代码行数:65,代码来源:Window.java


示例19: setSize

import wei.mark.standout.Utils; //导入依赖的package包/类
/**
 * Set the size of this window in absolute pixels. The window will
 * expand and shrink around the top-left corner, unless you've set a
 * different anchor point with {@link #setAnchorPoint(float, float)}.
 * 
 * Changes will not applied until you {@link #commit()}.
 * 
 * @param width
 * @param height
 * @param skip
 *            Don't call {@link #setPosition(int, int)} to avoid stack
 *            overflow.
 * @return The same Editor, useful for method chaining.
 */
private Editor setSize(int width, int height, boolean skip) {
	if (mParams != null) {
		if (anchorX < 0 || anchorX > 1 || anchorY < 0 || anchorY > 1) {
			throw new IllegalStateException(
					"Anchor point must be between 0 and 1, inclusive.");
		}

		int lastWidth = mParams.width;
		int lastHeight = mParams.height;

		if (width != UNCHANGED) {
			mParams.width = width;
		}
		if (height != UNCHANGED) {
			mParams.height = height;
		}

		// set max width/height
		int maxWidth = mParams.maxWidth;
		int maxHeight = mParams.maxHeight;

		if (Utils.isSet(flags,
				StandOutFlags.FLAG_WINDOW_EDGE_LIMITS_ENABLE)) {
			maxWidth = (int) Math.min(maxWidth, displayWidth);
			maxHeight = (int) Math.min(maxHeight, displayHeight);
		}

		// keep window between min and max
		mParams.width = Math.min(
				Math.max(mParams.width, mParams.minWidth), maxWidth);
		mParams.height = Math.min(
				Math.max(mParams.height, mParams.minHeight), maxHeight);

		// keep window in aspect ratio
		if (Utils.isSet(flags,
				StandOutFlags.FLAG_WINDOW_ASPECT_RATIO_ENABLE)) {
			int ratioWidth = (int) (mParams.height * touchInfo.ratio);
			int ratioHeight = (int) (mParams.width / touchInfo.ratio);
			if (ratioHeight >= mParams.minHeight
					&& ratioHeight <= mParams.maxHeight) {
				// width good adjust height
				mParams.height = ratioHeight;
			} else {
				// height good adjust width
				mParams.width = ratioWidth;
			}
		}

		if (!skip) {
			// set position based on anchor point
			setPosition((int) (mParams.x + lastWidth * anchorX),
					(int) (mParams.y + lastHeight * anchorY));
		}
	}

	return this;
}
 
开发者ID:ObsidianX,项目名称:xposed-spenonly,代码行数:72,代码来源:Window.java


示例20: Window

import wei.mark.standout.Utils; //导入依赖的package包/类
public Window(final StandOutWindow context, final int id) {
	super(context);
	context.setTheme(context.getThemeStyle());

	mContext = context;
	mLayoutInflater = LayoutInflater.from(context);

	this.cls = context.getClass();
	this.id = id;
	this.originalParams = context.getParams(id, this);
	this.flags = context.getFlags(id);
	this.touchInfo = new TouchInfo();
	touchInfo.ratio = (float) originalParams.width / originalParams.height;
	this.data = new Bundle();

	// create the window contents
	View content;
	FrameLayout body;

	if (Utils.isSet(flags, StandOutFlags.FLAG_DECORATION_SYSTEM)) {
		// requested system window decorations
		content = getSystemDecorations();
		body = (FrameLayout) content.findViewById(R.id.body);
	} else {
		// did not request decorations. will provide own implementation
		content = new FrameLayout(context);
		content.setId(R.id.content);
		body = (FrameLayout) content;
	}

	addView(content);

	body.setOnTouchListener(new OnTouchListener() {

		@Override
		public boolean onTouch(View v, MotionEvent event) {
			// pass all touch events to the implementation
			boolean consumed = false;

			// handle move and bring to front
			consumed = context.onTouchHandleMove(id, Window.this, v, event) || consumed;

			// alert implementation
			consumed = context.onTouchBody(id, Window.this, v, event) || consumed;

			return consumed;
		}
	});

	// attach the view corresponding to the id from the
	// implementation
	context.createAndAttachView(id, body);

	// make sure the implementation attached the view
	if (body.getChildCount() == 0) {
		throw new RuntimeException("You must attach your view to the given frame in createAndAttachView()");
	}

	// implement StandOut specific workarounds
	if (!Utils.isSet(flags, StandOutFlags.FLAG_FIX_COMPATIBILITY_ALL_DISABLE)) {
		fixCompatibility(body);
	}
	// implement StandOut specific additional functionality
	if (!Utils.isSet(flags, StandOutFlags.FLAG_ADD_FUNCTIONALITY_ALL_DISABLE)) {
		addFunctionality(body);
	}

	// attach the existing tag from the frame to the window
	setTag(body.getTag());
}
 
开发者ID:MohammadAdib,项目名称:Roundr,代码行数:71,代码来源:Window.java



注:本文中的wei.mark.standout.Utils类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TimeDefinition类代码示例发布时间:2022-05-22
下一篇:
Java MailingList类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap