11 |
12 |
--------------------------------------------------------------------------------
/MyApplication/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/MyApplication/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/MyApplication/app/src/androidTest/java/com/john/myapplication/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.john.myapplication;
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("com.john.myapplication", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/java/com/john/myapplication/Bean/RefreshModel.java:
--------------------------------------------------------------------------------
1 | package com.john.myapplication.Bean;
2 |
3 | /**
4 | * 刷新数据实体:
5 | */
6 | public class RefreshModel {
7 | public String title;
8 | public String detail;
9 |
10 | public RefreshModel() {
11 | }
12 |
13 | public RefreshModel(String title, String detail) {
14 | this.title = title;
15 | this.detail = detail;
16 | }
17 | }
--------------------------------------------------------------------------------
/MyApplication/app/src/main/java/com/john/myapplication/Bean/User.kt:
--------------------------------------------------------------------------------
1 | package com.john.myapplication.Bean
2 |
3 | /**
4 | * Created by guqh on 2017/8/2.
5 | */
6 | class User {
7 | var name : String=""
8 | var photo : String=""
9 | }
--------------------------------------------------------------------------------
/MyApplication/app/src/main/java/com/john/myapplication/MyConstants.java:
--------------------------------------------------------------------------------
1 | package com.john.myapplication;
2 |
3 | /**
4 | * @author John Gu
5 | * @date 2017/11/23.
6 | *
7 | * 常量类
8 | */
9 |
10 | public class MyConstants {
11 |
12 | public static final String EXTRA_URL ="url" ;
13 | }
14 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/java/com/john/myapplication/activity/KotlinAndDataBindingActivity.kt:
--------------------------------------------------------------------------------
1 | package com.john.myapplication.activity
2 |
3 | import android.databinding.DataBindingUtil
4 | import com.john.librarys.uikit.activity.BaseActivity
5 | import com.john.myapplication.Bean.User
6 | import com.john.myapplication.R
7 | import com.john.myapplication.databinding.ActivityDatabindingBinding
8 |
9 | /**
10 | * Created by guqh on 2017/8/2.
11 |
12 | * databinding activty 实例
13 | */
14 |
15 | class KotlinAndDataBindingActivity : BaseActivity() {
16 |
17 | override fun setBindingContentView() {
18 | val binding : ActivityDatabindingBinding = DataBindingUtil.setContentView(this, R.layout.activity_databinding)
19 | val mUser:User = User()
20 | mUser.name="这是User_Name"
21 | mUser.photo="http://wx.zshisong.com:8085/imgServer/upload/pic/02f3b3322a844014923453e95806f8a2.jpg"
22 | binding.mUser=mUser
23 | }
24 |
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/java/com/john/myapplication/activity/OpenGlActivity.java:
--------------------------------------------------------------------------------
1 | package com.john.myapplication.activity;
2 |
3 | import android.os.Bundle;
4 | import android.view.MotionEvent;
5 | import android.view.View;
6 | import android.widget.Toast;
7 |
8 | import com.john.librarys.uikit.activity.BaseActivity;
9 | import com.john.myapplication.R;
10 | import com.zph.glpanorama.GLPanorama;
11 |
12 | import butterknife.Bind;
13 | import butterknife.ButterKnife;
14 |
15 | /**
16 | * @author John Gu
17 | * @date 2017/11/23.
18 | * open GL 全景图像
19 | */
20 |
21 | public class OpenGlActivity extends BaseActivity{
22 |
23 | @Bind(R.id.mGLPanorama)
24 | GLPanorama mGLPanorama;
25 | @Override
26 | public void onCreate(Bundle savedInstanceState) {
27 | super.onCreate(savedInstanceState);
28 | setContentView(R.layout.activity_open_gl);
29 | ButterKnife.bind(this);
30 | //传入全景图片
31 | mGLPanorama.setGLPanorama(R.drawable.imgbug);
32 | // mGLPanorama.setOnTouchListener(new View.OnTouchListener() {
33 | // @Override
34 | // public boolean onTouch(View view, MotionEvent motionEvent) {
35 | // Toast.makeText(mContext,"点了X"+ motionEvent.getX()+ "Y"+ motionEvent.getY(),Toast.LENGTH_LONG).show();
36 | // return false;
37 | // }
38 | // });
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/java/com/john/myapplication/adapter/DataBindingListViewAdapter.java:
--------------------------------------------------------------------------------
1 | package com.john.myapplication.adapter;
2 |
3 | import android.content.Context;
4 | import android.databinding.ViewDataBinding;
5 | import android.view.LayoutInflater;
6 | import android.view.ViewGroup;
7 |
8 | import com.john.librarys.databinding.adapter.DataBindingListAdapter;
9 | import com.john.myapplication.databinding.ItemListviewBinding;
10 | import com.zhy.autolayout.utils.AutoUtils;
11 |
12 | /**
13 | * Created by guqh on 2017/8/3.
14 | */
15 |
16 | public class DataBindingListViewAdapter extends DataBindingListAdapter {
17 | public DataBindingListViewAdapter(Context context) {
18 | super(context);
19 | }
20 |
21 | @Override
22 | public ViewHolder onCreateViewHolder(int position, ViewGroup parent) {
23 | ItemListviewBinding binding=ItemListviewBinding.inflate(LayoutInflater.from(getContext()),parent,false);
24 | AutoUtils.autoSize(binding.getRoot());
25 | return new ViewHolder(binding);
26 | }
27 |
28 | @Override
29 | public void onBind(ViewHolder holder, int position, ViewDataBinding binding) {
30 | ItemListviewBinding dataBinding= (ItemListviewBinding) binding;
31 | dataBinding.setData(getItem(position));
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/java/com/john/myapplication/adapter/DatabindingRecycleViewAdapter.java:
--------------------------------------------------------------------------------
1 | package com.john.myapplication.adapter;
2 |
3 | import android.content.Context;
4 | import android.databinding.ViewDataBinding;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.view.LayoutInflater;
7 | import android.view.ViewGroup;
8 |
9 | import com.john.librarys.databinding.adapter.DataBindingRecyclerAdapter;
10 | import com.john.myapplication.BR;
11 | import com.john.myapplication.databinding.ItemDatabindingBinding;
12 | import com.zhy.autolayout.utils.AutoUtils;
13 |
14 | /**
15 | * Created by guqh on 2017/8/2.
16 | * databinding RecycleAdapter
17 | */
18 |
19 | public class DatabindingRecycleViewAdapter extends DataBindingRecyclerAdapter {
20 |
21 | public DatabindingRecycleViewAdapter(Context context) {
22 | super(context);
23 | }
24 |
25 |
26 | @Override
27 | protected RecyclerView.ViewHolder onCreateDataBindingViewHolder(ViewGroup parent, int viewType) {
28 | ItemDatabindingBinding binding = ItemDatabindingBinding.inflate(LayoutInflater.from(getContext()), parent, false);
29 | AutoUtils.autoSize(binding.getRoot()); //自动适配
30 | return new ViewHolder(binding);
31 | }
32 | @Override
33 | protected void onBinding(RecyclerView.ViewHolder holder, int position) {
34 | ViewHolder mHolder= (ViewHolder) holder;
35 | mHolder.bindData(getItem(position));
36 | }
37 |
38 | static class ViewHolder extends RecyclerView.ViewHolder {
39 | ViewDataBinding binding;
40 | public ViewHolder(ViewDataBinding binding) {
41 | super(binding.getRoot());
42 | this.binding=binding;
43 | }
44 | public void bindData(String item){
45 | binding.setVariable(BR.str,item);
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/java/com/john/myapplication/adapter/RecyclerRefreshViewAdapter.java:
--------------------------------------------------------------------------------
1 | package com.john.myapplication.adapter;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import com.john.librarys.uikit.adapter.baseadapter.MyBaseRecyclerViewAdapter;
5 | import com.john.librarys.uikit.adapter.baseadapter.MyBaseViewHolderHelper;
6 | import com.john.myapplication.Bean.RefreshModel;
7 | import com.john.myapplication.R;
8 |
9 | /**
10 | * @author John Gu
11 | * @date 2017/11/24.
12 | */
13 |
14 | public class RecyclerRefreshViewAdapter extends MyBaseRecyclerViewAdapter {
15 |
16 | public RecyclerRefreshViewAdapter(RecyclerView recyclerView) {
17 | super(recyclerView, R.layout.item_normal);
18 | }
19 |
20 | @Override
21 | protected void fillData(MyBaseViewHolderHelper helper, int position, RefreshModel model) {
22 | helper.setText(R.id.tv_item_normal_title, model.title).setText(R.id.tv_item_normal_detail, model.detail);
23 | }
24 |
25 | @Override
26 | protected void setItemChildListener(MyBaseViewHolderHelper helper, int viewType) {
27 | helper.setItemChildClickListener(R.id.tv_item_normal_delete);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/java/com/john/myapplication/adapter/SimpleRecucleAdapter.java:
--------------------------------------------------------------------------------
1 | package com.john.myapplication.adapter;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 | import com.john.librarys.databinding.adapter.ListRecyclerAdapter;
10 | import com.john.librarys.uikit.widget.DraweeView;
11 | import com.john.myapplication.R;
12 | import com.zhy.autolayout.utils.AutoUtils;
13 |
14 | /**
15 | * Created by guqh on 2017/8/3.
16 | * 普通 RecycleAdapter
17 | */
18 |
19 | public class SimpleRecucleAdapter extends ListRecyclerAdapter {
20 |
21 | public SimpleRecucleAdapter(Context context) {
22 | super(context);
23 | }
24 |
25 | @Override
26 | public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
27 | View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_databinding_2, parent, false);
28 | AutoUtils.autoSize(view);
29 | return new SimpleViewHolder(view);
30 | }
31 |
32 | @Override
33 | public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
34 | SimpleViewHolder mholder= (SimpleViewHolder) holder;
35 | mholder.dv.setUrl(getItem(position).toString());
36 | }
37 |
38 | class SimpleViewHolder extends RecyclerView.ViewHolder{
39 | public DraweeView dv;
40 |
41 | public SimpleViewHolder(View itemView) {
42 | super(itemView);
43 | dv=itemView.findViewById(R.id.dv);
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/java/com/john/myapplication/application/MyApplication.java:
--------------------------------------------------------------------------------
1 | package com.john.myapplication.application;
2 |
3 | import android.app.Application;
4 |
5 | import com.activeandroid.ActiveAndroid;
6 | import com.apkfuns.logutils.LogUtils;
7 | import com.facebook.drawee.backends.pipeline.Fresco;
8 | import com.john.librarys.net.core.ApiHttpClient;
9 | import com.john.librarys.utils.util.CrashHandler;
10 | import com.john.librarys.utils.util.DialogHelper;
11 | import com.john.myapplication.R;
12 | import com.zhy.autolayout.config.AutoLayoutConifg;
13 |
14 | /**
15 | * Created by guqh on 2017/7/s12.
16 | */
17 |
18 | public class MyApplication extends Application {
19 | @Override
20 | public void onCreate() {
21 | super.onCreate();
22 |
23 | LogUtils.getLogConfig()
24 | .configAllowLog(true)
25 | .configShowBorders(true); //初始化log打印
26 |
27 | CrashHandler.getInstance().init(this,getResources().getString(R.string.app_name)); //初始化异常捕获
28 |
29 | AutoLayoutConifg.getInstance().useDeviceSize(); //初始化自动适配
30 |
31 | Fresco.initialize(this);//初始化图片加载库
32 |
33 | ApiHttpClient.init(this); //初始化网络请求
34 |
35 | ActiveAndroid.initialize(this);//初始化数据库工具
36 | }
37 | @Override
38 | public void onTerminate() {
39 | super.onTerminate();
40 | ActiveAndroid.dispose();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/anim/anim_rotate.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/anim/fade_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/anim/fade_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/anim/pop_btn_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/anim/pop_btn_in2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/anim/popupwindow_in.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/anim/popupwindow_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/drawable/andes.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guqh/Android-Librarys/c7065309cc81b7ea4b7a80547a90296dd976b8d5/MyApplication/app/src/main/res/drawable/andes.jpg
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/drawable/ic_action_accept.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guqh/Android-Librarys/c7065309cc81b7ea4b7a80547a90296dd976b8d5/MyApplication/app/src/main/res/drawable/ic_action_accept.png
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/drawable/ic_action_cancel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guqh/Android-Librarys/c7065309cc81b7ea4b7a80547a90296dd976b8d5/MyApplication/app/src/main/res/drawable/ic_action_cancel.png
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/drawable/imgbug.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guqh/Android-Librarys/c7065309cc81b7ea4b7a80547a90296dd976b8d5/MyApplication/app/src/main/res/drawable/imgbug.jpg
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/drawable/imggugong.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guqh/Android-Librarys/c7065309cc81b7ea4b7a80547a90296dd976b8d5/MyApplication/app/src/main/res/drawable/imggugong.jpg
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/drawable/selector_btn_red.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/drawable/selector_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/layout/activity_databinding.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
10 |
11 |
12 |
17 |
18 |
25 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/layout/activity_databinding_recycler.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
16 |
17 |
18 |
23 |
28 |
29 |
35 | />
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/layout/activity_google_vr.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
12 |
13 |
21 |
22 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/layout/activity_issue_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/layout/activity_issue_selector2.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
25 |
26 |
38 |
39 |
40 |
41 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/layout/activity_listview_databinding.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
11 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/layout/activity_open_gl.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/layout/activity_recycle_refresh.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
15 |
16 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/layout/activity_step_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/layout/activity_web_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/layout/fabu_popwindow_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
26 |
27 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
53 |
54 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/layout/item_databinding.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
9 |
10 |
11 |
18 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/layout/item_databinding_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/layout/item_listview.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
9 |
10 |
19 |
20 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/layout/item_normal.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
25 |
26 |
39 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/layout/view_custom_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/mipmap-hdpi/bga_refresh_stickiness.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guqh/Android-Librarys/c7065309cc81b7ea4b7a80547a90296dd976b8d5/MyApplication/app/src/main/res/mipmap-hdpi/bga_refresh_stickiness.png
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/mipmap-hdpi/fabu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guqh/Android-Librarys/c7065309cc81b7ea4b7a80547a90296dd976b8d5/MyApplication/app/src/main/res/mipmap-hdpi/fabu.png
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/mipmap-hdpi/fabuquxiao.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guqh/Android-Librarys/c7065309cc81b7ea4b7a80547a90296dd976b8d5/MyApplication/app/src/main/res/mipmap-hdpi/fabuquxiao.png
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/mipmap-hdpi/holder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guqh/Android-Librarys/c7065309cc81b7ea4b7a80547a90296dd976b8d5/MyApplication/app/src/main/res/mipmap-hdpi/holder.png
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guqh/Android-Librarys/c7065309cc81b7ea4b7a80547a90296dd976b8d5/MyApplication/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guqh/Android-Librarys/c7065309cc81b7ea4b7a80547a90296dd976b8d5/MyApplication/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/mipmap-hdpi/info.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guqh/Android-Librarys/c7065309cc81b7ea4b7a80547a90296dd976b8d5/MyApplication/app/src/main/res/mipmap-hdpi/info.jpg
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guqh/Android-Librarys/c7065309cc81b7ea4b7a80547a90296dd976b8d5/MyApplication/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guqh/Android-Librarys/c7065309cc81b7ea4b7a80547a90296dd976b8d5/MyApplication/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/mipmap-mdpi/s11.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guqh/Android-Librarys/c7065309cc81b7ea4b7a80547a90296dd976b8d5/MyApplication/app/src/main/res/mipmap-mdpi/s11.jpg
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/mipmap-mdpi/s12.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guqh/Android-Librarys/c7065309cc81b7ea4b7a80547a90296dd976b8d5/MyApplication/app/src/main/res/mipmap-mdpi/s12.jpg
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guqh/Android-Librarys/c7065309cc81b7ea4b7a80547a90296dd976b8d5/MyApplication/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guqh/Android-Librarys/c7065309cc81b7ea4b7a80547a90296dd976b8d5/MyApplication/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guqh/Android-Librarys/c7065309cc81b7ea4b7a80547a90296dd976b8d5/MyApplication/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guqh/Android-Librarys/c7065309cc81b7ea4b7a80547a90296dd976b8d5/MyApplication/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guqh/Android-Librarys/c7065309cc81b7ea4b7a80547a90296dd976b8d5/MyApplication/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guqh/Android-Librarys/c7065309cc81b7ea4b7a80547a90296dd976b8d5/MyApplication/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 | #90000000
8 |
9 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | My Application
3 |
4 |
--------------------------------------------------------------------------------
/MyApplication/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/MyApplication/app/src/test/java/com/john/myapplication/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.john.myapplication;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/MyApplication/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.1.2-3'
5 | ext.android_plugin_version = '2.3.2'
6 | repositories {
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:2.3.3'
11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | jcenter()
21 | }
22 | }
23 |
24 | task clean(type: Delete) {
25 | delete rootProject.buildDir
26 | }
27 |
--------------------------------------------------------------------------------
/MyApplication/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/MyApplication/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/guqh/Android-Librarys/c7065309cc81b7ea4b7a80547a90296dd976b8d5/MyApplication/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/MyApplication/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Jul 12 09:30:23 GMT+08:00 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/MyApplication/librarys/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/MyApplication/librarys/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/MyApplication/librarys/src/androidTest/java/com/john/librarys/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.john.librarys;
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("com.john.librarys.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/databinding/adapter/DataBindingListAdapter.java:
--------------------------------------------------------------------------------
1 | package com.john.librarys.databinding.adapter;
2 |
3 |
4 | import android.content.Context;
5 | import android.databinding.ViewDataBinding;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 |
10 | import com.john.librarys.R;
11 | import com.john.librarys.uikit.adapter.DynamicListAdapter;
12 |
13 | import java.util.List;
14 |
15 | /**
16 | * 数据绑定 listAdapter
17 | * 配合 DataBinding使用
18 | * @param
19 | */
20 | public abstract class DataBindingListAdapter extends DynamicListAdapter {
21 |
22 | public DataBindingListAdapter(Context context) {
23 | super(context);
24 | }
25 |
26 | public DataBindingListAdapter(Context context, List data) {
27 | super(context, data);
28 | }
29 |
30 | @Override
31 | public View getView(int position, View convertView, ViewGroup parent) {
32 | ViewHolder holder = null;
33 | if(convertView == null){
34 | holder = onCreateViewHolder(position,parent);
35 | convertView = holder.getView();
36 | convertView.setTag(R.id.dataBindingViewHolder,holder);
37 | }else{
38 | holder = (ViewHolder)convertView.getTag(R.id.dataBindingViewHolder);
39 | }
40 | onBind(holder,position,holder.getBinding());
41 | return holder.getView();
42 | }
43 |
44 | /**
45 | * 创建viewholder
46 | * @param position
47 | * @param parent
48 | * @return
49 | */
50 | public abstract ViewHolder onCreateViewHolder(int position, ViewGroup parent);
51 |
52 | /**
53 | * 绑定数据
54 | * @param holder
55 | * @param position
56 | * @param binding
57 | */
58 | public abstract void onBind(ViewHolder holder,int position,ViewDataBinding binding);
59 |
60 | /**
61 | * 绑定用holder
62 | */
63 | public static class ViewHolder{
64 | private View mRootView;
65 | private ViewDataBinding mViewDataBinding;
66 |
67 | public ViewHolder(ViewDataBinding binding){
68 | mViewDataBinding = binding;
69 | mRootView = binding.getRoot();
70 | }
71 |
72 | public View getView(){
73 | return mRootView;
74 | }
75 |
76 | public ViewDataBinding getBinding() {
77 | return mViewDataBinding;
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/databinding/adapter/DataBindingPagerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.john.librarys.databinding.adapter;
2 |
3 |
4 | import android.content.Context;
5 | import android.databinding.ViewDataBinding;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 |
10 | import com.john.librarys.uikit.adapter.DynamicPagerAdapter;
11 |
12 | import java.util.Collection;
13 |
14 | /**
15 | * 数据绑定 listAdapter
16 | * 配合 DataBinding使用
17 | *
18 | * @param
19 | */
20 | public abstract class DataBindingPagerAdapter extends DynamicPagerAdapter {
21 |
22 |
23 | public DataBindingPagerAdapter(Context context) {
24 | super(context);
25 | }
26 |
27 | public DataBindingPagerAdapter(Context context, Collection data) {
28 | super(context, data);
29 | }
30 |
31 | @Override
32 | public View instantiateView(ViewGroup container, int position) {
33 | ViewHolder viewHolder = onCreateViewHolder(position, container);
34 | onBind(viewHolder, position, viewHolder.getBinding());
35 | return viewHolder.getView();
36 | }
37 |
38 | /**
39 | * 创建viewholder
40 | * 此方法内生成viewhoder 生成view的时候 不要 把view 附加到 parent中
41 | *
42 | * @param position
43 | * @param parent
44 | * @return
45 | */
46 | public abstract ViewHolder onCreateViewHolder(int position, ViewGroup parent);
47 |
48 | /**
49 | * 绑定数据
50 | *
51 | * @param holder
52 | * @param position
53 | * @param binding
54 | */
55 | public abstract void onBind(ViewHolder holder, int position, ViewDataBinding binding);
56 |
57 | /**
58 | * 绑定用holder
59 | */
60 | public static class ViewHolder {
61 | private View mRootView;
62 | private ViewDataBinding mViewDataBinding;
63 |
64 | public ViewHolder(ViewDataBinding binding) {
65 | mViewDataBinding = binding;
66 | mRootView = binding.getRoot();
67 | }
68 |
69 | public View getView() {
70 | return mRootView;
71 | }
72 |
73 | public ViewDataBinding getBinding() {
74 | return mViewDataBinding;
75 | }
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/databinding/adapter/DataBindingRecyclerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.john.librarys.databinding.adapter;
2 |
3 |
4 | import android.content.Context;
5 | import android.databinding.ViewDataBinding;
6 | import android.support.v7.widget.RecyclerView;
7 | import android.support.v7.widget.RecyclerView.ViewHolder;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 |
11 | import java.util.List;
12 |
13 | /**
14 | * RecyclerAdapter
15 | * 配合 DataBinding使用
16 | *
17 | * @param
18 | */
19 | public abstract class DataBindingRecyclerAdapter extends ListRecyclerAdapter {
20 |
21 | public DataBindingRecyclerAdapter(Context context) {
22 | super(context);
23 | }
24 |
25 | public DataBindingRecyclerAdapter(Context context, List items) {
26 | super(context, items);
27 | }
28 |
29 | @Override
30 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
31 | ViewHolder holder = onCreateDataBindingViewHolder(parent, viewType);
32 | return holder;
33 | }
34 |
35 | @Override
36 | public void onBindViewHolder(ViewHolder holder, int position) {
37 | onBinding(holder, position);
38 | }
39 |
40 | /**
41 | * 数据绑定动作
42 | *
43 | * @param holder
44 | * @param position
45 | */
46 | protected abstract void onBinding(ViewHolder holder, int position);
47 |
48 | /**
49 | * 创建 databinding ViewHolder
50 | *
51 | * @param parent
52 | * @param viewType
53 | * @return
54 | */
55 | protected abstract ViewHolder onCreateDataBindingViewHolder(ViewGroup parent, int viewType);
56 | }
57 |
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/floatwindow/FloatWindowSmallView.java:
--------------------------------------------------------------------------------
1 | package com.john.librarys.floatwindow;
2 |
3 | import android.content.Context;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.WindowManager;
7 | import android.widget.LinearLayout;
8 |
9 | import com.john.librarys.R;
10 |
11 |
12 | public class FloatWindowSmallView extends LinearLayout {
13 |
14 | /**
15 | * 记录小悬浮窗的宽度
16 | */
17 | public static int viewWidth;
18 |
19 | /**
20 | * 记录小悬浮窗的高度
21 | */
22 | public static int viewHeight;
23 |
24 |
25 |
26 | /**
27 | * 小悬浮窗的参数
28 | */
29 | private WindowManager.LayoutParams mParams;
30 |
31 |
32 | public FloatWindowSmallView(Context context) {
33 | super(context);
34 | LayoutInflater.from(context).inflate(R.layout.float_window_small, this);
35 | View view = findViewById(R.id.small_window_layout);
36 | viewWidth = view.getLayoutParams().width;
37 | viewHeight = view.getLayoutParams().height;
38 | }
39 |
40 | /**
41 | * 将小悬浮窗的参数传入,用于更新小悬浮窗的位置。
42 | *
43 | * @param params
44 | * 小悬浮窗的参数
45 | */
46 | public void setParams(WindowManager.LayoutParams params) {
47 | mParams = params;
48 | }
49 |
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/net/Constants.java:
--------------------------------------------------------------------------------
1 | package com.john.librarys.net;
2 |
3 | /**
4 | * Created by LinYi.
5 | */
6 | public class Constants {
7 |
8 |
9 |
10 | public static final int STATE_CODE_SUCCESS = 1;
11 | public static final int STATE_CODE_FAILED = -1;
12 | //...
13 |
14 |
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/net/core/ApiHelper.java:
--------------------------------------------------------------------------------
1 | package com.john.librarys.net.core;
2 |
3 | import android.content.Context;
4 | import android.util.Log;
5 |
6 | import com.google.gson.Gson;
7 | import com.john.librarys.utils.util.DateHelper;
8 | import com.john.librarys.utils.util.GsonHelper;
9 |
10 | import java.util.Date;
11 | import java.util.Map;
12 | import java.util.regex.Matcher;
13 | import java.util.regex.Pattern;
14 |
15 | /**
16 | * api工具类
17 | */
18 | public class ApiHelper {
19 |
20 | public final static String DATE_FORMAT = "yyyyMMddHHmmssSSS";
21 |
22 | /**
23 | * 获取gson解析
24 | *
25 | * @return
26 | */
27 | public static Gson getGson() {
28 | return GsonHelper.getGsonForDateFormat(DATE_FORMAT);
29 | }
30 |
31 | public static ApiHttpClient getApiHttpClient(Context context) {
32 | return ApiHttpClient.getInstance(context);
33 | }
34 |
35 | //时间戳转换
36 | public static String getTimestamp(long timestamp) {
37 | return DateHelper.formatDate(DATE_FORMAT, new Date(timestamp));
38 | }
39 |
40 | //时间戳转换
41 | public static String getTimestamp(Date timestamp) {
42 | return DateHelper.formatDate(DATE_FORMAT, timestamp);
43 | }
44 |
45 | /**
46 | * 格式化 url,处理{xx}包括的url参数
47 | * 转换参数到url中,并把paramsmap中的参数删除
48 | *
49 | * @param url
50 | * @param paramsmap
51 | * @return
52 | */
53 | public static String formatUrl(String url, Map paramsmap) {
54 | String resultUrl = url;
55 | Pattern regex = Pattern.compile("\\{([^/]+)\\}");//{xxxx}
56 | Matcher matcher = regex.matcher(url);
57 | while (matcher.find()) {//开始逐个匹配
58 | String matchParamName = matcher.group(1);//匹配具体名字
59 | if (paramsmap.containsKey(matchParamName)) {
60 | resultUrl = resultUrl.replaceAll("\\{" + matchParamName + "\\}", paramsmap.get(matchParamName));
61 | paramsmap.remove(matchParamName);
62 | } else {
63 | Log.w("ApiHelper", "formatUrl params can't find in paramsmap : " + matchParamName);
64 | }
65 | }
66 | return resultUrl;
67 | }
68 |
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/net/core/ApiJsonModelCallback.java:
--------------------------------------------------------------------------------
1 | package com.john.librarys.net.core;
2 |
3 |
4 | import com.apkfuns.logutils.LogUtils;
5 | import com.google.gson.reflect.TypeToken;
6 | import com.john.librarys.net.Constants;
7 | import com.john.librarys.net.interf.ServiceTask;
8 |
9 | import java.lang.reflect.Type;
10 |
11 | /**
12 | * ApiCallback
13 | * json模型callback
14 | */
15 | public class ApiJsonModelCallback extends ApiCallback {
16 | boolean DEBUG = false;
17 | private Type mJsonModelType;
18 |
19 | /**
20 | * @param serviceTask
21 | * @param jsonModelType 对应的json模型 class type
22 | */
23 | public ApiJsonModelCallback(ServiceTask serviceTask, Type jsonModelType) {
24 | super(serviceTask);
25 | mJsonModelType = jsonModelType;
26 | }
27 |
28 |
29 | /**
30 | * @param serviceTask
31 | * @param token 对应的json模型 TypeToken
32 | */
33 | public ApiJsonModelCallback(ServiceTask serviceTask, TypeToken token) {
34 | this(serviceTask, token.getType());
35 | }
36 |
37 | @Override
38 | public void onCall(int resultCode,String msg, Object data) {
39 | //增加debug打印
40 | if (DEBUG) {
41 | LogUtils.d("url====",mTag);
42 | LogUtils.json(String.valueOf(data));
43 | }
44 |
45 | super.onCall(resultCode,msg, data);
46 | }
47 |
48 | @Override
49 | public void onSuccess(Object data, String msg,ServiceTask task) throws Exception {
50 | Object modelForJson = null;
51 | if (data != null) {
52 | modelForJson = ApiHelper.getGson().fromJson(data.toString(), mJsonModelType);
53 | }
54 | task.complete(Constants.STATE_CODE_SUCCESS,msg, modelForJson);
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/net/core/CountingRequestBody.java:
--------------------------------------------------------------------------------
1 | package com.john.librarys.net.core;
2 |
3 | import com.squareup.okhttp.MediaType;
4 | import com.squareup.okhttp.RequestBody;
5 |
6 | import java.io.IOException;
7 |
8 | import okio.Buffer;
9 | import okio.BufferedSink;
10 | import okio.ForwardingSink;
11 | import okio.Okio;
12 | import okio.Sink;
13 |
14 | /**
15 | * Decorates an OkHttp request body to count the number of bytes written when writing it. Can
16 | * decorate any request body, but is most useful for tracking the upload progress of large
17 | * multipart requests.
18 | *
19 | * @author Leo Nikkilä
20 | */
21 | public class CountingRequestBody extends RequestBody
22 | {
23 |
24 | protected RequestBody delegate;
25 | protected Listener listener;
26 |
27 | protected CountingSink countingSink;
28 |
29 | public CountingRequestBody(RequestBody delegate, Listener listener)
30 | {
31 | this.delegate = delegate;
32 | this.listener = listener;
33 | }
34 |
35 | @Override
36 | public MediaType contentType()
37 | {
38 | return delegate.contentType();
39 | }
40 |
41 | @Override
42 | public long contentLength()
43 | {
44 | try
45 | {
46 | return delegate.contentLength();
47 | } catch (IOException e)
48 | {
49 | e.printStackTrace();
50 | }
51 | return -1;
52 | }
53 |
54 | @Override
55 | public void writeTo(BufferedSink sink) throws IOException
56 | {
57 | BufferedSink bufferedSink;
58 |
59 | countingSink = new CountingSink(sink);
60 | bufferedSink = Okio.buffer(countingSink);
61 |
62 | delegate.writeTo(bufferedSink);
63 |
64 | bufferedSink.flush();
65 | }
66 |
67 | protected final class CountingSink extends ForwardingSink
68 | {
69 |
70 | private long bytesWritten = 0;
71 |
72 | public CountingSink(Sink delegate)
73 | {
74 | super(delegate);
75 | }
76 |
77 | @Override
78 | public void write(Buffer source, long byteCount) throws IOException
79 | {
80 | super.write(source, byteCount);
81 |
82 | bytesWritten += byteCount;
83 | listener.onRequestProgress(bytesWritten, contentLength());
84 | }
85 |
86 | }
87 |
88 | public static interface Listener
89 | {
90 |
91 | public void onRequestProgress(long bytesWritten, long contentLength);
92 |
93 | }
94 |
95 | }
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/net/core/OkHttpStack.java:
--------------------------------------------------------------------------------
1 | package com.john.librarys.net.core;
2 |
3 | import com.android.volley.toolbox.HurlStack;
4 | import com.squareup.okhttp.OkHttpClient;
5 | import com.squareup.okhttp.OkUrlFactory;
6 |
7 | import java.io.IOException;
8 | import java.net.HttpURLConnection;
9 | import java.net.URL;
10 |
11 | /**
12 | * Created by LinYi.
13 | */
14 | public class OkHttpStack extends HurlStack {
15 | private final OkUrlFactory okUrlFactory;
16 | public OkHttpStack() {
17 | this(new OkHttpClient());
18 | }
19 | public OkHttpStack(OkHttpClient okHttpClient) {
20 | if (okHttpClient == null) {
21 | throw new NullPointerException("Client must not be null.");
22 | }
23 | this.okUrlFactory = new OkUrlFactory(okHttpClient);
24 | }
25 | @Override
26 | protected HttpURLConnection createConnection(URL url) throws IOException {
27 | return okUrlFactory.open(url);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/net/interf/Callback.java:
--------------------------------------------------------------------------------
1 | package com.john.librarys.net.interf;
2 |
3 | /**
4 | * Created by LinYi.
5 | * 处理后的callback
6 | * @param 确定onCall返回的类型(JSONObject/JSONArray..)
7 | */
8 | public interface Callback {
9 |
10 | void onCall(int resultCode,String msg, T t);
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/net/interf/ProgressCallback.java:
--------------------------------------------------------------------------------
1 | package com.john.librarys.net.interf;
2 |
3 | /**
4 | * Created by LinYi.
5 | * 带进度的回调
6 | */
7 | public interface ProgressCallback extends Callback{
8 |
9 | /**
10 | *
11 | * @param progress 0.0~1.0
12 | */
13 | void onProgress(float progress);
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/pulltorefresh/ILoadingLayout.java:
--------------------------------------------------------------------------------
1 | package com.john.librarys.pulltorefresh;
2 |
3 | import android.graphics.Typeface;
4 | import android.graphics.drawable.Drawable;
5 |
6 | public interface ILoadingLayout {
7 |
8 | /**
9 | * Set the Last Updated Text. This displayed under the main label when
10 | * Pulling
11 | *
12 | * @param label - Label to set
13 | */
14 | public void setLastUpdatedLabel(CharSequence label);
15 |
16 | /**
17 | * Set the drawable used in the loading layout. This is the same as calling
18 | * setLoadingDrawable(drawable, Mode.BOTH)
19 | *
20 | * @param drawable - Drawable to display
21 | */
22 | public void setLoadingDrawable(Drawable drawable);
23 |
24 | /**
25 | * Set Text to show when the Widget is being Pulled
26 | * setPullLabel(releaseLabel, Mode.BOTH)
27 | *
28 | * @param pullLabel - CharSequence to display
29 | */
30 | public void setPullLabel(CharSequence pullLabel);
31 |
32 | /**
33 | * Set Text to show when the Widget is refreshing
34 | * setRefreshingLabel(releaseLabel, Mode.BOTH)
35 | *
36 | * @param refreshingLabel - CharSequence to display
37 | */
38 | public void setRefreshingLabel(CharSequence refreshingLabel);
39 |
40 | /**
41 | * Set Text to show when the Widget is being pulled, and will refresh when
42 | * released. This is the same as calling
43 | * setReleaseLabel(releaseLabel, Mode.BOTH)
44 | *
45 | * @param releaseLabel - CharSequence to display
46 | */
47 | public void setReleaseLabel(CharSequence releaseLabel);
48 |
49 | /**
50 | * Set's the Sets the typeface and style in which the text should be
51 | * displayed. Please see
52 | * {@link android.widget.TextView#setTypeface(Typeface)
53 | * TextView#setTypeface(Typeface)}.
54 | */
55 | public void setTextTypeface(Typeface tf);
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/pulltorefresh/LoadingLayoutProxy.java:
--------------------------------------------------------------------------------
1 | package com.john.librarys.pulltorefresh;
2 |
3 | import android.graphics.Typeface;
4 | import android.graphics.drawable.Drawable;
5 |
6 | import com.john.librarys.pulltorefresh.internal.LoadingLayout;
7 |
8 | import java.util.HashSet;
9 |
10 | public class LoadingLayoutProxy implements ILoadingLayout {
11 |
12 | private final HashSet mLoadingLayouts;
13 |
14 | LoadingLayoutProxy() {
15 | mLoadingLayouts = new HashSet();
16 | }
17 |
18 | /**
19 | * This allows you to add extra LoadingLayout instances to this proxy. This
20 | * is only necessary if you keep your own instances, and want to have them
21 | * included in any
22 | * {@link PullToRefreshBase#createLoadingLayoutProxy(boolean, boolean)
23 | * createLoadingLayoutProxy(...)} calls.
24 | *
25 | * @param layout - LoadingLayout to have included.
26 | */
27 | public void addLayout(LoadingLayout layout) {
28 | if (null != layout) {
29 | mLoadingLayouts.add(layout);
30 | }
31 | }
32 |
33 | @Override
34 | public void setLastUpdatedLabel(CharSequence label) {
35 | for (LoadingLayout layout : mLoadingLayouts) {
36 | layout.setLastUpdatedLabel(label);
37 | }
38 | }
39 |
40 | @Override
41 | public void setLoadingDrawable(Drawable drawable) {
42 | for (LoadingLayout layout : mLoadingLayouts) {
43 | layout.setLoadingDrawable(drawable);
44 | }
45 | }
46 |
47 | @Override
48 | public void setRefreshingLabel(CharSequence refreshingLabel) {
49 | for (LoadingLayout layout : mLoadingLayouts) {
50 | layout.setRefreshingLabel(refreshingLabel);
51 | }
52 | }
53 |
54 | @Override
55 | public void setPullLabel(CharSequence label) {
56 | for (LoadingLayout layout : mLoadingLayouts) {
57 | layout.setPullLabel(label);
58 | }
59 | }
60 |
61 | @Override
62 | public void setReleaseLabel(CharSequence label) {
63 | for (LoadingLayout layout : mLoadingLayouts) {
64 | layout.setReleaseLabel(label);
65 | }
66 | }
67 |
68 | public void setTextTypeface(Typeface tf) {
69 | for (LoadingLayout layout : mLoadingLayouts) {
70 | layout.setTextTypeface(tf);
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/pulltorefresh/PullToRefreshFrameLayout.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2011, 2012 Chris Banes.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *******************************************************************************/
16 | package com.john.librarys.pulltorefresh;
17 |
18 | import android.content.Context;
19 | import android.util.AttributeSet;
20 | import android.view.View;
21 | import android.widget.FrameLayout;
22 |
23 | public class PullToRefreshFrameLayout extends PullToRefreshBase {
24 |
25 | public PullToRefreshFrameLayout(Context context) {
26 | super(context);
27 | }
28 |
29 | public PullToRefreshFrameLayout(Context context, AttributeSet attrs) {
30 | super(context, attrs);
31 | }
32 |
33 | public PullToRefreshFrameLayout(Context context, Mode mode) {
34 | super(context, mode);
35 | }
36 |
37 | public PullToRefreshFrameLayout(Context context, Mode mode, AnimationStyle style) {
38 | super(context, mode, style);
39 | }
40 |
41 | @Override
42 | public final Orientation getPullToRefreshScrollDirection() {
43 | return Orientation.VERTICAL;
44 | }
45 |
46 | @Override
47 | protected FrameLayout createRefreshableView(Context context, AttributeSet attrs) {
48 | return new FrameLayout(context,attrs);
49 | }
50 |
51 | @Override
52 | protected boolean isReadyForPullStart() {
53 | return mRefreshableView.getScrollY() == 0;
54 | }
55 |
56 | @Override
57 | protected boolean isReadyForPullEnd() {
58 | View firstChild = mRefreshableView.getChildAt(0);
59 | if (null != firstChild) {
60 | return mRefreshableView.getScrollY() >= (firstChild.getHeight() - getHeight());
61 | }
62 | return false;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/pulltorefresh/internal/EmptyViewMethodAccessor.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2011, 2012 Chris Banes.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *******************************************************************************/
16 | package com.john.librarys.pulltorefresh.internal;
17 |
18 | import android.view.View;
19 |
20 | /**
21 | * Interface that allows PullToRefreshBase to hijack the call to
22 | * AdapterView.setEmptyView()
23 | *
24 | * @author chris
25 | */
26 | public interface EmptyViewMethodAccessor {
27 |
28 | /**
29 | * Calls upto AdapterView.setEmptyView()
30 | *
31 | * @param emptyView - to set as Empty View
32 | */
33 | public void setEmptyViewInternal(View emptyView);
34 |
35 | /**
36 | * Should call PullToRefreshBase.setEmptyView() which will then
37 | * automatically call through to setEmptyViewInternal()
38 | *
39 | * @param emptyView - to set as Empty View
40 | */
41 | public void setEmptyView(View emptyView);
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/pulltorefresh/internal/Utils.java:
--------------------------------------------------------------------------------
1 | package com.john.librarys.pulltorefresh.internal;
2 |
3 | import android.util.Log;
4 |
5 | public class Utils {
6 |
7 | static final String LOG_TAG = "PullToRefresh";
8 |
9 | public static void warnDeprecation(String depreacted, String replacement) {
10 | Log.w(LOG_TAG, "You're using the deprecated " + depreacted + " attr, please switch over to " + replacement);
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/pulltorefresh/internal/ViewCompat.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2011, 2012 Chris Banes.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *******************************************************************************/
16 | package com.john.librarys.pulltorefresh.internal;
17 |
18 | import android.annotation.TargetApi;
19 | import android.graphics.drawable.Drawable;
20 | import android.os.Build.VERSION;
21 | import android.os.Build.VERSION_CODES;
22 | import android.view.View;
23 |
24 | @SuppressWarnings("deprecation")
25 | public class ViewCompat {
26 |
27 | public static void postOnAnimation(View view, Runnable runnable) {
28 | if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
29 | SDK16.postOnAnimation(view, runnable);
30 | } else {
31 | view.postDelayed(runnable, 16);
32 | }
33 | }
34 |
35 | public static void setBackground(View view, Drawable background) {
36 | if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
37 | SDK16.setBackground(view, background);
38 | } else {
39 | view.setBackgroundDrawable(background);
40 | }
41 | }
42 |
43 | public static void setLayerType(View view, int layerType) {
44 | if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) {
45 | SDK11.setLayerType(view, layerType);
46 | }
47 | }
48 |
49 | @TargetApi(11)
50 | static class SDK11 {
51 |
52 | public static void setLayerType(View view, int layerType) {
53 | view.setLayerType(layerType, null);
54 | }
55 | }
56 |
57 | @TargetApi(16)
58 | static class SDK16 {
59 |
60 | public static void postOnAnimation(View view, Runnable runnable) {
61 | view.postOnAnimation(runnable);
62 | }
63 |
64 | public static void setBackground(View view, Drawable background) {
65 | view.setBackground(background);
66 | }
67 |
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/uikit/Tagcloudlayout/TagBaseAdapter.java:
--------------------------------------------------------------------------------
1 | package com.john.librarys.uikit.Tagcloudlayout;
2 |
3 | import android.content.Context;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.BaseAdapter;
8 | import android.widget.Button;
9 |
10 | import com.john.librarys.R;
11 |
12 | import java.util.List;
13 |
14 | /**
15 | * @author fyales
16 | * @since 8/26/15.
17 | */
18 | public class TagBaseAdapter extends BaseAdapter {
19 |
20 | private Context mContext;
21 | private List mList;
22 |
23 | public TagBaseAdapter(Context context, List list) {
24 | mContext = context;
25 | mList = list;
26 | }
27 |
28 | @Override
29 | public int getCount() {
30 | return mList.size();
31 | }
32 |
33 | @Override
34 | public String getItem(int position) {
35 | return mList.get(position);
36 | }
37 |
38 | @Override
39 | public long getItemId(int position) {
40 | return position;
41 | }
42 |
43 | @Override
44 | public View getView(int position, View convertView, ViewGroup parent) {
45 | ViewHolder holder;
46 | if (convertView == null) {
47 | convertView = LayoutInflater.from(mContext).inflate(R.layout.tagview, null);
48 | holder = new ViewHolder();
49 | holder.tagBtn = (Button) convertView.findViewById(R.id.tag_btn);
50 | convertView.setTag(holder);
51 | }else{
52 | holder = (ViewHolder)convertView.getTag();
53 | }
54 | final String text = getItem(position);
55 | holder.tagBtn.setText(text);
56 | return convertView;
57 | }
58 |
59 | static class ViewHolder {
60 | Button tagBtn;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/uikit/Tagcloudlayout/TagCloudConfiguration.java:
--------------------------------------------------------------------------------
1 | package com.john.librarys.uikit.Tagcloudlayout;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.util.AttributeSet;
6 |
7 | import com.john.librarys.R;
8 |
9 | /**
10 | * @author fyales
11 | * @since date 11/3/15
12 | */
13 | public class TagCloudConfiguration {
14 |
15 | private static final int DEFAULT_LINE_SPACING = 5;
16 | private static final int DEFAULT_TAG_SPACING = 10;
17 | private static final int DEFAULT_FIXED_COLUMN_SIZE = 3; //默认列数
18 |
19 | private int lineSpacing;
20 | private int tagSpacing;
21 | private int columnSize;
22 | private boolean isFixed;
23 |
24 | public TagCloudConfiguration(Context context, AttributeSet attrs){
25 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TagCloudLayout);
26 | try {
27 | lineSpacing = a.getDimensionPixelSize(R.styleable.TagCloudLayout_lineSpacing, DEFAULT_LINE_SPACING);
28 | tagSpacing = a.getDimensionPixelSize(R.styleable.TagCloudLayout_tagSpacing, DEFAULT_TAG_SPACING);
29 | columnSize = a.getInteger(R.styleable.TagCloudLayout_columnSize, DEFAULT_FIXED_COLUMN_SIZE);
30 | isFixed = a.getBoolean(R.styleable.TagCloudLayout_isFixed,false);
31 | } finally {
32 | a.recycle();
33 | }
34 | }
35 |
36 | public int getLineSpacing() {
37 | return lineSpacing;
38 | }
39 |
40 | public void setLineSpacing(int lineSpacing) {
41 | this.lineSpacing = lineSpacing;
42 | }
43 |
44 | public int getTagSpacing() {
45 | return tagSpacing;
46 | }
47 |
48 | public void setTagSpacing(int tagSpacing) {
49 | this.tagSpacing = tagSpacing;
50 | }
51 |
52 | public int getColumnSize() {
53 | return columnSize;
54 | }
55 |
56 | public void setColumnSize(int columnSize) {
57 | this.columnSize = columnSize;
58 | }
59 |
60 | public boolean isFixed() {
61 | return isFixed;
62 | }
63 |
64 | public void setIsFixed(boolean isFixed) {
65 | this.isFixed = isFixed;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/uikit/adapter/CheckableListAdapter.java:
--------------------------------------------------------------------------------
1 | package com.john.librarys.uikit.adapter;
2 |
3 | import android.content.Context;
4 | import android.view.View;
5 | import android.view.ViewGroup;
6 | import android.widget.AbsListView;
7 | import android.widget.Checkable;
8 |
9 | import java.util.List;
10 |
11 | public abstract class CheckableListAdapter extends DynamicListAdapter {
12 | AbsListView mListView;
13 |
14 |
15 | public CheckableListAdapter(Context context, AbsListView listview) {
16 | this(context, null, listview);
17 | }
18 |
19 | public CheckableListAdapter(Context context, List data, AbsListView listview) {
20 | super(context, data);
21 | mListView = listview;
22 | }
23 |
24 | @Override
25 | public View getView(int position, View convertView, ViewGroup parent) {
26 | convertView = getCheckableView(position, convertView, parent);
27 |
28 | boolean checked = mListView.isItemChecked(position);
29 | if (convertView instanceof Checkable) {
30 | ((Checkable) convertView).setChecked(checked);
31 | }
32 |
33 | setChecked(convertView, checked);
34 | return convertView;
35 | }
36 |
37 | /**
38 | * 生成view 用,这个方法就是封装了 BaseAdapter.getView 方法,里面的实现需要跟 BaseAdapter.getView 一样
39 | *
40 | * @param position
41 | * @param convertView
42 | * @param parent
43 | * @return
44 | */
45 | public abstract View getCheckableView(int position, View convertView, ViewGroup parent);
46 |
47 | /**
48 | * 设置check状态用
49 | * 如果 itemview 是 checkable 的话 就会自动设置,如果不是就要另外设置,比如这个item 下 还layout了其他多层的checkable的view
50 | *
51 | * @param view
52 | * @param checked
53 | */
54 | public abstract void setChecked(View view, boolean checked);
55 |
56 | //这个值涉及到 listview.getCheckedItemIds()的取值
57 | @Override
58 | public boolean hasStableIds() {
59 | return true;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/uikit/adapter/DynamicListDataSet.java:
--------------------------------------------------------------------------------
1 | package com.john.librarys.uikit.adapter;
2 |
3 | import java.util.Collection;
4 |
5 | /**
6 | * 动态dynamicList
7 | */
8 | public interface DynamicListDataSet {
9 |
10 | int getCount();
11 |
12 | T getItem(int position);
13 |
14 | /**
15 | * 添加数据
16 | *
17 | * @param item
18 | */
19 | void addItem(T item);
20 |
21 | /**
22 | * 添加数据到 position 位置
23 | *
24 | * @param item
25 | * @param position
26 | */
27 | void addItem(T item, int position);
28 |
29 | /**
30 | * 添加数据到 position 位置
31 | *
32 | * @param items
33 | * @param position
34 | */
35 | void addItems(Collection items, int position);
36 |
37 | /**
38 | * 添加数据到 最后
39 | *
40 | * @param items
41 | */
42 | void addItems(Collection items);
43 |
44 | /**
45 | * 删除数据
46 | *
47 | * @param item
48 | */
49 | void removeItem(T item);
50 |
51 | /**
52 | * 删除 position位置的数据
53 | *
54 | * @param position
55 | */
56 | void removeItem(int position);
57 |
58 | /**
59 | * 删除数据
60 | *
61 | * @param items
62 | */
63 | void removeItems(Collection items);
64 |
65 | /**
66 | * 清除数据
67 | */
68 | void clear();
69 |
70 | /**
71 | * 通知已经修改
72 | */
73 | void notifyDataSetChanged();
74 | }
75 |
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/uikit/adapter/baseadapter/MyBaseAdapterViewHolder.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 bingoogolapple
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.john.librarys.uikit.adapter.baseadapter;
18 |
19 | import android.view.LayoutInflater;
20 | import android.view.View;
21 | import android.view.ViewGroup;
22 | import com.zhy.autolayout.utils.AutoUtils;
23 |
24 | /**
25 | * 作者:王浩 邮件:bingoogolapple@gmail.com
26 | * 创建时间:15/5/21 上午1:00
27 | * 描述:适用于AdapterView的item的ViewHolder
28 | */
29 | public class MyBaseAdapterViewHolder {
30 | protected View mConvertView;
31 | protected MyBaseViewHolderHelper mViewHolderHelper;
32 |
33 | private MyBaseAdapterViewHolder(ViewGroup parent, int layoutId) {
34 | mConvertView = LayoutInflater.from(parent.getContext()).inflate(layoutId, parent, false);
35 | AutoUtils.auto(mConvertView);
36 | mConvertView.setTag(this);
37 | mViewHolderHelper = new MyBaseViewHolderHelper(parent, mConvertView);
38 | }
39 |
40 | /**
41 | * 拿到一个可重用的ViewHolder对象
42 | *
43 | * @param convertView
44 | * @param parent
45 | * @param layoutId
46 | * @return
47 | */
48 | public static MyBaseAdapterViewHolder dequeueReusableAdapterViewHolder(View convertView, ViewGroup parent, int layoutId) {
49 | if (convertView == null) {
50 | return new MyBaseAdapterViewHolder(parent, layoutId);
51 | }
52 | return (MyBaseAdapterViewHolder) convertView.getTag();
53 | }
54 |
55 | public MyBaseViewHolderHelper getViewHolderHelper() {
56 | return mViewHolderHelper;
57 | }
58 |
59 | public View getConvertView() {
60 | return mConvertView;
61 | }
62 |
63 | }
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/uikit/adapter/baseadapter/MyBaseBindingViewHolder.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 bingoogolapple
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.john.librarys.uikit.adapter.baseadapter;
18 |
19 | import android.databinding.ViewDataBinding;
20 | import android.support.v7.widget.RecyclerView;
21 | import android.view.ViewParent;
22 | import com.zhy.autolayout.utils.AutoUtils;
23 |
24 | /**
25 | * 作者:王浩 邮件:bingoogolapple@gmail.com
26 | * 创建时间:16/11/10 下午9:34
27 | * 描述:
28 | */
29 | public class MyBaseBindingViewHolder extends RecyclerView.ViewHolder {
30 | private B mBinding;
31 | protected MyBaseBindingRecyclerViewAdapter mBindingRecyclerViewAdapter;
32 |
33 | public MyBaseBindingViewHolder(MyBaseBindingRecyclerViewAdapter bindingRecyclerViewAdapter, B binding) {
34 | super(binding.getRoot());
35 | AutoUtils.auto(binding.getRoot());
36 | mBindingRecyclerViewAdapter = bindingRecyclerViewAdapter;
37 | mBinding = binding;
38 | }
39 |
40 | public B getBinding() {
41 | return mBinding;
42 | }
43 |
44 | public RecyclerView getParent() {
45 | ViewParent parent = mBinding.getRoot().getParent();
46 | if (parent != null) {
47 | return (RecyclerView) parent;
48 | }
49 | return null;
50 | }
51 |
52 | public int getAdapterPositionWrapper() {
53 | if (mBindingRecyclerViewAdapter.getHeadersCount() > 0) {
54 | return getAdapterPosition() - mBindingRecyclerViewAdapter.getHeadersCount();
55 | } else {
56 | return getAdapterPosition();
57 | }
58 | }
59 | }
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/uikit/adapter/baseadapter/MyBaseOnItemChildCheckedChangeListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 bingoogolapple
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.john.librarys.uikit.adapter.baseadapter;
18 |
19 | import android.view.ViewGroup;
20 | import android.widget.CompoundButton;
21 |
22 | /**
23 | * 作者:王浩 邮件:bingoogolapple@gmail.com
24 | * 创建时间:15/10/7 下午8:35
25 | * 描述:AdapterView和RecyclerView的item中子控件选中状态变化事件监听器
26 | */
27 | public interface MyBaseOnItemChildCheckedChangeListener {
28 | void onItemChildCheckedChanged(ViewGroup parent, CompoundButton childView, int position, boolean isChecked);
29 | }
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/uikit/adapter/baseadapter/MyBaseOnItemChildClickListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 bingoogolapple
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.john.librarys.uikit.adapter.baseadapter;
18 |
19 | import android.view.View;
20 | import android.view.ViewGroup;
21 |
22 | /**
23 | * 作者:王浩 邮件:bingoogolapple@gmail.com
24 | * 创建时间:15/5/28 上午7:28
25 | * 描述:AdapterView和RecyclerView的item中子控件点击事件监听器
26 | */
27 | public interface MyBaseOnItemChildClickListener {
28 | void onItemChildClick(ViewGroup parent, View childView, int position);
29 | }
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/uikit/adapter/baseadapter/MyBaseOnItemChildLongClickListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 bingoogolapple
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.john.librarys.uikit.adapter.baseadapter;
18 |
19 | import android.view.View;
20 | import android.view.ViewGroup;
21 |
22 | /**
23 | * 作者:王浩 邮件:bingoogolapple@gmail.com
24 | * 创建时间:15/5/28 上午7:28
25 | * 描述:AdapterView和RecyclerView的item中子控件长按事件监听器
26 | */
27 | public interface MyBaseOnItemChildLongClickListener {
28 | boolean onItemChildLongClick(ViewGroup parent, View childView, int position);
29 | }
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/uikit/adapter/baseadapter/MyBaseOnNoDoubleClickListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 bingoogolapple
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.john.librarys.uikit.adapter.baseadapter;
18 |
19 | import android.view.View;
20 |
21 | /**
22 | * 作者:王浩 邮件:bingoogolapple@gmail.com
23 | * 创建时间:16/11/13 上午11:41
24 | * 描述:
25 | */
26 | public abstract class MyBaseOnNoDoubleClickListener implements View.OnClickListener {
27 | private int mThrottleFirstTime = 1000;
28 | private long mLastClickTime = 0;
29 |
30 | public MyBaseOnNoDoubleClickListener() {
31 | }
32 |
33 | public MyBaseOnNoDoubleClickListener(int throttleFirstTime) {
34 | mThrottleFirstTime = throttleFirstTime;
35 | }
36 |
37 | @Override
38 | public void onClick(View v) {
39 | long currentTime = System.currentTimeMillis();
40 | if (currentTime - mLastClickTime > mThrottleFirstTime) {
41 | mLastClickTime = currentTime;
42 | onNoDoubleClick(v);
43 | }
44 | }
45 |
46 | public abstract void onNoDoubleClick(View v);
47 | }
48 |
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/uikit/adapter/baseadapter/MyBaseOnRVItemChildTouchListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 bingoogolapple
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.john.librarys.uikit.adapter.baseadapter;
18 |
19 | import android.view.MotionEvent;
20 | import android.view.View;
21 |
22 | /**
23 | * 作者:王浩 邮件:bingoogolapple@gmail.com
24 | * 创建时间:15/5/28 上午7:28
25 | * 描述:RecyclerView的item中子控件触摸事件监听器
26 | */
27 | public interface MyBaseOnRVItemChildTouchListener {
28 | boolean onRvItemChildTouch(MyBaseRecyclerViewHolder holder, View childView, MotionEvent event);
29 | }
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/uikit/adapter/baseadapter/MyBaseOnRVItemClickListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 bingoogolapple
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.john.librarys.uikit.adapter.baseadapter;
18 |
19 | import android.view.View;
20 | import android.view.ViewGroup;
21 |
22 | /**
23 | * 作者:王浩 邮件:bingoogolapple@gmail.com
24 | * 创建时间:15/5/28 上午7:28
25 | * 描述:RecyclerView的item点击事件监听器
26 | */
27 | public interface MyBaseOnRVItemClickListener {
28 | void onRVItemClick(ViewGroup parent, View itemView, int position);
29 | }
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/uikit/adapter/baseadapter/MyBaseOnRVItemLongClickListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 bingoogolapple
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.john.librarys.uikit.adapter.baseadapter;
18 |
19 | import android.view.View;
20 | import android.view.ViewGroup;
21 |
22 | /**
23 | * 作者:王浩 邮件:bingoogolapple@gmail.com
24 | * 创建时间:15/5/28 上午7:28
25 | * 描述:RecyclerView的item长按事件监听器
26 | */
27 | public interface MyBaseOnRVItemLongClickListener {
28 | boolean onRVItemLongClick(ViewGroup parent, View itemView, int position);
29 | }
--------------------------------------------------------------------------------
/MyApplication/librarys/src/main/java/com/john/librarys/uikit/adapter/baseadapter/MyBaseViewBindingAdapter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2015 bingoogolapple
3 | *