本文整理汇总了Java中com.jakewharton.scalpel.ScalpelFrameLayout类的典型用法代码示例。如果您正苦于以下问题:Java ScalpelFrameLayout类的具体用法?Java ScalpelFrameLayout怎么用?Java ScalpelFrameLayout使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ScalpelFrameLayout类属于com.jakewharton.scalpel包,在下文中一共展示了ScalpelFrameLayout类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setContentView
import com.jakewharton.scalpel.ScalpelFrameLayout; //导入依赖的package包/类
@Override
public void setContentView(@LayoutRes int layoutResID) {
mScalpelLayout = new ScalpelFrameLayout(this);
mScalpelLayout.setLayerInteractionEnabled(false);
mScalpelLayout.setDrawViews(true);
mScalpelLayout.setDrawIds(true);
mScalpelLayout.setChromeColor(ContextCompat.getColor(this, R.color.white$1));
mScalpelLayout.setChromeShadowColor(ContextCompat.getColor(this, R.color.red$1));
LayoutInflater.from(this).inflate(layoutResID, mScalpelLayout, true);
final ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
super.setContentView(mScalpelLayout, lp);
}
示例2: testWrapsView
import com.jakewharton.scalpel.ScalpelFrameLayout; //导入依赖的package包/类
@Test
public void testWrapsView() throws Exception {
Context context = getContext();
RelativeLayout root = new RelativeLayout(context);
LinearLayout linearLayout = new LinearLayout(context);
root.addView(linearLayout);
for (int i = 0; i < 3; i++) {
linearLayout.addView(new TextView(context));
}
ScalpelFrameLayout scalpel = ScalpelUtil.wrapWithScalpel(linearLayout);
assertThat(linearLayout).hasParent(scalpel);
assertThat(scalpel).hasParent(root);
}
示例3: testKeepsLayoutParams
import com.jakewharton.scalpel.ScalpelFrameLayout; //导入依赖的package包/类
@Test
public void testKeepsLayoutParams() throws Exception {
Context context = getContext();
RelativeLayout root = new RelativeLayout(context);
FrameLayout frameLayout = new FrameLayout(context);
root.addView(frameLayout);
ViewGroup.LayoutParams layoutParams = frameLayout.getLayoutParams();
assertNotNull(layoutParams);
ScalpelFrameLayout scalpel = ScalpelUtil.wrapWithScalpel(frameLayout);
// Scalpel should adapt the previous layout params
Assert.assertThat(scalpel.getLayoutParams(), equalTo(layoutParams));
dispatchThreeDowns(scalpel);
// parameters should be same
Assert.assertThat(scalpel.getLayoutParams(), equalTo(layoutParams));
}
示例4: testWrapsActivity
import com.jakewharton.scalpel.ScalpelFrameLayout; //导入依赖的package包/类
@Test
public void testWrapsActivity() throws Exception {
Activity activity = Robolectric.buildActivity(Activity.class).create().get();
ScalpelFrameLayout scalpel = ScalpelUtil.wrapWithScalpel(activity);
@IdRes
int id = 0x11;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
id = View.generateViewId();
}
scalpel.setId(id);
View viewFromActivity = activity.findViewById(id);
Assert.assertThat(viewFromActivity, instanceOf(ScalpelFrameLayout.class));
Assert.assertThat((ScalpelFrameLayout) viewFromActivity, equalTo(scalpel));
}
示例5: testUnwrapsActivityOnThreeTaps
import com.jakewharton.scalpel.ScalpelFrameLayout; //导入依赖的package包/类
@Test
public void testUnwrapsActivityOnThreeTaps() throws Exception {
Activity activity = Robolectric.buildActivity(Activity.class).create().get();
ScalpelFrameLayout scalpel = ScalpelUtil.wrapWithScalpel(activity);
@IdRes
int id = 0x11;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
id = View.generateViewId();
}
scalpel.setId(id);
dispatchThreeDowns(scalpel);
View nextViewFromActivity = activity.findViewById(id);
Assert.assertThat(nextViewFromActivity, is(CoreMatchers.<View>nullValue()));
}
示例6: attach
import com.jakewharton.scalpel.ScalpelFrameLayout; //导入依赖的package包/类
public void attach(Activity activity, ViewGroup content){
scalpelFrameLayout = new ScalpelFrameLayout(activity);
ViewGroup parent = (ViewGroup) content.getParent();
parent.removeView(content);
parent.addView(scalpelFrameLayout,0);
scalpelFrameLayout.addView(content);
boolean scalpel = scalpelEnabled.get();
scalpelFrameLayout.setLayerInteractionEnabled(scalpel);
uiScalpelElement.setChecked(scalpel);
uiScalpelWireframeElement.setEnabled(scalpel);
boolean wireframe = scalpelWireframeEnabled.get();
scalpelFrameLayout.setDrawViews(!wireframe);
uiScalpelWireframeElement.setChecked(wireframe);
}
示例7: wrapWithScalpel
import com.jakewharton.scalpel.ScalpelFrameLayout; //导入依赖的package包/类
/**
* Wraps activity content with new {@link ScalpelFrameLayout instance}
* and turns on all of its features.
* <p/>
* You can unwrap the Activity with three fast clicks on screen.
*
* @param activity Activity to wrap content of.
* @return New created Scalpel frame layout wrapping the activity content.
*/
public static ScalpelFrameLayout wrapWithScalpel(Activity activity) {
if (activity == null) {
throw new IllegalArgumentException("Parameter activity cannot be null");
}
View view = (View) activity.findViewById(android.R.id.content).getParent();
return wrapWithScalpelInternal(view);
}
示例8: createScalpelFrameLayout
import com.jakewharton.scalpel.ScalpelFrameLayout; //导入依赖的package包/类
private static ScalpelFrameLayout createScalpelFrameLayout(Context context) {
if (context == null) {
throw new IllegalArgumentException("Parameter context cannot be null");
}
ScalpelFrameLayout scalpelFrameLayout = new ScalpelFrameLayout(context);
scalpelFrameLayout.setLayerInteractionEnabled(true);
scalpelFrameLayout.setDrawViews(true);
scalpelFrameLayout.setDrawIds(true);
return scalpelFrameLayout;
}
示例9: onTouch
import com.jakewharton.scalpel.ScalpelFrameLayout; //导入依赖的package包/类
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
long diff = getNextDiff();
if (diff < THREE_CLICKS_THRESHOLD) {
unwrapView((ScalpelFrameLayout) v);
return true;
}
}
return false;
}
示例10: testUnwrapsViewOnThreeTaps
import com.jakewharton.scalpel.ScalpelFrameLayout; //导入依赖的package包/类
@Test
public void testUnwrapsViewOnThreeTaps() throws Exception {
Context context = getContext();
RelativeLayout root = new RelativeLayout(context);
LinearLayout linearLayout = new LinearLayout(context);
root.addView(linearLayout);
ScalpelFrameLayout scalpel = ScalpelUtil.wrapWithScalpel(linearLayout);
dispatchThreeDowns(scalpel);
assertThat(linearLayout).hasParent(root);
assertThat(scalpel).hasParent(null);
}
示例11: testWrapViewOnNullParent
import com.jakewharton.scalpel.ScalpelFrameLayout; //导入依赖的package包/类
@Test
public void testWrapViewOnNullParent() throws Exception {
TextView textView = new TextView(getContext());
ScalpelFrameLayout scalpel = ScalpelUtil.wrapWithScalpel(textView);
assertThat(textView).hasParent(scalpel);
}
示例12: dispatchThreeDowns
import com.jakewharton.scalpel.ScalpelFrameLayout; //导入依赖的package包/类
private void dispatchThreeDowns(ScalpelFrameLayout scalpel) {
long millis = SystemClock.uptimeMillis();
MotionEvent downEvent = obtain(millis, millis, ACTION_DOWN, 0, 0, 0, 0, 0, 0, 0, 0, 0);
for (int i = 0; i < 3; i++) {
scalpel.dispatchTouchEvent(downEvent);
}
}
示例13: wrapItemWithScalpel
import com.jakewharton.scalpel.ScalpelFrameLayout; //导入依赖的package包/类
@OnClick(R.id.item_container) void wrapItemWithScalpel(View view){
ScalpelFrameLayout scalpel = ScalpelUtil.wrapWithScalpel(view);
scalpel.setId(R.id.scalpel_layout);
}
示例14: wrapWithScalpelInternal
import com.jakewharton.scalpel.ScalpelFrameLayout; //导入依赖的package包/类
private static ScalpelFrameLayout wrapWithScalpelInternal(View view) {
ScalpelFrameLayout scalpelFrameLayout = createScalpelFrameLayout(view.getContext());
wrapView(view, scalpelFrameLayout);
view.setLayoutParams(new ScalpelFrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
scalpelFrameLayout.setOnTouchListener(new UnwrapListener());
return scalpelFrameLayout;
}
示例15: testUnwrapViewOnNullParent
import com.jakewharton.scalpel.ScalpelFrameLayout; //导入依赖的package包/类
@Test
public void testUnwrapViewOnNullParent() throws Exception {
TextView textView = new TextView(getContext());
ScalpelFrameLayout scalpel = ScalpelUtil.wrapWithScalpel(textView);
dispatchThreeDowns(scalpel);
assertThat(textView).hasParent(null);
}