Android common lib, include ImageCache, HttpCache, DropDownListView, DownloadManager, Utils and so on

Overview

Trineaandroid-common-lib

关于我,欢迎关注
微博:Trinea    主页:trinea.cn    邮箱:trinea.cn#gmail.com    微信:codek2

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

Dev Tools App

The Dev Tools App is a powerful android development tool that can help you improve efficiency greatly, It can be used to view the latest open source projects, view activity history, view manifest, decompile, color picker, extract apk or so, view app info, open or close the options in the developer options quickly, and more.

You can download it from DevTools@Google Play.

一. 缓存类

主要特性:(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.**

Download

Gradle:

compile 'cn.trinea.android.common:trinea-android-common:4.2.15'

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.
Comments
  • 红米Note2静默卸载app失败

    红米Note2静默卸载app失败

    红米Note2(已经Root)静默卸载app失败,错误日志是:uninstallSilent successMsg:, ErrorMsg:CANNOT LINK EXECUTABLE: could not load library "libc.so" needed by "/system/bin/sh"; caused by "libc.so" is 32-bit instead of 64-bit

    opened by zhangsl 2
  • Utils Should have 2 version

    Utils Should have 2 version

    Hello,

    great work. indeed it would be great if we have 2 versions of Utils.

    1. Separate Utils which can be used individually without dependent on another Utils.
    2. Dependent Utils [the current version]

    i hope it makes clear. because sometimes a developer wants just one Utils in their project and they are ended up importing many files.

    opened by bliveinhack 1
  • API design discussion

    API design discussion

    研究了一下imagecache的code。demo app的用法是: IMAGE_SD_CACHE.get(imageUrlList.get(position), holder.imageView);

    一个建议,这个接口是不是不应该关心view呢,包括callback的接口。因为在callback的时候view和url的关系可能变化,或者view已经不可见了。如果用的人把ImageSDCardCache用成singleton的了,那么是不是可能造成view的内存泄漏呢。

    可能我的理解有误,供大家讨论吧

    opened by xiaoguaihou 1
  • HttpResponse getCacheControlMaxAge 返回值用int过小

    HttpResponse getCacheControlMaxAge 返回值用int过小

    比如缓存一个月的话 maxAge = 30 * 24 * 60 * 60 = 2592000 然后 maxAge * 1000 就超过了int的范围变成了负数,然后expireTime就永远在当前时间之前了.缓存就永远失败了.

    https://github.com/Trinea/android-common/blob/master/src/cn/trinea/android/common/entity/HttpResponse.java

    232 行改成long应该就可以了吧? 否则267行那里就会导致 maxAge * 1000 变成 -1702967296

    opened by at15 1
  • 修复部分手机静默卸载安装不生效的问题

    修复部分手机静默卸载安装不生效的问题

    部分手机上执行静默安装或者卸载不成功,错误信息是ErrorMsg:CANNOT LINK EXECUTABLE: could not load library "libc.so" needed by "/system/bin/sh"; caused by "libc.so" is 32-bit instead of 64-bit。修改后可以同时兼容32位和64位。

    opened by zhangsl 0
  • 老哥,还维护吗

    老哥,还维护吗

                ShellUtils.CommandResult result = ShellUtils.execCommand("screencap", true,true);           
                System.out.println(result.successMsg);
                System.out.println(result.errorMsg);
                System.out.println(result.result);
    

    如果这样的话就永远挂起了,没有响应,我不希望截图保存到闪存,我想直接拿到输出,但是命令返回值只有string类型的

    opened by Jinnrry 1
  • java.io.SyncFailedException: fsync failed: EINVAL (Invalid argument)

    java.io.SyncFailedException: fsync failed: EINVAL (Invalid argument)

    参数无效? 在执行ShellUtils.execCommand()时发现在控制台会有如下提示: W/System.err: java.io.SyncFailedException: fsync failed: EINVAL (Invalid argument) W/System.err: at java.io.FileDescriptor.sync(FileDescriptor.java:77) W/System.err: at java.io.FileOutputStream.flush(FileOutputStream.java:194) W/System.err: at java.io.FilterOutputStream.flush(FilterOutputStream.java:88) W/System.err: at java.io.DataOutputStream.flush(DataOutputStream.java:63)

    opened by wangkelei 1
  • 项目运行的时候报错,包依赖都没有问题

    项目运行的时候报错,包依赖都没有问题

    java.lang.RuntimeException: Unable to start activity ComponentInfo{cn.trinea.android.demo/cn.trinea.android.demo.MainActivity}: android.view.InflateException: Binary XML file line #31: Error inflating class com.google.ads.AdView

    opened by yk007 0
Releases(1.0)
Owner
Trinea
2021 滴滴、阿里内推可加我微信: trinea
Trinea
The most complete and powerful data-binding library and persistence infra for Kotlin 1.3, Android & Splitties Views DSL, JavaFX & TornadoFX, JSON, JDBC & SQLite, SharedPreferences.

Lychee (ex. reactive-properties) Lychee is a library to rule all the data. ToC Approach to declaring data Properties Other data-binding libraries Prop

Mike 112 Dec 9, 2022
VasSonic is a lightweight and high-performance Hybrid framework developed by tencent VAS team, which is intended to speed up the first screen of websites working on Android and iOS platform.

VasSonic: A Lightweight And High-performance Hybrid Framework VasSonic is a lightweight and high-performance Hybrid framework developed by tencent VAS

Tencent 11.6k Dec 30, 2022
A Job Queue specifically written for Android to easily schedule jobs (tasks) that run in the background, improving UX and application stability.

This Project is Deprecated! Thanks to everybody who've used Android Priority JobQueue. It was designed in a world where there was no JobScheduler, RxJ

Yigit Boyar 3.4k Dec 31, 2022
🚀Plugin for Android Studio And IntelliJ Idea to generate Kotlin data class code from JSON text ( Json to Kotlin )

JsonToKotlinClass Hi, Welcome! This is a plugin to generate Kotlin data class from JSON string, in another word, a plugin that converts JSON string to

Seal 2.8k Jan 3, 2023
Android app built with MVP architectural approach and uses Marvel Comics API that allows developers everywhere to access information about Marvel's vast library of comics. :zap:

Villains & Heroes Android app built with MVP architectural approach and uses Marvel Comics API that allows developers everywhere to access information

André Mion 53 Jul 13, 2022
kotlin-core - A full framework for making Android apps. Based on Anko and Kotson.

kotlin-core This package is not Android-specific, and can be used across platforms. However, for a good example of use in Android, take a look at kotl

Lightning Kite 36 Oct 3, 2022
Add new features for reverse engineering, such as: renaming of classes, fields, methods, variables, reference graphs and more.

Super JADX features Add new features for reverse engineering, such as: renaming of classes, fields, methods, variables, reference graphs and more. bas

null 284 Dec 28, 2022
Source++ is an open-source live coding platform. Add breakpoints, logs, metrics, and tracing to live production applications

Source++ is an open-source live coding platform. Add breakpoints, logs, metrics, and distributed tracing to live production software in real-time on-d

Source++ 40 Dec 14, 2022
Android part of the Android Studio(IntellijIDEA) OkHttp Profiler plugin

OkHttpProfiler Android Library Created by LocaleBro.com - Android Localization Platform The OkHttp Profiler plugin can show requests from the OkHttp l

Ievgenii 261 Dec 8, 2022
A Model-View-Presenter / Model-View-Intent library for modern Android apps

Mosby A Model-View-Presenter and Model-View-Intent library for Android apps. Dependency dependencies { compile 'com.hannesdorfmann.mosby3:mvi:3.1.1

Hannes Dorfmann 5.5k Dec 25, 2022
dexposed enable 'god' mode for single android application.

What is it? Dexposed is a powerful yet non-invasive runtime AOP (Aspect-oriented Programming) framework for Android app development, based on the work

Alibaba 4.5k Dec 28, 2022
A small, yet full-featured framework that allows building View-based Android applications

Conductor A small, yet full-featured framework that allows building View-based Android applications. Conductor provides a light-weight wrapper around

BlueLine Labs 3.9k Jan 6, 2023
A plugin system that runs like a browser, but instead of load web pages, it load apk plugins which runs natively on Android system.

Android Dynamic Loader Android Dynamic Loader is a plugin system. The host application is like a browser, but instead of load web pages, it load plugi

Tu Yimin 1.4k Dec 28, 2022
Nucleus is an Android library, which utilizes the Model-View-Presenter pattern to properly connect background tasks with visual parts of an application.

Nucleus Deprecation notice Nucleus is not under develpment anymore. It turns out that Redux architecture scales way better than MVP/MVI/MVVM/MVxxx and

Konstantin Mikheev 2k Nov 18, 2022
LiteOrm is a fast, small, powerful ORM framework for Android. LiteOrm makes you do CRUD operarions on SQLite database with a sigle line of code efficiently.

#LiteOrm:Android高性能数据库框架 A fast, small, powerful ORM framework for Android. LiteOrm makes you do CRUD operarions on SQLite database with a sigle line

马天宇 1.5k Nov 19, 2022
Kick-starts Android application development.

Synopsis If you've made it here, chances are you are not quite as satisfied with the Android application framework as you could be. Same for us, that'

Matthias Käppler 1.3k Dec 4, 2022
Rosie is an Android framework to create applications following the principles of Clean Architecture.

Rosie The only way to make the deadline—the only way to go fast—is to keep the code as clean as possible at all times. — Robert C. Martin in Clean Cod

Karumi 1.8k Dec 28, 2022
Create kotlin android project with one line of command.

README This is an android application template project built with kotlin language and some useful libraries. It provides a creator script to quickly c

nekocode 1.6k Dec 20, 2022
Moxy is MVP library for Android

Moxy This Moxy repository is deprecated and no longer supported. Please migrate to the actual version of the Moxy framework at Moxy communuty repo. De

Arello Mobile 1.6k Dec 28, 2022