void setMode(int mode) {
    if (mMode == mode) {
      return;
    }
    View slideshowPanel = findViewById(R.id.slideShowContainer);
    View normalPanel = findViewById(R.id.abs);

    Window win = getWindow();
    mMode = mode;
    if (mode == MODE_SLIDESHOW) {
      slideshowPanel.setVisibility(View.VISIBLE);
      normalPanel.setVisibility(View.GONE);

      win.addFlags(
          WindowManager.LayoutParams.FLAG_FULLSCREEN
              | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

      mImageView.clear();
      mActionIconPanel.setVisibility(View.GONE);

      slideshowPanel.getRootView().requestLayout();

      // The preferences we want to read:
      //   mUseShuffleOrder
      //   mSlideShowLoop
      //   mAnimationIndex
      //   mSlideShowInterval

      mUseShuffleOrder = mPrefs.getBoolean(PREF_SHUFFLE_SLIDESHOW, false);
      mSlideShowLoop = mPrefs.getBoolean(PREF_SLIDESHOW_REPEAT, false);
      mAnimationIndex = getPreferencesInteger(mPrefs, "pref_gallery_slideshow_transition_key", 0);
      mSlideShowInterval =
          getPreferencesInteger(mPrefs, "pref_gallery_slideshow_interval_key", 3) * 1000;
    } else {
      slideshowPanel.setVisibility(View.GONE);
      normalPanel.setVisibility(View.VISIBLE);

      win.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
      if (mFullScreenInNormalMode) {
        win.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
      } else {
        win.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
      }

      if (mGetter != null) {
        mGetter.cancelCurrent();
      }

      if (mShowActionIcons) {
        Animation animation = new AlphaAnimation(0F, 1F);
        animation.setDuration(500);
        mActionIconPanel.setAnimation(animation);
        mActionIconPanel.setVisibility(View.VISIBLE);
      }

      ImageViewTouchBase dst = mImageView;
      for (ImageViewTouchBase ivt : mSlideShowImageViews) {
        ivt.clear();
      }

      mShuffleOrder = null;

      // mGetter null is a proxy for being paused
      if (mGetter != null) {
        setImage(mCurrentPosition, true);
      }
    }
  }
  /**
   * When tabs change we fetch the current view that we are animating to and animate it and the
   * previous view in the appropriate directions.
   */
  @Override
  public void onTabChanged(String tabId) {

    currentView = tabHost.getCurrentView();
    if (tabHost.getCurrentTab() > currentTab) {
      previousView.setAnimation(outToLeftAnimation());
      currentView.setAnimation(inFromRightAnimation());
    } else {
      previousView.setAnimation(outToRightAnimation());
      currentView.setAnimation(inFromLeftAnimation());
    }
    previousView = currentView;
    currentTab = tabHost.getCurrentTab();
  }
 public void showEmpty(boolean show, View emptyView) {
   Animation anim =
       AnimationUtils.loadAnimation(
           getActivity(), show ? android.R.anim.fade_in : android.R.anim.fade_out);
   if (show
       && (emptyView.getVisibility() == View.GONE
           || emptyView.getVisibility() == View.INVISIBLE)) {
     emptyView.setAnimation(anim);
     emptyView.setVisibility(View.VISIBLE);
     if (adapter != null) adapter.changeDataSet(null);
   } else if (!show && emptyView.getVisibility() == View.VISIBLE) {
     emptyView.setAnimation(anim);
     emptyView.setVisibility(View.GONE);
   }
 }
Ejemplo n.º 4
0
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.vp_net_photos:
       View view = findViewById(R.id.layout_net_photos);
       Animation animation = null;
       if (flag_bottom) {
         animation =
             AnimationUtils.loadAnimation(NetPhotosActivity.this, R.anim.photos_bottom_exit);
       } else {
         animation =
             AnimationUtils.loadAnimation(NetPhotosActivity.this, R.anim.photos_bottom_enter);
       }
       view.setAnimation(animation);
       flag_bottom = !flag_bottom;
       break;
     case R.id.btn_net_photos_exit:
       finish();
       break;
     case R.id.btn_net_photos_save:
       String photo = photos[viewPager.getCurrentItem()];
       FinalBitmap finalBitmap = FinalBitmap.create(NetPhotosActivity.this);
       Bitmap bitmap = finalBitmap.getBitmapFromCache(photo);
       if (bitmap != null) {
         SdCardUtil.savePhoto(NetPhotosActivity.this, bitmap);
       } else {
         ToastUtil.prompt(NetPhotosActivity.this, "还在下载大图");
       }
       break;
   }
 }
 /**
  * 切换菜单
  *
  * @param target
  */
 private void switchMenu(View target) {
   System.out.println(current_tab_position);
   for (int i = 0; i < tabMenuView.getChildCount(); i = i + 2) {
     if (target == tabMenuView.getChildAt(i)) {
       if (current_tab_position == i) {
         closeMenu();
       } else {
         if (current_tab_position == -1) {
           popupMenuViews.setVisibility(View.VISIBLE);
           popupMenuViews.setAnimation(
               AnimationUtils.loadAnimation(getContext(), R.anim.dd_menu_in));
           maskView.setVisibility(VISIBLE);
           maskView.setAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.dd_mask_in));
           popupMenuViews.getChildAt(i / 2).setVisibility(View.VISIBLE);
         } else {
           popupMenuViews.getChildAt(i / 2).setVisibility(View.VISIBLE);
         }
         current_tab_position = i;
         ((TextView) tabMenuView.getChildAt(i)).setTextColor(textSelectedColor);
         ((TextView) tabMenuView.getChildAt(i))
             .setCompoundDrawablesWithIntrinsicBounds(
                 null, null, getResources().getDrawable(menuSelectedIcon), null);
       }
     } else {
       ((TextView) tabMenuView.getChildAt(i)).setTextColor(textUnselectedColor);
       ((TextView) tabMenuView.getChildAt(i))
           .setCompoundDrawablesWithIntrinsicBounds(
               null, null, getResources().getDrawable(menuUnselectedIcon), null);
       popupMenuViews.getChildAt(i / 2).setVisibility(View.GONE);
     }
   }
 }
