@Override
 public void onKey(int primaryCode, int[] keyCodes) {
   Editable editable = ed.getText();
   int start = ed.getSelectionStart();
   if (primaryCode == Keyboard.KEYCODE_CANCEL) { // 完成
     hideKeyboard();
   } else if (primaryCode == Keyboard.KEYCODE_DELETE) { // 回退
     if (editable != null && editable.length() > 0) {
       if (start > 0) {
         editable.delete(start - 1, start);
       }
     }
   } else if (primaryCode == Keyboard.KEYCODE_SHIFT) { // 大小写切换
     changeKey();
     keyboardView.setKeyboard(k1);
   } else if (primaryCode == Keyboard.KEYCODE_MODE_CHANGE) { // 数字键盘切换
     if (isnun) {
       isnun = false;
       keyboardView.setKeyboard(k1);
     } else {
       isnun = true;
       keyboardView.setKeyboard(k2);
     }
   } else if (primaryCode == 57419) { // go left
     if (start > 0) {
       ed.setSelection(start - 1);
     }
   } else if (primaryCode == 57421) { // go right
     if (start < ed.length()) {
       ed.setSelection(start + 1);
     }
   } else {
     editable.insert(start, Character.toString((char) primaryCode));
   }
 }
 private void loadData() {
   workInfo = (PersonalWorkInfo) getIntent().getSerializableExtra(WORK_INFO_INPUT);
   position = (Integer) getIntent().getSerializableExtra(POSITION_MODIFIED);
   works = workInfo.getWorks();
   if (works.size() != 0) {
     switch (position) {
       case 0:
         entreprise.setText(works.get(0));
         setWorkYear(works.get(1));
         post.setText(works.get(2));
         break;
       case 1:
         entreprise.setText(works.get(3));
         setWorkYear(works.get(4));
         post.setText(works.get(5));
         break;
       case 2:
         entreprise.setText(works.get(6));
         setWorkYear(works.get(7));
         post.setText(works.get(8));
         break;
       default:
         break;
     }
   }
   if (entreprise.getText() != null) {
     entreprise.setSelection(entreprise.getText().toString().length());
   }
   if (post.getText() != null) {
     post.setSelection(post.getText().toString().length());
   }
 }
 protected void restoreEnteredText(EditText previous, EditText current, String defaultText) {
   if (previous != null) {
     String text = previous.getText().toString();
     current.setText(TextUtils.isEmpty(text) ? defaultText : text);
     current.setSelection(current.getText().length());
   } else {
     current.setText(defaultText);
     current.setSelection(current.getText().length());
   }
 }
 private void toggle_eye() {
   if (img_eye.getDrawable().getLevel() == 0) {
     img_eye.setImageLevel(1);
     edt_password.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
     edt_password.setSelection(edt_password.length());
   } else {
     img_eye.setImageLevel(0);
     edt_password.setInputType(129);
     edt_password.setSelection(edt_password.length());
   }
 }
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    final OfflineRegion region = adapter.getItem(position);
    String metadata = OfflineUtils.convertRegionName(region.getMetadata());

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Rename metadata");

    final EditText input = new EditText(this);
    input.setText(metadata);
    input.setInputType(InputType.TYPE_CLASS_TEXT);
    input.setSelection(metadata.length());
    builder.setView(input);

    builder.setPositiveButton(
        "OK",
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            updateMetadata(region, OfflineUtils.convertRegionName(input.getText().toString()));
          }
        });
    builder.setNegativeButton(
        "Cancel",
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
          }
        });

    builder.show();
  }
