extends Serializable {
10 |
11 | void displayImage(Context context, Object path, T imageView);
12 |
13 | T createImageView(Context context);
14 | }
15 |
--------------------------------------------------------------------------------
/banner/src/main/java/com/youth/banner/transformer/AccordionTransformer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.youth.banner.transformer;
18 |
19 | import android.view.View;
20 |
21 | public class AccordionTransformer extends ABaseTransformer {
22 |
23 | @Override
24 | protected void onTransform(View view, float position) {
25 | view.setPivotX(position < 0 ? 0 : view.getWidth());
26 | view.setScaleX(position < 0 ? 1f + position : 1f - position);
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/banner/src/main/java/com/youth/banner/transformer/BackgroundToForegroundTransformer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.youth.banner.transformer;
18 |
19 | import android.view.View;
20 |
21 | public class BackgroundToForegroundTransformer extends ABaseTransformer {
22 |
23 | @Override
24 | protected void onTransform(View view, float position) {
25 | final float height = view.getHeight();
26 | final float width = view.getWidth();
27 | final float scale = min(position < 0 ? 1f : Math.abs(1f - position), 0.5f);
28 |
29 | view.setScaleX(scale);
30 | view.setScaleY(scale);
31 | view.setPivotX(width * 0.5f);
32 | view.setPivotY(height * 0.5f);
33 | view.setTranslationX(position < 0 ? width * position : -width * position * 0.25f);
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/banner/src/main/java/com/youth/banner/transformer/CubeInTransformer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.youth.banner.transformer;
18 |
19 | import android.view.View;
20 |
21 | public class CubeInTransformer extends ABaseTransformer {
22 |
23 | @Override
24 | protected void onTransform(View view, float position) {
25 | // Rotate the fragment on the left or right edge
26 | view.setPivotX(position > 0 ? 0 : view.getWidth());
27 | view.setPivotY(0);
28 | view.setRotationY(-90f * position);
29 | }
30 |
31 | @Override
32 | public boolean isPagingEnabled() {
33 | return true;
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/banner/src/main/java/com/youth/banner/transformer/CubeOutTransformer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.youth.banner.transformer;
18 |
19 | import android.view.View;
20 |
21 | public class CubeOutTransformer extends ABaseTransformer {
22 |
23 | @Override
24 | protected void onTransform(View view, float position) {
25 | view.setPivotX(position < 0f ? view.getWidth() : 0f);
26 | view.setPivotY(view.getHeight() * 0.5f);
27 | view.setRotationY(90f * position);
28 | }
29 |
30 | @Override
31 | public boolean isPagingEnabled() {
32 | return true;
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/banner/src/main/java/com/youth/banner/transformer/DefaultTransformer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.youth.banner.transformer;
18 |
19 | import android.view.View;
20 |
21 | public class DefaultTransformer extends ABaseTransformer {
22 |
23 | @Override
24 | protected void onTransform(View view, float position) {
25 | }
26 |
27 | @Override
28 | public boolean isPagingEnabled() {
29 | return true;
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/banner/src/main/java/com/youth/banner/transformer/DepthPageTransformer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.youth.banner.transformer;
18 |
19 | import android.view.View;
20 |
21 | public class DepthPageTransformer extends ABaseTransformer {
22 |
23 | private static final float MIN_SCALE = 0.75f;
24 |
25 | @Override
26 | protected void onTransform(View view, float position) {
27 | if (position <= 0f) {
28 | view.setTranslationX(0f);
29 | view.setScaleX(1f);
30 | view.setScaleY(1f);
31 | } else if (position <= 1f) {
32 | final float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position));
33 | view.setAlpha(1 - position);
34 | view.setPivotY(0.5f * view.getHeight());
35 | view.setTranslationX(view.getWidth() * -position);
36 | view.setScaleX(scaleFactor);
37 | view.setScaleY(scaleFactor);
38 | }
39 | }
40 |
41 | @Override
42 | protected boolean isPagingEnabled() {
43 | return true;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/banner/src/main/java/com/youth/banner/transformer/FlipHorizontalTransformer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.youth.banner.transformer;
18 |
19 | import android.view.View;
20 |
21 | public class FlipHorizontalTransformer extends ABaseTransformer {
22 |
23 | @Override
24 | protected void onTransform(View view, float position) {
25 | final float rotation = 180f * position;
26 |
27 | view.setAlpha(rotation > 90f || rotation < -90f ? 0 : 1);
28 | view.setPivotX(view.getWidth() * 0.5f);
29 | view.setPivotY(view.getHeight() * 0.5f);
30 | view.setRotationY(rotation);
31 | }
32 |
33 | @Override
34 | protected void onPostTransform(View page, float position) {
35 | super.onPostTransform(page, position);
36 |
37 | //resolve problem: new page can't handle click event!
38 | if (position > -0.5f && position < 0.5f) {
39 | page.setVisibility(View.VISIBLE);
40 | } else {
41 | page.setVisibility(View.INVISIBLE);
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/banner/src/main/java/com/youth/banner/transformer/FlipVerticalTransformer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.youth.banner.transformer;
18 |
19 | import android.view.View;
20 |
21 | public class FlipVerticalTransformer extends ABaseTransformer {
22 |
23 | @Override
24 | protected void onTransform(View view, float position) {
25 | final float rotation = -180f * position;
26 |
27 | view.setAlpha(rotation > 90f || rotation < -90f ? 0f : 1f);
28 | view.setPivotX(view.getWidth() * 0.5f);
29 | view.setPivotY(view.getHeight() * 0.5f);
30 | view.setRotationX(rotation);
31 | }
32 |
33 | @Override
34 | protected void onPostTransform(View page, float position) {
35 | super.onPostTransform(page, position);
36 |
37 | if (position > -0.5f && position < 0.5f) {
38 | page.setVisibility(View.VISIBLE);
39 | } else {
40 | page.setVisibility(View.INVISIBLE);
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/banner/src/main/java/com/youth/banner/transformer/ForegroundToBackgroundTransformer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.youth.banner.transformer;
18 |
19 | import android.view.View;
20 |
21 | public class ForegroundToBackgroundTransformer extends ABaseTransformer {
22 |
23 | @Override
24 | protected void onTransform(View view, float position) {
25 | final float height = view.getHeight();
26 | final float width = view.getWidth();
27 | final float scale = min(position > 0 ? 1f : Math.abs(1f + position), 0.5f);
28 |
29 | view.setScaleX(scale);
30 | view.setScaleY(scale);
31 | view.setPivotX(width * 0.5f);
32 | view.setPivotY(height * 0.5f);
33 | view.setTranslationX(position > 0 ? width * position : -width * position * 0.25f);
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/banner/src/main/java/com/youth/banner/transformer/RotateDownTransformer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.youth.banner.transformer;
18 |
19 | import android.view.View;
20 |
21 | public class RotateDownTransformer extends ABaseTransformer {
22 |
23 | private static final float ROT_MOD = -15f;
24 |
25 | @Override
26 | protected void onTransform(View view, float position) {
27 | final float width = view.getWidth();
28 | final float height = view.getHeight();
29 | final float rotation = ROT_MOD * position * -1.25f;
30 |
31 | view.setPivotX(width * 0.5f);
32 | view.setPivotY(height);
33 | view.setRotation(rotation);
34 | }
35 |
36 | @Override
37 | protected boolean isPagingEnabled() {
38 | return true;
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/banner/src/main/java/com/youth/banner/transformer/RotateUpTransformer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.youth.banner.transformer;
18 |
19 | import android.view.View;
20 |
21 | public class RotateUpTransformer extends ABaseTransformer {
22 |
23 | private static final float ROT_MOD = -15f;
24 |
25 | @Override
26 | protected void onTransform(View view, float position) {
27 | final float width = view.getWidth();
28 | final float rotation = ROT_MOD * position;
29 |
30 | view.setPivotX(width * 0.5f);
31 | view.setPivotY(0f);
32 | view.setTranslationX(0f);
33 | view.setRotation(rotation);
34 | }
35 |
36 | @Override
37 | protected boolean isPagingEnabled() {
38 | return true;
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/banner/src/main/java/com/youth/banner/transformer/ScaleInOutTransformer.java:
--------------------------------------------------------------------------------
1 | package com.youth.banner.transformer;
2 |
3 | import android.view.View;
4 |
5 | public class ScaleInOutTransformer extends ABaseTransformer {
6 |
7 | @Override
8 | protected void onTransform(View view, float position) {
9 | view.setPivotX(position < 0 ? 0 : view.getWidth());
10 | view.setPivotY(view.getHeight() / 2f);
11 | float scale = position < 0 ? 1f + position : 1f - position;
12 | view.setScaleX(scale);
13 | view.setScaleY(scale);
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/banner/src/main/java/com/youth/banner/transformer/StackTransformer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.youth.banner.transformer;
18 |
19 | import android.view.View;
20 |
21 | public class StackTransformer extends ABaseTransformer {
22 |
23 | @Override
24 | protected void onTransform(View view, float position) {
25 | view.setTranslationX(position < 0 ? 0f : -view.getWidth() * position);
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/banner/src/main/java/com/youth/banner/transformer/TabletTransformer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.youth.banner.transformer;
18 |
19 | import android.graphics.Camera;
20 | import android.graphics.Matrix;
21 | import android.view.View;
22 |
23 | public class TabletTransformer extends ABaseTransformer {
24 |
25 | private static final Matrix OFFSET_MATRIX = new Matrix();
26 | private static final Camera OFFSET_CAMERA = new Camera();
27 | private static final float[] OFFSET_TEMP_FLOAT = new float[2];
28 |
29 | @Override
30 | protected void onTransform(View view, float position) {
31 | final float rotation = (position < 0 ? 30f : -30f) * Math.abs(position);
32 |
33 | view.setTranslationX(getOffsetXForRotation(rotation, view.getWidth(), view.getHeight()));
34 | view.setPivotX(view.getWidth() * 0.5f);
35 | view.setPivotY(0);
36 | view.setRotationY(rotation);
37 | }
38 |
39 | protected static final float getOffsetXForRotation(float degrees, int width, int height) {
40 | OFFSET_MATRIX.reset();
41 | OFFSET_CAMERA.save();
42 | OFFSET_CAMERA.rotateY(Math.abs(degrees));
43 | OFFSET_CAMERA.getMatrix(OFFSET_MATRIX);
44 | OFFSET_CAMERA.restore();
45 |
46 | OFFSET_MATRIX.preTranslate(-width * 0.5f, -height * 0.5f);
47 | OFFSET_MATRIX.postTranslate(width * 0.5f, height * 0.5f);
48 | OFFSET_TEMP_FLOAT[0] = width;
49 | OFFSET_TEMP_FLOAT[1] = height;
50 | OFFSET_MATRIX.mapPoints(OFFSET_TEMP_FLOAT);
51 | return (width - OFFSET_TEMP_FLOAT[0]) * (degrees > 0.0f ? 1.0f : -1.0f);
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/banner/src/main/java/com/youth/banner/transformer/ZoomInTransformer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.youth.banner.transformer;
18 |
19 | import android.view.View;
20 |
21 | public class ZoomInTransformer extends ABaseTransformer {
22 |
23 | @Override
24 | protected void onTransform(View view, float position) {
25 | final float scale = position < 0 ? position + 1f : Math.abs(1f - position);
26 | view.setScaleX(scale);
27 | view.setScaleY(scale);
28 | view.setPivotX(view.getWidth() * 0.5f);
29 | view.setPivotY(view.getHeight() * 0.5f);
30 | view.setAlpha(position < -1f || position > 1f ? 0f : 1f - (scale - 1f));
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/banner/src/main/java/com/youth/banner/transformer/ZoomOutSlideTransformer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.youth.banner.transformer;
18 |
19 | import android.view.View;
20 |
21 | public class ZoomOutSlideTransformer extends ABaseTransformer {
22 |
23 | private static final float MIN_SCALE = 0.85f;
24 | private static final float MIN_ALPHA = 0.5f;
25 |
26 | @Override
27 | protected void onTransform(View view, float position) {
28 | if (position >= -1 || position <= 1) {
29 | // Modify the default slide transition to shrink the page as well
30 | final float height = view.getHeight();
31 | final float width = view.getWidth();
32 | final float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position));
33 | final float vertMargin = height * (1 - scaleFactor) / 2;
34 | final float horzMargin = width * (1 - scaleFactor) / 2;
35 |
36 | // Center vertically
37 | view.setPivotY(0.5f * height);
38 | view.setPivotX(0.5f * width);
39 |
40 | if (position < 0) {
41 | view.setTranslationX(horzMargin - vertMargin / 2);
42 | } else {
43 | view.setTranslationX(-horzMargin + vertMargin / 2);
44 | }
45 |
46 | // Scale the page down (between MIN_SCALE and 1)
47 | view.setScaleX(scaleFactor);
48 | view.setScaleY(scaleFactor);
49 |
50 | // Fade the page relative to its size.
51 | view.setAlpha(MIN_ALPHA + (scaleFactor - MIN_SCALE) / (1 - MIN_SCALE) * (1 - MIN_ALPHA));
52 | }
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/banner/src/main/java/com/youth/banner/transformer/ZoomOutTranformer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 Toxic Bakery
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.youth.banner.transformer;
18 |
19 | import android.view.View;
20 |
21 | public class ZoomOutTranformer extends ABaseTransformer {
22 |
23 | @Override
24 | protected void onTransform(View view, float position) {
25 | final float scale = 1f + Math.abs(position);
26 | view.setScaleX(scale);
27 | view.setScaleY(scale);
28 | view.setPivotX(view.getWidth() * 0.5f);
29 | view.setPivotY(view.getHeight() * 0.5f);
30 | view.setAlpha(position < -1f || position > 1f ? 0f : 1f - (scale - 1f));
31 | if(position == -1){
32 | view.setTranslationX(view.getWidth() * -1);
33 | }
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/banner/src/main/java/com/youth/banner/view/BannerViewPager.java:
--------------------------------------------------------------------------------
1 | package com.youth.banner.view;
2 |
3 | import android.content.Context;
4 | import android.support.v4.view.ViewPager;
5 | import android.util.AttributeSet;
6 | import android.view.MotionEvent;
7 |
8 |
9 | public class BannerViewPager extends ViewPager {
10 | private boolean scrollable = true;
11 |
12 | public BannerViewPager(Context context) {
13 | super(context);
14 | }
15 |
16 | public BannerViewPager(Context context, AttributeSet attrs) {
17 | super(context, attrs);
18 | setClipChildren(false);
19 | }
20 |
21 | @Override
22 | public boolean onTouchEvent(MotionEvent ev) {
23 | if(this.scrollable) {
24 | if (getCurrentItem() == 0 && getChildCount() == 0) {
25 | return false;
26 | }
27 | return super.onTouchEvent(ev);
28 | } else {
29 | return false;
30 | }
31 | }
32 |
33 | @Override
34 | public boolean onInterceptTouchEvent(MotionEvent ev) {
35 | if(this.scrollable) {
36 | if (getCurrentItem() == 0 && getChildCount() == 0) {
37 | return false;
38 | }
39 | return super.onInterceptTouchEvent(ev);
40 | } else {
41 | return false;
42 | }
43 | }
44 |
45 | public void setScrollable(boolean scrollable) {
46 | this.scrollable = scrollable;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/banner/src/main/res/animator/scale_with_alpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
11 |
16 |
--------------------------------------------------------------------------------
/banner/src/main/res/drawable/black_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
--------------------------------------------------------------------------------
/banner/src/main/res/drawable/gray_radius.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
--------------------------------------------------------------------------------
/banner/src/main/res/drawable/no_banner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xujiaji/WanAndroid/dd3cebc670a769e73dcf9a163100358e24f3d211/banner/src/main/res/drawable/no_banner.png
--------------------------------------------------------------------------------
/banner/src/main/res/drawable/white_radius.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/banner/src/main/res/values/attr.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/banner/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xujiaji/WanAndroid/dd3cebc670a769e73dcf9a163100358e24f3d211/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Oct 18 14:59:29 CST 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
7 |
--------------------------------------------------------------------------------
/json/plugin_list.json:
--------------------------------------------------------------------------------
1 | {
2 | "errorCode": 0,
3 | "errorMsg": "",
4 | "data": [
5 | {
6 | "thumb": "https://raw.githubusercontent.com/xujiaji/xujiaji.github.io/pictures/wanandroid/plugin-thumb/SolarProgresView.gif",
7 | "name":"SolarProgresView",
8 | "description":"类似于太阳花形状的自定义进度条,主要根据光线传感器展示光线强度",
9 | "pkg":"com.mqt.solarprogressview",
10 | "start_class":"com.mqt.solarprogressview.SampleActy",
11 | "version_code":1,
12 | "url":"https://github.com/miqt/SolarProgressView"
13 | },
14 | {
15 | "thumb": "https://raw.githubusercontent.com/xujiaji/xujiaji.github.io/pictures/wanandroid/plugin-thumb/RippleCheckBox.png",
16 | "name": "RippleCheckBox",
17 | "description": "简洁,舒服,波纹动画,勾选动画,高度可控的波纹CheckBox",
18 | "pkg": "com.xujiaji.ripplecheckbox",
19 | "start_class": "com.xujiaji.ripplecheckbox.MainActivity",
20 | "version_code": 2,
21 | "url": "https://github.com/xujiaji/RippleCheckBox"
22 | },
23 | {
24 | "thumb": "https://raw.githubusercontent.com/xujiaji/xujiaji.github.io/pictures/wanandroid/plugin-thumb/stepview.png",
25 | "name": "自定义签到的步骤View",
26 | "description": "以七天为周天,执行当天签到需要一个动画效果;签到前灰色,签到后变为绿色;每天加的分数不一定,第三天和第七天加的比较多,分数签到完成为橙色,有up标签。",
27 | "pkg": "com.sorgs.stepview",
28 | "start_class": "com.sorgs.stepview.ui.activity.MainActivity",
29 | "version_code": 1,
30 | "url": "https://github.com/sorgs/StepView"
31 | },
32 | {
33 | "thumb": "https://raw.githubusercontent.com/xujiaji/xujiaji.github.io/pictures/wanandroid/plugin-thumb/happy-bubble.png",
34 | "name": "HappyBubble",
35 | "description": "BubbleLayout随意变化的气泡布局,BubbleDialog根据点击View的位置定位它的位置,BubbleDialog可定制方向等!",
36 | "pkg": "com.xujiaji.happybubbletest",
37 | "start_class": "com.xujiaji.happybubbletest.MainActivity",
38 | "version_code": 2,
39 | "url": "https://github.com/xujiaji/HappyBubble"
40 | }
41 | ]
42 | }
43 |
--------------------------------------------------------------------------------
/json/version.json:
--------------------------------------------------------------------------------
1 | {
2 | "errorCode":0,
3 | "errorMsg":"",
4 | "data":{
5 | "version_name":"1.0.5",
6 | "version_code":6,
7 | "update_info":"1.删除首页右下角清单入口图标;\n2.清单将作为单独的项目运作;",
8 | "file_size":"9.05M",
9 | "constraint":false,
10 | "apk_url":"https://github.com/xujiaji/WanAndroid/releases/download/v1.0.5/app-release.apk"
11 | }
12 | }
--------------------------------------------------------------------------------
/pybridge/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/pybridge/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion rootProject.compileSdk
5 |
6 | defaultConfig {
7 | minSdkVersion rootProject.minSdk
8 | targetSdkVersion rootProject.targetSdk
9 | versionCode 1
10 | versionName "1.0"
11 | }
12 | buildTypes {
13 | release {
14 | minifyEnabled false
15 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
16 | }
17 | }
18 | sourceSets.main {
19 | jni.srcDirs = []
20 | jniLibs.srcDir 'src/main/libs'
21 | }
22 | }
23 |
24 | dependencies {
25 | api fileTree(dir: 'libs', include: ['*.jar'])
26 | implementation "com.android.support:appcompat-v7:$support"
27 | }
28 |
--------------------------------------------------------------------------------
/pybridge/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/jventura/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/pybridge/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
--------------------------------------------------------------------------------
/pybridge/src/main/assets/python/bootstrap.py:
--------------------------------------------------------------------------------
1 | """
2 | This file is executed when the Python interpreter is started.
3 | Use this file to configure all your necessary python code.
4 |
5 | """
6 |
7 | import json
8 | import html_to_json
9 | import parser_links
10 |
11 |
12 | def router(args):
13 | """
14 | Defines the router function that routes by function name.
15 |
16 | :param args: JSON arguments
17 | :return: JSON response
18 | """
19 | values = json.loads(args)
20 |
21 | try:
22 | function = routes[values.get('function')]
23 |
24 | status = 'ok'
25 | res = function(values)
26 | except KeyError:
27 | status = 'fail'
28 | res = None
29 |
30 | return json.dumps({
31 | 'status': status,
32 | 'result': res,
33 | })
34 |
35 |
36 | def greet(args):
37 | """Simple function that greets someone."""
38 | return 'Hello %s' % args['name']
39 |
40 |
41 | def add(args):
42 | """Simple function to add two numbers."""
43 | return args['a'] + args['b']
44 |
45 |
46 | def mul(args):
47 | """Simple function to multiply two numbers."""
48 | return args['a'] * args['b']
49 |
50 | def parserAPISPage(args):
51 | return html_to_json.parserAPISPage(args['data'])
52 |
53 | def parserLinks(args):
54 | return parser_links.parserFriendLinks(args['data'])
55 |
56 | routes = {
57 | 'greet': greet,
58 | 'add': add,
59 | 'mul': mul,
60 | 'parserAPISPage': parserAPISPage,
61 | 'parserLinks': parserLinks
62 | }
63 |
--------------------------------------------------------------------------------
/pybridge/src/main/assets/python/html_test.py:
--------------------------------------------------------------------------------
1 | from html.parser import HTMLParser
2 |
3 |
4 | class MyHTMLParser(HTMLParser):
5 |
6 | def __init__(self):
7 | HTMLParser.__init__(self)
8 | self.resultValue = []
9 |
10 | def handle_starttag(self, tag, attrs):
11 | self.resultValue.append(tag)
12 | print('<%s>' % tag)
13 | print('attr:', attrs)
14 | for attr in attrs:
15 | if attr == ('class', 'list_navi listNavi'):
16 | print(True)
17 | print(attr)
18 |
19 | def handle_endtag(self, tag):
20 | print('%s>' % tag)
21 |
22 | def handle_startendtag(self, tag, attrs):
23 | print('<%s/>' % tag)
24 |
25 | def handle_data(self, data):
26 | print(data)
27 |
28 | def handle_comment(self, data):
29 | print('')
30 |
31 | def handle_entityref(self, name):
32 | print('&%s;' % name)
33 |
34 | def handle_charref(self, name):
35 | print('%s;' % name)
36 |
37 | def runParser():
38 | parser = MyHTMLParser()
39 | parser.feed('''
40 |
41 |
42 |
43 |
44 | Some html HTML tutorial...
END
45 | ''')
46 | return parser.resultValue
47 |
48 |
--------------------------------------------------------------------------------
/pybridge/src/main/assets/python/stdlib.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xujiaji/WanAndroid/dd3cebc670a769e73dcf9a163100358e24f3d211/pybridge/src/main/assets/python/stdlib.zip
--------------------------------------------------------------------------------
/pybridge/src/main/java/com/jventura/pybridge/PyBridge.java:
--------------------------------------------------------------------------------
1 | package com.jventura.pybridge;
2 |
3 | import org.json.JSONObject;
4 | import org.json.JSONException;
5 |
6 |
7 | public class PyBridge {
8 |
9 | /**
10 | * Initializes the Python interpreter.
11 | *
12 | * @param datapath the location of the extracted python files
13 | * @return error code
14 | */
15 | public static native int start(String datapath);
16 |
17 | /**
18 | * Stops the Python interpreter.
19 | *
20 | * @return error code
21 | */
22 | public static native int stop();
23 |
24 | /**
25 | * Sends a string payload to the Python interpreter.
26 | *
27 | * @param payload the payload string
28 | * @return a string with the result
29 | */
30 | public static native String call(String payload);
31 |
32 | /**
33 | * Sends a JSON payload to the Python interpreter.
34 | *
35 | * @param payload JSON payload
36 | * @return JSON response
37 | */
38 | public static JSONObject call(JSONObject payload) {
39 | String result = call(payload.toString());
40 | try {
41 | return new JSONObject(result);
42 | } catch (JSONException e) {
43 | e.printStackTrace();
44 | return null;
45 | }
46 | }
47 |
48 | // Load library
49 | static {
50 | System.loadLibrary("pybridge");
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/pybridge/src/main/java/com/jventura/pybridge/PyManager.java:
--------------------------------------------------------------------------------
1 | package com.jventura.pybridge;
2 |
3 | import android.content.Context;
4 | import android.widget.Toast;
5 |
6 | import org.json.JSONException;
7 | import org.json.JSONObject;
8 |
9 |
10 | public class PyManager {
11 |
12 | private static PyManager instance;
13 | private String pythonPath;
14 |
15 | private PyManager(Context context) {
16 | // Extract python files from assets
17 | AssetExtractor assetExtractor = new AssetExtractor(context);
18 | assetExtractor.removeAssets("python");
19 | assetExtractor.copyAssets("python");
20 | // Get the extracted assets directory
21 | pythonPath = assetExtractor.getAssetsDataDir() + "python";
22 | }
23 |
24 | public static PyManager getInstance(Context context) {
25 | if (instance == null) {
26 | synchronized (PyManager.class) {
27 | instance = new PyManager(context);
28 | }
29 | }
30 | return instance;
31 | }
32 |
33 | private String handle(String data, String funName) {
34 | // Start the Python interpreter
35 | PyBridge.start(pythonPath);
36 |
37 | // Call a Python function
38 | try {
39 | JSONObject json = new JSONObject();
40 | json.put("function", funName);
41 | json.put("data", data);
42 |
43 | JSONObject result = PyBridge.call(json);
44 | return result.getString("result");
45 |
46 | // TextView textView = (TextView) findViewById(R.id.textView);
47 | // textView.setText(answer);
48 |
49 | } catch (JSONException e) {
50 | e.printStackTrace();
51 | return "";
52 | } finally {
53 | // Stop the interpreter
54 | PyBridge.stop();
55 | }
56 | }
57 |
58 | public String parserOPENAPISHtml(String data) {
59 | return handle(data, "parserAPISPage");
60 | }
61 |
62 | public String parserFriendLinks(String data) {
63 | return handle(data, "parserLinks");
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/pybridge/src/main/jni/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH := $(call my-dir)
2 | CRYSTAX_PATH := D:\Android\crystax-ndk-10.3.2
3 |
4 |
5 | # Build libpybridge.so
6 |
7 | include $(CLEAR_VARS)
8 | LOCAL_MODULE := pybridge
9 | LOCAL_SRC_FILES := pybridge.c
10 | LOCAL_LDLIBS := -llog
11 | LOCAL_SHARED_LIBRARIES := python3.5m
12 | include $(BUILD_SHARED_LIBRARY)
13 |
14 |
15 | # Include libpython3.5m.so
16 |
17 | include $(CLEAR_VARS)
18 | LOCAL_MODULE := python3.5m
19 | LOCAL_SRC_FILES := $(CRYSTAX_PATH)/sources/python/3.5/libs/$(TARGET_ARCH_ABI)/libpython3.5m.so
20 | LOCAL_EXPORT_CFLAGS := -I $(CRYSTAX_PATH)/sources/python/3.5/include/python/
21 | include $(PREBUILT_SHARED_LIBRARY)
22 |
--------------------------------------------------------------------------------
/pybridge/src/main/jni/Application.mk:
--------------------------------------------------------------------------------
1 | APP_PLATFORM := android-19
2 | APP_ABI := armeabi-v7a x86
3 |
--------------------------------------------------------------------------------
/pybridge/src/main/libs/armeabi-v7a/libcrystax.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xujiaji/WanAndroid/dd3cebc670a769e73dcf9a163100358e24f3d211/pybridge/src/main/libs/armeabi-v7a/libcrystax.so
--------------------------------------------------------------------------------
/pybridge/src/main/libs/armeabi-v7a/libpybridge.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xujiaji/WanAndroid/dd3cebc670a769e73dcf9a163100358e24f3d211/pybridge/src/main/libs/armeabi-v7a/libpybridge.so
--------------------------------------------------------------------------------
/pybridge/src/main/libs/armeabi-v7a/libpython3.5m.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xujiaji/WanAndroid/dd3cebc670a769e73dcf9a163100358e24f3d211/pybridge/src/main/libs/armeabi-v7a/libpython3.5m.so
--------------------------------------------------------------------------------
/pybridge/src/main/libs/x86/libcrystax.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xujiaji/WanAndroid/dd3cebc670a769e73dcf9a163100358e24f3d211/pybridge/src/main/libs/x86/libcrystax.so
--------------------------------------------------------------------------------
/pybridge/src/main/libs/x86/libpybridge.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xujiaji/WanAndroid/dd3cebc670a769e73dcf9a163100358e24f3d211/pybridge/src/main/libs/x86/libpybridge.so
--------------------------------------------------------------------------------
/pybridge/src/main/libs/x86/libpython3.5m.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xujiaji/WanAndroid/dd3cebc670a769e73dcf9a163100358e24f3d211/pybridge/src/main/libs/x86/libpython3.5m.so
--------------------------------------------------------------------------------
/pybridge/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/pybridge/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/pybridge/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | PyApp
3 |
4 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ":banner", ":pybridge"
2 |
--------------------------------------------------------------------------------
/xu.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xujiaji/WanAndroid/dd3cebc670a769e73dcf9a163100358e24f3d211/xu.jks
--------------------------------------------------------------------------------