Ejemplo n.º 6
0
  public void refreshViews() {
    layout.removeAllViews();
    views = new ArrayList<View>();
    cardViews = new ArrayList<CardUI>();
    profilePictures = new ArrayList<MLRoundedImageView>();

    users = ItemsData.retrieveUserIdsCurrentlyRenting(getActivity());
    bitmaps = new ArrayList<Bitmap>();
    if (users.size() == 0) {
      CardUI cards = new CardUI(getActivity());
      cards.setPadding(0, 20, 0, 20);
      cards.addCard(new EmptyRentalListCard(getActivity()));
      cards.refresh();
      views.add(cards);
    } else {
      for (User u : users) {
        views.add(createProfile(u));
        views.add(
            createUserRentals(
                ItemsData.retrieveItemsLentByUserId(u.getFacebookId(), getActivity())));
      }
    }

    for (int i = 0; i < views.size(); i++) {
      View v = views.get(i);
      v.setVisibility(LinearLayout.VISIBLE);
      Animation animation = AnimationUtils.loadAnimation(getActivity(), R.animator.fade_in);
      animation.setDuration(300);
      animation.setStartOffset(i * 100);
      v.setAnimation(animation);
      layout.addView(v);
    }
  }
Ejemplo n.º 7
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    View view = getLayoutInflater().inflate(R.layout.activity_startup, null);
    AlphaAnimation animation = new AlphaAnimation(0.0f, 1.0f);
    animation.setDuration(2000);
    animation.setAnimationListener(
        new AnimationListener() {

          @Override
          public void onAnimationStart(Animation animation) {}

          @Override
          public void onAnimationRepeat(Animation animation) {}

          @Override
          public void onAnimationEnd(Animation animation) {
            skip();
          }
        });
    view.setAnimation(animation);
    setContentView(view);

    // setContentView(R.layout.activity_startup);
  }
