Commit bcdc2b6a by sikang

test

parent 7fc4b04a
......@@ -150,6 +150,7 @@ public abstract class BaseActivity extends AppCompatActivity implements IView {
//填充Activity -> bindLayout();
if (bindLayout() != 0) {
LayoutInflater.from(this).inflate(bindLayout(), rootLayout, true);
LibConfig.bindView(this, rootLayout);
initView();
} else {
throw new RuntimeException("找不到布局文件 bindLayout() -> " + bindLayout());
......
......@@ -62,6 +62,7 @@ public abstract class BaseFragment extends Fragment implements IView {
initTopBar(mTopBar);
}
mContentView = (ViewGroup) LayoutInflater.from(getActivity()).inflate(bindLayout(), mContentView);
LibConfig.bindView(this, mContentView);
initView();
return mContentView;
}
......
......@@ -2,6 +2,7 @@ package tech.starwin.base;
import android.app.Application;
import android.content.Context;
import android.view.View;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.DefaultRefreshFooterCreator;
......@@ -43,16 +44,44 @@ public class LibConfig {
public static String HARVESTER_IP;
public static int HARVESTER_PORT;
public static ButterKnifeBinder butterKnifeBinder;
public static Context getContext() {
if (CONTEXT == null)
throw new RuntimeException("context is null ! you must execute LibConfig.bindApplication(application) in your Appliaction");
return CONTEXT;
}
/**
* 为Library绑定一个Context
*/
public static void bindApplication(Application application) {
CONTEXT = application;
}
/**
* 用于在Base 中 实现Butterknife.bind()的功能
*
* @param binder 实现 ButterKnifeBinder.bindView() 方法,在其中做Butterknife.bind() ,功能
*/
public static void setButterKnifeBinder(ButterKnifeBinder binder) {
butterKnifeBinder = binder;
}
public static void bindView(Object obj, View view) {
if (butterKnifeBinder != null) {
butterKnifeBinder.bindView(obj, view);
}
}
public interface ButterKnifeBinder {
void bindView(Object obj, View view);
}
/**
* SmartRefresh 默认风格
* */
static {
//设置全局的Header构建器
SmartRefreshLayout.setDefaultRefreshHeaderCreator(new DefaultRefreshHeaderCreator() {
......
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