예제 #1
0
 /** 退出时候保存选择后数据库的设置 */
 private void saveChannel() {
   BaseContext.getDBManager().deleteAllChannelItem();
   int size = userAdapter.getChannnelLst().size();
   for (int i = 0; i < size; i++) {
     ChannelItem ci = userAdapter.getChannnelLst().get(i);
     ci.setSelected(1);
     ci.setOrderId(i + 1);
     BaseContext.getDBManager().saveChannelItem(ci);
   }
   for (int i = 0; i < otherAdapter.getChannnelLst().size(); i++) {
     ChannelItem ci = otherAdapter.getChannnelLst().get(i);
     ci.setSelected(0);
     ci.setOrderId(size + i + 1);
     BaseContext.getDBManager().saveChannelItem(ci);
   }
 }
예제 #2
0
 /** GRIDVIEW对应的ITEM点击监听接口 */
 @Override
 public void onItemClick(AdapterView<?> parent, final View view, final int position, long id) {
   // 如果点击的时候,之前动画还没结束,那么就让点击事件无效
   if (isMove) {
     return;
   }
   switch (parent.getId()) {
     case R.id.userGridView:
       // position为 0,1 的不可以进行任何操作
       if (position != 0 && position != 1) {
         final ImageView moveImageView = getView(view);
         if (moveImageView != null) {
           TextView newTextView = (TextView) view.findViewById(R.id.text_item);
           final int[] startLocation = new int[2];
           newTextView.getLocationInWindow(startLocation);
           final ChannelItem channel =
               ((DragAdapter) parent.getAdapter()).getItem(position); // 获取点击的频道内容
           otherAdapter.setVisible(false);
           // 添加到最后一个
           otherAdapter.addItem(channel);
           new Handler()
               .postDelayed(
                   new Runnable() {
                     public void run() {
                       try {
                         int[] endLocation = new int[2];
                         // 获取终点的坐标
                         otherGridView
                             .getChildAt(otherGridView.getLastVisiblePosition())
                             .getLocationInWindow(endLocation);
                         MoveAnim(
                             moveImageView, startLocation, endLocation, channel, userGridView);
                         userAdapter.setRemove(position);
                       } catch (Exception localException) {
                       }
                     }
                   },
                   50L);
         }
       }
       break;
     case R.id.otherGridView:
       final ImageView moveImageView = getView(view);
       if (moveImageView != null) {
         TextView newTextView = (TextView) view.findViewById(R.id.text_item);
         final int[] startLocation = new int[2];
         newTextView.getLocationInWindow(startLocation);
         final ChannelItem channel = ((OtherAdapter) parent.getAdapter()).getItem(position);
         userAdapter.setVisible(false);
         // 添加到最后一个
         userAdapter.addItem(channel);
         new Handler()
             .postDelayed(
                 new Runnable() {
                   public void run() {
                     try {
                       int[] endLocation = new int[2];
                       // 获取终点的坐标
                       userGridView
                           .getChildAt(userGridView.getLastVisiblePosition())
                           .getLocationInWindow(endLocation);
                       MoveAnim(moveImageView, startLocation, endLocation, channel, otherGridView);
                       otherAdapter.setRemove(position);
                     } catch (Exception localException) {
                     }
                   }
                 },
                 50L);
       }
       break;
     default:
       break;
   }
 }