Ejemplo n.º 8
0
 protected void enableViewAnimation(View view, Animation animation) {
   if (animationDisabled()) {
     disableViewAnimation(view);
   } else {
     view.setAnimation(animation);
   }
 }
  public void setCurrentItem(int item) {
    final View oldChild = getChildAt(mCurrentPosition);
    final View newChild = getChildAt(item);

    TranslateAnimation translateAnimation =
        new TranslateAnimation(
            Animation.RELATIVE_TO_SELF, 0,
            Animation.RELATIVE_TO_SELF, item - mCurrentPosition,
            Animation.RELATIVE_TO_SELF, 0,
            Animation.RELATIVE_TO_SELF, 0);

    translateAnimation.setDuration(200);
    translateAnimation.setAnimationListener(
        new AnimationListener() {

          @Override
          public void onAnimationStart(Animation animation) {}

          @Override
          public void onAnimationRepeat(Animation animation) {}

          @Override
          public void onAnimationEnd(Animation animation) {
            oldChild.setBackgroundResource(R.color.transparent);
            newChild.setBackgroundResource(R.color.orange);
          }
        });
    oldChild.setAnimation(translateAnimation);

    mCurrentPosition = item;
    invalidate();
  }
Ejemplo n.º 10
0
 // 画像を押したときにアニメーションをさせる関数
 public void animationView(View view) {
   if (view.getVisibility() == View.GONE) {
     view.setAnimation(inAnim);
     view.setVisibility(View.VISIBLE);
   } else {
     view.startAnimation(outAnim);
     view.setVisibility(View.GONE);
   }
 }
Ejemplo n.º 11
0
 public void animateCards() {
   for (int i = 0; i < views.size(); i++) {
     View v = views.get(i);
     v.setVisibility(LinearLayout.VISIBLE);
     Animation animation = AnimationUtils.loadAnimation(getActivity(), R.animator.fade_in);
     animation.setDuration(200);
     animation.setStartOffset((i + 1) * 75);
     v.setAnimation(animation);
   }
 }
Ejemplo n.º 12
0
 public static View10 wrap(View view) {
   View10 proxy = PROXIES.get(view);
   Animation animation = view.getAnimation();
   if (proxy == null || proxy != animation && animation != null) {
     proxy = new View10(view);
     PROXIES.put(view, proxy);
   } else if (animation == null) {
     view.setAnimation(proxy);
   }
   return proxy;
 }
Ejemplo n.º 13
0
  public static void replaceProgressBarWhenLoadingFinished(
      Context context, View mainView, ProgressBar progressBar) {
    Animation fadeIn = AnimationUtils.loadAnimation(context, android.R.anim.fade_in);
    Animation fadeOut = AnimationUtils.loadAnimation(context, android.R.anim.fade_out);

    mainView.setAnimation(fadeIn);
    progressBar.setAnimation(fadeOut);

    mainView.setVisibility(View.VISIBLE);
    progressBar.setVisibility(View.GONE);
  }
