Commit e3083787 authored by 赵鹏翔's avatar 赵鹏翔

update

parent ce4a1f78
package com.miya.fastcashier.log;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
/**
* 作者:Leon
* 时间:2017/3/17 13:44
*/
public class EmptyRecyclerView extends RecyclerView {
private View mEmptyView;
public EmptyRecyclerView(Context context) {
super(context);
}
public EmptyRecyclerView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public EmptyRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
/**
* 根据数据源判断是否显示空白view
*/
private void checkIfEmpty() {
if (mEmptyView != null || getAdapter() != null) {
mEmptyView.setVisibility(getAdapter().getItemCount() > 0 ? GONE : VISIBLE);
}
}
public void setmEmptyView(View mEmptyView) {
this.mEmptyView = mEmptyView;
checkIfEmpty();
}
@Override
public void setAdapter(Adapter adapter) {
Adapter adapterOld = getAdapter();
if (adapterOld != null) {
adapterOld.unregisterAdapterDataObserver(observer);
}
super.setAdapter(adapter);
if (adapter != null) {
adapter.registerAdapterDataObserver(observer);
}
}
AdapterDataObserver observer = new AdapterDataObserver() {
@Override
public void onChanged() {
super.onChanged();
checkIfEmpty();
}
};
}
package com.miya.fastcashier.log
import android.content.Context
import android.util.AttributeSet
import android.view.View
import androidx.recyclerview.widget.RecyclerView
/**
* 作者:Leon
* 时间:2017/3/17 13:44
*/
class EmptyRecyclerView : RecyclerView {
private var mEmptyView: View? = null
constructor(context: Context?) : super(context!!) {}
constructor(context: Context?, attrs: AttributeSet?) : super(
context!!, attrs
) {
}
constructor(context: Context?, attrs: AttributeSet?, defStyle: Int) : super(
context!!, attrs, defStyle
) {
}
/**
* 根据数据源判断是否显示空白view
*/
private fun checkIfEmpty() {
if (mEmptyView != null || adapter != null) {
mEmptyView!!.visibility =
if (adapter!!.itemCount > 0) GONE else VISIBLE
}
}
fun setmEmptyView(mEmptyView: View?) {
this.mEmptyView = mEmptyView
checkIfEmpty()
}
override fun setAdapter(adapter: Adapter<*>?) {
val adapterOld = getAdapter()
adapterOld?.unregisterAdapterDataObserver(observer)
super.setAdapter(adapter)
adapter?.registerAdapterDataObserver(observer)
}
var observer: AdapterDataObserver = object : AdapterDataObserver() {
override fun onChanged() {
super.onChanged()
checkIfEmpty()
}
}
}
\ No newline at end of file
......@@ -16,7 +16,7 @@ import java.util.*
object PrintService {
private var payServiceResponse: PayServiceResponse? = null;
private var payServiceResponse: PayServiceResponse? = null
/**
* 退款
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment