Skip to content

Commit

Permalink
AbHttpUtil对非外链的兼容
Browse files Browse the repository at this point in the history
在AbActivity增加副操作栏的支持(完善中)
主操作栏增加下拉菜单的支持
  • Loading branch information
zhaoqp2010 committed Nov 21, 2013
1 parent e502109 commit 297cffe
Show file tree
Hide file tree
Showing 280 changed files with 1,783 additions and 1,591 deletions.
4 changes: 2 additions & 2 deletions AndBase/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
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/db/orm/AbTableHelper.class
Binary file not shown.
Binary file modified AndBase/bin/classes/com/ab/download/AbFileDownloader.class
Binary file not shown.
Binary file modified AndBase/bin/classes/com/ab/global/AbConstant.class
Binary file not shown.
Binary file added AndBase/bin/classes/com/ab/global/AbMenuItem.class
Binary file not shown.
Binary file modified AndBase/bin/classes/com/ab/http/AbFileHttpResponseListener.class
Binary file not shown.
Binary file modified AndBase/bin/classes/com/ab/http/AbHttpClient$1.class
Binary file not shown.
Binary file modified AndBase/bin/classes/com/ab/http/AbHttpClient$2.class
Binary file not shown.
Binary file not shown.
Binary file modified AndBase/bin/classes/com/ab/http/AbHttpClient.class
Binary file not shown.
Binary file not shown.
Binary file modified AndBase/bin/classes/com/ab/util/AbFileUtil.class
Binary file not shown.
Binary file modified AndBase/bin/classes/com/ab/view/titlebar/AbTitleBar$1.class
Binary file not shown.
Binary file not shown.
Binary file modified AndBase/bin/classes/com/ab/view/titlebar/AbTitleBar.class
Binary file not shown.
3 changes: 0 additions & 3 deletions AndBase/bin/jarlist.cache

This file was deleted.

106 changes: 81 additions & 25 deletions AndBase/src/com/ab/activity/AbActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
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,13 +39,15 @@
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 Down Expand Up @@ -139,9 +141,15 @@ public abstract class AbActivity extends FragmentActivity {
/** 标题栏布局ID. */
public int mAbTitlebarID = 1;

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

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

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

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

Expand Down Expand Up @@ -224,20 +232,22 @@ protected void onCreate(Bundle savedInstanceState) {
contentLayout = new RelativeLayout(this);
contentLayout.setPadding(0, 0, 0, 0);

Intent intent = this.getIntent();
int titleTransparentFlag = intent.getIntExtra(AbConstant.TITLE_TRANSPARENT_FLAG,AbConstant.TITLE_NOTRANSPARENT);
//副标题栏
bottomLayout = new RelativeLayout(this);
bottomLayout.setPadding(0, 0, 0, 0);
bottomLayout.setId(mBottombarID);

if(titleTransparentFlag == AbConstant.TITLE_TRANSPARENT){
ab_base.addView(contentLayout,layoutParamsFW);
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);
}else{
ab_base.addView(mAbTitlebar,layoutParamsFW);
RelativeLayout.LayoutParams layoutParamsFW1 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParamsFW1.addRule(RelativeLayout.BELOW, mAbTitlebarID);
ab_base.addView(contentLayout, layoutParamsFW1);
}
//填入View
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);

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

abApplication = getApplication();
abSharedPreferences = getSharedPreferences(AbConstant.SHAREPATH, Context.MODE_PRIVATE);
Expand Down Expand Up @@ -268,8 +278,6 @@ public void showToast(int resId) {
Toast.makeText(this,""+this.getResources().getText(resId), Toast.LENGTH_SHORT).show();
}



/**
* 描述:用指定的View填充主界面.
* @param contentView 指定的View
Expand All @@ -286,13 +294,8 @@ public void setAbContentView(View contentView) {
* @param resId 指定的View的资源ID
*/
public void setAbContentView(int resId) {
contentLayout.removeAllViews();
contentLayout.addView(mInflater.inflate(resId, null),layoutParamsFF);
//ioc
initIocView();
setAbContentView(mInflater.inflate(resId, null));
}



/**
* 描述:在线程中提示文本信息.
Expand Down Expand Up @@ -698,7 +701,7 @@ public Dialog getBottomDialog() {


/**
* Gets the center dialog.
* 获取显示在中间的Dialog.
*
* @return the center dialog
*/
Expand All @@ -716,8 +719,61 @@ public Dialog getTopDialog() {
return mTopDialog;
}



