implements ItemInput {
11 | protected String key;
12 |
13 | /**
14 | * @param key 录入对应key
15 | */
16 | public BaseItemInput(String key) {
17 | this.key = key;
18 | }
19 |
20 |
21 | @NonNull
22 | @Override
23 | public String getItemTypeName() {
24 | return toString();
25 | }
26 |
27 | @Override
28 | public InputHolderManager getViewHolderManager() {
29 | return this;
30 | }
31 |
32 | @Override
33 | public String getKey() {
34 | return key;
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/rxbus/RxBus.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.rxbus;
2 |
3 | import com.hwangjr.rxbus.Bus;
4 | import com.hwangjr.rxbus.thread.ThreadEnforcer;
5 |
6 | public final class RxBus {
7 | private static Bus sBus; //主线程post
8 | private static Bus ioBus; //子线程post
9 |
10 | public static synchronized Bus get() {
11 | if (sBus == null) {
12 | sBus = new Bus();
13 | }
14 | return sBus;
15 | }
16 | public static synchronized Bus getIO() {
17 | if (ioBus == null) {
18 | ioBus = new Bus(ThreadEnforcer.ANY);
19 | }
20 | return ioBus;
21 | }
22 | public static void register(Object o){
23 | get().register(o);
24 | getIO().register(o);
25 | }
26 | public static void unregister(Object o){
27 | get().unregister(o);
28 | getIO().unregister(o);
29 | }
30 | }
--------------------------------------------------------------------------------
/library/src/main/java/magicindicator/abs/IPagerNavigator.java:
--------------------------------------------------------------------------------
1 | package magicindicator.abs;
2 |
3 | /**
4 | * 抽象的ViewPager导航器
5 | * 博客: http://hackware.lucode.net
6 | * Created by hackware on 2016/6/26.
7 | */
8 | public interface IPagerNavigator {
9 |
10 | ///////////////////////// ViewPager的3个回调
11 | void onPageScrolled(int position, float positionOffset, int positionOffsetPixels);
12 |
13 | void onPageSelected(int position);
14 |
15 | void onPageScrollStateChanged(int state);
16 | /////////////////////////
17 |
18 | /**
19 | * 当IPagerNavigator被添加到MagicIndicator时调用
20 | */
21 | void onAttachToMagicIndicator();
22 |
23 | /**
24 | * 当IPagerNavigator从MagicIndicator上移除时调用
25 | */
26 | void onDetachFromMagicIndicator();
27 |
28 | /**
29 | * ViewPager内容改变时需要先调用此方法,自定义的IPagerNavigator应当遵守此约定
30 | */
31 | void notifyDataSetChanged();
32 | }
33 |
--------------------------------------------------------------------------------
/library/src/main/java/multiitem/item/UniqueItemManager.java:
--------------------------------------------------------------------------------
1 | package multiitem.item;
2 |
3 | import multiitem.adapter.holder.BaseViewHolder;
4 | import multiitem.adapter.holder.ViewHolderManager;
5 |
6 | /**
7 | * 唯一Item
8 | *
9 | * getItemTypeName时返回toString作为唯一标示,使得本item对应的ViewHolderManager不可复用
10 | * Created by free46000 on 2017/3/26.
11 | */
12 | public class UniqueItemManager implements ItemManager {
13 | private ViewHolderManager extends UniqueItemManager, ? extends BaseViewHolder> manager;
14 |
15 | public UniqueItemManager(ViewHolderManager extends UniqueItemManager, ? extends BaseViewHolder> manager) {
16 | this.manager = manager;
17 | }
18 |
19 | @Override
20 | public String getItemTypeName() {
21 | return toString();
22 | }
23 |
24 | @Override
25 | public ViewHolderManager getViewHolderManager() {
26 | return manager;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/library/src/androidTest/java/com/example/library/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.library;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.example.library.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/library/src/main/java/multiitem/animation/ScaleInAnimation.java:
--------------------------------------------------------------------------------
1 | package multiitem.animation;
2 |
3 | import android.animation.Animator;
4 | import android.animation.ObjectAnimator;
5 | import android.view.View;
6 |
7 | /**
8 | * scale 动画
9 | * Created by free46000 on 2017/5/22.
10 | */
11 | public class ScaleInAnimation implements BaseAnimation {
12 |
13 | private static final float DEFAULT_SCALE_FROM = .5f;
14 | private final float mFrom;
15 |
16 | public ScaleInAnimation() {
17 | this(DEFAULT_SCALE_FROM);
18 | }
19 |
20 | public ScaleInAnimation(float from) {
21 | mFrom = from;
22 | }
23 |
24 | @Override
25 | public Animator[] getAnimators(View view) {
26 | ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", mFrom, 1f);
27 | ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", mFrom, 1f);
28 | return new ObjectAnimator[] { scaleX, scaleY };
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/imgseletor/bean/Image.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.imgseletor.bean;
2 |
3 | import android.text.TextUtils;
4 | import android.widget.ImageView;
5 |
6 | /**
7 | * 图片实体
8 | * Created by Nereo on 2015/4/7.
9 | */
10 | public class Image {
11 | public String path;
12 | public String name;
13 | public long time;
14 | public ImageView imageView;
15 |
16 | public Image(String path, String name, long time){
17 | this.path = path;
18 | this.name = name;
19 | this.time = time;
20 | }
21 |
22 | @Override
23 | public boolean equals(Object o) {
24 | try {
25 | if(o==null)return false;
26 | Image other = (Image) o;
27 | return TextUtils.equals(this.path, other.path);
28 | }catch (ClassCastException e){
29 | e.printStackTrace();
30 | }
31 | return super.equals(o);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/activity_test.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
14 |
17 |
18 |
23 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/frame/project/ray/projectframe/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package frame.project.ray.projectframe;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("frame.project.ray.projectframe", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/library/src/main/java/multiitem/item/HiddenItemInput.java:
--------------------------------------------------------------------------------
1 | package multiitem.item;
2 |
3 | import multiitem.adapter.holder.BaseViewHolder;
4 |
5 | /**
6 | * 隐藏域的录入Item
7 | * Created by free46000 on 2017/4/13.
8 | */
9 | public class HiddenItemInput extends BaseItemInput {
10 | protected Object value;
11 |
12 | /**
13 | * @param key item对应key
14 | * @param value item对应value
15 | */
16 | public HiddenItemInput(String key, Object value) {
17 | super(key);
18 | this.value = value;
19 | }
20 |
21 | @Override
22 | public void onBindViewHolder(BaseViewHolder holder, Object o) {
23 |
24 | }
25 |
26 | @Override
27 | protected int getItemLayoutId() {
28 | return 0;
29 | }
30 |
31 | @Override
32 | public Object getValue() {
33 | return value;
34 | }
35 |
36 | @Override
37 | protected void initInputView(BaseViewHolder holder) {
38 |
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/library/src/main/java/multiitem/adapter/holder/BaseViewHolderManager.java:
--------------------------------------------------------------------------------
1 | package multiitem.adapter.holder;
2 |
3 | import android.support.annotation.NonNull;
4 | import android.view.ViewGroup;
5 |
6 | /**
7 | * ViewHolder鐨勭®$悊绫伙紝榛樿®ら噰鐢▄@link BaseViewHolder}鐨勫疄鐜°
8 | *
9 | * Created by free46000 on 2017/3/16.
10 | */
11 | public abstract class BaseViewHolderManager extends ViewHolderManager {
12 | @Override
13 | public abstract void onBindViewHolder(BaseViewHolder holder, T t);
14 |
15 | @NonNull
16 | @Override
17 | public BaseViewHolder onCreateViewHolder(@NonNull ViewGroup parent) {
18 | BaseViewHolder viewHolder = new BaseViewHolder(getItemView(parent));
19 | onCreateViewHolder(viewHolder);
20 | return viewHolder;
21 | }
22 |
23 | /**
24 | * {@link #onCreateViewHolder}
25 | */
26 | protected void onCreateViewHolder(@NonNull BaseViewHolder holder) {
27 | }
28 |
29 | }
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/utils/TimeCutTask.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.utils;
2 |
3 | import android.os.CountDownTimer;
4 |
5 | /**
6 | * Created by Ray on 2017/12/27.
7 | */
8 |
9 | public class TimeCutTask extends CountDownTimer {
10 |
11 | /**
12 | * @param millisInFuture The number of millis in the future from the call
13 | * to {@link #start()} until the countdown is done and {@link #onFinish()}
14 | * is called.
15 | * @param countDownInterval The interval along the way to receive
16 | * {@link #onTick(long)} callbacks.
17 | */
18 | public TimeCutTask(long millisInFuture, long countDownInterval) {
19 | super(millisInFuture, countDownInterval);
20 | }
21 |
22 | @Override
23 | public void onTick(long millisUntilFinished) {
24 |
25 | }
26 |
27 | @Override
28 | public void onFinish() {
29 |
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ray/projectframe/SplashActivity.java:
--------------------------------------------------------------------------------
1 | package com.ray.projectframe;
2 |
3 | import android.os.Handler;
4 |
5 | import com.hwangjr.rxbus.annotation.Subscribe;
6 | import com.hwangjr.rxbus.annotation.Tag;
7 | import com.ray.library.base.ui.CheckPermissionsActivity;
8 | import com.ray.library.common.TestActivity;
9 | import com.ray.library.rxbus.Event;
10 |
11 | public class SplashActivity extends CheckPermissionsActivity {
12 | /**
13 | * 获取需要检测的权限列表,返回null 直接回调startApp()
14 | * @return
15 | */
16 | @Override
17 | protected String[] getPermissions() {
18 | return null;
19 | }
20 |
21 | @Override
22 | protected void startApp() {
23 | new Handler().postDelayed(() -> {
24 | MainActivity.start(this);
25 | finish();
26 | }, 2000);
27 | }
28 |
29 | @Override
30 | protected int inflateContentView() {
31 | return R.layout.activity_splash;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ray/projectframe/Fragment2.java:
--------------------------------------------------------------------------------
1 | package com.ray.projectframe;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.TextView;
10 |
11 |
12 | /**
13 | * Created by 陈序员 on 2017/5/3.
14 | * Email: Matthew_Chen_1994@163.com
15 | * Blog: https://blog.ifmvo.cn
16 | */
17 |
18 | public class Fragment2 extends Fragment {
19 |
20 | @Nullable
21 | @Override
22 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
23 | View view = LayoutInflater.from(getActivity()).inflate(R.layout.fragment, null);
24 |
25 | TextView txt = (TextView) view.findViewById(R.id.txt);
26 | txt.setText(this.getClass().getSimpleName());
27 |
28 | return view;
29 | }
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ray/projectframe/Fragment3.java:
--------------------------------------------------------------------------------
1 | package com.ray.projectframe;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.TextView;
10 |
11 |
12 | /**
13 | * Created by 陈序员 on 2017/5/3.
14 | * Email: Matthew_Chen_1994@163.com
15 | * Blog: https://blog.ifmvo.cn
16 | */
17 |
18 | public class Fragment3 extends Fragment {
19 |
20 | @Nullable
21 | @Override
22 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
23 | View view = LayoutInflater.from(getActivity()).inflate(R.layout.fragment, null);
24 |
25 | TextView txt = (TextView) view.findViewById(R.id.txt);
26 | txt.setText(this.getClass().getSimpleName());
27 |
28 | return view;
29 | }
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ray/projectframe/Fragment4.java:
--------------------------------------------------------------------------------
1 | package com.ray.projectframe;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.TextView;
10 |
11 |
12 | /**
13 | * Created by 陈序员 on 2017/5/3.
14 | * Email: Matthew_Chen_1994@163.com
15 | * Blog: https://blog.ifmvo.cn
16 | */
17 |
18 | public class Fragment4 extends Fragment {
19 |
20 | @Nullable
21 | @Override
22 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
23 | View view = LayoutInflater.from(getActivity()).inflate(R.layout.fragment, null);
24 |
25 | TextView txt = (TextView) view.findViewById(R.id.txt);
26 | txt.setText(this.getClass().getSimpleName());
27 |
28 | return view;
29 | }
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/imgseletor/utils/TimeUtils.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.imgseletor.utils;
2 |
3 | import java.io.File;
4 | import java.text.SimpleDateFormat;
5 | import java.util.Date;
6 | import java.util.Locale;
7 |
8 | /**
9 | * 时间处理工具
10 | * Created by Nereo on 2015/4/8.
11 | */
12 | public class TimeUtils {
13 |
14 | public static String timeFormat(long timeMillis, String pattern){
15 | SimpleDateFormat format = new SimpleDateFormat(pattern, Locale.CHINA);
16 | return format.format(new Date(timeMillis));
17 | }
18 |
19 | public static String formatPhotoDate(long time){
20 | return timeFormat(time, "yyyy-MM-dd");
21 | }
22 |
23 | public static String formatPhotoDate(String path){
24 | File file = new File(path);
25 | if(file.exists()){
26 | long time = file.lastModified();
27 | return formatPhotoDate(time);
28 | }
29 | return "1970-01-01";
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/view/view/baseadapter/animation/ScaleInAnimation.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.view.view.baseadapter.animation;
2 |
3 | import android.animation.Animator;
4 | import android.animation.ObjectAnimator;
5 | import android.view.View;
6 |
7 |
8 | /**
9 | * https://github.com/CymChad/BaseRecyclerViewAdapterHelper
10 | */
11 | public class ScaleInAnimation implements BaseAnimation {
12 |
13 | private static final float DEFAULT_SCALE_FROM = .5f;
14 | private final float mFrom;
15 |
16 | public ScaleInAnimation() {
17 | this(DEFAULT_SCALE_FROM);
18 | }
19 |
20 | public ScaleInAnimation(float from) {
21 | mFrom = from;
22 | }
23 |
24 | @Override
25 | public Animator[] getAnimators(View view) {
26 | ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", mFrom, 1f);
27 | ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", mFrom, 1f);
28 | return new ObjectAnimator[] { scaleX, scaleY };
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/library/src/main/java/magicindicator/buildins/commonnavigator/abs/IPagerTitleView.java:
--------------------------------------------------------------------------------
1 | package magicindicator.buildins.commonnavigator.abs;
2 |
3 | /**
4 | * 抽象的指示器标题,适用于CommonNavigator
5 | * 博客: http://hackware.lucode.net
6 | * Created by hackware on 2016/6/26.
7 | */
8 | public interface IPagerTitleView {
9 | /**
10 | * 被选中
11 | */
12 | void onSelected(int index, int totalCount);
13 |
14 | /**
15 | * 未被选中
16 | */
17 | void onDeselected(int index, int totalCount);
18 |
19 | /**
20 | * 离开
21 | *
22 | * @param leavePercent 离开的百分比, 0.0f - 1.0f
23 | * @param leftToRight 从左至右离开
24 | */
25 | void onLeave(int index, int totalCount, float leavePercent, boolean leftToRight);
26 |
27 | /**
28 | * 进入
29 | *
30 | * @param enterPercent 进入的百分比, 0.0f - 1.0f
31 | * @param leftToRight 从左至右离开
32 | */
33 | void onEnter(int index, int totalCount, float enterPercent, boolean leftToRight);
34 | }
35 |
--------------------------------------------------------------------------------
/library/src/main/java/multiitem/adapter/holder/BaseViewHolder.java:
--------------------------------------------------------------------------------
1 | package multiitem.adapter.holder;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import android.view.View;
5 |
6 | /**
7 | * RecyclerView的view holder
8 | * 增加一些属性和方法,方便使用
9 | *
10 | * @author free46000 2017/03/16
11 | * @version v1.0
12 | */
13 | public class BaseViewHolder extends RecyclerView.ViewHolder {
14 | public ViewHolderManager viewHolderManager;
15 | public Object itemData;
16 |
17 |
18 | public BaseViewHolder(View itemView) {
19 | super(itemView);
20 | }
21 |
22 |
23 | public Object getItemData() {
24 | return itemData;
25 | }
26 |
27 | /**
28 | * header和footer的个数也计算在内
29 | * {@link #getAdapterPosition()}
30 | */
31 | public int getItemPosition() {
32 | return getAdapterPosition();
33 | }
34 |
35 | public ViewHolderManager getViewHolderManager() {
36 | return viewHolderManager;
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ray/projectframe/FrameApplication.java:
--------------------------------------------------------------------------------
1 | package com.ray.projectframe;
2 |
3 | import com.ray.library.BaseApplication;
4 | import com.ray.library.common.CrashHandler;
5 | import com.ray.library.utils.SystemUtil;
6 | import com.ray.library.greendao.MyDaoMaster;
7 | import com.ray.projectframe.common.Const;
8 | import com.tencent.bugly.crashreport.CrashReport;
9 |
10 | /**
11 | * Created by Ray on 2017/5/16.
12 | * email:1452011874@qq.com
13 | */
14 |
15 | public class FrameApplication extends BaseApplication {
16 |
17 | @Override
18 | public void onCreate() {
19 | super.onCreate();
20 | String processName = SystemUtil.getProcessName(android.os.Process.myPid());
21 | if(!getPackageName().equals(processName))return;
22 | // CrashReport.initCrashReport(getApplicationContext(), "注册时申请的APPID", true);
23 | CrashHandler.getInstance().init(this,true);
24 | MyDaoMaster.getInstance(this).init(Const.DB_NAME);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/image_corner.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
15 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ray/projectframe/demo/DemoActivity.java:
--------------------------------------------------------------------------------
1 | package com.ray.projectframe.demo;
2 |
3 | import android.os.Bundle;
4 |
5 | import com.ray.library.base.ui.BaseActivity;
6 | import com.ray.projectframe.R;
7 | import com.ray.projectframe.mvp.presenter.DemoPresenter;
8 | import com.ray.projectframe.mvp.view.DemoIView;
9 |
10 | import butterknife.ButterKnife;
11 |
12 | public class DemoActivity extends BaseActivity implements DemoIView {
13 |
14 | @Override
15 | protected int inflateContentView() {
16 | return R.layout.activity_demo;
17 | }
18 |
19 | @Override
20 | protected void initPresenter() {
21 | mPresenter=new DemoPresenter(this,this);
22 | }
23 |
24 | @Override
25 | protected void initView(Bundle savedInstanceState) {
26 | ButterKnife.bind(this);
27 | }
28 |
29 | @Override
30 | protected void initEvents() {
31 |
32 | }
33 |
34 | @Override
35 | public void onLoginSuccess() {
36 |
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/imgseletor/utils/ScreenUtils.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.imgseletor.utils;
2 |
3 | import android.content.Context;
4 | import android.graphics.Point;
5 | import android.os.Build;
6 | import android.view.Display;
7 | import android.view.WindowManager;
8 |
9 | /**
10 | * 屏幕工具
11 | * Created by nereo on 15/11/19.
12 | * Updated by nereo on 2016/1/19.
13 | */
14 | public class ScreenUtils {
15 |
16 | public static Point getScreenSize(Context context){
17 | WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
18 | Display display = wm.getDefaultDisplay();
19 | Point out = new Point();
20 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
21 | display.getSize(out);
22 | }else{
23 | int width = display.getWidth();
24 | int height = display.getHeight();
25 | out.set(width, height);
26 | }
27 | return out;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/pager_navigator_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
12 |
13 |
18 |
19 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/activity_base_bottom_tab.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
12 |
13 |
14 |
18 |
19 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/library/src/main/java/multiitem/adapter/holder/BindViewHolderManager.java:
--------------------------------------------------------------------------------
1 | package multiitem.adapter.holder;
2 |
3 | import android.databinding.DataBindingUtil;
4 | import android.databinding.ViewDataBinding;
5 |
6 |
7 | /**
8 | * 数据绑定ViewHolderManager
9 | * Created by free46000 on 2017/4/6.
10 | */
11 | public abstract class BindViewHolderManager extends BaseViewHolderManager {
12 | {
13 | enableDataBind();
14 | }
15 |
16 | @Override
17 | public void onBindViewHolder(BaseViewHolder holder, T data) {
18 | ViewDataBinding dataBinding = DataBindingUtil.getBinding(holder.itemView);
19 | onBindViewHolder(dataBinding, data);
20 | // dataBinding.executePendingBindings();
21 | }
22 |
23 | /**
24 | * 绑定数据到视图
25 | *
26 | * @param dataBinding item视图对应dataBinding类
27 | * @param data 数据源
28 | */
29 | protected abstract void onBindViewHolder(ViewDataBinding dataBinding, T data);
30 |
31 | @Override
32 | protected abstract int getItemLayoutId();
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
13 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/library/src/main/java/magicindicator/buildins/commonnavigator/titles/DummyPagerTitleView.java:
--------------------------------------------------------------------------------
1 | package magicindicator.buildins.commonnavigator.titles;
2 |
3 | import android.content.Context;
4 | import android.view.View;
5 |
6 | import magicindicator.buildins.commonnavigator.abs.IPagerTitleView;
7 |
8 | /**
9 | * 空指示器标题,用于只需要指示器而不需要title的需求
10 | * 博客: http://hackware.lucode.net
11 | * Created by hackware on 2016/6/26.
12 | */
13 | public class DummyPagerTitleView extends View implements IPagerTitleView {
14 |
15 | public DummyPagerTitleView(Context context) {
16 | super(context);
17 | }
18 |
19 | @Override
20 | public void onSelected(int index, int totalCount) {
21 | }
22 |
23 | @Override
24 | public void onDeselected(int index, int totalCount) {
25 | }
26 |
27 | @Override
28 | public void onLeave(int index, int totalCount, float leavePercent, boolean leftToRight) {
29 | }
30 |
31 | @Override
32 | public void onEnter(int index, int totalCount, float enterPercent, boolean leftToRight) {
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/library/src/main/java/magicindicator/ViewPagerHelper.java:
--------------------------------------------------------------------------------
1 | package magicindicator;
2 |
3 | import android.support.v4.view.ViewPager;
4 |
5 | /**
6 | * 简化和ViewPager绑定
7 | * Created by hackware on 2016/8/17.
8 | */
9 |
10 | public class ViewPagerHelper {
11 | public static void bind(final MagicIndicator magicIndicator, ViewPager viewPager) {
12 | viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
13 |
14 | @Override
15 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
16 | magicIndicator.onPageScrolled(position, positionOffset, positionOffsetPixels);
17 | }
18 |
19 | @Override
20 | public void onPageSelected(int position) {
21 | magicIndicator.onPageSelected(position);
22 | }
23 |
24 | @Override
25 | public void onPageScrollStateChanged(int state) {
26 | magicIndicator.onPageScrollStateChanged(state);
27 | }
28 | });
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/library/src/main/res/drawable/mis_action_btn.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 |
11 | -
12 |
13 |
14 |
15 |
16 |
17 |
18 | -
19 |
20 |
21 |
22 |
23 |
24 |
25 | -
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/def_loading.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
24 |
25 |
--------------------------------------------------------------------------------
/library/src/main/java/magicindicator/buildins/commonnavigator/model/PositionData.java:
--------------------------------------------------------------------------------
1 | package magicindicator.buildins.commonnavigator.model;
2 |
3 | /**
4 | * 保存指示器标题的坐标
5 | * 博客: http://hackware.lucode.net
6 | * Created by hackware on 2016/6/26.
7 | */
8 | public class PositionData {
9 | public int mLeft;
10 | public int mTop;
11 | public int mRight;
12 | public int mBottom;
13 | public int mContentLeft;
14 | public int mContentTop;
15 | public int mContentRight;
16 | public int mContentBottom;
17 |
18 | public int width() {
19 | return mRight - mLeft;
20 | }
21 |
22 | public int height() {
23 | return mBottom - mTop;
24 | }
25 |
26 | public int contentWidth() {
27 | return mContentRight - mContentLeft;
28 | }
29 |
30 | public int contentHeight() {
31 | return mContentBottom - mContentTop;
32 | }
33 |
34 | public int horizontalCenter() {
35 | return mLeft + width() / 2;
36 | }
37 |
38 | public int verticalCenter() {
39 | return mTop + height() / 2;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/utils/GsonUtil.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.utils;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.JsonObject;
5 | import com.google.gson.reflect.TypeToken;
6 |
7 | import java.lang.reflect.Type;
8 | import java.util.ArrayList;
9 |
10 | /**
11 | * Created by Ray on 2018/2/9.
12 | */
13 |
14 | public class GsonUtil {
15 |
16 | public static T parseJSON(String json, Class clazz) {
17 | Gson gson = new Gson();
18 | Type listType = new TypeToken(){}.getType();
19 | return gson.fromJson(json,listType);
20 | }
21 |
22 | public static ArrayList jsonToArrayList(String json, Class clazz) {
23 | Type type = new TypeToken>() {}.getType();
24 | ArrayList jsonObjects = new Gson().fromJson(json, type);
25 | ArrayList arrayList = new ArrayList<>();
26 | for (JsonObject jsonObject : jsonObjects)
27 | {
28 | arrayList.add(new Gson().fromJson(jsonObject, clazz));
29 | }
30 | return arrayList;
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/common/adapter/PagerViewAdapter.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.common.adapter;
2 |
3 | import android.support.v4.view.PagerAdapter;
4 | import android.view.View;
5 | import android.view.ViewGroup;
6 |
7 | import java.util.ArrayList;
8 |
9 | public class PagerViewAdapter extends PagerAdapter {
10 |
11 |
12 | private final ArrayList views;
13 |
14 | public PagerViewAdapter(ArrayList views) {
15 | this.views = views;
16 | }
17 |
18 | @Override
19 | public int getCount() {
20 | return views.size();
21 | }
22 |
23 | @Override
24 | public boolean isViewFromObject(View view, Object object) {
25 | return view == object;
26 | }
27 |
28 | @Override
29 | public void destroyItem(ViewGroup container, int position,
30 | Object object) {
31 | container.removeView(views.get(position));
32 | }
33 |
34 | @Override
35 | public Object instantiateItem(ViewGroup container, int position) {
36 | container.addView(views.get(position));
37 | return views.get(position);
38 | }
39 | }
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/view/view/viewpager/tabviewpager/Tool.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.view.view.viewpager.tabviewpager;
2 |
3 | import android.content.Context;
4 | import android.text.TextPaint;
5 | import android.util.DisplayMetrics;
6 | import android.view.WindowManager;
7 | import android.widget.TextView;
8 |
9 | public class Tool {
10 |
11 | public static float getTextViewLength(TextView textView) {
12 | TextPaint paint = textView.getPaint();
13 | return paint.measureText(textView.getText().toString());
14 | }
15 |
16 | public static float getTextViewLength(TextView textView, float textSize) {
17 | TextPaint paint = textView.getPaint();
18 | paint.setTextSize(textSize);
19 | return paint.measureText(textView.getText().toString());
20 | }
21 |
22 | public static int getScreenWidth(Context context) {
23 | WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
24 | DisplayMetrics dm = new DisplayMetrics();
25 | wm.getDefaultDisplay().getMetrics(dm);
26 | return dm.widthPixels;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/utils/T.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.utils;
2 |
3 | import android.content.Context;
4 |
5 | import com.ray.library.BaseApplication;
6 |
7 |
8 | /**
9 | * Created by Ray on 2017/5/16.
10 | * email:1452011874@qq.com
11 | */
12 |
13 | public class T {
14 |
15 | /**
16 | * 短暂显示Toast提示(来自String) *
17 | */
18 | public static void show(Context context, String text) {
19 | android.widget.Toast.makeText(context, text, android.widget.Toast.LENGTH_SHORT).show();
20 | }
21 |
22 | /**
23 | * 短暂显示Toast提示(来自res) *
24 | */
25 | public static void show(Context context, int resId) {
26 | android.widget.Toast.makeText(context, resId, android.widget.Toast.LENGTH_SHORT).show();
27 | }
28 |
29 | public static void show(String text) {
30 | android.widget.Toast.makeText(BaseApplication.getInstance(), text, android.widget.Toast.LENGTH_SHORT).show();
31 | }
32 |
33 | public static void show(int resId) {
34 | android.widget.Toast.makeText(BaseApplication.getInstance(), resId, android.widget.Toast.LENGTH_SHORT).show();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/activity_base_top_bar.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
12 |
13 |
20 |
21 |
22 |
26 |
27 |
--------------------------------------------------------------------------------
/library/src/main/java/magicindicator/buildins/ArgbEvaluatorHolder.java:
--------------------------------------------------------------------------------
1 | package magicindicator.buildins;
2 |
3 |
4 | /**
5 | * 实现颜色渐变,考虑到兼容性,不使用内置的ArgbEvaluator
6 | * 博客: http://hackware.lucode.net
7 | * Created by hackware on 2016/6/26.
8 | */
9 | public class ArgbEvaluatorHolder {
10 | public static int eval(float fraction, int startValue, int endValue) {
11 | int startA = (startValue >> 24) & 0xff;
12 | int startR = (startValue >> 16) & 0xff;
13 | int startG = (startValue >> 8) & 0xff;
14 | int startB = startValue & 0xff;
15 |
16 | int endA = (endValue >> 24) & 0xff;
17 | int endR = (endValue >> 16) & 0xff;
18 | int endG = (endValue >> 8) & 0xff;
19 | int endB = endValue & 0xff;
20 |
21 | int currentA = (startA + (int) (fraction * (endA - startA))) << 24;
22 | int currentR = (startR + (int) (fraction * (endR - startR))) << 16;
23 | int currentG = (startG + (int) (fraction * (endG - startG))) << 8;
24 | int currentB = startB + (int) (fraction * (endB - startB));
25 |
26 | return currentA | currentR | currentG | currentB;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/library/src/main/java/multiitem/item/DataBindItemInput.java:
--------------------------------------------------------------------------------
1 | package multiitem.item;
2 |
3 | import android.databinding.DataBindingUtil;
4 | import android.databinding.ViewDataBinding;
5 |
6 | import multiitem.adapter.holder.BaseViewHolder;
7 | import multiitem.adapter.holder.InputHolderManager;
8 |
9 | /**
10 | * 数据绑定的录入Item
11 | * Created by free46000 on 2017/4/16.
12 | */
13 | public abstract class DataBindItemInput extends BaseItemInput {
14 |
15 | {
16 | enableDataBind();
17 | }
18 |
19 | /**
20 | * @param key 录入对应key
21 | */
22 | public DataBindItemInput(String key) {
23 | super(key);
24 | }
25 |
26 | @Override
27 | protected void initInputView(BaseViewHolder holder) {
28 | ViewDataBinding dataBinding = DataBindingUtil.getBinding(holder.itemView);
29 | initInputView(dataBinding);
30 | }
31 |
32 | /**
33 | * 通过ViewDataBinding初始化Input视图
34 | *
35 | * @param dataBinding
36 | * @see InputHolderManager#initInputView(BaseViewHolder)
37 | */
38 | protected abstract void initInputView(ViewDataBinding dataBinding);
39 |
40 | }
--------------------------------------------------------------------------------
/library/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ray/projectframe/mvp/presenter/DemoEntry.java:
--------------------------------------------------------------------------------
1 | package com.ray.projectframe.mvp.presenter;
2 |
3 | /**
4 | * Created by Ray on 2017/5/11.
5 | * email:1452011874@qq.com
6 | */
7 |
8 | public class DemoEntry {
9 | public static int REG_REGIST=1;
10 | public static int REG_LOGIN=2;
11 | private int reg; //1注册 2登录
12 | private String mobile;
13 | private String password;
14 | private String ext0; //设备标识
15 |
16 | public DemoEntry(int reg) {
17 | this.reg = reg;
18 | }
19 |
20 |
21 | public String getPassword() {
22 | return password;
23 | }
24 |
25 | public void setPassword(String password) {
26 | this.password = password;
27 | }
28 |
29 | public int getReg() {
30 | return reg;
31 | }
32 |
33 | public void setReg(int reg) {
34 | this.reg = reg;
35 | }
36 |
37 | public String getMobile() {
38 | return mobile;
39 | }
40 |
41 | public void setMobile(String mobile) {
42 | this.mobile = mobile;
43 | }
44 |
45 | public String getExt0() {
46 | return ext0;
47 | }
48 |
49 | public void setExt0(String ext0) {
50 | this.ext0 = ext0;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/view/view/viewpager/LimitViewPager.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.view.view.viewpager;
2 |
3 | import android.content.Context;
4 | import android.support.v4.view.ViewPager;
5 | import android.util.AttributeSet;
6 | import android.view.MotionEvent;
7 |
8 | public class LimitViewPager extends ViewPager {
9 |
10 | private boolean isScrollable = false;
11 |
12 | public LimitViewPager(Context context) {
13 | super(context);
14 | }
15 |
16 | public LimitViewPager(Context context, AttributeSet attrs) {
17 | super(context, attrs);
18 | }
19 |
20 | public void setScanScroll(boolean isCanScroll){
21 | this.isScrollable = isCanScroll;
22 | }
23 |
24 |
25 | @Override
26 | public boolean onTouchEvent(MotionEvent ev) {
27 | if (!isScrollable ) {
28 | return false;
29 | } else {
30 | return super.onTouchEvent(ev);
31 | }
32 |
33 | }
34 |
35 | @Override
36 | public boolean onInterceptTouchEvent(MotionEvent ev) {
37 | if (!isScrollable) {
38 | return false;
39 | } else {
40 | return super.onInterceptTouchEvent(ev);
41 | }
42 |
43 | }
44 | }
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/view/view/viewpager/CustomViewPager.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.view.view.viewpager;
2 |
3 | import android.content.Context;
4 | import android.support.v4.view.ViewPager;
5 | import android.util.AttributeSet;
6 | import android.view.MotionEvent;
7 |
8 | public class CustomViewPager extends ViewPager {
9 |
10 | private boolean isScrollable = false;
11 |
12 | public CustomViewPager(Context context) {
13 | super(context);
14 | }
15 |
16 | public CustomViewPager(Context context, AttributeSet attrs) {
17 | super(context, attrs);
18 | }
19 |
20 | public void setScanScroll(boolean isCanScroll){
21 | this.isScrollable = isCanScroll;
22 | }
23 |
24 |
25 | @Override
26 | public boolean onTouchEvent(MotionEvent ev) {
27 | if (!isScrollable ) {
28 | return false;
29 | } else {
30 | return super.onTouchEvent(ev);
31 | }
32 |
33 | }
34 |
35 | @Override
36 | public boolean onInterceptTouchEvent(MotionEvent ev) {
37 | if (!isScrollable) {
38 | return false;
39 | } else {
40 | return super.onInterceptTouchEvent(ev);
41 | }
42 |
43 | }
44 | }
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/view/viewhelper/ICaseViewHelper.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.view.viewhelper;
2 |
3 | import android.content.Context;
4 | import android.view.View;
5 |
6 | /**
7 | * 作者: corer 时间: 2015/10/18.
8 | * 功能:切换页面的接口
9 | * 修改:
10 | */
11 | public interface ICaseViewHelper {
12 |
13 | /**
14 | * 获取上下文
15 | *
16 | * @return Context
17 | */
18 | Context getContext();
19 |
20 | /**
21 | * 获取显示数据的View
22 | *
23 | * @return View
24 | */
25 | View getDataView();
26 |
27 | /**
28 | * 获取当前正在显示的View
29 | *
30 | * @return View
31 | */
32 | View getCurrentView();
33 |
34 | /**
35 | * 切换View
36 | *
37 | * @param view 需要显示的View
38 | */
39 | void showCaseLayout(View view);
40 |
41 | /**
42 | * 切换View
43 | *
44 | * @param layoutId 需要显示布局id
45 | */
46 | void showCaseLayout(int layoutId);
47 |
48 | /**
49 | * 恢复显示数据的View
50 | */
51 | void restoreLayout();
52 |
53 | /**
54 | * 实例化布局
55 | *
56 | * @param layoutId 需要实例化的布局id
57 | * @return View
58 | */
59 | View inflate(int layoutId);
60 | }
61 |
--------------------------------------------------------------------------------
/library/src/main/java/multiitem/item/BaseItemState.java:
--------------------------------------------------------------------------------
1 | package multiitem.item;
2 |
3 | import android.support.annotation.NonNull;
4 |
5 | import multiitem.adapter.holder.BindViewHolderManager;
6 | import multiitem.adapter.holder.ViewHolderManager;
7 | import multiitem.listener.OnStateClickListener;
8 |
9 | /**
10 | * 基础的状态页Item(如:空白页 错误页...)
11 | * Created by free46000 on 2017/4/23.
12 | */
13 | public abstract class BaseItemState extends BindViewHolderManager implements ItemManager {
14 | protected OnStateClickListener onStateClickListener;
15 |
16 |
17 | public OnStateClickListener getOnStateClickListener() {
18 | return onStateClickListener;
19 | }
20 |
21 | /**
22 | * 设置状态页面中按钮的点击监听
23 | *
24 | * @param onStateClickListener OnStateClickListener
25 | */
26 | public void setOnStateClickListener(OnStateClickListener onStateClickListener) {
27 | this.onStateClickListener = onStateClickListener;
28 | }
29 |
30 | @Override
31 | public ViewHolderManager getViewHolderManager() {
32 | return this;
33 | }
34 |
35 |
36 | @NonNull
37 | @Override
38 | public String getItemTypeName() {
39 | return toString();
40 | }
41 |
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/utils/LocationUtil.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.utils;
2 |
3 |
4 | /**
5 | * Created by Ray on 2017/12/20.
6 | */
7 |
8 | public class LocationUtil {
9 |
10 | /*
11 | public static String getDistance(LatLng lng){
12 | String distance="";
13 | if(MiPaiLifelication.getLocation()==null)return distance;
14 | LatLng myL=new LatLng(MiPaiLifelication.getLocation().getLatitude(),MiPaiLifelication.getLocation().getLongitude());
15 | float location = AMapUtils.calculateLineDistance(myL,lng);
16 | if(location==-1D){
17 | return distance;
18 | }
19 | if(location>1000){
20 | String a=new DecimalFormat("##0.0").format((location)/1000);
21 | return a+"km";
22 | }else {
23 | return new DecimalFormat("##0.0").format((location))+"m";
24 | }
25 | }
26 |
27 | public static float getDistanceR(LatLng lng){
28 | float distance=-1;
29 | if(MiPaiLifelication.getLocation()==null)return distance;
30 | LatLng myL=new LatLng(MiPaiLifelication.getLocation().getLatitude(),MiPaiLifelication.getLocation().getLongitude());
31 | float location = AMapUtils.calculateLineDistance(myL,lng);
32 | return location;
33 | }*/
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/mis_list_item_image.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
12 |
13 |
19 |
20 |
28 |
29 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/gen/DaoSession.java:
--------------------------------------------------------------------------------
1 | package com.ray.gen;
2 |
3 | import java.util.Map;
4 |
5 | import org.greenrobot.greendao.AbstractDao;
6 | import org.greenrobot.greendao.AbstractDaoSession;
7 | import org.greenrobot.greendao.database.Database;
8 | import org.greenrobot.greendao.identityscope.IdentityScopeType;
9 | import org.greenrobot.greendao.internal.DaoConfig;
10 |
11 | import com.ray.library.bean.DemoUser;
12 |
13 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
14 |
15 | /**
16 | * {@inheritDoc}
17 | *
18 | * @see org.greenrobot.greendao.AbstractDaoSession
19 | */
20 | public class DaoSession extends AbstractDaoSession {
21 |
22 | private final DaoConfig userDaoConfig;
23 |
24 | private final UserDao userDao;
25 |
26 | public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig>
27 | daoConfigMap) {
28 | super(db);
29 |
30 | userDaoConfig = daoConfigMap.get(UserDao.class).clone();
31 | userDaoConfig.initIdentityScope(type);
32 |
33 | userDao = new UserDao(userDaoConfig, this);
34 |
35 | registerDao(DemoUser.class, userDao);
36 | }
37 |
38 | public void clear() {
39 | userDaoConfig.clearIdentityScope();
40 | }
41 |
42 | public UserDao getUserDao() {
43 | return userDao;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/utils/ImageUtil.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.utils;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 |
6 | import com.ray.library.view.view.photoview.ImageGalleryActivity;
7 |
8 | import java.util.ArrayList;
9 |
10 | public class ImageUtil {
11 | public static void lookBigPic(Context context, ArrayList imageList, int currentPos){
12 | Intent intent = new Intent(context, ImageGalleryActivity.class);
13 | intent.putStringArrayListExtra("images", imageList);
14 | intent.putExtra("position", currentPos);
15 | context.startActivity(intent);
16 | }
17 | public static void lookBigPic(Context context, String[] imageList, int currentPos){
18 | ArrayList list= StringUtil.arrayToList(imageList);
19 | Intent intent = new Intent(context, ImageGalleryActivity.class);
20 | intent.putStringArrayListExtra("images", list);
21 | intent.putExtra("position", getCurrentPos(list,imageList[currentPos]));
22 | context.startActivity(intent);
23 | }
24 |
25 | private static int getCurrentPos(ArrayList list, String s){
26 | int pos=0;
27 | for (int i=0;i bus;
12 |
13 | private RxBus() {
14 | bus = new SerializedSubject<>(PublishSubject.create());
15 | }
16 |
17 | /**
18 | * 单例RxBus
19 | *
20 | * @return
21 | */
22 | public static RxBus getDefault() {
23 | RxBus rxBus = mInstance;
24 | if (mInstance == null) {
25 | synchronized (RxBus.class) {
26 | rxBus = mInstance;
27 | if (mInstance == null) {
28 | rxBus = new RxBus();
29 | mInstance = rxBus;
30 | }
31 | }
32 | }
33 | return rxBus;
34 | }
35 |
36 | /**
37 | * 发送一个新事件
38 | *
39 | * @param o
40 | */
41 | public void post(Object o) {
42 | bus.onNext(o);
43 | }
44 |
45 | /**
46 | * 返回特定类型的被观察者
47 | *
48 | * @param eventType
49 | * @param
50 | * @return
51 | */
52 | public Observable toObservable(Class eventType) {
53 | return bus.ofType(eventType);
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/common/adapter/PagerFragmentAdapter.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.common.adapter;
2 |
3 | import android.support.v4.app.Fragment;
4 | import android.support.v4.app.FragmentManager;
5 | import android.support.v4.app.FragmentPagerAdapter;
6 |
7 | import java.util.ArrayList;
8 |
9 | public class PagerFragmentAdapter extends FragmentPagerAdapter {
10 | private ArrayList tabFragments=new ArrayList<>();
11 | private String[] tabIndicators;
12 |
13 | public void setTabIndicators(String[] tabIndicators) {
14 | this.tabIndicators = tabIndicators;
15 | }
16 |
17 | public PagerFragmentAdapter(FragmentManager fm, ArrayList tabFragments, String[] tabIndicators) {
18 | super(fm);
19 | this.tabFragments = tabFragments;
20 | this.tabIndicators = tabIndicators;
21 | }
22 |
23 | public PagerFragmentAdapter(FragmentManager fm) {
24 | super(fm);
25 | }
26 |
27 | @Override
28 | public Fragment getItem(int position) {
29 | return tabFragments.get(position);
30 | }
31 |
32 | @Override
33 | public int getCount() {
34 | return tabIndicators.length;
35 | }
36 |
37 | @Override
38 | public CharSequence getPageTitle(int position) {
39 | return tabIndicators[position];
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/library/src/main/java/multiitem/adapter/holder/HeadFootHolderManager.java:
--------------------------------------------------------------------------------
1 | package multiitem.adapter.holder;
2 |
3 | import android.support.annotation.NonNull;
4 | import android.view.View;
5 | import android.view.ViewGroup;
6 |
7 | /**
8 | * Head Foot 的ViewHolderManager
9 | *
10 | * Created by free46000 on 2017/3/25.
11 | */
12 | public class HeadFootHolderManager extends ViewHolderManager {
13 | private View itemView;
14 |
15 | public HeadFootHolderManager(View view) {
16 | this.itemView = view;
17 | }
18 |
19 | public HeadFootHolderManager() {
20 |
21 | }
22 |
23 | @NonNull
24 | @Override
25 | public BaseViewHolder onCreateViewHolder(@NonNull ViewGroup parent) {
26 | BaseViewHolder viewHolder = new BaseViewHolder(getItemView(parent));
27 | return viewHolder;
28 | }
29 |
30 | @Override
31 | protected View getItemView(ViewGroup parent) {
32 | if (itemView != null) {
33 | return itemView;
34 | } else {
35 | return super.getItemView(parent);
36 | }
37 | }
38 |
39 | @Override
40 | public void onBindViewHolder(BaseViewHolder holder, T t) {
41 |
42 | }
43 |
44 | @Override
45 | protected int getItemLayoutId() {
46 | return 0;
47 | }
48 |
49 | @Override
50 | public boolean isFullSpan() {
51 | return true;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/library/src/main/java/magicindicator/buildins/commonnavigator/abs/CommonNavigatorAdapter.java:
--------------------------------------------------------------------------------
1 | package magicindicator.buildins.commonnavigator.abs;
2 |
3 | import android.content.Context;
4 | import android.database.DataSetObservable;
5 | import android.database.DataSetObserver;
6 |
7 | /**
8 | * CommonNavigator适配器,通过它可轻松切换不同的指示器样式
9 | * 博客: http://hackware.lucode.net
10 | * Created by hackware on 2016/6/26.
11 | */
12 | public abstract class CommonNavigatorAdapter {
13 |
14 | private final DataSetObservable mDataSetObservable = new DataSetObservable();
15 |
16 | public abstract int getCount();
17 |
18 | public abstract IPagerTitleView getTitleView(Context context, int index);
19 |
20 | public abstract IPagerIndicator getIndicator(Context context);
21 |
22 | public float getTitleWeight(Context context, int index) {
23 | return 1;
24 | }
25 |
26 | public final void registerDataSetObserver(DataSetObserver observer) {
27 | mDataSetObservable.registerObserver(observer);
28 | }
29 |
30 | public final void unregisterDataSetObserver(DataSetObserver observer) {
31 | mDataSetObservable.unregisterObserver(observer);
32 | }
33 |
34 | public final void notifyDataSetChanged() {
35 | mDataSetObservable.notifyChanged();
36 | }
37 |
38 | public final void notifyDataSetInvalidated() {
39 | mDataSetObservable.notifyInvalidated();
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/library/src/main/java/update/fileload/FileResponseBody.java:
--------------------------------------------------------------------------------
1 | package update.fileload;
2 |
3 |
4 | import java.io.IOException;
5 |
6 | import okhttp3.MediaType;
7 | import okhttp3.Response;
8 | import okhttp3.ResponseBody;
9 | import okio.Buffer;
10 | import okio.BufferedSource;
11 | import okio.ForwardingSource;
12 | import okio.Okio;
13 |
14 |
15 | public class FileResponseBody extends ResponseBody {
16 |
17 | Response originalResponse;
18 |
19 | public FileResponseBody(Response originalResponse) {
20 | this.originalResponse = originalResponse;
21 | }
22 |
23 | @Override
24 | public MediaType contentType() {
25 | return originalResponse.body().contentType();
26 | }
27 |
28 | @Override
29 | public long contentLength() {
30 | return originalResponse.body().contentLength();
31 | }
32 |
33 | @Override
34 | public BufferedSource source() {
35 | return Okio.buffer(new ForwardingSource(originalResponse.body().source()) {
36 | long bytesReaded = 0;
37 |
38 | @Override
39 | public long read(Buffer sink, long byteCount) throws IOException {
40 | long bytesRead = super.read(sink, byteCount);
41 | bytesReaded += bytesRead == -1 ? 0 : bytesRead;
42 | RxBus.getDefault().post(new FileLoadingBean(contentLength(), bytesReaded));
43 | return bytesRead;
44 | }
45 | });
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ray/projectframe/api/Api.java:
--------------------------------------------------------------------------------
1 | package com.ray.projectframe.api;
2 |
3 |
4 | import com.jakewharton.retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
5 |
6 | import java.util.concurrent.TimeUnit;
7 |
8 | import okhttp3.OkHttpClient;
9 | import okhttp3.logging.HttpLoggingInterceptor;
10 | import retrofit2.Retrofit;
11 | import retrofit2.converter.gson.GsonConverterFactory;
12 |
13 | /**
14 | * Created by Ray on 2017/5/7.
15 | * email:1452011874@qq.com
16 | */
17 | public class Api{
18 | public static final String ROOT_URL = "http://wififan.zhikenet.com/";
19 | private static ApiService mApiService;
20 |
21 | static {
22 | HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
23 | logging.setLevel(HttpLoggingInterceptor.Level.BODY);
24 | OkHttpClient okHttpClient = new OkHttpClient.Builder()
25 | .readTimeout(30, TimeUnit.SECONDS)
26 | .connectTimeout(30, TimeUnit.SECONDS)
27 | .addInterceptor(logging)
28 | .build();
29 | mApiService = new Retrofit.Builder()
30 | .client(okHttpClient)
31 | .baseUrl(ROOT_URL)
32 | .addConverterFactory(GsonConverterFactory.create())
33 | .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
34 | .build()
35 | .create(ApiService.class);
36 | }
37 | public static ApiService get(){
38 | return mApiService;
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/view/view/imageview/ColorFilterImageView.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.view.view.imageview;
2 |
3 | import android.content.Context;
4 | import android.graphics.Color;
5 | import android.graphics.PorterDuff;
6 | import android.util.AttributeSet;
7 | import android.view.MotionEvent;
8 | import android.view.View;
9 |
10 | public class ColorFilterImageView extends android.support.v7.widget.AppCompatImageView implements View.OnTouchListener {
11 | public ColorFilterImageView(Context context) {
12 | this(context, null, 0);
13 | }
14 |
15 | public ColorFilterImageView(Context context, AttributeSet attrs) {
16 | this(context, attrs, 0);
17 | }
18 |
19 | public ColorFilterImageView(Context context, AttributeSet attrs, int defStyle) {
20 | super(context, attrs, defStyle);
21 | init();
22 | }
23 |
24 | private void init() {
25 | setOnTouchListener(this);
26 | }
27 |
28 | @Override
29 | public boolean onTouch(View v, MotionEvent event) {
30 | switch (event.getAction()) {
31 | case MotionEvent.ACTION_DOWN: // 按下时图像变灰
32 | setColorFilter(Color.GRAY, PorterDuff.Mode.MULTIPLY);
33 | break;
34 | case MotionEvent.ACTION_UP: // 手指离开或取消操作时恢复原色
35 | case MotionEvent.ACTION_CANCEL:
36 | setColorFilter(Color.TRANSPARENT);
37 | break;
38 | default:
39 | break;
40 | }
41 | return false;
42 | }
43 | }
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/view/view/textview/CircleTextView.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.view.view.textview;
2 |
3 | import android.content.Context;
4 | import android.graphics.Paint;
5 | import android.graphics.Rect;
6 | import android.util.AttributeSet;
7 | import android.widget.TextView;
8 |
9 | /**
10 | * @author YanLu
11 | * @since 16/6/9
12 | */
13 |
14 | public class CircleTextView extends TextView {
15 |
16 | public CircleTextView(Context context) {
17 | super(context);
18 | }
19 |
20 | public CircleTextView(Context context, AttributeSet attrs) {
21 | super(context, attrs);
22 | }
23 |
24 | @Override
25 | protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec) {
26 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
27 |
28 | int width = (int) (getTextWidth(getPaint(), getText().toString()) + 0.5);
29 | int height = (int) (getTextHeight(getPaint(), getText().toString()) + 0.5);
30 | int viewLength = Math.max(width, height) + 12;
31 | setMeasuredDimension(viewLength, viewLength);
32 |
33 | }
34 |
35 |
36 | public static float getTextWidth(Paint paint, String text) {
37 | Rect rect = new Rect();
38 | paint.getTextBounds(text + "", 0, text.length(), rect);
39 | return rect.width();
40 | }
41 |
42 |
43 | public static float getTextHeight(Paint paint, String text) {
44 | Rect rect = new Rect();
45 | paint.getTextBounds(text + "", 0, text.length(), rect);
46 | return rect.height();
47 | }
48 |
49 | }
50 |
51 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/view/view/button/DrawableImgCenterView.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.view.view.button;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.drawable.Drawable;
6 | import android.util.AttributeSet;
7 | import android.widget.TextView;
8 |
9 | /**
10 | * Created by ray on 2017/1/3.
11 | */
12 |
13 | public class DrawableImgCenterView extends TextView {
14 |
15 | public DrawableImgCenterView(Context context) {
16 | super(context);
17 | }
18 |
19 | public DrawableImgCenterView(Context context, AttributeSet attrs) {
20 | super(context, attrs);
21 | }
22 |
23 | public DrawableImgCenterView(Context context, AttributeSet attrs, int defStyleAttr) {
24 | super(context, attrs, defStyleAttr);
25 | }
26 |
27 | @Override
28 | protected void onDraw(Canvas canvas) {
29 | Drawable[] drawables = getCompoundDrawables();
30 | if (drawables != null) {
31 | Drawable drawableLeft = drawables[0];
32 | if (drawableLeft != null) {
33 | final float textWidth = getPaint().measureText(getText().toString());
34 | final int drawablePadding = getCompoundDrawablePadding();
35 | final int drawableWidth = drawableLeft.getIntrinsicWidth();
36 | final float bodyWidth = textWidth + drawableWidth + drawablePadding;
37 | canvas.translate((getWidth() - bodyWidth) / 2, 0);
38 | }
39 | }
40 | super.onDraw(canvas);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/bean/DemoUser.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.bean;
2 |
3 | import org.greenrobot.greendao.annotation.Entity;
4 | import org.greenrobot.greendao.annotation.Generated;
5 | import org.greenrobot.greendao.annotation.Id;
6 | import org.greenrobot.greendao.annotation.Property;
7 | import org.greenrobot.greendao.annotation.Transient;
8 |
9 | /**
10 | * (一) @Entity 定义实体
11 | @nameInDb 在数据库中的名字,如不写则为实体中类名
12 | @indexes 索引
13 | @createInDb 是否创建表,默认为true,false时不创建
14 | @schema 指定架构名称为实体
15 | @active 无论是更新生成都刷新
16 | (二) @Id
17 | (三) @NotNull 不为null
18 | (四) @Unique 唯一约束
19 | (五) @ToMany 一对多
20 | (六) @OrderBy 排序
21 | (七) @ToOne 一对一
22 | (八) @Transient 不存储在数据库中
23 | (九) @generated 由greendao产生的构造函数或方法
24 | * */
25 | //@Entity
26 | public class DemoUser {
27 | @Id
28 | private Long id;
29 | @Property(nameInDb = "USERNAME")
30 | private String name;
31 | @Transient //不存储再数据库中
32 | private int tempUsageCount; // not persisted
33 | public String getName() {
34 | return this.name;
35 | }
36 | public void setName(String name) {
37 | this.name = name;
38 | }
39 | public Long getId() {
40 | return this.id;
41 | }
42 | public void setId(Long id) {
43 | this.id = id;
44 | }
45 | @Generated(hash = 873297011)
46 | public DemoUser(Long id, String name) {
47 | this.id = id;
48 | this.name = name;
49 | }
50 | @Generated(hash = 586692638)
51 | public DemoUser() {
52 | }
53 |
54 | public DemoUser(String name) {
55 | this.name = name;
56 | }
57 | }
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/utils/StringUtil.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.utils;
2 |
3 | import android.text.TextUtils;
4 |
5 | import java.util.ArrayList;
6 | import java.util.List;
7 | import java.util.regex.Matcher;
8 | import java.util.regex.Pattern;
9 |
10 | /**
11 | * Created by Ray on 2017/5/5.
12 | * email:1452011874@qq.com
13 | */
14 |
15 | public class StringUtil {
16 |
17 | /**
18 | * 判断String是否为空
19 | **/
20 | public static boolean isEmpty(String string) {
21 | return string == null || string.length() == 0 || string.equals("null");
22 | }
23 |
24 | public static String listToString(List list, String separator) {
25 | StringBuilder sb = new StringBuilder();
26 | for (int i = 0; i < list.size(); i++) {
27 | sb.append(list.get(i)).append(separator);
28 | }
29 | return sb.toString().substring(0,sb.toString().length()-1);}
30 |
31 | public static ArrayList arrayToList(String[] array){
32 | ArrayList list=new ArrayList<>();
33 | if(array==null){
34 | return list;
35 | }
36 | for (String s:array){
37 | if(!TextUtils.isEmpty(s))
38 | list.add(s);
39 | }
40 | return list;
41 | }
42 |
43 | public static String replaceBlank(String str) {
44 | String dest = "";
45 | if (str!=null) {
46 | Pattern p = Pattern.compile("\\s*|\t|\r|\n");
47 | Matcher m = p.matcher(str);
48 | dest = m.replaceAll("");
49 | }
50 | return dest;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/library/src/main/java/multiitem/adapter/holder/ViewHolderParams.java:
--------------------------------------------------------------------------------
1 | package multiitem.adapter.holder;
2 |
3 | import multiitem.listener.OnItemClickListener;
4 | import multiitem.listener.OnItemLongClickListener;
5 |
6 | /**
7 | * Created by free46000 on 2017/3/20.
8 | */
9 |
10 | public class ViewHolderParams {
11 | private OnItemClickListener clickListener;
12 | private OnItemLongClickListener longClickListener;
13 | private int itemCount;
14 | private int listViewScrollState;
15 |
16 | public ViewHolderParams setClickListener(OnItemClickListener clickListener) {
17 | this.clickListener = clickListener;
18 | return this;
19 | }
20 |
21 | public ViewHolderParams setLongClickListener(OnItemLongClickListener longClickListener) {
22 | this.longClickListener = longClickListener;
23 | return this;
24 | }
25 |
26 |
27 | public ViewHolderParams setItemCount(int itemCount) {
28 | this.itemCount = itemCount;
29 | return this;
30 | }
31 |
32 | public ViewHolderParams setListViewScrollState(int listViewScrollState) {
33 | this.listViewScrollState = listViewScrollState;
34 | return this;
35 | }
36 |
37 | public OnItemClickListener getClickListener() {
38 | return clickListener;
39 | }
40 |
41 | public OnItemLongClickListener getLongClickListener() {
42 | return longClickListener;
43 | }
44 |
45 | public int getItemCount() {
46 | return itemCount;
47 | }
48 |
49 | public int getListViewScrollState() {
50 | return listViewScrollState;
51 | }
52 |
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | //apply plugin: 'android-apt'
3 | apply plugin: 'me.tatarka.retrolambda' // java8 语法支持
4 | apply plugin: 'com.jakewharton.butterknife'
5 | apply plugin: 'org.greenrobot.greendao'
6 | android {
7 | compileSdkVersion 26
8 | buildToolsVersion '26.0.2'
9 | defaultConfig {
10 | applicationId "com.ray.projectframe"
11 | minSdkVersion 15
12 | targetSdkVersion 26
13 | versionCode 1
14 | versionName "1.0"
15 | multiDexEnabled true
16 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
17 | }
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 | compileOptions {
25 | targetCompatibility 1.8
26 | sourceCompatibility 1.8
27 | }
28 | packagingOptions {
29 | exclude 'META-INF/rxjava.properties'
30 | }
31 | }
32 |
33 |
34 | dependencies {
35 | implementation 'com.android.support.constraint:constraint-layout:1.0.2'
36 | testCompile 'junit:junit:4.12'
37 | compile fileTree(include: ['*.jar'], dir: 'libs')
38 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
39 | exclude group: 'com.android.support', module: 'support-annotations'
40 | })
41 | compile project(':library')
42 | // compile 'com.ray:mvplib:0.0.2'
43 | compile 'com.jakewharton:butterknife:8.8.1'
44 | annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
45 | }
46 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/greendao/MyDaoMaster.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.greendao;
2 |
3 | import android.content.Context;
4 | import android.database.sqlite.SQLiteDatabase;
5 |
6 | import com.ray.gen.DaoMaster;
7 | import com.ray.gen.DaoSession;
8 |
9 |
10 | /**
11 | * Created by ray on 2017/6/22.
12 | * emial:1452011874@qq.com
13 | */
14 |
15 | public class MyDaoMaster {
16 | private static MyDaoMaster mMyDaoMaster;
17 | private Context mContext;
18 |
19 | private DaoMaster.DevOpenHelper mHelper;
20 | private SQLiteDatabase db;
21 | private DaoMaster mDaoMaster;
22 | private DaoSession mDaoSession;
23 | public MyDaoMaster(Context mContext) {
24 | this.mContext = mContext;
25 | }
26 |
27 | public static MyDaoMaster getInstance(Context context){
28 | if(mMyDaoMaster==null){
29 | synchronized (MyDaoMaster.class){
30 | if(mMyDaoMaster==null){
31 | mMyDaoMaster=new MyDaoMaster(context.getApplicationContext());
32 | }
33 | }
34 | }
35 | return mMyDaoMaster;
36 | }
37 |
38 | public void init(String Dbname){
39 | mHelper = new DaoMaster.DevOpenHelper(mContext, Dbname, null);
40 | db = mHelper.getWritableDatabase();
41 | // 注意:该数据库连接属于 DaoMaster,所以多个 Session 指的是相同的数据库连接。
42 | mDaoMaster = new DaoMaster(db);
43 | mDaoSession = mDaoMaster.newSession();
44 | }
45 |
46 |
47 | public DaoSession getDaoSession() {
48 | return mDaoSession;
49 | }
50 | public SQLiteDatabase getDb() {
51 | return db;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/library/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 | 10dip
7 | 12dip
8 | 14dip
9 | 15dip
10 | 16dip
11 | 18dip
12 | 20dip
13 | 22dip
14 | 24dip
15 | 70dip
16 |
17 |
18 | 5dip
19 | 10dip
20 | 12dip
21 | 15dip
22 | 20dip
23 | 22dip
24 | 25dip
25 | 30dip
26 | 40dip
27 | 45dip
28 | 50dip
29 | 80dip
30 |
31 | 16sp
32 | 14sp
33 | 16dp
34 | 16dp
35 | 120dp
36 | 2dp
37 | 72dp
38 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/mis_activity_default.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
32 |
33 |
34 |
35 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/view/view/button/MyRadioButton.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.view.view.button;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.drawable.Drawable;
6 | import android.util.AttributeSet;
7 |
8 | import com.ray.library.R;
9 |
10 |
11 | public class MyRadioButton extends android.support.v7.widget.AppCompatRadioButton {
12 | //图片大小
13 | //private int drawableSize;
14 |
15 | public MyRadioButton(Context context) {
16 | this(context,null);
17 | }
18 |
19 | public MyRadioButton(Context context, AttributeSet attrs) {
20 | this(context, attrs, 0);
21 | }
22 |
23 | public MyRadioButton(Context context, AttributeSet attrs, int defStyleAttr) {
24 | super(context, attrs, defStyleAttr);
25 |
26 | TypedArray a = context.obtainStyledAttributes(attrs,
27 | R.styleable.MyRadioButton);
28 | // drawableSize = a.getDimensionPixelSize(R.styleable.MyRadioButton_rbDrawableTopSize, 50);
29 | Drawable drawableTop = a.getDrawable(R.styleable.MyRadioButton_rbDrawableTop);
30 |
31 | //释放资源
32 | a.recycle();
33 |
34 | setCompoundDrawablesWithIntrinsicBounds(null,drawableTop,null,null);
35 | }
36 |
37 | @Override
38 | public void setCompoundDrawablesWithIntrinsicBounds(Drawable left, Drawable top, Drawable right, Drawable bottom) {
39 | super.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
40 | if(top != null){ //这里只要改后面两个参数就好了,一个宽一个是高,如果想知道为什么可以查找源码
41 | top.setBounds(0,0,60,50);
42 | }
43 | setCompoundDrawables(left,top,right,bottom);
44 | }
45 | }
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/view/view/textview/LeanTextView.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.view.view.textview;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.util.AttributeSet;
7 | import android.view.Gravity;
8 |
9 | import com.ray.library.R;
10 |
11 |
12 | /***
13 | * 可以倾斜的textview
14 | */
15 | public class LeanTextView extends android.support.v7.widget.AppCompatTextView {
16 | public int getmDegrees() {
17 | return mDegrees;
18 | }
19 |
20 | public void setmDegrees(int mDegrees) {
21 | this.mDegrees = mDegrees;
22 | invalidate();
23 | }
24 |
25 | private int mDegrees;
26 |
27 | public LeanTextView(Context context) {
28 | super(context, null);
29 | }
30 |
31 | public LeanTextView(Context context, AttributeSet attrs) {
32 | super(context, attrs, android.R.attr.textViewStyle);
33 | this.setGravity(Gravity.CENTER);
34 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.LeanTextView);
35 | mDegrees = a.getDimensionPixelSize(R.styleable.LeanTextView_degree, 0);
36 | a.recycle();
37 | }
38 |
39 | @Override
40 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
41 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
42 | setMeasuredDimension(getMeasuredWidth(), getMeasuredWidth());
43 | }
44 |
45 | @Override
46 | protected void onDraw(Canvas canvas) {
47 | canvas.save();
48 | canvas.translate(getCompoundPaddingLeft(), getExtendedPaddingTop());
49 | canvas.rotate(mDegrees, this.getWidth() / 2f, this.getHeight() / 2f);
50 | super.onDraw(canvas);
51 | canvas.restore();
52 | }
53 | }
--------------------------------------------------------------------------------
/library/src/main/java/magicindicator/buildins/commonnavigator/titles/ColorTransitionPagerTitleView.java:
--------------------------------------------------------------------------------
1 | package magicindicator.buildins.commonnavigator.titles;
2 |
3 | import android.content.Context;
4 |
5 | import magicindicator.buildins.ArgbEvaluatorHolder;
6 |
7 |
8 | /**
9 | * 两种颜色过渡的指示器标题
10 | * 博客: http://hackware.lucode.net
11 | * Created by hackware on 2016/6/26.
12 | */
13 | public class ColorTransitionPagerTitleView extends SimplePagerTitleView {
14 | protected int mSelectedSize=14,mNormalSize=14;
15 |
16 | public ColorTransitionPagerTitleView(Context context) {
17 | super(context);
18 | }
19 |
20 | public ColorTransitionPagerTitleView(Context context,int padding) {
21 | super(context,padding);
22 | }
23 |
24 | @Override
25 | public void onLeave(int index, int totalCount, float leavePercent, boolean leftToRight) {
26 | int color = ArgbEvaluatorHolder.eval(leavePercent, mSelectedColor, mNormalColor);
27 | setTextColor(color);
28 | setTextSize(mNormalSize);
29 | getPaint().setFakeBoldText(false);
30 | // paint.setTypeface(Typeface.create("System", Typeface.BOLD));
31 | }
32 |
33 | @Override
34 | public void onEnter(int index, int totalCount, float enterPercent, boolean leftToRight) {
35 | int color = ArgbEvaluatorHolder.eval(enterPercent, mNormalColor, mSelectedColor);
36 | setTextColor(color);
37 | setTextSize(mSelectedSize);
38 | getPaint().setFakeBoldText(true);
39 | }
40 |
41 | @Override
42 | public void onSelected(int index, int totalCount) {
43 | }
44 |
45 | @Override
46 | public void onDeselected(int index, int totalCount) {
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/mis_cmp_customer_actionbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
15 |
16 |
24 |
25 |
42 |
43 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/utils/VersionInfoUtil.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.utils;
2 |
3 | import android.content.Context;
4 | import android.content.pm.PackageInfo;
5 | import android.content.pm.PackageManager;
6 | import android.os.Build;
7 |
8 |
9 | /**
10 | * Created by ray on 2016/4/13.
11 | * 关于应用版本的一些信息
12 | */
13 | public class VersionInfoUtil {
14 |
15 | /**
16 | * 判断系统api版本是否超过指定数字
17 | * */
18 | public static boolean isVersionOver(int code){
19 | if (Build.VERSION.SDK_INT >=code) {
20 | return true;
21 | }else {
22 | return false;
23 | }
24 | }
25 |
26 |
27 | /**
28 | * 获取版本信息 10
29 | * */
30 | public static int getVersionCode(Context context) {
31 | PackageManager packageManager =context.getPackageManager();
32 | PackageInfo packInfo = null;
33 | try {
34 | packInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
35 | } catch (PackageManager.NameNotFoundException e) {
36 | e.printStackTrace();
37 | }
38 | if(packInfo==null)return 0;
39 | return packInfo.versionCode;
40 | }
41 |
42 | /**
43 | *
44 | * 获取版本名 1.9.6
45 | * */
46 | public static String getVersionName(Context context) {
47 | PackageManager packageManager =context.getPackageManager();
48 | PackageInfo packInfo = null;
49 | try {
50 | packInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
51 | } catch (PackageManager.NameNotFoundException e) {
52 | e.printStackTrace();
53 | }
54 | if(packInfo==null)return "1.0.0";
55 | return packInfo.versionName;
56 | }
57 |
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/view/view/textview/FontTextView.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.view.view.textview;
2 |
3 | import android.content.Context;
4 | import android.graphics.Typeface;
5 | import android.util.AttributeSet;
6 | import android.widget.TextView;
7 |
8 | /**
9 | * Created by xiaoniao on 2016/3/14.
10 | */
11 | public class FontTextView extends TextView {
12 |
13 | public static Typeface tf;
14 | public static Typeface tf_bold;
15 |
16 | public FontTextView(Context context) {
17 | super(context);
18 | }
19 |
20 | public FontTextView(Context context, AttributeSet attrs) {
21 | super(context, attrs);
22 |
23 | }
24 | public FontTextView(Context context, AttributeSet attrs, int defStyleAttr) {
25 | super(context, attrs, defStyleAttr);
26 | }
27 | /**
28 | * 字体
29 | */
30 | public void init(Context context){
31 |
32 |
33 | if (tf == null) {
34 | tf = Typeface.createFromAsset(context.getAssets(),
35 | "font/SIMYOU.TTF");
36 | }
37 | setTypeface(tf);
38 | }
39 |
40 |
41 | @Override
42 | public void setTypeface(Typeface tf1, int style) {
43 | if (style == Typeface.BOLD){
44 | if (tf_bold == null){
45 | tf_bold = Typeface.createFromAsset(getContext().getAssets(),
46 | "font/pingfangbold.ttf");
47 | }
48 | super.setTypeface(tf_bold);
49 | }else {
50 | if (tf == null) {
51 | tf = Typeface.createFromAsset(getContext().getAssets(),
52 | "font/pingfangregular.ttf");
53 | }
54 | super.setTypeface(tf);
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/common_title.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
20 |
21 |
32 |
33 |
45 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/view/view/baseadapter/listener/OnItemSwipeListener.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.view.view.baseadapter.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 | /**
12 | * Called when the swipe action go.
13 | */
14 | void onItemSwipeStart(RecyclerView.ViewHolder viewHolder, int pos);
15 |
16 | /**
17 | * Called when the swipe action is over.
18 | * If you change the view on the go, you should reset is here, no matter the item has swiped or not.
19 | * @param pos If the view is swiped, pos will be negative.
20 | */
21 | void clearView(RecyclerView.ViewHolder viewHolder, int pos);
22 | /**
23 | * Called when item is swiped, the view is going to be removed from the adapter.
24 | */
25 | void onItemSwiped(RecyclerView.ViewHolder viewHolder, int pos);
26 |
27 | /**
28 | * Draw on the empty edge when swipe moving
29 | * @param canvas the empty edge's canvas
30 | * @param viewHolder The ViewHolder which is being interacted by the UserDemo or it was
31 | * interacted and simply animating to its original position
32 | * @param dX The amount of horizontal displacement caused by user's action
33 | * @param dY The amount of vertical displacement caused by user's action
34 | * @param isCurrentlyActive True if this view is currently being controlled by the user or
35 | * false it is simply animating back to its original state.
36 | */
37 | void onItemSwipeMoving(Canvas canvas, RecyclerView.ViewHolder viewHolder, float dX, float dY, boolean isCurrentlyActive);
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/utils/L.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.utils;
2 |
3 | import android.util.Log;
4 |
5 | /**
6 | * Created by caism on 2017/4/13.
7 | */
8 |
9 | public class L {
10 | private L(){
11 | throw new UnsupportedOperationException("cannot be instantiated");
12 | }
13 | public static boolean isDebug = true;//是否需要打印bug,可以在applation的oncreate里初始化
14 | private static final String TAG = "";
15 | public static void i(String msg){
16 | if (isDebug){
17 | Log.i(TAG,msg);
18 | }
19 | }
20 | public static void d(String msg){
21 | if (isDebug){
22 | Log.d(TAG,msg);
23 | }
24 | }
25 | public static void e(String msg){
26 | if (isDebug){
27 | Log.e(TAG,msg);
28 | }
29 | }
30 | public static void v(String msg){
31 | if (isDebug){
32 | Log.v(TAG,msg);
33 | }
34 | }
35 | public static void i(String tag, String msg){
36 | if (isDebug){
37 | Log.i(tag,msg);
38 | }
39 | }
40 | public static void d(String tag, String msg){
41 | if (isDebug){
42 | Log.d(tag,msg);
43 | }
44 | }
45 | public static void e(String tag, String msg){
46 | if (isDebug){
47 | Log.e(tag,msg);
48 | }
49 | }
50 | public static void w(String tag, String msg){
51 | if (isDebug){
52 | Log.w(tag,msg);
53 | }
54 | }
55 | public static void v(String tag, String msg){
56 | if (isDebug){
57 | Log.v(tag,msg);
58 | }
59 | }
60 |
61 | public static void f(String name, String msg){
62 | if (isDebug){
63 | FileUtils.writeTxtToFile(msg,FileUtils.path,name);
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/utils/SeviceUtils.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.utils;
2 |
3 | import android.app.ActivityManager;
4 | import android.content.ComponentName;
5 | import android.content.Context;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * Created by caism on 2017/4/16.
11 | */
12 |
13 | public class SeviceUtils {
14 | /**
15 | * 判断当前应用程序处于前台还是后台
16 | */
17 | public static boolean isAppAtBackground(final Context context) {
18 | ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
19 | List tasks = am.getRunningTasks(1);
20 | if (!tasks.isEmpty()) {
21 | ComponentName topActivity = tasks.get(0).topActivity;
22 | if (!topActivity.getPackageName().equals(context.getPackageName())) {
23 | return true;
24 | }
25 | }
26 | return false;
27 | }
28 | /**
29 | * 用来判断服务是否运行.
30 | * @param
31 | * @param className 判断的服务名字
32 | * @return true 在运行 false 不在运行
33 | */
34 | public static boolean isServiceRunning(Context mContext, String className) {
35 | boolean isRunning = false;
36 | ActivityManager activityManager = (ActivityManager)
37 | mContext.getSystemService(Context.ACTIVITY_SERVICE);
38 | List serviceList
39 | = activityManager.getRunningServices(34);
40 | if (!(serviceList.size()>0)) {
41 | return false;
42 | }
43 | for (int i=0; i extends DiffUtil.Callback {
14 | protected List mOldL, mNewL;
15 | private int type=-1;
16 |
17 | /* public DiffCallback(List oldL, List newL) {
18 | this.mOldL = oldL;
19 | this.mNewL = newL;
20 | }*/
21 |
22 |
23 | /**
24 | * 列表数据
25 | * */
26 | public void setData(int type, List o, List n) {
27 | this.type=type;
28 | mOldL = o;
29 | mNewL = n;
30 | }
31 |
32 |
33 | /**
34 | * 单个数据
35 | * */
36 | public void setData(int type,T o, T n) {
37 | this.type=type;
38 | List os=new ArrayList();
39 | List on=new ArrayList();
40 | os.add(o);on.add(n);
41 | mOldL = os;
42 | mNewL = on;
43 | }
44 |
45 |
46 | @Override
47 | public int getOldListSize() {
48 | return mOldL == null ? 0 : mOldL.size();
49 | }
50 |
51 | @Override
52 | public int getNewListSize() {
53 | return mNewL == null ? 0 : mNewL.size();
54 | }
55 |
56 | @Override
57 | public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) {
58 | Object oldD=mOldL.get(oldItemPosition);
59 | Object newD=mNewL.get(newItemPosition);
60 | if(oldD==null)return false;
61 | if(newD==null)return false;
62 | return /*DataUtils.isSame(type,oldD,newD)*/false;
63 | }
64 |
65 | @Override
66 | public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
67 | return false;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/view/view/imageview/GlideCircleTransform.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.view.view.imageview;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.graphics.BitmapShader;
6 | import android.graphics.Canvas;
7 | import android.graphics.Paint;
8 |
9 | import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
10 | import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
11 |
12 | public class GlideCircleTransform extends BitmapTransformation {
13 | public GlideCircleTransform(Context context) {
14 | super(context);
15 | }
16 |
17 | @Override
18 | protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
19 | return circleCrop(pool, toTransform);
20 | }
21 |
22 | private static Bitmap circleCrop(BitmapPool pool, Bitmap source) {
23 | if (source == null) return null;
24 |
25 | int size = Math.min(source.getWidth(), source.getHeight());
26 | int x = (source.getWidth() - size) / 2;
27 | int y = (source.getHeight() - size) / 2;
28 |
29 | Bitmap squared = Bitmap.createBitmap(source, x, y, size, size);
30 |
31 | Bitmap result = pool.get(size, size, Bitmap.Config.ARGB_8888);
32 | if (result == null) {
33 | result = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
34 | }
35 |
36 | Canvas canvas = new Canvas(result);
37 | Paint paint = new Paint();
38 | paint.setShader(new BitmapShader(squared, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
39 | paint.setAntiAlias(true);
40 | float r = size / 2f;
41 | canvas.drawCircle(r, r, r, paint);
42 | return result;
43 | }
44 |
45 | @Override
46 | public String getId() {
47 | return getClass().getName();
48 | }
49 | }
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/view/view/imageview/RoundImageView.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.view.view.imageview;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Path;
6 | import android.os.Build;
7 | import android.util.AttributeSet;
8 | import android.view.View;
9 |
10 | public class RoundImageView extends android.support.v7.widget.AppCompatImageView {
11 |
12 | float width,height;
13 |
14 | public RoundImageView(Context context) {
15 | this(context, null);
16 | }
17 |
18 | public RoundImageView(Context context, AttributeSet attrs) {
19 | this(context, attrs, 0);
20 | }
21 |
22 | public RoundImageView(Context context, AttributeSet attrs, int defStyleAttr) {
23 | super(context, attrs, defStyleAttr);
24 | if (Build.VERSION.SDK_INT < 18) {
25 | setLayerType(View.LAYER_TYPE_SOFTWARE, null);
26 | }
27 | }
28 |
29 | @Override
30 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
31 | super.onLayout(changed, left, top, right, bottom);
32 | width = getWidth();
33 | height = getHeight();
34 | }
35 |
36 | @Override
37 | protected void onDraw(Canvas canvas) {
38 |
39 | if (width > 12 && height > 12) {
40 | Path path = new Path();
41 | path.moveTo(12, 0);
42 | path.lineTo(width - 12, 0);
43 | path.quadTo(width, 0, width, 12);
44 | path.lineTo(width, height - 12);
45 | path.quadTo(width, height, width - 12, height);
46 | path.lineTo(12, height);
47 | path.quadTo(0, height, 0, height - 12);
48 | path.lineTo(0, 12);
49 | path.quadTo(0, 0, 12, 0);
50 | canvas.clipPath(path);
51 | }
52 |
53 | super.onDraw(canvas);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/library/src/main/java/multiitem/adapter/holder/DataBindViewHolderManager.java:
--------------------------------------------------------------------------------
1 | package multiitem.adapter.holder;
2 |
3 | import android.databinding.ViewDataBinding;
4 | import android.support.annotation.LayoutRes;
5 | import android.support.annotation.NonNull;
6 |
7 |
8 | /**
9 | * 数据绑定ViewHolderManager
10 | * Created by free46000 on 2017/4/6.
11 | */
12 | public class DataBindViewHolderManager extends BindViewHolderManager {
13 | @LayoutRes
14 | private int itemLayoutId;
15 | private ItemBindView itemBindView;
16 |
17 | /**
18 | * @param itemLayoutId item 布局文件资源id
19 | * @param bindVariableId 需要绑定一个VariableId时使用本构造函数
20 | */
21 | public DataBindViewHolderManager(@LayoutRes int itemLayoutId, int bindVariableId) {
22 | this(itemLayoutId, (dataBinding, data) -> dataBinding.setVariable(bindVariableId, data));
23 | }
24 |
25 | /**
26 | * @param itemLayoutId item 布局文件资源id
27 | * @param itemBindView item数据绑定回调 可以自定义绑定逻辑
28 | */
29 | public DataBindViewHolderManager(@LayoutRes int itemLayoutId, @NonNull ItemBindView itemBindView) {
30 | this.itemLayoutId = itemLayoutId;
31 | this.itemBindView = itemBindView;
32 | }
33 |
34 | /**
35 | * 绑定数据到视图 {@link ItemBindView}
36 | *
37 | * @param dataBinding item视图对应dataBinding类
38 | * @param data 数据源
39 | */
40 | @Override
41 | protected void onBindViewHolder(ViewDataBinding dataBinding, T data) {
42 | itemBindView.onBindViewHolder(dataBinding, data);
43 | }
44 |
45 | @Override
46 | protected int getItemLayoutId() {
47 | return itemLayoutId;
48 | }
49 |
50 |
51 | /**
52 | * item数据绑定回调接口,在回调方法中自定义绑定逻辑
53 | */
54 | @FunctionalInterface
55 | public interface ItemBindView {
56 | void onBindViewHolder(ViewDataBinding dataBinding, T data);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/mis_fragment_multi_image.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
17 |
18 |
25 |
26 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/library/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | #59b0ff
5 | #303F9F
6 | #FF4081
7 |
8 | #F0F0F0
9 | #00000000
10 | #88000000
11 | #FFFFFF
12 | #FFFF00
13 | #000000
14 | #E93E45
15 | #B7B7B7
16 | #59b0ff
17 | #428bca
18 |
19 | #D3D3D3
20 | #666666
21 | #898989
22 | #eeeeee
23 | #00BCD4
24 | #00000000
25 | #F09C61
26 |
27 |
28 | #636060
29 | #32f1f1f1
30 | #02B890
31 | #91e2d0
32 | #21282C
33 |
34 | #626262
35 | #878787
36 | #AAAAAA
37 | #CFCFCF
38 | #83DC3B
39 | #8083DC3B
40 | #8088DD88
41 |
42 |
43 | #0076FF
44 | #333333
45 |
46 |
47 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/view/view/baseadapter/BaseMultiItemQuickAdapter.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.view.view.baseadapter;
2 |
3 | import android.util.SparseArray;
4 | import android.view.ViewGroup;
5 |
6 | import com.ray.library.view.view.baseadapter.entity.MultiItemEntity;
7 |
8 | import java.util.List;
9 |
10 | /**
11 | * https://github.com/CymChad/BaseRecyclerViewAdapterHelper
12 | */
13 | public abstract class BaseMultiItemQuickAdapter extends BaseQuickAdapter {
14 |
15 | /**
16 | * layouts indexed with their types
17 | */
18 | private SparseArray layouts;
19 |
20 | /**
21 | * Same as QuickAdapter#QuickAdapter(Context,int) but with
22 | * some initialization data.
23 | *
24 | * @param data A new list is created out of this one to avoid mutable list
25 | */
26 | public BaseMultiItemQuickAdapter( List data) {
27 | super( data);
28 | }
29 |
30 | @Override
31 | protected int getDefItemViewType(int position) {
32 | return ((MultiItemEntity) mData.get(position)).getItemType();
33 | }
34 |
35 |
36 | @Override
37 | protected BaseViewHolder onCreateDefViewHolder(ViewGroup parent, int viewType) {
38 | return createBaseViewHolder(parent, getLayoutId(viewType));
39 | }
40 |
41 | private int getLayoutId(int viewType) {
42 | return layouts.get(viewType);
43 | }
44 |
45 | protected void addItemType(int type, int layoutResId) {
46 | if (layouts == null) {
47 | layouts = new SparseArray<>();
48 | }
49 | layouts.put(type, layoutResId);
50 | }
51 |
52 |
53 | @Override
54 | protected void convert(BaseViewHolder helper, Object item, int position) {
55 | convert(helper, (T) item);
56 | }
57 |
58 | protected abstract void convert(BaseViewHolder helper, T item);
59 |
60 |
61 | }
62 |
63 |
64 |
--------------------------------------------------------------------------------
/library/src/main/res/layout/view_empty.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
17 |
18 |
24 |
25 |
35 |
36 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/view/view/recyclerviewHelper/GridSpacingItemDecoration.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.view.view.recyclerviewHelper;
2 |
3 | import android.graphics.Rect;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.View;
6 |
7 | /**
8 | * 设置RecyclerView GridLayoutManager or StaggeredGridLayoutManager spacing
9 | * Created by john on 17-1-5.
10 | */
11 |
12 | public class GridSpacingItemDecoration extends RecyclerView.ItemDecoration {
13 |
14 | private int spanCount;
15 | private int spacing;
16 | private boolean includeEdge;
17 |
18 | public GridSpacingItemDecoration(int spanCount, int spacing, boolean includeEdge) {
19 | this.spanCount = spanCount;
20 | this.spacing = spacing;
21 | this.includeEdge = includeEdge;
22 | }
23 |
24 | @Override
25 | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
26 | int position = parent.getChildAdapterPosition(view); // item position
27 | int column = position % spanCount; // item column
28 |
29 | if (includeEdge) {
30 | outRect.left = spacing - column * spacing / spanCount; // spacing - column * ((1f / spanCount) * spacing)
31 | outRect.right = (column + 1) * spacing / spanCount; // (column + 1) * ((1f / spanCount) * spacing)
32 |
33 | if (position < spanCount) { // top edge
34 | outRect.top = spacing;
35 | }
36 | outRect.bottom = spacing; // item bottom
37 | } else {
38 | outRect.left = column * spacing / spanCount; // column * ((1f / spanCount) * spacing)
39 | outRect.right = spacing - (column + 1) * spacing / spanCount; // spacing - (column + 1) * ((1f / spanCount) * spacing)
40 | if (position >= spanCount) {
41 | outRect.top = spacing; // item top
42 | }
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/library/src/main/res/layout/view_tab_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
21 |
27 |
39 |
40 |
48 |
49 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/view/view/photoview/PhotoViewAdapter.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.view.view.photoview;
2 |
3 | import android.content.Context;
4 | import android.support.v4.view.PagerAdapter;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | import java.util.List;
9 |
10 | public class PhotoViewAdapter extends PagerAdapter {
11 |
12 | protected final Context mContext;
13 | private List imgUrls;
14 | protected OnItemChangeListener mOnItemChangeListener;
15 |
16 | public PhotoViewAdapter(Context mContext, List imgUrls) {
17 | this.mContext = mContext;
18 | this.imgUrls = imgUrls;
19 | }
20 |
21 | @Override
22 | public int getCount() {
23 | return imgUrls.size();
24 | }
25 |
26 | @Override
27 | public void setPrimaryItem(ViewGroup container, int position, Object object) {
28 | super.setPrimaryItem(container, position, object);
29 | if (mOnItemChangeListener != null)
30 | mOnItemChangeListener.onItemChange(position);
31 | }
32 |
33 | @Override
34 | public View instantiateItem(ViewGroup container, int position) {
35 | final PhotoViewWrapper iv = new PhotoViewWrapper(mContext);
36 | iv.setTag(position);
37 | iv.setUrl(imgUrls.get(position));
38 | iv.setLayoutParams(new ViewGroup.LayoutParams(
39 | ViewGroup.LayoutParams.MATCH_PARENT,
40 | ViewGroup.LayoutParams.MATCH_PARENT));
41 |
42 | container.addView(iv, 0);
43 | return iv;
44 | }
45 |
46 | @Override
47 | public void destroyItem(ViewGroup container, int position, Object object) {
48 | container.removeView((View) object);
49 | }
50 |
51 | @Override
52 | public boolean isViewFromObject(View view, Object object) {
53 | return view == object;
54 | }
55 |
56 | public void setOnItemChangeListener(OnItemChangeListener listener) {
57 | mOnItemChangeListener = listener;
58 | }
59 |
60 | public static interface OnItemChangeListener {
61 | public void onItemChange(int currentPosition);
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/library/src/main/java/multiitem/helper/StateViewHelper.java:
--------------------------------------------------------------------------------
1 | package multiitem.helper;
2 |
3 | import android.support.annotation.NonNull;
4 | import android.support.v7.widget.RecyclerView;
5 |
6 | import multiitem.adapter.BaseItemAdapter;
7 | import multiitem.item.BaseItemState;
8 |
9 | /**
10 | * 状态页(如空白错误页等)辅助类
11 | *
12 | * 状态页展示时会作为RecyclerView的唯一的Item展示在界面中
13 | * 注意:需要在RecyclerView设置完adapter后在初始化本实例
14 | * Created by free46000 on 2017/4/23.
15 | */
16 | public class StateViewHelper {
17 | private RecyclerView recyclerView;
18 | private BaseItemState itemState;
19 |
20 | private RecyclerView.Adapter dataAdapter;
21 | private BaseItemAdapter stateAdapter;
22 |
23 | /**
24 | * 需要在RecyclerView设置完adapter后在初始化本实例
25 | *
26 | * @param recyclerView
27 | * @param itemState
28 | */
29 | public StateViewHelper(@NonNull RecyclerView recyclerView, @NonNull BaseItemState itemState) {
30 | this.recyclerView = recyclerView;
31 | //记住RecyclerView初始的Adapter
32 | this.dataAdapter = recyclerView.getAdapter();
33 | if (dataAdapter == null) {
34 | throw new IllegalArgumentException("请在设置完adapter后在初始化本实例!");
35 | }
36 | this.itemState = itemState;
37 | }
38 |
39 | /**
40 | * 展示状态页
41 | *
42 | * 为RecyclerView设置新的stateAdapter,本adapter中保存唯一的状态页Item{@link BaseItemState}
43 | */
44 | public void show() {
45 | if (stateAdapter != null) {
46 | return;
47 | }
48 | stateAdapter = new BaseItemAdapter();
49 | stateAdapter.addDataItem(itemState);
50 | recyclerView.setAdapter(stateAdapter);
51 | }
52 |
53 | /**
54 | * 隐藏状态页
55 | *
56 | * 将RecyclerView的Adapter设置为初始化时记住的Adapter
57 | */
58 | public void hide() {
59 | if (dataAdapter == null) {
60 | return;
61 | }
62 | stateAdapter = null;
63 | recyclerView.setAdapter(dataAdapter);
64 | }
65 |
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/utils/DensityUtils.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.utils;
2 |
3 | import android.content.Context;
4 | import android.util.TypedValue;
5 |
6 | /**
7 | * Created by Ray on 2017/12/13.
8 | */
9 |
10 | public class DensityUtils {
11 | /**
12 |
13 | * dp转px
14 |
15 | *
16 |
17 | * @param context
18 |
19 | * @param val
20 |
21 | * @return
22 |
23 | */
24 |
25 | public static int dp2px(Context context, float dpVal)
26 |
27 | {
28 |
29 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
30 |
31 | dpVal, context.getResources().getDisplayMetrics());
32 |
33 | }
34 |
35 |
36 |
37 | /**
38 |
39 | * sp转px
40 |
41 | *
42 |
43 | * @param context
44 |
45 | * @param val
46 |
47 | * @return
48 |
49 | */
50 |
51 | public static int sp2px(Context context, float spVal)
52 |
53 | {
54 |
55 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,
56 |
57 | spVal, context.getResources().getDisplayMetrics());
58 |
59 | }
60 |
61 |
62 |
63 | /**
64 |
65 | * px转dp
66 |
67 | *
68 |
69 | * @param context
70 |
71 | * @param pxVal
72 |
73 | * @return
74 |
75 | */
76 |
77 | public static float px2dp(Context context, float pxVal)
78 |
79 | {
80 |
81 | final float scale = context.getResources().getDisplayMetrics().density;
82 |
83 | return (pxVal / scale);
84 |
85 | }
86 |
87 |
88 |
89 | /**
90 |
91 | * px转sp
92 |
93 | *
94 |
95 | * @param fontScale
96 |
97 | * @param pxVal
98 |
99 | * @return
100 |
101 | */
102 |
103 | public static float px2sp(Context context, float pxVal)
104 |
105 | {
106 |
107 | return (pxVal / context.getResources().getDisplayMetrics().scaledDensity);
108 |
109 | }
110 |
111 | }
112 |
--------------------------------------------------------------------------------
/library/src/main/java/magicindicator/MagicIndicator.java:
--------------------------------------------------------------------------------
1 | package magicindicator;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.View;
6 | import android.widget.FrameLayout;
7 |
8 | import magicindicator.abs.IPagerNavigator;
9 |
10 | /**
11 | * 整个框架的入口,核心
12 | * 博客: http://hackware.lucode.net
13 | * Created by hackware on 2016/6/26.
14 | */
15 | public class MagicIndicator extends FrameLayout {
16 | private IPagerNavigator mNavigator;
17 |
18 | public MagicIndicator(Context context) {
19 | super(context);
20 | }
21 |
22 | public MagicIndicator(Context context, AttributeSet attrs) {
23 | super(context, attrs);
24 | }
25 |
26 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
27 | if (mNavigator != null) {
28 | mNavigator.onPageScrolled(position, positionOffset, positionOffsetPixels);
29 | }
30 | }
31 |
32 | public void onPageSelected(int position) {
33 | if (mNavigator != null) {
34 | mNavigator.onPageSelected(position);
35 | }
36 | }
37 |
38 | public void onPageScrollStateChanged(int state) {
39 | if (mNavigator != null) {
40 | mNavigator.onPageScrollStateChanged(state);
41 | }
42 | }
43 |
44 | public IPagerNavigator getNavigator() {
45 | return mNavigator;
46 | }
47 |
48 | public void setNavigator(IPagerNavigator navigator) {
49 | if (mNavigator == navigator) {
50 | return;
51 | }
52 | if (mNavigator != null) {
53 | mNavigator.onDetachFromMagicIndicator();
54 | }
55 | mNavigator = navigator;
56 | removeAllViews();
57 | if (mNavigator instanceof View) {
58 | LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
59 | addView((View) mNavigator, lp);
60 | mNavigator.onAttachToMagicIndicator();
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/view/view/imageview/GlideRoundTransform.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.view.view.imageview;
2 |
3 | import android.content.Context;
4 | import android.content.res.Resources;
5 | import android.graphics.Bitmap;
6 | import android.graphics.BitmapShader;
7 | import android.graphics.Canvas;
8 | import android.graphics.Paint;
9 | import android.graphics.RectF;
10 |
11 | import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
12 | import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
13 |
14 | public class GlideRoundTransform extends BitmapTransformation {
15 |
16 | private static float radius = 0f;
17 |
18 | public GlideRoundTransform(Context context) {
19 | this(context, 15);
20 | }
21 |
22 | public GlideRoundTransform(Context context, int dp) {
23 | super(context);
24 | this.radius = Resources.getSystem().getDisplayMetrics().density * dp;
25 | }
26 |
27 | @Override
28 | protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
29 | return roundCrop(pool, toTransform);
30 | }
31 |
32 | private static Bitmap roundCrop(BitmapPool pool, Bitmap source) {
33 | if (source == null) return null;
34 |
35 | Bitmap result = pool.get(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
36 | if (result == null) {
37 | result = Bitmap.createBitmap(source.getWidth(), source.getHeight(), Bitmap.Config.ARGB_8888);
38 | }
39 |
40 | Canvas canvas = new Canvas(result);
41 | Paint paint = new Paint();
42 | paint.setShader(new BitmapShader(source, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP));
43 | paint.setAntiAlias(true);
44 | RectF rectF = new RectF(0f, 0f, source.getWidth(), source.getHeight());
45 | canvas.drawRoundRect(rectF, radius, radius, paint);
46 | return result;
47 | }
48 |
49 | @Override
50 | public String getId() {
51 | return getClass().getName() + Math.round(radius);
52 | }
53 | }
--------------------------------------------------------------------------------
/library/src/main/java/multiitem/adapter/holder/ViewHolderManagerGroup.java:
--------------------------------------------------------------------------------
1 | package multiitem.adapter.holder;
2 |
3 | /**
4 | * 多个ViewHolder的管理类的组合
5 | * 主要为相同数据源根据内部属性的值会对应多个ViewHolderManager设计,常见的如聊天界面的消息
6 | * Created by free46000 on 2017/3/20.
7 | */
8 | public abstract class ViewHolderManagerGroup {
9 | private ViewHolderManager[] viewHolderManagers;
10 |
11 | /**
12 | * @param viewHolderManagers 相同数据源对应的所有ViewHolderManager
13 | */
14 | public ViewHolderManagerGroup(ViewHolderManager... viewHolderManagers) {
15 | if (viewHolderManagers == null || viewHolderManagers.length == 0) {
16 | throw new IllegalArgumentException("viewHolderManagers can not be null");
17 | }
18 | this.viewHolderManagers = viewHolderManagers;
19 | }
20 |
21 | /**
22 | * 根据item数据源中的属性判断应该返回的对应viewHolderManagers的index值
23 | *
24 | * @param itemData item数据源
25 | * @return index值应该是在viewHolderManagers数组有效范围内
26 | */
27 | public abstract int getViewHolderManagerIndex(T itemData);
28 |
29 | /**
30 | * 根据item数据源中的属性判断应该返回的对应viewHolderManager
31 | *
32 | * @param itemData item数据源
33 | * @return viewHolderManager
34 | */
35 | public ViewHolderManager getViewHolderManager(T itemData) {
36 | int index = getViewHolderManagerIndex(itemData);
37 | if (index < 0 || index > viewHolderManagers.length - 1) {
38 | throw new IllegalArgumentException("ViewHolderManagerGroup中的getViewHolderManagerIndex方法返回的index必须在有效范围内");
39 | }
40 | return viewHolderManagers[index];
41 | }
42 |
43 | /**
44 | * 通过viewHolderManager获取标识字符串,为了方便查找ViewHolderManager
45 | *
46 | * @param viewHolderManager ViewHolderManager
47 | * @return 获取viewHolderManager标识字符串
48 | */
49 | public String getViewHolderManagerTag(ViewHolderManager viewHolderManager) {
50 | return viewHolderManager.getClass().getName();
51 | }
52 |
53 | public ViewHolderManager[] getViewHolderManagers() {
54 | return viewHolderManagers;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/app/src/main/java/com/ray/projectframe/Fragment1.java:
--------------------------------------------------------------------------------
1 | package com.ray.projectframe;
2 |
3 | import android.graphics.Color;
4 | import android.view.View;
5 | import android.widget.TextView;
6 |
7 | import com.ray.library.base.ui.BaseFragment;
8 |
9 | import java.util.Random;
10 | import java.util.Timer;
11 | import java.util.TimerTask;
12 |
13 | import butterknife.BindView;
14 | import butterknife.ButterKnife;
15 | import tyrantgit.widget.HeartLayout;
16 |
17 | public class Fragment1 extends BaseFragment {
18 |
19 | @BindView(R.id.txt)
20 | TextView txt;
21 | @BindView(R.id.heart_layout)
22 | HeartLayout mHeartLayout;
23 | private Timer timer;
24 |
25 | @Override
26 | protected int inflateContentView() {
27 | return R.layout.fragment;
28 | }
29 |
30 | @Override
31 | protected void initPresenter() {
32 |
33 | }
34 |
35 | @Override
36 | protected void initEvents() {
37 | }
38 |
39 | @Override
40 | protected void initView(View view) {
41 | ButterKnife.bind(this,view);
42 | mHeartLayout.setOnClickListener(v -> {
43 | if(!isRun){
44 | start();
45 | }else {
46 | stop();
47 | }
48 | // mHeartLayout.addHeart(randomColor());
49 | });
50 |
51 | }
52 |
53 | private boolean isRun=false;
54 | private void start(){
55 | isRun=true;
56 | timer = new Timer();
57 | timer.scheduleAtFixedRate(new TimerTask() {
58 | @Override
59 | public void run() {
60 | mHeartLayout.post(() -> mHeartLayout.addHeart(randomColor()));
61 | }
62 | }, 100, 100);
63 | }
64 |
65 | private void stop(){
66 | isRun=false;
67 | timer.cancel();
68 | }
69 |
70 | @Override
71 | public void onDestroy() {
72 | super.onDestroy();
73 | stop();
74 | }
75 | private int randomColor() {
76 | return Color.rgb(new Random().nextInt(255), new Random().nextInt(255), new Random().nextInt(255));
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/common/adapter/RecyleAdapter.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.common.adapter;
2 |
3 | import android.content.Context;
4 |
5 | import com.ray.library.common.adapter.base.BaseAdapterHelper;
6 | import com.ray.library.common.adapter.base.BaseQuickAdapter;
7 | import com.ray.library.common.adapter.base.MultiItemTypeSupport;
8 |
9 | import java.util.List;
10 |
11 |
12 | /**
13 | * Created by HanHailong on 15/9/6.
14 | */
15 | public abstract class RecyleAdapter extends BaseQuickAdapter {
16 |
17 | /**
18 | * Create a QuickAdapter.
19 | *
20 | * @param context The context.
21 | * @param layoutResId The layout resource id of each item.
22 | */
23 | public RecyleAdapter(Context context, int layoutResId) {
24 | super(context, layoutResId);
25 | }
26 |
27 | /**
28 | * Same as QuickAdapter#QuickAdapter(Context,int) but with
29 | * some initialization mData.
30 | *
31 | * @param context The context.
32 | * @param layoutResId The layout resource id of each item.
33 | * @param data A new list is created out of this one to avoid mutable list
34 | */
35 | public RecyleAdapter(Context context, int layoutResId, List data) {
36 | super(context, layoutResId, data);
37 | }
38 |
39 | /**
40 | * Create a multi-view-type QuickAdapter
41 | *
42 | * @param context The context
43 | * @param multiItemTypeSupport multiitemtypesupport
44 | */
45 | protected RecyleAdapter(Context context, MultiItemTypeSupport multiItemTypeSupport) {
46 | super(context, multiItemTypeSupport);
47 | }
48 |
49 | /**
50 | * Same as QuickAdapter#QuickAdapter(Context,MultiItemTypeSupport) but with
51 | * some initialization mData
52 | *
53 | * @param context
54 | * @param multiItemTypeSupport
55 | * @param data
56 | */
57 | protected RecyleAdapter(Context context, MultiItemTypeSupport multiItemTypeSupport, List data) {
58 | super(context, multiItemTypeSupport, data);
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/utils/ScreenUtils.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.utils;
2 |
3 | import android.app.Activity;
4 | import android.graphics.Color;
5 | import android.os.Build;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.view.Window;
9 | import android.view.WindowManager;
10 |
11 | /**
12 | * Created by Ray on 2017/5/16.
13 | * email:1452011874@qq.com
14 | */
15 |
16 | public class ScreenUtils {
17 |
18 | //设置透明状态栏
19 | public static void virtualStatusBar(Activity activity) {
20 | Window window = activity.getWindow();
21 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
22 | window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION |
23 | WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
24 | window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
25 | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
26 | window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
27 | window.setStatusBarColor(Color.TRANSPARENT);
28 | window.setNavigationBarColor(Color.TRANSPARENT);
29 | } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
30 | window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
31 | }
32 | }
33 |
34 | public static void smoothSwitchScreen(Activity activity) {
35 | // 5.0以上修复了此bug
36 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
37 | ViewGroup rootView = ((ViewGroup) activity.findViewById(android.R.id.content));
38 | int resourceId = activity.getResources().getIdentifier("status_bar_height", "dimen", "android");
39 | int statusBarHeight = activity.getResources().getDimensionPixelSize(resourceId);
40 | rootView.setPadding(0, statusBarHeight, 0, 0);
41 | activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
42 | activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/library/src/main/java/com/ray/library/retrofit/BaseApiManager.java:
--------------------------------------------------------------------------------
1 | package com.ray.library.retrofit;
2 |
3 |
4 | import com.jakewharton.retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
5 |
6 | import java.util.concurrent.TimeUnit;
7 |
8 | import okhttp3.Interceptor;
9 | import okhttp3.OkHttpClient;
10 | import okhttp3.logging.HttpLoggingInterceptor;
11 | import retrofit2.Retrofit;
12 | import retrofit2.converter.gson.GsonConverterFactory;
13 |
14 | /**
15 | * Created by Ray on 2017/5/7.
16 | * email:1452011874@qq.com
17 | */
18 | public class BaseApiManager {
19 |
20 | public static String ROOT_URL = "";
21 | private static Retrofit retrofit;
22 |
23 | /**
24 | * 初始化api
25 | * @param apiServer
26 | * @param rootUrl
27 | * @param interceptors 选择添加拦截器
28 | * @param
29 | * @return
30 | */
31 | public static T create(Class apiServer, String rootUrl, Interceptor...interceptors){
32 | if(retrofit==null) {
33 | ROOT_URL=rootUrl;
34 | HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
35 | logging.setLevel(HttpLoggingInterceptor.Level.BODY);
36 | OkHttpClient.Builder builder=new OkHttpClient.Builder();
37 | for (Interceptor interceptor : interceptors) {
38 | builder.addInterceptor(interceptor);
39 | }
40 | OkHttpClient okHttpClient = builder
41 | .readTimeout(30, TimeUnit.SECONDS)
42 | .connectTimeout(30, TimeUnit.SECONDS)
43 | .addInterceptor(logging)
44 | .build();
45 |
46 | retrofit=new Retrofit.Builder()
47 | .client(okHttpClient)
48 | .baseUrl(rootUrl)
49 | .addConverterFactory(GsonConverterFactory.create())
50 | .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
51 | .build();
52 | }
53 | return retrofit.create(apiServer);
54 | }
55 |
56 | public static T get(Class apiServer) {
57 | if(retrofit==null) throw new NullPointerException("请先初始化");
58 | return retrofit.create(apiServer);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------