getBanner(@Query("plat") String platform, @Query("version") int version);
30 | }
31 |
--------------------------------------------------------------------------------
/module_library/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 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/chs/library/base/adapter/listener/OnItemClickListener.java:
--------------------------------------------------------------------------------
1 | package com.chs.library.base.adapter.listener;
2 |
3 | import android.view.View;
4 |
5 | import com.chs.library.base.adapter.BaseQuickAdapter;
6 |
7 |
8 | /**
9 | * Created by AllenCoder on 2016/8/03.
10 | *
11 | *
12 | * A convenience class to extend when you only want to OnItemClickListener for a subset
13 | * of all the SimpleClickListener. This implements all methods in the
14 | * {@link SimpleClickListener}
15 | */
16 | public abstract class OnItemClickListener extends SimpleClickListener {
17 | @Override
18 | public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
19 | onSimpleItemClick(adapter, view, position);
20 | }
21 |
22 | @Override
23 | public void onItemLongClick(BaseQuickAdapter adapter, View view, int position) {
24 |
25 | }
26 |
27 | @Override
28 | public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
29 |
30 | }
31 |
32 | @Override
33 | public void onItemChildLongClick(BaseQuickAdapter adapter, View view, int position) {
34 |
35 | }
36 |
37 | public abstract void onSimpleItemClick(BaseQuickAdapter adapter, View view, int position);
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/chs/moduledevelop/second/BookAdapter.java:
--------------------------------------------------------------------------------
1 | package com.chs.moduledevelop.second;
2 |
3 | import android.support.annotation.LayoutRes;
4 | import android.support.annotation.Nullable;
5 | import android.widget.ImageView;
6 |
7 | import com.chs.library.base.adapter.BaseQuickAdapter;
8 | import com.chs.library.base.adapter.BaseViewHolder;
9 | import com.chs.library.image.ImageLoader;
10 | import com.chs.moduledevelop.R;
11 |
12 | import java.util.List;
13 |
14 | /**
15 | * 作者:chs on 2017-08-11 15:16
16 | * 邮箱:657083984@qq.com
17 | */
18 |
19 | public class BookAdapter extends BaseQuickAdapter{
20 |
21 | public BookAdapter(@LayoutRes int layoutResId, @Nullable List data) {
22 | super(layoutResId, data);
23 | }
24 |
25 | @Override
26 | protected void convert(BaseViewHolder helper, BookEntity.BooksEntity item) {
27 | ImageLoader.loadImageView(mContext,item.getImages().getLarge(), (ImageView) helper.getView(R.id.iv_book_img));
28 | helper.setText(R.id.tv_author,item.getAuthor().size()>0?item.getAuthor().get(0):"暂无");
29 | helper.setText(R.id.tv_press,item.getPublisher());
30 | helper.setText(R.id.tv_date,item.getPubdate());
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_first_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
20 |
21 |
33 |
34 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/scwang/smartrefresh/layout/api/RefreshFooter.java:
--------------------------------------------------------------------------------
1 | package com.scwang.smartrefresh.layout.api;
2 |
3 | /**
4 | * 刷新底部
5 | * Created by SCWANG on 2017/5/26.
6 | */
7 |
8 | public interface RefreshFooter extends RefreshInternal {
9 | /**
10 | * 手指拖动下拉(会连续多次调用)
11 | * @param percent 下拉的百分比 值 = offset/footerHeight (0 - percent - (footerHeight+extendHeight) / footerHeight )
12 | * @param offset 下拉的像素偏移量 0 - offset - (footerHeight+extendHeight)
13 | * @param footerHeight Footer的高度
14 | * @param extendHeight Footer的扩展高度
15 | */
16 | void onPullingUp(float percent, int offset, int footerHeight, int extendHeight);
17 | /**
18 | * 手指释放之后的持续动画(会连续多次调用)
19 | * @param percent 下拉的百分比 值 = offset/footerHeight (0 - percent - (footerHeight+extendHeight) / footerHeight )
20 | * @param offset 下拉的像素偏移量 0 - offset - (footerHeight+extendHeight)
21 | * @param footerHeight Footer的高度
22 | * @param extendHeight Footer的扩展高度
23 | */
24 | void onPullReleasing(float percent, int offset, int footerHeight, int extendHeight);
25 |
26 | /**
27 | * 设置数据全部加载完成,将不能再次触发加载功能
28 | * @return true 支持全部加载完成的状态显示 false 不支持
29 | */
30 | boolean setLoadmoreFinished(boolean finished);
31 | }
32 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/chs/library/base/adapter/listener/OnItemChildClickListener.java:
--------------------------------------------------------------------------------
1 | package com.chs.library.base.adapter.listener;
2 |
3 | import android.view.View;
4 |
5 | import com.chs.library.base.adapter.BaseQuickAdapter;
6 |
7 |
8 | /**
9 | * Created by AllenCoder on 2016/8/03.
10 | * A convenience class to extend when you only want to OnItemChildClickListener for a subset
11 | * of all the SimpleClickListener. This implements all methods in the
12 | * {@link SimpleClickListener}
13 | **/
14 |
15 | public abstract class OnItemChildClickListener extends SimpleClickListener {
16 | @Override
17 | public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
18 |
19 | }
20 |
21 | @Override
22 | public void onItemLongClick(BaseQuickAdapter adapter, View view, int position) {
23 |
24 | }
25 |
26 | @Override
27 | public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
28 | onSimpleItemChildClick(adapter, view, position);
29 | }
30 |
31 | @Override
32 | public void onItemChildLongClick(BaseQuickAdapter adapter, View view, int position) {
33 |
34 | }
35 |
36 | public abstract void onSimpleItemChildClick(BaseQuickAdapter adapter, View view, int position);
37 | }
38 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/scwang/smartrefresh/layout/constant/RefreshState.java:
--------------------------------------------------------------------------------
1 | package com.scwang.smartrefresh.layout.constant;
2 |
3 | public enum RefreshState {
4 | None,
5 | PullDownToRefresh, PullToUpLoad,
6 | PullDownCanceled, PullUpCanceled,
7 | ReleaseToRefresh, ReleaseToLoad,
8 | Refreshing, Loading,
9 | RefreshFinish, LoadFinish,;
10 |
11 | public boolean isAnimating() {
12 | return this == Refreshing ||
13 | this == Loading;
14 | }
15 |
16 | public boolean isDraging() {
17 | return ordinal() >= PullDownToRefresh.ordinal()
18 | && ordinal() <= ReleaseToLoad.ordinal()
19 | && this != PullDownCanceled
20 | && this != PullUpCanceled;
21 | }
22 |
23 | public boolean isDragingHeader() {
24 | return this == PullDownToRefresh ||
25 | this == ReleaseToRefresh;
26 | }
27 |
28 | public boolean isDragingFooter() {
29 | return this == PullToUpLoad ||
30 | this == ReleaseToLoad;
31 | }
32 |
33 | public boolean isHeader() {
34 | return (ordinal() & 1) == 1;
35 | }
36 |
37 | public boolean isFooter() {
38 | return (ordinal() & 1) == 0 && ordinal() > 0;
39 | }
40 |
41 | }
--------------------------------------------------------------------------------
/module_library/src/main/java/com/youth/banner/BannerConfig.java:
--------------------------------------------------------------------------------
1 | package com.youth.banner;
2 |
3 |
4 | public class BannerConfig {
5 | /**
6 | * indicator style
7 | */
8 | public static final int NOT_INDICATOR = 0;
9 | public static final int CIRCLE_INDICATOR = 1;
10 | public static final int NUM_INDICATOR = 2;
11 | public static final int NUM_INDICATOR_TITLE = 3;
12 | public static final int CIRCLE_INDICATOR_TITLE = 4;
13 | public static final int CIRCLE_INDICATOR_TITLE_INSIDE = 5;
14 | /**
15 | * indicator gravity
16 | */
17 | public static final int LEFT = 5;
18 | public static final int CENTER = 6;
19 | public static final int RIGHT = 7;
20 |
21 | /**
22 | * banner
23 | */
24 | public static final int PADDING_SIZE = 5;
25 | public static final int TIME = 2000;
26 | public static final int DURATION = 800;
27 | public static final boolean IS_AUTO_PLAY = true;
28 | public static final boolean IS_SCROLL = true;
29 |
30 | /**
31 | * title style
32 | */
33 | public static final int TITLE_BACKGROUND = -1;
34 | public static final int TITLE_HEIGHT = -1;
35 | public static final int TITLE_TEXT_COLOR = -1;
36 | public static final int TITLE_TEXT_SIZE = -1;
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/module_library/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 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/chs/library/base/adapter/listener/OnItemChildLongClickListener.java:
--------------------------------------------------------------------------------
1 | package com.chs.library.base.adapter.listener;
2 |
3 | import android.view.View;
4 |
5 | import com.chs.library.base.adapter.BaseQuickAdapter;
6 |
7 |
8 | /**
9 | * Created by AllenCoder on 2016/8/03.
10 | * A convenience class to extend when you only want to OnItemChildLongClickListener for a subset
11 | * of all the SimpleClickListener. This implements all methods in the
12 | * {@link SimpleClickListener}
13 | **/
14 | public abstract class OnItemChildLongClickListener extends SimpleClickListener {
15 | @Override
16 | public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
17 |
18 | }
19 |
20 | @Override
21 | public void onItemLongClick(BaseQuickAdapter adapter, View view, int position) {
22 |
23 | }
24 |
25 | @Override
26 | public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
27 |
28 | }
29 |
30 | @Override
31 | public void onItemChildLongClick(BaseQuickAdapter adapter, View view, int position) {
32 | onSimpleItemChildLongClick(adapter, view, position);
33 | }
34 |
35 | public abstract void onSimpleItemChildLongClick(BaseQuickAdapter adapter, View view, int position);
36 | }
37 |
--------------------------------------------------------------------------------
/module_news/src/main/java/com/chs/news/net/NewsDataManager.java:
--------------------------------------------------------------------------------
1 | package com.chs.news.net;
2 |
3 | import com.chs.library.http.RetrofitManager;
4 | import com.chs.news.module.NewsListEntity;
5 |
6 | import io.reactivex.Observable;
7 | import io.reactivex.Observer;
8 | import io.reactivex.android.schedulers.AndroidSchedulers;
9 | import io.reactivex.schedulers.Schedulers;
10 |
11 | /**
12 | * 作者:chs on 2017-09-27 09:54
13 | * 邮箱:657083984@qq.com
14 | */
15 |
16 | public class NewsDataManager {
17 | public NewsDataManager() {
18 | String baseUrl = "https://c.m.163.com/";
19 | RetrofitManager.getInstance().initRetrofit(baseUrl);
20 | }
21 | public void getZhuHuList(Observer observer){
22 | /**
23 | * @return
24 | */
25 | Observable observable = RetrofitManager.getInstance().createReq(GetServiceData.class).getZhiHuList();
26 |
27 | toSubscribe(observable, observer);
28 | }
29 | private void toSubscribe(Observable o, Observer observer){
30 | o.subscribeOn(Schedulers.io())//指定Observable
31 | .unsubscribeOn(Schedulers.io())
32 | .observeOn(AndroidSchedulers.mainThread())//指定observer
33 | .subscribe(observer);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/module_weather/src/main/java/com/chs/weather/net/WeatherDataManager.java:
--------------------------------------------------------------------------------
1 | package com.chs.weather.net;
2 |
3 | import com.chs.library.http.RetrofitManager;
4 | import com.chs.weather.module.WeatherEntity;
5 |
6 | import io.reactivex.Observable;
7 | import io.reactivex.Observer;
8 | import io.reactivex.android.schedulers.AndroidSchedulers;
9 | import io.reactivex.schedulers.Schedulers;
10 |
11 | /**
12 | * 作者:chs on 2017-08-10 14:18
13 | * 邮箱:657083984@qq.com
14 | */
15 |
16 | public class WeatherDataManager {
17 |
18 | public WeatherDataManager() {
19 | String baseUrl = "http://aider.meizu.com/app/weather/";
20 | RetrofitManager.getInstance().initRetrofit(baseUrl);
21 | }
22 | public void getWeather(Observer observer, int cityId){
23 |
24 | Observable observable = RetrofitManager.getInstance().createReq(GetServiceData.class).getWeather(cityId);
25 |
26 | toSubscribe(observable, observer);
27 | }
28 | private void toSubscribe(Observable o, Observer observer){
29 | o.subscribeOn(Schedulers.io())//指定Observable
30 | .unsubscribeOn(Schedulers.io())
31 | .observeOn(AndroidSchedulers.mainThread())//指定observer
32 | .subscribe(observer);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_second.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
15 |
24 |
25 |
29 |
30 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/scwang/smartrefresh/layout/api/RefreshContent.java:
--------------------------------------------------------------------------------
1 | package com.scwang.smartrefresh.layout.api;
2 |
3 | import android.animation.ValueAnimator.AnimatorUpdateListener;
4 | import android.view.MotionEvent;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | /**
9 | * 刷新内容组件
10 | * Created by SCWANG on 2017/5/26.
11 | */
12 |
13 | public interface RefreshContent {
14 | void moveSpinner(int spinner);
15 | boolean canRefresh();
16 | boolean canLoadmore();
17 | int getMeasuredWidth();
18 | int getMeasuredHeight();
19 | void measure(int widthSpec, int heightSpec);
20 | void layout(int left, int top, int right, int bottom);
21 |
22 | View getView();
23 | View getScrollableView();
24 | ViewGroup.LayoutParams getLayoutParams();
25 |
26 | void onActionDown(MotionEvent e);
27 | void onActionUpOrCancel();
28 |
29 | void setupComponent(RefreshKernel kernel, View fixedHeader, View fixedFooter);
30 | void onInitialHeaderAndFooter(int headerHeight, int footerHeight);
31 | void setScrollBoundaryDecider(ScrollBoundaryDecider boundary);
32 | void setEnableLoadmoreWhenContentNotFull(boolean enable);
33 |
34 | AnimatorUpdateListener onLoadingFinish(RefreshKernel kernel, int footerHeight, int startDelay, int reboundDuration);
35 | }
36 |
--------------------------------------------------------------------------------
/module_library/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 |
--------------------------------------------------------------------------------
/module_library/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 |
--------------------------------------------------------------------------------
/module_library/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 |
--------------------------------------------------------------------------------
/module_library/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 |
--------------------------------------------------------------------------------
/module_library/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 |
--------------------------------------------------------------------------------
/app/src/main/java/com/chs/moduledevelop/ThirdFragment.java:
--------------------------------------------------------------------------------
1 | package com.chs.moduledevelop;
2 |
3 | import android.os.Bundle;
4 | import android.view.View;
5 |
6 | import com.alibaba.android.arouter.launcher.ARouter;
7 | import com.chs.library.base.BaseFragment;
8 |
9 | import butterknife.OnClick;
10 | import butterknife.Unbinder;
11 |
12 | /**
13 | * 作者:chs on 2017-08-03 15:42
14 | * 邮箱:657083984@qq.com
15 | */
16 |
17 | public class ThirdFragment extends BaseFragment {
18 | Unbinder unbinder;
19 |
20 | public static ThirdFragment newInstance() {
21 | return new ThirdFragment();
22 | }
23 |
24 | @Override
25 | public int getLayoutResId() {
26 | return R.layout.fragment_third;
27 | }
28 |
29 | @Override
30 | public void finishCreateView(Bundle state) {
31 |
32 | }
33 |
34 | @Override
35 | public void onDestroyView() {
36 | super.onDestroyView();
37 | unbinder.unbind();
38 | }
39 |
40 | @OnClick({R.id.weather,R.id.duanzi})
41 | public void onViewClicked(View view) {
42 | switch (view.getId()){
43 | case R.id.weather:
44 | ARouter.getInstance().build("/weather/WeatherActivity").navigation();
45 | break;
46 | case R.id.duanzi:
47 | ARouter.getInstance().build("/news/NewsActivity").navigation();
48 | break;
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_third.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
11 |
17 |
25 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/module_library/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 |
--------------------------------------------------------------------------------
/module_library/src/main/res/layout/loading_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
19 |
20 |
26 |
27 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/module_library/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 |
--------------------------------------------------------------------------------
/module_library/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 D:\AndroidTools\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 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 | -keep public class com.alibaba.android.arouter.routes.**{*;}
27 | -keep class * implements com.alibaba.android.arouter.facade.template.ISyringe{*;}
28 | -dontwarn okio.**
29 | -dontwarn javax.annotation.**
30 | -keep class com.chad.library.adapter.** {
31 | *;
32 | }
33 | -keep public class * extends com.chad.library.adapter.base.BaseQuickAdapter
34 | -keep public class * extends com.chad.library.adapter.base.BaseViewHolder
35 | -keepclassmembers public class * extends com.chad.library.adapter.base.BaseViewHolder {
36 | (android.view.View);
37 | }
38 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/scwang/smartrefresh/layout/util/ViscousFluidInterpolator.java:
--------------------------------------------------------------------------------
1 | package com.scwang.smartrefresh.layout.util;
2 |
3 | import android.view.animation.Interpolator;
4 |
5 | public class ViscousFluidInterpolator implements Interpolator {
6 | /** Controls the viscous fluid effect (how much of it). */
7 | private static final float VISCOUS_FLUID_SCALE = 8.0f;
8 |
9 | private static final float VISCOUS_FLUID_NORMALIZE;
10 | private static final float VISCOUS_FLUID_OFFSET;
11 |
12 | static {
13 |
14 | // must be set to 1.0 (used in viscousFluid())
15 | VISCOUS_FLUID_NORMALIZE = 1.0f / viscousFluid(1.0f);
16 | // account for very small floating-point error
17 | VISCOUS_FLUID_OFFSET = 1.0f - VISCOUS_FLUID_NORMALIZE * viscousFluid(1.0f);
18 | }
19 |
20 | private static float viscousFluid(float x) {
21 | x *= VISCOUS_FLUID_SCALE;
22 | if (x < 1.0f) {
23 | x -= (1.0f - (float)Math.exp(-x));
24 | } else {
25 | float start = 0.36787944117f; // 1/e == exp(-1)
26 | x = 1.0f - (float)Math.exp(1.0f - x);
27 | x = start + x * (1.0f - start);
28 | }
29 | return x;
30 | }
31 |
32 | @Override
33 | public float getInterpolation(float input) {
34 | final float interpolated = VISCOUS_FLUID_NORMALIZE * viscousFluid(input);
35 | if (interpolated > 0) {
36 | return interpolated + VISCOUS_FLUID_OFFSET;
37 | }
38 | return interpolated;
39 | }
40 | }
--------------------------------------------------------------------------------
/module_library/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 |
--------------------------------------------------------------------------------
/module_weather/src/main/res/layout/weather_activity_weather.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
22 |
23 |
33 |
34 |
43 |
44 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/scwang/smartrefresh/layout/constant/DimensionStatus.java:
--------------------------------------------------------------------------------
1 | package com.scwang.smartrefresh.layout.constant;
2 |
3 | /**
4 | * 尺寸值的定义状态,用于在值覆盖的时候决定优先级
5 | * 越往下优先级越高
6 | */
7 | public enum DimensionStatus {
8 | DefaultUnNotify(false),//默认值,但是还没通知确认
9 | Default(true),//默认值
10 | XmlWrap(true),//Xml计算
11 | XmlExact(true),//Xml 的view 指定
12 | XmlLayoutUnNotify(false),//Xml 的layout 中指定,但是还没通知确认
13 | XmlLayout(true),//Xml 的layout 中指定
14 | CodeExactUnNotify(false),//代码指定,但是还没通知确认
15 | CodeExact(true),//代码指定
16 | DeadLockUnNotify(false),//锁死,但是还没通知确认
17 | DeadLock(true);//锁死
18 | public final boolean notifyed;
19 |
20 | DimensionStatus(boolean notifyed) {
21 | this.notifyed = notifyed;
22 | }
23 |
24 | /**
25 | * 转换为未通知状态
26 | */
27 | public DimensionStatus unNotify() {
28 | if (notifyed) {
29 | DimensionStatus prev = values()[ordinal() - 1];
30 | if (!prev.notifyed) {
31 | return prev;
32 | }
33 | return DefaultUnNotify;
34 | }
35 | return this;
36 | }
37 |
38 | /**
39 | * 转换为通知状态
40 | */
41 | public DimensionStatus notifyed() {
42 | if (!notifyed) {
43 | return values()[ordinal() + 1];
44 | }
45 | return this;
46 | }
47 |
48 | /**
49 | * 小于等于
50 | */
51 | public boolean canReplaceWith(DimensionStatus status) {
52 | return ordinal() < status.ordinal() || ((!notifyed || CodeExact == this) && ordinal() == status.ordinal());
53 | }
54 |
55 | /**
56 | * 大于等于
57 | */
58 | public boolean gteReplaceWith(DimensionStatus status) {
59 | return ordinal() >= status.ordinal();
60 | }
61 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_book_adapter.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
19 |
20 |
26 |
27 |
28 |
34 |
35 |
41 |
42 |
43 |
50 |
--------------------------------------------------------------------------------
/module_library/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.jakewharton.butterknife'
3 | android {
4 | compileSdkVersion Integer.parseInt(COMPILE_SDK_VERSION)
5 | buildToolsVersion BUILDTOOLS_VERSION
6 |
7 | defaultConfig {
8 | minSdkVersion Integer.parseInt(MIN_SDK_VERSION)
9 | targetSdkVersion Integer.parseInt(TARGET_SDK_VERSION)
10 | versionCode 1
11 | versionName "1.0"
12 |
13 | javaCompileOptions {
14 | annotationProcessorOptions {
15 | arguments = [ moduleName : project.getName() ]
16 | }
17 | }
18 |
19 | }
20 | buildTypes {
21 | release {
22 | minifyEnabled false
23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
24 | }
25 | }
26 | }
27 |
28 | dependencies {
29 | compile "com.android.support:appcompat-v7:${SUPPORT_LIB_VERSION}"
30 | compile "com.jakewharton:butterknife:${BUTTERKNIFE_VERDION}"
31 | annotationProcessor "com.jakewharton:butterknife-compiler:${BUTTERKNIFE_VERDION}"
32 | compile "com.alibaba:arouter-api:${A_ROUTER_API}"
33 | annotationProcessor "com.alibaba:arouter-compiler:${A_ROUTER_COMPILER}"
34 |
35 | compile 'com.squareup.retrofit2:retrofit:2.3.0'
36 | compile 'io.reactivex.rxjava2:rxjava:2.0.3'
37 | compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
38 | compile 'com.google.code.gson:gson:2.7'
39 | compile 'com.squareup.okhttp3:logging-interceptor:3.8.0'
40 | compile 'com.squareup.retrofit2:converter-gson:2.3.0'
41 | compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
42 | compile 'com.android.support:design:25.3.1'
43 | compile 'com.github.bumptech.glide:glide:4.0.0'
44 | compile 'com.android.support:support-v4:25.3.1'
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/java/com/chs/moduledevelop/first/SectionAdapter.java:
--------------------------------------------------------------------------------
1 | package com.chs.moduledevelop.first;
2 |
3 | import android.widget.ImageView;
4 |
5 | import com.chs.library.base.adapter.BaseSectionQuickAdapter;
6 | import com.chs.library.base.adapter.BaseViewHolder;
7 | import com.chs.library.image.ImageLoader;
8 | import com.chs.moduledevelop.R;
9 |
10 | import java.util.List;
11 |
12 | /**
13 | * https://github.com/CymChad/BaseRecyclerViewAdapterHelper
14 | */
15 | public class SectionAdapter extends BaseSectionQuickAdapter {
16 | /**
17 | * Same as QuickAdapter#QuickAdapter(Context,int) but with
18 | * some initialization data.
19 | *
20 | * @param sectionHeadResId The section head layout id for each item
21 | * @param layoutResId The layout resource id of each item.
22 | * @param data A new list is created out of this one to avoid mutable list
23 | */
24 | public SectionAdapter(int layoutResId, int sectionHeadResId, List data) {
25 | super(layoutResId, sectionHeadResId, data);
26 | }
27 |
28 | @Override
29 | protected void convertHead(BaseViewHolder helper, final MovieSection item) {
30 | helper.setText(R.id.tv_title, item.header);
31 | helper.setVisible(R.id.tv_more, true);
32 | helper.addOnClickListener(R.id.tv_more);
33 | }
34 |
35 |
36 | @Override
37 | protected void convert(BaseViewHolder helper, MovieSection item) {
38 | int pos = helper.getLayoutPosition();
39 | HeatMovieEntity.SubjectsEntity entity = (HeatMovieEntity.SubjectsEntity) item.t;
40 | String path = entity.getImages().getLarge();
41 | ImageLoader.loadImageView(mContext,path, (ImageView) helper.getView(R.id.iv_img));
42 | helper.setText(R.id.tv_des, entity.getTitle());
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/chs/library/base/adapter/listener/OnItemSwipeListener.java:
--------------------------------------------------------------------------------
1 | package com.chs.library.base.adapter.listener;
2 |
3 | import android.graphics.Canvas;
4 | import android.support.v7.widget.RecyclerView;
5 |
6 | /**
7 | * Created by luoxw on 2016/6/23.
8 | */
9 | public interface OnItemSwipeListener {
10 | /**
11 | * Called when the swipe action start.
12 | */
13 | void onItemSwipeStart(RecyclerView.ViewHolder viewHolder, int pos);
14 |
15 | /**
16 | * Called when the swipe action is over.
17 | * If you change the view on the start, you should reset is here, no matter the item has swiped or not.
18 | *
19 | * @param pos If the view is swiped, pos will be negative.
20 | */
21 | void clearView(RecyclerView.ViewHolder viewHolder, int pos);
22 |
23 | /**
24 | * Called when item is swiped, the view is going to be removed from the adapter.
25 | */
26 | void onItemSwiped(RecyclerView.ViewHolder viewHolder, int pos);
27 |
28 | /**
29 | * Draw on the empty edge when swipe moving
30 | *
31 | * @param canvas the empty edge's canvas
32 | * @param viewHolder The ViewHolder which is being interacted by the User or it was
33 | * interacted and simply animating to its original position
34 | * @param dX The amount of horizontal displacement caused by user's action
35 | * @param dY The amount of vertical displacement caused by user's action
36 | * @param isCurrentlyActive True if this view is currently being controlled by the user or
37 | * false it is simply animating back to its original state.
38 | */
39 | void onItemSwipeMoving(Canvas canvas, RecyclerView.ViewHolder viewHolder, float dX, float dY, boolean isCurrentlyActive);
40 | }
41 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/scwang/smartrefresh/layout/impl/ScrollBoundaryDeciderAdapter.java:
--------------------------------------------------------------------------------
1 | package com.scwang.smartrefresh.layout.impl;
2 |
3 | import android.view.MotionEvent;
4 | import android.view.View;
5 |
6 | import com.scwang.smartrefresh.layout.api.ScrollBoundaryDecider;
7 | import com.scwang.smartrefresh.layout.util.ScrollBoundaryUtil;
8 |
9 | /**
10 | * 滚动边界
11 | * Created by SCWANG on 2017/7/8.
12 | */
13 |
14 | @SuppressWarnings("WeakerAccess")
15 | public class ScrollBoundaryDeciderAdapter implements ScrollBoundaryDecider {
16 |
17 | //
18 | protected MotionEvent mActionEvent;
19 | protected ScrollBoundaryDecider boundary;
20 | protected boolean mEnableLoadmoreWhenContentNotFull;
21 |
22 | void setScrollBoundaryDecider(ScrollBoundaryDecider boundary){
23 | this.boundary = boundary;
24 | }
25 |
26 | void setActionEvent(MotionEvent event) {
27 | mActionEvent = event;
28 | }
29 | //
30 |
31 | //
32 | @Override
33 | public boolean canRefresh(View content) {
34 | if (boundary != null) {
35 | return boundary.canRefresh(content);
36 | }
37 | return ScrollBoundaryUtil.canRefresh(content, mActionEvent);
38 | }
39 |
40 | @Override
41 | public boolean canLoadmore(View content) {
42 | if (boundary != null) {
43 | return boundary.canLoadmore(content);
44 | }
45 | if (mEnableLoadmoreWhenContentNotFull) {
46 | return !ScrollBoundaryUtil.canScrollDown(content, mActionEvent);
47 | }
48 | return ScrollBoundaryUtil.canLoadmore(content, mActionEvent);
49 | }
50 |
51 | public void setEnableLoadmoreWhenContentNotFull(boolean enable) {
52 | mEnableLoadmoreWhenContentNotFull = enable;
53 | }
54 | //
55 | }
56 |
--------------------------------------------------------------------------------
/module_weather/build.gradle:
--------------------------------------------------------------------------------
1 | if (isDebug.toBoolean()) {
2 | apply plugin: 'com.android.application'
3 | } else {
4 | apply plugin: 'com.android.library'
5 | }
6 | apply plugin: 'com.jakewharton.butterknife'
7 | android {
8 | compileSdkVersion Integer.parseInt(COMPILE_SDK_VERSION)
9 | buildToolsVersion BUILDTOOLS_VERSION
10 |
11 | defaultConfig {
12 | // 作为library时不能有applicationId,只有作为一个独立应用时才能够如下设置
13 | if (isDebug.toBoolean()) {
14 | applicationId "com.chs.weather"
15 | }
16 | minSdkVersion Integer.parseInt(MIN_SDK_VERSION)
17 | targetSdkVersion Integer.parseInt(TARGET_SDK_VERSION)
18 | versionCode 1
19 | versionName "1.0"
20 | //所有资源必须以此 weather_ 开头,否则会报错
21 | resourcePrefix "weather_"
22 | //用到ARouter中都要加下面的一段
23 | javaCompileOptions {
24 | annotationProcessorOptions {
25 | arguments = [ moduleName : project.getName() ]
26 | }
27 | }
28 |
29 | }
30 | buildTypes {
31 | release {
32 | minifyEnabled false
33 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
34 | }
35 | }
36 | sourceSets {
37 | main {
38 | if (isDebug.toBoolean()) {
39 | manifest.srcFile 'src/main/debug/AndroidManifest.xml'
40 | } else {
41 | manifest.srcFile 'src/main/AndroidManifest.xml'
42 | java {
43 | //release 时 debug 目录下文件不需要合并到主工程
44 | exclude 'debug/**'
45 | exclude '**/debug/**'
46 | }
47 | }
48 | }
49 | }
50 | }
51 |
52 | dependencies {
53 | compile project(':module_library')
54 | annotationProcessor "com.jakewharton:butterknife-compiler:${BUTTERKNIFE_VERDION}"
55 | annotationProcessor "com.alibaba:arouter-compiler:${A_ROUTER_COMPILER}"
56 | }
57 |
--------------------------------------------------------------------------------
/module_library/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
13 |
23 |
24 |
32 |
39 |
40 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/scwang/smartrefresh/layout/listener/SimpleMultiPurposeListener.java:
--------------------------------------------------------------------------------
1 | package com.scwang.smartrefresh.layout.listener;
2 |
3 | import com.scwang.smartrefresh.layout.api.RefreshFooter;
4 | import com.scwang.smartrefresh.layout.api.RefreshHeader;
5 | import com.scwang.smartrefresh.layout.api.RefreshLayout;
6 | import com.scwang.smartrefresh.layout.constant.RefreshState;
7 |
8 | /**
9 | * 多功能监听器
10 | * Created by SCWANG on 2017/5/26.
11 | */
12 |
13 | public class SimpleMultiPurposeListener implements OnMultiPurposeListener {
14 |
15 | @Override
16 | public void onHeaderPulling(RefreshHeader header, float percent, int offset, int headerHeight, int extendHeight) {
17 |
18 | }
19 |
20 | @Override
21 | public void onHeaderReleasing(RefreshHeader header, float percent, int offset, int footerHeight, int extendHeight) {
22 |
23 | }
24 |
25 | @Override
26 | public void onHeaderStartAnimator(RefreshHeader header, int footerHeight, int extendHeight) {
27 |
28 | }
29 |
30 | @Override
31 | public void onHeaderFinish(RefreshHeader header, boolean success) {
32 |
33 | }
34 |
35 | @Override
36 | public void onFooterPulling(RefreshFooter footer, float percent, int offset, int footerHeight, int extendHeight) {
37 |
38 | }
39 |
40 | @Override
41 | public void onFooterReleasing(RefreshFooter footer, float percent, int offset, int footerHeight, int extendHeight) {
42 |
43 | }
44 |
45 | @Override
46 | public void onFooterStartAnimator(RefreshFooter footer, int headHeight, int extendHeight) {
47 |
48 | }
49 |
50 | @Override
51 | public void onFooterFinish(RefreshFooter footer, boolean success) {
52 |
53 | }
54 |
55 | @Override
56 | public void onRefresh(RefreshLayout refreshlayout) {
57 |
58 | }
59 |
60 | @Override
61 | public void onLoadmore(RefreshLayout refreshlayout) {
62 |
63 | }
64 |
65 | @Override
66 | public void onStateChanged(RefreshLayout refreshLayout, RefreshState oldState, RefreshState newState) {
67 |
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/module_library/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 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/chs/library/base/adapter/BaseMultiItemQuickAdapter.java:
--------------------------------------------------------------------------------
1 | package com.chs.library.base.adapter;
2 |
3 | import android.support.annotation.LayoutRes;
4 | import android.util.SparseIntArray;
5 | import android.view.ViewGroup;
6 |
7 | import com.chs.library.base.adapter.entity.MultiItemEntity;
8 |
9 | import java.util.List;
10 |
11 | /**
12 | * https://github.com/CymChad/BaseRecyclerViewAdapterHelper
13 | */
14 | public abstract class BaseMultiItemQuickAdapter extends BaseQuickAdapter {
15 |
16 | /**
17 | * layouts indexed with their types
18 | */
19 | private SparseIntArray layouts;
20 |
21 | private static final int DEFAULT_VIEW_TYPE = -0xff;
22 | public static final int TYPE_NOT_FOUND = -404;
23 |
24 | /**
25 | * Same as QuickAdapter#QuickAdapter(Context,int) but with
26 | * some initialization data.
27 | *
28 | * @param data A new list is created out of this one to avoid mutable list
29 | */
30 | public BaseMultiItemQuickAdapter(List data) {
31 | super(data);
32 | }
33 |
34 | @Override
35 | protected int getDefItemViewType(int position) {
36 | Object item = mData.get(position);
37 | if (item instanceof MultiItemEntity) {
38 | return ((MultiItemEntity) item).getItemType();
39 | }
40 | return DEFAULT_VIEW_TYPE;
41 | }
42 |
43 | protected void setDefaultViewTypeLayout(@LayoutRes int layoutResId) {
44 | addItemType(DEFAULT_VIEW_TYPE, layoutResId);
45 | }
46 |
47 | @Override
48 | protected K onCreateDefViewHolder(ViewGroup parent, int viewType) {
49 | return createBaseViewHolder(parent, getLayoutId(viewType));
50 | }
51 |
52 | private int getLayoutId(int viewType) {
53 | return layouts.get(viewType, TYPE_NOT_FOUND);
54 | }
55 |
56 | protected void addItemType(int type, @LayoutRes int layoutResId) {
57 | if (layouts == null) {
58 | layouts = new SparseIntArray();
59 | }
60 | layouts.put(type, layoutResId);
61 | }
62 |
63 |
64 | }
65 |
66 |
67 |
--------------------------------------------------------------------------------
/module_library/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 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/scwang/smartrefresh/layout/api/RefreshInternal.java:
--------------------------------------------------------------------------------
1 | package com.scwang.smartrefresh.layout.api;
2 |
3 | import android.support.annotation.NonNull;
4 | import android.view.View;
5 |
6 | import com.scwang.smartrefresh.layout.constant.SpinnerStyle;
7 | import com.scwang.smartrefresh.layout.listener.OnStateChangedListener;
8 |
9 |
10 | /**
11 | * 刷新内部组件
12 | * Created by SCWANG on 2017/5/26.
13 | */
14 |
15 | public interface RefreshInternal extends OnStateChangedListener {
16 | /**
17 | * 获取实体视图
18 | */
19 | @NonNull
20 | View getView();
21 |
22 | /**
23 | * 获取变换方式 {@link SpinnerStyle}
24 | */
25 | SpinnerStyle getSpinnerStyle();
26 |
27 | /**
28 | * 设置主题颜色
29 | * @param colors 对应Xml中配置的 srlPrimaryColor srlAccentColor
30 | */
31 | void setPrimaryColors(int... colors);
32 |
33 | /**
34 | * 尺寸定义完成 (如果高度不改变(代码修改:setHeader),只调用一次, 在RefreshLayout#onMeasure中调用)
35 | * @param kernel RefreshKernel
36 | * @param height HeaderHeight or FooterHeight
37 | * @param extendHeight extendHeaderHeight or extendFooterHeight
38 | */
39 | void onInitialized(RefreshKernel kernel, int height, int extendHeight);
40 |
41 | /**
42 | * 水平方向的拖动
43 | * @param percentX 下拉时,手指水平坐标对屏幕的占比(0 - percentX - 1)
44 | * @param offsetX 下拉时,手指水平坐标对屏幕的偏移(0 - offsetX - LayoutWidth)
45 | */
46 | void onHorizontalDrag(float percentX, int offsetX, int offsetMax);
47 |
48 | /**
49 | * 开始动画
50 | * @param layout RefreshLayout
51 | * @param height HeaderHeight or FooterHeight
52 | * @param extendHeight extendHeaderHeight or extendFooterHeight
53 | */
54 | void onStartAnimator(RefreshLayout layout, int height, int extendHeight);
55 |
56 | /**
57 | * 动画结束
58 | * @param layout RefreshLayout
59 | * @param success 数据是否成功刷新或加载
60 | * @return 完成动画所需时间 如果返回 Integer.MAX_VALUE 将取消本次完成事件,继续保持原有状态
61 | */
62 | int onFinish(RefreshLayout layout, boolean success);
63 |
64 | /**
65 | * 是否支持水平方向的拖动(将会影响到onHorizontalDrag的调用)
66 | * @return 水平拖动需要消耗更多的时间和资源,所以如果不支持请返回false
67 | */
68 | boolean isSupportHorizontalDrag();
69 | }
70 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/chs/library/http/RetrofitManager.java:
--------------------------------------------------------------------------------
1 | package com.chs.library.http;
2 |
3 | import com.chs.library.AppConfig;
4 |
5 | import java.util.concurrent.TimeUnit;
6 |
7 | import okhttp3.OkHttpClient;
8 | import okhttp3.logging.HttpLoggingInterceptor;
9 | import retrofit2.Retrofit;
10 | import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
11 | import retrofit2.converter.gson.GsonConverterFactory;
12 |
13 | /**
14 | * 作者:chs on 2017-08-04 14:39
15 | * 邮箱:657083984@qq.com
16 | */
17 |
18 | public class RetrofitManager {
19 | public RetrofitManager() {
20 | // initRetrofit();
21 | }
22 |
23 | //在访问HttpMethods时创建单例
24 | private static class SingletonHolder{
25 | private static final RetrofitManager INSTANCE = new RetrofitManager();
26 | }
27 |
28 | //获取单例
29 | public static RetrofitManager getInstance(){
30 | return SingletonHolder.INSTANCE;
31 | }
32 | private Retrofit mRetrofit;
33 | //正常情况一个项目中的baseUrl是一样的可以写死一个常量,这里因为到处找的免费API接口 所以baseUrl动态传入
34 | public RetrofitManager initRetrofit(String baseUrl) {
35 | OkHttpClient.Builder builder = new OkHttpClient.Builder();
36 | builder.connectTimeout(110, TimeUnit.SECONDS);
37 | builder.readTimeout(20, TimeUnit.SECONDS);
38 | builder.writeTimeout(20, TimeUnit.SECONDS);
39 | builder.retryOnConnectionFailure(true);
40 |
41 | if (AppConfig.DEBUG) {
42 | // Log信息拦截器
43 | HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
44 | loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
45 | //设置 Debug Log 模式
46 | builder.addInterceptor(loggingInterceptor);
47 | }
48 | OkHttpClient okHttpClient = builder.build();
49 | mRetrofit = new Retrofit.Builder()
50 | .baseUrl(baseUrl)
51 | .addConverterFactory(GsonConverterFactory.create())
52 | .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
53 | .client(okHttpClient)
54 | .build();
55 | return this;
56 | }
57 |
58 | public T createReq(Class service){
59 | return mRetrofit.create(service);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
26 |
36 |
46 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/module_library/src/main/res/layout/quick_view_load_more.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
20 |
21 |
29 |
30 |
31 |
36 |
37 |
38 |
44 |
45 |
46 |
47 |
52 |
53 |
59 |
60 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/scwang/smartrefresh/layout/header/bezierradar/RippleView.java:
--------------------------------------------------------------------------------
1 | package com.scwang.smartrefresh.layout.header.bezierradar;
2 |
3 |
4 | import android.animation.Animator;
5 | import android.animation.AnimatorListenerAdapter;
6 | import android.animation.ValueAnimator;
7 | import android.content.Context;
8 | import android.graphics.Canvas;
9 | import android.graphics.Paint;
10 | import android.view.View;
11 |
12 | /**
13 | * cjj
14 | */
15 | public class RippleView extends View {
16 |
17 | private int mRadius;
18 | private Paint mPaint;
19 | private ValueAnimator mAnimator;
20 |
21 | public RippleView(Context context) {
22 | super(context);
23 | mPaint = new Paint();
24 | mPaint.setAntiAlias(true);
25 | mPaint.setColor(0xffffffff);
26 | mPaint.setStyle(Paint.Style.FILL);
27 | }
28 |
29 | @Override
30 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
31 | setMeasuredDimension(resolveSize(getSuggestedMinimumWidth(), widthMeasureSpec),
32 | resolveSize(getSuggestedMinimumHeight(), heightMeasureSpec));
33 | }
34 |
35 | public void setFrontColor(int color) {
36 | mPaint.setColor(color);
37 | }
38 |
39 | public void startReveal() {
40 | if (mAnimator == null) {
41 | int bigRadius = (int) (Math.sqrt(Math.pow(getHeight(), 2) + Math.pow(getWidth(), 2)));
42 | mAnimator = ValueAnimator.ofInt(0, bigRadius);
43 | mAnimator.setDuration(400);
44 | mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
45 | @Override
46 | public void onAnimationUpdate(ValueAnimator animation) {
47 | mRadius = (int) animation.getAnimatedValue();
48 | invalidate();
49 | }
50 | });
51 | mAnimator.addListener(new AnimatorListenerAdapter() {
52 | @Override
53 | public void onAnimationEnd(Animator animation) {
54 | }
55 | });
56 | }
57 | mAnimator.start();
58 | }
59 |
60 | @Override
61 | protected void onDraw(Canvas canvas) {
62 | super.onDraw(canvas);
63 | canvas.drawCircle(getWidth() / 2, getHeight() / 2, mRadius, mPaint);
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/module_news/build.gradle:
--------------------------------------------------------------------------------
1 | if (isDebug.toBoolean()) {
2 | apply plugin: 'com.android.application'
3 | } else {
4 | apply plugin: 'com.android.library'
5 | }
6 | apply plugin: 'com.jakewharton.butterknife'
7 | android {
8 | compileSdkVersion Integer.parseInt(COMPILE_SDK_VERSION)
9 | buildToolsVersion BUILDTOOLS_VERSION
10 |
11 | defaultConfig {
12 | minSdkVersion Integer.parseInt(MIN_SDK_VERSION)
13 | targetSdkVersion Integer.parseInt(TARGET_SDK_VERSION)
14 | versionCode 1
15 | versionName "1.0"
16 | // 作为library时不能有applicationId,只有作为一个独立应用时才能够如下设置
17 | if (isDebug.toBoolean()) {
18 | applicationId "com.chs.news"
19 | }
20 | //所有资源必须以此 news_ 开头,否则会报错
21 | resourcePrefix "news_"
22 | //用到ARouter中都要加下面的一段
23 | javaCompileOptions {
24 | annotationProcessorOptions {
25 | arguments = [ moduleName : project.getName() ]
26 | }
27 | }
28 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
29 |
30 | }
31 | buildTypes {
32 | release {
33 | minifyEnabled false
34 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
35 | }
36 | }
37 | sourceSets {
38 | main {
39 | if (isDebug.toBoolean()) {
40 | manifest.srcFile 'src/main/debug/AndroidManifest.xml'
41 | } else {
42 | manifest.srcFile 'src/main/AndroidManifest.xml'
43 | java {
44 | //release 时 debug 目录下文件不需要合并到主工程
45 | exclude 'debug/**'
46 | exclude '**/debug/**'
47 | }
48 | }
49 | }
50 | }
51 | }
52 |
53 | dependencies {
54 | compile fileTree(dir: 'libs', include: ['*.jar'])
55 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
56 | exclude group: 'com.android.support', module: 'support-annotations'
57 | })
58 | compile 'com.android.support:appcompat-v7:25.3.1'
59 | testCompile 'junit:junit:4.12'
60 | compile project(':module_library')
61 | annotationProcessor "com.jakewharton:butterknife-compiler:${BUTTERKNIFE_VERDION}"
62 | annotationProcessor "com.alibaba:arouter-compiler:${A_ROUTER_COMPILER}"
63 | }
64 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/chs/library/base/adapter/BaseSectionQuickAdapter.java:
--------------------------------------------------------------------------------
1 | package com.chs.library.base.adapter;
2 |
3 | import android.view.ViewGroup;
4 |
5 | import com.chs.library.base.adapter.entity.SectionEntity;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * https://github.com/CymChad/BaseRecyclerViewAdapterHelper
11 | */
12 | public abstract class BaseSectionQuickAdapter extends BaseQuickAdapter {
13 |
14 |
15 | protected int mSectionHeadResId;
16 | protected static final int SECTION_HEADER_VIEW = 0x00000444;
17 |
18 | /**
19 | * Same as QuickAdapter#QuickAdapter(Context,int) but with
20 | * some initialization data.
21 | *
22 | * @param sectionHeadResId The section head layout id for each item
23 | * @param layoutResId The layout resource id of each item.
24 | * @param data A new list is created out of this one to avoid mutable list
25 | */
26 | public BaseSectionQuickAdapter(int layoutResId, int sectionHeadResId, List data) {
27 | super(layoutResId, data);
28 | this.mSectionHeadResId = sectionHeadResId;
29 | }
30 |
31 | @Override
32 | protected int getDefItemViewType(int position) {
33 | return mData.get(position).isHeader ? SECTION_HEADER_VIEW : 0;
34 | }
35 |
36 | @Override
37 | protected K onCreateDefViewHolder(ViewGroup parent, int viewType) {
38 | if (viewType == SECTION_HEADER_VIEW)
39 | return createBaseViewHolder(getItemView(mSectionHeadResId, parent));
40 |
41 | return super.onCreateDefViewHolder(parent, viewType);
42 | }
43 |
44 | @Override
45 | protected boolean isFixedViewType(int type) {
46 | return super.isFixedViewType(type) || type == SECTION_HEADER_VIEW;
47 | }
48 |
49 | @Override
50 | public void onBindViewHolder(K holder, int position) {
51 | switch (holder.getItemViewType()) {
52 | case SECTION_HEADER_VIEW:
53 | setFullSpan(holder);
54 | convertHead(holder, getItem(position - getHeaderLayoutCount()));
55 | break;
56 | default:
57 | super.onBindViewHolder(holder, position);
58 | break;
59 | }
60 | }
61 |
62 | protected abstract void convertHead(K helper, T item);
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/chs/library/widget/RecycleViewDivider.java:
--------------------------------------------------------------------------------
1 | package com.chs.library.widget;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Rect;
6 | import android.graphics.drawable.Drawable;
7 | import android.support.v4.content.ContextCompat;
8 | import android.support.v7.widget.RecyclerView;
9 | import android.view.View;
10 |
11 | import com.chs.library.R;
12 |
13 |
14 | /**
15 | * 作者:chs on 2017-08-28 14:30
16 | * 邮箱:657083984@qq.com
17 | */
18 |
19 | public class RecycleViewDivider extends RecyclerView.ItemDecoration {
20 | private Drawable drawable;
21 |
22 | public RecycleViewDivider(Context context) {
23 | drawable = ContextCompat.getDrawable(context, R.drawable.bottom_line);
24 | }
25 |
26 | @Override
27 | public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
28 | // drawVertical(c, parent);
29 | }
30 |
31 | @Override
32 | public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
33 | super.onDrawOver(c, parent, state);
34 | drawVertical(c, parent);
35 | }
36 |
37 | private void drawVertical(Canvas canvas, RecyclerView parent) {
38 | int left;
39 | int right = parent.getWidth() - parent.getPaddingRight();
40 | View child;
41 | RecyclerView.LayoutParams layoutParams;
42 | int top;
43 | int bottom;
44 | int count = parent.getChildCount();
45 | for (int i = 0; i < count; i++) {
46 | child = parent.getChildAt(i);
47 | layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();
48 | left = child.getLeft();
49 |
50 | top = child.getBottom() + layoutParams.bottomMargin;
51 | bottom = top + drawable.getIntrinsicHeight();
52 | drawable.setBounds(left, top, right, bottom);
53 | drawable.draw(canvas);
54 | }
55 |
56 | }
57 |
58 | //如果等于分割线的高度或宽度的话可以不重写次方法
59 | @Override
60 | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
61 | if (parent.getChildLayoutPosition(view) == parent.getChildCount() - 1) {
62 | outRect.set(0, 0, 0, 0);
63 | } else {
64 | outRect.set(0, 0, 0, drawable.getIntrinsicHeight());
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/scwang/smartrefresh/layout/header/bezierradar/RoundDotView.java:
--------------------------------------------------------------------------------
1 | package com.scwang.smartrefresh.layout.header.bezierradar;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Color;
6 | import android.graphics.Paint;
7 | import android.view.View;
8 |
9 | import com.scwang.smartrefresh.layout.util.DensityUtil;
10 |
11 | /**
12 | *
13 | * Created by cjj on 2015/8/27.
14 | */
15 | public class RoundDotView extends View {
16 |
17 | private int num = 7;
18 | private Paint mPath;
19 | private float mRadius;
20 | private float fraction;
21 |
22 | public RoundDotView(Context context) {
23 | super(context);
24 | mPath = new Paint();
25 | mPath.setAntiAlias(true);
26 | mPath.setColor(Color.WHITE);
27 | mRadius = DensityUtil.dp2px(7);
28 | }
29 |
30 | @Override
31 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
32 | setMeasuredDimension(resolveSize(getSuggestedMinimumWidth(), widthMeasureSpec),
33 | resolveSize(getSuggestedMinimumHeight(), heightMeasureSpec));
34 | }
35 |
36 | public void setDotColor(int color) {
37 | mPath.setColor(color);
38 | }
39 |
40 | @Override
41 | protected void onDraw(Canvas canvas) {
42 | super.onDraw(canvas);
43 | int width = getWidth();
44 | int height = getHeight();
45 | float wide = (width / num) * fraction-((fraction>1)?((fraction-1)*(width / num)/fraction):0);//y1 = t*(w/n)-(t>1)*((t-1)*(w/n)/t)
46 | float high = height - ((fraction>1)?((fraction-1)*height/2/fraction):0);//y2 = x - (t>1)*((t-1)*x/t);
47 | for (int i = 0 ; i < num; i++) {
48 | float index = 1f + i - (1f + num) / 2;//y3 = (x + 1) - (n + 1)/2; 居中 index 变量:0 1 2 3 4 结果: -2 -1 0 1 2
49 | float alpha = 255 * (1 - (2 * (Math.abs(index) / num)));//y4 = m * ( 1 - 2 * abs(y3) / n); 横向 alpha 差
50 | float x = DensityUtil.px2dp(height);
51 | mPath.setAlpha((int) (alpha * (1d - 1d / Math.pow((x / 800d + 1d), 15))));//y5 = y4 * (1-1/((x/800+1)^15));竖直 alpha 差
52 | float radius = mRadius * (1-1/((x/10+1)));//y6 = mRadius*(1-1/(x/10+1));半径
53 | canvas.drawCircle(width / 2- radius/2 + wide * index , high / 2, radius, mPath);
54 | }
55 | }
56 |
57 | public void setFraction(float fraction) {
58 | this.fraction = fraction;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/chs/library/base/adapter/entity/AbstractExpandableItem.java:
--------------------------------------------------------------------------------
1 | package com.chs.library.base.adapter.entity;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | /**
7 | * A helper to implement expandable item.
8 | * if you don't want to extent a class, you can also implement the interface IExpandable
9 | * Created by luoxw on 2016/8/9.
10 | */
11 | public abstract class AbstractExpandableItem implements IExpandable {
12 | protected boolean mExpandable = false;
13 | protected List mSubItems;
14 |
15 | @Override
16 | public boolean isExpanded() {
17 | return mExpandable;
18 | }
19 |
20 | @Override
21 | public void setExpanded(boolean expanded) {
22 | mExpandable = expanded;
23 | }
24 |
25 | @Override
26 | public List getSubItems() {
27 | return mSubItems;
28 | }
29 |
30 | public boolean hasSubItem() {
31 | return mSubItems != null && mSubItems.size() > 0;
32 | }
33 |
34 | public void setSubItems(List list) {
35 | mSubItems = list;
36 | }
37 |
38 | public T getSubItem(int position) {
39 | if (hasSubItem() && position < mSubItems.size()) {
40 | return mSubItems.get(position);
41 | } else {
42 | return null;
43 | }
44 | }
45 |
46 | public int getSubItemPosition(T subItem) {
47 | return mSubItems != null ? mSubItems.indexOf(subItem) : -1;
48 | }
49 |
50 | public void addSubItem(T subItem) {
51 | if (mSubItems == null) {
52 | mSubItems = new ArrayList<>();
53 | }
54 | mSubItems.add(subItem);
55 | }
56 |
57 | public void addSubItem(int position, T subItem) {
58 | if (mSubItems != null && position >= 0 && position < mSubItems.size()) {
59 | mSubItems.add(position, subItem);
60 | } else {
61 | addSubItem(subItem);
62 | }
63 | }
64 |
65 | public boolean contains(T subItem) {
66 | return mSubItems != null && mSubItems.contains(subItem);
67 | }
68 |
69 | public boolean removeSubItem(T subItem) {
70 | return mSubItems != null && mSubItems.remove(subItem);
71 | }
72 |
73 | public boolean removeSubItem(int position) {
74 | if (mSubItems != null && position >= 0 && position < mSubItems.size()) {
75 | mSubItems.remove(position);
76 | return true;
77 | }
78 | return false;
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/scwang/smartrefresh/layout/internal/pathview/PathsView.java:
--------------------------------------------------------------------------------
1 | package com.scwang.smartrefresh.layout.internal.pathview;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.util.AttributeSet;
6 | import android.view.View;
7 |
8 | /**
9 | * 路径视图
10 | * Created by SCWANG on 2017/5/29.
11 | */
12 |
13 | public class PathsView extends View {
14 |
15 | protected PathsDrawable mPathsDrawable = new PathsDrawable();
16 |
17 | public PathsView(Context context) {
18 | super(context);
19 | this.initView(context, null, 0);
20 | }
21 |
22 | public PathsView(Context context, AttributeSet attrs) {
23 | super(context, attrs);
24 | this.initView(context, attrs, 0);
25 | }
26 |
27 | public PathsView(Context context, AttributeSet attrs, int defStyleAttr) {
28 | super(context, attrs, defStyleAttr);
29 | this.initView(context, attrs, defStyleAttr);
30 | }
31 |
32 | private void initView(Context context, AttributeSet attrs, int defStyleAttr) {
33 | mPathsDrawable = new PathsDrawable();
34 | }
35 |
36 | @Override
37 | protected void onFinishInflate() {
38 | super.onFinishInflate();
39 | if (getTag() instanceof String) {
40 | parserPaths(getTag().toString());
41 | }
42 | }
43 |
44 | @Override
45 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
46 | setMeasuredDimension(resolveSize(mPathsDrawable.width()+getPaddingLeft()+getPaddingRight(), widthMeasureSpec),
47 | resolveSize(mPathsDrawable.height()+getPaddingTop()+getPaddingBottom(), heightMeasureSpec));
48 | }
49 |
50 | @Override
51 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
52 | super.onLayout(changed, left, top, right, bottom);
53 | mPathsDrawable.setBounds(getPaddingLeft(), getPaddingTop(),
54 | Math.max((right - left) - getPaddingRight(), getPaddingLeft()),
55 | Math.max((bottom - top) - getPaddingTop(), getPaddingTop()));
56 | }
57 |
58 | @Override
59 | protected void onDraw(Canvas canvas) {
60 | super.onDraw(canvas);
61 | mPathsDrawable.draw(canvas);
62 | }
63 |
64 | public void parserPaths(String... paths) {
65 | mPathsDrawable.parserPaths(paths);
66 | }
67 |
68 | public void parserColors(int... colors) {
69 | mPathsDrawable.parserColors(colors);
70 | }
71 |
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/scwang/smartrefresh/layout/header/bezierradar/WaveView.java:
--------------------------------------------------------------------------------
1 | package com.scwang.smartrefresh.layout.header.bezierradar;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.graphics.Path;
7 | import android.util.AttributeSet;
8 | import android.view.View;
9 |
10 | /**
11 | * Created by cjj on 2015/8/5.
12 | * 绘制贝塞尔来绘制波浪形
13 | */
14 | public class WaveView extends View {
15 |
16 | private int waveHeight;
17 | private int headHeight;
18 | private Path path;
19 | private Paint paint;
20 | private int mOffsetX = -1;
21 |
22 | public WaveView(Context context) {
23 | this(context, null, 0);
24 | }
25 |
26 | public WaveView(Context context, AttributeSet attrs) {
27 | this(context, attrs, 0);
28 | }
29 |
30 | public WaveView(Context context, AttributeSet attrs, int defStyleAttr) {
31 | super(context, attrs, defStyleAttr);
32 | initView();
33 | }
34 |
35 | private void initView() {
36 | path = new Path();
37 | paint = new Paint();
38 | paint.setColor(0xff1F2426);
39 | paint.setAntiAlias(true);
40 | }
41 |
42 | @Override
43 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
44 | setMeasuredDimension(resolveSize(getSuggestedMinimumWidth(), widthMeasureSpec),
45 | resolveSize(getSuggestedMinimumHeight(), heightMeasureSpec));
46 | }
47 |
48 | public void setWaveColor(int color) {
49 | paint.setColor(color);
50 | }
51 |
52 | public int getHeadHeight() {
53 | return headHeight;
54 | }
55 |
56 | public void setHeadHeight(int headHeight) {
57 | this.headHeight = headHeight;
58 | }
59 |
60 | public int getWaveHeight() {
61 | return waveHeight;
62 | }
63 |
64 | public void setWaveHeight(int waveHeight) {
65 | this.waveHeight = waveHeight;
66 | }
67 |
68 | @Override
69 | protected void onDraw(Canvas canvas) {
70 | super.onDraw(canvas);
71 | final int width = getWidth();
72 | //重置画笔
73 | path.reset();
74 | //绘制贝塞尔曲线
75 | path.lineTo(0, headHeight);
76 | path.quadTo(mOffsetX >= 0 ? (mOffsetX) : width / 2, headHeight + waveHeight, width, headHeight);
77 | path.lineTo(width, 0);
78 | canvas.drawPath(path, paint);
79 | }
80 |
81 | public void setWaveOffsetX(int offset) {
82 | mOffsetX = offset;
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/module_news/src/main/java/com/chs/news/NewsActivity.java:
--------------------------------------------------------------------------------
1 | package com.chs.news;
2 |
3 | import android.os.Bundle;
4 | import android.support.v7.widget.GridLayoutManager;
5 | import android.support.v7.widget.LinearLayoutManager;
6 | import android.support.v7.widget.RecyclerView;
7 |
8 | import com.alibaba.android.arouter.facade.annotation.Route;
9 | import com.chs.library.base.BaseActivity;
10 | import com.chs.library.util.LogUtils;
11 | import com.chs.library.widget.RecycleViewDivider;
12 | import com.chs.news.adapter.NewsListAdapter;
13 | import com.chs.news.module.NewsListEntity;
14 | import com.chs.news.net.NewsDataManager;
15 |
16 | import butterknife.BindView;
17 | import io.reactivex.Observer;
18 | import io.reactivex.disposables.Disposable;
19 |
20 | /**
21 | * 作者:chs on 2017-09-26 16:13
22 | * 邮箱:657083984@qq.com
23 | */
24 | @Route(path = "/news/NewsActivity")
25 | public class NewsActivity extends BaseActivity {
26 | @BindView(R2.id.recycler_view)
27 | RecyclerView mRecyclerView;
28 |
29 | @Override
30 | public int getLayoutId() {
31 | return R.layout.news_home;
32 | }
33 |
34 | @Override
35 | public void initViews(Bundle savedInstanceState) {
36 | GridLayoutManager manager = new GridLayoutManager(this,2);
37 | manager.setOrientation(LinearLayoutManager.VERTICAL);
38 | RecycleViewDivider divider = new RecycleViewDivider(this);
39 | mRecyclerView.addItemDecoration(divider);
40 | mRecyclerView.setLayoutManager(manager);
41 | loadData(true);
42 | }
43 |
44 | @Override
45 | protected void loadData(boolean isShowLoading) {
46 | super.loadData(isShowLoading);
47 | new NewsDataManager().getZhuHuList(new Observer() {
48 | @Override
49 | public void onSubscribe(Disposable d) {
50 |
51 | }
52 |
53 | @Override
54 | public void onNext(final NewsListEntity entity) {
55 | NewsListAdapter adapter = new NewsListAdapter(R.layout.news_item_list,entity.getT1348647909107());
56 | mRecyclerView.setAdapter(adapter);
57 | }
58 |
59 | @Override
60 | public void onError(Throwable e) {
61 | LogUtils.i("NewsActivity", "onError:" + e.getMessage());
62 | }
63 |
64 | @Override
65 | public void onComplete() {
66 | finishDialog();
67 | LogUtils.i("NewsActivity", "onComplete:" );
68 | }
69 | });
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/module_weather/src/main/java/com/chs/weather/WeatherActivity.java:
--------------------------------------------------------------------------------
1 | package com.chs.weather;
2 |
3 | import android.os.Bundle;
4 | import android.widget.TextView;
5 |
6 | import com.alibaba.android.arouter.facade.annotation.Route;
7 | import com.chs.library.base.BaseActivity;
8 | import com.chs.library.util.LogUtils;
9 | import com.chs.library.util.StatusBarUtil;
10 | import com.chs.weather.module.WeatherEntity;
11 | import com.chs.weather.net.WeatherDataManager;
12 |
13 | import butterknife.BindView;
14 | import io.reactivex.Observer;
15 | import io.reactivex.disposables.Disposable;
16 |
17 | @Route(path = "/weather/WeatherActivity")
18 | public class WeatherActivity extends BaseActivity {
19 | @BindView(R2.id.weather_tv_city)
20 | TextView mWeatherTvCity;
21 | @BindView(R2.id.weather_tv_temperature)
22 | TextView mWeatherTvTemperature;
23 | @BindView(R2.id.weather_tv_temperature_del)
24 | TextView mWeatherTvTemperatureDel;
25 |
26 | @Override
27 | protected void onCreate(Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | StatusBarUtil.setTransparent(this);
30 | loadData(true);
31 | }
32 |
33 | @Override
34 | public int getLayoutId() {
35 | return R.layout.weather_activity_weather;
36 | }
37 |
38 | @Override
39 | public void initViews(Bundle savedInstanceState) {
40 |
41 | }
42 |
43 | @Override
44 | protected void loadData(boolean isShowLoading) {
45 | super.loadData(isShowLoading);
46 | new WeatherDataManager().getWeather(new Observer() {
47 | @Override
48 | public void onSubscribe(Disposable d) {
49 |
50 | }
51 |
52 | @Override
53 | public void onNext(WeatherEntity weatherEntity) {
54 | WeatherEntity.ValueEntity valueEntity = weatherEntity.getValue().get(0);
55 | mWeatherTvCity.setText(valueEntity.getCity());
56 | mWeatherTvTemperature.setText(valueEntity.getRealtime().getTemp());
57 | mWeatherTvTemperatureDel.setText(valueEntity.getRealtime().getWeather());
58 | }
59 |
60 | @Override
61 | public void onError(Throwable e) {
62 | LogUtils.i("weatherEntity", "onError:" + e.getMessage());
63 | }
64 |
65 | @Override
66 | public void onComplete() {
67 | finishDialog();
68 | LogUtils.i("weatherEntity", "onComplete");
69 | }
70 | }, 101010100);
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/chs/library/base/BaseApplication.java:
--------------------------------------------------------------------------------
1 | package com.chs.library.base;
2 |
3 | import android.app.Activity;
4 | import android.app.Application;
5 | import android.content.Context;
6 | import android.util.DisplayMetrics;
7 |
8 | import java.util.Stack;
9 |
10 | /**
11 | * 作者:chs on 2017-08-03 14:04
12 | * 邮箱:657083984@qq.com
13 | */
14 |
15 | public class BaseApplication extends Application {
16 | private static BaseApplication instance;
17 | private Stack activityStack;
18 | public static BaseApplication getInstance(){
19 | return instance;
20 | }
21 | public static int H,W;
22 | @Override
23 | public void onCreate() {
24 | super.onCreate();
25 | instance = this;
26 | getScreen(this);
27 | }
28 | /**
29 | * 添加指定Activity到堆栈
30 | */
31 | public void addActivity(Activity activity) {
32 | if (activityStack == null) {
33 | activityStack = new Stack<>();
34 | }
35 | activityStack.add(activity);
36 | }
37 | /**
38 | * 获取当前Activity
39 | */
40 | public Activity currentActivity() {
41 | return activityStack.lastElement();
42 | }
43 |
44 | /**
45 | * 结束当前Activity
46 | */
47 | public void finishActivity() {
48 | Activity activity = activityStack.lastElement();
49 | finishActivity(activity);
50 | }
51 | /**
52 | * 结束指定的Activity
53 | */
54 | public void finishActivity(Activity activity) {
55 | if (activity != null) {
56 | activityStack.remove(activity);
57 | activity.finish();
58 | activity = null;
59 | }
60 | }
61 | /**
62 | * 结束指定Class的Activity
63 | */
64 | public void finishActivity(Class> cls) {
65 | for (Activity activity : activityStack) {
66 | if (activity.getClass().equals(cls)) {
67 | finishActivity(activity);
68 | return;
69 | }
70 | }
71 | }
72 |
73 | /**
74 | * 结束全部的Activity
75 | */
76 | public void finishAllActivity() {
77 | for (int i = 0, size = activityStack.size(); i < size; i++) {
78 | if (null != activityStack.get(i)) {
79 | activityStack.get(i).finish();
80 | }
81 | }
82 | activityStack.clear();
83 | }
84 | public void getScreen(Context aty) {
85 | DisplayMetrics dm = aty.getResources().getDisplayMetrics();
86 | H=dm.heightPixels;
87 | W=dm.widthPixels;
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/app/src/main/java/com/chs/moduledevelop/second/SecondFragment.java:
--------------------------------------------------------------------------------
1 | package com.chs.moduledevelop.second;
2 |
3 | import android.os.Bundle;
4 | import android.support.design.widget.TabLayout;
5 | import android.support.v4.app.Fragment;
6 | import android.support.v4.app.FragmentManager;
7 | import android.support.v4.app.FragmentStatePagerAdapter;
8 | import android.support.v4.view.ViewPager;
9 |
10 | import com.chs.library.base.BaseFragment;
11 | import com.chs.moduledevelop.R;
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | import butterknife.BindView;
17 | import butterknife.Unbinder;
18 |
19 | /**
20 | * 作者:chs on 2017-08-03 15:42
21 | * 邮箱:657083984@qq.com
22 | */
23 |
24 | public class SecondFragment extends BaseFragment {
25 | @BindView(R.id.tab)
26 | TabLayout mTab;
27 | @BindView(R.id.viewpager)
28 | ViewPager mViewpager;
29 | Unbinder unbinder;
30 | private String[] mTitles = new String[]{"Android","Java","Web","ios","python"};
31 | private List mFragmentList;
32 | public static SecondFragment newInstance() {
33 | return new SecondFragment();
34 | }
35 | private ContentAdapter mAdapter;
36 |
37 | @Override
38 | public int getLayoutResId() {
39 | return R.layout.fragment_second;
40 | }
41 |
42 | @Override
43 | public void finishCreateView(Bundle state) {
44 | initFragment();
45 | mAdapter = new ContentAdapter(getChildFragmentManager());
46 | mViewpager.setAdapter(mAdapter);
47 | mTab.setupWithViewPager(mViewpager);
48 | }
49 |
50 | private void initFragment() {
51 | mFragmentList = new ArrayList<>();
52 | mFragmentList.clear();
53 | for (String mTitle : mTitles) {
54 | Bundle bundle = new Bundle();
55 | bundle.putString("searchName", mTitle);
56 | mFragmentList.add(MovieFragment.newInstance(bundle));
57 | }
58 | }
59 |
60 | @Override
61 | public void onDestroyView() {
62 | super.onDestroyView();
63 | unbinder.unbind();
64 | }
65 | private class ContentAdapter extends FragmentStatePagerAdapter{
66 |
67 | public ContentAdapter(FragmentManager fm) {
68 | super(fm);
69 | }
70 |
71 | @Override
72 | public Fragment getItem(int position) {
73 | return mFragmentList.get(position);
74 | }
75 |
76 | @Override
77 | public int getCount() {
78 | return mTitles.length;
79 | }
80 |
81 | @Override
82 | public CharSequence getPageTitle(int position) {
83 | return mTitles[position];
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
19 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | 1.8
51 |
52 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/chs/library/base/adapter/util/MultiTypeDelegate.java:
--------------------------------------------------------------------------------
1 | package com.chs.library.base.adapter.util;
2 |
3 | import android.support.annotation.LayoutRes;
4 | import android.util.SparseIntArray;
5 |
6 | import java.util.List;
7 |
8 | import static com.chs.library.base.adapter.BaseMultiItemQuickAdapter.TYPE_NOT_FOUND;
9 |
10 | /**
11 | * help you to achieve multi type easily
12 | *
13 | * Created by tysheng
14 | * Date: 2017/4/6 08:41.
15 | * Email: tyshengsx@gmail.com
16 | *
17 | *
18 | * more information: https://github.com/CymChad/BaseRecyclerViewAdapterHelper/issues/968
19 | */
20 |
21 | public abstract class MultiTypeDelegate {
22 |
23 | private static final int DEFAULT_VIEW_TYPE = -0xff;
24 | private SparseIntArray layouts;
25 | private boolean autoMode, selfMode;
26 |
27 | public MultiTypeDelegate(SparseIntArray layouts) {
28 | this.layouts = layouts;
29 | }
30 |
31 | public MultiTypeDelegate() {
32 | }
33 |
34 | public final int getDefItemViewType(List data, int position) {
35 | T item = data.get(position);
36 | return item != null ? getItemType(item) : DEFAULT_VIEW_TYPE;
37 | }
38 |
39 | /**
40 | * get the item type from specific entity.
41 | *
42 | * @param t entity
43 | * @return item type
44 | */
45 | protected abstract int getItemType(T t);
46 |
47 | public final int getLayoutId(int viewType) {
48 | return this.layouts.get(viewType, TYPE_NOT_FOUND);
49 | }
50 |
51 | private void addItemType(int type, @LayoutRes int layoutResId) {
52 | if (this.layouts == null) {
53 | this.layouts = new SparseIntArray();
54 | }
55 | this.layouts.put(type, layoutResId);
56 | }
57 |
58 | /**
59 | * auto increase type vale, start from 0.
60 | *
61 | * @param layoutResIds layout id arrays
62 | * @return MultiTypeDelegate
63 | */
64 | public MultiTypeDelegate registerItemTypeAutoIncrease(@LayoutRes int... layoutResIds) {
65 | autoMode = true;
66 | checkMode(selfMode);
67 | for (int i = 0; i < layoutResIds.length; i++) {
68 | addItemType(i, layoutResIds[i]);
69 | }
70 | return this;
71 | }
72 |
73 | /**
74 | * set your own type one by one.
75 | *
76 | * @param type type value
77 | * @param layoutResId layout id
78 | * @return MultiTypeDelegate
79 | */
80 | public MultiTypeDelegate registerItemType(int type, @LayoutRes int layoutResId) {
81 | selfMode = true;
82 | checkMode(autoMode);
83 | addItemType(type, layoutResId);
84 | return this;
85 | }
86 |
87 | private void checkMode(boolean mode) {
88 | if (mode) {
89 | throw new RuntimeException("Don't mess two register mode");
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/youth/banner/Transformer.java:
--------------------------------------------------------------------------------
1 | package com.youth.banner;
2 |
3 | import android.support.v4.view.ViewPager.PageTransformer;
4 |
5 | import com.youth.banner.transformer.AccordionTransformer;
6 | import com.youth.banner.transformer.BackgroundToForegroundTransformer;
7 | import com.youth.banner.transformer.CubeInTransformer;
8 | import com.youth.banner.transformer.CubeOutTransformer;
9 | import com.youth.banner.transformer.DefaultTransformer;
10 | import com.youth.banner.transformer.DepthPageTransformer;
11 | import com.youth.banner.transformer.FlipHorizontalTransformer;
12 | import com.youth.banner.transformer.FlipVerticalTransformer;
13 | import com.youth.banner.transformer.ForegroundToBackgroundTransformer;
14 | import com.youth.banner.transformer.RotateDownTransformer;
15 | import com.youth.banner.transformer.RotateUpTransformer;
16 | import com.youth.banner.transformer.ScaleInOutTransformer;
17 | import com.youth.banner.transformer.StackTransformer;
18 | import com.youth.banner.transformer.TabletTransformer;
19 | import com.youth.banner.transformer.ZoomInTransformer;
20 | import com.youth.banner.transformer.ZoomOutSlideTransformer;
21 | import com.youth.banner.transformer.ZoomOutTranformer;
22 |
23 | public class Transformer {
24 | public static Class extends PageTransformer> Default = DefaultTransformer.class;
25 | public static Class extends PageTransformer> Accordion = AccordionTransformer.class;
26 | public static Class extends PageTransformer> BackgroundToForeground = BackgroundToForegroundTransformer.class;
27 | public static Class extends PageTransformer> ForegroundToBackground = ForegroundToBackgroundTransformer.class;
28 | public static Class extends PageTransformer> CubeIn = CubeInTransformer.class;
29 | public static Class extends PageTransformer> CubeOut = CubeOutTransformer.class;
30 | public static Class extends PageTransformer> DepthPage = DepthPageTransformer.class;
31 | public static Class extends PageTransformer> FlipHorizontal = FlipHorizontalTransformer.class;
32 | public static Class extends PageTransformer> FlipVertical = FlipVerticalTransformer.class;
33 | public static Class extends PageTransformer> RotateDown = RotateDownTransformer.class;
34 | public static Class extends PageTransformer> RotateUp = RotateUpTransformer.class;
35 | public static Class extends PageTransformer> ScaleInOut = ScaleInOutTransformer.class;
36 | public static Class extends PageTransformer> Stack = StackTransformer.class;
37 | public static Class extends PageTransformer> Tablet = TabletTransformer.class;
38 | public static Class extends PageTransformer> ZoomIn = ZoomInTransformer.class;
39 | public static Class extends PageTransformer> ZoomOut = ZoomOutTranformer.class;
40 | public static Class extends PageTransformer> ZoomOutSlide = ZoomOutSlideTransformer.class;
41 | }
42 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/chs/library/base/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package com.chs.library.base;
2 |
3 | import android.app.Dialog;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.widget.LinearLayout;
10 | import android.widget.TextView;
11 |
12 | import com.chs.library.R;
13 |
14 | import butterknife.ButterKnife;
15 | import butterknife.Unbinder;
16 |
17 | /**
18 | * 作者:chs on 2017-08-03 14:02
19 | * 邮箱:657083984@qq.com
20 | */
21 |
22 | public abstract class BaseActivity extends AppCompatActivity {
23 | private Dialog mLoadingDialog;
24 | private Unbinder bind;
25 |
26 | @Override
27 | protected void onCreate(@Nullable Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | //设置布局内容
30 | setContentView(getLayoutId());
31 | BaseApplication.getInstance().addActivity(this);
32 | bind = ButterKnife.bind(this);
33 | //初始化控件
34 | initViews(savedInstanceState);
35 | }
36 |
37 | @Override
38 | protected void onDestroy() {
39 | super.onDestroy();
40 | BaseApplication.getInstance().finishActivity(this);
41 | bind.unbind();
42 | }
43 |
44 | /**
45 | * 得到自定义的progressDialog
46 | *
47 | * @param msg
48 | */
49 | public void createLoadingDialog(String msg) {
50 | LayoutInflater inflater = LayoutInflater.from(this);
51 | View v = inflater.inflate(R.layout.loading_dialog, null);// 得到加载view
52 | LinearLayout layout = (LinearLayout) v.findViewById(R.id.dialog_view);// 加载布局
53 | TextView tipTextView = (TextView) v.findViewById(R.id.tipTextView);// 提示文字
54 | // 加载动画
55 | tipTextView.setText(msg);// 设置加载信息
56 | if (mLoadingDialog == null) {
57 | mLoadingDialog = new Dialog(this, R.style.MyDialog);// 创建自定义样式dialog
58 | // loadingDialog.setCancelable(true);// 不可以用“返回键”取消
59 | mLoadingDialog.setCanceledOnTouchOutside(false);
60 | mLoadingDialog.setContentView(layout, new LinearLayout.LayoutParams(
61 | LinearLayout.LayoutParams.MATCH_PARENT,
62 | LinearLayout.LayoutParams.MATCH_PARENT));// 设置布局
63 | mLoadingDialog.show();
64 | }
65 |
66 | }
67 |
68 | /**
69 | * 关闭自定义的progressDialog
70 | */
71 | public void finishDialog() {
72 | if (mLoadingDialog != null) {
73 | mLoadingDialog.dismiss();
74 | mLoadingDialog = null;
75 | }
76 | }
77 |
78 | /**
79 | * 设置布局layout
80 | *
81 | * @return
82 | */
83 | public abstract int getLayoutId();
84 |
85 | /**
86 | * 初始化views
87 | *
88 | * @param savedInstanceState
89 | */
90 | public abstract void initViews(Bundle savedInstanceState);
91 |
92 | /**
93 | * 加载数据
94 | */
95 | protected void loadData(boolean isShowLoading) {
96 | if (isShowLoading) {
97 | createLoadingDialog(getString(R.string.loading));
98 | }
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/scwang/smartrefresh/layout/api/RefreshKernel.java:
--------------------------------------------------------------------------------
1 | package com.scwang.smartrefresh.layout.api;
2 |
3 | import android.support.annotation.NonNull;
4 |
5 | /**
6 | * 刷新布局核心功能接口
7 | * 为功能复杂的 Header 或者 Footer 开放的接口
8 | * Created by SCWANG on 2017/5/26.
9 | */
10 |
11 | public interface RefreshKernel {
12 |
13 | @NonNull
14 | RefreshLayout getRefreshLayout();
15 | @NonNull
16 | RefreshContent getRefreshContent();
17 |
18 | //
19 | RefreshKernel setStatePullUpToLoad() ;
20 | RefreshKernel setStateReleaseToLoad() ;
21 | RefreshKernel setStateReleaseToRefresh() ;
22 | RefreshKernel setStatePullDownToRefresh() ;
23 | RefreshKernel setStatePullDownCanceled() ;
24 | RefreshKernel setStatePullUpCanceled() ;
25 | RefreshKernel setStateLoding() ;
26 | RefreshKernel setStateRefresing() ;
27 | RefreshKernel setStateLodingFinish() ;
28 | RefreshKernel setStateRefresingFinish() ;
29 | RefreshKernel resetStatus() ;
30 | //
31 |
32 | //
33 |
34 | /**
35 | * 结束视图位移(调用之后,如果没有在初始位移状态,会执行动画回到初始位置)
36 | * moveSpinner 的取名来自 谷歌官方的 @{@link android.support.v4.widget.SwipeRefreshLayout#moveSpinner(float)}
37 | */
38 | RefreshKernel overSpinner() ;
39 |
40 | /**
41 | * 移动视图到预设距离(dy 会被内部函数计算,将会出现无限接近最大值(height+extendHeader)的阻尼效果)
42 | * moveSpinner 的取名来自 谷歌官方的 @{@link android.support.v4.widget.SwipeRefreshLayout#moveSpinner(float)}
43 | * @param dy 距离 (px) 大于0表示下拉 小于0表示上啦
44 | */
45 | RefreshKernel moveSpinnerInfinitely(float dy);
46 |
47 | /**
48 | * 移动视图到指定位置
49 | * moveSpinner 的取名来自 谷歌官方的 @{@link android.support.v4.widget.SwipeRefreshLayout#moveSpinner(float)}
50 | * @param spinner 位置 (px)
51 | * @param isAnimator 标记是否是动画执行
52 | */
53 | RefreshKernel moveSpinner(int spinner, boolean isAnimator);
54 |
55 | /**
56 | * 执行动画使视图位移到指定的 位置
57 | * moveSpinner 的取名来自 谷歌官方的 @{@link android.support.v4.widget.SwipeRefreshLayout#moveSpinner(float)}
58 | * @param endSpinner 指定的结束位置 (px)
59 | */
60 | RefreshKernel animSpinner(int endSpinner);
61 |
62 | /**
63 | * 回弹动画
64 | * @param bounceSpinner 回弹的最大位置 (px)
65 | */
66 | RefreshKernel animSpinnerBounce(int bounceSpinner);
67 |
68 | /**
69 | * 获取 Spinner
70 | */
71 | int getSpinner();
72 | //
73 |
74 | //
75 |
76 | /**
77 | * 指定在下拉时候为 Header 绘制背景
78 | * @param backgroundColor 背景颜色
79 | */
80 | RefreshKernel requestDrawBackgoundForHeader(int backgroundColor);
81 | /**
82 | * 指定在下拉时候为 Footer 绘制背景
83 | * @param backgroundColor 背景颜色
84 | */
85 | RefreshKernel requestDrawBackgoundForFooter(int backgroundColor);
86 | /**
87 | * 请求事件
88 | */
89 | RefreshKernel requestHeaderNeedTouchEventWhenRefreshing(boolean request);
90 | /**
91 | * 请求事件
92 | */
93 | RefreshKernel requestFooterNeedTouchEventWhenLoading(boolean request);
94 | /**
95 | * 请求重新测量
96 | */
97 | RefreshKernel requestRemeasureHeightForHeader();
98 | /**
99 | * 请求重新测量
100 | */
101 | RefreshKernel requestRemeasureHeightForFooter();
102 | //
103 | }
104 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/scwang/smartrefresh/layout/footer/FalsifyFooter.java:
--------------------------------------------------------------------------------
1 | package com.scwang.smartrefresh.layout.footer;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.content.Context;
5 | import android.graphics.Canvas;
6 | import android.graphics.DashPathEffect;
7 | import android.graphics.Paint;
8 | import android.os.Build;
9 | import android.support.annotation.Nullable;
10 | import android.support.annotation.RequiresApi;
11 | import android.util.AttributeSet;
12 | import android.view.Gravity;
13 | import android.widget.TextView;
14 |
15 | import com.scwang.smartrefresh.layout.api.RefreshFooter;
16 | import com.scwang.smartrefresh.layout.header.FalsifyHeader;
17 | import com.scwang.smartrefresh.layout.util.DensityUtil;
18 |
19 | import static android.view.View.MeasureSpec.EXACTLY;
20 | import static android.view.View.MeasureSpec.makeMeasureSpec;
21 |
22 | /**
23 | * 虚假的 Footer
24 | * 用于 正真的 Footer 在 RefreshLayout 外部时,
25 | * Created by SCWANG on 2017/6/14.
26 | */
27 |
28 | public class FalsifyFooter extends FalsifyHeader implements RefreshFooter {
29 |
30 | //
31 | public FalsifyFooter(Context context) {
32 | super(context);
33 | }
34 |
35 | public FalsifyFooter(Context context, AttributeSet attrs) {
36 | super(context, attrs);
37 | }
38 |
39 | public FalsifyFooter(Context context, AttributeSet attrs, int defStyleAttr) {
40 | super(context, attrs, defStyleAttr);
41 | }
42 |
43 | @RequiresApi(Build.VERSION_CODES.LOLLIPOP)
44 | public FalsifyFooter(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
45 | super(context, attrs, defStyleAttr, defStyleRes);
46 | }
47 |
48 | @Override@SuppressLint("DrawAllocation")
49 | protected void onDraw(Canvas canvas) {
50 | super.onDraw(canvas);
51 | if (isInEditMode()) {//这段代码在运行时不会执行,只会在Studio编辑预览时运行,不用在意性能问题
52 | int d = DensityUtil.dp2px(5);
53 |
54 | Paint paint = new Paint();
55 | paint.setStyle(Paint.Style.STROKE);
56 | paint.setColor(0x44ffffff);
57 | paint.setStrokeWidth(DensityUtil.dp2px(1));
58 | paint.setPathEffect(new DashPathEffect(new float[]{d, d, d, d}, 1));
59 | canvas.drawRect(d, d, getWidth() - d, getBottom() - d, paint);
60 |
61 | TextView textView = new TextView(getContext());
62 | textView.setText(getClass().getSimpleName()+" 虚假区域\n运行时代表上拉Footer的高度【" + DensityUtil.px2dp(getHeight()) + "dp】\n而不会显示任何东西");
63 | textView.setTextColor(0x44ffffff);
64 | textView.setGravity(Gravity.CENTER);
65 | textView.measure(makeMeasureSpec(getWidth(), EXACTLY), makeMeasureSpec(getHeight(), EXACTLY));
66 | textView.layout(0, 0, getWidth(), getHeight());
67 | textView.draw(canvas);
68 | }
69 | }
70 |
71 |
72 | //
73 |
74 | //
75 |
76 | @Override
77 | public void onPullingUp(float percent, int offset, int footerHeight, int extendHeight) {
78 |
79 | }
80 |
81 | @Override
82 | public void onPullReleasing(float percent, int offset, int footerHeight, int extendHeight) {
83 |
84 | }
85 |
86 | @Override
87 | public boolean setLoadmoreFinished(boolean finished) {
88 | return false;
89 | }
90 |
91 | //
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/scwang/smartrefresh/layout/impl/RefreshHeaderWrapper.java:
--------------------------------------------------------------------------------
1 | package com.scwang.smartrefresh.layout.impl;
2 |
3 | import android.support.annotation.NonNull;
4 | import android.view.View;
5 | import android.view.ViewGroup;
6 |
7 | import com.scwang.smartrefresh.layout.SmartRefreshLayout;
8 | import com.scwang.smartrefresh.layout.api.RefreshHeader;
9 | import com.scwang.smartrefresh.layout.api.RefreshKernel;
10 | import com.scwang.smartrefresh.layout.api.RefreshLayout;
11 | import com.scwang.smartrefresh.layout.constant.RefreshState;
12 | import com.scwang.smartrefresh.layout.constant.SpinnerStyle;
13 |
14 | /**
15 | * 刷新头部包装
16 | * Created by SCWANG on 2017/5/26.
17 | */
18 |
19 | public class RefreshHeaderWrapper implements RefreshHeader {
20 |
21 | private static final String TAG_REFRESH_HEADER_WRAPPER = "TAG_REFRESH_HEADER_WRAPPER";
22 |
23 | private View mWrapperView;
24 | private SpinnerStyle mSpinnerStyle;
25 |
26 | public RefreshHeaderWrapper(View wrapper) {
27 | this.mWrapperView = wrapper;
28 | this.mWrapperView.setTag(TAG_REFRESH_HEADER_WRAPPER.hashCode(), TAG_REFRESH_HEADER_WRAPPER);
29 | }
30 |
31 | public static boolean isTagedHeader(View view) {
32 | return TAG_REFRESH_HEADER_WRAPPER.equals(view.getTag(TAG_REFRESH_HEADER_WRAPPER.hashCode()));
33 | }
34 | @NonNull
35 | public View getView() {
36 | return mWrapperView;
37 | }
38 |
39 | @Override
40 | public int onFinish(RefreshLayout layout, boolean success) {
41 | return 0;
42 | }
43 |
44 | @Override
45 | public void setPrimaryColors(int... colors) {
46 |
47 | }
48 |
49 | @NonNull
50 | @Override
51 | public SpinnerStyle getSpinnerStyle() {
52 | if (mSpinnerStyle != null) {
53 | return mSpinnerStyle;
54 | }
55 | ViewGroup.LayoutParams params = mWrapperView.getLayoutParams();
56 | if (params instanceof SmartRefreshLayout.LayoutParams) {
57 | mSpinnerStyle = ((SmartRefreshLayout.LayoutParams) params).spinnerStyle;
58 | if (mSpinnerStyle != null) {
59 | return mSpinnerStyle;
60 | }
61 | }
62 | if (params != null) {
63 | if (params.height == ViewGroup.LayoutParams.MATCH_PARENT) {
64 | return mSpinnerStyle = SpinnerStyle.Scale;
65 | }
66 | }
67 | return mSpinnerStyle = SpinnerStyle.Translate;
68 | }
69 |
70 | @Override
71 | public void onInitialized(RefreshKernel kernel, int height, int extendHeight) {
72 | ViewGroup.LayoutParams params = mWrapperView.getLayoutParams();
73 | if (params instanceof SmartRefreshLayout.LayoutParams) {
74 | kernel.requestDrawBackgoundForHeader(((SmartRefreshLayout.LayoutParams) params).backgroundColor);
75 | }
76 | }
77 |
78 | @Override
79 | public boolean isSupportHorizontalDrag() {
80 | return false;
81 | }
82 |
83 | @Override
84 | public void onHorizontalDrag(float percentX, int offsetX, int offsetMax) {
85 | }
86 |
87 | @Override
88 | public void onPullingDown(float percent, int offset, int headHeight, int extendHeight) {
89 |
90 | }
91 |
92 | @Override
93 | public void onReleasing(float percent, int offset, int headHeight, int extendHeight) {
94 |
95 | }
96 |
97 | @Override
98 | public void onStartAnimator(RefreshLayout layout, int headHeight, int extendHeight) {
99 |
100 | }
101 |
102 | @Override
103 | public void onStateChanged(RefreshLayout refreshLayout, RefreshState oldState, RefreshState newState) {
104 |
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/chs/library/base/BaseFragment.java:
--------------------------------------------------------------------------------
1 | package com.chs.library.base;
2 |
3 | import android.app.Dialog;
4 | import android.os.Bundle;
5 | import android.support.annotation.LayoutRes;
6 | import android.support.annotation.Nullable;
7 | import android.support.v4.app.Fragment;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.LinearLayout;
12 | import android.widget.TextView;
13 |
14 | import com.chs.library.R;
15 |
16 | import butterknife.ButterKnife;
17 | import butterknife.Unbinder;
18 |
19 | /**
20 | * 作者:chs on 2017-08-03 15:46
21 | * 邮箱:657083984@qq.com
22 | */
23 |
24 | public abstract class BaseFragment extends Fragment {
25 | /**
26 | * Fragment当前状态是否可见
27 | */
28 | private Dialog mLoadingDialog;
29 | private Unbinder bind;
30 |
31 | public abstract
32 | @LayoutRes
33 | int getLayoutResId();
34 |
35 | @Override
36 | public void setUserVisibleHint(boolean isVisibleToUser) {
37 | super.setUserVisibleHint(isVisibleToUser);
38 | if (isVisibleToUser) {
39 | onVisible();
40 | }
41 | }
42 |
43 | @Override
44 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle state) {
45 | return inflater.inflate(getLayoutResId(), container, false);
46 | }
47 |
48 | @Override
49 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
50 | super.onViewCreated(view, savedInstanceState);
51 | bind = ButterKnife.bind(this, view);
52 | finishCreateView(savedInstanceState);
53 | }
54 |
55 | @Override
56 | public void onDestroyView() {
57 | super.onDestroyView();
58 | if (bind != null) {
59 | bind.unbind();
60 | }
61 | }
62 |
63 | /**
64 | * 初始化views
65 | *
66 | * @param state
67 | */
68 | public abstract void finishCreateView(Bundle state);
69 |
70 | /**
71 | * 加载数据
72 | */
73 | protected void loadData(boolean isShowLoading) {
74 | if (isShowLoading) {
75 | createLoadingDialog(getString(R.string.loading));
76 | }
77 | }
78 |
79 | /**
80 | * 可见
81 | */
82 | protected void onVisible() {
83 |
84 | }
85 |
86 | /**
87 | * 得到自定义的progressDialog
88 | *
89 | * @param msg
90 | */
91 | public void createLoadingDialog(String msg) {
92 | LayoutInflater inflater = LayoutInflater.from(getActivity());
93 | View v = inflater.inflate(R.layout.loading_dialog, null);// 得到加载view
94 | LinearLayout layout = (LinearLayout) v.findViewById(R.id.dialog_view);// 加载布局
95 | TextView tipTextView = (TextView) v.findViewById(R.id.tipTextView);// 提示文字
96 | // 加载动画
97 | tipTextView.setText(msg);// 设置加载信息
98 | if (mLoadingDialog == null) {
99 | mLoadingDialog = new Dialog(getActivity(), R.style.MyDialog);// 创建自定义样式dialog
100 | // loadingDialog.setCancelable(true);// 不可以用“返回键”取消
101 | mLoadingDialog.setCanceledOnTouchOutside(false);
102 | mLoadingDialog.setContentView(layout, new LinearLayout.LayoutParams(
103 | LinearLayout.LayoutParams.MATCH_PARENT,
104 | LinearLayout.LayoutParams.MATCH_PARENT));// 设置布局
105 | mLoadingDialog.show();
106 | }
107 |
108 | }
109 |
110 | /**
111 | * 关闭自定义的progressDialog
112 | */
113 | public void finishDialog() {
114 | if (mLoadingDialog != null) {
115 | mLoadingDialog.dismiss();
116 | mLoadingDialog = null;
117 | }
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/module_library/src/main/res/layout/banner.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
14 |
15 |
19 |
20 |
29 |
30 |
41 |
42 |
50 |
51 |
64 |
65 |
70 |
71 |
79 |
80 |
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/scwang/smartrefresh/layout/impl/RefreshFooterWrapper.java:
--------------------------------------------------------------------------------
1 | package com.scwang.smartrefresh.layout.impl;
2 |
3 | import android.support.annotation.NonNull;
4 | import android.view.View;
5 | import android.view.ViewGroup;
6 |
7 | import com.scwang.smartrefresh.layout.SmartRefreshLayout;
8 | import com.scwang.smartrefresh.layout.api.RefreshFooter;
9 | import com.scwang.smartrefresh.layout.api.RefreshKernel;
10 | import com.scwang.smartrefresh.layout.api.RefreshLayout;
11 | import com.scwang.smartrefresh.layout.constant.RefreshState;
12 | import com.scwang.smartrefresh.layout.constant.SpinnerStyle;
13 |
14 | /**
15 | * 刷新底部包装
16 | * Created by SCWANG on 2017/5/26.
17 | */
18 |
19 | public class RefreshFooterWrapper implements RefreshFooter {
20 |
21 | private static final String TAG_REFRESH_FOOTER_WRAPPER = "TAG_REFRESH_FOOTER_WRAPPER";
22 |
23 | private View mWrapperView;
24 | private SpinnerStyle mSpinnerStyle;
25 |
26 | public RefreshFooterWrapper(View wrapper) {
27 | this.mWrapperView = wrapper;
28 | this.mWrapperView.setTag(TAG_REFRESH_FOOTER_WRAPPER.hashCode(), TAG_REFRESH_FOOTER_WRAPPER);
29 | }
30 |
31 | public static boolean isTagedFooter(View view) {
32 | return TAG_REFRESH_FOOTER_WRAPPER.equals(view.getTag(TAG_REFRESH_FOOTER_WRAPPER.hashCode()));
33 | }
34 |
35 | @NonNull
36 | public View getView() {
37 | return mWrapperView;
38 | }
39 |
40 | @Override
41 | public int onFinish(RefreshLayout layout, boolean success) {
42 | return 0;
43 | }
44 |
45 | @Override
46 | public void setPrimaryColors(int... colors) {
47 |
48 | }
49 |
50 | @Override
51 | public SpinnerStyle getSpinnerStyle() {
52 | if (mSpinnerStyle != null) {
53 | return mSpinnerStyle;
54 | }
55 | ViewGroup.LayoutParams params = mWrapperView.getLayoutParams();
56 | if (params instanceof SmartRefreshLayout.LayoutParams) {
57 | mSpinnerStyle = ((SmartRefreshLayout.LayoutParams) params).spinnerStyle;
58 | if (mSpinnerStyle != null) {
59 | return mSpinnerStyle;
60 | }
61 | }
62 | if (params != null) {
63 | if (params.height == 0) {
64 | return mSpinnerStyle = SpinnerStyle.Scale;
65 | }
66 | }
67 | return mSpinnerStyle = SpinnerStyle.Translate;
68 | }
69 |
70 | @Override
71 | public void onInitialized(RefreshKernel kernel, int height, int extendHeight) {
72 | ViewGroup.LayoutParams params = mWrapperView.getLayoutParams();
73 | if (params instanceof SmartRefreshLayout.LayoutParams) {
74 | kernel.requestDrawBackgoundForFooter(((SmartRefreshLayout.LayoutParams) params).backgroundColor);
75 | }
76 | }
77 |
78 | @Override
79 | public boolean isSupportHorizontalDrag() {
80 | return false;
81 | }
82 |
83 | @Override
84 | public void onHorizontalDrag(float percentX, int offsetX, int offsetMax) {
85 | }
86 |
87 | @Override
88 | public void onPullingUp(float percent, int offset, int footerHeight, int extendHeight) {
89 |
90 | }
91 |
92 | @Override
93 | public void onPullReleasing(float percent, int offset, int footerHeight, int extendHeight) {
94 |
95 | }
96 |
97 | @Override
98 | public void onStartAnimator(RefreshLayout layout, int footerHeight, int extendHeight) {
99 |
100 | }
101 |
102 | @Override
103 | public void onStateChanged(RefreshLayout refreshLayout, RefreshState oldState, RefreshState newState) {
104 |
105 | }
106 |
107 | @Override
108 | public boolean setLoadmoreFinished(boolean finished) {
109 | return false;
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/module_library/src/main/java/com/chs/library/base/adapter/loadmore/LoadMoreView.java:
--------------------------------------------------------------------------------
1 | package com.chs.library.base.adapter.loadmore;
2 |
3 | import android.support.annotation.IdRes;
4 | import android.support.annotation.LayoutRes;
5 |
6 | import com.chs.library.base.adapter.BaseViewHolder;
7 |
8 |
9 | /**
10 | * Created by BlingBling on 2016/11/11.
11 | */
12 |
13 | public abstract class LoadMoreView {
14 |
15 | public static final int STATUS_DEFAULT = 1;
16 | public static final int STATUS_LOADING = 2;
17 | public static final int STATUS_FAIL = 3;
18 | public static final int STATUS_END = 4;
19 |
20 | private int mLoadMoreStatus = STATUS_DEFAULT;
21 | private boolean mLoadMoreEndGone = false;
22 |
23 | public void setLoadMoreStatus(int loadMoreStatus) {
24 | this.mLoadMoreStatus = loadMoreStatus;
25 | }
26 |
27 | public int getLoadMoreStatus() {
28 | return mLoadMoreStatus;
29 | }
30 |
31 | public void convert(BaseViewHolder holder) {
32 | switch (mLoadMoreStatus) {
33 | case STATUS_LOADING:
34 | visibleLoading(holder, true);
35 | visibleLoadFail(holder, false);
36 | visibleLoadEnd(holder, false);
37 | break;
38 | case STATUS_FAIL:
39 | visibleLoading(holder, false);
40 | visibleLoadFail(holder, true);
41 | visibleLoadEnd(holder, false);
42 | break;
43 | case STATUS_END:
44 | visibleLoading(holder, false);
45 | visibleLoadFail(holder, false);
46 | visibleLoadEnd(holder, true);
47 | break;
48 | case STATUS_DEFAULT:
49 | visibleLoading(holder, false);
50 | visibleLoadFail(holder, false);
51 | visibleLoadEnd(holder, false);
52 | break;
53 | }
54 | }
55 |
56 | private void visibleLoading(BaseViewHolder holder, boolean visible) {
57 | holder.setVisible(getLoadingViewId(), visible);
58 | }
59 |
60 | private void visibleLoadFail(BaseViewHolder holder, boolean visible) {
61 | holder.setVisible(getLoadFailViewId(), visible);
62 | }
63 |
64 | private void visibleLoadEnd(BaseViewHolder holder, boolean visible) {
65 | final int loadEndViewId = getLoadEndViewId();
66 | if (loadEndViewId != 0) {
67 | holder.setVisible(loadEndViewId, visible);
68 | }
69 | }
70 |
71 | public final void setLoadMoreEndGone(boolean loadMoreEndGone) {
72 | this.mLoadMoreEndGone = loadMoreEndGone;
73 | }
74 |
75 | public final boolean isLoadEndMoreGone() {
76 | if (getLoadEndViewId() == 0) {
77 | return true;
78 | }
79 | return mLoadMoreEndGone;
80 | }
81 |
82 | /**
83 | * No more data is hidden
84 | *
85 | * @return true for no more data hidden load more
86 | * @deprecated Use {@link BaseQuickAdapter#loadMoreEnd(boolean)} instead.
87 | */
88 | @Deprecated
89 | public boolean isLoadEndGone() {
90 | return mLoadMoreEndGone;
91 | }
92 |
93 | /**
94 | * load more layout
95 | *
96 | * @return
97 | */
98 | public abstract
99 | @LayoutRes
100 | int getLayoutId();
101 |
102 | /**
103 | * loading view
104 | *
105 | * @return
106 | */
107 | protected abstract
108 | @IdRes
109 | int getLoadingViewId();
110 |
111 | /**
112 | * load fail view
113 | *
114 | * @return
115 | */
116 | protected abstract
117 | @IdRes
118 | int getLoadFailViewId();
119 |
120 | /**
121 | * load end view, you can return 0
122 | *
123 | * @return
124 | */
125 | protected abstract
126 | @IdRes
127 | int getLoadEndViewId();
128 | }
129 |
--------------------------------------------------------------------------------