MCPcopy Index your code
hub / github.com/Trinea/android-common

github.com/Trinea/android-common @v4.2.15

Chat with this repo
repository ↗ · DeepWiki ↗ · release v4.2.15 ↗ · + Follow
685 symbols 1,422 edges 73 files 535 documented · 78% updated 3mo ago1.0 · 2014-03-26★ 4,99918 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Trineaandroid-common-lib

主要包括缓存(图片缓存、预取缓存、网络缓存)、公共View(下拉及底部加载更多ListView、底部加载更多ScrollView、滑动一页Gallery)及Android常用工具类(网络、下载、Android资源操作、shell、文件、Json、随机数、Collection等等)。
示例源码:TrineaAndroidDemo
使        用:拉取代码导入IDE,右击你的工程->properties->Android,在library中选择TrineaAndroidCommon。
Api Guide:TrineaAndroidCommon API Guide

微博:Trinea    主页:trinea.cn    邮箱:trinea.cn#gmail.com    QQ:717763774

示例APK:

本地下载

一. 缓存类

主要特性:(1).使用简单 (2).轻松获取及预取取新图片 (3).包含二级缓存 (4).可选择多种缓存算法(FIFO、LIFO、LRU、MRU、LFU、MFU等13种)或自定义缓存算法 (5).可方便的保存及初始化恢复数据 (6).省流量性能佳(有且仅有一个线程获取图片) (7).支持http请求header设置及不同类型网络处理(8).可根据系统配置初始化缓存 (9).扩展性强 (10).支持等待队列 (11)包含map的大多数接口。

1. 图片缓存

使用见:图片缓存的使用
适用:获取图片较多且图片使用频繁的应用,包含二级缓存,如新浪微博、twitter、微信头像、美丽说、蘑菇街、花瓣、淘宝等等。效果图如下:
ImageCahe

2. 图片SD卡缓存

使用见:图片SD卡缓存的使用
适用:应用中获取图片较多且图片较大的情况。需要二级缓存及ListView或GridView图片加载推荐使用上面的ImageCache。效果图如下:
ImageSDCardCache

3. 网络缓存

使用见:Android网络缓存
适用:网络获取内容不大的应用,尤其是api接口数据,如新浪微博、twitter的timeline、微信公众账号发送的内容等等。效果图如下:
HttpCache

4. 预取数据缓存

使用见:预取数据缓存
缓存类关系图如下:其中HttpCache为后续计划的http缓存 Image Cache

二. 公用的view

1. 下拉刷新及滚动到底部加载更多的Listview

使用: 下拉刷新及滚动到底部加载更多listview的使用
实现原理: http://trinea.iteye.com/blog/1562281。效果图如下:
DropDownListView

2. 滑动一页(一个Item)的Gallery

使用及实现原理:滑动一页(一个Item)的Gallery的使用。效果图如下:
ViewPager1 ViewPager2

3. 滑动到底部或顶部响应的ScrollView

使用及实现原理: 滚动到底部或顶部响应的ScrollView使用。效果图如下:
ScrollView

三. 工具类

具体介绍可见:Android常用工具类
目前包括HttpUtils、DownloadManagerProShellUtilsPackageUtils、PreferencesUtils、JSONUtils、FileUtils、ResourceUtils、StringUtils、ParcelUtils、RandomUtils、ArrayUtils、ImageUtils、ListUtils、MapUtils、ObjectUtils、SerializeUtils、SystemUtils、TimeUtils。

1. Android系统下载管理DownloadManager使用

使用示例:Android系统下载管理DownloadManager功能介绍及使用示例
功能扩展:Android下载管理DownloadManager功能扩展和bug修改 效果图如下:
downloadManagerDemo

2. Android APK root权限静默安装

使用示例:Android APK root权限静默安装

3. Android root权限

直接调用ShellUtils.execCommand方法

4. 图片工具类

(1)Drawable、Bitmap、byte数组相互转换; (2)根据url获得InputStream、Drawable、Bitmap
更多工具类介绍见Android常用工具类

Proguard

-keep class cn.trinea.android.** { *; }
-keepclassmembers class cn.trinea.android.** { *; }
-dontwarn cn.trinea.android.**

License

Copyright 2013 trinea.cn

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Extension points exported contracts — how you extend this code

FileNameRule (Interface)
File name rule, used when saving images in ImageSDCardCache @author <a href="http://www.trinea.cn" target="_bla [6 implementers]
src/cn/trinea/android/common/service/FileNameRule.java
CacheFullRemoveType (Interface)
Remove type when cache is full. when cache is full, compare object is cache with this class, delete the smallest on [16 …
src/cn/trinea/android/common/service/CacheFullRemoveType.java
OnGetDataListener (Interface)
get data interface, implements this to get data @author Trinea 2012- [4 implementers]
src/cn/trinea/android/common/service/impl/PreloadDataCache.java
ImageSDCardCacheDao (Interface)
ImageSDCardCacheDao @author Trinea 2013-10-21 [2 implementers]
src/cn/trinea/android/common/dao/ImageSDCardCacheDao.java
HttpCacheDao (Interface)
HttpCacheDao @author Trinea 2013-11-04 [2 implementers]
src/cn/trinea/android/common/dao/HttpCacheDao.java

Core symbols most depended-on inside this repo

isEmpty
called by 73
src/cn/trinea/android/common/util/StringUtils.java
get
called by 51
src/cn/trinea/android/common/service/Cache.java
put
called by 37
src/cn/trinea/android/common/service/Cache.java
getEnterTime
called by 26
src/cn/trinea/android/common/entity/CacheObject.java
getUsedCount
called by 25
src/cn/trinea/android/common/entity/CacheObject.java
getData
called by 20
src/cn/trinea/android/common/entity/CacheObject.java
getString
called by 17
src/cn/trinea/android/common/util/JSONUtils.java
remove
called by 13
src/cn/trinea/android/common/service/Cache.java

Shape

Method 591
Class 81
Interface 11
Enum 2

Languages

Java100%

Modules by API surface

src/cn/trinea/android/common/view/DropDownListView.java64 symbols
src/cn/trinea/android/common/service/impl/ImageSDCardCache.java42 symbols
src/cn/trinea/android/common/service/impl/ImageCache.java41 symbols
src/cn/trinea/android/common/service/impl/PreloadDataCache.java30 symbols
src/cn/trinea/android/common/view/HorizontalListView.java29 symbols
src/cn/trinea/android/common/service/impl/ImageMemoryCache.java29 symbols
src/cn/trinea/android/common/util/HttpUtils.java26 symbols
src/cn/trinea/android/common/service/impl/SimpleCache.java26 symbols
src/cn/trinea/android/common/service/HttpCache.java24 symbols
src/cn/trinea/android/common/entity/HttpResponse.java22 symbols
src/cn/trinea/android/common/util/DownloadManagerPro.java21 symbols
src/cn/trinea/android/common/entity/CacheObject.java20 symbols

For agents

$ claude mcp add android-common \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact