public void back_butt_clicked(View v) {
    Toast.makeText(ShopPageClicked.this, "back_butt_clicked", Toast.LENGTH_SHORT).show();
    getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    getSupportActionBar().setCustomView(R.layout.custom_action_bar);
    ImageView im_shop = (ImageView) findViewById(R.id.shop_icon);
    im_shop.setImageDrawable(getResources().getDrawable(R.drawable.shop_selected));
    rl_front.setVisibility(View.VISIBLE);
    System.out.println("back button clicked");
    TranslateAnimation tanim1 =
        new TranslateAnimation(
            TranslateAnimation.RELATIVE_TO_PARENT,
            0,
            TranslateAnimation.RELATIVE_TO_PARENT,
            0,
            TranslateAnimation.ABSOLUTE,
            0,
            TranslateAnimation.ABSOLUTE,
            ((RelativeLayout) rl_front.getParent()).getHeight());

    tanim1.setDuration(400);
    tanim1.setFillAfter(false);
    tanim1.setAnimationListener(
        new AnimationListener() {

          @Override
          public void onAnimationStart(Animation animation) {
            // TODO Auto-generated method stub

          }

          @Override
          public void onAnimationRepeat(Animation animation) {
            // TODO Auto-generated method stub

          }

          @Override
          public void onAnimationEnd(Animation animation) {
            // TODO Auto-generated method stub
            lin_anim.setVisibility(View.GONE);
            rl_front.requestFocus();
            // rl_front.setVisibility(View.VISIBLE);
            System.out.println("anim end");
          }
        });
    tanim1.setInterpolator(new DecelerateInterpolator());
    lin_anim.setAnimation(tanim1);
  }
  public void apply_filter_butt_clicked(View v) {
    getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    getSupportActionBar().setCustomView(R.layout.custom_action_bar);
    ImageView im_shop = (ImageView) findViewById(R.id.shop_icon);
    im_shop.setImageDrawable(getResources().getDrawable(R.drawable.shop_selected));
    ArrayList<Model> selected_men_models = new ArrayList<Model>();
    ArrayList<Model> selected_women_models = new ArrayList<Model>();
    ArrayList<Model> selected_kids_models = new ArrayList<Model>();
    ArrayList<String> selected_strings = new ArrayList<String>();
    selected_men_models = (ArrayList<Model>) adapter_active_men.getListModels();
    selected_women_models = (ArrayList<Model>) adapter_active_women.getListModels();
    selected_kids_models = (ArrayList<Model>) adapter_active_kids.getListModels();
    for (int i = 0; i < selected_men_models.size(); ++i) {
      String tmp = selected_men_models.get(i).getName();
      tmp = tmp.toLowerCase();
      tmp = tmp.replaceAll("\\s+", "");
      selected_strings.add("m_" + tmp);
    }
    for (int i = 0; i < selected_women_models.size(); ++i) {
      String tmp = selected_women_models.get(i).getName();
      tmp = tmp.toLowerCase();
      tmp = tmp.replaceAll("\\s+", "");
      selected_strings.add("w_" + tmp);
    }
    for (int i = 0; i < selected_kids_models.size(); ++i) {
      String tmp = selected_kids_models.get(i).getName();
      tmp = tmp.toLowerCase();
      tmp = tmp.replaceAll("\\s+", "");
      selected_strings.add("k_" + tmp);
    }
    if (selected_strings.size() > 0) {
      shop_list = new ArrayList<ShopInfo>();
      for (int i = 0; i < selected_strings.size(); ++i) {
        for (int j = 0; j < unchangeable_shop_list.size(); ++j) {
          String cat_all = unchangeable_shop_list.get(j).categories;
          System.out.println(cat_all);
          String[] cat_split = cat_all.split("\\+");
          // ArrayList<String> list_cat = (ArrayList<String>) Arrays.asList(cat_split);
          for (int k = 0; k < cat_split.length; ++k) {
            if (selected_strings.get(i).equals(cat_split[k])) {
              shop_list.add(unchangeable_shop_list.get(j));
              break;
            }
          }
        }
      }
      shop_list = new ArrayList<ShopInfo>(new LinkedHashSet<ShopInfo>(shop_list));
    } else {
      shop_list = unchangeable_shop_list;
    }
    after_load();

    rl_front.setVisibility(View.VISIBLE);
    System.out.println("back button clicked");
    TranslateAnimation tanim1 =
        new TranslateAnimation(
            TranslateAnimation.RELATIVE_TO_PARENT,
            0,
            TranslateAnimation.RELATIVE_TO_PARENT,
            0,
            TranslateAnimation.ABSOLUTE,
            0,
            TranslateAnimation.ABSOLUTE,
            ((RelativeLayout) rl_front.getParent()).getHeight());

    tanim1.setDuration(400);
    tanim1.setFillAfter(false);
    tanim1.setAnimationListener(
        new AnimationListener() {

          @Override
          public void onAnimationStart(Animation animation) {
            // TODO Auto-generated method stub

          }

          @Override
          public void onAnimationRepeat(Animation animation) {
            // TODO Auto-generated method stub

          }

          @Override
          public void onAnimationEnd(Animation animation) {
            // TODO Auto-generated method stub
            lin_anim.setVisibility(View.GONE);
            rl_front.requestFocus();
            // rl_front.setVisibility(View.VISIBLE);
            System.out.println("anim end");
          }
        });
    tanim1.setInterpolator(new DecelerateInterpolator());
    lin_anim.setAnimation(tanim1);
  }