Ejemplo n.º 14
0
  // Some tests with viewFlipper in order to switch between Smart List and Full List
  // TODO: Remove this code and upgrade to something similar to Launcher. Drag and slide views by
  // using gestures.
  @Override
  public boolean onTouch(View v, MotionEvent event) {
    // Get the action that was done on this touch event
    switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN:
        {
          // store the X value when the user's finger was pressed down
          downXvalue = event.getX();
          break;
        }

      case MotionEvent.ACTION_UP:
        {
          // Get the X value when the user released his/her finger
          float currentX = event.getX();

          // going backwards: pushing stuff to the right
          if (downXvalue < currentX) {
            // Get a reference to the ViewFlipper
            // ViewFlipper vf = (ViewFlipper) findViewById(R.id.viewFlipper_Lists_Container);
            // Set the animation
            v.setAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_in_left));
            // Flip!
            ((ViewAnimator) v).showPrevious();
          }

          // going forwards: pushing stuff to the left
          if (downXvalue > currentX) {
            // Get a reference to the ViewFlipper
            // ViewFlipper vf = (ViewFlipper) findViewById(R.id.viewFlipper_Lists_Container);
            // Set the animation
            v.setAnimation(AnimationUtils.loadAnimation(this, R.anim.slide_in_right));
            // Flip!
            ((ViewAnimator) v).showNext();
          }
          break;
        }
    }
    // if you return false, these actions will not be recorded
    return true;
  }
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {

    View root = getView();

    mContainer = root.findViewById(R.id.scheduler_container);

    mViewSwitcher = (ViewAnimator) root.findViewById(R.id.scheduler_switcher);

    mBtnOneShot = (Button) root.findViewById(R.id.btn_one_shot);
    mBtnOneShot.setOnClickListener(mBtnClickListener);
    mBtnRepeat = (Button) root.findViewById(R.id.btn_repeat);
    mBtnRepeat.setOnClickListener(mBtnClickListener);
    mBtnEvery = (Button) root.findViewById(R.id.btn_every);
    mBtnEvery.setOnClickListener(mBtnClickListener);

    mDatePicker = (ScrollDatePicker) root.findViewById(R.id.scheduler_date_picker);
    Calendar calendar = Calendar.getInstance();
    mDatePicker.init(
        calendar.get(Calendar.YEAR),
        calendar.get(Calendar.MONTH),
        calendar.get(Calendar.DAY_OF_MONTH),
        this);

    mRepeatPicker = (RepeatPicker) root.findViewById(R.id.scheduler_repeat_picker);
    mRepeatPicker.setListener(this);

    mIntervalPicker = (IntervalPicker) root.findViewById(R.id.scheduler_every_picker);
    mIntervalPicker.setOnChangeListener(this);

    mOverlayView = root.findViewById(R.id.scheduler_overlay);
    mOverlayView.setOnClickListener(mOverlayClickListener);

    if (savedInstanceState != null) {
      mCurrentValues = savedInstanceState.getParcelable(STATE_CURRENT_VALUES);
    } else {
      mContainer.setAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.slide_in_bottom));
      mOverlayView.animate().alpha(1.0f);

      mCurrentValues = getArguments().getParcelable(STATE_CURRENT_VALUES);
    }

    if (mCurrentValues == null) {
      mCurrentValues = new OneShotValues(Calendar.getInstance());
    }

    // save();     this overwrites the loaded schedule ;(

    updateViews();

    super.onActivityCreated(savedInstanceState);
  }
Ejemplo n.º 16
0
 /** 关闭菜单 */
 public void closeMenu() {
   if (current_tab_position != -1) {
     ((TextView) tabMenuView.getChildAt(current_tab_position)).setTextColor(textUnselectedColor);
     ((TextView) tabMenuView.getChildAt(current_tab_position))
         .setCompoundDrawablesWithIntrinsicBounds(
             null, null, getResources().getDrawable(menuUnselectedIcon), null);
     popupMenuViews.setVisibility(View.GONE);
     popupMenuViews.setAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.dd_menu_out));
     maskView.setVisibility(GONE);
     maskView.setAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.dd_mask_out));
     current_tab_position = -1;
   }
 }
Ejemplo n.º 17
0
  public static void fadeIn(View view) {
    view.clearAnimation();
    final int fadeInDuration = 200; // 0.2s

    Animation fadeIn = new AlphaAnimation(0, 1);
    fadeIn.setInterpolator(new DecelerateInterpolator()); // add this
    fadeIn.setDuration(fadeInDuration);

    AnimationSet animation = new AnimationSet(false);
    animation.addAnimation(fadeIn);
    animation.setRepeatCount(1);
    view.setAnimation(animation);
  }
