private void initializeReceiverData(long receiverId) {
    if (receiverId == -1) {
      // init blank
      brandListView.setItemChecked(0, true);
      updateModelList(brandListView.getSelectedItem().toString());

      modelListView.setItemChecked(0, true);
    } else {
      try {
        // init existing receiver
        final Receiver receiver = DatabaseHandler.getReceiver(receiverId);

        int brandPosition = brandNamesAdapter.getPosition(receiver.getBrand().getName());
        brandListView.setItemChecked(brandPosition, true);
        brandListView.smoothScrollToPosition(brandPosition);
        updateModelList(receiver.getBrand().getName());

        int modelPosition = modelNamesAdapter.getPosition(receiver.getModel());
        modelListView.setItemChecked(modelPosition, true);
        modelListView.smoothScrollToPosition(modelPosition);

      } catch (Exception e) {
        StatusMessageHandler.showErrorMessage(getActivity(), e);
      }
    }
  }
  private void initData(final MasterSlaveReceiver receiver) {
    channelMasterNamesAdapter.clear();
    for (String string : receiver.getMasterNames()) {
      channelMasterNamesAdapter.add(string);
    }
    channelMasterNamesAdapter.notifyDataSetChanged();

    channelSlaveNamesAdapter.clear();
    for (String string : receiver.getSlaveNames()) {
      channelSlaveNamesAdapter.add(string);
    }
    channelSlaveNamesAdapter.notifyDataSetChanged();

    int channelMasterPosition = channelMasterNamesAdapter.getPosition(receiver.getMaster() + "");
    if (channelMasterPosition == -1) {
      channelMasterPosition = 0;
    }
    channelMasterListView.setItemChecked(channelMasterPosition, true);
    channelMasterListView.smoothScrollToPosition(channelMasterPosition);

    int channelSlavePosition = channelSlaveNamesAdapter.getPosition(receiver.getSlave() + "");
    if (channelSlavePosition == -1) {
      channelSlavePosition = 0;
    }
    channelSlaveListView.setItemChecked(channelSlavePosition, true);
    channelSlaveListView.smoothScrollToPosition(channelSlavePosition);
  }
Example #3
0
        public void processMessage(Chat chat, Message message) {
          if ((message.getBody() != null) && (!message.getType().equals(Message.Type.error))) {
            if (!cipher) {

              Log.i(TAG, "Recibido mensaje plano: " + message.getBody());
              listMessages.add(message);
              refreshAdapter();
              myListView.smoothScrollToPosition(adapter.getCount() - 1);
            } else {

              try {
                PrivateKey pk =
                    RSA.getPrivateKeyDecryted(KeyStore.getInstance().getPk(), passPhrase);
                String decodedMessage = RSA.decipher(message.getBody(), pk);
                Log.i(TAG, "Recibido mensaje cifrado: " + decodedMessage);

                Message m = new Message();
                m.setFrom(message.getFrom());
                m.setTo(message.getTo());

                m.setBody(decodedMessage);
                SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
                m.setSubject(sdf.format(new Date()));
                listMessages.add(m);
                refreshAdapter();
                myListView.smoothScrollToPosition(adapter.getCount() - 1);

              } catch (Exception e) {
                Log.d(TAG, "PETO AL DESCIFRAR");
                e.printStackTrace();
              }
            }
          }
        }
