├── .gitignore ├── README.md ├── library ├── AndroidManifest.xml ├── project.properties └── src │ └── com │ └── lidroid │ └── xutils │ ├── BitmapUtils.java │ ├── DbUtils.java │ ├── HttpUtils.java │ ├── ViewUtils.java │ ├── bitmap │ ├── BitmapCacheListener.java │ ├── BitmapCommonUtils.java │ ├── BitmapDisplayConfig.java │ ├── BitmapGlobalConfig.java │ ├── PauseOnScrollListener.java │ ├── callback │ │ ├── BitmapLoadCallBack.java │ │ ├── BitmapLoadFrom.java │ │ ├── BitmapSetter.java │ │ └── DefaultBitmapLoadCallBack.java │ ├── core │ │ ├── AsyncDrawable.java │ │ ├── BitmapCache.java │ │ ├── BitmapDecoder.java │ │ └── BitmapSize.java │ ├── download │ │ ├── DefaultDownloader.java │ │ └── Downloader.java │ ├── factory │ │ └── BitmapFactory.java │ └── package-info.java │ ├── cache │ ├── FileNameGenerator.java │ ├── KeyExpiryMap.java │ ├── LruDiskCache.java │ ├── LruMemoryCache.java │ ├── MD5FileNameGenerator.java │ └── package-info.java │ ├── db │ ├── annotation │ │ ├── Check.java │ │ ├── Column.java │ │ ├── Finder.java │ │ ├── Foreign.java │ │ ├── Id.java │ │ ├── NoAutoIncrement.java │ │ ├── NotNull.java │ │ ├── Table.java │ │ ├── Transient.java │ │ └── Unique.java │ ├── converter │ │ ├── BooleanColumnConverter.java │ │ ├── ByteArrayColumnConverter.java │ │ ├── ByteColumnConverter.java │ │ ├── CharColumnConverter.java │ │ ├── ColumnConverter.java │ │ ├── ColumnConverterFactory.java │ │ ├── DateColumnConverter.java │ │ ├── DoubleColumnConverter.java │ │ ├── FloatColumnConverter.java │ │ ├── IntegerColumnConverter.java │ │ ├── LongColumnConverter.java │ │ ├── ShortColumnConverter.java │ │ ├── SqlDateColumnConverter.java │ │ └── StringColumnConverter.java │ ├── package-info.java │ ├── sqlite │ │ ├── ColumnDbType.java │ │ ├── CursorUtils.java │ │ ├── DbModelSelector.java │ │ ├── FinderLazyLoader.java │ │ ├── ForeignLazyLoader.java │ │ ├── Selector.java │ │ ├── SqlInfo.java │ │ ├── SqlInfoBuilder.java │ │ └── WhereBuilder.java │ └── table │ │ ├── Column.java │ │ ├── ColumnUtils.java │ │ ├── DbModel.java │ │ ├── Finder.java │ │ ├── Foreign.java │ │ ├── Id.java │ │ ├── KeyValue.java │ │ ├── Table.java │ │ └── TableUtils.java │ ├── exception │ ├── BaseException.java │ ├── DbException.java │ ├── HttpException.java │ └── package-info.java │ ├── http │ ├── HttpCache.java │ ├── HttpHandler.java │ ├── RequestParams.java │ ├── ResponseInfo.java │ ├── ResponseStream.java │ ├── SyncHttpHandler.java │ ├── callback │ │ ├── DefaultHttpRedirectHandler.java │ │ ├── FileDownloadHandler.java │ │ ├── HttpRedirectHandler.java │ │ ├── RequestCallBack.java │ │ ├── RequestCallBackHandler.java │ │ └── StringDownloadHandler.java │ ├── client │ │ ├── DefaultSSLSocketFactory.java │ │ ├── HttpRequest.java │ │ ├── RetryHandler.java │ │ ├── entity │ │ │ ├── BodyParamsEntity.java │ │ │ ├── DecompressingEntity.java │ │ │ ├── FileUploadEntity.java │ │ │ ├── GZipDecompressingEntity.java │ │ │ ├── InputStreamUploadEntity.java │ │ │ └── UploadEntity.java │ │ ├── multipart │ │ │ ├── FormBodyPart.java │ │ │ ├── HttpMultipart.java │ │ │ ├── HttpMultipartMode.java │ │ │ ├── MIME.java │ │ │ ├── MinimalField.java │ │ │ ├── MinimalFieldHeader.java │ │ │ ├── MultipartEntity.java │ │ │ └── content │ │ │ │ ├── AbstractContentBody.java │ │ │ │ ├── ByteArrayBody.java │ │ │ │ ├── ContentBody.java │ │ │ │ ├── ContentDescriptor.java │ │ │ │ ├── FileBody.java │ │ │ │ ├── InputStreamBody.java │ │ │ │ └── StringBody.java │ │ └── util │ │ │ ├── URIBuilder.java │ │ │ └── URLEncodedUtils.java │ └── package-info.java │ ├── package-info.java │ ├── task │ ├── Priority.java │ ├── PriorityAsyncTask.java │ ├── PriorityExecutor.java │ ├── PriorityObject.java │ ├── PriorityObjectBlockingQueue.java │ ├── PriorityRunnable.java │ ├── TaskHandler.java │ └── package-info.java │ ├── util │ ├── CharsetUtils.java │ ├── DoubleKeyValueMap.java │ ├── IOUtils.java │ ├── LogUtils.java │ ├── MimeTypeUtils.java │ ├── OtherUtils.java │ ├── PreferencesCookieStore.java │ └── package-info.java │ └── view │ ├── EventListenerManager.java │ ├── ResLoader.java │ ├── ResType.java │ ├── ViewFinder.java │ ├── ViewInjectInfo.java │ ├── annotation │ ├── ContentView.java │ ├── PreferenceInject.java │ ├── ResInject.java │ ├── ViewInject.java │ └── event │ │ ├── EventBase.java │ │ ├── OnChildClick.java │ │ ├── OnClick.java │ │ ├── OnCompoundButtonCheckedChange.java │ │ ├── OnFocusChange.java │ │ ├── OnGroupClick.java │ │ ├── OnGroupCollapse.java │ │ ├── OnGroupExpand.java │ │ ├── OnItemClick.java │ │ ├── OnItemLongClick.java │ │ ├── OnItemSelected.java │ │ ├── OnKey.java │ │ ├── OnLongClick.java │ │ ├── OnNothingSelected.java │ │ ├── OnPreferenceChange.java │ │ ├── OnPreferenceClick.java │ │ ├── OnProgressChanged.java │ │ ├── OnRadioGroupCheckedChange.java │ │ ├── OnScroll.java │ │ ├── OnScrollStateChanged.java │ │ ├── OnStartTrackingTouch.java │ │ ├── OnStopTrackingTouch.java │ │ ├── OnTabChange.java │ │ └── OnTouch.java │ └── package-info.java ├── sample ├── AndroidManifest.xml ├── assets │ └── img │ │ └── wallpaper.jpg ├── libs │ └── android-support-v4.jar ├── proguard-project.txt ├── project.properties ├── res │ ├── drawable-hdpi │ │ └── ic_launcher.png │ ├── drawable-ldpi │ │ └── ic_launcher.png │ ├── drawable-mdpi │ │ └── ic_launcher.png │ ├── drawable-xhdpi │ │ └── ic_launcher.png │ ├── drawable │ │ ├── bitmap.png │ │ ├── bitmap_press.png │ │ ├── database.png │ │ ├── database_press.png │ │ ├── http.png │ │ ├── http_press.png │ │ ├── icon_btimap.xml │ │ ├── icon_database.xml │ │ ├── icon_http.xml │ │ ├── tab_background.9.png │ │ ├── tab_item.xml │ │ └── tab_item_press.9.png │ ├── layout │ │ ├── bitmap_fragment.xml │ │ ├── bitmap_item.xml │ │ ├── db_fragment.xml │ │ ├── download_item.xml │ │ ├── download_list.xml │ │ ├── http_fragment.xml │ │ ├── image.xml │ │ ├── main.xml │ │ └── tab_bottom_nav.xml │ ├── values-zh-rCN │ │ └── strings.xml │ └── values │ │ └── strings.xml └── src │ └── com │ └── lidroid │ └── xutils │ └── sample │ ├── BitmapHelp.java │ ├── DownloadListActivity.java │ ├── ImageActivity.java │ ├── MyActivity.java │ ├── download │ ├── DownloadInfo.java │ ├── DownloadManager.java │ └── DownloadService.java │ ├── entities │ ├── Child.java │ ├── EntityBase.java │ └── Parent.java │ └── fragment │ ├── BitmapFragment.java │ ├── DbFragment.java │ └── HttpFragment.java ├── xUtils-2.6.14-doc.jar ├── xUtils-2.6.14-doc.war └── xUtils-2.6.14.jar /.gitignore: -------------------------------------------------------------------------------- 1 | # built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # files for the dex VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # generated files 12 | gen/ 13 | 14 | # Local configuration file (sdk path, etc) 15 | local.properties 16 | 17 | # Eclipse project files 18 | .classpath 19 | .project 20 | 21 | # IDEA project files 22 | *.iml 23 | .idea/ 24 | 25 | # others 26 | ant.properties 27 | build.xml 28 | META-INF 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 本项目是对xUtils的Fork 2 | * 对xUtils作者致敬! 3 | * 本项目旨在为xUtils添加注释,以便学习查阅 4 | 5 | 6 | ## 特别感谢 @格格-西安 的大力支持!鸣谢 7 | * 因个人语言表达能力有限,加上对xUtils的思想不是很清楚,撰写的注释可能不尽如人意,大家可以给我反馈,或自行修改 8 | * 注释使用通用的UTF-8编码格式,注释乱码问题望自行解决 9 | 10 | 11 | ---- 12 | ## xUtils简介 13 | * xUtils 包含了很多实用的android工具。 14 | * xUtils 支持大文件上传,更全面的http请求协议支持(10种谓词),拥有更加灵活的ORM,更多的事件注解支持且不受混淆影响... 15 | * xUitls 最低兼容android 2.2 (api level 8) 16 | 17 | # 关于作者 18 | * xUtils作者: wyouflf 邮箱:, 19 | * 注释撰写作者: king 邮箱: 20 | * 有任何建议或者使用中遇到问题都可以给作者发邮件, 你也可以加入QQ群:384426013,技术交流,idea分享 *_* 21 | -------------------------------------------------------------------------------- /library/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /library/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | android.library=true 14 | # Project target. 15 | target=android-8 16 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/bitmap/BitmapCacheListener.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.bitmap; 2 | 3 | /** 4 | * 图片缓存生命周期监听器 5 | * 6 | *
 7 |  * Created with IntelliJ IDEA.
 8 |  * User: wyouflf
 9 |  * Date: 13-10-16
