Java Code Examples for org.telegram.ui.LocationActivity#LiveLocation

The following examples show how to use org.telegram.ui.LocationActivity#LiveLocation . 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: LocationActivityAdapter.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public void setLiveLocations(ArrayList<LocationActivity.LiveLocation> liveLocations) {
    currentLiveLocations = new ArrayList<>(liveLocations);
    int uid = UserConfig.getInstance(currentAccount).getClientUserId();
    for (int a = 0; a < currentLiveLocations.size(); a++) {
        if (currentLiveLocations.get(a).id == uid) {
            currentLiveLocations.remove(a);
            break;
        }
    }
    notifyDataSetChanged();
}
 
Example 2
Source File: LocationActivityAdapter.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public void setLiveLocations(ArrayList<LocationActivity.LiveLocation> liveLocations) {
    currentLiveLocations = new ArrayList<>(liveLocations);
    int uid = UserConfig.getInstance(currentAccount).getClientUserId();
    for (int a = 0; a < currentLiveLocations.size(); a++) {
        if (currentLiveLocations.get(a).id == uid) {
            currentLiveLocations.remove(a);
            break;
        }
    }
    notifyDataSetChanged();
}
 
Example 3
Source File: LocationActivityAdapter.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void setLiveLocations(ArrayList<LocationActivity.LiveLocation> liveLocations) {
    currentLiveLocations = new ArrayList<>(liveLocations);
    int uid = UserConfig.getInstance(currentAccount).getClientUserId();
    for (int a = 0; a < currentLiveLocations.size(); a++) {
        if (currentLiveLocations.get(a).id == uid) {
            currentLiveLocations.remove(a);
            break;
        }
    }
    notifyDataSetChanged();
}
 
Example 4
Source File: SharingLiveLocationCell.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void setDialog(LocationActivity.LiveLocation info, Location userLocation) {
    liveLocation = info;
    int lower_id = info.id;
    if (lower_id > 0) {
        TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(lower_id);
        if (user != null) {
            avatarDrawable.setInfo(user);
            nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
            avatarImageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable,  user);
        }
    } else {
        TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-lower_id);
        if (chat != null) {
            avatarDrawable.setInfo(chat);
            nameTextView.setText(chat.title);
            avatarImageView.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable,  chat);
        }
    }

    GeoPoint position = info.marker.getPosition();
    location.setLatitude(position.getLatitude());
    location.setLongitude(position.getLongitude());

    String time = LocaleController.formatLocationUpdateDate(info.object.edit_date != 0 ? info.object.edit_date : info.object.date);
    if (userLocation != null) {
        distanceTextView.setText(String.format("%s - %s", time, LocaleController.formatDistance(location.distanceTo(userLocation))));
    } else {
        distanceTextView.setText(time);
    }
}
 
Example 5
Source File: LocationActivityAdapter.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void setLiveLocations(ArrayList<LocationActivity.LiveLocation> liveLocations) {
    currentLiveLocations = new ArrayList<>(liveLocations);
    int uid = UserConfig.getInstance(currentAccount).getClientUserId();
    for (int a = 0; a < currentLiveLocations.size(); a++) {
        if (currentLiveLocations.get(a).id == uid) {
            currentLiveLocations.remove(a);
            break;
        }
    }
    notifyDataSetChanged();
}
 
Example 6
Source File: SharingLiveLocationCell.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void setDialog(LocationActivity.LiveLocation info, Location userLocation) {
    liveLocation = info;
    int lower_id = info.id;
    if (lower_id > 0) {
        TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(lower_id);
        if (user != null) {
            avatarDrawable.setInfo(user);
            nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
            avatarImageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable,  user);
        }
    } else {
        TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-lower_id);
        if (chat != null) {
            avatarDrawable.setInfo(chat);
            nameTextView.setText(chat.title);
            avatarImageView.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable,  chat);
        }
    }

    LatLng position = info.marker.getPosition();
    location.setLatitude(position.latitude);
    location.setLongitude(position.longitude);

    String time = LocaleController.formatLocationUpdateDate(info.object.edit_date != 0 ? info.object.edit_date : info.object.date);
    if (userLocation != null) {
        distanceTextView.setText(String.format("%s - %s", time, LocaleController.formatDistance(location.distanceTo(userLocation))));
    } else {
        distanceTextView.setText(time);
    }
}
 
Example 7
Source File: SharingLiveLocationCell.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public void setDialog(LocationActivity.LiveLocation info, Location userLocation) {
    liveLocation = info;
    int lower_id = info.id;
    TLRPC.FileLocation photo = null;
    if (lower_id > 0) {
        TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(lower_id);
        avatarDrawable.setInfo(user);
        if (user != null) {
            nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
            if (user.photo != null && user.photo.photo_small != null) {
                photo = user.photo.photo_small;
            }
        }
    } else {
        TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-lower_id);
        if (chat != null) {
            avatarDrawable.setInfo(chat);
            nameTextView.setText(chat.title);
            if (chat.photo != null && chat.photo.photo_small != null) {
                photo = chat.photo.photo_small;
            }
        }
    }

    LatLng position = info.marker.getPosition();
    location.setLatitude(position.latitude);
    location.setLongitude(position.longitude);

    String time = LocaleController.formatLocationUpdateDate(info.object.edit_date != 0 ? info.object.edit_date : info.object.date);
    if (userLocation != null) {
        float distance = location.distanceTo(userLocation);
        if (distance < 1000) {
            distanceTextView.setText(String.format("%s - %d %s", time, (int) (distance), LocaleController.getString("MetersAway", R.string.MetersAway)));
        } else {
            distanceTextView.setText(String.format("%s - %.2f %s", time, distance / 1000.0f, LocaleController.getString("KMetersAway", R.string.KMetersAway)));
        }
    } else {
        distanceTextView.setText(time);
    }

    avatarImageView.setImage(photo, null, avatarDrawable);
}
 
Example 8
Source File: SharingLiveLocationCell.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public void setDialog(LocationActivity.LiveLocation info, Location userLocation) {
    liveLocation = info;
    int lower_id = info.id;
    TLRPC.FileLocation photo = null;
    if (lower_id > 0) {
        TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(lower_id);
        avatarDrawable.setInfo(user);
        if (user != null) {
            nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
            if (user.photo != null && user.photo.photo_small != null) {
                photo = user.photo.photo_small;
            }
        }
    } else {
        TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-lower_id);
        if (chat != null) {
            avatarDrawable.setInfo(chat);
            nameTextView.setText(chat.title);
            if (chat.photo != null && chat.photo.photo_small != null) {
                photo = chat.photo.photo_small;
            }
        }
    }

    LatLng position = info.marker.getPosition();
    location.setLatitude(position.latitude);
    location.setLongitude(position.longitude);

    String time = LocaleController.formatLocationUpdateDate(info.object.edit_date != 0 ? info.object.edit_date : info.object.date);
    if (userLocation != null) {
        float distance = location.distanceTo(userLocation);
        if (distance < 1000) {
            distanceTextView.setText(String.format("%s - %d %s", time, (int) (distance), LocaleController.getString("MetersAway", R.string.MetersAway)));
        } else {
            distanceTextView.setText(String.format("%s - %.2f %s", time, distance / 1000.0f, LocaleController.getString("KMetersAway", R.string.KMetersAway)));
        }
    } else {
        distanceTextView.setText(time);
    }

    avatarImageView.setImage(photo, null, avatarDrawable);
}