Example usage for android.widget ImageView getBackground

List of usage examples for android.widget ImageView getBackground

Introduction

In this page you can find the example usage for android.widget ImageView getBackground.

Prototype

public Drawable getBackground() 

Source Link

Document

Gets the background drawable

Usage

From source file:com.github.colorchief.colorchief.MainActivity.java

public void resetColorControl(View view) {
    ImageView colourBlock21 = (ImageView) findViewById(R.id.colour21);
    ColorDrawable colourDrawable = (ColorDrawable) colourBlock21.getBackground();
    int[] verticeCoords = colorLUT.getNearestVerticeCoords(colourDrawable.getColor());

    int resetColor = colorLUT.getLUTElement(verticeCoords[0], verticeCoords[1], verticeCoords[2]);

    ImageView colourBlock22 = (ImageView) findViewById(R.id.colour22);
    colourBlock22.setBackgroundColor(resetColor);
}

From source file:com.github.colorchief.colorchief.MainActivity.java

public void acceptButtonClick(View view) {
    LinearLayout overlayColorControl = (LinearLayout) findViewById(R.id.overlayColorControl);
    overlayColorControl.setVisibility(LinearLayout.INVISIBLE);
    ImageView colourBlock22 = (ImageView) findViewById(R.id.colour22);
    ColorDrawable colourDrawable = (ColorDrawable) colourBlock22.getBackground();
    int setColour = colourDrawable.getColor();
    colorLUT.setLUTElement(verticeCoords[0], verticeCoords[1], verticeCoords[2], setColour);
    colorControlVerticesX.add(verticeCoords[0]);
    colorControlVerticesY.add(verticeCoords[1]);
    colorControlVerticesZ.add(verticeCoords[2]);
    colorControlOutputColors.add(setColour);

    transformImage();//w  w  w .  j  a v a2s.  co m
    updateImageViewer();
}

From source file:com.github.colorchief.colorchief.MainActivity.java

public void hsvButtonClick(View view) {
    ImageView colourBlock22 = (ImageView) findViewById(R.id.colour22);
    ColorDrawable colourDrawable = (ColorDrawable) colourBlock22.getBackground();
    int setColour = colourDrawable.getColor();
    int newColour = 0;
    float hsvColour[] = new float[3];
    Color.colorToHSV(setColour, hsvColour);

    if (view.getId() == R.id.hueDownButton) {

        //Log.d(TAG, "Hue Down Button Clicked");

        hsvColour[0] = hsvColour[0] - H_ADJUST;
        if (hsvColour[0] < 0f)
            hsvColour[0] = 360f + hsvColour[0];

    }/*from ww w.ja v a  2  s.  co  m*/
    if (view.getId() == R.id.hueUpButton) {
        //Log.d(TAG, "Hue Up Button Clicked");

        hsvColour[0] = hsvColour[0] + H_ADJUST;
        if (hsvColour[0] > 360f)
            hsvColour[0] = hsvColour[0] - 360f;

    }
    if (view.getId() == R.id.saturationDownButton) {
        //Log.d(TAG, "Saturation Down Button Clicked");

        hsvColour[1] = hsvColour[1] - S_ADJUST;
        //if (hsvColour[1] < 0f ) hsvColour[1] = 1f + hsvColour[1];
        if (hsvColour[1] < 0f)
            hsvColour[1] = 0f;

    }
    if (view.getId() == R.id.saturationUpButton) {
        //Log.d(TAG, "Saturation Up Button Clicked");

        hsvColour[1] = hsvColour[1] + S_ADJUST;
        //if (hsvColour[1] > 1f ) hsvColour[1] = hsvColour[1] - 1f;
        if (hsvColour[1] > 1f)
            hsvColour[1] = 1f;

    }
    if (view.getId() == R.id.lightnessDownButton) {
        //Log.d(TAG, "Lightness Down Button Clicked");

        hsvColour[2] = hsvColour[2] - V_ADJUST;
        //if (hsvColour[2] < 0f ) hsvColour[2] = 1f + hsvColour[2];
        if (hsvColour[2] < 0f)
            hsvColour[2] = 0f;

    }
    if (view.getId() == R.id.lightnessUpButton) {
        //Log.d(TAG, "Lightness Up Button Clicked");

        hsvColour[2] = hsvColour[2] + V_ADJUST;
        //if (hsvColour[2] > 1f ) hsvColour[2] = hsvColour[2] - 1f;
        if (hsvColour[2] > 1f)
            hsvColour[2] = 1f;
    }

    newColour = Color.HSVToColor(hsvColour);
    colourBlock22.setBackgroundColor(newColour);

}

