List of usage examples for android.view View getRight
@ViewDebug.CapturedViewProperty public final int getRight()
From source file:com.appunite.list.AbsHorizontalListView.java
void updateScrollIndicators() { if (mScrollLeft != null) { boolean canScrollLeft; // 0th element is not visible canScrollLeft = mFirstPosition > 0; // ... Or top of 0th element is not visible if (!canScrollLeft) { if (getChildCount() > 0) { View child = getChildAt(0); canScrollLeft = child.getLeft() < mListPadding.left; }//from w w w. j a va 2s .co m } mScrollLeft.setVisibility(canScrollLeft ? View.VISIBLE : View.INVISIBLE); } if (mScrollRight != null) { boolean canScrollRight; int count = getChildCount(); // Last item is not visible canScrollRight = (mFirstPosition + count) < mItemCount; // ... Or bottom of the last element is not visible if (!canScrollRight && count > 0) { View child = getChildAt(count - 1); final int right = getRight(); canScrollRight = child.getRight() > right - mListPadding.right; } mScrollRight.setVisibility(canScrollRight ? View.VISIBLE : View.INVISIBLE); } }
From source file:com.aliasapps.seq.scroller.TwoWayView.java
private void fillBeforeAndAfter(View selected, int position) { final int itemMargin = mItemMargin; final int offsetBefore; if (mIsVertical) { offsetBefore = selected.getTop() - itemMargin; } else {/*from w w w. j a v a 2 s. c o m*/ offsetBefore = selected.getLeft() - itemMargin; } fillBefore(position - 1, offsetBefore); adjustViewsStartOrEnd(); final int offsetAfter; if (mIsVertical) { offsetAfter = selected.getBottom() + itemMargin; } else { offsetAfter = selected.getRight() + itemMargin; } fillAfter(position + 1, offsetAfter); }
From source file:com.artifex.mupdf.view.ThumbnailViews.java
private View moveSelection(View oldSelected, View newSelected, int delta, int start, int end) { final int selectedPosition = mSelectedPosition; final int oldSelectedStart = (mIsVertical ? oldSelected.getTop() : oldSelected.getLeft()); final int oldSelectedEnd = (mIsVertical ? oldSelected.getBottom() : oldSelected.getRight()); View selected = null;/* w ww .j a v a 2s . co m*/ if (delta > 0) { /* * Case 1: Scrolling down. */ /* * Before After | | | | +-------+ +-------+ | A | | A | | 1 | => * +-------+ +-------+ | B | | B | | 2 | +-------+ +-------+ | | | | * * Try to keep the top of the previously selected item where it was. * oldSelected = A selected = B */ // Put oldSelected (A) where it belongs oldSelected = makeAndAddView(selectedPosition - 1, oldSelectedStart, true, false); final int itemMargin = mItemMargin; // Now put the new selection (B) below that selected = makeAndAddView(selectedPosition, oldSelectedEnd + itemMargin, true, true); final int selectedStart = (mIsVertical ? selected.getTop() : selected.getLeft()); final int selectedEnd = (mIsVertical ? selected.getBottom() : selected.getRight()); // Some of the newly selected item extends below the bottom of the // list if (selectedEnd > end) { // Find space available above the selection into which we can // scroll upwards final int spaceBefore = selectedStart - start; // Find space required to bring the bottom of the selected item // fully into view final int spaceAfter = selectedEnd - end; // Don't scroll more than half the size of the list final int halfSpace = (end - start) / 2; int offset = Math.min(spaceBefore, spaceAfter); offset = Math.min(offset, halfSpace); if (mIsVertical) { oldSelected.offsetTopAndBottom(-offset); selected.offsetTopAndBottom(-offset); } else { oldSelected.offsetLeftAndRight(-offset); selected.offsetLeftAndRight(-offset); } } // Fill in views before and after fillBefore(mSelectedPosition - 2, selectedStart - itemMargin); adjustViewsStartOrEnd(); fillAfter(mSelectedPosition + 1, selectedEnd + itemMargin); } else if (delta < 0) { /* * Case 2: Scrolling up. */ /* * Before After | | | | +-------+ +-------+ | A | | A | +-------+ => * | 1 | | B | +-------+ | 2 | | B | +-------+ +-------+ | | | | * * Try to keep the top of the item about to become selected where it * was. newSelected = A olSelected = B */ if (newSelected != null) { // Try to position the top of newSel (A) where it was before it // was selected final int newSelectedStart = (mIsVertical ? newSelected.getTop() : newSelected.getLeft()); selected = makeAndAddView(selectedPosition, newSelectedStart, true, true); } else { // If (A) was not on screen and so did not have a view, position // it above the oldSelected (B) selected = makeAndAddView(selectedPosition, oldSelectedStart, false, true); } final int selectedStart = (mIsVertical ? selected.getTop() : selected.getLeft()); final int selectedEnd = (mIsVertical ? selected.getBottom() : selected.getRight()); // Some of the newly selected item extends above the top of the list if (selectedStart < start) { // Find space required to bring the top of the selected item // fully into view final int spaceBefore = start - selectedStart; // Find space available below the selection into which we can // scroll downwards final int spaceAfter = end - selectedEnd; // Don't scroll more than half the height of the list final int halfSpace = (end - start) / 2; int offset = Math.min(spaceBefore, spaceAfter); offset = Math.min(offset, halfSpace); if (mIsVertical) { selected.offsetTopAndBottom(offset); } else { selected.offsetLeftAndRight(offset); } } // Fill in views above and below fillBeforeAndAfter(selected, selectedPosition); } else { /* * Case 3: Staying still */ selected = makeAndAddView(selectedPosition, oldSelectedStart, true, true); final int selectedStart = (mIsVertical ? selected.getTop() : selected.getLeft()); final int selectedEnd = (mIsVertical ? selected.getBottom() : selected.getRight()); // We're staying still... if (oldSelectedStart < start) { // ... but the top of the old selection was off screen. // (This can happen if the data changes size out from under us) int newEnd = selectedEnd; if (newEnd < start + 20) { // Not enough visible -- bring it onscreen if (mIsVertical) { selected.offsetTopAndBottom(start - selectedStart); } else { selected.offsetLeftAndRight(start - selectedStart); } } } // Fill in views above and below fillBeforeAndAfter(selected, selectedPosition); } return selected; }
From source file:com.aliasapps.seq.scroller.TwoWayView.java
/** * Determine how much we need to scroll in order to get the next selected view * visible. The amount is capped at {@link #getMaxScrollAmount()}. * * @param direction either {@link View#FOCUS_UP} or {@link View#FOCUS_DOWN} or * {@link View#FOCUS_LEFT} or {@link View#FOCUS_RIGHT} depending on the * current view orientation.//from w w w . jav a 2 s . c o m * @param nextSelectedPosition The position of the next selection, or * {@link #INVALID_POSITION} if there is no next selectable position * * @return The amount to scroll. Note: this is always positive! Direction * needs to be taken into account when actually scrolling. */ private int amountToScroll(int direction, int nextSelectedPosition) { forceValidFocusDirection(direction); final int numChildren = getChildCount(); if (direction == View.FOCUS_DOWN || direction == View.FOCUS_RIGHT) { final int end = (mIsVertical ? getHeight() - getPaddingBottom() : getWidth() - getPaddingRight()); int indexToMakeVisible = numChildren - 1; if (nextSelectedPosition != INVALID_POSITION) { indexToMakeVisible = nextSelectedPosition - mFirstPosition; } final int positionToMakeVisible = mFirstPosition + indexToMakeVisible; final View viewToMakeVisible = getChildAt(indexToMakeVisible); int goalEnd = end; if (positionToMakeVisible < mItemCount - 1) { goalEnd -= getArrowScrollPreviewLength(); } final int viewToMakeVisibleStart = (mIsVertical ? viewToMakeVisible.getTop() : viewToMakeVisible.getLeft()); final int viewToMakeVisibleEnd = (mIsVertical ? viewToMakeVisible.getBottom() : viewToMakeVisible.getRight()); if (viewToMakeVisibleEnd <= goalEnd) { // Target item is fully visible return 0; } if (nextSelectedPosition != INVALID_POSITION && (goalEnd - viewToMakeVisibleStart) >= getMaxScrollAmount()) { // Item already has enough of it visible, changing selection is good enough return 0; } int amountToScroll = (viewToMakeVisibleEnd - goalEnd); if (mFirstPosition + numChildren == mItemCount) { final View lastChild = getChildAt(numChildren - 1); final int lastChildEnd = (mIsVertical ? lastChild.getBottom() : lastChild.getRight()); // Last is last in list -> Make sure we don't scroll past it final int max = lastChildEnd - end; amountToScroll = Math.min(amountToScroll, max); } return Math.min(amountToScroll, getMaxScrollAmount()); } else { final int start = (mIsVertical ? getPaddingTop() : getPaddingLeft()); int indexToMakeVisible = 0; if (nextSelectedPosition != INVALID_POSITION) { indexToMakeVisible = nextSelectedPosition - mFirstPosition; } final int positionToMakeVisible = mFirstPosition + indexToMakeVisible; final View viewToMakeVisible = getChildAt(indexToMakeVisible); int goalStart = start; if (positionToMakeVisible > 0) { goalStart += getArrowScrollPreviewLength(); } final int viewToMakeVisibleStart = (mIsVertical ? viewToMakeVisible.getTop() : viewToMakeVisible.getLeft()); final int viewToMakeVisibleEnd = (mIsVertical ? viewToMakeVisible.getBottom() : viewToMakeVisible.getRight()); if (viewToMakeVisibleStart >= goalStart) { // Item is fully visible return 0; } if (nextSelectedPosition != INVALID_POSITION && (viewToMakeVisibleEnd - goalStart) >= getMaxScrollAmount()) { // Item already has enough of it visible, changing selection is good enough return 0; } int amountToScroll = (goalStart - viewToMakeVisibleStart); if (mFirstPosition == 0) { final View firstChild = getChildAt(0); final int firstChildStart = (mIsVertical ? firstChild.getTop() : firstChild.getLeft()); // First is first in list -> make sure we don't scroll past it final int max = start - firstChildStart; amountToScroll = Math.min(amountToScroll, max); } return Math.min(amountToScroll, getMaxScrollAmount()); } }
From source file:com.artifex.mupdf.view.ThumbnailViews.java
/** * Determine how much we need to scroll in order to get the next selected * view visible. The amount is capped at {@link #getMaxScrollAmount()}. * // w w w.j a v a2 s. co m * @param direction * either {@link View#FOCUS_UP} or {@link View#FOCUS_DOWN} or * {@link View#FOCUS_LEFT} or {@link View#FOCUS_RIGHT} depending * on the current view orientation. * @param nextSelectedPosition * The position of the next selection, or * {@link #INVALID_POSITION} if there is no next selectable * position * * @return The amount to scroll. Note: this is always positive! Direction * needs to be taken into account when actually scrolling. */ private int amountToScroll(int direction, int nextSelectedPosition) { forceValidFocusDirection(direction); final int numChildren = getChildCount(); if (direction == View.FOCUS_DOWN || direction == View.FOCUS_RIGHT) { final int end = (mIsVertical ? getHeight() - getPaddingBottom() : getWidth() - getPaddingRight()); int indexToMakeVisible = numChildren - 1; if (nextSelectedPosition != INVALID_POSITION) { indexToMakeVisible = nextSelectedPosition - mFirstPosition; } final int positionToMakeVisible = mFirstPosition + indexToMakeVisible; final View viewToMakeVisible = getChildAt(indexToMakeVisible); int goalEnd = end; if (positionToMakeVisible < mItemCount - 1) { goalEnd -= getArrowScrollPreviewLength(); } final int viewToMakeVisibleStart = (mIsVertical ? viewToMakeVisible.getTop() : viewToMakeVisible.getLeft()); final int viewToMakeVisibleEnd = (mIsVertical ? viewToMakeVisible.getBottom() : viewToMakeVisible.getRight()); if (viewToMakeVisibleEnd <= goalEnd) { // Target item is fully visible return 0; } if (nextSelectedPosition != INVALID_POSITION && (goalEnd - viewToMakeVisibleStart) >= getMaxScrollAmount()) { // Item already has enough of it visible, changing selection is // good enough return 0; } int amountToScroll = (viewToMakeVisibleEnd - goalEnd); if (mFirstPosition + numChildren == mItemCount) { final View lastChild = getChildAt(numChildren - 1); final int lastChildEnd = (mIsVertical ? lastChild.getBottom() : lastChild.getRight()); // Last is last in list -> Make sure we don't scroll past it final int max = lastChildEnd - end; amountToScroll = Math.min(amountToScroll, max); } return Math.min(amountToScroll, getMaxScrollAmount()); } else { final int start = (mIsVertical ? getPaddingTop() : getPaddingLeft()); int indexToMakeVisible = 0; if (nextSelectedPosition != INVALID_POSITION) { indexToMakeVisible = nextSelectedPosition - mFirstPosition; } final int positionToMakeVisible = mFirstPosition + indexToMakeVisible; final View viewToMakeVisible = getChildAt(indexToMakeVisible); int goalStart = start; if (positionToMakeVisible > 0) { goalStart += getArrowScrollPreviewLength(); } final int viewToMakeVisibleStart = (mIsVertical ? viewToMakeVisible.getTop() : viewToMakeVisible.getLeft()); final int viewToMakeVisibleEnd = (mIsVertical ? viewToMakeVisible.getBottom() : viewToMakeVisible.getRight()); if (viewToMakeVisibleStart >= goalStart) { // Item is fully visible return 0; } if (nextSelectedPosition != INVALID_POSITION && (viewToMakeVisibleEnd - goalStart) >= getMaxScrollAmount()) { // Item already has enough of it visible, changing selection is // good enough return 0; } int amountToScroll = (goalStart - viewToMakeVisibleStart); if (mFirstPosition == 0) { final View firstChild = getChildAt(0); final int firstChildStart = (mIsVertical ? firstChild.getTop() : firstChild.getLeft()); // First is first in list -> make sure we don't scroll past it final int max = start - firstChildStart; amountToScroll = Math.min(amountToScroll, max); } return Math.min(amountToScroll, getMaxScrollAmount()); } }
From source file:com.artifex.mupdflib.TwoWayView.java
private int getChildEndEdge(View child) { return (mIsVertical ? child.getBottom() : child.getRight()); }
From source file:com.aliasapps.seq.scroller.TwoWayView.java
private View fillSpecific(int position, int offset) { final boolean tempIsSelected = (position == mSelectedPosition); View temp = makeAndAddView(position, offset, true, tempIsSelected); // Possibly changed again in fillBefore if we add rows above this one. mFirstPosition = position;//from w w w . j a v a2 s.c om final int itemMargin = mItemMargin; final int offsetBefore; if (mIsVertical) { offsetBefore = temp.getTop() - itemMargin; } else { offsetBefore = temp.getLeft() - itemMargin; } final View before = fillBefore(position - 1, offsetBefore); // This will correct for the top of the first view not touching the top of the list adjustViewsStartOrEnd(); final int offsetAfter; if (mIsVertical) { offsetAfter = temp.getBottom() + itemMargin; } else { offsetAfter = temp.getRight() + itemMargin; } final View after = fillAfter(position + 1, offsetAfter); final int childCount = getChildCount(); if (childCount > 0) { correctTooHigh(childCount); } if (tempIsSelected) { return temp; } else if (before != null) { return before; } else { return after; } }
From source file:com.artifex.mupdf.view.ThumbnailViews.java
private View fillSpecific(int position, int offset) { final boolean tempIsSelected = (position == mSelectedPosition); View temp = makeAndAddView(position, offset, true, tempIsSelected); // Possibly changed again in fillBefore if we add rows above this one. mFirstPosition = position;//from ww w .jav a 2 s.c o m final int itemMargin = mItemMargin; final int offsetBefore; if (mIsVertical) { offsetBefore = temp.getTop() - itemMargin; } else { offsetBefore = temp.getLeft() - itemMargin; } final View before = fillBefore(position - 1, offsetBefore); // This will correct for the top of the first view not touching the top // of the list adjustViewsStartOrEnd(); final int offsetAfter; if (mIsVertical) { offsetAfter = temp.getBottom() + itemMargin; } else { offsetAfter = temp.getRight() + itemMargin; } final View after = fillAfter(position + 1, offsetAfter); final int childCount = getChildCount(); if (childCount > 0) { correctTooHigh(childCount); } if (tempIsSelected) { return temp; } else if (before != null) { return before; } else { return after; } }
From source file:com.aliasapps.seq.scroller.TwoWayView.java
boolean resurrectSelection() { final int childCount = getChildCount(); if (childCount <= 0) { return false; }/*from w w w.j a va 2 s. co m*/ int selectedStart = 0; int selectedPosition; final int start = (mIsVertical ? getPaddingTop() : getPaddingLeft()); final int end = (mIsVertical ? getHeight() - getPaddingBottom() : getWidth() - getPaddingRight()); final int firstPosition = mFirstPosition; final int toPosition = mResurrectToPosition; boolean down = true; if (toPosition >= firstPosition && toPosition < firstPosition + childCount) { selectedPosition = toPosition; final View selected = getChildAt(selectedPosition - mFirstPosition); selectedStart = (mIsVertical ? selected.getTop() : selected.getLeft()); } else if (toPosition < firstPosition) { // Default to selecting whatever is first selectedPosition = firstPosition; for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); final int childStart = (mIsVertical ? child.getTop() : child.getLeft()); if (i == 0) { // Remember the position of the first item selectedStart = childStart; } if (childStart >= start) { // Found a view whose top is fully visible selectedPosition = firstPosition + i; selectedStart = childStart; break; } } } else { selectedPosition = firstPosition + childCount - 1; down = false; for (int i = childCount - 1; i >= 0; i--) { final View child = getChildAt(i); final int childStart = (mIsVertical ? child.getTop() : child.getLeft()); final int childEnd = (mIsVertical ? child.getBottom() : child.getRight()); if (i == childCount - 1) { selectedStart = childStart; } if (childEnd <= end) { selectedPosition = firstPosition + i; selectedStart = childStart; break; } } } mResurrectToPosition = INVALID_POSITION; mTouchMode = TOUCH_MODE_REST; reportScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE); mSpecificStart = selectedStart; selectedPosition = lookForSelectablePosition(selectedPosition, down); if (selectedPosition >= firstPosition && selectedPosition <= getLastVisiblePosition()) { mLayoutMode = LAYOUT_SPECIFIC; updateSelectorState(); setSelectionInt(selectedPosition); invokeOnItemScrollListener(); } else { selectedPosition = INVALID_POSITION; } return selectedPosition >= 0; }
From source file:me.ububble.speakall.fragment.ConversationGroupFragment.java
@Override public boolean onTouch(View v, MotionEvent event) { int action = event.getActionMasked(); switch (v.getId()) { case R.id.record_audio: switch (action) { case MotionEvent.ACTION_DOWN: textRecordingPress.setVisibility(View.INVISIBLE); rect = new Rect(v.getLeft(), v.getTop(), v.getRight(), v.getBottom()); fechaAudioMillis = Calendar.getInstance().getTimeInMillis(); File directory = new File( Environment.getExternalStorageDirectory().getAbsolutePath() + "/SpeakOn/Audio/Sent"); directory.mkdirs();//from ww w . j a v a 2 s.com ficheroAudio = Environment.getExternalStorageDirectory().getAbsolutePath() + "/SpeakOn/Audio/Sent/" + fechaAudioMillis + ".mp4"; mediaRecorder = new MediaRecorder(); mediaRecorder.setOutputFile(ficheroAudio); mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC); try { mediaRecorder.prepare(); } catch (IOException e) { } mediaRecorder.start(); handler.post(new Runnable() { @Override public void run() { finalTime += 1000; int seconds = (int) (finalTime / 1000) % 60; int minutes = (int) ((finalTime / (1000 * 60)) % 60); int hours = (int) ((finalTime / (1000 * 60 * 60)) % 24); timeFinal = String.format("%02d", minutes) + ":" + String.format("%02d", seconds); timerAudio.setText(timeFinal); if (!saveAudio) { textRecording.setText(timeFinal); } handler.postDelayed(this, 1000); } }); scaleAnimX = ObjectAnimator.ofFloat(recordAudioButton, "scaleX", 1, 1.2f); scaleAnimX.setDuration(800); scaleAnimX.setRepeatCount(ValueAnimator.INFINITE); scaleAnimX.setRepeatMode(ValueAnimator.REVERSE); scaleAnimY = ObjectAnimator.ofFloat(recordAudioButton, "scaleY", 1, 1.2f); scaleAnimY.setDuration(800); scaleAnimY.setRepeatCount(ValueAnimator.INFINITE); scaleAnimY.setRepeatMode(ValueAnimator.REVERSE); scaleAnimY.start(); scaleAnimX.start(); scaleRedBackgroundX = ObjectAnimator.ofFloat(audioRecordBackground, "scaleX", 1, 100f); scaleRedBackgroundX.setDuration(200); scaleRedBackgroundY = ObjectAnimator.ofFloat(audioRecordBackground, "scaleY", 1, 100f); scaleRedBackgroundY.setDuration(200); saveAudio = true; break; case MotionEvent.ACTION_MOVE: if (!rect.contains(v.getLeft() + (int) event.getX(), v.getTop() + (int) event.getY())) { recordAudioButton.setBackgroundResource(R.drawable.rounded_record_audio_white); timerAudio.setVisibility(View.GONE); textRecording.setTextColor(getResources().getColor(R.color.speak_all_red)); if (!animatorBackground) { textRecording.setText(timeFinal); if (scaleRedBackgroundX.isRunning()) scaleRedBackgroundX.end(); if (scaleRedBackgroundY.isRunning()) scaleRedBackgroundY.end(); scaleRedBackgroundY.start(); scaleRedBackgroundX.start(); animatorBackground = true; } saveAudio = false; } else { recordAudioButton.setBackgroundResource(R.drawable.rounded_record_audio_red); textRecording.setTextColor(getResources().getColor(R.color.speak_all_white)); textRecording.setText(getString(R.string.audio_record)); timerAudio.setVisibility(View.VISIBLE); if (animatorBackground) { if (scaleRedBackgroundX.isRunning()) scaleRedBackgroundX.end(); if (scaleRedBackgroundY.isRunning()) scaleRedBackgroundY.end(); ViewHelper.setScaleX(audioRecordBackground, 1); ViewHelper.setScaleY(audioRecordBackground, 1); animatorBackground = false; } saveAudio = true; } break; case MotionEvent.ACTION_UP: textRecordingPress.setVisibility(View.VISIBLE); animatorBackground = false; if (scaleAnimY.isRunning()) scaleAnimY.end(); if (scaleAnimX.isRunning()) scaleAnimX.end(); if (scaleRedBackgroundX.isRunning()) scaleRedBackgroundX.end(); if (scaleRedBackgroundY.isRunning()) scaleRedBackgroundY.end(); ViewHelper.setScaleX(audioRecordBackground, 1); ViewHelper.setScaleY(audioRecordBackground, 1); ViewHelper.setScaleX(recordAudioButton, 1); ViewHelper.setScaleY(recordAudioButton, 1); handler.removeCallbacksAndMessages(null); timerAudio.setText("00:00"); timerAudio.setVisibility(View.VISIBLE); textRecording.setTextColor(getResources().getColor(R.color.speak_all_white)); textRecording.setText(getString(R.string.audio_record)); recordAudioButton.setBackgroundResource(R.drawable.rounded_record_audio_red); if (finalTime > 1000) { mediaRecorder.stop(); mediaRecorder.release(); } else { saveAudio = false; mediaRecorder.release(); } finalTime = 0; timeFinal = ""; if (saveAudio) { try { hideKeyBoard(); final MsgGroups msjAudio = new MsgGroups(); JSONArray targets = new JSONArray(); JSONArray contactos = new JSONArray(grupo.targets); String contactosId = null; if (SpeakSocket.mSocket != null) { if (SpeakSocket.mSocket.connected()) { for (int i = 0; i < contactos.length(); i++) { JSONObject contacto = contactos.getJSONObject(i); JSONObject newContact = new JSONObject(); Contact contact = new Select().from(Contact.class) .where("id_contact = ?", contacto.getString("name")).executeSingle(); if (contact != null) { if (!contact.idContacto.equals(u.id)) { if (translate) newContact.put("lang", contact.lang); else newContact.put("lang", u.lang); newContact.put("name", contact.idContacto); newContact.put("screen_name", contact.screenName); newContact.put("status", 1); contactosId += contact.idContacto; targets.put(targets.length(), newContact); } } } } else { for (int i = 0; i < contactos.length(); i++) { JSONObject contacto = contactos.getJSONObject(i); JSONObject newContact = new JSONObject(); Contact contact = new Select().from(Contact.class) .where("id_contact = ?", contacto.getString("name")).executeSingle(); if (contact != null) { if (!contact.idContacto.equals(u.id)) { if (translate) newContact.put("lang", contact.lang); else newContact.put("lang", u.lang); newContact.put("name", contact.idContacto); newContact.put("screen_name", contact.screenName); newContact.put("status", -1); contactosId += contact.idContacto; targets.put(targets.length(), newContact); } } } } } msjAudio.grupoId = grupo.grupoId; msjAudio.mensajeId = u.id + grupo.grupoId + fechaAudioMillis + Settings.Secure .getString(activity.getContentResolver(), Settings.Secure.ANDROID_ID); msjAudio.emisor = u.id; msjAudio.receptores = targets.toString(); msjAudio.mensaje = "new Audio"; msjAudio.emisorEmail = u.email; msjAudio.emisorLang = u.lang; msjAudio.translation = false; msjAudio.emitedAt = fechaAudioMillis; msjAudio.tipo = Integer.parseInt(getString(R.string.MSG_TYPE_GROUP_AUDIO)); msjAudio.delay = 0; msjAudio.fileUploaded = false; msjAudio.audioName = ficheroAudio; msjAudio.save(); showNewMessage(msjAudio); } catch (Exception e) { // TODO: handle exception } } else { new File(ficheroAudio).delete(); } break; } break; } return true; }