Ejemplo n.º 18
0
    protected void onPostExecute(Void result) {
      for (int i = 0; i < views.size(); i++) {
        View v = views.get(i);
        v.setVisibility(LinearLayout.VISIBLE);
        Animation animation = AnimationUtils.loadAnimation(getActivity(), R.animator.fade_in);
        animation.setDuration(300);
        animation.setStartOffset(i * 100);
        v.setAnimation(animation);
        layout.addView(v);
      }

      new FacebookPictures().execute(new Void[] {});
    }
Ejemplo n.º 19
0
 protected synchronized void animateNow() {
   View view = this.view.get();
   if (view != null) {
     AnimationSet set = new AnimationSet(true);
     for (Animation animation : animations) {
       if (animation != null) {
         set.addAnimation(animation);
       }
     }
     set.setDuration(0);
     set.setFillAfter(true);
     view.setAnimation(set);
     set.start();
     animations.clear();
   }
 }
  private void yTranslateAnimation(
      final View v,
      final int yStart,
      final int yEnd,
      final boolean visibleAfter,
      final boolean fillAfter) {
    TranslateAnimation anim = new TranslateAnimation(0, 0, yStart, yEnd);
    anim.setDuration(600);
    anim.setFillEnabled(fillAfter);
    if (!visibleAfter || v == deleteButton) {
      anim.setAnimationListener(
          new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {}

            @Override
            public void onAnimationRepeat(Animation animation) {}

            @Override
            public void onAnimationEnd(Animation animation) {
              if (!visibleAfter) {
                v.setVisibility(View.GONE);
              }
              if (fillAfter && v == deleteButton) {
                RelativeLayout.LayoutParams params =
                    (RelativeLayout.LayoutParams) v.getLayoutParams();
                if (yEnd > 0) {
                  params.topMargin = deleteButtonSecondPos;
                } else {
                  params.topMargin = deleteButtonFirstPos;
                }
                deleteButton.setLayoutParams(params);
              }
            }
          });
    }
    v.clearAnimation();
    v.setAnimation(anim);
    v.invalidate();
    v.startAnimation(anim);
    anim.startNow();
  }
Ejemplo n.º 21
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    profilePictures = new ArrayList<MLRoundedImageView>();
    views = new ArrayList<View>();
    cardViews = new ArrayList<CardUI>();
    myInflater = inflater;
    scroller = new ScrollView(getActivity().getApplicationContext());
    layout = new LinearLayout(getActivity().getApplicationContext());
    layout.setPadding(0, 5, 0, 5);
    layout.setOrientation(LinearLayout.VERTICAL);

    scroller.addView(layout);
    scroller.setBackgroundColor(Color.parseColor(Utils.BACKGROUND_COLOR));

    users = ItemsData.retrieveUserIdsCurrentlyRenting(getActivity());
    bitmaps = new ArrayList<Bitmap>();
    if (users.size() == 0) {
      CardUI cards = new CardUI(getActivity());
      cards.setPadding(0, 20, 0, 20);
      cards.addCard(new EmptyRentalListCard(getActivity()));
      cards.refresh();
      views.add(cards);
    } else {
      for (User u : users) {
        views.add(createProfile(u));
        views.add(
            createUserRentals(
                ItemsData.retrieveItemsLentByUserId(u.getFacebookId(), getActivity())));
      }
    }
    for (int i = 0; i < views.size(); i++) {
      View v = views.get(i);
      v.setVisibility(LinearLayout.VISIBLE);
      Animation animation = AnimationUtils.loadAnimation(getActivity(), R.animator.fade_in);
      animation.setDuration(300);
      animation.setStartOffset(i * 100);
      v.setAnimation(animation);
      layout.addView(v);
    }

    return scroller;
  }