From source file:lu.fisch.canze.activities.MainActivity.java

private void setBluetoothState(int btState) {
    if (bluetoothMenutItem != null) {
        final ImageView imageView = (ImageView) bluetoothMenutItem.getActionView()
                .findViewById(R.id.animated_menu_item_action);

        // stop the animation if there is one running
        AnimationDrawable frameAnimation;
        if (imageView.getBackground() instanceof AnimationDrawable) {
            frameAnimation = (AnimationDrawable) imageView.getBackground();
            if (frameAnimation.isRunning())
                frameAnimation.stop();//from   w  ww .ja  va2s . c  o m
        }

        switch (btState) {
        case BLUETOOTH_DISCONNECTED:
            imageView.setBackgroundResource(R.mipmap.bluetooth_none);
            break;
        case BLUETOOTH_CONNECTED:
            imageView.setBackgroundResource(R.mipmap.bluetooth_3);
            break;
        case BLUETOOTH_SEARCH:
            runOnUiThread(new Runnable() {
                @SuppressLint("NewApi")
                @Override
                public void run() {
                    AnimationDrawable drawable = (AnimationDrawable) ContextCompat
                            .getDrawable(getApplicationContext(), R.anim.animation_bluetooth);
                    // Use setBackgroundDrawable() for API 14 and 15 and setBackground() for API 16+:
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                        imageView.setBackground(drawable);
                    } else {
                        //noinspection deprecation
                        imageView.setBackgroundDrawable(drawable);
                    }
                    AnimationDrawable frameAnimation = (AnimationDrawable) imageView.getBackground();
                    frameAnimation.start();
                }
            });
            break;
        default:
            break;
        }
    }
}

From source file:com.andrada.sitracker.ui.fragment.PublicationInfoFragment.java

private void setOrAnimateReadPubIcon(final ImageView imageView, PublicationState currentState,
        boolean allowAnimate) {
    final int imageResId = currentState.equals(PublicationState.READY_FOR_READING)
            ? R.drawable.read_pub_button_icon_checked
            : currentState.equals(PublicationState.DOWNLOADING) ? R.drawable.download_pub_icon_fab_up
                    : R.drawable.read_pub_button_icon_unchecked;

    if (imageView.getTag() != null) {
        if (imageView.getTag() instanceof Animator) {
            Animator anim = (Animator) imageView.getTag();
            anim.end();//  w ww  .j  a v  a 2  s . co  m
            ViewHelper.setAlpha(imageView, 1f);
        }
    }
    /*
    if (imageView.getBackground() instanceof AnimationDrawable) {
    AnimationDrawable frameAnimation = (AnimationDrawable) imageView.getBackground();
    frameAnimation.stop();
    imageView.setBackgroundResource(0);
    }*/

    if (allowAnimate && currentState.equals(PublicationState.DOWNLOADING)) {
        int duration = getResources().getInteger(android.R.integer.config_shortAnimTime);
        Animator outAnimator = ObjectAnimator.ofFloat(imageView, "alpha", 0f);
        outAnimator.setDuration(duration);
        outAnimator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                imageView.setImageDrawable(null);
                imageView.setBackgroundResource(imageResId);
                Drawable frameAnimation = imageView.getBackground();
                if (frameAnimation instanceof AnimationDrawable) {
                    ((AnimationDrawable) frameAnimation).start();
                }
            }
        });

        ObjectAnimator inAnimator = ObjectAnimator.ofFloat(imageView, "alpha", 1f);
        inAnimator.setDuration(duration * 2);
        final AnimatorSet set = new AnimatorSet();
        set.playSequentially(outAnimator, inAnimator);
        set.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                imageView.setTag(null);
            }
        });
        imageView.setTag(set);
        set.start();

    } else if (allowAnimate && currentState.equals(PublicationState.READY_FOR_READING)) {
        int duration = getResources().getInteger(android.R.integer.config_shortAnimTime);
        Animator outAnimator = ObjectAnimator.ofFloat(imageView, "alpha", 0f);
        outAnimator.setDuration(duration);
        outAnimator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                imageView.setBackgroundResource(0);
                imageView.setImageResource(imageResId);
            }
        });
        ObjectAnimator inAnimator = ObjectAnimator.ofFloat(imageView, "alpha", 1f);
        inAnimator.setDuration(duration * 2);
        final AnimatorSet set = new AnimatorSet();
        set.playSequentially(outAnimator, inAnimator);
        set.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                imageView.setTag(null);
            }
        });
        imageView.setTag(set);
        set.start();
    } else if (!allowAnimate && currentState.equals(PublicationState.DOWNLOADING)) {
        mHandler.post(new Runnable() {
            @Override
            public void run() {
                imageView.setImageDrawable(null);
                imageView.setBackgroundResource(imageResId);
                AnimationDrawable frameAnimation = (AnimationDrawable) imageView.getBackground();
                frameAnimation.start();
            }
        });
    } else {
        mHandler.post(new Runnable() {
            @Override
            public void run() {
                imageView.setBackgroundResource(0);
                imageView.setImageResource(imageResId);
            }
        });
    }
}

