Skip to content

Commit

Permalink
BaseTab 的 DemoTab: 优化命名和注释
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyLemon committed Aug 17, 2019
1 parent f654968 commit 0b85cd0
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 61 deletions.
27 changes: 12 additions & 15 deletions ZBLibrary/src/main/java/zuo/biao/library/base/BaseTabActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public void initData() {//必须调用


//tab<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
topTabView = setTopBarLayout(context,0,setTabBarLayout());
topTabView = newTopTabView(context, 0, getTopTabViewResId());
llBaseTabTabContainer.removeAllViews();
llBaseTabTabContainer.addView(topTabView.createView());
topTabView.setCurrentPosition(currentPosition);
Expand All @@ -303,23 +303,20 @@ public void initData() {//必须调用

}

/*
* 如果需要自定义tab layout 需要实现此方法
*
* */

public int setTabBarLayout(){
/**如果需要自定义tab layout 需要实现此方法
*/
public int getTopTabViewResId() {
return R.layout.top_tab_view;
}

/*
*
* TopTabView 构造函数中,第二个参数为最小宽度,可以默认传入0即可
* */

@Override
public TopTabView setTopBarLayout(Activity context, int minWidth, int layoutId) {
return new TopTabView(context,0,layoutId);
/**TopTabView 构造函数
* @param context
* @param minWidth 最小宽度,传入 0 表示默认值
* @param layoutId
* @return
*/
public TopTabView newTopTabView(Activity context, int minWidth, int layoutId) {
return new TopTabView(context, 0, layoutId);
}


Expand Down
27 changes: 12 additions & 15 deletions ZBLibrary/src/main/java/zuo/biao/library/base/BaseTabFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public void initData() {//必须调用
}
}

topTabView = setTopBarLayout(context,0,setTabBarLayout());
topTabView = newTopTabView(context, 0, getTopTabViewResId());
llBaseTabTabContainer.removeAllViews();
llBaseTabTabContainer.addView(topTabView.createView());
topTabView.setCurrentPosition(currentPosition);
Expand All @@ -289,23 +289,20 @@ public void initData() {//必须调用

}

/*
* 如果需要自定义tab layout 需要实现此方法
*
* */

public int setTabBarLayout(){
/**如果需要自定义tab layout 需要实现此方法
*/
public int getTopTabViewResId() {
return R.layout.top_tab_view;
}

/*
*
* TopTabView 构造函数中,第二个参数为最小宽度,可以默认传入0即可
* */

@Override
public TopTabView setTopBarLayout(Activity context, int minWidth, int layoutId) {
return new TopTabView(context,0,layoutId);
/**TopTabView 构造函数
* @param context
* @param minWidth 最小宽度,传入 0 表示默认值
* @param layoutId
* @return
*/
public TopTabView newTopTabView(Activity context, int minWidth, int layoutId) {
return new TopTabView(context, 0, layoutId);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,5 @@ public interface ViewPresenter {
@Nullable
public String getForwardName();

/*
* 如果需要自定义tab layout 需要实现此方法
* TopTabView 构造函数中,第二个参数为最小宽度,可以默认传入0即可
* */

default TopTabView setTopBarLayout(Activity context, int minWidth , @LayoutRes int layoutId){
if (layoutId == 0){
return new TopTabView(context);
}else {
return new TopTabView(context,0,layoutId);
}
}

}
3 changes: 1 addition & 2 deletions ZBLibrary/src/main/java/zuo/biao/library/ui/TopTabView.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public TopTabView(Activity context, int minWidth) {
}

public TopTabView(Activity context, int minWidth, @LayoutRes int resource){
super(context,resource);
super(context, resource);
this.minWidth = minWidth;
this.inflater = context.getLayoutInflater();
}
Expand Down Expand Up @@ -189,7 +189,6 @@ public void onClick(View v) {
private TextView[] tvTabs;
/**选择tab
* @param position
* @param tabType
*/
public void select(int position) {
Log.i(TAG, "select position = " + position);
Expand Down
15 changes: 6 additions & 9 deletions app/src/main/java/zblibrary/demo/DEMO/DemoTabActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,12 @@ public void onClick(View v) {
//示例代码>>>>>>>>
}

/*
* 当需要自定义 tab bar layout时,要实现此方法
*
* */

@Override
public int setTabBarLayout() {
return zuo.biao.library.R.layout.top_tab_view;
}
/**当需要自定义 tab bar layout时,要实现此方法
*/
// @Override
// public int getTopTabViewResId() {
// return R.layout.top_tab_view;
// }

//UI显示区(操作UI,但不存在数据获取或处理代码,也不存在事件监听代码)>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Expand Down
14 changes: 6 additions & 8 deletions app/src/main/java/zblibrary/demo/DEMO/DemoTabFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,13 @@ public void initView() {//必须在onCreate方法内调用
tvDemoTabLeft = findView(R.id.tvDemoTabLeft);
}

/*
* 当需要自定义 tab bar layout时,要实现此方法
*
* */

@Override
public int setTabBarLayout() {
return zuo.biao.library.R.layout.top_tab_view;
}
/**当需要自定义 tab bar layout时,要实现此方法
*/
// @Override
// public int getTopTabViewResId() {
// return R.layout.top_tab_view;
// }

/**一行代码没必要新建方法,这里是为了给DemoBottomTabActivity调用
*/
Expand Down

0 comments on commit 0b85cd0

Please sign in to comment.