Example #4
0
 /**
  * Scroll view to the center of the list
  *
  * @param view
  * @param parent
  */
 public static void scrollViewToCenter(View view, ListView parent) {
   ListAdapter items = parent.getAdapter();
   int viewY = view.getTop() + view.getHeight() / 2 - parent.getHeight() / 2;
   if (viewY < 0 && parent.getFirstVisiblePosition() == 0) {
     parent.smoothScrollToPosition(0);
   } else if (viewY > 0 && parent.getLastVisiblePosition() == items.getCount() - 1) {
     parent.smoothScrollToPosition(items.getCount() - 1);
   } else {
     Command.invoke(SCROLL_LIST_FOR_DISTANCE_IN_ANY_MILLIS)
         .args(parent, viewY, 300)
         .only()
         .sendDelayed(100);
   }
 }
  @Override
  public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {

    if ((cursor.moveToFirst()) && (cursor.getCount() == 1)) {
      // Check to see if there is a no artists flag in the cursor indicating that
      // there are no artists for the given search term.
      String flag = cursor.getString(COL_ARTIST_SPOTIFY_ID);
      if (flag.equals(DataContract.ArtistEntry.FLAG_NO_ARTISTS_FOUND)) {
        Toast toast =
            Toast.makeText(
                getActivity(), getString(R.string.toast_no_artist_found), Toast.LENGTH_LONG);
        toast.show();
      } else {
        mArtistsAdapter.swapCursor(cursor);
      }
    } else if (cursor.moveToFirst()) {
      Log.i(
          TAG,
          "onLoadFinished called and cursor.moveToFirst() is true. mArtistAdapter swaps with cursor");
      mArtistsAdapter.swapCursor(cursor);
      if (mPosition != ListView.INVALID_POSITION) {
        mListView.smoothScrollToPosition(mPosition);
      }
    } else if (null
        != mSearchTerm) { // if the cursor is null, this means that the artists for mSearchTerm have
      // not been added to the db.
      Log.i(
          TAG,
          "onLoadFinished called, cursor is empty, and mSearchTerm is "
              + mSearchTerm
              + ". getArtists() called to start new FetchArtistsTask");
      getArtists();
    }
  }
 @Override
 public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
   bookListAdapter.swapCursor(data);
   if (position != ListView.INVALID_POSITION) {
     bookList.smoothScrollToPosition(position);
   }
 }
 @Override
 public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
   mForecastAdapter.swapCursor(data);
   if (mPosition != ListView.INVALID_POSITION) {
     mlistView.smoothScrollToPosition(mPosition);
   }
   updateEmptyView();
 }
 @Override
 public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
   weatheradapter.swapCursor(cursor);
   if (mPosition != ListView.INVALID_POSITION) {
     // If we don't need to restart the loader, and there's a desired position to restore
     // to, do so now.
     listview.smoothScrollToPosition(mPosition);
   }
 }
Example #9
0
 @OnClick(R.id.countUpButton)
 protected void OnCountUpClick(View view) {
   statsAggregator = ((MainActivity) getActivity()).getStatsAggregator();
   data = statsAggregator.newEvent();
   refreshPercent(votersEditText.getText().toString());
   bucketAdapter.notifyDataSetChanged();
   listView.smoothScrollToPosition(statsAggregator.getFilteredBuckets().size());
   view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
 }
 @Override
 public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
   mCurrencyAdapter.swapCursor(data);
   if (mPosition != ListView.INVALID_POSITION) {
     // If we don't need to restart the loader, and there's a desired position to restore
     // to, do so now.
     mListView.smoothScrollToPosition(mPosition);
   }
 }
 /**
  * Set the currently selected list item to the specified position with the adapter's data.
  *
  * @param position the new selection
  * @author RayBa
  * @date 07.04.2013
  */
 public void setSelection(int position) {
   try {
     ensureList();
   } catch (Exception e) {
     return;
   }
   if (UIUtils.isFroyo()) {
     mList.smoothScrollToPosition(position);
   } else {
     mList.setSelection(position);
   }
 }
  @Override
  public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {

    switch (loader.getId()) {
      case TRACKS_LOADER_ID:
        Log.v(LOG_TAG, "onLoadFinished");
        mCursorAdapter.swapCursor(cursor);
        mCursor = cursor;
        // Check if we have the artist and tracks loaded in the player
        // if so, highlight that track
        if (!highlightCurrentTrack()) {
          if (mPosition != ListView.INVALID_POSITION) {
            // If we don't need to restart the loader, and there's a desired position to
            // restore to, do so
            mTracksListView.smoothScrollToPosition(mPosition);
            mTracksListView.setSelection(mPosition);
            mTracksListView.setItemChecked(mPosition, true);
          } else if (cursor.getCount() > 0) mTracksListView.smoothScrollToPosition(0);
        }
        break;
      default:
        break;
    }
  }
  @Override
  public void onScrollStateChanged(AbsListView view, int scrollState) {
    // TODO Auto-generated method stub

    if (scrollState == SCROLL_STATE_FLING && byaotu == false) {

      ObjectAnimator.ofFloat(m1, "Alpha", 0.3F, 0.0F).setDuration(100).start();

    } else if (scrollState == SCROLL_STATE_IDLE) {

      if (byaotu == false) {

        ObjectAnimator.ofFloat(m1, "Alpha", 0.1F, 0.0F).setDuration(500).start();

        if (top == 0) {}

        if (top == 85) {

        } else if (top != 0) {

          dataList.clear();
          datachange();

          m1111.notifyDataSetChanged();

          listView.smoothScrollToPosition(top);
          byaotu = true;
        }

      } else {
        byaotu = false;
      }

    } else if (scrollState == SCROLL_STATE_TOUCH_SCROLL && byaotu == false) {

      if (lockforsrcoll == false) {

        dataList.clear();
        for (int i = 0; i < max * 3; i++) {

          dataList.add(new ItemBean("" + i % max, 0));
        }
        m1111.notifyDataSetChanged();
        ObjectAnimator.ofFloat(m1, "Alpha", 0.3F, 0.2F).setDuration(100).start();
      }
    }
  }
  /**
   * Highlight current playing item Make the playing item can be seen.
   *
   * @param position
   */
  private void onItemPlay(int position) {
    // Make the the playing item can be seen.
    mMusicListView.smoothScrollToPosition(position);
    int prePlayingPosition = mMusicListAdapter.getPlayingPosition();
    if (prePlayingPosition >= mMusicListView.getFirstVisiblePosition()
        && prePlayingPosition <= mMusicListView.getLastVisiblePosition()) {
      int preItem = prePlayingPosition - mMusicListView.getFirstVisiblePosition();
      ((ViewGroup) mMusicListView.getChildAt(preItem)).getChildAt(0).setVisibility(View.INVISIBLE);
    }

    mMusicListAdapter.setPlayingPosition(position);

    if (mMusicListView.getLastVisiblePosition() < position
        || mMusicListView.getFirstVisiblePosition() > position) return;

    int currentItem = position - mMusicListView.getFirstVisiblePosition();
    ((ViewGroup) mMusicListView.getChildAt(currentItem)).getChildAt(0).setVisibility(View.VISIBLE);
  }