From source file:com.android.tv.settings.dialog.old.BaseDialogFragment.java

public void performEntryTransition(final Activity activity, final ViewGroup contentView, int iconResourceId,
        Uri iconResourceUri, final ImageView icon, final TextView title, final TextView description,
        final TextView breadcrumb) {
    // Pull out the root layout of the dialog and set the background drawable, to be
    // faded in during the transition.
    final ViewGroup twoPane = (ViewGroup) contentView.getChildAt(0);
    twoPane.setVisibility(View.INVISIBLE);

    // If the appropriate data is embedded in the intent and there is an icon specified
    // in the content fragment, we animate the icon from its initial position to the final
    // position. Otherwise, we perform a simpler transition in which the ActionFragment
    // slides in and the ContentFragment text fields slide in.
    mIntroAnimationInProgress = true;// w w  w  . java2  s.c  o  m
    List<TransitionImage> images = TransitionImage.readMultipleFromIntent(activity, activity.getIntent());
    TransitionImageAnimation ltransitionAnimation = null;
    final Uri iconUri;
    final int color;
    if (images != null && images.size() > 0) {
        if (iconResourceId != 0) {
            iconUri = Uri.parse(UriUtils.getAndroidResourceUri(activity, iconResourceId));
        } else if (iconResourceUri != null) {
            iconUri = iconResourceUri;
        } else {
            iconUri = null;
        }
        TransitionImage src = images.get(0);
        color = src.getBackground();
        if (iconUri != null) {
            ltransitionAnimation = new TransitionImageAnimation(contentView);
            ltransitionAnimation.addTransitionSource(src);
            ltransitionAnimation.transitionDurationMs(ANIMATE_IN_DURATION).transitionStartDelayMs(0)
                    .interpolator(new DecelerateInterpolator(1f));
        }
    } else {
        iconUri = null;
        color = 0;
    }
    final TransitionImageAnimation transitionAnimation = ltransitionAnimation;

    // Fade out the old activity, and hard cut the new activity.
    activity.overridePendingTransition(R.anim.hard_cut_in, R.anim.fade_out);

    int bgColor = mFragment.getResources().getColor(R.color.dialog_activity_background);
    mBgDrawable.setColor(bgColor);
    mBgDrawable.setAlpha(0);
    twoPane.setBackground(mBgDrawable);

    // If we're animating the icon, we create a new ImageView in which to place the embedded
    // bitmap. We place it in the root layout to match its location in the previous activity.
    mShadowLayer = (FrameLayoutWithShadows) twoPane.findViewById(R.id.shadow_layout);
    if (transitionAnimation != null) {
        transitionAnimation.listener(new TransitionImageAnimation.Listener() {
            @Override
            public void onRemovedView(TransitionImage src, TransitionImage dst) {
                if (icon != null) {
                    //want to make sure that users still see at least the source image
                    // if the dst image is too large to finish downloading before the
                    // animation is done. Check if the icon is not visible. This mean
                    // BaseContentFragement have not finish downloading the image yet.
                    if (icon.getVisibility() != View.VISIBLE) {
                        icon.setImageDrawable(src.getBitmap());
                        int intrinsicWidth = icon.getDrawable().getIntrinsicWidth();
                        LayoutParams lp = icon.getLayoutParams();
                        lp.height = lp.width * icon.getDrawable().getIntrinsicHeight() / intrinsicWidth;
                        icon.setVisibility(View.VISIBLE);
                    }
                    icon.setAlpha(1f);
                }
                if (mShadowLayer != null) {
                    mShadowLayer.setShadowsAlpha(1f);
                }
                onIntroAnimationFinished();
            }
        });
        icon.setAlpha(0f);
        if (mShadowLayer != null) {
            mShadowLayer.setShadowsAlpha(0f);
        }
    }

    // We need to defer the remainder of the animation preparation until the first
    // layout has occurred, as we don't yet know the final location of the icon.
    twoPane.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            twoPane.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            // if we buildLayer() at this time,  the texture is actually not created
            // delay a little so we can make sure all hardware layer is created before
            // animation, in that way we can avoid the jittering of start animation
            twoPane.postOnAnimationDelayed(mEntryAnimationRunnable, ANIMATE_DELAY);
        }

        final Runnable mEntryAnimationRunnable = new Runnable() {
            @Override
            public void run() {
                if (!mFragment.isAdded()) {
                    // We have been detached before this could run, so just bail
                    return;
                }

                twoPane.setVisibility(View.VISIBLE);
                final int secondaryDelay = SLIDE_IN_DISTANCE;

                // Fade in the activity background protection
                ObjectAnimator oa = ObjectAnimator.ofInt(mBgDrawable, "alpha", 255);
                oa.setDuration(ANIMATE_IN_DURATION);
                oa.setStartDelay(secondaryDelay);
                oa.setInterpolator(new DecelerateInterpolator(1.0f));
                oa.start();

                View actionFragmentView = activity.findViewById(mActionAreaId);
                boolean isRtl = ViewCompat.getLayoutDirection(contentView) == ViewCompat.LAYOUT_DIRECTION_RTL;
                int startDist = isRtl ? SLIDE_IN_DISTANCE : -SLIDE_IN_DISTANCE;
                int endDist = isRtl ? -actionFragmentView.getMeasuredWidth()
                        : actionFragmentView.getMeasuredWidth();

                // Fade in and slide in the ContentFragment TextViews from the start.
                prepareAndAnimateView(title, 0, startDist, secondaryDelay, ANIMATE_IN_DURATION,
                        new DecelerateInterpolator(1.0f), false);
                prepareAndAnimateView(breadcrumb, 0, startDist, secondaryDelay, ANIMATE_IN_DURATION,
                        new DecelerateInterpolator(1.0f), false);
                prepareAndAnimateView(description, 0, startDist, secondaryDelay, ANIMATE_IN_DURATION,
                        new DecelerateInterpolator(1.0f), false);

                // Fade in and slide in the ActionFragment from the end.
                prepareAndAnimateView(actionFragmentView, 0, endDist, secondaryDelay, ANIMATE_IN_DURATION,
                        new DecelerateInterpolator(1.0f), false);

                if (icon != null && transitionAnimation != null) {
                    // now we get the icon view in place,  update the transition target
                    TransitionImage target = new TransitionImage();
                    target.setUri(iconUri);
                    target.createFromImageView(icon);
                    if (icon.getBackground() instanceof ColorDrawable) {
                        ColorDrawable d = (ColorDrawable) icon.getBackground();
                        target.setBackground(d.getColor());
                    }
                    transitionAnimation.addTransitionTarget(target);
                    transitionAnimation.startTransition();
                } else if (icon != null) {
                    prepareAndAnimateView(icon, 0, startDist, secondaryDelay, ANIMATE_IN_DURATION,
                            new DecelerateInterpolator(1.0f), true /* is the icon */);
                    if (mShadowLayer != null) {
                        mShadowLayer.setShadowsAlpha(0f);
                    }
                }
            }
        };
    });
}

