Skip to content

Commit

Permalink
主操作栏和副操作栏相关修改与使用示例
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoqp2010 committed Nov 22, 2013
1 parent 297cffe commit 0add6ee
Show file tree
Hide file tree
Showing 357 changed files with 1,720 additions and 1,257 deletions.
Binary file modified AndBase/bin/andbase.jar
Binary file not shown.
Binary file modified AndBase/bin/classes/com/ab/activity/AbActivity$1.class
Binary file not shown.
Binary file modified AndBase/bin/classes/com/ab/activity/AbActivity$2.class
Binary file not shown.
Binary file modified AndBase/bin/classes/com/ab/activity/AbActivity$3.class
Binary file not shown.
Binary file modified AndBase/bin/classes/com/ab/activity/AbActivity$4.class
Binary file not shown.
Binary file modified AndBase/bin/classes/com/ab/activity/AbActivity$5.class
Binary file not shown.
Binary file modified AndBase/bin/classes/com/ab/activity/AbActivity$Method.class
Binary file not shown.
Binary file modified AndBase/bin/classes/com/ab/activity/AbActivity.class
Binary file not shown.
Binary file modified AndBase/bin/classes/com/ab/util/AbViewUtil.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified AndBase/bin/classes/com/ab/view/titlebar/AbTitleBar$1.class
Binary file not shown.
Binary file modified AndBase/bin/classes/com/ab/view/titlebar/AbTitleBar$2.class
Binary file not shown.
Binary file modified AndBase/bin/classes/com/ab/view/titlebar/AbTitleBar.class
Binary file not shown.
3 changes: 3 additions & 0 deletions AndBase/bin/jarlist.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# cache for current jar dependency. DO NOT EDIT.
# format is <lastModified> <length> <SHA-1> <path>
# Encoding is UTF-8
80 changes: 30 additions & 50 deletions AndBase/src/com/ab/activity/AbActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.PixelFormat;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
Expand All @@ -39,15 +38,13 @@
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AbsListView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.Toast;

Expand All @@ -58,6 +55,7 @@
import com.ab.view.ioc.AbIocSelect;
import com.ab.view.ioc.AbIocView;
import com.ab.view.listener.AbIocEventListener;
import com.ab.view.titlebar.AbBottomBar;
import com.ab.view.titlebar.AbTitleBar;