Example #6
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ButterKnife.bind(this);
    // sets the text in the searchtext view in the xml to this default
    mSearchText.setText(DEFAULT_SEARCH_TERM);
    // changes what is in the searchtext view to whatever the user types in
    mSearchText.setSelection(mSearchText.getText().length());

    // Check if we have data to display (after rotation)
    if (savedInstanceState != null) {
      mSongsResponse = (SongsResponse) savedInstanceState.getSerializable(KEY_SONGS_RESPONSE);
      mSongs = mSongsResponse.getSongs();
    } else {
      handleSearch();
    }

    // the adapter that adapts the array from this activity and puts it into this variable name
    mAdapter = new SongsAdapter(this, mSongs);
    // puts the content from mAdapter into the listview
    mListView.setAdapter(mAdapter);

    mSearchText.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEND) {
              handleSearch();
              return true;
            }
            return false;
          }
        });
  }
  @Override
  protected void onResume() {
    // TODO Auto-generated method stub
    super.onResume();
    if (mBundle != null
        && mBundle.containsKey(Constants.JOB_ID)
        && mBundle.getString(Constants.JOB_ID) != null
        && !mBundle.getString(Constants.JOB_ID).isEmpty()) {
      sJobId = mBundle.getString(Constants.JOB_ID);
    }
    if (!sJobId.isEmpty()) { // for hail jobs
      // llReceiptTypeRadiobutton.setVisibility(View.VISIBLE);
      llReceiptTypeForWalkUp.setVisibility(View.VISIBLE);
      etEmailOrNumber.setVisibility(View.VISIBLE);

      if (mBundle != null) {
        sMobileNo = mBundle.getString(Constants.PASSENGER_NUMBER);
        sInternationalNo = mBundle.getString(Constants.PASSENGER_INTERNATIONAL_CODE);
        sEmail = mBundle.getString(Constants.PASSENGER_EMAIL);
        sPickUp = mBundle.getString(Constants.PICK_UP_ADDRESS);
        sDropOff = mBundle.getString(Constants.DROP_ADDRESS);
        etEmailOrNumber.setText(sEmail);
        etEmailOrNumber.setSelection(etEmailOrNumber.getText().length());
      }
    }
    /*
     * else { llReceiptTypeRadiobutton.setVisibility(View.GONE);
     * llReceiptTypeForWalkUp.setVisibility(View.VISIBLE); }
     */
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_edit_item);
    setActivityBackgroundColor();

    // Initialize variables for views
    etEditTitle = (EditText) findViewById(R.id.etEditTitle);
    dropdown = (Spinner) findViewById(R.id.spinnerPriority);
    String[] priorities = new String[] {"LOW", "MED", "HIGH"};
    ArrayAdapter<String> dropdownAdapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, priorities);
    dropdown.setAdapter(dropdownAdapter);

    // Initialize variables for item
    title = getIntent().getStringExtra("title");
    priority = getIntent().getStringExtra("priority");
    dueDate = getIntent().getStringExtra("dueDate");
    position = getIntent().getIntExtra("position", 0);
    etEditTitle.setText(title);
    etEditTitle.setSelection(title.length());
    etEditTitle.requestFocus();
    dropdown.setSelection(dropdownAdapter.getPosition(priority));
    setItemDueDate();
  }
 @Override
 public void onClick() {
   final EditText editText = (EditText) getView().findViewById(R.id.text_entry);
   editText.requestFocus();
   editText.setText(String.format("%s: %s", getObject(), editText.getText()));
   editText.setSelection(editText.getText().length());
 }
Example #10
0
  /** OnClickListener methods */
  @Override
  public void onClick(View view) {
    if (editText == null) {
      editText = new EditText(Utils.mainActivity);
      editText.setGravity(Gravity.CENTER);
      editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
    }

    if (inputType != null) {
      if (inputType.toLowerCase().equals("numeric"))
        editText.setInputType(InputType.TYPE_CLASS_NUMBER);
      else
        editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    } else if (lastLive instanceof Integer) editText.setInputType(InputType.TYPE_CLASS_NUMBER);
    else editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

    textView.setVisibility(View.GONE);
    if (editText.getParent() != null) {
      ((LinearLayout) editText.getParent()).findViewById(tv_id).setVisibility(View.VISIBLE);
      ((LinearLayout) editText.getParent()).removeView(editText);
    }

    elementFrame.addView(editText);
    editText.setOnEditorActionListener(this);
    editText.setText(lastEdit.toString());
    editText.requestFocus();
    editText.setSelection(0, editText.getText().length());
    Utils.imm.showSoftInput(editText, InputMethodManager.SHOW_FORCED);
  }
Example #11
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    Intent intent;
    switch (item.getItemId()) {
      case android.R.id.home:
        savaDraft();
        InputMethodManager imm =
            (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm.isActive())
          imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_NOT_ALWAYS);
        intent = new Intent(this, MainTimeLineActivity.class);
        intent.putExtra("account", getAccount());
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
        break;
      case R.id.menu_emoticon:
        EmotionsGridDialog dialog = new EmotionsGridDialog();
        dialog.show(getFragmentManager(), "");
        break;

      case R.id.menu_topic:
        String ori = content.getText().toString();
        String topicTag = "##";
        content.setText(ori + topicTag);
        content.setSelection(content.getText().toString().length() - 1);
        break;
      case R.id.menu_at:
        intent = new Intent(WriteWeiboActivity.this, AtUserActivity.class);
        intent.putExtra("token", token);
        startActivityForResult(intent, AT_USER);
        break;
    }
    return true;
  }