Ejemplo n.º 22
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    // 这句代码换掉dialog默认背景,否则dialog的边缘发虚透明而且很宽
    // 总之达不到想要的效果
    getWindow().setBackgroundDrawableResource(android.R.color.transparent);
    LayoutInflater inflater = LayoutInflater.from(context);
    // ((AnimationActivity) context).getLayoutInflater();
    localView = inflater.inflate(R.layout.sharedialog, null);
    localView.setAnimation(AnimationUtils.loadAnimation(context, R.anim.slide_bottom_to_top));
    setContentView(localView);
    // 这句话起全屏的作用
    getWindow()
        .setLayout(
            RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);
    initViews();
    setOnclick();
  }
Ejemplo n.º 23
0
  private void invalidateAfterUpdate() {
    View view = mView.get();
    if (view == null) {
      return;
    }
    View parent = (View) view.getParent();
    if (parent == null) {
      return;
    }

    view.setAnimation(this);

    final RectF after = mAfter;
    computeRect(after, view);
    after.union(mBefore);

    parent.invalidate(
        (int) FloatMath.floor(after.left),
        (int) FloatMath.floor(after.top),
        (int) FloatMath.ceil(after.right),
        (int) FloatMath.ceil(after.bottom));
  }
Ejemplo n.º 24
0
  public static void listItemCollapse(final View view, final OnAnimationEndListener onEndListener) {
    AnimationListener animListener =
        new AnimationListener() {

          @Override
          public void onAnimationStart(Animation animation) {}

          @Override
          public void onAnimationRepeat(Animation animation) {}

          @Override
          public void onAnimationEnd(Animation animation) {
            onEndListener.onAnimated(view);
          }
        };

    Animation animation = new FadeUpAnimation(view);
    animation.setDuration(ANIMATION_DURATION);
    animation.setAnimationListener(animListener);
    view.setAnimation(animation);
    view.startAnimation(animation);
  }
Ejemplo n.º 25
0
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   ViewHolder viewHolder;
   if (convertView == null) {
     convertView = inflater.inflate(R.layout.griditem_photo_grid, parent, false);
     viewHolder = new ViewHolder();
     viewHolder.title = (TextView) convertView.findViewById(R.id.griditem_text);
     viewHolder.image = (ImageView) convertView.findViewById(R.id.griditem_img);
     convertView.setTag(viewHolder);
   } else {
     viewHolder = (ViewHolder) convertView.getTag();
   }
   // 将图片显示任务增加到执行池,图片将被显示到ImageView当轮到此ImageView
   viewHolder.title.setText(results.get(position).getFile().getName());
   final String path = results.get(position).getFile().getPath();
   imageLoader.displayImage("file://" + path, viewHolder.image);
   convertView.setOnTouchListener(
       new View.OnTouchListener() {
         @Override
         public boolean onTouch(View v, MotionEvent event) {
           Log.e("touch", "touch");
           if (event.getAction() == MotionEvent.ACTION_DOWN) {
             x = (int) event.getX();
             y = (int) event.getY();
             Log.e("txy", x + " " + y);
           }
           return false;
         }
       });
   AnimationSet animationSet = new AnimationSet(true);
   ScaleAnimation scaleAnimation = new ScaleAnimation(0f, 1f, 0f, 1f, 0.4f, 0.4f);
   AlphaAnimation alphaAnimation = new AlphaAnimation(0.2f, 1f);
   animationSet.addAnimation(scaleAnimation);
   animationSet.addAnimation(alphaAnimation);
   convertView.setAnimation(animationSet);
   animationSet.setDuration(1200);
   return convertView;
 }
Ejemplo n.º 26
0
 private AnimatorProxy(View view) {
   setDuration(0); // perform transformation immediately
   setFillAfter(true); // persist transformation beyond duration
   view.setAnimation(this);
   mView = new WeakReference<View>(view);
 }