10 |  * Time: 下午4:26
11 |  * 
12 | * 13 | * @author wyouflf 14 | */ 15 | public interface BitmapCacheListener { 16 | /** 17 | * 内存缓存初始化完成 18 | */ 19 | void onInitMemoryCacheFinished(); 20 | /** 21 | * 磁盘缓存初始化完成 22 | */ 23 | void onInitDiskFinished(); 24 | 25 | 26 | /** 27 | * 清空缓存(内存、磁盘)完成 28 | */ 29 | void onClearCacheFinished(); 30 | /** 31 | * 清空内存缓存完成 32 | */ 33 | void onClearMemoryCacheFinished(); 34 | /** 35 | * 清空磁盘缓存完成 36 | */ 37 | void onClearDiskCacheFinished(); 38 | 39 | 40 | /** 41 | * 清除指定URL的内存、磁盘缓存完成 42 | */ 43 | void onClearCacheFinished(String uri); 44 | /** 45 | * 清除指定URL的内存缓存完成 46 | */ 47 | void onClearMemoryCacheFinished(String uri); 48 | /** 49 | * 清除指定URL的磁盘缓存完成 50 | */ 51 | void onClearDiskCacheFinished(String uri); 52 | 53 | 54 | /** 55 | * 清空文件系统缓冲区数据完成 56 | */ 57 | void onFlushCacheFinished(); 58 | 59 | 60 | /** 61 | * 缓存关闭 62 | */ 63 | void onCloseCacheFinished(); 64 | 65 | } 66 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/bitmap/PauseOnScrollListener.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright 2011-2013 Sergey Tarasevich 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | *******************************************************************************/ 16 | package com.lidroid.xutils.bitmap; 17 | 18 | import android.widget.AbsListView; 19 | import android.widget.AbsListView.OnScrollListener; 20 | 21 | import com.lidroid.xutils.task.TaskHandler; 22 | 23 | /** 24 | * 滚动暂停监听器 25 | */ 26 | public class PauseOnScrollListener implements OnScrollListener { 27 | 28 | private TaskHandler taskHandler; 29 | 30 | private final boolean pauseOnScroll; 31 | private final boolean pauseOnFling; 32 | private final OnScrollListener externalListener; 33 | 34 | /** 35 | * 构造滚动暂停监听器 36 | * 37 | * @param taskHandler 任务处理接口{@link com.lidroid.xutils.task.TaskHandler} 38 | * @param pauseOnScroll 触摸滚动是否暂停加载 39 | * @param pauseOnFling 快速滚动是否暂停加载 40 | */ 41 | public PauseOnScrollListener(TaskHandler taskHandler, boolean pauseOnScroll, boolean pauseOnFling) { 42 | this(taskHandler, pauseOnScroll, pauseOnFling, null); 43 | } 44 | 45 | /** 46 | * 构造滚动暂停监听器 47 | * 48 | * @param taskHandler 任务处理接口{@link com.lidroid.xutils.task.TaskHandler} 49 | * @param pauseOnScroll 触摸滚动是否暂停加载 50 | * @param pauseOnFling 快速滚动是否暂停加载 51 | * @param customListener 滑动暂停监听器{@link android.widget.AbsListView.OnScrollListener} 52 | */ 53 | public PauseOnScrollListener(TaskHandler taskHandler, boolean pauseOnScroll, boolean pauseOnFling, OnScrollListener customListener) { 54 | this.taskHandler = taskHandler; 55 | this.pauseOnScroll = pauseOnScroll; 56 | this.pauseOnFling = pauseOnFling; 57 | externalListener = customListener; 58 | } 59 | 60 | /** 61 | * 滚动状态改变 62 | * @param view 列表控件 63 | * @param scrollState 滚动状态 64 | */ 65 | @Override 66 | public void onScrollStateChanged(AbsListView view, int scrollState) { 67 | switch (scrollState) { 68 | case OnScrollListener.SCROLL_STATE_IDLE: 69 | taskHandler.resume(); 70 | break; 71 | case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL: 72 | if (pauseOnScroll) { 73 | taskHandler.pause(); 74 | } 75 | break; 76 | case OnScrollListener.SCROLL_STATE_FLING: 77 | if (pauseOnFling) { 78 | taskHandler.pause(); 79 | } 80 | break; 81 | } 82 | if (externalListener != null) { 83 | externalListener.onScrollStateChanged(view, scrollState); 84 | } 85 | } 86 | 87 | /** 88 | * 滚动事件 89 | * @param view 列表控件 90 | * @param firstVisibleItem 当前显示的第一项的索引 91 | * @param visibleItemCount 当前显示项的总数 92 | * @param totalItemCount 可显示项总数 93 | */ 94 | @Override 95 | public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { 96 | if (externalListener != null) { 97 | externalListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount); 98 | } 99 | } 100 | 101 | } 102 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/bitmap/callback/BitmapLoadFrom.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.bitmap.callback; 2 | 3 | /** 4 | * 图片来源 5 | * 6 | *
 7 |  * Author: wyouflf
 8 |  * Date: 13-11-1
 9 |  * Time: 下午8:17
10 |  * 
11 | * 12 | * @author wyouflf 13 | */ 14 | public enum BitmapLoadFrom { 15 | /** 内存缓存 */ 16 | MEMORY_CACHE, 17 | /** 磁盘缓存 */ 18 | DISK_CACHE, 19 | /** 网络地址 */ 20 | URI 21 | } 22 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/bitmap/callback/BitmapSetter.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.bitmap.callback; 2 | 3 | import android.graphics.Bitmap; 4 | import android.graphics.drawable.Drawable; 5 | import android.view.View; 6 | 7 | /** 8 | * Bitmap位图显示器 9 | * 10 | *
11 |  * Author: wyouflf
12 |  * Date: 13-11-1
13 |  * Time: 下午11:05
14 |  * 
15 | * 16 | * @author wyouflf 17 | */ 18 | public interface BitmapSetter { 19 | 20 | /** 21 | * 显示图片到控件 22 | * @param container 控件{@link android.view.View} 23 | * @param bitmap 位图{@link android.graphics.Bitmap} 24 | */ 25 | void setBitmap(T container, Bitmap bitmap); 26 | 27 | /** 28 | * 显示图片到控件 29 | * @param container 控件{@link android.view.View} 30 | * @param drawable 图片{@link android.graphics.drawable.Drawable} 31 | */ 32 | void setDrawable(T container, Drawable drawable); 33 | 34 | /** 35 | * 获取图片 36 | * @param container 控件{@link android.view.View} 37 | * @return 图片{@link android.graphics.drawable.Drawable} 38 | */ 39 | Drawable getDrawable(T container); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/bitmap/callback/DefaultBitmapLoadCallBack.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.bitmap.callback; 17 | 18 | import android.graphics.Bitmap; 19 | import android.graphics.drawable.Drawable; 20 | import android.view.View; 21 | import android.view.animation.Animation; 22 | import com.lidroid.xutils.bitmap.BitmapDisplayConfig; 23 | 24 | import java.lang.reflect.Method; 25 | 26 | /** 27 | * 图片加载回调接口-默认实现 28 | * @version v0.1 king 2014-12-5 29 | * @param 控件类型{@link android.view.View} 30 | */ 31 | public class DefaultBitmapLoadCallBack extends BitmapLoadCallBack { 32 | 33 | @Override 34 | public void onLoadCompleted(T container, String uri, Bitmap bitmap, BitmapDisplayConfig config, BitmapLoadFrom from) { 35 | this.setBitmap(container, bitmap); 36 | Animation animation = config.getAnimation(); 37 | if (animation != null) { 38 | animationDisplay(container, animation); 39 | } 40 | } 41 | 42 | @Override 43 | public void onLoadFailed(T container, String uri, Drawable drawable) { 44 | this.setDrawable(container, drawable); 45 | } 46 | 47 | private void animationDisplay(T container, Animation animation) { 48 | try { 49 | Method cloneMethod = Animation.class.getDeclaredMethod("clone"); 50 | cloneMethod.setAccessible(true); 51 | container.startAnimation((Animation) cloneMethod.invoke(animation)); 52 | } catch (Throwable e) { 53 | container.startAnimation(animation); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/bitmap/core/BitmapSize.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.bitmap.core; 2 | 3 | /** 4 | * 尺寸大小 5 | * 6 | *
 7 |  * Author: wyouflf
 8 |  * Date: 13-11-7
 9 |  * Time: 下午1:20
10 |  * 
11 | * 12 | * @author wyouflf 13 | */ 14 | public class BitmapSize { 15 | 16 | public static final BitmapSize ZERO = new BitmapSize(0, 0); 17 | 18 | private final int width; 19 | private final int height; 20 | 21 | /** 22 | * 构造尺寸大小 23 | * @param width 宽度 24 | * @param height 高度 25 | */ 26 | public BitmapSize(int width, int height) { 27 | this.width = width; 28 | this.height = height; 29 | } 30 | 31 | /** 32 | * 缩小为原来尺寸的N分之一 33 | * @param sampleSize 缩放比例 34 | * @return 新的实例 35 | */ 36 | public BitmapSize scaleDown(int sampleSize) { 37 | return new BitmapSize(width / sampleSize, height / sampleSize); 38 | } 39 | 40 | /** 41 | * 放大为原来尺寸的N倍 42 | * @param scale 放大比例 43 | * @return 新的实例 44 | */ 45 | public BitmapSize scale(float scale) { 46 | return new BitmapSize((int) (width * scale), (int) (height * scale)); 47 | } 48 | 49 | /** 50 | * 获取宽度 51 | * @return 宽度值 52 | */ 53 | public int getWidth() { 54 | return width; 55 | } 56 | 57 | /** 58 | * 获取高度 59 | * @return 高度值 60 | */ 61 | public int getHeight() { 62 | return height; 63 | } 64 | 65 | @Override 66 | public String toString() { 67 | return "_" + width + "_" + height; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/bitmap/download/DefaultDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.bitmap.download; 17 | 18 | import com.lidroid.xutils.BitmapUtils; 19 | import com.lidroid.xutils.util.IOUtils; 20 | import com.lidroid.xutils.util.LogUtils; 21 | import com.lidroid.xutils.util.OtherUtils; 22 | 23 | import java.io.*; 24 | import java.net.URL; 25 | import java.net.URLConnection; 26 | 27 | /** 28 | * 默认的图片下载器 29 | */ 30 | public class DefaultDownloader extends Downloader { 31 | 32 | /** 33 | * 根据URL下载Bitmap位图 34 | * @param uri 本地文件完整路径,assets文件路径(assets/xxx),或者URL地址 35 | * @param outputStream 图片IO输出流 36 | * @param task 图片加载任务管理器 37 | * @return 过期时间的时间戳(如果下载失败,返回-1) 38 | */ 39 | @Override 40 | public long downloadToStream(String uri, OutputStream outputStream, final BitmapUtils.BitmapLoadTask task) { 41 | 42 | if (task == null || task.isCancelled() || task.getTargetContainer() == null) return -1; 43 | 44 | URLConnection urlConnection = null; 45 | BufferedInputStream bis = null; 46 | 47 | OtherUtils.trustAllHttpsURLConnection(); 48 | 49 | long result = -1; 50 | long fileLen = 0; 51 | long currCount = 0; 52 | try { 53 | if (uri.startsWith("/")) { 54 | FileInputStream fileInputStream = new FileInputStream(uri); 55 | fileLen = fileInputStream.available(); 56 | bis = new BufferedInputStream(fileInputStream); 57 | result = System.currentTimeMillis() + this.getDefaultExpiry(); 58 | } else if (uri.startsWith("assets/")) { 59 | InputStream inputStream = this.getContext().getAssets().open(uri.substring(7, uri.length())); 60 | fileLen = inputStream.available(); 61 | bis = new BufferedInputStream(inputStream); 62 | result = Long.MAX_VALUE; 63 | } else { 64 | final URL url = new URL(uri); 65 | urlConnection = url.openConnection(); 66 | urlConnection.setConnectTimeout(this.getDefaultConnectTimeout()); 67 | urlConnection.setReadTimeout(this.getDefaultReadTimeout()); 68 | bis = new BufferedInputStream(urlConnection.getInputStream()); 69 | result = urlConnection.getExpiration(); 70 | result = result < System.currentTimeMillis() ? System.currentTimeMillis() + this.getDefaultExpiry() : result; 71 | fileLen = urlConnection.getContentLength(); 72 | } 73 | 74 | if (task.isCancelled() || task.getTargetContainer() == null) return -1; 75 | 76 | byte[] buffer = new byte[4096]; 77 | int len = 0; 78 | BufferedOutputStream out = new BufferedOutputStream(outputStream); 79 | while ((len = bis.read(buffer)) != -1) { 80 | out.write(buffer, 0, len); 81 | currCount += len; 82 | if (task.isCancelled() || task.getTargetContainer() == null) return -1; 83 | task.updateProgress(fileLen, currCount); 84 | } 85 | out.flush(); 86 | } catch (Throwable e) { 87 | result = -1; 88 | LogUtils.e(e.getMessage(), e); 89 | } finally { 90 | IOUtils.closeQuietly(bis); 91 | } 92 | return result; 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/bitmap/download/Downloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.bitmap.download; 17 | 18 | import android.content.Context; 19 | import com.lidroid.xutils.BitmapUtils; 20 | 21 | import java.io.OutputStream; 22 | 23 | /** 24 | * 图片下载器 25 | */ 26 | public abstract class Downloader { 27 | 28 | /** 29 | * 根据URL下载Bitmap位图 30 | * @param uri 本地文件完整路径,assets文件路径(assets/xxx),或者URL地址 31 | * @param outputStream 图片IO输出流 32 | * @param task 图片加载任务管理器 33 | * @return 过期时间的时间戳(如果下载失败,返回-1) 34 | */ 35 | public abstract long downloadToStream(String uri, OutputStream outputStream, final BitmapUtils.BitmapLoadTask task); 36 | 37 | private Context context; 38 | private long defaultExpiry; 39 | private int defaultConnectTimeout; 40 | private int defaultReadTimeout; 41 | 42 | /** 43 | * 获取{@link android.content.Context} 44 | * @return {@link android.content.Context} 45 | */ 46 | public Context getContext() { 47 | return context; 48 | } 49 | 50 | /** 51 | * 设置{@link android.content.Context} 52 | * @param context android.content.Context 53 | */ 54 | public void setContext(Context context) { 55 | this.context = context; 56 | } 57 | 58 | /** 59 | * 设置默认过期时间 60 | * @param expiry 时间戳 61 | */ 62 | public void setDefaultExpiry(long expiry) { 63 | this.defaultExpiry = expiry; 64 | } 65 | 66 | /** 67 | * 获取默认过期时间 68 | * @return 时间戳 69 | */ 70 | public long getDefaultExpiry() { 71 | return this.defaultExpiry; 72 | } 73 | 74 | /** 75 | * 获取默认连接超时时长 76 | * @return 连接超时时长 77 | */ 78 | public int getDefaultConnectTimeout() { 79 | return defaultConnectTimeout; 80 | } 81 | 82 | /** 83 | * 设置默认连接超时时长 84 | * @param defaultConnectTimeout 连接超时时长 85 | */ 86 | public void setDefaultConnectTimeout(int defaultConnectTimeout) { 87 | this.defaultConnectTimeout = defaultConnectTimeout; 88 | } 89 | 90 | /** 91 | * 获取默认读取数据超时时长 92 | * @return 读取数据超时时长 93 | */ 94 | public int getDefaultReadTimeout() { 95 | return defaultReadTimeout; 96 | } 97 | 98 | /** 99 | * 设置默认读取数据超时时长 100 | * @param defaultReadTimeout 读取数据超时时长 101 | */ 102 | public void setDefaultReadTimeout(int defaultReadTimeout) { 103 | this.defaultReadTimeout = defaultReadTimeout; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/bitmap/factory/BitmapFactory.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.bitmap.factory; 2 | 3 | import android.graphics.Bitmap; 4 | 5 | /** 6 | * Bitmap图片处理工厂 7 | * 8 | *
 9 |  * Created with IntelliJ IDEA.
10 |  * User: wyouflf
11 |  * Date: 14-05-20
12 |  * Time: 下午4:26
13 |  * 
14 | * 15 | * @author wyouflf 16 | */ 17 | public interface BitmapFactory { 18 | 19 | /** 20 | * 克隆一个新的实例 21 | * @return 新的实例 22 | */ 23 | BitmapFactory cloneNew(); 24 | 25 | /** 26 | * 创建{@link android.graphics.Bitmap}图片 27 | * @param rawBitmap 图片{@link android.graphics.Bitmap} 28 | * @return 图片{@link android.graphics.Bitmap} 29 | */ 30 | Bitmap createBitmap(Bitmap rawBitmap); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/bitmap/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 图片加载模块 3 | */ 4 | package com.lidroid.xutils.bitmap; -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/cache/FileNameGenerator.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.cache; 2 | 3 | /** 4 | * 文件名生成器 5 | * 6 | *
 7 |  * Author: wyouflf
 8 |  * Date: 14-5-16
 9 |  * Time: 上午11:25
10 |  * 
11 | * 12 | * @author wyouflf 13 | */ 14 | public interface FileNameGenerator { 15 | 16 | /** 17 | * 根据KEY键值,生成文件名 18 | * @param key KEY键值 19 | * @return 文件名(不包含后缀) 20 | */ 21 | public String generate(String key); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/cache/KeyExpiryMap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.cache; 17 | 18 | import java.util.concurrent.ConcurrentHashMap; 19 | 20 | /** 21 | * 过期时间键值对集合 22 | * 23 | *
 24 |  * Author: wyouflf
 25 |  * Date: 13-8-1
 26 |  * Time: 上午11:25
 27 |  * 
28 | * 29 | * @author wyouflf 30 | */ 31 | public class KeyExpiryMap extends ConcurrentHashMap { 32 | private static final long serialVersionUID = 1L; 33 | 34 | private static final int DEFAULT_CONCURRENCY_LEVEL = 16; 35 | 36 | /** 37 | * 构造过期时间键值对集合 38 | * @param initialCapacity 初始容量 39 | * @param loadFactor 加载因子 40 | * @param concurrencyLevel 并发级别 41 | */ 42 | public KeyExpiryMap(int initialCapacity, float loadFactor, int concurrencyLevel) { 43 | super(initialCapacity, loadFactor, concurrencyLevel); 44 | } 45 | /** 46 | * 构造过期时间键值对集合 47 | * @param initialCapacity 48 | * @param loadFactor 49 | */ 50 | public KeyExpiryMap(int initialCapacity, float loadFactor) { 51 | super(initialCapacity, loadFactor, DEFAULT_CONCURRENCY_LEVEL); 52 | } 53 | /** 54 | * 构造过期时间键值对集合 55 | * @param initialCapacity 56 | */ 57 | public KeyExpiryMap(int initialCapacity) { 58 | super(initialCapacity); 59 | } 60 | /** 61 | * 构造过期时间键值对集合 62 | */ 63 | public KeyExpiryMap() { 64 | super(); 65 | } 66 | 67 | 68 | /** 69 | * 获取键值对应的过期时间 70 | * @param key 键值 71 | * @return 过期时间 72 | */ 73 | @Override 74 | public synchronized Long get(Object key) { 75 | if (this.containsKey(key)) { 76 | return super.get(key); 77 | } else { 78 | return null; 79 | } 80 | } 81 | 82 | /** 83 | * 添加过期时间键值对 84 | * @param key 键值 85 | * @param expiryTimestamp 过期时间 86 | * @return 过期时间 87 | */ 88 | @Override 89 | public synchronized Long put(K key, Long expiryTimestamp) { 90 | if (this.containsKey(key)) { 91 | this.remove(key); 92 | } 93 | return super.put(key, expiryTimestamp); 94 | } 95 | 96 | /** 97 | * 根据键值判断是否存在该记录 98 | * @param key 键值 99 | * @return 是否存在该记录 100 | */ 101 | @Override 102 | public synchronized boolean containsKey(Object key) { 103 | boolean result = false; 104 | Long expiryTimestamp = super.get(key); 105 | if (expiryTimestamp != null && System.currentTimeMillis() < expiryTimestamp) { 106 | result = true; 107 | } else { 108 | this.remove(key); 109 | } 110 | return result; 111 | } 112 | 113 | /** 114 | * 根据键值判断删除记录 115 | * @param key 键值 116 | * @return 该键值对应的过期时间 117 | */ 118 | @Override 119 | public synchronized Long remove(Object key) { 120 | return super.remove(key); 121 | } 122 | 123 | /** 124 | * 清空记录 125 | */ 126 | @Override 127 | public synchronized void clear() { 128 | super.clear(); 129 | } 130 | 131 | } 132 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/cache/MD5FileNameGenerator.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.cache; 2 | 3 | import java.security.MessageDigest; 4 | import java.security.NoSuchAlgorithmException; 5 | 6 | /** 7 | * MD5摘要文件名生成器 8 | * 9 | *
10 |  * Author: wyouflf
11 |  * Date: 14-5-16
12 |  * Time: 上午11:25
13 |  * 
14 | * 15 | * @author wyouflf 16 | */ 17 | public class MD5FileNameGenerator implements FileNameGenerator { 18 | 19 | /** 20 | * 构建MD5摘要文件名生成器 21 | */ 22 | public MD5FileNameGenerator() { 23 | } 24 | 25 | /** 26 | * 根据KEY键值,生成文件名 27 | * @param key KEY键值 28 | * @return 文件名(不包含后缀) 29 | */ 30 | public String generate(String key) { 31 | String cacheKey; 32 | try { 33 | final MessageDigest mDigest = MessageDigest.getInstance("MD5"); 34 | mDigest.update(key.getBytes()); 35 | cacheKey = bytesToHexString(mDigest.digest()); 36 | } catch (NoSuchAlgorithmException e) { 37 | cacheKey = String.valueOf(key.hashCode()); 38 | } 39 | return cacheKey; 40 | } 41 | 42 | private String bytesToHexString(byte[] bytes) { 43 | StringBuilder sb = new StringBuilder(); 44 | for (int i = 0; i < bytes.length; i++) { 45 | String hex = Integer.toHexString(0xFF & bytes[i]); 46 | if (hex.length() == 1) { 47 | sb.append('0'); 48 | } 49 | sb.append(hex); 50 | } 51 | return sb.toString(); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/cache/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 缓存管理模块 3 | */ 4 | package com.lidroid.xutils.cache; -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/annotation/Check.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.db.annotation; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | /** 24 | * 数据库表中列CHECK约束注解(限制值的范围) 25 | * 26 | *
27 |  * SQL CHECK列约束用于限制列中的值的范围
28 |  * 
29 | * 30 | *
31 |  * Author: wyouflf
32 |  * Date: 13-8-20
33 |  * Time: 上午9:44
34 |  * 
35 | * 36 | * @author wyouflf 37 | */ 38 | @Target(ElementType.FIELD) 39 | @Retention(RetentionPolicy.RUNTIME) 40 | public @interface Check { 41 | 42 | /** 43 | * 标识该列只允许特定的值 44 | * @return 该列允许的值 45 | */ 46 | String value(); 47 | 48 | } 49 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/annotation/Column.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.db.annotation; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | /** 24 | * 数据库表中列注解 25 | * 26 | *
27 |  * 列名不要使用SQL关键字、SQL保留字符、特殊字符、空格;
28 |  * 不能用于主键ID的注解;
29 |  * 如果没有该注解,则默认使用实体类属性名为该列列名(代码混淆可能导致列名不易分辨,建议添加该注解)
30 |  * 
31 | * 32 | * @see com.lidroid.xutils.db.annotation.Id 33 | * @see com.lidroid.xutils.db.annotation.NotNull 34 | */ 35 | @Target(ElementType.FIELD) 36 | @Retention(RetentionPolicy.RUNTIME) 37 | public @interface Column { 38 | 39 | /** 40 | * 数据库的列名 41 | * @return 列名(不要使用SQL关键字、SQL保留字符、特殊字符、空格) 42 | */ 43 | String column() default ""; 44 | 45 | /** 46 | * 列的数据默认值 47 | * @return 默认值 48 | */ 49 | String defaultValue() default ""; 50 | } 51 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/annotation/Finder.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.db.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * 数据库表的主表关联注解 10 | * 11 | *
12 |  * Author: wyouflf
13 |  * Date: 13-9-10
14 |  * Time: 下午6:44
15 |  * 
16 | * 17 | * @author wyouflf 18 | */ 19 | @Target(ElementType.FIELD) 20 | @Retention(RetentionPolicy.RUNTIME) 21 | public @interface Finder { 22 | 23 | /** 24 | * 主表的主键ID的列名(当前实体类对应的表) 25 | * @return 当前ID列名 26 | */ 27 | String valueColumn(); 28 | 29 | /** 30 | * 从表关联该主表的列名(从表生成的关联列名) 31 | * @return 从表关联该主表ID的列名(关联列的名称) 32 | */ 33 | String targetColumn(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/annotation/Foreign.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.db.annotation; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | /** 24 | * 数据库表的从表关联注解 25 | */ 26 | @Target(ElementType.FIELD) 27 | @Retention(RetentionPolicy.RUNTIME) 28 | public @interface Foreign { 29 | 30 | /** 31 | * 关联主表的列名(会在该实体类对应的表生成列) 32 | * @return 关联主表ID的列名(关联列的名称) 33 | */ 34 | String column() default ""; 35 | 36 | /** 37 | * 从表的主键ID的列名(当前实体类对应的表) 38 | * @return 当前ID列名 39 | */ 40 | String foreign(); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/annotation/Id.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.db.annotation; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | /** 24 | * 数据库表中主键ID的列注解 25 | * 26 | *
27 |  * 列名不要使用SQL关键字、SQL保留字符、特殊字符、空格;
28 |  * 若实体类属性名不是id、_id,必须添加该注解,否则报错;
29 |  * 默认主键ID为数值自动增长;
30 |  * 若主键非数值型(int ,Integer,long, Long),请添加注解{@link com.lidroid.xutils.db.annotation.NoAutoIncrement}
31 |  * 
32 | * 33 | * @see com.lidroid.xutils.db.annotation.Column 34 | * @see com.lidroid.xutils.db.annotation.NoAutoIncrement 35 | */ 36 | @Target(ElementType.FIELD) 37 | @Retention(RetentionPolicy.RUNTIME) 38 | public @interface Id { 39 | 40 | /** 41 | * 数据库的列名 42 | * @return 主键ID的列名(不要使用SQL关键字、SQL保留字符、特殊字符、空格) 43 | */ 44 | String column() default ""; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/annotation/NoAutoIncrement.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.db.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * 数据库表中主键ID不自动增长(默认自增) 10 | * 11 | *
12 |  * Author: wyouflf
13 |  * Date: 13-9-24
14 |  * Time: 上午9:33
15 |  * 
16 | * 17 | * @author wyouflf 18 | */ 19 | @Target(ElementType.FIELD) 20 | @Retention(RetentionPolicy.RUNTIME) 21 | public @interface NoAutoIncrement { 22 | } 23 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/annotation/NotNull.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.db.annotation; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | /** 24 | * 数据库表中列NOT NULL约束注解(非空约束) 25 | * 26 | *
27 |  * SQL NOT NULL列约束用于强制列不接受NULL值
28 |  * 
29 | * 30 | *
31 |  * Author: wyouflf
32 |  * Date: 13-8-20
33 |  * Time: 上午9:42
34 |  * 
35 | * 36 | * @author wyouflf 37 | */ 38 | @Target(ElementType.FIELD) 39 | @Retention(RetentionPolicy.RUNTIME) 40 | public @interface NotNull { 41 | 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/annotation/Table.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.db.annotation; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | /** 24 | * 数据库表的注解 25 | * 26 | *
27 |  * 表名不要使用SQL关键字、SQL保留字符、特殊字符、空格;
28 |  * 如果没有该注解,则默认使用实体类完整类名为该表的表名(代码混淆可能导致表名不易分辨,建议添加该注解)
29 |  * 
30 | * 31 | * @see com.lidroid.xutils.db.annotation.Id 32 | * @see com.lidroid.xutils.db.annotation.Column 33 | */ 34 | @Target(ElementType.TYPE) 35 | @Retention(RetentionPolicy.RUNTIME) 36 | public @interface Table { 37 | 38 | /** 39 | * 数据库的表名 40 | * @return 表名(不要使用SQL关键字、SQL保留字符、特殊字符、空格) 41 | */ 42 | String name() default ""; 43 | 44 | /** 45 | * 数据库表创建后执行的SQL语句 46 | * @return SQL语句 47 | */ 48 | String execAfterTableCreated() default ""; 49 | 50 | } -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/annotation/Transient.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.db.annotation; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | /** 24 | * 数据库操作忽略该属性,忽略标识注解 25 | * 26 | *
27 |  * 忽略后,数据库表中不会创建该列;
28 |  * 该列的数据不会被保存到数据库;
29 |  * 静态属性也不会存入数据库
30 |  * 
31 | * 32 | * @see com.lidroid.xutils.db.annotation.Id 33 | * @see com.lidroid.xutils.db.annotation.NotNull 34 | */ 35 | @Target(ElementType.FIELD) 36 | @Retention(RetentionPolicy.RUNTIME) 37 | public @interface Transient { 38 | } 39 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/annotation/Unique.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.db.annotation; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | /** 24 | * 数据库表中列UNIQUE约束注解(唯一性约束) 25 | * 26 | *
27 |  * SQL UNIQUE列约束用于唯一标识数据库表中的每条记录
28 |  * 
29 | * 30 | *
31 |  * Author: wyouflf
32 |  * Date: 13-8-20
33 |  * Time: 上午9:41
34 |  * 
35 | * 36 | * @author wyouflf 37 | */ 38 | @Target(ElementType.FIELD) 39 | @Retention(RetentionPolicy.RUNTIME) 40 | public @interface Unique { 41 | } 42 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/converter/BooleanColumnConverter.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.db.converter; 2 | 3 | import android.database.Cursor; 4 | import android.text.TextUtils; 5 | import com.lidroid.xutils.db.sqlite.ColumnDbType; 6 | 7 | /** 8 | * 数据库列的数据转换器(布尔型) 9 | * 10 | *
11 |  * Author: wyouflf
12 |  * Date: 13-11-4
13 |  * Time: 下午10:51
14 |  * 
15 | * 16 | * @author wyouflf 17 | */ 18 | public class BooleanColumnConverter implements ColumnConverter { 19 | 20 | @Override 21 | public Boolean getFieldValue(final Cursor cursor, int index) { 22 | return cursor.isNull(index) ? null : cursor.getInt(index) == 1; 23 | } 24 | 25 | @Override 26 | public Boolean getFieldValue(String fieldStringValue) { 27 | if (TextUtils.isEmpty(fieldStringValue)) return null; 28 | return fieldStringValue.length() == 1 ? "1".equals(fieldStringValue) : Boolean.valueOf(fieldStringValue); 29 | } 30 | 31 | @Override 32 | public Object fieldValue2ColumnValue(Boolean fieldValue) { 33 | if (fieldValue == null) return null; 34 | return fieldValue ? 1 : 0; 35 | } 36 | 37 | @Override 38 | public ColumnDbType getColumnDbType() { 39 | return ColumnDbType.INTEGER; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/converter/ByteArrayColumnConverter.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.db.converter; 2 | 3 | import android.database.Cursor; 4 | import com.lidroid.xutils.db.sqlite.ColumnDbType; 5 | 6 | /** 7 | * 数据库列的数据转换器(字节数组型) 8 | * 9 | *
10 |  * Author: wyouflf
11 |  * Date: 13-11-4
12 |  * Time: 下午10:51
13 |  * 
14 | * 15 | * @author wyouflf 16 | */ 17 | public class ByteArrayColumnConverter implements ColumnConverter { 18 | @Override 19 | public byte[] getFieldValue(final Cursor cursor, int index) { 20 | return cursor.isNull(index) ? null : cursor.getBlob(index); 21 | } 22 | 23 | @Override 24 | public byte[] getFieldValue(String fieldStringValue) { 25 | return null; 26 | } 27 | 28 | @Override 29 | public Object fieldValue2ColumnValue(byte[] fieldValue) { 30 | return fieldValue; 31 | } 32 | 33 | @Override 34 | public ColumnDbType getColumnDbType() { 35 | return ColumnDbType.BLOB; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/converter/ByteColumnConverter.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.db.converter; 2 | 3 | import android.database.Cursor; 4 | import android.text.TextUtils; 5 | import com.lidroid.xutils.db.sqlite.ColumnDbType; 6 | 7 | /** 8 | * 数据库列的数据转换器(字节型) 9 | * 10 | *
11 |  * Author: wyouflf
12 |  * Date: 13-11-4
13 |  * Time: 下午10:51
14 |  * 
15 | * 16 | * @author wyouflf 17 | */ 18 | public class ByteColumnConverter implements ColumnConverter { 19 | @Override 20 | public Byte getFieldValue(final Cursor cursor, int index) { 21 | return cursor.isNull(index) ? null : (byte) cursor.getInt(index); 22 | } 23 | 24 | @Override 25 | public Byte getFieldValue(String fieldStringValue) { 26 | if (TextUtils.isEmpty(fieldStringValue)) return null; 27 | return Byte.valueOf(fieldStringValue); 28 | } 29 | 30 | @Override 31 | public Object fieldValue2ColumnValue(Byte fieldValue) { 32 | return fieldValue; 33 | } 34 | 35 | @Override 36 | public ColumnDbType getColumnDbType() { 37 | return ColumnDbType.INTEGER; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/converter/CharColumnConverter.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.db.converter; 2 | 3 | import android.database.Cursor; 4 | import android.text.TextUtils; 5 | import com.lidroid.xutils.db.sqlite.ColumnDbType; 6 | 7 | /** 8 | * 数据库列的数据转换器(字符型) 9 | * 10 | *
11 |  * Author: wyouflf
12 |  * Date: 13-11-4
13 |  * Time: 下午10:51
14 |  * 
15 | * 16 | * @author wyouflf 17 | */ 18 | public class CharColumnConverter implements ColumnConverter { 19 | @Override 20 | public Character getFieldValue(final Cursor cursor, int index) { 21 | return cursor.isNull(index) ? null : (char) cursor.getInt(index); 22 | } 23 | 24 | @Override 25 | public Character getFieldValue(String fieldStringValue) { 26 | if (TextUtils.isEmpty(fieldStringValue)) return null; 27 | return fieldStringValue.charAt(0); 28 | } 29 | 30 | @Override 31 | public Object fieldValue2ColumnValue(Character fieldValue) { 32 | if (fieldValue == null) return null; 33 | return (int) fieldValue; 34 | } 35 | 36 | @Override 37 | public ColumnDbType getColumnDbType() { 38 | return ColumnDbType.INTEGER; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/converter/ColumnConverter.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.db.converter; 2 | 3 | import android.database.Cursor; 4 | import com.lidroid.xutils.db.sqlite.ColumnDbType; 5 | 6 | /** 7 | * 数据库列的数据转换器 8 | * 9 | *
10 |  * Author: wyouflf
11 |  * Date: 13-11-4
12 |  * Time: 下午8:57
13 |  * 
14 | * 15 | * @author wyouflf 16 | */ 17 | public interface ColumnConverter { 18 | 19 | /** 20 | * 从数据库查询游标{@link android.database.Cursor},获取字段的值 21 | * @param cursor 游标{@link android.database.Cursor} 22 | * @param index 索引 23 | * @return 字段的值 24 | */ 25 | T getFieldValue(final Cursor cursor, int index); 26 | 27 | /** 28 | * 从字段的字符串值,获取字段的值 29 | * @param fieldStringValue 字符串 30 | * @return 字段的值 31 | */ 32 | T getFieldValue(String fieldStringValue); 33 | 34 | /** 35 | * 将字段的值,转换为数据库中列的值 36 | * @param fieldValue 字段的值 37 | * @return 数据库中列的值 38 | */ 39 | Object fieldValue2ColumnValue(T fieldValue); 40 | 41 | /** 42 | * 数据库中列的类型 43 | * @return 列的类型{@link com.lidroid.xutils.db.sqlite.ColumnDbType} 44 | */ 45 | ColumnDbType getColumnDbType(); 46 | 47 | } 48 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/converter/DateColumnConverter.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.db.converter; 2 | 3 | import android.database.Cursor; 4 | import android.text.TextUtils; 5 | import com.lidroid.xutils.db.sqlite.ColumnDbType; 6 | 7 | import java.util.Date; 8 | 9 | /** 10 | * 数据库列的数据转换器(日期型) 11 | * 12 | *
13 |  * Author: wyouflf
14 |  * Date: 13-11-4
15 |  * Time: 下午10:51
16 |  * 
17 | * 18 | * @author wyouflf 19 | */ 20 | public class DateColumnConverter implements ColumnConverter { 21 | @Override 22 | public Date getFieldValue(final Cursor cursor, int index) { 23 | return cursor.isNull(index) ? null : new Date(cursor.getLong(index)); 24 | } 25 | 26 | @Override 27 | public Date getFieldValue(String fieldStringValue) { 28 | if (TextUtils.isEmpty(fieldStringValue)) return null; 29 | return new Date(Long.valueOf(fieldStringValue)); 30 | } 31 | 32 | @Override 33 | public Object fieldValue2ColumnValue(Date fieldValue) { 34 | if (fieldValue == null) return null; 35 | return fieldValue.getTime(); 36 | } 37 | 38 | @Override 39 | public ColumnDbType getColumnDbType() { 40 | return ColumnDbType.INTEGER; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/converter/DoubleColumnConverter.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.db.converter; 2 | 3 | import android.database.Cursor; 4 | import android.text.TextUtils; 5 | import com.lidroid.xutils.db.sqlite.ColumnDbType; 6 | 7 | /** 8 | * 数据库列的数据转换器(双精度浮点型) 9 | * 10 | *
11 |  * Author: wyouflf
12 |  * Date: 13-11-4
13 |  * Time: 下午10:51
14 |  * 
15 | * 16 | * @author wyouflf 17 | */ 18 | public class DoubleColumnConverter implements ColumnConverter { 19 | @Override 20 | public Double getFieldValue(final Cursor cursor, int index) { 21 | return cursor.isNull(index) ? null : cursor.getDouble(index); 22 | } 23 | 24 | @Override 25 | public Double getFieldValue(String fieldStringValue) { 26 | if (TextUtils.isEmpty(fieldStringValue)) return null; 27 | return Double.valueOf(fieldStringValue); 28 | } 29 | 30 | @Override 31 | public Object fieldValue2ColumnValue(Double fieldValue) { 32 | return fieldValue; 33 | } 34 | 35 | @Override 36 | public ColumnDbType getColumnDbType() { 37 | return ColumnDbType.REAL; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/converter/FloatColumnConverter.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.db.converter; 2 | 3 | import android.database.Cursor; 4 | import android.text.TextUtils; 5 | import com.lidroid.xutils.db.sqlite.ColumnDbType; 6 | 7 | /** 8 | * 数据库列的数据转换器(单精度浮点型) 9 | * 10 | *
11 |  * Author: wyouflf
12 |  * Date: 13-11-4
13 |  * Time: 下午10:51
14 |  * 
15 | * 16 | * @author wyouflf 17 | */ 18 | public class FloatColumnConverter implements ColumnConverter { 19 | @Override 20 | public Float getFieldValue(final Cursor cursor, int index) { 21 | return cursor.isNull(index) ? null : cursor.getFloat(index); 22 | } 23 | 24 | @Override 25 | public Float getFieldValue(String fieldStringValue) { 26 | if (TextUtils.isEmpty(fieldStringValue)) return null; 27 | return Float.valueOf(fieldStringValue); 28 | } 29 | 30 | @Override 31 | public Object fieldValue2ColumnValue(Float fieldValue) { 32 | return fieldValue; 33 | } 34 | 35 | @Override 36 | public ColumnDbType getColumnDbType() { 37 | return ColumnDbType.REAL; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/converter/IntegerColumnConverter.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.db.converter; 2 | 3 | import android.database.Cursor; 4 | import android.text.TextUtils; 5 | import com.lidroid.xutils.db.sqlite.ColumnDbType; 6 | 7 | /** 8 | * 数据库列的数据转换器(整型) 9 | * 10 | *
11 |  * Author: wyouflf
12 |  * Date: 13-11-4
13 |  * Time: 下午10:51
14 |  * 
15 | * 16 | * @author wyouflf 17 | */ 18 | public class IntegerColumnConverter implements ColumnConverter { 19 | @Override 20 | public Integer getFieldValue(final Cursor cursor, int index) { 21 | return cursor.isNull(index) ? null : cursor.getInt(index); 22 | } 23 | 24 | @Override 25 | public Integer getFieldValue(String fieldStringValue) { 26 | if (TextUtils.isEmpty(fieldStringValue)) return null; 27 | return Integer.valueOf(fieldStringValue); 28 | } 29 | 30 | @Override 31 | public Object fieldValue2ColumnValue(Integer fieldValue) { 32 | return fieldValue; 33 | } 34 | 35 | @Override 36 | public ColumnDbType getColumnDbType() { 37 | return ColumnDbType.INTEGER; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/converter/LongColumnConverter.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.db.converter; 2 | 3 | import android.database.Cursor; 4 | import android.text.TextUtils; 5 | import com.lidroid.xutils.db.sqlite.ColumnDbType; 6 | 7 | /** 8 | * 数据库列的数据转换器(长整型) 9 | * 10 | *
11 |  * Author: wyouflf
12 |  * Date: 13-11-4
13 |  * Time: 下午10:51
14 |  * 
15 | * 16 | * @author wyouflf 17 | */ 18 | public class LongColumnConverter implements ColumnConverter { 19 | @Override 20 | public Long getFieldValue(final Cursor cursor, int index) { 21 | return cursor.isNull(index) ? null : cursor.getLong(index); 22 | } 23 | 24 | @Override 25 | public Long getFieldValue(String fieldStringValue) { 26 | if (TextUtils.isEmpty(fieldStringValue)) return null; 27 | return Long.valueOf(fieldStringValue); 28 | } 29 | 30 | @Override 31 | public Object fieldValue2ColumnValue(Long fieldValue) { 32 | return fieldValue; 33 | } 34 | 35 | @Override 36 | public ColumnDbType getColumnDbType() { 37 | return ColumnDbType.INTEGER; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/converter/ShortColumnConverter.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.db.converter; 2 | 3 | import android.database.Cursor; 4 | import android.text.TextUtils; 5 | import com.lidroid.xutils.db.sqlite.ColumnDbType; 6 | 7 | /** 8 | * 数据库列的数据转换器(短整型) 9 | * 10 | *
11 |  * Author: wyouflf
12 |  * Date: 13-11-4
13 |  * Time: 下午10:51
14 |  * 
15 | * 16 | * @author wyouflf 17 | */ 18 | public class ShortColumnConverter implements ColumnConverter { 19 | @Override 20 | public Short getFieldValue(final Cursor cursor, int index) { 21 | return cursor.isNull(index) ? null : cursor.getShort(index); 22 | } 23 | 24 | @Override 25 | public Short getFieldValue(String fieldStringValue) { 26 | if (TextUtils.isEmpty(fieldStringValue)) return null; 27 | return Short.valueOf(fieldStringValue); 28 | } 29 | 30 | @Override 31 | public Object fieldValue2ColumnValue(Short fieldValue) { 32 | return fieldValue; 33 | } 34 | 35 | @Override 36 | public ColumnDbType getColumnDbType() { 37 | return ColumnDbType.INTEGER; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/converter/SqlDateColumnConverter.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.db.converter; 2 | 3 | import android.database.Cursor; 4 | import android.text.TextUtils; 5 | import com.lidroid.xutils.db.sqlite.ColumnDbType; 6 | 7 | /** 8 | * 数据库列的数据转换器(SQL日期型) 9 | * 10 | *
11 |  * Author: wyouflf
12 |  * Date: 13-11-4
13 |  * Time: 下午10:51
14 |  * 
15 | * 16 | * @author wyouflf 17 | */ 18 | public class SqlDateColumnConverter implements ColumnConverter { 19 | @Override 20 | public java.sql.Date getFieldValue(final Cursor cursor, int index) { 21 | return cursor.isNull(index) ? null : new java.sql.Date(cursor.getLong(index)); 22 | } 23 | 24 | @Override 25 | public java.sql.Date getFieldValue(String fieldStringValue) { 26 | if (TextUtils.isEmpty(fieldStringValue)) return null; 27 | return new java.sql.Date(Long.valueOf(fieldStringValue)); 28 | } 29 | 30 | @Override 31 | public Object fieldValue2ColumnValue(java.sql.Date fieldValue) { 32 | if (fieldValue == null) return null; 33 | return fieldValue.getTime(); 34 | } 35 | 36 | @Override 37 | public ColumnDbType getColumnDbType() { 38 | return ColumnDbType.INTEGER; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/converter/StringColumnConverter.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.db.converter; 2 | 3 | import android.database.Cursor; 4 | import com.lidroid.xutils.db.sqlite.ColumnDbType; 5 | 6 | /** 7 | * 数据库列的数据转换器(字符串型) 8 | * 9 | *
10 |  * Author: wyouflf
11 |  * Date: 13-11-4
12 |  * Time: 下午10:51
13 |  * 
14 | * 15 | * @author wyouflf 16 | */ 17 | public class StringColumnConverter implements ColumnConverter { 18 | @Override 19 | public String getFieldValue(final Cursor cursor, int index) { 20 | return cursor.isNull(index) ? null : cursor.getString(index); 21 | } 22 | 23 | @Override 24 | public String getFieldValue(String fieldStringValue) { 25 | return fieldStringValue; 26 | } 27 | 28 | @Override 29 | public Object fieldValue2ColumnValue(String fieldValue) { 30 | return fieldValue; 31 | } 32 | 33 | @Override 34 | public ColumnDbType getColumnDbType() { 35 | return ColumnDbType.TEXT; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * SQLite管理模块 3 | */ 4 | package com.lidroid.xutils.db; -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/sqlite/ColumnDbType.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.db.sqlite; 2 | 3 | /** 4 | * 数据库中列的类型 5 | * 6 | *
 7 |  * Created by wyouflf on 14-2-20.
 8 |  * 
9 | * 10 | * @author wyouflf 11 | */ 12 | public enum ColumnDbType { 13 | 14 | /** 整形型 */ 15 | INTEGER("INTEGER"), 16 | /** 浮点型 */ 17 | REAL("REAL"), 18 | /** 文本型 */ 19 | TEXT("TEXT"), 20 | /** 数据块型 */ 21 | BLOB("BLOB"); 22 | 23 | private String value; 24 | 25 | ColumnDbType(String value) { 26 | this.value = value; 27 | } 28 | 29 | @Override 30 | public String toString() { 31 | return value; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/sqlite/FinderLazyLoader.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.db.sqlite; 2 | 3 | import com.lidroid.xutils.db.table.ColumnUtils; 4 | import com.lidroid.xutils.db.table.Finder; 5 | import com.lidroid.xutils.db.table.Table; 6 | import com.lidroid.xutils.exception.DbException; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * 数据库表的主表关联数据集懒加载 12 | * 13 | *
14 |  * 主表关联的从表数据,并不会立即加载;
15 |  * 调用getFirstFromDb()或getAllFromDb()方法,会立即执行数据库查询,此时才真正获取到数据
16 |  * 
17 | * 18 | *
19 |  * Author: wyouflf
20 |  * Date: 13-9-10
21 |  * Time: 下午10:50
22 |  * 
23 | * 24 | * @param 关联从表对应的实体类类型 25 | * 26 | * @author wyouflf 27 | */ 28 | public class FinderLazyLoader { 29 | private final Finder finderColumn; 30 | private final Object finderValue; 31 | 32 | /** 33 | * 构造主表关联数据集懒加载 34 | * @param finderColumn 主表关联列的描述 {@link com.lidroid.xutils.db.table.Finder} 35 | * @param value 数据库列值 36 | */ 37 | public FinderLazyLoader(Finder finderColumn, Object value) { 38 | this.finderColumn = finderColumn; 39 | this.finderValue = ColumnUtils.convert2DbColumnValueIfNeeded(value); 40 | } 41 | 42 | /** 43 | * 获取关联的所有从表数据 44 | * 45 | *
46 |      * 会立即执行数据库查询,此时真正获取到数据
47 |      * 
48 | * 49 | * @return 从表数据集{@link java.util.List} 50 | * @throws DbException 数据库操作异常 51 | */ 52 | public List getAllFromDb() throws DbException { 53 | List entities = null; 54 | Table table = finderColumn.getTable(); 55 | if (table != null) { 56 | entities = table.db.findAll( 57 | Selector.from(finderColumn.getTargetEntityType()). 58 | where(finderColumn.getTargetColumnName(), "=", finderValue) 59 | ); 60 | } 61 | return entities; 62 | } 63 | 64 | /** 65 | * 获取关联的一条从表数据 66 | * 67 | *
68 |      * 会立即执行数据库查询,此时真正获取到数据
69 |      * 
70 | * 71 | * @return 一条从表数据 72 | * @throws DbException 数据库操作异常 73 | */ 74 | public T getFirstFromDb() throws DbException { 75 | T entity = null; 76 | Table table = finderColumn.getTable(); 77 | if (table != null) { 78 | entity = table.db.findFirst( 79 | Selector.from(finderColumn.getTargetEntityType()). 80 | where(finderColumn.getTargetColumnName(), "=", finderValue) 81 | ); 82 | } 83 | return entity; 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/sqlite/ForeignLazyLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.db.sqlite; 17 | 18 | import com.lidroid.xutils.db.table.ColumnUtils; 19 | import com.lidroid.xutils.db.table.Foreign; 20 | import com.lidroid.xutils.db.table.Table; 21 | import com.lidroid.xutils.exception.DbException; 22 | 23 | import java.util.List; 24 | 25 | /** 26 | * 数据库表的从表关联数据集懒加载 27 | * 28 | *
 29 |  * 从表关联的主表数据,并不会立即加载;
 30 |  * 调用getFirstFromDb()或getAllFromDb()方法,会立即执行数据库查询,此时才真正获取到数据
 31 |  * 
32 | * 33 | * @param 所属主表的实体类类型 34 | */ 35 | public class ForeignLazyLoader { 36 | private final Foreign foreignColumn; 37 | private Object columnValue; 38 | 39 | /** 40 | * 构造从表关联数据集懒加载 41 | * @param foreignColumn 从表关联列的描述 {@link com.lidroid.xutils.db.table.Foreign} 42 | * @param value 关联列的值(一般为主表ID值) 43 | */ 44 | public ForeignLazyLoader(Foreign foreignColumn, Object value) { 45 | this.foreignColumn = foreignColumn; 46 | this.columnValue = ColumnUtils.convert2DbColumnValueIfNeeded(value); 47 | } 48 | 49 | /** 50 | * 获取关联的所有主表数据 51 | * 52 | *
 53 |      * 会立即执行数据库查询,此时真正获取到数据
 54 |      * 
55 | * 56 | * @return 主表数据集{@link java.util.List} 57 | * @throws DbException 数据库操作异常 58 | */ 59 | public List getAllFromDb() throws DbException { 60 | List entities = null; 61 | Table table = foreignColumn.getTable(); 62 | if (table != null) { 63 | entities = table.db.findAll( 64 | Selector.from(foreignColumn.getForeignEntityType()). 65 | where(foreignColumn.getForeignColumnName(), "=", columnValue) 66 | ); 67 | } 68 | return entities; 69 | } 70 | 71 | /** 72 | * 获取关联的一条主表数据 73 | * 74 | *
 75 |      * 会立即执行数据库查询,此时真正获取到数据
 76 |      * 
77 | * 78 | * @return 一条主表数据 79 | * @throws DbException 数据库操作异常 80 | */ 81 | public T getFirstFromDb() throws DbException { 82 | T entity = null; 83 | Table table = foreignColumn.getTable(); 84 | if (table != null) { 85 | entity = table.db.findFirst( 86 | Selector.from(foreignColumn.getForeignEntityType()). 87 | where(foreignColumn.getForeignColumnName(), "=", columnValue) 88 | ); 89 | } 90 | return entity; 91 | } 92 | 93 | /** 94 | * 设置数据库关联列的值 95 | * @param value 关联列的值(一般为主表ID值) 96 | */ 97 | public void setColumnValue(Object value) { 98 | this.columnValue = ColumnUtils.convert2DbColumnValueIfNeeded(value); 99 | } 100 | 101 | /** 102 | * 获取数据库关联列的值 103 | * @return 关联列的值(一般为主表ID值) 104 | */ 105 | public Object getColumnValue() { 106 | return columnValue; 107 | } 108 | 109 | } 110 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/sqlite/SqlInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.db.sqlite; 17 | 18 | import com.lidroid.xutils.db.table.ColumnUtils; 19 | 20 | import java.util.LinkedList; 21 | 22 | /** 23 | * SQL语句描述 24 | */ 25 | public class SqlInfo { 26 | 27 | private String sql; 28 | private LinkedList bindArgs; 29 | 30 | /** 31 | * 构造SQL语句描述 32 | */ 33 | public SqlInfo() { 34 | } 35 | /** 36 | * 构造SQL语句描述 37 | * @param sql SQL语句 38 | */ 39 | public SqlInfo(String sql) { 40 | this.sql = sql; 41 | } 42 | /** 43 | * 构造SQL语句描述 44 | * @param sql SQL语句 45 | * @param bindArgs SQL参数的值 46 | */ 47 | public SqlInfo(String sql, Object... bindArgs) { 48 | this.sql = sql; 49 | addBindArgs(bindArgs); 50 | } 51 | 52 | /** 53 | * 获取SQL语句 54 | * @return SQL语句 55 | */ 56 | public String getSql() { 57 | return sql; 58 | } 59 | 60 | /** 61 | * 设置SQL语句 62 | * @param sql SQL语句 63 | */ 64 | public void setSql(String sql) { 65 | this.sql = sql; 66 | } 67 | 68 | /** 69 | * 获取SQL参数的值 70 | * @return SQL参数的值{@link java.util.LinkedList}(可能为null) 71 | */ 72 | public LinkedList getBindArgs() { 73 | return bindArgs; 74 | } 75 | 76 | /** 77 | * 获取SQL参数的值 78 | * @return SQL参数的值(可能为null) 79 | */ 80 | public Object[] getBindArgsAsArray() { 81 | if (bindArgs != null) { 82 | return bindArgs.toArray(); 83 | } 84 | return null; 85 | } 86 | 87 | /** 88 | * 获取SQL参数的值 89 | * @return SQL参数的值(可能为null) 90 | */ 91 | public String[] getBindArgsAsStrArray() { 92 | if (bindArgs != null) { 93 | String[] strings = new String[bindArgs.size()]; 94 | for (int i = 0; i < bindArgs.size(); i++) { 95 | Object value = bindArgs.get(i); 96 | strings[i] = value == null ? null : value.toString(); 97 | } 98 | return strings; 99 | } 100 | return null; 101 | } 102 | 103 | /** 104 | * 添加SQL参数的值(自动转换为数据库可操作的数据) 105 | * @param arg SQL参数的值(实体类属性值) 106 | */ 107 | public void addBindArg(Object arg) { 108 | if (bindArgs == null) { 109 | bindArgs = new LinkedList(); 110 | } 111 | 112 | bindArgs.add(ColumnUtils.convert2DbColumnValueIfNeeded(arg)); 113 | } 114 | 115 | /** 116 | * 添加SQL参数的值(无需再处理) 117 | * @param arg SQL参数的值(数据库可操作的数据) 118 | */ 119 | /* package */ void addBindArgWithoutConverter(Object arg) { 120 | if (bindArgs == null) { 121 | bindArgs = new LinkedList(); 122 | } 123 | 124 | bindArgs.add(arg); 125 | } 126 | 127 | /** 128 | * 添加SQL参数的值(自动转换为数据库可操作的数据) 129 | * @param bindArgs SQL参数的值(实体类属性值) 130 | */ 131 | public void addBindArgs(Object... bindArgs) { 132 | if (bindArgs != null) { 133 | for (Object arg : bindArgs) { 134 | addBindArg(arg); 135 | } 136 | } 137 | } 138 | 139 | } 140 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/table/Finder.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.db.table; 2 | 3 | import android.database.Cursor; 4 | import com.lidroid.xutils.db.sqlite.ColumnDbType; 5 | import com.lidroid.xutils.db.sqlite.FinderLazyLoader; 6 | import com.lidroid.xutils.exception.DbException; 7 | import com.lidroid.xutils.util.LogUtils; 8 | 9 | import java.lang.reflect.Field; 10 | import java.util.List; 11 | 12 | /** 13 | * 数据库表的主表关联列的描述 14 | * 15 | *
 16 |  * Author: wyouflf
 17 |  * Date: 13-9-10
 18 |  * Time: 下午7:43
 19 |  * 
20 | * 21 | * @author wyouflf 22 | */ 23 | public class Finder extends Column { 24 | 25 | private final String valueColumnName; 26 | private final String targetColumnName; 27 | 28 | /* package */ Finder(Class entityType, Field field) { 29 | super(entityType, field); 30 | 31 | com.lidroid.xutils.db.annotation.Finder finder = 32 | field.getAnnotation(com.lidroid.xutils.db.annotation.Finder.class); 33 | this.valueColumnName = finder.valueColumn(); 34 | this.targetColumnName = finder.targetColumn(); 35 | } 36 | 37 | /** 38 | * 获取该关联列对应的从表实体类类型 39 | * @return 实体类类型{@link java.lang.Class} 40 | */ 41 | public Class getTargetEntityType() { 42 | return ColumnUtils.getFinderTargetEntityType(this); 43 | } 44 | 45 | /** 46 | * 获取该关联列对应的从表列名 47 | * @return 关联列的从表列名 48 | */ 49 | public String getTargetColumnName() { 50 | return targetColumnName; 51 | } 52 | 53 | @Override 54 | public void setValue2Entity(Object entity, Cursor cursor, int index) { 55 | Object value = null; 56 | Class columnType = columnField.getType(); 57 | Object finderValue = TableUtils.getColumnOrId(entity.getClass(), this.valueColumnName).getColumnValue(entity); 58 | if (columnType.equals(FinderLazyLoader.class)) { 59 | value = new FinderLazyLoader(this, finderValue); 60 | } else if (columnType.equals(List.class)) { 61 | try { 62 | value = new FinderLazyLoader(this, finderValue).getAllFromDb(); 63 | } catch (DbException e) { 64 | LogUtils.e(e.getMessage(), e); 65 | } 66 | } else { 67 | try { 68 | value = new FinderLazyLoader(this, finderValue).getFirstFromDb(); 69 | } catch (DbException e) { 70 | LogUtils.e(e.getMessage(), e); 71 | } 72 | } 73 | 74 | if (setMethod != null) { 75 | try { 76 | setMethod.invoke(entity, value); 77 | } catch (Throwable e) { 78 | LogUtils.e(e.getMessage(), e); 79 | } 80 | } else { 81 | try { 82 | this.columnField.setAccessible(true); 83 | this.columnField.set(entity, value); 84 | } catch (Throwable e) { 85 | LogUtils.e(e.getMessage(), e); 86 | } 87 | } 88 | } 89 | 90 | @Override 91 | public Object getColumnValue(Object entity) { 92 | return null; 93 | } 94 | 95 | @Override 96 | public Object getDefaultValue() { 97 | return null; 98 | } 99 | 100 | /** 101 | * 获取数据库列的默认值(永远返回null) 102 | * @return null(永远返回null) 103 | */ 104 | @Override 105 | public ColumnDbType getColumnDbType() { 106 | return ColumnDbType.TEXT; 107 | } 108 | 109 | } 110 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/table/Id.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.db.table; 17 | 18 | import com.lidroid.xutils.db.annotation.NoAutoIncrement; 19 | import com.lidroid.xutils.util.LogUtils; 20 | 21 | import java.lang.reflect.Field; 22 | import java.util.HashSet; 23 | 24 | /** 25 | * 数据库表中主键ID的描述 26 | */ 27 | public class Id extends Column { 28 | 29 | private String columnFieldClassName; 30 | private boolean isAutoIncrementChecked = false; 31 | private boolean isAutoIncrement = false; 32 | 33 | /* package */ Id(Class entityType, Field field) { 34 | super(entityType, field); 35 | columnFieldClassName = columnField.getType().getName(); 36 | } 37 | 38 | /** 39 | * 判断是否自动增长 40 | * @return 是否自动增长 41 | */ 42 | public boolean isAutoIncrement() { 43 | if (!isAutoIncrementChecked) { 44 | isAutoIncrementChecked = true; 45 | isAutoIncrement = columnField.getAnnotation(NoAutoIncrement.class) == null 46 | && AUTO_INCREMENT_TYPES.contains(columnFieldClassName); 47 | } 48 | return isAutoIncrement; 49 | } 50 | 51 | /** 52 | * 设置自动增长的主键ID值 53 | * @param entity 实体类实例 54 | * @param value 主键ID值 55 | */ 56 | public void setAutoIncrementId(Object entity, long value) { 57 | Object idValue = value; 58 | if (INTEGER_TYPES.contains(columnFieldClassName)) { 59 | idValue = (int) value; 60 | } 61 | 62 | if (setMethod != null) { 63 | try { 64 | setMethod.invoke(entity, idValue); 65 | } catch (Throwable e) { 66 | LogUtils.e(e.getMessage(), e); 67 | } 68 | } else { 69 | try { 70 | this.columnField.setAccessible(true); 71 | this.columnField.set(entity, idValue); 72 | } catch (Throwable e) { 73 | LogUtils.e(e.getMessage(), e); 74 | } 75 | } 76 | } 77 | 78 | @Override 79 | public Object getColumnValue(Object entity) { 80 | Object idValue = super.getColumnValue(entity); 81 | if (idValue != null) { 82 | if (this.isAutoIncrement() && (idValue.equals(0) || idValue.equals(0L))) { 83 | return null; 84 | } else { 85 | return idValue; 86 | } 87 | } 88 | return null; 89 | } 90 | 91 | private static final HashSet INTEGER_TYPES = new HashSet(2); 92 | private static final HashSet AUTO_INCREMENT_TYPES = new HashSet(4); 93 | 94 | static { 95 | INTEGER_TYPES.add(int.class.getName()); 96 | INTEGER_TYPES.add(Integer.class.getName()); 97 | 98 | AUTO_INCREMENT_TYPES.addAll(INTEGER_TYPES); 99 | AUTO_INCREMENT_TYPES.add(long.class.getName()); 100 | AUTO_INCREMENT_TYPES.add(Long.class.getName()); 101 | } 102 | 103 | } 104 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/db/table/KeyValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.db.table; 17 | 18 | /** 19 | * 键值对模型 20 | */ 21 | public class KeyValue { 22 | /** 23 | * 键 24 | */ 25 | public final String key; 26 | /** 27 | * 值 28 | */ 29 | public final Object value; 30 | 31 | /** 32 | * 构造键值对 33 | * @param key 键 34 | * @param value 值 35 | */ 36 | public KeyValue(String key, Object value) { 37 | this.key = key; 38 | this.value = value; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/exception/BaseException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.exception; 17 | 18 | /** 19 | * 框架内抛出异常的基类 20 | * 21 | *
22 |  * Author: wyouflf
23 |  * Date: 13-7-24
24 |  * Time: 下午3:00
25 |  * 
26 | * 27 | * @author wyouflf 28 | */ 29 | public class BaseException extends Exception { 30 | private static final long serialVersionUID = 1L; 31 | 32 | /** 33 | * 构造异常实例 34 | */ 35 | public BaseException() { 36 | } 37 | /** 38 | * 构造异常实例 39 | * @param detailMessage 异常信息描述 40 | */ 41 | public BaseException(String detailMessage) { 42 | super(detailMessage); 43 | } 44 | /** 45 | * 构造异常实例 46 | * @param detailMessage 异常信息描述 47 | * @param throwable 异常内容(包含栈堆跟踪) 48 | */ 49 | public BaseException(String detailMessage, Throwable throwable) { 50 | super(detailMessage, throwable); 51 | } 52 | /** 53 | * 构造异常实例 54 | * @param throwable 异常内容(包含栈堆跟踪) 55 | */ 56 | public BaseException(Throwable throwable) { 57 | super(throwable); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/exception/DbException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.exception; 17 | 18 | /** 19 | * 数据库操作异常 20 | */ 21 | public class DbException extends BaseException { 22 | private static final long serialVersionUID = 1L; 23 | 24 | /** 25 | * 构造数据库操作异常 26 | */ 27 | public DbException() { 28 | } 29 | /** 30 | * 构造数据库操作异常 31 | * @param detailMessage 异常信息描述 32 | */ 33 | public DbException(String detailMessage) { 34 | super(detailMessage); 35 | } 36 | /** 37 | * 构造数据库操作异常 38 | * @param detailMessage 异常信息描述 39 | * @param throwable 异常内容(包含栈堆跟踪) 40 | */ 41 | public DbException(String detailMessage, Throwable throwable) { 42 | super(detailMessage, throwable); 43 | } 44 | /** 45 | * 构造数据库操作异常 46 | * @param throwable 异常内容(包含栈堆跟踪) 47 | */ 48 | public DbException(Throwable throwable) { 49 | super(throwable); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/exception/HttpException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.exception; 17 | 18 | /** 19 | * 网络请求异常 20 | */ 21 | public class HttpException extends BaseException { 22 | private static final long serialVersionUID = 1L; 23 | 24 | private int exceptionCode; 25 | 26 | /** 27 | * 构造网络请求异常 28 | */ 29 | public HttpException() { 30 | } 31 | /** 32 | * 构造网络请求异常 33 | * @param detailMessage 异常信息描述 34 | */ 35 | public HttpException(String detailMessage) { 36 | super(detailMessage); 37 | } 38 | /** 39 | * 构造网络请求异常 40 | * @param detailMessage 异常信息描述 41 | * @param throwable 异常内容(包含栈堆跟踪) 42 | */ 43 | public HttpException(String detailMessage, Throwable throwable) { 44 | super(detailMessage, throwable); 45 | } 46 | /** 47 | * 构造网络请求异常 48 | * @param throwable 异常内容(包含栈堆跟踪) 49 | */ 50 | public HttpException(Throwable throwable) { 51 | super(throwable); 52 | } 53 | 54 | 55 | /** 56 | * 构造网络请求异常 57 | * @param exceptionCode HTTP响应状态码(0:表示请求出错,或没有响应) 58 | */ 59 | public HttpException(int exceptionCode) { 60 | this.exceptionCode = exceptionCode; 61 | } 62 | 63 | /** 64 | * 构造网络请求异常 65 | * @param exceptionCode HTTP响应状态码(0:表示请求出错,或没有响应) 66 | * @param detailMessage 异常信息描述 67 | */ 68 | public HttpException(int exceptionCode, String detailMessage) { 69 | super(detailMessage); 70 | this.exceptionCode = exceptionCode; 71 | } 72 | /** 73 | * 构造网络请求异常 74 | * @param exceptionCode HTTP响应状态码(0:表示请求出错,或没有响应) 75 | * @param detailMessage 异常信息描述 76 | * @param throwable 异常内容(包含栈堆跟踪) 77 | */ 78 | public HttpException(int exceptionCode, String detailMessage, Throwable throwable) { 79 | super(detailMessage, throwable); 80 | this.exceptionCode = exceptionCode; 81 | } 82 | /** 83 | * 构造网络请求异常 84 | * @param exceptionCode HTTP响应状态码(0:表示请求出错,或没有响应) 85 | * @param throwable 异常内容(包含栈堆跟踪) 86 | */ 87 | public HttpException(int exceptionCode, Throwable throwable) { 88 | super(throwable); 89 | this.exceptionCode = exceptionCode; 90 | } 91 | 92 | /** 93 | * 获取异常信息代码 94 | * @return HTTP响应状态码(0:表示请求出错,或没有响应) 95 | */ 96 | public int getExceptionCode() { 97 | return exceptionCode; 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/exception/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 框架内抛出异常的定义 3 | */ 4 | package com.lidroid.xutils.exception; -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/http/callback/DefaultHttpRedirectHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.http.callback; 17 | 18 | import org.apache.http.HttpResponse; 19 | import org.apache.http.client.methods.HttpGet; 20 | import org.apache.http.client.methods.HttpRequestBase; 21 | 22 | /** 23 | * HTTP重定向处理器的默认实现 24 | * 25 | *
26 |  * Created with IntelliJ IDEA.
27 |  * User: wyouflf
28 |  * Date: 13-7-17
29 |  * Time: 上午10:41
30 |  * 
31 | * 32 | * @author wyouflf 33 | */ 34 | public class DefaultHttpRedirectHandler implements HttpRedirectHandler { 35 | @Override 36 | public HttpRequestBase getDirectRequest(HttpResponse response) { 37 | if (response.containsHeader("Location")) { 38 | String location = response.getFirstHeader("Location").getValue(); 39 | HttpGet request = new HttpGet(location); 40 | if (response.containsHeader("Set-Cookie")) { 41 | String cookie = response.getFirstHeader("Set-Cookie").getValue(); 42 | request.addHeader("Cookie", cookie); 43 | } 44 | return request; 45 | } 46 | return null; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/http/callback/HttpRedirectHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.http.callback; 17 | 18 | import org.apache.http.HttpResponse; 19 | import org.apache.http.client.methods.HttpRequestBase; 20 | 21 | /** 22 | * HTTP重定向处理器 23 | * 24 | *
25 |  * Created with IntelliJ IDEA.
26 |  * User: wyouflf
27 |  * Date: 13-7-17
28 |  * Time: 上午10:36
29 |  * 
30 | * 31 | * @author wyouflf 32 | */ 33 | public interface HttpRedirectHandler { 34 | /** 35 | * 获取重定向的HTTP请求描述 36 | * @param response 重定向响应信息{@link org.apache.http.HttpResponse} 37 | * @return HTTP请求描述{@link org.apache.http.client.methods.HttpRequestBase} 38 | */ 39 | HttpRequestBase getDirectRequest(HttpResponse response); 40 | } 41 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/http/callback/RequestCallBackHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.http.callback; 17 | 18 | /** 19 | * 网络请求进度更新通知接口 20 | */ 21 | public interface RequestCallBackHandler { 22 | 23 | /** 24 | * 更新进度 25 | * @param total 数据总大小(byte) 26 | * @param current 当前读取大小(byte) 27 | * @param forceUpdateUI 是否强制更新UI 28 | * @return 是否继续执行(false:取消读取数据,否则继续执行) 29 | */ 30 | boolean updateProgress(long total, long current, boolean forceUpdateUI); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/http/callback/StringDownloadHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.http.callback; 17 | 18 | import com.lidroid.xutils.util.IOUtils; 19 | import com.lidroid.xutils.util.OtherUtils; 20 | import org.apache.http.HttpEntity; 21 | 22 | import java.io.BufferedReader; 23 | import java.io.IOException; 24 | import java.io.InputStream; 25 | import java.io.InputStreamReader; 26 | 27 | /** 28 | * 网络文本数据下载处理器 29 | */ 30 | public class StringDownloadHandler { 31 | 32 | /** 33 | * 处理网络文本数据下载 34 | * 35 | * @param entity 网络请求实体{@link org.apache.http.HttpEntity} 36 | * @param callBackHandler 网络请求进度更新通知接口{@link com.lidroid.xutils.http.callback.RequestCallBackHandler} 37 | * @param charset 字符编码 38 | * @return 下载得到的文本数据(下载失败时,返回null) 39 | * @throws IOException IO读取异常{@link java.io.IOException} 40 | */ 41 | public String handleEntity(HttpEntity entity, RequestCallBackHandler callBackHandler, String charset) throws IOException { 42 | if (entity == null) return null; 43 | 44 | long current = 0; 45 | long total = entity.getContentLength(); 46 | 47 | if (callBackHandler != null && !callBackHandler.updateProgress(total, current, true)) { 48 | return null; 49 | } 50 | 51 | InputStream inputStream = null; 52 | StringBuilder sb = new StringBuilder(); 53 | try { 54 | inputStream = entity.getContent(); 55 | BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, charset)); 56 | String line = ""; 57 | while ((line = reader.readLine()) != null) { 58 | sb.append(line).append('\n'); 59 | current += OtherUtils.sizeOfString(line, charset); 60 | if (callBackHandler != null) { 61 | if (!callBackHandler.updateProgress(total, current, false)) { 62 | break; 63 | } 64 | } 65 | } 66 | if (callBackHandler != null) { 67 | callBackHandler.updateProgress(total, current, true); 68 | } 69 | } finally { 70 | IOUtils.closeQuietly(inputStream); 71 | } 72 | return sb.toString().trim(); 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/http/client/DefaultSSLSocketFactory.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.http.client; 2 | 3 | import com.lidroid.xutils.util.LogUtils; 4 | import org.apache.http.conn.ssl.SSLSocketFactory; 5 | 6 | import javax.net.ssl.SSLContext; 7 | import javax.net.ssl.TrustManager; 8 | import javax.net.ssl.X509TrustManager; 9 | import java.io.IOException; 10 | import java.net.Socket; 11 | import java.security.*; 12 | 13 | /** 14 | * SSL协议连接工厂(信任所有证书) 15 | */ 16 | public class DefaultSSLSocketFactory extends SSLSocketFactory { 17 | 18 | private SSLContext sslContext = SSLContext.getInstance("TLS"); 19 | 20 | private static KeyStore trustStore; 21 | 22 | static { 23 | try { 24 | trustStore = KeyStore.getInstance(KeyStore.getDefaultType()); 25 | trustStore.load(null, null); 26 | } catch (Throwable e) { 27 | LogUtils.e(e.getMessage(), e); 28 | } 29 | } 30 | 31 | private static DefaultSSLSocketFactory instance; 32 | 33 | /** 34 | * 获取默认的SSL协议连接工厂单例 35 | * @return SSL协议连接工厂{@link com.lidroid.xutils.http.client.DefaultSSLSocketFactory} 36 | */ 37 | public static DefaultSSLSocketFactory getSocketFactory() { 38 | if (instance == null) { 39 | try { 40 | instance = new DefaultSSLSocketFactory(); 41 | } catch (Throwable e) { 42 | LogUtils.e(e.getMessage(), e); 43 | } 44 | } 45 | return instance; 46 | } 47 | 48 | private DefaultSSLSocketFactory() 49 | throws UnrecoverableKeyException, 50 | NoSuchAlgorithmException, 51 | KeyStoreException, 52 | KeyManagementException { 53 | super(trustStore); 54 | 55 | TrustManager trustAllCerts = new X509TrustManager() { 56 | public java.security.cert.X509Certificate[] getAcceptedIssuers() { 57 | return null; 58 | } 59 | 60 | @Override 61 | public void checkClientTrusted( 62 | java.security.cert.X509Certificate[] chain, String authType) 63 | throws java.security.cert.CertificateException { 64 | } 65 | 66 | @Override 67 | public void checkServerTrusted( 68 | java.security.cert.X509Certificate[] chain, String authType) 69 | throws java.security.cert.CertificateException { 70 | } 71 | }; 72 | sslContext.init(null, new TrustManager[]{trustAllCerts}, null); 73 | 74 | this.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); 75 | } 76 | 77 | /** 78 | * 创建连接 79 | * @param socket {@link java.net.Socket} 80 | * @param host 主机HOST 81 | * @param port 端口 82 | * @param autoClose 是否自动关闭连接 83 | * @return {@link java.net.Socket} 84 | * @throws IOException IO网络通讯异常 85 | */ 86 | @Override 87 | public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException { 88 | return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose); 89 | } 90 | 91 | /** 92 | * 创建连接 93 | * @return {@link java.net.Socket} 94 | * @throws IOException IO网络通讯异常 95 | */ 96 | @Override 97 | public Socket createSocket() throws IOException { 98 | return sslContext.getSocketFactory().createSocket(); 99 | } 100 | 101 | } 102 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/http/client/entity/FileUploadEntity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.http.client.entity; 17 | 18 | import java.io.BufferedInputStream; 19 | import java.io.File; 20 | import java.io.FileInputStream; 21 | import java.io.IOException; 22 | import java.io.InterruptedIOException; 23 | import java.io.OutputStream; 24 | 25 | import org.apache.http.entity.FileEntity; 26 | 27 | import com.lidroid.xutils.http.callback.RequestCallBackHandler; 28 | import com.lidroid.xutils.util.IOUtils; 29 | 30 | /** 31 | * 文件上传参数实体 32 | * 33 | *
34 |  * Created with IntelliJ IDEA.
35 |  * User: wyouflf
36 |  * Date: 13-6-24
37 |  * Time: 下午4:45
38 |  * 
39 | * 40 | * @author wyouflf 41 | */ 42 | public class FileUploadEntity extends FileEntity implements UploadEntity { 43 | 44 | /** 45 | * 构造文件上传参数实体 46 | * @param file 要上传的文件 47 | * @param contentType 内容类型(CONTENT-TYPE) 48 | */ 49 | public FileUploadEntity(File file, String contentType) { 50 | super(file, contentType); 51 | fileSize = file.length(); 52 | } 53 | 54 | private long fileSize; 55 | private long uploadedSize = 0; 56 | 57 | /** 58 | * 将参数内容写入到输出流 59 | * @param outStream IO输出流 {@link java.io.OutputStream} 60 | * @throws IOException IO流操作异常{@link java.io.IOException} 61 | */ 62 | @Override 63 | public void writeTo(OutputStream outStream) throws IOException { 64 | if (outStream == null) { 65 | throw new IllegalArgumentException("Output stream may not be null"); 66 | } 67 | BufferedInputStream inStream = null; 68 | try { 69 | inStream = new BufferedInputStream(new FileInputStream(this.file)); 70 | byte[] tmp = new byte[4096]; 71 | int len; 72 | while ((len = inStream.read(tmp)) != -1) { 73 | outStream.write(tmp, 0, len); 74 | uploadedSize += len; 75 | if (callBackHandler != null) { 76 | if (!callBackHandler.updateProgress(fileSize, uploadedSize, false)) { 77 | throw new InterruptedIOException("cancel"); 78 | } 79 | } 80 | } 81 | outStream.flush(); 82 | if (callBackHandler != null) { 83 | callBackHandler.updateProgress(fileSize, uploadedSize, true); 84 | } 85 | } finally { 86 | IOUtils.closeQuietly(inStream); 87 | } 88 | } 89 | 90 | private RequestCallBackHandler callBackHandler = null; 91 | 92 | @Override 93 | public void setCallBackHandler(RequestCallBackHandler callBackHandler) { 94 | this.callBackHandler = callBackHandler; 95 | } 96 | 97 | } -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/http/client/entity/GZipDecompressingEntity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.http.client.entity; 17 | 18 | import org.apache.http.Header; 19 | import org.apache.http.HttpEntity; 20 | 21 | import java.io.IOException; 22 | import java.io.InputStream; 23 | import java.util.zip.GZIPInputStream; 24 | 25 | /** 26 | * GZip参数实体的数据流解压器(实现自{@link org.apache.http.HttpEntity}) 27 | */ 28 | public class GZipDecompressingEntity extends DecompressingEntity { 29 | 30 | /** 31 | * 构造GZip数据流解压器(包装请求参数实体) 32 | * @param entity 非空的网络请求参数实体{@link org.apache.http.HttpEntity} 33 | */ 34 | public GZipDecompressingEntity(final HttpEntity entity) { 35 | super(entity); 36 | } 37 | 38 | @Override 39 | InputStream decorate(final InputStream wrapped) throws IOException { 40 | return new GZIPInputStream(wrapped); 41 | } 42 | 43 | /** 44 | * 获取内容编码 45 | * 46 | *
47 |      * 原文:This HttpEntityWrapper has dealt with the Content-Encoding
48 |      * 
49 | * 50 | * @return null 51 | */ 52 | @Override 53 | public Header getContentEncoding() { 54 | /* This HttpEntityWrapper has dealt with the Content-Encoding. */ 55 | return null; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/http/client/entity/UploadEntity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.http.client.entity; 17 | 18 | import com.lidroid.xutils.http.callback.RequestCallBackHandler; 19 | 20 | /** 21 | * 上传参数实体的接口定义 22 | * 23 | *
24 |  * Created with IntelliJ IDEA.
25 |  * User: wyouflf
26 |  * Date: 13-7-3
27 |  * Time: 下午1:40
28 |  * 
29 | * 30 | * @author wyouflf 31 | */ 32 | public interface UploadEntity { 33 | 34 | /** 35 | * 设置进度更新监听 36 | * @param callBackHandler 网络请求进度更新通知接口{@link com.lidroid.xutils.http.callback.RequestCallBackHandler} 37 | */ 38 | void setCallBackHandler(RequestCallBackHandler callBackHandler); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/http/client/multipart/HttpMultipartMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.http.client.multipart; 17 | 18 | /** 19 | * HTTP模式 20 | * @since 4.0 21 | */ 22 | public enum HttpMultipartMode { 23 | 24 | /** 25 | * 严格模式 26 | * RFC 822, RFC 2045, RFC 2046 compliant 27 | */ 28 | STRICT, 29 | /** 30 | * 浏览器兼容模式 31 | * browser-compatible mode, i.e. only write Content-Disposition; use content charset 32 | */ 33 | BROWSER_COMPATIBLE 34 | 35 | } 36 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/http/client/multipart/MIME.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.http.client.multipart; 17 | 18 | import org.apache.http.protocol.HTTP; 19 | 20 | import java.nio.charset.Charset; 21 | 22 | /** 23 | * MIME常量 24 | * @since 4.0 25 | */ 26 | public class MIME { 27 | 28 | public static final String CONTENT_TYPE = "Content-Type"; 29 | public static final String CONTENT_TRANSFER_ENC = "Content-Transfer-Encoding"; 30 | public static final String CONTENT_DISPOSITION = "Content-Disposition"; 31 | 32 | public static final String ENC_8BIT = "8bit"; 33 | public static final String ENC_BINARY = "binary"; 34 | 35 | /** 36 | * 默认使用的编码,即:"UTF-8" 37 | */ 38 | public static final Charset DEFAULT_CHARSET = Charset.forName(HTTP.UTF_8); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/http/client/multipart/MinimalField.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.http.client.multipart; 17 | 18 | /** 19 | * 最小的MIME字段 20 | * @since 4.0 21 | */ 22 | class MinimalField { 23 | 24 | private final String name; 25 | private final String value; 26 | 27 | MinimalField(final String name, final String value) { 28 | super(); 29 | this.name = name; 30 | this.value = value; 31 | } 32 | 33 | /** 34 | * 获取字段名 35 | * @return 字段名 36 | */ 37 | public String getName() { 38 | return this.name; 39 | } 40 | 41 | /** 42 | * 获取字段的值 43 | * @return 字段的值 44 | */ 45 | public String getBody() { 46 | return this.value; 47 | } 48 | 49 | @Override 50 | public String toString() { 51 | StringBuilder buffer = new StringBuilder(); 52 | buffer.append(this.name); 53 | buffer.append(": "); 54 | buffer.append(this.value); 55 | return buffer.toString(); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/http/client/multipart/content/AbstractContentBody.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.http.client.multipart.content; 17 | 18 | import com.lidroid.xutils.http.client.multipart.MultipartEntity; 19 | 20 | /** 21 | * 网络请求的内容主体抽象类 22 | * @since 4.0 23 | */ 24 | public abstract class AbstractContentBody implements ContentBody { 25 | 26 | private final String mimeType; 27 | private final String mediaType; 28 | private final String subType; 29 | 30 | /** 31 | * 构造网络请求的内容主体 32 | * @param mimeType MIME类型 33 | * @see com.lidroid.xutils.http.client.multipart.MIME 34 | */ 35 | public AbstractContentBody(final String mimeType) { 36 | super(); 37 | if (mimeType == null) { 38 | throw new IllegalArgumentException("MIME type may not be null"); 39 | } 40 | this.mimeType = mimeType; 41 | int i = mimeType.indexOf('/'); 42 | if (i != -1) { 43 | this.mediaType = mimeType.substring(0, i); 44 | this.subType = mimeType.substring(i + 1); 45 | } else { 46 | this.mediaType = mimeType; 47 | this.subType = null; 48 | } 49 | } 50 | 51 | public String getMimeType() { 52 | return this.mimeType; 53 | } 54 | 55 | public String getMediaType() { 56 | return this.mediaType; 57 | } 58 | 59 | public String getSubType() { 60 | return this.subType; 61 | } 62 | 63 | protected MultipartEntity.CallBackInfo callBackInfo = MultipartEntity.CallBackInfo.DEFAULT; 64 | 65 | @Override 66 | public void setCallBackInfo(MultipartEntity.CallBackInfo callBackInfo) { 67 | this.callBackInfo = callBackInfo; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/http/client/multipart/content/ByteArrayBody.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.http.client.multipart.content; 17 | 18 | import com.lidroid.xutils.http.client.multipart.MIME; 19 | 20 | import java.io.IOException; 21 | import java.io.OutputStream; 22 | 23 | /** 24 | * 字节数组包裹的网络请求文件内容主体 25 | * 26 | *
 27 |  * 原文:Body part that is built using a byte array containing a file.
 28 |  * 
29 | * 30 | * @since 4.1 31 | */ 32 | public class ByteArrayBody extends AbstractContentBody { 33 | 34 | /** 35 | * The contents of the file contained in this part. 36 | */ 37 | private final byte[] data; 38 | 39 | /** 40 | * The name of the file contained in this part. 41 | */ 42 | private final String filename; 43 | 44 | /** 45 | * 构造字节数组包裹的文件内容主体 46 | * 47 | *
 48 |      * data为空时,抛出异常{@link java.lang.IllegalArgumentException}
 49 |      * 
50 | * 51 | * @param data 包含的数据内容(原文:The contents of the file contained in this part.) 52 | * @param mimeType MIME类型(原文:The mime type of the file contained in this part.) 53 | * @param filename 文件名(原文:The name of the file contained in this part.) 54 | * @see com.lidroid.xutils.http.client.multipart.MIME 55 | */ 56 | public ByteArrayBody(final byte[] data, final String mimeType, final String filename) { 57 | super(mimeType); 58 | if (data == null) { 59 | throw new IllegalArgumentException("byte[] may not be null"); 60 | } 61 | this.data = data; 62 | this.filename = filename; 63 | } 64 | 65 | /** 66 | * 构造字节数组包裹的文件内容主体 67 | * 68 | *
 69 |      * data为空时,抛出异常{@link java.lang.IllegalArgumentException};
 70 |      * 默认:MIME类型(application/octet-stream)
 71 |      * 
72 | * 73 | * @param data 包含的数据内容(原文:The contents of the file contained in this part.) 74 | * @param filename 文件名(原文:The name of the file contained in this part.) 75 | * @see com.lidroid.xutils.http.client.multipart.MIME 76 | */ 77 | public ByteArrayBody(final byte[] data, final String filename) { 78 | this(data, "application/octet-stream", filename); 79 | } 80 | 81 | public String getFilename() { 82 | return filename; 83 | } 84 | 85 | public void writeTo(final OutputStream out) throws IOException { 86 | out.write(data); 87 | callBackInfo.pos += data.length; 88 | callBackInfo.doCallBack(false); 89 | } 90 | 91 | /** 92 | * 获取字符编码 93 | * @return null 94 | */ 95 | public String getCharset() { 96 | return null; 97 | } 98 | 99 | /** 100 | * 获取传输编码 101 | * @return "binary" 102 | */ 103 | public String getTransferEncoding() { 104 | return MIME.ENC_BINARY; 105 | } 106 | 107 | public long getContentLength() { 108 | return data.length; 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/http/client/multipart/content/ContentBody.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.http.client.multipart.content; 17 | 18 | import com.lidroid.xutils.http.client.multipart.MultipartEntity; 19 | 20 | import java.io.IOException; 21 | import java.io.OutputStream; 22 | 23 | /** 24 | * 网络请求的内容主体接口 25 | * 26 | * @since 4.0 27 | */ 28 | public interface ContentBody extends ContentDescriptor { 29 | 30 | /** 31 | * 获取文件名 32 | * @return 文件名 33 | */ 34 | String getFilename(); 35 | 36 | /** 37 | * 将内容写入到输出流 38 | * @param out IO输出流 {@link java.io.OutputStream} 39 | * @throws IOExceptionIO流操作异常{@link java.io.IOException} 40 | */ 41 | void writeTo(OutputStream out) throws IOException; 42 | 43 | /** 44 | * 设置上传监听器 45 | * @param callBackInfo 上传的回调函数{@link com.lidroid.xutils.http.client.multipart.MultipartEntity.CallBackInfo} 46 | */ 47 | void setCallBackInfo(MultipartEntity.CallBackInfo callBackInfo); 48 | 49 | } 50 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/http/client/multipart/content/ContentDescriptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.http.client.multipart.content; 17 | 18 | /** 19 | * 网络请求的内容描述接口(定义通用属性获取方法) 20 | */ 21 | public interface ContentDescriptor { 22 | 23 | /** 24 | * 获取MIME类型 25 | * 26 | * @return The MIME type, which has been parsed from the 27 | * content-type definition. Must not be null, but 28 | * "text/plain", if no content-type was specified. 29 | * @see #getMediaType() 30 | * @see #getSubType() 31 | * @see com.lidroid.xutils.http.client.multipart.MIME 32 | */ 33 | String getMimeType(); 34 | 35 | /** 36 | * 获取默认的MIME类型(如:TEXT, IMAGE, MULTIPART) 37 | * 38 | *
 39 |      * 原文:
 40 |      * Gets the defaulted MIME media type for this content.
 41 |      * For example TEXT, IMAGE, MULTIPART
 42 |      * 
43 | * 44 | * @return the MIME media type when content-type specified, 45 | * otherwise the correct default (TEXT) 46 | * @see #getMimeType() 47 | * @see com.lidroid.xutils.http.client.multipart.MIME 48 | */ 49 | String getMediaType(); 50 | 51 | /** 52 | * 获取默认的MIME类型 53 | * 54 | *
 55 |      * 原文:
 56 |      * Gets the defaulted MIME sub type for this content.
 57 |      * 
58 | * 59 | * @return the MIME media type when content-type is specified, 60 | * otherwise the correct default (PLAIN) 61 | * @see #getMimeType() 62 | * @see com.lidroid.xutils.http.client.multipart.MIME 63 | */ 64 | String getSubType(); 65 | 66 | /** 67 | * 获取字符编码 68 | * 69 | *
 70 |      * 原文:
 71 |      * The body descriptors character set, defaulted appropriately for the MIME type.
 72 |      * 
 73 |      * For TEXT types, this will be defaulted to UTF-8.
 74 |      * For other types, when the charset parameter is missing this property will be null.
 75 |      * 
76 | * 77 | * @return Character set, which has been parsed from the 78 | * content-type definition. Not null for TEXT types, when unset will 79 | * be set to default UTF-8. For other types, when unset, 80 | * null will be returned. 81 | */ 82 | String getCharset(); 83 | 84 | /** 85 | * 获取传输编码 86 | * 87 | *
 88 |      * 原文:
 89 |      * Returns the body descriptors transfer encoding.
 90 |      * 
91 | * 92 | * @return The transfer encoding. Must not be null, but "7bit", 93 | * if no transfer-encoding was specified. 94 | */ 95 | String getTransferEncoding(); 96 | 97 | /** 98 | * 获取内容长度 99 | * 100 | *
101 |      * 原文:
102 |      * Returns the body descriptors content-length.
103 |      * 
104 | * 105 | * @return Content length, if known, or -1, to indicate the absence of a 106 | * content-length header. 107 | */ 108 | long getContentLength(); 109 | 110 | } 111 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/http/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * HTTP管理模块 3 | */ 4 | package com.lidroid.xutils.http; -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * xUtils核心API工具包,包含BitmapUtils、DbUtils、HttpUtils、ViewUtils四大模块工具包 3 | */ 4 | package com.lidroid.xutils; -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/task/Priority.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.task; 2 | 3 | /** 4 | * 线程优先级 5 | * 6 | *
 7 |  * Author: wyouflf
 8 |  * Date: 14-5-16
 9 |  * Time: 上午11:25
10 |  * 
11 | * 12 | * @author wyouflf 13 | */ 14 | public enum Priority { 15 | /** 前台-高 */ 16 | UI_TOP, 17 | /** 前台-默认 */ 18 | UI_NORMAL, 19 | /** 前台-低 */ 20 | UI_LOW, 21 | /** 默认 */ 22 | DEFAULT, 23 | /** 后台-高 */ 24 | BG_TOP, 25 | /** 后台-默认 */ 26 | BG_NORMAL, 27 | /** 后台-低 */ 28 | BG_LOW; 29 | } 30 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/task/PriorityExecutor.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.task; 2 | 3 | import java.util.concurrent.*; 4 | import java.util.concurrent.atomic.AtomicInteger; 5 | 6 | /** 7 | * 可调度优先级的线程池 8 | * 9 | *
10 |  * Author: wyouflf
11 |  * Date: 14-5-16
12 |  * Time: 上午11:25
13 |  * 
14 | * 15 | * @author wyouflf 16 | */ 17 | public class PriorityExecutor implements Executor { 18 | 19 | private static final int CORE_POOL_SIZE = 5; 20 | private static final int MAXIMUM_POOL_SIZE = 256; 21 | private static final int KEEP_ALIVE = 1; 22 | 23 | private static final ThreadFactory sThreadFactory = new ThreadFactory() { 24 | private final AtomicInteger mCount = new AtomicInteger(1); 25 | 26 | @Override 27 | public Thread newThread(Runnable r) { 28 | return new Thread(r, "PriorityExecutor #" + mCount.getAndIncrement()); 29 | } 30 | }; 31 | 32 | private final BlockingQueue mPoolWorkQueue = new PriorityObjectBlockingQueue(); 33 | private final ThreadPoolExecutor mThreadPoolExecutor; 34 | 35 | /** 36 | * 实例化可调度优先级的线程池(默认线程池大小:5) 37 | */ 38 | public PriorityExecutor() { 39 | this(CORE_POOL_SIZE); 40 | } 41 | /** 42 | * 实例化可调度优先级的线程池 43 | * @param poolSize 线程池大小 44 | */ 45 | public PriorityExecutor(int poolSize) { 46 | mThreadPoolExecutor = new ThreadPoolExecutor( 47 | poolSize, 48 | MAXIMUM_POOL_SIZE, 49 | KEEP_ALIVE, 50 | TimeUnit.SECONDS, 51 | mPoolWorkQueue, 52 | sThreadFactory); 53 | } 54 | 55 | /** 56 | * 获取线程池大小 57 | * @return 线程池大小 58 | */ 59 | public int getPoolSize() { 60 | return mThreadPoolExecutor.getCorePoolSize(); 61 | } 62 | 63 | /** 64 | * 设置线程池大小 65 | * @param poolSize 线程池大小 66 | */ 67 | public void setPoolSize(int poolSize) { 68 | if (poolSize > 0) { 69 | mThreadPoolExecutor.setCorePoolSize(poolSize); 70 | } 71 | } 72 | 73 | /** 74 | * 判断是否任务正忙 75 | * @return 是否任务正忙 76 | */ 77 | public boolean isBusy() { 78 | return mThreadPoolExecutor.getActiveCount() >= mThreadPoolExecutor.getCorePoolSize(); 79 | } 80 | 81 | /** 82 | * 执行任务 83 | * @param r 需要执行的任务 84 | */ 85 | @Override 86 | public void execute(final Runnable r) { 87 | mThreadPoolExecutor.execute(r); 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/task/PriorityObject.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.task; 2 | 3 | /** 4 | * 可设置线程优先级的任务对象 5 | * 6 | *
 7 |  * Author: wyouflf
 8 |  * Date: 14-5-16
 9 |  * Time: 上午11:25
10 |  * 
11 | * 12 | * @param 对象类型 13 | * @author wyouflf 14 | */ 15 | public class PriorityObject { 16 | 17 | /** 18 | * 线程优先级 19 | */ 20 | public final Priority priority; 21 | /** 22 | * 任务对象 23 | */ 24 | public final E obj; 25 | 26 | /** 27 | * 构造任务对象 28 | * @param priority 线程优先级{@link com.lidroid.xutils.task.Priority} 29 | * @param obj 任务对象 30 | */ 31 | public PriorityObject(Priority priority, E obj) { 32 | this.priority = priority == null ? Priority.DEFAULT : priority; 33 | this.obj = obj; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/task/PriorityRunnable.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.task; 2 | 3 | /** 4 | * 可设置线程优先级的任务接口 5 | * 6 | * Author: wyouflf 7 | * Date: 14-5-16 8 | * Time: 上午11:25 9 | */ 10 | public class PriorityRunnable extends PriorityObject implements Runnable { 11 | 12 | /** 13 | * 构造任务接口 14 | * @param priority 线程优先级{@link com.lidroid.xutils.task.Priority} 15 | * @param obj 需要执行的任务 16 | */ 17 | public PriorityRunnable(Priority priority, Runnable obj) { 18 | super(priority, obj); 19 | } 20 | 21 | /** 22 | * 执行任务 23 | */ 24 | @Override 25 | public void run() { 26 | this.obj.run(); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/task/TaskHandler.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.task; 2 | 3 | /** 4 | * 任务处理接口 5 | * 6 | *
 7 |  * Author: wyouflf
 8 |  * Time: 2014/05/23
 9 |  * 
10 | * 11 | * @author wyouflf 12 | */ 13 | public interface TaskHandler { 14 | 15 | /** 16 | * 判断是否支持暂停任务 17 | * @return 是否支持暂停任务 18 | */ 19 | boolean supportPause(); 20 | 21 | /** 22 | * 判断是否支持恢复任务 23 | * @return 是否支持恢复任务 24 | */ 25 | boolean supportResume(); 26 | 27 | /** 28 | * 判断是否支持取消任务 29 | * @return 是否支持取消任务 30 | */ 31 | boolean supportCancel(); 32 | 33 | /** 34 | * 暂停任务 35 | */ 36 | void pause(); 37 | 38 | /** 39 | * 恢复任务 40 | */ 41 | void resume(); 42 | 43 | /** 44 | * 取消任务 45 | */ 46 | void cancel(); 47 | 48 | /** 49 | * 判断任务是否处于暂停状态 50 | * @return 暂停:true,否则false 51 | */ 52 | boolean isPaused(); 53 | 54 | /** 55 | * 判断任务是否处于取消状态 56 | * @return 已取消:true,否则false 57 | */ 58 | boolean isCancelled(); 59 | 60 | } 61 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/task/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 线程调度管理模块 3 | */ 4 | package com.lidroid.xutils.task; -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/util/CharsetUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.util; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | import org.apache.http.protocol.HTTP; 22 | 23 | /** 24 | * 字符编码处理-工具类 25 | * 26 | *
 27 |  * Created by wyouflf on 13-8-30.
 28 |  * 
29 | * 30 | * @author wyouflf 31 | */ 32 | public class CharsetUtils { 33 | 34 | private CharsetUtils() { 35 | } 36 | 37 | /** 38 | * 将字符串转换为指定编码 39 | * @param str 原始字符串 40 | * @param charset 字符编码 41 | * @param judgeCharsetLength 预估的字符长度 42 | * @return 编码转换后的字符串 43 | * @see java.nio.charset.Charset 44 | */ 45 | public static String toCharset(final String str, final String charset, int judgeCharsetLength) { 46 | try { 47 | String oldCharset = getEncoding(str, judgeCharsetLength); 48 | return new String(str.getBytes(oldCharset), charset); 49 | } catch (Throwable ex) { 50 | LogUtils.w(ex); 51 | return str; 52 | } 53 | } 54 | 55 | /** 56 | * 判断字符串的编码 57 | * @param str 原始字符串 58 | * @param judgeCharsetLength 预估的字符长度 59 | * @return 字符编码 60 | * @see java.nio.charset.Charset 61 | */ 62 | public static String getEncoding(final String str, int judgeCharsetLength) { 63 | String encode = CharsetUtils.DEFAULT_ENCODING_CHARSET; 64 | for (String charset : SUPPORT_CHARSET) { 65 | if (isCharset(str, charset, judgeCharsetLength)) { 66 | encode = charset; 67 | break; 68 | } 69 | } 70 | return encode; 71 | } 72 | 73 | /** 74 | * 判断是否指定编码 75 | * @param str 原始字符串 76 | * @param charset 字符编码 77 | * @param judgeCharsetLength 预估的字符长度 78 | * @return 是否该字符编码 79 | * @see java.nio.charset.Charset 80 | */ 81 | public static boolean isCharset(final String str, final String charset, int judgeCharsetLength) { 82 | try { 83 | String temp = str.length() > judgeCharsetLength ? str.substring(0, judgeCharsetLength) : str; 84 | return temp.equals(new String(temp.getBytes(charset), charset)); 85 | } catch (Throwable e) { 86 | return false; 87 | } 88 | } 89 | 90 | /** 91 | * 默认字符编码(ISO-8859-1) 92 | */ 93 | public static final String DEFAULT_ENCODING_CHARSET = HTTP.DEFAULT_CONTENT_CHARSET; 94 | 95 | /** 96 | * 支持的字符编码集 97 | */ 98 | public static final List SUPPORT_CHARSET = new ArrayList(); 99 | 100 | static { 101 | SUPPORT_CHARSET.add("ISO-8859-1"); 102 | 103 | SUPPORT_CHARSET.add("GB2312"); 104 | SUPPORT_CHARSET.add("GBK"); 105 | SUPPORT_CHARSET.add("GB18030"); 106 | 107 | SUPPORT_CHARSET.add("US-ASCII"); 108 | SUPPORT_CHARSET.add("ASCII"); 109 | 110 | SUPPORT_CHARSET.add("ISO-2022-KR"); 111 | 112 | SUPPORT_CHARSET.add("ISO-8859-2"); 113 | 114 | SUPPORT_CHARSET.add("ISO-2022-JP"); 115 | SUPPORT_CHARSET.add("ISO-2022-JP-2"); 116 | 117 | SUPPORT_CHARSET.add("UTF-8"); 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/util/IOUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.util; 17 | 18 | import android.database.Cursor; 19 | 20 | import java.io.Closeable; 21 | 22 | /** 23 | * IO流处理-工具类 24 | * 25 | *
26 |  * Author: wyouflf
27 |  * Date: 13-8-26
28 |  * Time: 下午6:02
29 |  * 
30 | * 31 | * @author wyouflf 32 | */ 33 | public class IOUtils { 34 | 35 | private IOUtils() { 36 | } 37 | 38 | /** 39 | * 安静地关闭 40 | * @param closeable 可以关闭的数据源或目标{@link java.io.Closeable} 41 | */ 42 | public static void closeQuietly(Closeable closeable) { 43 | if (closeable != null) { 44 | try { 45 | closeable.close(); 46 | } catch (Throwable e) { 47 | } 48 | } 49 | } 50 | 51 | /** 52 | * 安静地关闭 53 | * @param cursor 数据库游标{@link android.database.Cursor} 54 | */ 55 | public static void closeQuietly(Cursor cursor) { 56 | if (cursor != null) { 57 | try { 58 | cursor.close(); 59 | } catch (Throwable e) { 60 | } 61 | } 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/util/MimeTypeUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.util; 17 | 18 | import android.webkit.MimeTypeMap; 19 | 20 | /** 21 | * MIME类型处理工具 22 | * 23 | *
24 |  * Author: wyouflf
25 |  * Date: 13-7-26
26 |  * Time: 下午2:31
27 |  * 
28 | */ 29 | public class MimeTypeUtils { 30 | 31 | private MimeTypeUtils() { 32 | } 33 | 34 | /** 35 | * 获取文件MIME类型 36 | * @param fileName 文件名(文件完整路径) 37 | * @return MIME类型{@link com.lidroid.xutils.http.client.multipart.MIME} 38 | */ 39 | public static String getMimeType(final String fileName) { 40 | String result = "application/octet-stream"; 41 | int extPos = fileName.lastIndexOf("."); 42 | if (extPos != -1) { 43 | String ext = fileName.substring(extPos + 1); 44 | result = MimeTypeMap.getSingleton().getMimeTypeFromExtension(ext); 45 | } 46 | return result; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/util/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 辅助工具类模块 3 | */ 4 | package com.lidroid.xutils.util; -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/ResLoader.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.view; 2 | 3 | import android.content.Context; 4 | import android.view.animation.AnimationUtils; 5 | 6 | /** 7 | * 资源文件的内容加载器 8 | * 9 | *
10 |  * Author: wyouflf
11 |  * Date: 13-11-9
12 |  * Time: 下午3:12
13 |  * 
14 | * 15 | * @author wyouflf 16 | */ 17 | public class ResLoader { 18 | 19 | /** 20 | * 加载资源文件的内容 21 | * @param type 资源文件类型{@link com.lidroid.xutils.view.ResType} 22 | * @param context android.content.Context 23 | * @param id 资源文件ID 24 | * @return 资源文件的内容 25 | */ 26 | public static Object loadRes(ResType type, Context context, int id) { 27 | if (context == null || id < 1) return null; 28 | switch (type) { 29 | case Animation: 30 | return AnimationUtils.loadAnimation(context, id); 31 | case Boolean: 32 | return context.getResources().getBoolean(id); 33 | case Color: 34 | return context.getResources().getColor(id); 35 | case ColorStateList: 36 | return context.getResources().getColorStateList(id); 37 | case Dimension: 38 | return context.getResources().getDimension(id); 39 | case DimensionPixelOffset: 40 | return context.getResources().getDimensionPixelOffset(id); 41 | case DimensionPixelSize: 42 | return context.getResources().getDimensionPixelSize(id); 43 | case Drawable: 44 | return context.getResources().getDrawable(id); 45 | case Integer: 46 | return context.getResources().getInteger(id); 47 | case IntArray: 48 | return context.getResources().getIntArray(id); 49 | case Movie: 50 | return context.getResources().getMovie(id); 51 | case String: 52 | return context.getResources().getString(id); 53 | case StringArray: 54 | return context.getResources().getStringArray(id); 55 | case Text: 56 | return context.getResources().getText(id); 57 | case TextArray: 58 | return context.getResources().getTextArray(id); 59 | case Xml: 60 | return context.getResources().getXml(id); 61 | default: 62 | break; 63 | } 64 | 65 | return null; 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/ResType.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.view; 2 | 3 | /** 4 | * 资源文件类型 5 | * 6 | *
 7 |  * Author: wyouflf
 8 |  * Date: 13-11-9
 9 |  * Time: 下午3:55
10 |  * 
11 | * 12 | * @author wyouflf 13 | */ 14 | public enum ResType { 15 | Animation, 16 | Boolean, 17 | Color, 18 | ColorStateList, 19 | Dimension, 20 | DimensionPixelOffset, 21 | DimensionPixelSize, 22 | Drawable, 23 | Integer, 24 | IntArray, 25 | Movie, 26 | String, 27 | StringArray, 28 | Text, 29 | TextArray, 30 | Xml 31 | } 32 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/ViewFinder.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.view; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.preference.Preference; 6 | import android.preference.PreferenceActivity; 7 | import android.preference.PreferenceGroup; 8 | import android.view.View; 9 | 10 | /** 11 | * 控件{@link android.view.View}查找辅助工具 12 | * 13 | *
 14 |  * Author: wyouflf
 15 |  * Date: 13-9-9
 16 |  * Time: 下午12:29
 17 |  * 
18 | */ 19 | public class ViewFinder { 20 | 21 | private View view; 22 | private Activity activity; 23 | private PreferenceGroup preferenceGroup; 24 | private PreferenceActivity preferenceActivity; 25 | 26 | /** 27 | * 构造控件查找辅助工具 28 | * @param view {@link android.view.View} 29 | */ 30 | public ViewFinder(View view) { 31 | this.view = view; 32 | } 33 | /** 34 | * 构造控件查找辅助工具 35 | * @param activity {@link android.app.Activity} 36 | */ 37 | public ViewFinder(Activity activity) { 38 | this.activity = activity; 39 | } 40 | /** 41 | * 构造控件查找辅助工具 42 | * @param preferenceGroup {@link android.preference.PreferenceGroup} 43 | */ 44 | public ViewFinder(PreferenceGroup preferenceGroup) { 45 | this.preferenceGroup = preferenceGroup; 46 | } 47 | /** 48 | * 构造控件查找辅助工具 49 | * @param preferenceActivity {@link android.preference.PreferenceActivity} 50 | */ 51 | public ViewFinder(PreferenceActivity preferenceActivity) { 52 | this.preferenceActivity = preferenceActivity; 53 | this.activity = preferenceActivity; 54 | } 55 | 56 | public View findViewById(int id) { 57 | return activity == null ? view.findViewById(id) : activity.findViewById(id); 58 | } 59 | 60 | /** 61 | * 查找控件 62 | * @param info 控件注入注解信息(只用于单个ID注解,否则抛出异常{@link java.lang.ClassCastException}) 63 | * @return 控件{@link android.view.View} 64 | */ 65 | public View findViewByInfo(ViewInjectInfo info) { 66 | return findViewById((Integer) info.value, info.parentId); 67 | } 68 | 69 | public View findViewById(int id, int pid) { 70 | View pView = null; 71 | if (pid > 0) { 72 | pView = this.findViewById(pid); 73 | } 74 | 75 | View view = null; 76 | if (pView != null) { 77 | view = pView.findViewById(id); 78 | } else { 79 | view = this.findViewById(id); 80 | } 81 | return view; 82 | } 83 | 84 | /** 85 | * 查找首选项控件 86 | * @param key 首选项标签名 87 | * @return 首选项控件{@link android.preference.Preference} 88 | */ 89 | public Preference findPreference(CharSequence key) { 90 | return preferenceGroup == null ? preferenceActivity.findPreference(key) : preferenceGroup.findPreference(key); 91 | } 92 | 93 | public Context getContext() { 94 | if (view != null) return view.getContext(); 95 | if (activity != null) return activity; 96 | if (preferenceActivity != null) return preferenceActivity; 97 | return null; 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/ViewInjectInfo.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.view; 2 | 3 | /** 4 | * 控件注入{@link android.view.View}注解信息 5 | * 6 | *
 7 |  * Author: wyouflf
 8 |  * Date: 13-12-5
 9 |  * Time: 下午11:25
10 |  * 
11 | * 12 | * @author wyouflf 13 | */ 14 | public class ViewInjectInfo { 15 | 16 | /** 17 | * 控件ID的值 18 | */ 19 | public Object value; 20 | 21 | /** 22 | * 所属父控件的ID 23 | */ 24 | public int parentId; 25 | 26 | @Override 27 | public boolean equals(Object o) { 28 | if (this == o) return true; 29 | if (!(o instanceof ViewInjectInfo)) return false; 30 | 31 | ViewInjectInfo that = (ViewInjectInfo) o; 32 | 33 | if (parentId != that.parentId) return false; 34 | if (value == null) return (null == that.value); 35 | 36 | return value.equals(that.value); 37 | } 38 | 39 | @Override 40 | public int hashCode() { 41 | int result = value.hashCode(); 42 | result = 31 * result + parentId; 43 | return result; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/annotation/ContentView.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.view.annotation; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | /** 24 | * Activity使用的布局文件注解 25 | */ 26 | @Target(ElementType.TYPE) 27 | @Retention(RetentionPolicy.RUNTIME) 28 | public @interface ContentView { 29 | 30 | /** 31 | * Activity要绑定的布局文件ID 32 | * @return 布局文件ID 33 | */ 34 | int value(); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/annotation/PreferenceInject.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.view.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * 首选项控件绑定注解 10 | * 11 | *
12 |  * Author: wyouflf
13 |  * Date: 13-11-16
14 |  * Time: 上午9:56
15 |  * 
16 | * 17 | * @author wyouflf 18 | */ 19 | @Target(ElementType.FIELD) 20 | @Retention(RetentionPolicy.RUNTIME) 21 | public @interface PreferenceInject { 22 | 23 | /** 24 | * 要绑定的首选项标签名 25 | * @return 首选项标签名 26 | */ 27 | String value(); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/annotation/ResInject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.view.annotation; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | import com.lidroid.xutils.view.ResType; 24 | 25 | /** 26 | * 资源文件{@link android.content.res.Resources}内容绑定注解 27 | */ 28 | @Target(ElementType.FIELD) 29 | @Retention(RetentionPolicy.RUNTIME) 30 | public @interface ResInject { 31 | 32 | /** 33 | * 要获取内容的资源文件ID 34 | * @return 资源文件ID(如:R.string.appname、R.color.blue等) 35 | */ 36 | int id(); 37 | 38 | /** 39 | * 资源类型 40 | * @return 资源类型(如:String、Color等){@link com.lidroid.xutils.view.ResType} 41 | */ 42 | ResType type(); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/annotation/ViewInject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.view.annotation; 17 | 18 | import java.lang.annotation.ElementType; 19 | import java.lang.annotation.Retention; 20 | import java.lang.annotation.RetentionPolicy; 21 | import java.lang.annotation.Target; 22 | 23 | /** 24 | * 控件{@link android.view.View}绑定注解 25 | */ 26 | @Target(ElementType.FIELD) 27 | @Retention(RetentionPolicy.RUNTIME) 28 | public @interface ViewInject { 29 | 30 | /** 31 | * 要绑定事件的控件ID 32 | * @return 控件ID 33 | */ 34 | int value(); 35 | 36 | /* parent view id */ 37 | /** 38 | * 所属父控件的ID 39 | * @return 控件ID 40 | */ 41 | int parentId() default 0; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/annotation/event/EventBase.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.view.annotation.event; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * 事件注解属性(给注解类使用) 10 | * 11 | *
12 |  * Author: wyouflf
13 |  * Date: 13-9-9
14 |  * Time: 下午12:43
15 |  * 
16 | * 17 | * @author wyouflf 18 | */ 19 | @Target(ElementType.ANNOTATION_TYPE) 20 | @Retention(RetentionPolicy.RUNTIME) 21 | public @interface EventBase { 22 | 23 | /** 24 | * 监听类型 25 | * @return {@link java.lang.Class} 26 | */ 27 | Class listenerType(); 28 | 29 | /** 30 | * 设置监听器的方法 31 | * @return 方法名(如:"setOnClickListener") 32 | */ 33 | String listenerSetter(); 34 | 35 | /** 36 | * 监听器的实现方法 37 | * @return 方法名(如:"onClick") 38 | */ 39 | String methodName(); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/annotation/event/OnChildClick.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.view.annotation.event; 17 | 18 | import android.widget.ExpandableListView; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * 二级列表的子节点单击事件注解 27 | * 28 | *
29 |  * Author: wyouflf
30 |  * Date: 13-8-16
31 |  * Time: 下午2:27
32 |  * 
33 | * 34 | * @author wyouflf 35 | */ 36 | @Target(ElementType.METHOD) 37 | @Retention(RetentionPolicy.RUNTIME) 38 | @EventBase( 39 | listenerType = ExpandableListView.OnChildClickListener.class, 40 | listenerSetter = "setOnChildClickListener", 41 | methodName = "onChildClick") 42 | public @interface OnChildClick { 43 | 44 | /** 45 | * 要绑定事件的控件ID 46 | * @return 控件ID 47 | */ 48 | int[] value(); 49 | 50 | /** 51 | * 所属父控件的ID 52 | * @return 控件ID 53 | */ 54 | int[] parentId() default 0; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/annotation/event/OnClick.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.view.annotation.event; 17 | 18 | import android.view.View; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * 单击事件注解 27 | * 28 | *
29 |  * Author: wyouflf
30 |  * Date: 13-8-16
31 |  * Time: 下午2:27
32 |  * 
33 | * 34 | * @author wyouflf 35 | */ 36 | @Target(ElementType.METHOD) 37 | @Retention(RetentionPolicy.RUNTIME) 38 | @EventBase( 39 | listenerType = View.OnClickListener.class, 40 | listenerSetter = "setOnClickListener", 41 | methodName = "onClick") 42 | public @interface OnClick { 43 | 44 | /** 45 | * 要绑定事件的控件ID 46 | * @return 控件ID 47 | */ 48 | int[] value(); 49 | 50 | /** 51 | * 所属父控件的ID 52 | * @return 控件ID 53 | */ 54 | int[] parentId() default 0; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/annotation/event/OnCompoundButtonCheckedChange.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.view.annotation.event; 17 | 18 | import android.widget.CompoundButton; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * 按钮选中改变事件注解 27 | * 28 | *
29 |  * Author: wyouflf
30 |  * Date: 13-8-16
31 |  * Time: 下午2:36
32 |  * 
33 | * 34 | * @author wyouflf 35 | */ 36 | @Target(ElementType.METHOD) 37 | @Retention(RetentionPolicy.RUNTIME) 38 | @EventBase( 39 | listenerType = CompoundButton.OnCheckedChangeListener.class, 40 | listenerSetter = "setOnCheckedChangeListener", 41 | methodName = "onCheckedChanged") 42 | public @interface OnCompoundButtonCheckedChange { 43 | 44 | /** 45 | * 要绑定事件的控件ID 46 | * @return 控件ID 47 | */ 48 | int[] value(); 49 | 50 | /** 51 | * 所属父控件的ID 52 | * @return 控件ID 53 | */ 54 | int[] parentId() default 0; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/annotation/event/OnFocusChange.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.view.annotation.event; 17 | 18 | import android.view.View; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * 按钮焦点改变事件注解 27 | * 28 | *
29 |  * Author: wyouflf
30 |  * Date: 13-8-16
31 |  * Time: 下午2:27
32 |  * 
33 | * 34 | * @author wyouflf 35 | */ 36 | @Target(ElementType.METHOD) 37 | @Retention(RetentionPolicy.RUNTIME) 38 | @EventBase( 39 | listenerType = View.OnFocusChangeListener.class, 40 | listenerSetter = "setOnFocusChangeListener", 41 | methodName = "onFocusChange") 42 | public @interface OnFocusChange { 43 | 44 | /** 45 | * 要绑定事件的控件ID 46 | * @return 控件ID 47 | */ 48 | int[] value(); 49 | 50 | /** 51 | * 所属父控件的ID 52 | * @return 控件ID 53 | */ 54 | int[] parentId() default 0; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/annotation/event/OnGroupClick.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.view.annotation.event; 17 | 18 | import android.widget.ExpandableListView; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * 二级列表的父节点单击事件注解 27 | * 28 | *
29 |  * Author: wyouflf
30 |  * Date: 13-8-16
31 |  * Time: 下午2:27
32 |  * 
33 | * 34 | * @author wyouflf 35 | */ 36 | @Target(ElementType.METHOD) 37 | @Retention(RetentionPolicy.RUNTIME) 38 | @EventBase( 39 | listenerType = ExpandableListView.OnGroupClickListener.class, 40 | listenerSetter = "setOnGroupClickListener", 41 | methodName = "onGroupClick") 42 | public @interface OnGroupClick { 43 | 44 | /** 45 | * 要绑定事件的控件ID 46 | * @return 控件ID 47 | */ 48 | int[] value(); 49 | 50 | /** 51 | * 所属父控件的ID 52 | * @return 控件ID 53 | */ 54 | int[] parentId() default 0; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/annotation/event/OnGroupCollapse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.view.annotation.event; 17 | 18 | import android.widget.ExpandableListView; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * 二级列表的子节点折叠监听事件注解 27 | * 28 | *
29 |  * Author: wyouflf
30 |  * Date: 13-8-16
31 |  * Time: 下午2:27
32 |  * 
33 | * 34 | * @author wyouflf 35 | */ 36 | @Target(ElementType.METHOD) 37 | @Retention(RetentionPolicy.RUNTIME) 38 | @EventBase( 39 | listenerType = ExpandableListView.OnGroupCollapseListener.class, 40 | listenerSetter = "setOnGroupCollapseListener", 41 | methodName = "onGroupCollapse") 42 | public @interface OnGroupCollapse { 43 | 44 | /** 45 | * 要绑定事件的控件ID 46 | * @return 控件ID 47 | */ 48 | int[] value(); 49 | 50 | /** 51 | * 所属父控件的ID 52 | * @return 控件ID 53 | */ 54 | int[] parentId() default 0; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/annotation/event/OnGroupExpand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.view.annotation.event; 17 | 18 | import android.widget.ExpandableListView; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * 二级列表的子节点展开监听事件注解 27 | * 28 | *
29 |  * Author: wyouflf
30 |  * Date: 13-8-16
31 |  * Time: 下午2:27
32 |  * 
33 | * 34 | * @author wyouflf 35 | */ 36 | @Target(ElementType.METHOD) 37 | @Retention(RetentionPolicy.RUNTIME) 38 | @EventBase( 39 | listenerType = ExpandableListView.OnGroupExpandListener.class, 40 | listenerSetter = "setOnGroupExpandListener", 41 | methodName = "onGroupExpand") 42 | public @interface OnGroupExpand { 43 | 44 | /** 45 | * 要绑定事件的控件ID 46 | * @return 控件ID 47 | */ 48 | int[] value(); 49 | 50 | /** 51 | * 所属父控件的ID 52 | * @return 控件ID 53 | */ 54 | int[] parentId() default 0; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/annotation/event/OnItemClick.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.view.annotation.event; 17 | 18 | import android.widget.AdapterView; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * 列表的条目单击事件注解 27 | * 28 | *
29 |  * Author: wyouflf
30 |  * Date: 13-8-16
31 |  * Time: 下午2:32
32 |  * 
33 | * 34 | * @author wyouflf 35 | */ 36 | @Target(ElementType.METHOD) 37 | @Retention(RetentionPolicy.RUNTIME) 38 | @EventBase( 39 | listenerType = AdapterView.OnItemClickListener.class, 40 | listenerSetter = "setOnItemClickListener", 41 | methodName = "onItemClick") 42 | public @interface OnItemClick { 43 | 44 | /** 45 | * 要绑定事件的控件ID 46 | * @return 控件ID 47 | */ 48 | int[] value(); 49 | 50 | /** 51 | * 所属父控件的ID 52 | * @return 控件ID 53 | */ 54 | int[] parentId() default 0; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/annotation/event/OnItemLongClick.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.view.annotation.event; 17 | 18 | import android.widget.AdapterView; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * 列表的条目长按事件注解 27 | * 28 | *
29 |  * Author: wyouflf
30 |  * Date: 13-8-16
31 |  * Time: 下午2:34
32 |  * 
33 | * 34 | * @author wyouflf 35 | */ 36 | @Target(ElementType.METHOD) 37 | @Retention(RetentionPolicy.RUNTIME) 38 | @EventBase( 39 | listenerType = AdapterView.OnItemLongClickListener.class, 40 | listenerSetter = "setOnItemLongClickListener", 41 | methodName = "onItemLongClick") 42 | public @interface OnItemLongClick { 43 | 44 | /** 45 | * 要绑定事件的控件ID 46 | * @return 控件ID 47 | */ 48 | int[] value(); 49 | 50 | /** 51 | * 所属父控件的ID 52 | * @return 控件ID 53 | */ 54 | int[] parentId() default 0; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/annotation/event/OnItemSelected.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.view.annotation.event; 17 | 18 | import android.widget.AdapterView; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * 列表的条目选中事件注解 27 | * 28 | *
29 |  * Author: wyouflf
30 |  * Date: 13-8-16
31 |  * Time: 下午2:41
32 |  * 
33 | * 34 | * @author wyouflf 35 | */ 36 | @Target(ElementType.METHOD) 37 | @Retention(RetentionPolicy.RUNTIME) 38 | @EventBase( 39 | listenerType = AdapterView.OnItemSelectedListener.class, 40 | listenerSetter = "setOnItemSelectedListener", 41 | methodName = "onItemSelected") 42 | public @interface OnItemSelected { 43 | 44 | /** 45 | * 要绑定事件的控件ID 46 | * @return 控件ID 47 | */ 48 | int[] value(); 49 | 50 | /** 51 | * 所属父控件的ID 52 | * @return 控件ID 53 | */ 54 | int[] parentId() default 0; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/annotation/event/OnKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.view.annotation.event; 17 | 18 | import android.view.View; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * 键盘点击事件注解 27 | * 28 | *
29 |  * Author: wyouflf
30 |  * Date: 13-8-16
31 |  * Time: 下午2:27
32 |  * 
33 | * 34 | * @author wyouflf 35 | */ 36 | @Target(ElementType.METHOD) 37 | @Retention(RetentionPolicy.RUNTIME) 38 | @EventBase( 39 | listenerType = View.OnKeyListener.class, 40 | listenerSetter = "setOnKeyListener", 41 | methodName = "onKey") 42 | public @interface OnKey { 43 | 44 | /** 45 | * 要绑定事件的控件ID 46 | * @return 控件ID 47 | */ 48 | int[] value(); 49 | 50 | /** 51 | * 所属父控件的ID 52 | * @return 控件ID 53 | */ 54 | int[] parentId() default 0; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/annotation/event/OnLongClick.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.view.annotation.event; 17 | 18 | import android.view.View; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * 长按事件注解 27 | * 28 | *
29 |  * Author: wyouflf
30 |  * Date: 13-8-16
31 |  * Time: 下午2:31
32 |  * 
33 | * 34 | * @author wyouflf 35 | */ 36 | @Target(ElementType.METHOD) 37 | @Retention(RetentionPolicy.RUNTIME) 38 | @EventBase( 39 | listenerType = View.OnLongClickListener.class, 40 | listenerSetter = "setOnLongClickListener", 41 | methodName = "onLongClick") 42 | public @interface OnLongClick { 43 | 44 | /** 45 | * 要绑定事件的控件ID 46 | * @return 控件ID 47 | */ 48 | int[] value(); 49 | 50 | /** 51 | * 所属父控件的ID 52 | * @return 控件ID 53 | */ 54 | int[] parentId() default 0; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/annotation/event/OnNothingSelected.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.view.annotation.event; 17 | 18 | import android.widget.AdapterView; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * 列表的没有选中条目事件注解 27 | * 28 | *
29 |  * Author: wyouflf
30 |  * Date: 13-8-16
31 |  * Time: 下午2:41
32 |  * 
33 | * 34 | * @author wyouflf 35 | */ 36 | @Target(ElementType.METHOD) 37 | @Retention(RetentionPolicy.RUNTIME) 38 | @EventBase( 39 | listenerType = AdapterView.OnItemSelectedListener.class, 40 | listenerSetter = "setOnItemSelectedListener", 41 | methodName = "onNothingSelected") 42 | public @interface OnNothingSelected { 43 | 44 | /** 45 | * 要绑定事件的控件ID 46 | * @return 控件ID 47 | */ 48 | int[] value(); 49 | 50 | /** 51 | * 所属父控件的ID 52 | * @return 控件ID 53 | */ 54 | int[] parentId() default 0; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/annotation/event/OnPreferenceChange.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.view.annotation.event; 17 | 18 | import android.preference.Preference; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * 首选项内容改变事件注解 27 | * 28 | *
29 |  * Author: wyouflf
30 |  * Date: 13-8-16
31 |  * Time: 下午2:37
32 |  * 
33 | * 34 | * @author wyouflf 35 | */ 36 | @Target(ElementType.METHOD) 37 | @Retention(RetentionPolicy.RUNTIME) 38 | @EventBase( 39 | listenerType = Preference.OnPreferenceChangeListener.class, 40 | listenerSetter = "setOnPreferenceChangeListener", 41 | methodName = "onPreferenceChange") 42 | public @interface OnPreferenceChange { 43 | 44 | /** 45 | * 要绑定事件的首选项标签名 46 | * @return 首选项标签名 47 | */ 48 | String[] value(); 49 | 50 | } 51 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/annotation/event/OnPreferenceClick.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.view.annotation.event; 17 | 18 | import android.preference.Preference; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * 首选项点击事件注解 27 | * 28 | *
29 |  * Author: wyouflf
30 |  * Date: 13-8-16
31 |  * Time: 下午2:37
32 |  * 
33 | * 34 | * @author wyouflf 35 | */ 36 | @Target(ElementType.METHOD) 37 | @Retention(RetentionPolicy.RUNTIME) 38 | @EventBase( 39 | listenerType = Preference.OnPreferenceClickListener.class, 40 | listenerSetter = "setOnPreferenceClickListener", 41 | methodName = "onPreferenceClick") 42 | public @interface OnPreferenceClick { 43 | 44 | /** 45 | * 要绑定事件的首选项标签名 46 | * @return 首选项标签名 47 | */ 48 | String[] value(); 49 | 50 | } 51 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/annotation/event/OnProgressChanged.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.view.annotation.event; 17 | 18 | import android.widget.SeekBar; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * 进度条状态改变事件注解 27 | * 28 | *
29 |  * Author: wyouflf
30 |  * Date: 13-8-16
31 |  * Time: 下午2:37
32 |  * 
33 | * 34 | * @author wyouflf 35 | */ 36 | @Target(ElementType.METHOD) 37 | @Retention(RetentionPolicy.RUNTIME) 38 | @EventBase( 39 | listenerType = SeekBar.OnSeekBarChangeListener.class, 40 | listenerSetter = "setOnSeekBarChangeListener", 41 | methodName = "onProgressChanged") 42 | public @interface OnProgressChanged { 43 | 44 | /** 45 | * 要绑定事件的控件ID 46 | * @return 控件ID 47 | */ 48 | int[] value(); 49 | 50 | /** 51 | * 所属父控件的ID 52 | * @return 控件ID 53 | */ 54 | int[] parentId() default 0; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/annotation/event/OnRadioGroupCheckedChange.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.view.annotation.event; 17 | 18 | import android.widget.RadioGroup; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * 单选按钮组选中项改变事件注解 27 | * 28 | *
29 |  * Author: wyouflf
30 |  * Date: 13-8-16
31 |  * Time: 下午2:36
32 |  * 
33 | * 34 | * @author wyouflf 35 | */ 36 | @Target(ElementType.METHOD) 37 | @Retention(RetentionPolicy.RUNTIME) 38 | @EventBase( 39 | listenerType = RadioGroup.OnCheckedChangeListener.class, 40 | listenerSetter = "setOnCheckedChangeListener", 41 | methodName = "onCheckedChanged") 42 | public @interface OnRadioGroupCheckedChange { 43 | 44 | /** 45 | * 要绑定事件的控件ID 46 | * @return 控件ID 47 | */ 48 | int[] value(); 49 | 50 | /** 51 | * 所属父控件的ID 52 | * @return 控件ID 53 | */ 54 | int[] parentId() default 0; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/annotation/event/OnScroll.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.view.annotation.event; 2 | 3 | import android.widget.AbsListView; 4 | 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | /** 11 | * 列表控件的滑动监听事件注解 12 | * 13 | *
14 |  * Author: wyouflf
15 |  * Date: 13-9-12
16 |  * Time: 下午11:25
17 |  * 
18 | * 19 | * @author wyouflf 20 | */ 21 | @Target(ElementType.METHOD) 22 | @Retention(RetentionPolicy.RUNTIME) 23 | @EventBase( 24 | listenerType = AbsListView.OnScrollListener.class, 25 | listenerSetter = "setOnScrollListener", 26 | methodName = "onScroll") 27 | public @interface OnScroll { 28 | 29 | /** 30 | * 要绑定事件的控件ID 31 | * @return 控件ID 32 | */ 33 | int[] value(); 34 | 35 | /** 36 | * 所属父控件的ID 37 | * @return 控件ID 38 | */ 39 | int[] parentId() default 0; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/annotation/event/OnScrollStateChanged.java: -------------------------------------------------------------------------------- 1 | package com.lidroid.xutils.view.annotation.event; 2 | 3 | import android.widget.AbsListView; 4 | 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | /** 11 | * 列表控件的滑动状态改变事件注解 12 | * 13 | *
14 |  * Author: wyouflf
15 |  * Date: 13-9-12
16 |  * Time: 下午11:25
17 |  * 
18 | * 19 | * @author wyouflf 20 | */ 21 | @Target(ElementType.METHOD) 22 | @Retention(RetentionPolicy.RUNTIME) 23 | @EventBase( 24 | listenerType = AbsListView.OnScrollListener.class, 25 | listenerSetter = "setOnScrollListener", 26 | methodName = "onScrollStateChanged") 27 | public @interface OnScrollStateChanged { 28 | 29 | /** 30 | * 要绑定事件的控件ID 31 | * @return 控件ID 32 | */ 33 | int[] value(); 34 | 35 | /** 36 | * 所属父控件的ID 37 | * @return 控件ID 38 | */ 39 | int[] parentId() default 0; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/annotation/event/OnStartTrackingTouch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.view.annotation.event; 17 | 18 | import android.widget.SeekBar; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * 进度条开始拖动事件注解 27 | * 28 | *
29 |  * Author: wyouflf
30 |  * Date: 13-8-16
31 |  * Time: 下午2:42
32 |  * 
33 | * 34 | * @author wyouflf 35 | */ 36 | @Target(ElementType.METHOD) 37 | @Retention(RetentionPolicy.RUNTIME) 38 | @EventBase( 39 | listenerType = SeekBar.OnSeekBarChangeListener.class, 40 | listenerSetter = "setOnSeekBarChangeListener", 41 | methodName = "onStartTrackingTouch") 42 | public @interface OnStartTrackingTouch { 43 | 44 | /** 45 | * 要绑定事件的控件ID 46 | * @return 控件ID 47 | */ 48 | int[] value(); 49 | 50 | /** 51 | * 所属父控件的ID 52 | * @return 控件ID 53 | */ 54 | int[] parentId() default 0; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/annotation/event/OnStopTrackingTouch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.view.annotation.event; 17 | 18 | import android.widget.SeekBar; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * 进度条停止拖动事件注解 27 | * 28 | *
29 |  * Author: wyouflf
30 |  * Date: 13-8-16
31 |  * Time: 下午2:42
32 |  * 
33 | * 34 | * @author wyouflf 35 | */ 36 | @Target(ElementType.METHOD) 37 | @Retention(RetentionPolicy.RUNTIME) 38 | @EventBase( 39 | listenerType = SeekBar.OnSeekBarChangeListener.class, 40 | listenerSetter = "setOnSeekBarChangeListener", 41 | methodName = "onStopTrackingTouch") 42 | public @interface OnStopTrackingTouch { 43 | 44 | /** 45 | * 要绑定事件的控件ID 46 | * @return 控件ID 47 | */ 48 | int[] value(); 49 | 50 | /** 51 | * 所属父控件的ID 52 | * @return 控件ID 53 | */ 54 | int[] parentId() default 0; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/annotation/event/OnTabChange.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.view.annotation.event; 17 | 18 | import android.widget.TabHost; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * 标签页改变事件注解 27 | * 28 | *
29 |  * Author: wyouflf
30 |  * Date: 13-8-16
31 |  * Time: 下午2:38
32 |  * 
33 | * 34 | * @author wyouflf 35 | */ 36 | @Target(ElementType.METHOD) 37 | @Retention(RetentionPolicy.RUNTIME) 38 | @EventBase( 39 | listenerType = TabHost.OnTabChangeListener.class, 40 | listenerSetter = "setOnTabChangeListener", 41 | methodName = "onTabChange") 42 | public @interface OnTabChange { 43 | 44 | /** 45 | * 要绑定事件的控件ID 46 | * @return 控件ID 47 | */ 48 | int[] value(); 49 | 50 | /** 51 | * 所属父控件的ID 52 | * @return 控件ID 53 | */ 54 | int[] parentId() default 0; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/annotation/event/OnTouch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013. wyouflf (wyouflf@gmail.com) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | package com.lidroid.xutils.view.annotation.event; 17 | 18 | import android.view.View; 19 | 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * 触摸事件注解 27 | * 28 | *
29 |  * Author: wyouflf
30 |  * Date: 13-8-16
31 |  * Time: 下午2:27
32 |  * 
33 | * 34 | * @author wyouflf 35 | */ 36 | @Target(ElementType.METHOD) 37 | @Retention(RetentionPolicy.RUNTIME) 38 | @EventBase( 39 | listenerType = View.OnTouchListener.class, 40 | listenerSetter = "setOnTouchListener", 41 | methodName = "onTouch") 42 | public @interface OnTouch { 43 | 44 | /** 45 | * 要绑定事件的控件ID 46 | * @return 控件ID 47 | */ 48 | int[] value(); 49 | 50 | /** 51 | * 所属父控件的ID 52 | * @return 控件ID 53 | */ 54 | int[] parentId() default 0; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /library/src/com/lidroid/xutils/view/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 控件IOC注入管理模块 3 | */ 4 | package com.lidroid.xutils.view; -------------------------------------------------------------------------------- /sample/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /sample/assets/img/wallpaper.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imkarl/xUtils/15b811af842d7dac8d97372a1588c223a50f881a/sample/assets/img/wallpaper.jpg -------------------------------------------------------------------------------- /sample/libs/android-support-v4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imkarl/xUtils/15b811af842d7dac8d97372a1588c223a50f881a/sample/libs/android-support-v4.jar -------------------------------------------------------------------------------- /sample/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | 22 | -keep class * extends java.lang.annotation.Annotation { *; } 23 | -keep class * extends com.example.demo.EntityBase { *; } 24 | -------------------------------------------------------------------------------- /sample/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-8 15 | android.library.reference.1=../library 16 | -------------------------------------------------------------------------------- /sample/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imkarl/xUtils/15b811af842d7dac8d97372a1588c223a50f881a/sample/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/res/drawable-ldpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imkarl/xUtils/15b811af842d7dac8d97372a1588c223a50f881a/sample/res/drawable-ldpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imkarl/xUtils/15b811af842d7dac8d97372a1588c223a50f881a/sample/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imkarl/xUtils/15b811af842d7dac8d97372a1588c223a50f881a/sample/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/res/drawable/bitmap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imkarl/xUtils/15b811af842d7dac8d97372a1588c223a50f881a/sample/res/drawable/bitmap.png -------------------------------------------------------------------------------- /sample/res/drawable/bitmap_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imkarl/xUtils/15b811af842d7dac8d97372a1588c223a50f881a/sample/res/drawable/bitmap_press.png -------------------------------------------------------------------------------- /sample/res/drawable/database.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imkarl/xUtils/15b811af842d7dac8d97372a1588c223a50f881a/sample/res/drawable/database.png -------------------------------------------------------------------------------- /sample/res/drawable/database_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imkarl/xUtils/15b811af842d7dac8d97372a1588c223a50f881a/sample/res/drawable/database_press.png -------------------------------------------------------------------------------- /sample/res/drawable/http.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imkarl/xUtils/15b811af842d7dac8d97372a1588c223a50f881a/sample/res/drawable/http.png -------------------------------------------------------------------------------- /sample/res/drawable/http_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imkarl/xUtils/15b811af842d7dac8d97372a1588c223a50f881a/sample/res/drawable/http_press.png -------------------------------------------------------------------------------- /sample/res/drawable/icon_btimap.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /sample/res/drawable/icon_database.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /sample/res/drawable/icon_http.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /sample/res/drawable/tab_background.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imkarl/xUtils/15b811af842d7dac8d97372a1588c223a50f881a/sample/res/drawable/tab_background.9.png -------------------------------------------------------------------------------- /sample/res/drawable/tab_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /sample/res/drawable/tab_item_press.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imkarl/xUtils/15b811af842d7dac8d97372a1588c223a50f881a/sample/res/drawable/tab_item_press.9.png -------------------------------------------------------------------------------- /sample/res/layout/bitmap_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | -------------------------------------------------------------------------------- /sample/res/layout/bitmap_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 12 | 16 | -------------------------------------------------------------------------------- /sample/res/layout/db_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 |