Example #12
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_edit_note, container, false);

    titleEditText = (EditText) rootView.findViewById(R.id.titleEditText);
    contentEditText = (EditText) rootView.findViewById(R.id.contentEditText);

    if (getArguments() != null) {
      note =
          new Note(
              getArguments().getString(ARG_ID),
              getArguments().getString(ARG_TITLE),
              getArguments().getString(ARG_CONTENT));

      titleEditText.setText(note.getTitle());
      // Place cursor at the end of title
      titleEditText.setSelection(titleEditText.getText().length());
      contentEditText.setText(note.getContent());

      showKeyboard = getArguments().getBoolean(ARG_SHOW_KEYBOARD);
    }

    titleEditText.clearFocus();

    if (showKeyboard) {
      titleEditText.requestFocus();
    }

    getActivity().setTitle(getString(R.string.title_add_note));
    return rootView;
  }
  private void updateTextDataUI() {

    if (!mIsTimestampDisplayMode) {
      if (mDataBufferLastSize != mDataBuffer.size()) {

        final int bufferSize = mDataBuffer.size();
        if (bufferSize > maxPacketsToPaintAsText) {
          mDataBufferLastSize = bufferSize - maxPacketsToPaintAsText;
          mTextSpanBuffer.clear();
          addTextToSpanBuffer(
              mTextSpanBuffer, getString(R.string.uart_text_dataomitted) + "\n", mInfoColor);
        }

        // Log.d(TAG, "update packets: "+(bufferSize-mDataBufferLastSize));
        for (int i = mDataBufferLastSize; i < bufferSize; i++) {
          final UartDataChunk dataChunk = mDataBuffer.get(i);
          final boolean isRX = dataChunk.getMode() == UartDataChunk.TRANSFERMODE_RX;
          final String data = dataChunk.getData();
          final String formattedData = mShowDataInHexFormat ? asciiToHex(data) : data;
          addTextToSpanBuffer(mTextSpanBuffer, formattedData, isRX ? mRxColor : mTxColor);
        }

        mDataBufferLastSize = mDataBuffer.size();
        mBufferTextView.setText(mTextSpanBuffer);
        mBufferTextView.setSelection(
            0, mTextSpanBuffer.length()); // to automatically scroll to the end
      }
    }
  }
  /*
   * gets user input from pop u p dialog
   *
   * @param title of the dialog
   *
   * @param message for dialog
   *
   * @param text firld to be assign data
   */
  private void getInputToField(String title, String message, final TextView field) {

    final EditText input = new EditText(this);
    input.setText(field.getText());
    input.setSelection(field.getText().length());
    new AlertDialog.Builder(this)
        .setTitle(title)
        .setMessage(message)
        .setView(input)
        .setPositiveButton(
            "Ok",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int whichButton) {

                field.setText(input.getText().toString());
              }
            })
        .setNegativeButton(
            "Cancel",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int whichButton) {
                // Do nothing.
              }
            })
        .show();
  }
 @Override
 public void onViewCreated(View view, Bundle savedInstanceState) {
   super.onViewCreated(view, savedInstanceState);
   flowProfitView.setTextColor(
       getResources().getColor(TradeUtil.getTextColorOfFloatProfitLoss(holdOrderInfo.oProfit)));
   flowProfitView.setText(
       TradeUtil.format(holdOrderInfo.oProfit, TradeConstants.AMOUNT_SCALE) + "");
   holdView.setText(
       goodsInfo == null
           ? (holdOrderInfo.hpPrice + "")
           : TradeUtil.formatExchangePrice(holdOrderInfo.hpPrice, goodsInfo.minPriceUnit));
   closeView.setText(
       goodsInfo == null
           ? (holdOrderInfo.cPrice + "")
           : TradeUtil.formatExchangePrice(holdOrderInfo.cPrice, goodsInfo.minPriceUnit));
   if (goodsInfo != null) {
     nameView.setText(goodsInfo.name);
   }
   orderIdView.setText(holdOrderInfo.hpid);
   rangeView.setText("手数范围1-" + holdOrderInfo.qty);
   numberTextView.setText(holdOrderInfo.qty + "");
   if (getActivity() != null && getActivity().getCurrentFocus() == numberEditView) {
     numberEditView.setSelection(numberEditView.getText().length());
   }
 }
