diff --git a/app/src/main/java/com/zhoujinlong/ui/activity/SplashActivity.java b/app/src/main/java/com/zhoujinlong/ui/activity/SplashActivity.java index 779f84f..87eff37 100644 --- a/app/src/main/java/com/zhoujinlong/ui/activity/SplashActivity.java +++ b/app/src/main/java/com/zhoujinlong/ui/activity/SplashActivity.java @@ -6,7 +6,7 @@ import android.widget.ImageView; import com.android.core.ui.BaseActivity; -import com.android.core.util.StatusBarUtil; +import com.android.core.control.StatusBarUtil; import com.zhoujinlong.R; import com.zhoujinlong.util.AnimationUtil; diff --git a/app/src/main/java/com/zhoujinlong/ui/fragment/HomeFragment.java b/app/src/main/java/com/zhoujinlong/ui/fragment/HomeFragment.java index 78195a1..607861e 100644 --- a/app/src/main/java/com/zhoujinlong/ui/fragment/HomeFragment.java +++ b/app/src/main/java/com/zhoujinlong/ui/fragment/HomeFragment.java @@ -3,14 +3,11 @@ import android.os.Bundle; import android.os.Handler; -import android.support.v7.widget.LinearLayoutManager; import android.view.View; import com.android.core.ui.BaseFragment; -import com.android.core.util.StatusBarUtil; +import com.android.core.control.XRecyclerViewControl; import com.android.core.widget.CustomViewpager; -import com.android.core.widget.SpacesItemDecoration; -import com.jcodecraeer.xrecyclerview.ProgressStyle; import com.jcodecraeer.xrecyclerview.XRecyclerView; import com.zhoujinlong.R; import com.zhoujinlong.adapter.CustomViewPageAdapter; @@ -49,7 +46,6 @@ protected int getLayoutResource() { @Override protected void onInitView() { - StatusBarUtil.setTransparent(getActivity()); } @Override @@ -70,15 +66,7 @@ public static List getAdData() { public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity()); - layoutManager.setOrientation(LinearLayoutManager.VERTICAL); - //分割线 - mRecyclerView.addItemDecoration(new SpacesItemDecoration(1)); - mRecyclerView.setLayoutManager(layoutManager); - - mRecyclerView.setRefreshProgressStyle(ProgressStyle.BallSpinFadeLoader); - mRecyclerView.setLoadingMoreProgressStyle(ProgressStyle.BallRotate); - mRecyclerView.setArrowImageView(R.drawable.abc_icon_down_arrow); + XRecyclerViewControl.init().setLinearLayout(getActivity(), mRecyclerView); View header = View.inflate(getActivity(), R.layout.abc_viewpager_view, null); mViewpage = (CustomViewpager) header.findViewById(R.id.viewpager); @@ -111,6 +99,7 @@ public void onLoadComplete() { */ @Override public void onShowListData(Classify listData, boolean isMore) { + hideLoadingView(); if (listData.isStatus()) { if (!isMore) classifys.clear(); @@ -121,6 +110,7 @@ public void onShowListData(Classify listData, boolean isMore) { @Override public void onRefresh() { + showLoadingView(); new Handler().postDelayed(new Runnable() { @Override public void run() { diff --git a/app/src/main/java/com/zhoujinlong/ui/fragment/PersonFragment.java b/app/src/main/java/com/zhoujinlong/ui/fragment/PersonFragment.java index 87f260d..f5275a4 100644 --- a/app/src/main/java/com/zhoujinlong/ui/fragment/PersonFragment.java +++ b/app/src/main/java/com/zhoujinlong/ui/fragment/PersonFragment.java @@ -6,7 +6,7 @@ import android.widget.ScrollView; import com.android.core.ui.BaseFragment; -import com.android.core.util.StatusBarUtil; +import com.android.core.control.StatusBarUtil; import com.zhoujinlong.R; import butterknife.Bind; diff --git a/app/src/main/java/com/zhoujinlong/ui/widget/TitleBar.java b/app/src/main/java/com/zhoujinlong/ui/widget/TitleBar.java index 882158e..4677197 100644 --- a/app/src/main/java/com/zhoujinlong/ui/widget/TitleBar.java +++ b/app/src/main/java/com/zhoujinlong/ui/widget/TitleBar.java @@ -11,7 +11,7 @@ import android.widget.RelativeLayout; import android.widget.TextView; -import com.android.core.util.ScreenUtil; +import com.android.core.control.ScreenUtil; import com.zhoujinlong.R; /** diff --git a/app/src/main/res/layout/abc_viewpager_view.xml b/app/src/main/res/layout/abc_viewpager_view.xml index 5c00e17..bc3e185 100644 --- a/app/src/main/res/layout/abc_viewpager_view.xml +++ b/app/src/main/res/layout/abc_viewpager_view.xml @@ -6,6 +6,6 @@ diff --git a/app/src/main/res/layout/item_compete_classitfy.xml b/app/src/main/res/layout/item_compete_classitfy.xml index 6dee8a2..af89dac 100644 --- a/app/src/main/res/layout/item_compete_classitfy.xml +++ b/app/src/main/res/layout/item_compete_classitfy.xml @@ -7,7 +7,7 @@ diff --git a/core/build.gradle b/core/build.gradle index 0fa3ef1..a3da697 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -30,7 +30,7 @@ dependencies { compile 'com.jcodecraeer:xrecyclerview:1.2.7' compile 'com.jakewharton:butterknife:7.0.1' - // Glide + compile 'com.github.ybq:Android-SpinKit:1.0.1' compile 'com.github.bumptech.glide:glide:3.7.0' //squareup diff --git a/core/src/main/java/com/android/core/util/MobileUtil.java b/core/src/main/java/com/android/core/control/MobileControl.java similarity index 91% rename from core/src/main/java/com/android/core/util/MobileUtil.java rename to core/src/main/java/com/android/core/control/MobileControl.java index aecb804..d627415 100644 --- a/core/src/main/java/com/android/core/util/MobileUtil.java +++ b/core/src/main/java/com/android/core/control/MobileControl.java @@ -1,4 +1,4 @@ -package com.android.core.util; +package com.android.core.control; import android.content.Context; import android.content.Intent; @@ -9,7 +9,7 @@ * @date: 2016-05-26 17:47 * @GitHub: https://github.com/meikoz */ -public class MobileUtil { +public class MobileControl { //调起拨号键 public static void startPanel(Context context, String phoneNumber) { Intent intent = new Intent(Intent.ACTION_DIAL); diff --git a/core/src/main/java/com/android/core/util/NetWorkUtil.java b/core/src/main/java/com/android/core/control/NetWorkControl.java similarity index 96% rename from core/src/main/java/com/android/core/util/NetWorkUtil.java rename to core/src/main/java/com/android/core/control/NetWorkControl.java index a43ae6c..77c2075 100644 --- a/core/src/main/java/com/android/core/util/NetWorkUtil.java +++ b/core/src/main/java/com/android/core/control/NetWorkControl.java @@ -1,4 +1,4 @@ -package com.android.core.util; +package com.android.core.control; import android.content.Context; import android.net.ConnectivityManager; @@ -12,7 +12,7 @@ * @date: 2016-05-31 14:15 * @GitHub: https://github.com/meikoz */ -public class NetWorkUtil { +public class NetWorkControl { /** * 检测网络是否连接 diff --git a/core/src/main/java/com/android/core/util/ScreenUtil.java b/core/src/main/java/com/android/core/control/ScreenUtil.java similarity index 98% rename from core/src/main/java/com/android/core/util/ScreenUtil.java rename to core/src/main/java/com/android/core/control/ScreenUtil.java index e236239..a18c119 100644 --- a/core/src/main/java/com/android/core/util/ScreenUtil.java +++ b/core/src/main/java/com/android/core/control/ScreenUtil.java @@ -1,4 +1,4 @@ -package com.android.core.util; +package com.android.core.control; import android.content.Context; import android.content.res.TypedArray; diff --git a/core/src/main/java/com/android/core/util/StatusBarUtil.java b/core/src/main/java/com/android/core/control/StatusBarUtil.java similarity index 99% rename from core/src/main/java/com/android/core/util/StatusBarUtil.java rename to core/src/main/java/com/android/core/control/StatusBarUtil.java index cc0a4b2..ffd1f83 100644 --- a/core/src/main/java/com/android/core/util/StatusBarUtil.java +++ b/core/src/main/java/com/android/core/control/StatusBarUtil.java @@ -1,4 +1,4 @@ -package com.android.core.util; +package com.android.core.control; import android.annotation.TargetApi; import android.app.Activity; diff --git a/core/src/main/java/com/android/core/control/XRecyclerViewControl.java b/core/src/main/java/com/android/core/control/XRecyclerViewControl.java new file mode 100644 index 0000000..cfd73b2 --- /dev/null +++ b/core/src/main/java/com/android/core/control/XRecyclerViewControl.java @@ -0,0 +1,41 @@ +package com.android.core.control; + +import android.content.Context; +import android.support.v7.widget.LinearLayoutManager; + +import com.android.core.R; +import com.jcodecraeer.xrecyclerview.ProgressStyle; +import com.jcodecraeer.xrecyclerview.XRecyclerView; + +/** + * @author: 蜡笔小新 + * @date: 2016-06-01 17:42 + * @GitHub: https://github.com/meikoz + */ +public class XRecyclerViewControl { + static XRecyclerViewControl ourInstance; + + public XRecyclerViewControl() { + + } + + public static XRecyclerViewControl init() { + if (ourInstance == null) + ourInstance = new XRecyclerViewControl(); + return ourInstance; + } + + + public void setLinearLayout(Context context, XRecyclerView mRecy) { + LinearLayoutManager layoutManager = new LinearLayoutManager(context); + layoutManager.setOrientation(LinearLayoutManager.VERTICAL); + + mRecy.setLayoutManager(layoutManager); + //设置分隔线 +// mRecy.addItemDecoration(new SpacesItemDecoration(1)); + mRecy.setRefreshProgressStyle(ProgressStyle.BallSpinFadeLoader); + mRecy.setLoadingMoreProgressStyle(ProgressStyle.BallRotate); + mRecy.setArrowImageView(R.drawable.abc_icon_down_arrow); + } + +} diff --git a/core/src/main/java/com/android/core/model/http/HttpCacheInterceptor.java b/core/src/main/java/com/android/core/model/http/HttpCacheInterceptor.java index bab2459..ee927db 100644 --- a/core/src/main/java/com/android/core/model/http/HttpCacheInterceptor.java +++ b/core/src/main/java/com/android/core/model/http/HttpCacheInterceptor.java @@ -3,7 +3,7 @@ import android.util.Log; import com.android.core.MainApp; -import com.android.core.util.NetWorkUtil; +import com.android.core.control.NetWorkControl; import java.io.IOException; @@ -22,7 +22,7 @@ public class HttpCacheInterceptor implements Interceptor { @Override public Response intercept(Chain chain) throws IOException { Request request = chain.request(); - if (!NetWorkUtil.isNetConnected(MainApp.getContext())) { + if (!NetWorkControl.isNetConnected(MainApp.getContext())) { request = request.newBuilder() .cacheControl(CacheControl.FORCE_CACHE) .build(); @@ -30,7 +30,7 @@ public Response intercept(Chain chain) throws IOException { } Response originalResponse = chain.proceed(request); - if (NetWorkUtil.isNetConnected(MainApp.getContext())) { + if (NetWorkControl.isNetConnected(MainApp.getContext())) { //有网的时候读接口上的@Headers里的配置,你可以在这里进行统一的设置 String cacheControl = request.cacheControl().toString(); return originalResponse.newBuilder() diff --git a/core/src/main/java/com/android/core/ui/BaseActivity.java b/core/src/main/java/com/android/core/ui/BaseActivity.java index 6e8ff13..3b22d71 100644 --- a/core/src/main/java/com/android/core/ui/BaseActivity.java +++ b/core/src/main/java/com/android/core/ui/BaseActivity.java @@ -6,6 +6,7 @@ import android.view.Window; import com.android.core.model.control.LogicProxy; +import com.android.core.widget.LoadingView; import butterknife.ButterKnife; @@ -16,12 +17,15 @@ */ public abstract class BaseActivity extends Activity { + private LoadingView mLoadingView; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(getLayoutResource()); ButterKnife.bind(this); + mLoadingView = new LoadingView(this); onInitView(); onInitData(); } @@ -44,6 +48,14 @@ public void startActivity(Intent intent) { // 打开Activity动画 } + public void showLoadView() { + mLoadingView.show(); + } + + public void hideLoadView() { + mLoadingView.hide(); + } + //获得该页面的实例 public T getLogicImpl(Class cls, Object o) { return LogicProxy.getInstance().bind(cls, o); diff --git a/core/src/main/java/com/android/core/ui/BaseFragment.java b/core/src/main/java/com/android/core/ui/BaseFragment.java index 1f8d0c3..7be3c8d 100644 --- a/core/src/main/java/com/android/core/ui/BaseFragment.java +++ b/core/src/main/java/com/android/core/ui/BaseFragment.java @@ -8,6 +8,7 @@ import android.view.ViewGroup; import com.android.core.model.control.LogicProxy; +import com.android.core.widget.LoadingView; import butterknife.ButterKnife; @@ -18,6 +19,7 @@ */ public abstract class BaseFragment extends Fragment { protected View rootView; + private LoadingView mLoginView; @Nullable @Override @@ -25,6 +27,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa if (rootView == null) rootView = inflater.inflate(getLayoutResource(), container, false); ButterKnife.bind(this, rootView); + mLoginView = new LoadingView(getActivity()); onInitView(); onInitData(); return rootView; @@ -36,6 +39,14 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa protected abstract void onInitData(); + public void showLoadingView() { + mLoginView.show(); + } + + public void hideLoadingView() { + mLoginView.hide(); + } + //获得该页面的实例 public T getLogicImpl(Class cls, Object o) { return LogicProxy.getInstance().bind(cls, o); diff --git a/core/src/main/java/com/android/core/widget/CustomViewpager.java b/core/src/main/java/com/android/core/widget/CustomViewpager.java index c3f3732..7eda1e2 100644 --- a/core/src/main/java/com/android/core/widget/CustomViewpager.java +++ b/core/src/main/java/com/android/core/widget/CustomViewpager.java @@ -13,7 +13,7 @@ import com.android.core.R; import com.android.core.iface.CustomInterface; -import com.android.core.util.ScreenUtil; +import com.android.core.control.ScreenUtil; /** * @author: 蜡笔小新 diff --git a/core/src/main/java/com/android/core/widget/LoadingView.java b/core/src/main/java/com/android/core/widget/LoadingView.java new file mode 100644 index 0000000..1d45066 --- /dev/null +++ b/core/src/main/java/com/android/core/widget/LoadingView.java @@ -0,0 +1,65 @@ +package com.android.core.widget; + +import android.app.Dialog; +import android.content.Context; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ProgressBar; + +import com.android.core.R; +import com.github.ybq.android.spinkit.style.DoubleBounce; +/** + * @author: 蜡笔小新 + * @date: 2016-06-01 17:58 + * @GitHub: https://github.com/meikoz + */ +public class LoadingView extends Dialog implements View.OnClickListener { + + int[] colors = new int[]{ + android.graphics.Color.parseColor("#D55400"), + android.graphics.Color.parseColor("#2B3E51"), + android.graphics.Color.parseColor("#00BD9C"), + android.graphics.Color.parseColor("#227FBB"), + android.graphics.Color.parseColor("#7F8C8D"), + android.graphics.Color.parseColor("#FFCC5C"), + android.graphics.Color.parseColor("#D55400"), + android.graphics.Color.parseColor("#1AAF5D"), + }; + + public LoadingView(Context context) { + super(context, R.style.loading_dialog_style); + onInit(); + } + + private void onInit() { + View view = getLayoutInflater().inflate(R.layout.abc_view_loading, null); + + ProgressBar mProgressBar = (ProgressBar) view.findViewById(R.id.progress); + DoubleBounce doubleBounce = new DoubleBounce(); + doubleBounce.setBounds(0, 0, + 100, + 100); + doubleBounce.setColor(colors[7]); + mProgressBar.setIndeterminateDrawable(doubleBounce); + + view.setOnClickListener(this); + setContentView(view); + getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); + } + + @Override + public void onClick(View v) { + this.dismiss(); + } + + @Override + public void show() { + super.show(); + } + + + @Override + public void dismiss() { + super.dismiss(); + } +} \ No newline at end of file diff --git a/core/src/main/java/com/android/core/widget/TabStripView.java b/core/src/main/java/com/android/core/widget/TabStripView.java index 4361369..8fa57ab 100644 --- a/core/src/main/java/com/android/core/widget/TabStripView.java +++ b/core/src/main/java/com/android/core/widget/TabStripView.java @@ -18,7 +18,7 @@ import android.widget.TextView; import com.android.core.R; -import com.android.core.util.ScreenUtil; +import com.android.core.control.ScreenUtil; import java.util.ArrayList; import java.util.List; diff --git a/core/src/main/res/drawable/abc_icon_down_arrow.png b/core/src/main/res/drawable-xhdpi/abc_icon_down_arrow.png similarity index 100% rename from core/src/main/res/drawable/abc_icon_down_arrow.png rename to core/src/main/res/drawable-xhdpi/abc_icon_down_arrow.png diff --git a/core/src/main/res/layout/abc_view_loading.xml b/core/src/main/res/layout/abc_view_loading.xml new file mode 100644 index 0000000..80c658f --- /dev/null +++ b/core/src/main/res/layout/abc_view_loading.xml @@ -0,0 +1,14 @@ + + + + + + diff --git a/core/src/main/res/values/colors.xml b/core/src/main/res/values/colors.xml index 27b5d8d..ec20dfc 100644 --- a/core/src/main/res/values/colors.xml +++ b/core/src/main/res/values/colors.xml @@ -2,4 +2,5 @@ #7f000000 #212121 + #ffffff diff --git a/core/src/main/res/values/styles.xml b/core/src/main/res/values/styles.xml index 71aeaae..e4c6384 100644 --- a/core/src/main/res/values/styles.xml +++ b/core/src/main/res/values/styles.xml @@ -12,4 +12,14 @@ true +