/**
*
* 描述:设置绝对定位的主标题栏覆盖到内容的上边
* @param above
* @throws
*/
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);
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);

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);

}else{
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);

RelativeLayout.LayoutParams layoutParamsFW1 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParamsFW1.addRule(RelativeLayout.BELOW, mAbTitlebarID);
layoutParamsFW1.addRule(RelativeLayout.ABOVE, mBottombarID);
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
2 changes: 1 addition & 1 deletion AndBase/src/com/ab/db/orm/AbTableHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ else if (field.isAnnotationPresent(Id.class)) {

String sql = sb.toString();

Log.d(TAG, "crate table [" + tableName + "]: " + sql);
Log.d(TAG, "create table [" + tableName + "]: " + sql);

db.execSQL(sql);
}
Expand Down
4 changes: 2 additions & 2 deletions AndBase/src/com/ab/download/AbFileDownloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ protected synchronized void update(DownFile downFile) {
* @param suffix 文件类型后缀
* @param threadNum 下载线程数
*/
public AbFileDownloader(Context context,DownFile downFile,String suffix,int threadNum) {
public AbFileDownloader(Context context,DownFile downFile,int threadNum) {
try {
this.context = context;
this.mDownFile = downFile;
this.mThreadNum = threadNum;
mDownFileDao = new DownFileDao(context);
// 构建保存文件
String fileName = AbFileUtil.getFileNameFromUrl(mDownFile.getDownUrl(),suffix);
String fileName = AbFileUtil.getFileNameFromUrl(mDownFile.getDownUrl());
saveFile = new File(Environment.getExternalStorageDirectory().getPath()+File.separator+AbFileUtil.getDownPathFileDir()+fileName);
if (!saveFile.getParentFile().exists()){
saveFile.getParentFile().mkdirs();
Expand Down
15 changes: 5 additions & 10 deletions AndBase/src/com/ab/global/AbConstant.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,6 @@ public class AbConstant {
/** 删除顶部进度框. */
public static final int REMOVE_DIALOGTOP = 5;

/** 标题栏透明标记. */
public static final String TITLE_TRANSPARENT_FLAG = "TITLE_TRANSPARENT_FLAG";

/** 标题栏透明. */
public static final int TITLE_TRANSPARENT = 0;

/** 标题栏不透明. */
public static final int TITLE_NOTRANSPARENT = 1;

/** View的类型. */
public static final int LISTVIEW = 1;

Expand All @@ -96,8 +87,12 @@ public class AbConstant {

/** 连接失败的HTTP返回码. */
public static final int CONNECT_FAILURE_CODE = 600;
/** 连接失败的HTTP返回码. */
public static final int CONNECT_TIMEOUT_CODE = 601;
/** 响应失败的HTTP返回码. */
public static final int RESPONSE_TIMEOUT_CODE = 602;
/** 未处理的HTTP返回码. */
public static final int UNTREATED_CODE = 700;
public static final int UNTREATED_CODE = 900;

public static final String CONNECTEXCEPTION = "无法连接到网络";
public static final String UNKNOWNHOSTEXCEPTION = "连接远程地址失败";
Expand Down
101 changes: 101 additions & 0 deletions AndBase/src/com/ab/global/AbMenuItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
* Copyright (C) 2013 www.418log.org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.ab.global;

// TODO: Auto-generated Javadoc
/**
* 描述:菜单对象.
*
* @author zhaoqp
* @date:2013-11-21 下午1:30:54
* @version v1.0
*/
public class AbMenuItem {

/** 菜单的id. */
private int iconId;

/** 菜单的文本. */
private String text;


/**
* Instantiates a new ab menu item.
*
* @param iconId the icon id
* @param text the text
*/
public AbMenuItem(int iconId, String text) {
super();
this.iconId = iconId;
this.text = text;
}

/**
* Instantiates a new ab menu item.
*
* @param text the text
*/
public AbMenuItem(String text) {
super();
this.text = text;
}

/**
* Instantiates a new ab menu item.
*
*/
public AbMenuItem() {
super();
}

/**
* Gets the icon id.
*
* @return the icon id
*/
public int getIconId() {
return iconId;
}

/**
* Sets the icon id.
*
* @param iconId the new icon id
*/
public void setIconId(int iconId) {
this.iconId = iconId;
}

/**
* Gets the text.
*
* @return the text
*/
public String getText() {
return text;
}

/**
* Sets the text.
*
* @param text the new text
*/
public void setText(String text) {
this.text = text;
}

}
Loading

0 comments on commit 297cffe

Please sign in to comment.