Example #16
0
  private void showCustomEndpointDialog(final int originalSelection, String defaultUrl) {
    View view = LayoutInflater.from(app).inflate(R.layout.debug_drawer_network_endpoint, null);
    final EditText url = findById(view, R.id.debug_drawer_network_endpoint_url);
    url.setText(defaultUrl);
    url.setSelection(url.length());

    new AlertDialog.Builder(getContext()) //
        .setTitle("Set Network Endpoint")
        .setView(view)
        .setNegativeButton(
            "Cancel",
            (dialog, i) -> {
              endpointView.setSelection(originalSelection);
              dialog.cancel();
            })
        .setPositiveButton(
            "Use",
            (dialog, i) -> {
              String theUrl = url.getText().toString();
              if (!Strings.isBlank(theUrl)) {
                setEndpointAndRelaunch(theUrl);
              } else {
                endpointView.setSelection(originalSelection);
              }
            })
        .setOnCancelListener(
            (dialogInterface) -> {
              endpointView.setSelection(originalSelection);
            })
        .show();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.general_setting);
    Email = (EditText) findViewById(R.id.et_GeneralSetting_selected);
    Name = (EditText) findViewById(R.id.et_GeneralSetting_UserName_selected);
    myDb = new DbHelper(this);
    GetEmail();
    Email.setText(user_Email);
    int i = Email.getText().length();
    Email.setSelection(i);
    Name.setText(user_Name);
    int j = Name.getText().length();
    Name.setSelection(j);
  }
 private void updateTextBox(
     String currentFilter, String locEndingText, T obj, boolean updateText) {
   String prevEndtext = endingText;
   endingText = locEndingText;
   endingObject = obj;
   if (updateText) {
     searchText
         .getText()
         .replace(
             currentFilter.length(), currentFilter.length() + prevEndtext.length(), locEndingText);
   }
   if (previousSpan != null) {
     searchText.getText().removeSpan(previousSpan);
     previousSpan = null;
   }
   if (locEndingText.length() > 0) {
     previousSpan = new StyleSpan(Typeface.BOLD_ITALIC);
     searchText
         .getText()
         .setSpan(
             previousSpan,
             currentFilter.length(),
             currentFilter.length() + locEndingText.length(),
             Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
     if (searchText.getSelectionEnd() > currentFilter.length()) {
       searchText.setSelection(currentFilter.length());
     }
   }
 }
Example #19
0
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    // TODO Auto-generated method stub

    Object itemAdapter = parent.getAdapter();

    if (itemAdapter instanceof EmotionGvAdapter) {
      // 点击的是表情
      EmotionGvAdapter emotionGvAdapter = (EmotionGvAdapter) itemAdapter;

      if (position == emotionGvAdapter.getCount() - 1) {
        // 如果点击了最后一个回退按钮,则调用删除键事件
        msg.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));

      } else {

        // 如果点击了表情,则添加到输入框中
        String emotionName = (String) emotionGvAdapter.getItem(position);

        // 获取当前光标位置,在指定位置上添加表情图片文本
        int curPosition = msg.getSelectionStart();
        StringBuilder sb = new StringBuilder(msg.getText().toString());
        sb.insert(curPosition, emotionName);

        // 特殊文字处理,将表情等转换一下

        msg.setText(StringUtils.getEmotionContent(this, msg, sb.toString()));

        // 将光标设置到新增完表情的右侧
        msg.setSelection(curPosition + emotionName.length());
      }
    }
  }
  private void initView() {
    this.findViewById(R.id.backBtn).setOnClickListener(this);
    ((TextView) this.findViewById(R.id.titleTextView)).setText("设置备注");

    this.remarkEditText = (EditText) this.findViewById(R.id.remarkEditText);
    this.handleBtn = (Button) this.findViewById(R.id.handleBtn);
    this.handleBtn.setOnClickListener(this);

    this.commitBtn = (Button) this.findViewById(R.id.commitBtn);
    this.commitBtn.setOnClickListener(this);

    seekBar = (PaginationSeekBar) findViewById(R.id.starsSeekbar);
    seekBar.setMin(1);
    seekBar.setMax(1);
    seekBar.setPagecountPerOneboard(1, 9);
    seekBar.setHapticFeedbackEnabled(true);

    try {
      remarkEditText.setText(appDto.getCommunity());
      remarkEditText.setSelection(remarkEditText.getText().toString().trim().length());
    } catch (Exception e) {
    }

    this.handle = appDto.isHandle();
    this.handleBtn.setBackgroundResource(
        this.handle ? R.drawable.btn_toggle_on : R.drawable.btn_toggle_off);
    this.seekBar.setProgress(appDto.getStars());
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_edit_item);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                .setAction("Action", null)
                .show();
          }
        });

    displayText = getIntent().getStringExtra("ItemName");
    UpdatePosition = getIntent().getIntExtra("ItemPosition", 0);

    etEditText = (EditText) findViewById(R.id.etEditText);

    etEditText.setText(displayText);
    etEditText.setSelection(etEditText.getText().length());
  }