Example #15
0
  public void send(View view) {
    Message message = new Message(destJid);
    EditText editText = (EditText) findViewById(R.id.textInput);
    String plainText = editText.getText().toString();
    editText.setText("");

    message.setFrom(myJid);
    message.setTo(destJid);

    Message m = new Message();
    m.setFrom(myJid);
    m.setBody(plainText);
    SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
    m.setSubject(sdf.format(new Date()));
    listMessages.add(m);
    refreshAdapter();
    myListView.smoothScrollToPosition(adapter.getCount() - 1);

    if (!cipher) {
      try {
        message.setBody(plainText);
        chatMan.getChat().sendMessage(message);
        Log.d(TAG, "Enviando: " + message.getBody());

      } catch (XMPPException e) {
        Log.d(TAG, "ERROR al enviar mensaje");
      }
    } else {
      try {
        String encodedMessage = RSA.cipher(plainText, cert.getPublicKey());
        message.setBody(encodedMessage);
        chatMan.getChat().sendMessage(message);
        Log.d(TAG, "Enviando cifrado: " + message.getBody() + " " + plainText);

      } catch (Exception e) {
        Log.d(TAG, "PETO ENVIANDO CIFRADOOOO");
        e.printStackTrace();
      }
    }
  }
Example #16
0
  // 数据同步
  private void sync() {

    mComversation.sync(
        new SyncListener() {

          @Override
          public void onSendUserReply(List<Reply> replyList) {}

          @Override
          public void onReceiveDevReply(List<Reply> replyList) {
            // SwipeRefreshLayout停止刷新
            mSwipeRefreshLayout.setRefreshing(false);
            // 发送消息,刷新ListView
            mHandler.sendMessage(new Message());
            // 如果开发者没有新的回复数据,则返回
            if (replyList == null || replyList.size() < 1) {
              return;
            }
          }
        });
    // 更新adapter,刷新ListView
    adapter.notifyDataSetChanged();
    mListView.smoothScrollToPosition(mComversation.getReplyList().size());
  }
Example #17
0
 @Click(R.id.actionbar)
 void actionBarClicked() {
   mPostsList.smoothScrollToPosition(0);
 }