// TODO: Auto-generated Javadoc
Expand Down Expand Up @@ -136,20 +134,14 @@ public abstract class AbActivity extends FragmentActivity {
public RelativeLayout ab_base = null;

/** 标题栏布局. */
protected AbTitleBar mAbTitlebar = null;
protected AbTitleBar mAbTitleBar = null;

/** 标题栏布局ID. */
public int mAbTitlebarID = 1;

/** 副标题栏布局ID. */
public int mBottombarID = 2;
/** 副标题栏布局. */
protected AbBottomBar mAbBottomBar = null;

/** 主内容布局. */
protected RelativeLayout contentLayout = null;

/** 副标题栏布局. */
protected RelativeLayout bottomLayout = null;

/** 屏幕宽度. */
public int diaplayWidth = 320;

Expand Down Expand Up @@ -224,7 +216,8 @@ protected void onCreate(Bundle savedInstanceState) {
layoutParamsWF = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
layoutParamsWW = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

mAbTitlebar = new AbTitleBar(this);
//主标题栏
mAbTitleBar = new AbTitleBar(this);

ab_base = new RelativeLayout(this);
ab_base.setBackgroundColor(Color.rgb(255, 255, 255));
Expand All @@ -233,20 +226,18 @@ protected void onCreate(Bundle savedInstanceState) {
contentLayout.setPadding(0, 0, 0, 0);

//副标题栏
bottomLayout = new RelativeLayout(this);
bottomLayout.setPadding(0, 0, 0, 0);
bottomLayout.setId(mBottombarID);
mAbBottomBar = new AbBottomBar(this);

//填入View
ab_base.addView(mAbTitlebar,layoutParamsFW);
ab_base.addView(mAbTitleBar,layoutParamsFW);

RelativeLayout.LayoutParams layoutParamsFW2 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParamsFW2.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
ab_base.addView(bottomLayout, layoutParamsFW2);
ab_base.addView(mAbBottomBar, layoutParamsFW2);

RelativeLayout.LayoutParams layoutParamsFW1 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParamsFW1.addRule(RelativeLayout.BELOW, mAbTitlebarID);
layoutParamsFW1.addRule(RelativeLayout.ABOVE, mBottombarID);
layoutParamsFW1.addRule(RelativeLayout.BELOW, mAbTitleBar.getId());
layoutParamsFW1.addRule(RelativeLayout.ABOVE, mAbBottomBar.getId());
ab_base.addView(contentLayout, layoutParamsFW1);

abApplication = getApplication();
Expand Down Expand Up @@ -538,13 +529,23 @@ public void removeDialogInThread(int id){
}

/**
* Gets the title layout.
* 获取主标题栏布局.
* @return the title layout
*/
public AbTitleBar getTitleBar() {
return mAbTitlebar;
return mAbTitleBar;
}


/**
* 获取副标题栏布局.
* @return the bottom layout
*/
public AbBottomBar getAbBottomBar() {
return mAbBottomBar;
}


/**
* 描述:打开关闭帧数测试
* <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
Expand Down Expand Up @@ -729,51 +730,30 @@ public void setTitleBarAbove(boolean above) {
ab_base.removeAllViews();
if(above){
RelativeLayout.LayoutParams layoutParamsFW1 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParamsFW1.addRule(RelativeLayout.ABOVE, mBottombarID);
layoutParamsFW1.addRule(RelativeLayout.ABOVE, mAbBottomBar.getId());
ab_base.addView(contentLayout,layoutParamsFW1);
RelativeLayout.LayoutParams layoutParamsFW2 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParamsFW2.addRule(RelativeLayout.ALIGN_PARENT_TOP,RelativeLayout.TRUE);
ab_base.addView(mAbTitlebar,layoutParamsFW2);
ab_base.addView(mAbTitleBar,layoutParamsFW2);

RelativeLayout.LayoutParams layoutParamsFW3 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParamsFW3.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
ab_base.addView(bottomLayout, layoutParamsFW3);
ab_base.addView(mAbBottomBar, layoutParamsFW3);

}else{
ab_base.addView(mAbTitlebar,layoutParamsFW);
ab_base.addView(mAbTitleBar,layoutParamsFW);

RelativeLayout.LayoutParams layoutParamsFW2 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParamsFW2.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
ab_base.addView(bottomLayout, layoutParamsFW2);
ab_base.addView(mAbBottomBar, layoutParamsFW2);

RelativeLayout.LayoutParams layoutParamsFW1 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParamsFW1.addRule(RelativeLayout.BELOW, mAbTitlebarID);
layoutParamsFW1.addRule(RelativeLayout.ABOVE, mBottombarID);
layoutParamsFW1.addRule(RelativeLayout.BELOW, mAbTitleBar.getId());
layoutParamsFW1.addRule(RelativeLayout.ABOVE, mAbBottomBar.getId());
ab_base.addView(contentLayout, layoutParamsFW1);
}
}



/**
*
* 描述:设置副标题栏界面显示
* @param view
* @throws
*/
public void setBottomView(View view) {
bottomLayout.removeAllViews();
bottomLayout.addView(view,layoutParamsFW);
}

/**
* 描述:用指定资源ID表示的View填充主界面.
* @param resId 指定的View的资源ID
*/
public void setBottomView(int resId) {
setBottomView(mInflater.inflate(resId, null));
}

/**
* 描述:设置界面显示(忽略标题栏)
* @see android.app.Activity#setContentView(int)
Expand Down
38 changes: 24 additions & 14 deletions AndBase/src/com/ab/util/AbViewUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,40 @@ public class AbViewUtil {
*/
public static void setAbsListViewHeight(AbsListView absListView,int lineNumber,int verticalSpace) {

if (lineNumber == 0) {
return;
}
int totalHeight = getAbsListViewHeight(absListView,lineNumber,verticalSpace);
ViewGroup.LayoutParams params = absListView.getLayoutParams();
params.height = totalHeight;
((MarginLayoutParams) params).setMargins(0, 0, 0, 0);
absListView.setLayoutParams(params);
}

/**
* 描述:获取AbsListView的高度.
* @param absListView the abs list view
* @param lineNumber 每行几个 ListView一行一个item
* @param verticalSpace the vertical space
*/
public static int getAbsListViewHeight(AbsListView absListView,int lineNumber,int verticalSpace) {
int totalHeight = 0;
int w = View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED);
int h = View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED);
ListAdapter mListAdapter = absListView.getAdapter();
absListView.measure(w, h);
ListAdapter mListAdapter = absListView.getAdapter();
if (mListAdapter == null) {
return;
return totalHeight;
}
int totalHeight = 0;

int count = mListAdapter.getCount();
ViewGroup.LayoutParams params = absListView.getLayoutParams();
if(absListView instanceof ListView){
for (int i = 0; i < count; i++) {
View listItem = mListAdapter.getView(i, null, absListView);
listItem.measure(w, h);
totalHeight += listItem.getMeasuredHeight();
}
if (count == 0) {
params.height = verticalSpace;
totalHeight = verticalSpace;
} else {
params.height = totalHeight + (((ListView)absListView).getDividerHeight() * (count - 1));
totalHeight = totalHeight + (((ListView)absListView).getDividerHeight() * (count - 1));
}

}else if(absListView instanceof GridView){
Expand All @@ -69,18 +81,16 @@ public static void setAbsListViewHeight(AbsListView absListView,int lineNumber,i
remain = 1;
}
if(mListAdapter.getCount()==0){
params.height = verticalSpace;
totalHeight = verticalSpace;
}else{
View listItem = mListAdapter.getView(0, null, absListView);
listItem.measure(w, h);
int line = count/lineNumber + remain;
params.height = line*listItem.getMeasuredHeight()+(line-1)*verticalSpace;
totalHeight = line*listItem.getMeasuredHeight()+(line-1)*verticalSpace;
}

}

((MarginLayoutParams) params).setMargins(0, 0, 0, 0);
absListView.setLayoutParams(params);
return totalHeight;

}

Expand Down
Loading

0 comments on commit 0add6ee

Please sign in to comment.