Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Icepick broken?

I've tried some very simple tests with a fragment. But Icepick does not seem to be saving the value of String test in the outState bundle...

public class MyFragment extends Fragment {
    @Icicle String test;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Icepick.restoreInstanceState(this,savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_settings, container, false);
        Log.d(TAG,"restored value of test="+test);
        return view;
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        test="I have a value";
        super.onSaveInstanceState(outState);
        Icepick.saveInstanceState(this,outState);
        Log.d(TAG, "test="+test);
   }

My gradle build looks like this:

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.my31daychallenge.mysleepchallenge"
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:design:22.2.0'
    compile 'com.jakewharton.threetenabp:threetenabp:1.0.1'
    apt 'com.bluelinelabs:logansquare-compiler:1.1.0'
    compile 'com.bluelinelabs:logansquare:1.1.0'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'frankiesardo:icepick:3.0.0'
    provided 'frankiesardo:icepick-processor:3.0.0'
}

Note, I tried the latest version of Icepick 3.0.2 and 3.0.3-SNAPSHOT, none of them worked, so I thought to use an earlier version with the same result.

and also:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven {url "https://clojars.org/repo/"}
    }
}

What am I missing?

like image 226
aajiwa Avatar asked Jul 20 '15 10:07

aajiwa


People also ask

Are ice picks still used today?

One way that the ice pick is still used today is through bartending. Bartenders go to great lengths to create new and unique beverages. In many cases a bartender will use an ice pick to create various shapes out of blocks of ice. This allows them to create a unique ice creation to add to any beverage.

What are ice picks made of?

Ice axe and ice tool picks are almost always made of a steel alloy to provide you with the most durability. The shafts, on the other hand, come in a variety of materials: Steel shafts are the most durable, but they are also the heaviest.

How do ice picks work?

The tip has a slight bend toward the flat side. If the ice pick is straight, it will penetrate the ice, chopping well. But if there is a slight bend, the tip quivers when it penetrates, shattering much more ice than a straight one could. Ice picks with different designs sound different when they pick the ice.

Is an ice pick a knife?

An ice pick is simply a metal spike attached to a short wooden handle.


2 Answers

In your build.gradle file, for this line provided 'frankiesardo:icepick-processor:3.0.0' change provided to apt. That should do the trick.

Source: https://github.com/frankiesardo/icepick/issues/56

like image 137
Ugo Avatar answered Oct 10 '22 05:10

Ugo


Ok, I literally started looking at the IcePick library 5 minutes ago so keep that in mind if this is a stupid answer :)

As of this commit https://github.com/frankiesardo/icepick/commit/f60b4b9c0307be208178381661ee13b958eda531 it looks like @State should be used instead of @Icicle. Does this solve your issue?

like image 42
aaronmarino Avatar answered Oct 10 '22 04:10

aaronmarino