List tempList;
synchronized (activities) {
tempList = new LinkedList(activities);
}
for (BaseActivity a : tempList) {
a.finish();
}
}
@Override
protected void onDestroy() {
activities.remove(this);
try {
System.gc();
} catch (Exception e) {
}
super.onDestroy();
}
}
- 创建BaseRecyclerViewActivity处理布局绑定
package tsou.cn.databinding;
import android.databinding.DataBindingUtil;
import android.databinding.ViewDataBinding;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
public abstract class BaseRecyclerViewActivity extends BaseActivity {
protected View notDataView;
protected View errorView;
protected M binding;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, getLayoutId());
setEmptyAndErrorView(getRecyclerView(), R.mipmap.icon_empty, getString(R.string.the_server_did_not_return_data));
initData(savedInstanceState);
initListener();
}
public abstract int getLayoutId();
public abstract RecyclerView getRecyclerView();
protected abstract void initData(Bundle savedInstanceState);
protected void initListener() {
}
protected void setEmptyAndErrorView(RecyclerView mRecyclerView, int emptyIcon, String emptyText) {
notDataView = ge
tLayoutInflater().inflate(R.layout.empty_view, (ViewGroup) mRecyclerView.getParent(), false);
ImageView empty_icon = (ImageVie