parent
190c2b3a05
commit
8049af34e0
@ -0,0 +1,59 @@ |
||||
/* |
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package com.arialyy.aria.core.scheduler; |
||||
|
||||
import com.arialyy.aria.core.inf.ITask; |
||||
|
||||
/** |
||||
* Created by Aria.Lao on 2017/6/7. |
||||
*/ |
||||
public class AbsSchedulerListener<TASK extends ITask> implements ISchedulerListener<TASK> { |
||||
@Override public void onPre(TASK task) { |
||||
|
||||
} |
||||
|
||||
@Override public void onTaskPre(TASK task) { |
||||
|
||||
} |
||||
|
||||
@Override public void onTaskResume(TASK task) { |
||||
|
||||
} |
||||
|
||||
@Override public void onTaskStart(TASK task) { |
||||
|
||||
} |
||||
|
||||
@Override public void onTaskStop(TASK task) { |
||||
|
||||
} |
||||
|
||||
@Override public void onTaskCancel(TASK task) { |
||||
|
||||
} |
||||
|
||||
@Override public void onTaskFail(TASK task) { |
||||
|
||||
} |
||||
|
||||
@Override public void onTaskComplete(TASK task) { |
||||
|
||||
} |
||||
|
||||
@Override public void onTaskRunning(TASK task) { |
||||
|
||||
} |
||||
} |
@ -0,0 +1,38 @@ |
||||
/* |
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package com.arialyy.compiler; |
||||
|
||||
/** |
||||
* Created by lyy on 2017/6/7. |
||||
*/ |
||||
|
||||
public interface ProxyConstance { |
||||
/** |
||||
* 设置观察者的方法 |
||||
*/ |
||||
String SET_LISTENER = "setListener"; |
||||
|
||||
/** |
||||
* 下载的动态生成的代理类后缀 |
||||
*/ |
||||
String DOWNLOAD_PROXY_CLASS_SUFFIX = "$$DownloadListenerProxy"; |
||||
|
||||
/** |
||||
* 上传的动态生成的代理类后缀 |
||||
*/ |
||||
String UPLOAD_PROXY_CLASS_SUFFIX = "$$UploadListenerProxy"; |
||||
|
||||
} |
@ -0,0 +1,32 @@ |
||||
/* |
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package com.arialyy.compiler; |
||||
|
||||
import java.lang.annotation.Annotation; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* Created by Aria.Lao on 2017/6/7. |
||||
*/ |
||||
|
||||
class ProxyEntity { |
||||
public String packageName; |
||||
public String className; |
||||
public boolean isDownlaod = true; |
||||
|
||||
public Map<Class<? extends Annotation>, String> methods = new HashMap<>(); |
||||
} |
@ -1,20 +0,0 @@ |
||||
//package com.arialyy.compiler;
|
||||
//
|
||||
///**
|
||||
// * Created by AriaL on 2017/6/6.
|
||||
// */
|
||||
//
|
||||
//public class test {
|
||||
// Object obj;
|
||||
//
|
||||
// public void setObj(Object obj){
|
||||
// this.obj = obj;
|
||||
// }
|
||||
//
|
||||
// public void onPre(DownloadTask task){
|
||||
// obj.method(task);
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//}
|
@ -0,0 +1,48 @@ |
||||
/* |
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package com.arialyy.simple.base.adapter; |
||||
|
||||
import android.support.annotation.IdRes; |
||||
import android.support.v7.widget.RecyclerView; |
||||
import android.util.SparseArray; |
||||
import android.view.View; |
||||
|
||||
import butterknife.ButterKnife; |
||||
|
||||
/** |
||||
* Created by lyy on 2015/12/3. |
||||
* 通用Holder |
||||
*/ |
||||
public class AbsHolder extends RecyclerView.ViewHolder { |
||||
View mView; |
||||
private SparseArray<View> mViews = new SparseArray<>(); |
||||
|
||||
public AbsHolder(View itemView) { |
||||
super(itemView); |
||||
ButterKnife.bind(this, itemView); |
||||
} |
||||
|
||||
@SuppressWarnings("unchecked") |
||||
public <T extends View> T getView(@IdRes int id) { |
||||
View view = mViews.get(id); |
||||
if (view == null) { |
||||
view = mView.findViewById(id); |
||||
mViews.put(id, view); |
||||
} |
||||
return (T) view; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,72 @@ |
||||
/* |
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package com.arialyy.simple.base.adapter; |
||||
|
||||
import android.content.Context; |
||||
import android.support.v7.widget.RecyclerView; |
||||
import android.view.LayoutInflater; |
||||
import android.view.View; |
||||
import android.view.ViewGroup; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Created by lyy on 2015/12/3. |
||||
* RecyclerView 通用Adapter |
||||
*/ |
||||
public abstract class AbsRVAdapter<T, Holder extends AbsHolder> |
||||
extends RecyclerView.Adapter<Holder> { |
||||
protected String TAG; |
||||
protected List<T> mData = new ArrayList<>(); |
||||
protected Context mContext; |
||||
Holder holder; |
||||
|
||||
public AbsRVAdapter(Context context, List<T> data) { |
||||
mData = data; |
||||
mContext = context; |
||||
String arrays[] = getClass().getName().split("\\."); |
||||
TAG = arrays[arrays.length - 1]; |
||||
} |
||||
|
||||
@Override public Holder onCreateViewHolder(ViewGroup parent, int viewType) { |
||||
View view = |
||||
LayoutInflater.from(parent.getContext()).inflate(setLayoutId(viewType), parent, false); |
||||
holder = getViewHolder(view, viewType); |
||||
return holder; |
||||
} |
||||
|
||||
protected abstract Holder getViewHolder(View convertView, int viewType); |
||||
|
||||
@Override public void onBindViewHolder(Holder holder, int position) { |
||||
bindData(holder, position, mData.get(position)); |
||||
} |
||||
|
||||
public Context getContext() { |
||||
return mContext; |
||||
} |
||||
|
||||
@Override public int getItemCount() { |
||||
return mData.size(); |
||||
} |
||||
|
||||
/** |
||||
* item 的type |
||||
*/ |
||||
protected abstract int setLayoutId(int type); |
||||
|
||||
protected abstract void bindData(Holder holder, int position, T item); |
||||
} |
@ -0,0 +1,204 @@ |
||||
/* |
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package com.arialyy.simple.base.adapter; |
||||
|
||||
import android.support.v7.widget.RecyclerView; |
||||
import android.view.KeyEvent; |
||||
import android.view.MotionEvent; |
||||
import android.view.View; |
||||
import com.arialyy.simple.R; |
||||
|
||||
/* |
||||
* RecyclerView item 事件监听帮助类 |
||||
* RvItemClickSupport.addTo(recyclerView).setOnItemClickListener(new RvItemClickSupport.OnItemClickListener() { |
||||
* |
||||
* @Override |
||||
* public void onItemClicked(RecyclerView recyclerView, int position, View v) { |
||||
* //处理你的事件
|
||||
* }); |
||||
*/ |
||||
public class RvItemClickSupport { |
||||
private final RecyclerView mRecyclerView; |
||||
private OnItemClickListener mOnItemClickListener; |
||||
private OnItemLongClickListener mOnItemLongClickListener; |
||||
private OnItemTouchListener mOnItemTouchListener; |
||||
private OnItemFocusChangeListener mOnItemFocusChangeListener; |
||||
private OnItemKeyListener mOnItemKeyListener; |
||||
|
||||
public interface OnItemClickListener { |
||||
void onItemClicked(RecyclerView recyclerView, int position, View v); |
||||
} |
||||
|
||||
public interface OnItemLongClickListener { |
||||
boolean onItemLongClicked(RecyclerView recyclerView, int position, View v); |
||||
} |
||||
|
||||
public interface OnItemTouchListener { |
||||
public void onTouchEvent(RecyclerView rv, MotionEvent e, int position, View v); |
||||
} |
||||
|
||||
public interface OnItemFocusChangeListener { |
||||
public void onFocusChange(View v, int position, boolean hasFocus); |
||||
} |
||||
|
||||
public interface OnItemKeyListener { |
||||
public boolean onKey(View v, int keyCode, int position, KeyEvent event); |
||||
} |
||||
|
||||
private View.OnFocusChangeListener mOnFocusChangeListener = new View.OnFocusChangeListener() { |
||||
|
||||
@Override public void onFocusChange(View v, boolean hasFocus) { |
||||
if (mOnItemFocusChangeListener != null) { |
||||
RecyclerView.ViewHolder holder = mRecyclerView.getChildViewHolder(v); |
||||
mOnItemFocusChangeListener.onFocusChange(v, holder.getAdapterPosition(), |
||||
holder.itemView.hasFocus()); |
||||
} |
||||
} |
||||
}; |
||||
|
||||
private View.OnClickListener mOnClickListener = new View.OnClickListener() { |
||||
@Override public void onClick(View v) { |
||||
if (mOnItemClickListener != null) { |
||||
RecyclerView.ViewHolder holder = mRecyclerView.getChildViewHolder(v); |
||||
mOnItemClickListener.onItemClicked(mRecyclerView, holder.getAdapterPosition(), v); |
||||
} |
||||
} |
||||
}; |
||||
|
||||
private View.OnLongClickListener mOnLongClickListener = new View.OnLongClickListener() { |
||||
@Override public boolean onLongClick(View v) { |
||||
if (mOnItemLongClickListener != null) { |
||||
RecyclerView.ViewHolder holder = mRecyclerView.getChildViewHolder(v); |
||||
return mOnItemLongClickListener.onItemLongClicked(mRecyclerView, |
||||
holder.getAdapterPosition(), v); |
||||
} |
||||
return false; |
||||
} |
||||
}; |
||||
|
||||
private View.OnTouchListener mOnTouchListener = new View.OnTouchListener() { |
||||
@Override public boolean onTouch(View v, MotionEvent event) { |
||||
if (mOnItemTouchListener != null) { |
||||
RecyclerView.ViewHolder holder = mRecyclerView.getChildViewHolder(v); |
||||
mOnItemTouchListener.onTouchEvent(mRecyclerView, event, holder.getAdapterPosition(), v); |
||||
} |
||||
return false; |
||||
} |
||||
}; |
||||
|
||||
private View.OnKeyListener mOnKeyListener = new View.OnKeyListener() { |
||||
@Override public boolean onKey(View v, int keyCode, KeyEvent event) { |
||||
if (mOnItemKeyListener != null) { |
||||
RecyclerView.ViewHolder holder = mRecyclerView.getChildViewHolder(v); |
||||
return mOnItemKeyListener.onKey(v, keyCode, holder.getAdapterPosition(), event); |
||||
} |
||||
return false; |
||||
} |
||||
}; |
||||
|
||||
private RecyclerView.OnChildAttachStateChangeListener mAttachListener = |
||||
new RecyclerView.OnChildAttachStateChangeListener() { |
||||
@Override public void onChildViewAttachedToWindow(View view) { |
||||
if (mOnItemClickListener != null) { |
||||
view.setOnClickListener(mOnClickListener); |
||||
} |
||||
if (mOnItemLongClickListener != null) { |
||||
view.setOnLongClickListener(mOnLongClickListener); |
||||
} |
||||
if (mOnItemTouchListener != null) { |
||||
view.setOnTouchListener(mOnTouchListener); |
||||
} |
||||
if (mOnItemFocusChangeListener != null) { |
||||
view.setOnFocusChangeListener(mOnFocusChangeListener); |
||||
} |
||||
if (mOnItemKeyListener != null) { |
||||
view.setOnKeyListener(mOnKeyListener); |
||||
} |
||||
} |
||||
|
||||
@Override public void onChildViewDetachedFromWindow(View view) { |
||||
|
||||
} |
||||
}; |
||||
|
||||
private RvItemClickSupport(RecyclerView recyclerView) { |
||||
mRecyclerView = recyclerView; |
||||
mRecyclerView.setTag(R.id.item_click_support, this); |
||||
mRecyclerView.addOnChildAttachStateChangeListener(mAttachListener); |
||||
} |
||||
|
||||
public static RvItemClickSupport addTo(RecyclerView view) { |
||||
RvItemClickSupport support = (RvItemClickSupport) view.getTag(R.id.item_click_support); |
||||
if (support == null) { |
||||
support = new RvItemClickSupport(view); |
||||
} |
||||
return support; |
||||
} |
||||
|
||||
public static RvItemClickSupport removeFrom(RecyclerView view) { |
||||
RvItemClickSupport support = (RvItemClickSupport) view.getTag(R.id.item_click_support); |
||||
if (support != null) { |
||||
support.detach(view); |
||||
} |
||||
return support; |
||||
} |
||||
|
||||
/** |
||||
* 设置按键监听 |
||||
*/ |
||||
public RvItemClickSupport setOnItemKeyListenr(OnItemKeyListener onItemKeyListener) { |
||||
mOnItemKeyListener = onItemKeyListener; |
||||
return this; |
||||
} |
||||
|
||||
/** |
||||
* 设置焦点监听 |
||||
*/ |
||||
public RvItemClickSupport setOnItemFocusChangeListener( |
||||
OnItemFocusChangeListener onItemFocusChangeListener) { |
||||
mOnItemFocusChangeListener = onItemFocusChangeListener; |
||||
return this; |
||||
} |
||||
|
||||
/** |
||||
* 设置触摸监听 |
||||
*/ |
||||
public RvItemClickSupport setOnItemTouchListener(OnItemTouchListener onItemTouchListener) { |
||||
mOnItemTouchListener = onItemTouchListener; |
||||
return this; |
||||
} |
||||
|
||||
/** |
||||
* 设置点击监听 |
||||
*/ |
||||
public RvItemClickSupport setOnItemClickListener(OnItemClickListener listener) { |
||||
mOnItemClickListener = listener; |
||||
return this; |
||||
} |
||||
|
||||
/** |
||||
* 设置长按监听 |
||||
*/ |
||||
public RvItemClickSupport setOnItemLongClickListener(OnItemLongClickListener listener) { |
||||
mOnItemLongClickListener = listener; |
||||
return this; |
||||
} |
||||
|
||||
private void detach(RecyclerView view) { |
||||
view.removeOnChildAttachStateChangeListener(mAttachListener); |
||||
view.setTag(R.id.item_click_support, null); |
||||
} |
||||
} |
@ -0,0 +1,19 @@ |
||||
<?xml version="1.0" encoding="utf-8"?><!-- |
||||
Copyright (C) 2014 Lucas Rocha |
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); |
||||
you may not use this file except in compliance with the License. |
||||
You may obtain a copy of the License at |
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0 |
||||
|
||||
Unless required by applicable law or agreed to in writing, software |
||||
distributed under the License is distributed on an "AS IS" BASIS, |
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
See the License for the specific language governing permissions and |
||||
limitations under the License. |
||||
--> |
||||
|
||||
<resources> |
||||
<item name="item_click_support" type="id" /> |
||||
</resources> |
Loading…
Reference in new issue