Ejemplo n.º 27
0
  public static void backToMainMenuDialog(final Activity a, final LatLon searchLocation) {
    final Dialog dlg = new Dialog(a, R.style.Dialog_Fullscreen);
    final View menuView = (View) a.getLayoutInflater().inflate(R.layout.menu, null);
    menuView.setBackgroundColor(Color.argb(200, 150, 150, 150));
    dlg.setContentView(menuView);
    final OsmAndAppCustomization appCustomization =
        ((OsmandApplication) a.getApplication()).getAppCustomization();
    MainMenuActivity.onCreateMainMenu(dlg.getWindow(), a);
    Animation anim =
        new Animation() {
          @Override
          protected void applyTransformation(float interpolatedTime, Transformation t) {
            ColorDrawable colorDraw = ((ColorDrawable) menuView.getBackground());
            colorDraw.setAlpha((int) (interpolatedTime * 200));
          }
        };
    anim.setDuration(700);
    anim.setInterpolator(new AccelerateInterpolator());
    menuView.setAnimation(anim);

    View showMap = dlg.findViewById(R.id.MapButton);
    showMap.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            dlg.dismiss();
          }
        });
    View settingsButton = dlg.findViewById(R.id.SettingsButton);
    settingsButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            final Intent settings = new Intent(a, appCustomization.getSettingsActivity());
            a.startActivity(settings);
            dlg.dismiss();
          }
        });

    View favouritesButton = dlg.findViewById(R.id.FavoritesButton);
    favouritesButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            final Intent favorites = new Intent(a, appCustomization.getFavoritesActivity());
            favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
            a.startActivity(favorites);
            dlg.dismiss();
          }
        });

    View closeButton = dlg.findViewById(R.id.CloseButton);
    closeButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            dlg.dismiss();
            // 1. Work for almost all cases when user open apps from main menu
            Intent newIntent = new Intent(a, appCustomization.getMainMenuActivity());
            newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            newIntent.putExtra(MainMenuActivity.APP_EXIT_KEY, MainMenuActivity.APP_EXIT_CODE);
            a.startActivity(newIntent);
            // 2. good analogue but user will come back to the current activity onResume()
            // so application is not reloaded !!!
            // moveTaskToBack(true);
            // 3. bad results if user comes from favorites
            // a.setResult(MainMenuActivity.APP_EXIT_CODE);
            // a.finish();
          }
        });

    View searchButton = dlg.findViewById(R.id.SearchButton);
    searchButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            final Intent search = new Intent(a, appCustomization.getSearchActivity());
            LatLon loc = searchLocation;
            search.putExtra(SearchActivity.SEARCH_LAT, loc.getLatitude());
            search.putExtra(SearchActivity.SEARCH_LON, loc.getLongitude());
            // causes wrong position caching:
            // search.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
            search.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            a.startActivity(search);
            dlg.dismiss();
          }
        });
    menuView.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            dlg.dismiss();
          }
        });

    dlg.show();
    // Intent newIntent = new Intent(a, MainMenuActivity.class);
    // newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    // startActivity(newIntent);
  }
