Java Code Examples for org.telegram.messenger.MessageObject#getDialogId()

The following examples show how to use org.telegram.messenger.MessageObject#getDialogId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocationActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private int getMessageId(TLRPC.Message message) {
    if (message.from_id != 0) {
        return message.from_id;
    } else {
        return (int) MessageObject.getDialogId(message);
    }
}
 
Example 2
Source File: MediaActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public boolean addMessage(MessageObject messageObject, boolean isNew, boolean enc) {
    int loadIndex = messageObject.getDialogId() == dialog_id ? 0 : 1;
    if (messagesDict[loadIndex].indexOfKey(messageObject.getId()) >= 0) {
        return false;
    }
    ArrayList<MessageObject> messageObjects = sectionArrays.get(messageObject.monthKey);
    if (messageObjects == null) {
        messageObjects = new ArrayList<>();
        sectionArrays.put(messageObject.monthKey, messageObjects);
        if (isNew) {
            sections.add(0, messageObject.monthKey);
        } else {
            sections.add(messageObject.monthKey);
        }
    }
    if (isNew) {
        messageObjects.add(0, messageObject);
        messages.add(0, messageObject);
    } else {
        messageObjects.add(messageObject);
        messages.add(messageObject);
    }
    messagesDict[loadIndex].put(messageObject.getId(), messageObject);
    if (!enc) {
        if (messageObject.getId() > 0) {
            max_id[loadIndex] = Math.min(messageObject.getId(), max_id[loadIndex]);
        }
    } else {
        max_id[loadIndex] = Math.max(messageObject.getId(), max_id[loadIndex]);
    }
    return true;
}
 
Example 3
Source File: PopupNotificationActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void getNewMessage() {
    if (popupMessages.isEmpty()) {
        onFinish();
        finish();
        return;
    }

    boolean found = false;
    if ((currentMessageNum != 0 || chatActivityEnterView.hasText() || startedMoving) && currentMessageObject != null) {
        for (int a = 0, size = popupMessages.size(); a < size; a++) {
            MessageObject messageObject = popupMessages.get(a);
            if (messageObject.currentAccount == currentMessageObject.currentAccount && messageObject.getDialogId() == currentMessageObject.getDialogId() && messageObject.getId() == currentMessageObject.getId()) {
                currentMessageNum = a;
                found = true;
                break;
            }
        }
    }
    if (!found) {
        currentMessageNum = 0;
        currentMessageObject = popupMessages.get(0);
        updateInterfaceForCurrentMessage(0);
    } else if (startedMoving) {
        if (currentMessageNum == popupMessages.size() - 1) {
            prepareLayouts(3);
        } else if (currentMessageNum == 1) {
            prepareLayouts(4);
        }
    }
    countText.setText(String.format("%d/%d", currentMessageNum + 1, popupMessages.size()));
}
 
Example 4
Source File: LocationActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private int getMessageId(TLRPC.Message message) {
    if (message.from_id != 0) {
        return message.from_id;
    } else {
        return (int) MessageObject.getDialogId(message);
    }
}
 
Example 5
Source File: MediaActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public boolean addMessage(MessageObject messageObject, boolean isNew, boolean enc) {
    int loadIndex = messageObject.getDialogId() == dialog_id ? 0 : 1;
    if (messagesDict[loadIndex].indexOfKey(messageObject.getId()) >= 0) {
        return false;
    }
    ArrayList<MessageObject> messageObjects = sectionArrays.get(messageObject.monthKey);
    if (messageObjects == null) {
        messageObjects = new ArrayList<>();
        sectionArrays.put(messageObject.monthKey, messageObjects);
        if (isNew) {
            sections.add(0, messageObject.monthKey);
        } else {
            sections.add(messageObject.monthKey);
        }
    }
    if (isNew) {
        messageObjects.add(0, messageObject);
        messages.add(0, messageObject);
    } else {
        messageObjects.add(messageObject);
        messages.add(messageObject);
    }
    messagesDict[loadIndex].put(messageObject.getId(), messageObject);
    if (!enc) {
        if (messageObject.getId() > 0) {
            max_id[loadIndex] = Math.min(messageObject.getId(), max_id[loadIndex]);
        }
    } else {
        max_id[loadIndex] = Math.max(messageObject.getId(), max_id[loadIndex]);
    }
    return true;
}
 