Пример #3
0
    @Override
    public View onCreateView(
        LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      final View rootView = inflater.inflate(R.layout.with_overlay, container, false);

      // Referenciamos el botón como final
      Button wejecuta = (Button) rootView.findViewById(R.id.wejecuta);

      // Obtenemos el cuadrado y el ViewGroup, que será el padre del cuadrado (que es donde lo
      // queremos añadir)
      final RelativeLayout cuadrado = (RelativeLayout) rootView.findViewById(R.id.cuadrado);
      final ViewGroup padre = (ViewGroup) cuadrado.getParent();

      // Si lo pulsamos, pasa esto:
      wejecuta.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {

              // Añadimos el botón al elemento padre
              padre.getOverlay().add(cuadrado);

              // Creamos el interpolador para la animación
              OvershootInterpolator sOvershooter = new OvershootInterpolator(2f);

              // Animaciones para el cuadrado y un listener para detectar cambios en la animación.
              cuadrado.animate().setDuration(8000);
              cuadrado
                  .animate()
                  .setInterpolator(sOvershooter)
                  .scaleX(7f)
                  .scaleY(7f)
                  .alpha(0)
                  .translationY(padre.getHeight())
                  .setListener(
                      new Animator.AnimatorListener() {

                        /* Tras el fin de la animación (o su posible cancelación) eliminamos el TextView, que es lo que queríamos
                        realizar. Cuando se añade a la Overlay se elimina de su padre, por lo cual sólo hace falta eliminarlo
                        de la OverlayLayout. */

                        @Override
                        public void onAnimationStart(Animator animation) {
                          // No nos interesa hacer nada cuando comienza.
                        }

                        @Override
                        public void onAnimationEnd(Animator animation) {
                          // Animación acabada, eliminamos el cuadrado
                          padre.getOverlay().remove(cuadrado);
                        }

                        @Override
                        public void onAnimationCancel(Animator animation) {
                          // Animación cancelada, eliminamos el cuadrado
                          padre.getOverlay().remove(cuadrado);
                        }

                        @Override
                        public void onAnimationRepeat(Animator animation) {
                          // No nos interesa hacer nada
                        }
                      });

              // Iniciamos animación
              cuadrado.animate().start();
            }
          });

      return rootView;
    }