-1

I have three check boxes in my live wallpaper's settings that I need to figure out how to make them work, I want for example checkbox1 to execute code1, checkbox2 to execute code 2 and the last checkbox to execute code3:

code1:

private void incrementCounter() {


        if (mImagesArrayIndex >= mImagesArray.length-10) {
            mImagesArrayIndex = mImagesArray.length-10;}
            if (mImagesArrayIndex <10) {
                mImagesArrayIndex = 10;

code2:

private void incrementCounter() {


        if (mImagesArrayIndex >= mImagesArray.length-20) {
            mImagesArrayIndex = 0;}
            if (mImagesArrayIndex <0) {
                mImagesArrayIndex = mImagesArray.length-20;

            }       

            }   

code3:

 mImagesArrayIndex++;

code3 (goes into code1 and code2), codes1,2,3 are all in CustomWallpaper.java That's all, I have already set my settings layout and it looks like this:

settings screen

halfer
  • 19,824
  • 17
  • 99
  • 186
  • Add listeners to each check box. http://stackoverflow.com/questions/8386832/android-checkbox-listener – DSS Sep 11 '14 at 21:49
  • @DSS thank you sir, but it is not exactly what i am looking for. i found a solution, i don't know if it is the proper way to do it but it gets the job done, the code is in the main question thread just for those seeking the same answer, happy coding ^^ – zakaria bouhanna Sep 12 '14 at 12:02

1 Answers1

0

solution:

public void run() {

            SharedPreferences myPref = PreferenceManager.getDefaultSharedPreferences( CustomWallpaper.this);
            try {
                while (true) {
                    drawFrame();

                    if (myPref.getBoolean("lwp_o_scroll_lock_key",true)) 
                    incrementCounter1();
                    else 
                        incrementCounter2();
                    if (myPref.getBoolean("lwp_auto_animation_key",true))
                        mImagesArrayIndex++;
                    else
                        //
                //  if (myPref.getBoolean("lwp_auto_animation_key",true))
                        //incrementCounter2();

                    Thread.sleep(SeekBarPreference.mCurrentValue);
                }
            } catch (Exception e) {
                //
            }
        }