diff --git a/doric-android/app/src/main/java/pub/doric/demo/MainActivity.java b/doric-android/app/src/main/java/pub/doric/demo/MainActivity.java index f5882711..f0091cb5 100644 --- a/doric-android/app/src/main/java/pub/doric/demo/MainActivity.java +++ b/doric-android/app/src/main/java/pub/doric/demo/MainActivity.java @@ -134,12 +134,12 @@ public class MainActivity extends AppCompatActivity { } }); }else { - tv.setText(data[position - 2]); + tv.setText(data[position - 3]); tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(tv.getContext(), DoricDebugTimingActivity.class); - intent.putExtra("source", "assets://src/" + data[position - 2]); + intent.putExtra("source", "assets://src/" + data[position - 3]); //intent.putExtra("alias", data[position - 1].replace(".js", "")); intent.putExtra("alias", "__dev__"); tv.getContext().startActivity(intent); diff --git a/doric-android/doric/src/main/java/pub/doric/shader/slider/SliderNode.java b/doric-android/doric/src/main/java/pub/doric/shader/slider/SliderNode.java index af86c619..135124bb 100644 --- a/doric-android/doric/src/main/java/pub/doric/shader/slider/SliderNode.java +++ b/doric-android/doric/src/main/java/pub/doric/shader/slider/SliderNode.java @@ -40,7 +40,6 @@ import pub.doric.shader.ViewNode; * @Description: pub.doric.shader.slider * @Author: pengfei.zhou * @CreateDate: 2019-11-19 - * @UpdateDate: 2020-04-09 */ @DoricPlugin(name = "Slider") public class SliderNode extends SuperNode { @@ -51,6 +50,9 @@ public class SliderNode extends SuperNode { private boolean loop = false; private String renderPageFuncId; private boolean scrollable = true; + private String slideStyle = null; + private static final float MIN_SCALE = 0.5f; + private static final float MAX_SCALE = 1; public SliderNode(DoricContext doricContext) { super(doricContext); @@ -123,13 +125,29 @@ public class SliderNode extends SuperNode { @Override public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); + if ("zoomOut".equals(slideStyle)) { + final int childCount = recyclerView.getChildCount(); + for (int i = 0; i < childCount; i++) { + View child = recyclerView.getChildAt(i); + RecyclerView.LayoutParams lp = (RecyclerView.LayoutParams) child.getLayoutParams(); + if (child.getWidth() == 0) { + return; + } + float centerX = (child.getLeft() + child.getRight()) / 2.f; + float percent = 1 - Math.abs(recyclerView.getWidth() / 2f - centerX) / recyclerView.getWidth() / 2f; + float scaleFactor = MIN_SCALE + Math.abs(percent) * (MAX_SCALE - MIN_SCALE); + child.setLayoutParams(lp); + child.setScaleY(scaleFactor); + child.setScaleX(scaleFactor); + } + } } }); return recyclerView; } @Override - public ViewNode getSubNodeById(String id) { + public ViewNode getSubNodeById(String id) { RecyclerView.LayoutManager manager = mView.getLayoutManager(); if (manager == null) { return null; @@ -150,7 +168,7 @@ public class SliderNode extends SuperNode { @Override protected void blendSubNode(JSObject subProperties) { String viewId = subProperties.getProperty("id").asString().value(); - ViewNode node = getSubNodeById(viewId); + ViewNode node = getSubNodeById(viewId); if (node != null) { node.blend(subProperties.getProperty("props").asObject()); } else { @@ -225,6 +243,11 @@ public class SliderNode extends SuperNode { case "loop": this.loop = prop.asBoolean().value(); break; + case "slideStyle": + if (prop.isString()) { + this.slideStyle = prop.asString().value(); + } + break; default: super.blend(view, name, prop); break;