Example #22
0
 private void insertEmote(String emote) {
   selectionStart = mMessage.getSelectionStart();
   mMessage.getEditableText().insert(selectionStart, emote);
   mMessage.setSelection(selectionStart + emote.length());
   selectionStart = -1; // reset them for next time
   selectionEnd = -1;
 }
Example #23
0
 public static void setText(EditText editText, CharSequence text) {
   if (null == editText) {
     return;
   }
   editText.setText(text);
   editText.setSelection(editText.getText().length());
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (fragmentView == null) {
      fragmentView = inflater.inflate(R.layout.chat_profile_change_name_layout, container, false);

      TLRPC.Chat currentChat = MessagesController.Instance.chats.get(chat_id);

      firstNameField = (EditText) fragmentView.findViewById(R.id.first_name_field);
      firstNameField.setOnEditorActionListener(
          new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
              if (i == EditorInfo.IME_ACTION_DONE) {
                doneButton.performClick();
                return true;
              }
              return false;
            }
          });
      firstNameField.setText(currentChat.title);
      firstNameField.setSelection(firstNameField.length());

      TextView headerLabel = (TextView) fragmentView.findViewById(R.id.settings_section_text);
      headerLabel.setText(getStringEntry(R.string.EnterGroupNameTitle));
    } else {
      ViewGroup parent = (ViewGroup) fragmentView.getParent();
      if (parent != null) {
        parent.removeView(fragmentView);
      }
    }
    return fragmentView;
  }
 private void initData() {
   if (pet != null && !CommonTextUtils.isEmpty(pet.getName())) {
     nickname = pet.getName();
     mNickName.setText(pet.getName());
     mNickName.setSelection(pet.getName().length());
   }
 }
Example #26
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.search);

    // TODO: create layout
    mHistoryAdapter = new SearchHistoryAdapter(this);
    mResultAdapter = new SearchResultAdapter(this);

    mSearchText = (EditText) findViewById(R.id.search_text);
    mSearchText.setOnEditorActionListener(searchTextListener);
    mSearchText.addTextChangedListener(searchTextWatcher);

    final Intent queryIntent = getIntent();
    final String queryAction = queryIntent.getAction();
    if (Intent.ACTION_SEARCH.equals(queryAction)) {
      String query = queryIntent.getStringExtra(SearchManager.QUERY);
      mSearchText.setText(query);
      mSearchText.setSelection(query.length());
    } else {
      InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
      imm.showSoftInput(mSearchText, InputMethodManager.RESULT_SHOWN);
      showSearchHistory();
    }

    mSearchText.requestFocus();
  }
Example #27
0
  @Override
  protected void onListItemClick(ListView l, View v, int position, long id) {
    if (getListAdapter() == mHistoryAdapter) {
      String selection = ((TextView) v.findViewById(android.R.id.text1)).getText().toString();
      mSearchText.setText(selection);
      mSearchText.setSelection(selection.length());
      mSearchText.requestFocus();
    } else if (getListAdapter() == mResultAdapter) {
      // add search text to the database (history)
      MediaDatabase db = MediaDatabase.getInstance(this);
      db.addSearchhistoryItem(mSearchText.getText().toString());

      // open media in the player
      Media item = (Media) getListAdapter().getItem(position - 1);
      if (item.getType() == Media.TYPE_VIDEO) {
        VideoPlayerActivity.start(this, item.getLocation());
      } else {
        ArrayList<String> arr = new ArrayList<String>();
        for (int i = 0; i < getListAdapter().getCount(); i++) {
          Media audioItem = (Media) getListAdapter().getItem(i);
          if (audioItem.getType() == Media.TYPE_AUDIO) arr.add(audioItem.getLocation());
        }
        AudioServiceController.getInstance().load(arr, arr.indexOf(item.getLocation()));
        AudioPlayerActivity.start(this);
      }
      super.onListItemClick(l, v, position, id);
    }
  };