Example 6
Source File: PopupNotificationActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void getNewMessage() {
    if (popupMessages.isEmpty()) {
        onFinish();
        finish();
        return;
    }

    boolean found = false;
    if ((currentMessageNum != 0 || chatActivityEnterView.hasText() || startedMoving) && currentMessageObject != null) {
        for (int a = 0, size = popupMessages.size(); a < size; a++) {
            MessageObject messageObject = popupMessages.get(a);
            if (messageObject.currentAccount == currentMessageObject.currentAccount && messageObject.getDialogId() == currentMessageObject.getDialogId() && messageObject.getId() == currentMessageObject.getId()) {
                currentMessageNum = a;
                found = true;
                break;
            }
        }
    }
    if (!found) {
        currentMessageNum = 0;
        currentMessageObject = popupMessages.get(0);
        updateInterfaceForCurrentMessage(0);
    } else if (startedMoving) {
        if (currentMessageNum == popupMessages.size() - 1) {
            prepareLayouts(3);
        } else if (currentMessageNum == 1) {
            prepareLayouts(4);
        }
    }
    countText.setText(String.format("%d/%d", currentMessageNum + 1, popupMessages.size()));
}
 
Example 7
Source File: LocationActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private int getMessageId(TLRPC.Message message) {
    if (message.from_id != 0) {
        return message.from_id;
    } else {
        return (int) MessageObject.getDialogId(message);
    }
}
 
Example 8
Source File: PopupNotificationActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void getNewMessage() {
    if (popupMessages.isEmpty()) {
        onFinish();
        finish();
        return;
    }

    boolean found = false;
    if ((currentMessageNum != 0 || chatActivityEnterView.hasText() || startedMoving) && currentMessageObject != null) {
        for (int a = 0, size = popupMessages.size(); a < size; a++) {
            MessageObject messageObject = popupMessages.get(a);
            if (messageObject.currentAccount == currentMessageObject.currentAccount && messageObject.getDialogId() == currentMessageObject.getDialogId() && messageObject.getId() == currentMessageObject.getId()) {
                currentMessageNum = a;
                found = true;
                break;
            }
        }
    }
    if (!found) {
        currentMessageNum = 0;
        currentMessageObject = popupMessages.get(0);
        updateInterfaceForCurrentMessage(0);
    } else if (startedMoving) {
        if (currentMessageNum == popupMessages.size() - 1) {
            prepareLayouts(3);
        } else if (currentMessageNum == 1) {
            prepareLayouts(4);
        }
    }
    countText.setText(String.format("%d/%d", currentMessageNum + 1, popupMessages.size()));
}
 
Example 9
Source File: LocationActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private int getMessageId(TLRPC.Message message) {
    if (message.from_id != 0) {
        return message.from_id;
    } else {
        return (int) MessageObject.getDialogId(message);
    }
}
 
Example 10
Source File: PopupNotificationActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void getNewMessage() {
    if (popupMessages.isEmpty()) {
        onFinish();
        finish();
        return;
    }

    boolean found = false;
    if ((currentMessageNum != 0 || chatActivityEnterView.hasText() || startedMoving) && currentMessageObject != null) {
        for (int a = 0, size = popupMessages.size(); a < size; a++) {
            MessageObject messageObject = popupMessages.get(a);
            if (messageObject.currentAccount == currentMessageObject.currentAccount && messageObject.getDialogId() == currentMessageObject.getDialogId() && messageObject.getId() == currentMessageObject.getId()) {
                currentMessageNum = a;
                found = true;
                break;
            }
        }
    }
    if (!found) {
        currentMessageNum = 0;
        currentMessageObject = popupMessages.get(0);
        updateInterfaceForCurrentMessage(0);
    } else if (startedMoving) {
        if (currentMessageNum == popupMessages.size() - 1) {
            prepareLayouts(3);
        } else if (currentMessageNum == 1) {
            prepareLayouts(4);
        }
    }
    countText.setText(String.format("%d/%d", currentMessageNum + 1, popupMessages.size()));
}
 