Example #18
0
 public void onListScrolPosition(final int i) {
   lvMain.smoothScrollToPosition(i);
 }
 private void scrollToBottom() {
   if (adapter.getCount() > 0) {
     mListView.smoothScrollToPosition(adapter.getCount());
   }
 }
 public void scrollToItem(int sectionIndex, int sectionItemIndex) {
   int position = findItemPosition(sectionIndex, sectionItemIndex);
   if (position > -1) {
     listView.smoothScrollToPosition(position + 1);
   }
 }
  private void updateModelList(String brandName) {
    Brand brandEnum = Brand.getEnum(brandName);

    switch (brandEnum) {
      case BAT:
        {
          modelNamesAdapter.clear();
          String[] array = getResources().getStringArray(R.array.model_bat_array);
          modelNamesAdapter.addAll(array);

          setModelVisibility(View.VISIBLE);
          break;
        }
      case BRENNENSTUHL:
        {
          modelNamesAdapter.clear();
          String[] array = getResources().getStringArray(R.array.model_brennenstuhl_array);
          modelNamesAdapter.addAll(array);

          setModelVisibility(View.VISIBLE);
          break;
        }
      case ELRO:
        {
          modelNamesAdapter.clear();
          String[] array = getResources().getStringArray(R.array.model_elro_array);
          modelNamesAdapter.addAll(array);

          setModelVisibility(View.VISIBLE);
          break;
        }
      case HAMA:
        {
          modelNamesAdapter.clear();
          String[] array = getResources().getStringArray(R.array.model_hama_array);
          modelNamesAdapter.addAll(array);

          setModelVisibility(View.VISIBLE);
          break;
        }
      case INTERTECHNO:
        {
          modelNamesAdapter.clear();
          String[] array = getResources().getStringArray(R.array.model_intertechno_array);
          modelNamesAdapter.addAll(array);

          setModelVisibility(View.VISIBLE);
          break;
        }
      case INTERTEK:
        {
          modelNamesAdapter.clear();
          String[] array = getResources().getStringArray(R.array.model_intertek_array);
          modelNamesAdapter.addAll(array);

          setModelVisibility(View.VISIBLE);
          break;
        }
      case MUMBI:
        {
          modelNamesAdapter.clear();
          String[] array = getResources().getStringArray(R.array.model_mumbi_array);
          modelNamesAdapter.addAll(array);

          setModelVisibility(View.VISIBLE);
          break;
        }
      case POLLIN_ELECTRONIC:
        {
          modelNamesAdapter.clear();
          String[] array = getResources().getStringArray(R.array.model_pollin_electronic_array);
          modelNamesAdapter.addAll(array);

          setModelVisibility(View.VISIBLE);
          break;
        }
      case REV:
        {
          modelNamesAdapter.clear();
          String[] array = getResources().getStringArray(R.array.model_rev_array);
          modelNamesAdapter.addAll(array);

          setModelVisibility(View.VISIBLE);
          break;
        }
      case ROHRMOTOR24:
        {
          modelNamesAdapter.clear();
          String[] array = getResources().getStringArray(R.array.model_rohrmotor24_array);
          modelNamesAdapter.addAll(array);

          setModelVisibility(View.VISIBLE);
          break;
        }
      case UNIVERSAL:
        {
          modelNamesAdapter.clear();
          String[] array = getResources().getStringArray(R.array.model_universal_array);
          modelNamesAdapter.addAll(array);

          setModelVisibility(View.VISIBLE);
          break;
        }
      case VIVANCO:
        {
          modelNamesAdapter.clear();
          String[] array = getResources().getStringArray(R.array.model_vivanco_array);
          modelNamesAdapter.addAll(array);

          setModelVisibility(View.VISIBLE);
          break;
        }
      default:
        setModelVisibility(View.GONE);
        break;
    }

    if (modelNamesAdapter.getCount() > modelListView.getSelectedItemPosition()) {
      modelListView.setItemChecked(0, true);
      modelListView.smoothScrollToPosition(0);
    }

    modelNamesAdapter.notifyDataSetChanged();
  }
 /** 刷新listview */
 private void freshListView() {
   adapter.setDataToAdapter(index_messageList);
   adapter.notifyDataSetChanged();
   mListview.smoothScrollToPosition(0);
 }
 @Override
 public void onActionBarTopClick() {
   mListView.smoothScrollToPosition(0);
 }
 private void scrollToEnd() {
   messagesList.smoothScrollToPosition(messagesList.getCount());
   chatRoom.markAsRead();
 }