From source file:com.zoffcc.applications.zanavi.Navit.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    ////from  w  ww.j a  v a2s. com
    menu.clear();

    // load the menu from XML
    getMenuInflater().inflate(R.menu.actionbaricons, menu);

    // NavitOverflowMenuItemID = R.id.item_overflow_menu_button;
    menu.findItem(R.id.share_menu_destination).setTitle(Navit.get_text("Share Destination"));
    menu.findItem(R.id.share_menu_location).setTitle(Navit.get_text("Share my Location"));
    menu.findItem(R.id.search_menu_offline).setTitle(get_text("address search (offline)"));
    menu.findItem(R.id.search_menu_online).setTitle(get_text("address search (online)"));
    menu.findItem(R.id.item_recentdest_menu_button).setTitle(get_text("Recent destinations"));
    menu.findItem(R.id.item_settings_menu_button).setTitle(get_text("Settings"));
    menu.findItem(R.id.item_search_menu_button).setTitle(get_text("Search"));

    // --- download icon ---
    menu.findItem(R.id.item_download_menu_button).setTitle(get_text("downloading map"));
    // --- download icon ---

    //
    menu.findItem(R.id.overflow_share_location).setTitle(Navit.get_text("Share my Location"));
    menu.findItem(R.id.overflow_share_destination).setTitle(Navit.get_text("Share Destination"));
    menu.findItem(R.id.overflow_settings).setTitle(Navit.get_text("Settings"));
    menu.findItem(R.id.overflow_zoom_to_route).setTitle(Navit.get_text("Zoom to Route"));

    if (ZANaviNormalDonateActivity.on_amazon_device) {
        menu.findItem(R.id.overflow_donate_item).setTitle(Navit.get_text("Donate"));
    } else {
        menu.findItem(R.id.overflow_donate_item).setTitle(Navit.get_text("Donate with Google Play"));
    }
    menu.findItem(R.id.overflow_donate_bitcoins_item).setTitle(Navit.get_text("Donate with Bitcoin"));
    //. TRANSLATORS: text to translate is: exit ZANavi
    menu.findItem(R.id.overflow_exit).setTitle(Navit.get_text("exit navit"));
    menu.findItem(R.id.overflow_toggle_poi).setTitle(Navit.get_text("toggle POI"));
    menu.findItem(R.id.overflow_announcer_on).setTitle(Navit.get_text("Announcer On"));
    menu.findItem(R.id.overflow_announcer_off).setTitle(Navit.get_text("Announcer Off"));
    menu.findItem(R.id.overflow_download_maps).setTitle(Navit.get_text("download maps"));
    menu.findItem(R.id.overflow_delete_maps).setTitle(Navit.get_text("delete maps"));
    menu.findItem(R.id.overflow_maps_age).setTitle(Navit.get_text("show Maps age"));
    menu.findItem(R.id.overflow_coord_dialog).setTitle(Navit.get_text("Coord Dialog"));
    menu.findItem(R.id.overflow_add_traffic_block).setTitle(Navit.get_text("add Traffic block"));
    menu.findItem(R.id.overflow_clear_traffic_block).setTitle(Navit.get_text("clear Traffic blocks"));
    menu.findItem(R.id.overflow_convert_gpx_file).setTitle(Navit.get_text("convert GPX file"));
    menu.findItem(R.id.overflow_replay_gps_file).setTitle(Navit.get_text("replay a ZANavi gps file"));
    menu.findItem(R.id.overflow_yaml_tests).setTitle(Navit.get_text("run YAML tests"));
    menu.findItem(R.id.overflow_clear_gpx_map).setTitle(Navit.get_text("clear GPX map"));
    // menu.findItem(R.id.overflow_dummy2)
    menu.findItem(R.id.overflow_demo_v_normal).setTitle(get_text("Demo Vehicle") + " [normal]");
    menu.findItem(R.id.overflow_demo_v_fast).setTitle(get_text("Demo Vehicle") + " [fast]");
    menu.findItem(R.id.overflow_speech_texts).setTitle(Navit.get_text("Speech Texts"));
    menu.findItem(R.id.overflow_nav_commands).setTitle(Navit.get_text("Nav. Commands"));
    menu.findItem(R.id.overflow_toggle_route_graph).setTitle(Navit.get_text("toggle Routegraph"));
    //menu.findItem(R.id.overflow_dummy1)
    menu.findItem(R.id.overflow_export_map_points_to_sdcard).setTitle(Navit.get_text("export Destinations"));
    menu.findItem(R.id.overflow_import_map_points_from_sdcard).setTitle(Navit.get_text("import Destinations"));
    menu.findItem(R.id.overflow_send_feedback).setTitle(Navit.get_text("send feedback"));
    menu.findItem(R.id.overflow_online_help).setTitle(Navit.get_text("online Help"));
    menu.findItem(R.id.overflow_about).setTitle(Navit.get_text("About"));
    //. TRANSLATORS: it means: "show current target in google maps"
    //. TRANSLATORS: please keep this text short, to fit in the android menu!
    menu.findItem(R.id.overflow_target_in_gmaps).setTitle(Navit.get_text("Target in gmaps"));
    //
    //
    menu.findItem(R.id.item_share_menu_button).setTitle(get_text("Share"));

    Display display_ = getWindowManager().getDefaultDisplay();
    Log.e("Navit", "Navit width in DP -> " + display_.getWidth() / Navit.metrics.density);
    Log.e("Navit", "Navit width in DP -> density=" + Navit.metrics.density);

    try {
        View v4 = findViewById(R.id.item_settings_menu_button);
        // Log.e("Navit", "Navit width in DP -> v4=" + v4);
        if ((v4 != null) && (v4.getWidth() > 0)) {
            Log.e("Navit", "Navit width in DP -> v4.w=" + v4.getWidth());
            MenuItem menuItem = menu.findItem(R.id.item_settings_menu_button);
            // Log.e("Navit", "Navit width in DP -> mi=" + menuItem);
            // Log.e("Navit", "Navit width in DP -> i=" + menuItem.getIcon());
            Log.e("Navit", "Navit width in DP -> i.w=" + menuItem.getIcon().getIntrinsicWidth());
            actionbar_item_width = (int) ((v4.getWidth() + (menuItem.getIcon().getIntrinsicWidth() * 1.5f))
                    / 2);
        } else {
            MenuItem menuItem = menu.findItem(R.id.item_settings_menu_button);
            // Log.e("Navit", "Navit width in DP -> mi=" + menuItem);
            // Log.e("Navit", "Navit width in DP -> i=" + menuItem.getIcon());
            Log.e("Navit", "Navit width in DP -> i.w=" + menuItem.getIcon().getIntrinsicWidth());
            actionbar_item_width = (int) ((menuItem.getIcon().getIntrinsicWidth()) * 1.7f);
        }

        actionbar_items_will_fit = display_.getWidth() / actionbar_item_width;
        Log.e("Navit", "Navit width in DP -> number of items that will fit=" + actionbar_items_will_fit);
        if (actionbar_items_will_fit > 6) // now we need to fit max. 6 items on actionbar
        {
            actionbar_all_items_will_fit = true;
        } else {
            actionbar_all_items_will_fit = false;
        }
    } catch (Exception e) {
        if ((display_.getWidth() / Navit.metrics.density) < NAVIT_MIN_HORIZONTAL_DP_FOR_ACTIONBAR) {
            actionbar_all_items_will_fit = false;
        } else {
            actionbar_all_items_will_fit = true;
        }
    }

    if (actionbar_all_items_will_fit == false) {
        menu.findItem(R.id.item_share_menu_button).setVisible(false);
        menu.findItem(R.id.overflow_share_location).setVisible(true);
        if (NavitGraphics.CallbackDestinationValid2() == 0) {
            menu.findItem(R.id.overflow_share_destination).setVisible(false);
        } else {
            menu.findItem(R.id.overflow_share_destination).setVisible(true);
        }

        if (actionbar_items_will_fit < 6) {
            // also push the settings icons to overflow menu
            menu.findItem(R.id.item_settings_menu_button).setVisible(false);
            menu.findItem(R.id.overflow_settings).setVisible(true);
        } else {
            menu.findItem(R.id.item_settings_menu_button).setVisible(true);
            menu.findItem(R.id.overflow_settings).setVisible(false);
        }
    } else {
        menu.findItem(R.id.item_settings_menu_button).setVisible(true);
        menu.findItem(R.id.overflow_settings).setVisible(false);
        menu.findItem(R.id.overflow_share_location).setVisible(false);
        menu.findItem(R.id.overflow_share_destination).setVisible(false);
        menu.findItem(R.id.item_share_menu_button).setVisible(true);
    }

    cur_menu = menu;

    System.out.println("down_icon:000");

    try {
        MenuItem downloadViewMenuItem = menu.findItem(R.id.item_download_menu_button);
        System.out.println("down_icon:001");
        downloadViewMenuItem.setVisible(true);
        System.out.println("down_icon:002");
        System.out.println("down_icon:003");
        android.widget.ImageView v = (android.widget.ImageView) MenuItemCompat
                .getActionView(menu.findItem(R.id.item_download_menu_button));
        System.out.println("down_icon:004");
        v.setVisibility(View.VISIBLE);
        if (v != null) {
            System.out.println("down_icon:005");
            v.setImageBitmap(null);
            System.out.println("down_icon:006");

            v.setBackgroundResource(R.drawable.anim_download_icon_2);
            final AnimationDrawable anim = (AnimationDrawable) v.getBackground();

            // ----------------------------------
            // thanks to: http://stackoverflow.com/questions/14686802/animationdrawable-is-not-working-on-2-3-6-android-version
            // ----------------------------------
            v.post(new Runnable() {
                public void run() {
                    try {
                        anim.start();
                        System.out.println("down_icon:006a");
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });

            System.out.println("down_icon:007");

            v.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Intent mapdownload_cancel_activity = new Intent(Navit.this,
                            ZANaviDownloadMapCancelActivity.class);
                    mapdownload_cancel_activity
                            .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
                    startActivity(mapdownload_cancel_activity);
                }
            });
        }
    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("down_icon:099:EE");
    }

    if (actionabar_download_icon_visible) {
        menu.findItem(R.id.item_download_menu_button).setVisible(true);
    } else {
        menu.findItem(R.id.item_download_menu_button).setVisible(false);
    }

    if (NavitGraphics.CallbackDestinationValid2() > 0) {
        menu.findItem(R.id.item_endnavigation_menu_button).setVisible(true);
        menu.findItem(R.id.item_endnavigation_menu_button).setTitle(get_text("Stop Navigation"));
        menu.findItem(R.id.overflow_zoom_to_route).setVisible(true);
        menu.findItem(R.id.overflow_target_in_gmaps).setVisible(true);
        menu.findItem(R.id.share_menu_destination).setVisible(true);
    } else {
        menu.findItem(R.id.item_endnavigation_menu_button).setVisible(false);
        menu.findItem(R.id.overflow_zoom_to_route).setVisible(false);
        menu.findItem(R.id.overflow_target_in_gmaps).setVisible(false);
        menu.findItem(R.id.share_menu_destination).setVisible(false);
    }

    if (Navit_Announcer == true) {
        menu.findItem(R.id.overflow_announcer_off).setVisible(true);
        menu.findItem(R.id.overflow_announcer_on).setVisible(false);
    } else {
        menu.findItem(R.id.overflow_announcer_off).setVisible(false);
        menu.findItem(R.id.overflow_announcer_on).setVisible(true);
    }

    if (p.PREF_enable_debug_functions) {
        menu.findItem(R.id.overflow_dummy2).setVisible(true);
        menu.findItem(R.id.overflow_demo_v_normal).setVisible(true);
        menu.findItem(R.id.overflow_demo_v_fast).setVisible(true);
        menu.findItem(R.id.overflow_speech_texts).setVisible(true);
        menu.findItem(R.id.overflow_nav_commands).setVisible(true);
        menu.findItem(R.id.overflow_toggle_route_graph).setVisible(true);
        menu.findItem(R.id.overflow_replay_gps_file).setVisible(true);
        menu.findItem(R.id.overflow_yaml_tests).setVisible(true);
    } else {
        menu.findItem(R.id.overflow_dummy2).setVisible(false);
        menu.findItem(R.id.overflow_demo_v_normal).setVisible(false);
        menu.findItem(R.id.overflow_demo_v_fast).setVisible(false);
        menu.findItem(R.id.overflow_speech_texts).setVisible(false);
        menu.findItem(R.id.overflow_nav_commands).setVisible(false);
        menu.findItem(R.id.overflow_toggle_route_graph).setVisible(false);
        menu.findItem(R.id.overflow_replay_gps_file).setVisible(false);
        menu.findItem(R.id.overflow_yaml_tests).setVisible(false);
    }

    return true;
}