Example 11
Source File: LocationActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private LiveLocation addUserMarker(TLRPC.Message message) {
    LiveLocation liveLocation;
    LatLng latLng = new LatLng(message.media.geo.lat, message.media.geo._long);
    if ((liveLocation = markersMap.get(message.from_id)) == null) {
        liveLocation = new LiveLocation();
        liveLocation.object = message;
        if (liveLocation.object.from_id != 0) {
            liveLocation.user = MessagesController.getInstance(currentAccount).getUser(liveLocation.object.from_id);
            liveLocation.id = liveLocation.object.from_id;
        } else {
            int did = (int) MessageObject.getDialogId(message);
            if (did > 0) {
                liveLocation.user = MessagesController.getInstance(currentAccount).getUser(did);
                liveLocation.id = did;
            } else {
                liveLocation.chat = MessagesController.getInstance(currentAccount).getChat(-did);
                liveLocation.id = did;
            }
        }

        try {
            MarkerOptions options = new MarkerOptions().position(latLng);
            Bitmap bitmap = createUserBitmap(liveLocation);
            if (bitmap != null) {
                options.icon(BitmapDescriptorFactory.fromBitmap(bitmap));
                options.anchor(0.5f, 0.907f);
                liveLocation.marker = googleMap.addMarker(options);
                markers.add(liveLocation);
                markersMap.put(liveLocation.id, liveLocation);
                LocationController.SharingLocationInfo myInfo = LocationController.getInstance(currentAccount).getSharingLocationInfo(dialogId);
                if (liveLocation.id == UserConfig.getInstance(currentAccount).getClientUserId() && myInfo != null && liveLocation.object.id == myInfo.mid && myLocation != null) {
                    liveLocation.marker.setPosition(new LatLng(myLocation.getLatitude(), myLocation.getLongitude()));
                }
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
    } else {
        liveLocation.object = message;
        liveLocation.marker.setPosition(latLng);
    }
    return liveLocation;
}
 
Example 12
Source File: LocationActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
private LiveLocation addUserMarker(TLRPC.Message message) {
    LiveLocation liveLocation;
    LatLng latLng = new LatLng(message.media.geo.lat, message.media.geo._long);
    if ((liveLocation = markersMap.get(message.from_id)) == null) {
        liveLocation = new LiveLocation();
        liveLocation.object = message;
        if (liveLocation.object.from_id != 0) {
            liveLocation.user = MessagesController.getInstance(currentAccount).getUser(liveLocation.object.from_id);
            liveLocation.id = liveLocation.object.from_id;
        } else {
            int did = (int) MessageObject.getDialogId(message);
            if (did > 0) {
                liveLocation.user = MessagesController.getInstance(currentAccount).getUser(did);
                liveLocation.id = did;
            } else {
                liveLocation.chat = MessagesController.getInstance(currentAccount).getChat(-did);
                liveLocation.id = did;
            }
        }

        try {
            MarkerOptions options = new MarkerOptions().position(latLng);
            Bitmap bitmap = createUserBitmap(liveLocation);
            if (bitmap != null) {
                options.icon(BitmapDescriptorFactory.fromBitmap(bitmap));
                options.anchor(0.5f, 0.907f);
                liveLocation.marker = googleMap.addMarker(options);
                markers.add(liveLocation);
                markersMap.put(liveLocation.id, liveLocation);
                LocationController.SharingLocationInfo myInfo = LocationController.getInstance(currentAccount).getSharingLocationInfo(dialogId);
                if (liveLocation.id == UserConfig.getInstance(currentAccount).getClientUserId() && myInfo != null && liveLocation.object.id == myInfo.mid && myLocation != null) {
                    liveLocation.marker.setPosition(new LatLng(myLocation.getLatitude(), myLocation.getLongitude()));
                }
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
    } else {
        liveLocation.object = message;
        liveLocation.marker.setPosition(latLng);
    }
    return liveLocation;
}
 
Example 13
Source File: LocationActivity.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
private LiveLocation addUserMarker(TLRPC.Message message) {
    LiveLocation liveLocation;
    LatLng latLng = new LatLng(message.media.geo.lat, message.media.geo._long);
    if ((liveLocation = markersMap.get(message.from_id)) == null) {
        liveLocation = new LiveLocation();
        liveLocation.object = message;
        if (liveLocation.object.from_id != 0) {
            liveLocation.user = getMessagesController().getUser(liveLocation.object.from_id);
            liveLocation.id = liveLocation.object.from_id;
        } else {
            int did = (int) MessageObject.getDialogId(message);
            if (did > 0) {
                liveLocation.user = getMessagesController().getUser(did);
                liveLocation.id = did;
            } else {
                liveLocation.chat = getMessagesController().getChat(-did);
                liveLocation.id = did;
            }
        }

        try {
            MarkerOptions options = new MarkerOptions().position(latLng);
            Bitmap bitmap = createUserBitmap(liveLocation);
            if (bitmap != null) {
                options.icon(BitmapDescriptorFactory.fromBitmap(bitmap));
                options.anchor(0.5f, 0.907f);
                liveLocation.marker = googleMap.addMarker(options);
                markers.add(liveLocation);
                markersMap.put(liveLocation.id, liveLocation);
                LocationController.SharingLocationInfo myInfo = getLocationController().getSharingLocationInfo(dialogId);
                if (liveLocation.id == getUserConfig().getClientUserId() && myInfo != null && liveLocation.object.id == myInfo.mid && myLocation != null) {
                    liveLocation.marker.setPosition(new LatLng(myLocation.getLatitude(), myLocation.getLongitude()));
                }
            }
        } catch (Exception e) {
            FileLog.e(e);
        }
    } else {
        liveLocation.object = message;
        liveLocation.marker.setPosition(latLng);
    }
    return liveLocation;
}