# Icepick使用说明
# 废弃
[](https://circleci.com/gh/frankiesardo/icepick)
Icepick is an Android library that eliminates the boilerplate of saving and restoring instance state.
It uses annotation processing to generate code that does bundle manipulation and key generation, so that you don't have to write it yourself.
```java
class ExampleActivity extends Activity {
@State String username; // This will be automatically saved and restored
@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Icepick.restoreInstanceState(this, savedInstanceState);
}
@Override public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
Icepick.saveInstanceState(this, outState);
}
// You can put the calls to Icepick into a BaseActivity
// All Activities extending BaseActivity automatically have state saved/restored
}
```
It works for `Activities`, `Fragments` or any object that needs to serialize its state on a `Bundle` (e.g. mortar's [ViewPresenters](https://github.com/square/mortar/blob/master/mortar/src/main/java/mortar/ViewPresenter.java))
Icepick can also generate the instance state code for custom Views:
```java
class CustomView extends View {
@State int selectedPosition; // This will be automatically saved and restored
@Override public Parcelable onSaveInstanceState() {
return Icepick.saveInstanceState(this, super.onSaveInstanceState());
}
@Override public void onRestoreInstanceState(Parcelable state) {
super.onRestoreInstanceState(Icepick.restoreInstanceState(this, state));
}
// You can put the calls to Bundles into a BaseCustomView and inherit from it
// All Views extending this CustomView automatically have state saved/restored
}
```
Custom Bundler
--------
From version `3.2.0` you can supply a class parameter to the `State` annotation.
This class should implement the `Bundler` interface and you can use it to provide custom serialisation and deserialisation for your types.
```java
class MyFragment {
@State(MyCustomBundler.class) MyCustomType myCustomType;
}
class MyCustomBundler implements Bundler<MyCustomType> {
void put(String key, MyCustomType value, Bundle bundle) {
...
}
MyCustomType get(String key, Bundle bundle) {
...
}
}
```
This is useful if you want to use `icepick` in conjunction with `Parceler`.
Proguard
--------
If Proguard is enabled make sure you add these rules to your configuration:
```
-dontwarn icepick.**
-keep class icepick.** { *; }
-keep class **$$Icepick { *; }
-keepclasseswithmembernames class * {
@icepick.* <fields>;
}
```
Download
--------
Icepick needs two libraries: `icepick` and `icepick-processor`.
[](http://clojars.org/frankiesardo/icepick)
[](http://clojars.org/frankiesardo/icepick-processor)
Gradle:
```groovy
repositories {
maven {url "https://clojars.org/repo/"}
}
dependencies {
compile 'frankiesardo:icepick:{{latest-version}}'
provided 'frankiesardo:icepick-processor:{{latest-version}}'
}
```
Maven:
```xml
<repositories>
<repository>
<id>clojars</id>
<url>https://clojars.org/repo/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>frankiesardo</groupId>
<artifactId>icepick</artifactId>
<version>{{latest-version}}</version>
</dependency>
<dependency>
<groupId>frankiesardo</groupId>
<artifactId>icepick-processor</artifactId>
<version>{{latest-version}}</version>
<optional>true</optional>
</dependency>
</dependencies>
```
- 发布aar到maven仓库
- svn或gitlab代码上传规范
- maven仓库管理
- 自动构建
- Android自动构建
- Android-jenkins发布
- 规范
- Android
- Android组件模块文档
- 基础业务模块
- 智能导诊
- 科室医生
- 医院导航
- 健康资讯
- 健康百科
- 个人中心
- 外链模块
- 微信资讯
- 动态首页
- 互联网医院
- 外链模块基础版本
- 底层功能模块
- UI样式
- Http请求
- 动态功能
- 版本更新
- 支付(微信、支付宝)
- 二维码扫描
- 安全键盘
- 开发工具类模块
- icepick
- dart
- butterknife
- superRecycler
- jsonBuilder
- android-state
- iOS文档
- iOS组件模块文档
- iOS底层功能模块
- iOS弹出窗
- iOS加载框
- iOS-标准样式库
- iOS网络请求
- iOS二维码扫描
- iOS功能模块组件
- iOS健康资讯
- iOS健康百科
- iOS智能导诊
- iOS科室医生
- iOS医院导航
- iOS外链
- iOS模板(健康资讯类)
- iOS其它
- Cocoapods安装
- iOS-Cocoapods相关
- iOS-创建私有Cocoapods仓库
- 平台相关文档
- 全栈中心概述
- WEEX跨平台解决方法
- 玩转开发者平台
- android打包指南
- iOS自动化打包指南
- rubik-u web组件文档
- 开始
- 全局方法
- 列表组件
- 标题组件
- 按钮组件
- 切换组件
- 下拉框组件
- 开关/单/复选组件
- 功能列表组件
- 评星组件
- 搜索组件
- 图片上传组件
- 表单
- 表单例一
- 表单例二
- 表单例三
- 聊天组件
- 滑动刷新组件
- View窗口操作
- 面板组件
- 简单面板组件
- 信息展示面板
- 提示文字
- 底部悬浮组件
- 长文字展示组件
- 隐藏/显示面板
- 客户端组件
- 判断客户端环境
- 登录
- 等待框
- 提示框
- 时间选择器
- 扫码组件
- 拍照组件
- 访问相册组件
- 用户信息获取组件
- 返回上一页
- 返回首页
- 关闭webview
- 获取客户端类型
- 支付
- rubik-u web模板文档
- 基础组件模板
- 复选框使用案例