Ejemplo n.º 28
0
  public void removeItem(SparseBooleanArray positions, final long[] ids, final ActionMode mode) {
    int size = positions.size();
    final List<Integer> positionList = new ArrayList<Integer>();
    for (int i = 0; i < size; i++) {
      if (positions.get(positions.keyAt(i))) {
        positionList.add(positions.keyAt(i));
      }
    }
    List<View> views = new ArrayList<View>();
    int start = getListView().getFirstVisiblePosition();
    int end = getListView().getLastVisiblePosition();

    for (Integer position : positionList) {
      if (position >= start && position <= end) {
        views.add(getListView().getChildAt((position - start)).findViewById(R.id.text1));
      }
    }
    List<Animation> animations = new ArrayList<Animation>();

    Animation.AnimationListener listener =
        new Animation.AnimationListener() {

          boolean finished = false;

          @Override
          public void onAnimationStart(Animation animation) {}

          @Override
          public void onAnimationEnd(Animation animation) {
            if (finished) {
              return;
            }
            finished = true;
            Set<String> set = new HashSet<String>();
            for (long id : ids) {
              set.add(list.get((int) id));
            }

            for (String name : set) {
              Iterator<String> iterator = list.iterator();
              while (iterator.hasNext()) {
                String s = iterator.next();
                if (s.equals(name)) {
                  iterator.remove();
                }
              }
            }

            mode.finish();

            if (Utility.isTaskStopped(removeTask)) {
              removeTask = new RemoveFilterDBTask(set);
              removeTask.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
            }
          }

          @Override
          public void onAnimationRepeat(Animation animation) {}
        };

    for (View view : views) {
      CollapseAnimation animation = new CollapseAnimation(view, 300);
      animation.setAnimationListener(listener);
      animations.add(animation);
      view.setAnimation(animation);
    }

    for (int i = 0; i < views.size(); i++) {
      views.get(i).startAnimation(animations.get(i));
    }
  }
Ejemplo n.º 29
0
 @Test
 public void shouldSetAnimation() throws Exception {
   Animation anim = new TestAnimation();
   view.setAnimation(anim);
   assertThat(view.getAnimation(), sameInstance(anim));
 }
Ejemplo n.º 30
0
  private void setSuggestionsEnabled(final boolean enabled) {
    // Clicking the yes/no buttons quickly can cause the click events be
    // queued before the listeners are removed above, so it's possible
    // setSuggestionsEnabled() can be called twice. mSuggestionsOptInPrompt
    // can be null if this happens (bug 828480).
    if (mSuggestionsOptInPrompt == null) {
      return;
    }

    // Make suggestions appear immediately after the user opts in
    primeSuggestions();

    // Pref observer in gecko will also set prompted = true
    PrefsHelper.setPref("browser.search.suggest.enabled", enabled);

    TranslateAnimation anim1 = new TranslateAnimation(0, mSuggestionsOptInPrompt.getWidth(), 0, 0);
    anim1.setDuration(ANIMATION_DURATION);
    anim1.setInterpolator(new AccelerateInterpolator());
    anim1.setFillAfter(true);
    mSuggestionsOptInPrompt.setAnimation(anim1);

    TranslateAnimation anim2 =
        new TranslateAnimation(0, 0, 0, -1 * mSuggestionsOptInPrompt.getHeight());
    anim2.setDuration(ANIMATION_DURATION);
    anim2.setFillAfter(true);
    anim2.setStartOffset(anim1.getDuration());
    final LinearLayout view = (LinearLayout) getView();
    anim2.setAnimationListener(
        new Animation.AnimationListener() {
          @Override
          public void onAnimationStart(Animation a) {
            // Increase the height of the view so a gap isn't shown during animation
            view.getLayoutParams().height = view.getHeight() + mSuggestionsOptInPrompt.getHeight();
            view.requestLayout();
          }

          @Override
          public void onAnimationRepeat(Animation a) {}

          @Override
          public void onAnimationEnd(Animation a) {
            // Removing the view immediately results in a NPE in
            // dispatchDraw(), possibly because this callback executes
            // before drawing is finished. Posting this as a Runnable fixes
            // the issue.
            view.post(
                new Runnable() {
                  @Override
                  public void run() {
                    view.removeView(mSuggestionsOptInPrompt);
                    getListView().clearAnimation();
                    mSuggestionsOptInPrompt = null;

                    if (enabled) {
                      // Reset the view height
                      view.getLayoutParams().height = LayoutParams.FILL_PARENT;

                      mSuggestionsEnabled = enabled;
                      mAnimateSuggestions = true;
                      getCursorAdapter().notifyDataSetChanged();
                      filterSuggestions(mSearchTerm);
                    }
                  }
                });
          }
        });

    mSuggestionsOptInPrompt.startAnimation(anim1);
    getListView().startAnimation(anim2);
  }