Example #28
0
  private void bindData() {
    task = (Task) getIntent().getSerializableExtra("task");
    tv_name.setText(task.getName());
    tv_name.setSelection(tv_name.length());
    tv_time.setText(TaskUtil.getZixiTimeS(task.getTime()));
    int p = 4320 - TaskUtil.getDurationFromNow(task.getTime());
    if (p <= 0) p = 1;
    pb.setText(TaskUtil.getDescriptionTimeFromTimestamp(task.getTime()));
    if (task.getTime() <= System.currentTimeMillis()) {
      pb.setRoundWidth(0);
      pb.setText(TaskUtil.getZixiDateS(task.getTime()));
    } else {
      pb.setRoundWidth(PixelUtil.dp2px(6));
    }
    if (p < 100) p = 100; // 防止太小了
    pb.setProgressNoAnim(p);
    if (task.getImageUrl() != null) {
      iv_home_bg.setImageURI(Uri.parse(task.getImageUrl()));
    }

    materialMenu.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            onBackPressed();
          }
        });

    String path = task.getAudioUrl();
    if (path != null) {
      final ImageButton ib_play = (ImageButton) ll_audio.findViewById(R.id.ib_play);
      final ProgressBar pb = (ProgressBar) ll_audio.findViewById(R.id.pb2);
      ib_play.setTag("play");
      ib_play.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              ib_play.setOnClickListener(
                  new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                      if (ib_play.getTag().equals("play")) {
                        ib_play.setImageResource(R.drawable.pause_audio);
                        ib_play.setTag("pause");
                        NotifyUtils.palyAudio(context, ib_play, pb, task.getAudioUrl());
                      } else {
                        ib_play.setTag("play");
                        ib_play.setImageResource(R.drawable.play_audio);
                        NotifyUtils.pauseAudio(ib_play);
                      }
                    }
                  });
            }
          });
    }
    if (task.getNote() != null) {
      ((TextView) findViewById(R.id.tv_note)).setText(task.getNote());
    }
  }
  public void showEditDialog(final int position, final QuickAnswer item) {
    AlertDialog.Builder builder =
        new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.QAPopup));
    builder.setTitle(position >= 0 ? R.string.edit : R.string.add);

    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final EditText et = (EditText) inflater.inflate(R.layout.edittext_holo, null);
    LinearLayout.LayoutParams p =
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    p.setMargins(
        MeasuresUtils.DpToPx(4),
        MeasuresUtils.DpToPx(15),
        MeasuresUtils.DpToPx(4),
        MeasuresUtils.DpToPx(15));
    et.setHint(R.string.edittext_hint_qa);
    et.setLayoutParams(p);
    if (item != null) {
      et.setText(item.getMessage());
      et.setSelection(item.getMessage().length());
    }
    et.postDelayed(
        new Runnable() {
          @Override
          public void run() {
            InputMethodManager keyboard =
                (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            keyboard.showSoftInput(et, 0);
          }
        },
        200);
    builder.setView(et);
    builder.setNegativeButton(
        R.string.cancel,
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialogInterface, int i) {
            dialogInterface.dismiss();
          }
        });

    builder.setPositiveButton(
        R.string.valid,
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialogInterface, int i) {
            if (et.getText() != null && et.getText().length() > 0) {
              if (item != null) {
                mAdapter.setMessageEdited(position, et.getText().toString());
              } else {
                mAdapter.addNewMessage(et.getText().toString());
              }
              dialogInterface.dismiss();
            }
          }
        });

    builder.create().show();
  }
Example #30
0
 public void insertEmotion(String emotionChar) {
   String ori = content.getText().toString();
   int index = content.getSelectionStart();
   StringBuilder stringBuilder = new StringBuilder(ori);
   stringBuilder.insert(index, emotionChar);
   content.setText(stringBuilder.toString());
   content.setSelection(index + emotionChar.length());
 }