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

The following examples show how to use org.telegram.ui.LocationActivity#LOCATION_TYPE_GROUP . 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 Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
public int getItemCount() {
    if (locationType == LocationActivity.LOCATION_TYPE_GROUP_VIEW) {
        return 2;
    } else if (locationType == LocationActivity.LOCATION_TYPE_GROUP) {
        return 2;
    } else if (currentMessageObject != null) {
        return 2 + (currentLiveLocations.isEmpty() ? 1 : currentLiveLocations.size() + 3);
    } else if (locationType == 2) {
        return 2 + currentLiveLocations.size();
    } else {
        if (searching || !searching && places.isEmpty()) {
            return (locationType != 0 ? 6 : 5) + (needEmptyView ? 1 : 0);
        }
        if (locationType == 1) {
            return 5 + places.size() + (places.isEmpty() ? 0 : 1) + (needEmptyView ? 1 : 0);
        } else {
            return 4 + places.size() + (places.isEmpty() ? 0 : 1) + (needEmptyView ? 1 : 0);
        }
    }
}
 
Example 2
Source File: LocationActivityAdapter.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public int getItemCount() {
    if (locationType == LocationActivity.LOCATION_TYPE_GROUP_VIEW) {
        return 2;
    } else if (locationType == LocationActivity.LOCATION_TYPE_GROUP) {
        return 2;
    } else if (currentMessageObject != null) {
        return 2 + (currentLiveLocations.isEmpty() ? 1 : currentLiveLocations.size() + 3);
    } else if (locationType == 2) {
        return 2 + currentLiveLocations.size();
    } else {
        if (searching || !searching && places.isEmpty()) {
            return (locationType != 0 ? 6 : 5) + (needEmptyView ? 1 : 0);
        }
        if (locationType == 1) {
            return 5 + places.size() + (places.isEmpty() ? 0 : 1) + (needEmptyView ? 1 : 0);
        } else {
            return 4 + places.size() + (places.isEmpty() ? 0 : 1) + (needEmptyView ? 1 : 0);
        }
    }
}
 
Example 3
Source File: LocationActivityAdapter.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void updateCell() {
    if (sendLocationCell != null) {
        if (locationType == LocationActivity.LOCATION_TYPE_GROUP || customLocation != null) {
            String address;
            if (!TextUtils.isEmpty(addressName)) {
                address = addressName;
            } else if (customLocation == null && gpsLocation == null || fetchingLocation) {
                address = LocaleController.getString("Loading", R.string.Loading);
            } else if (customLocation != null) {
                address = String.format(Locale.US, "(%f,%f)", customLocation.getLatitude(), customLocation.getLongitude());
            } else if (gpsLocation != null) {
                address = String.format(Locale.US, "(%f,%f)", gpsLocation.getLatitude(), gpsLocation.getLongitude());
            } else {
                address = LocaleController.getString("Loading", R.string.Loading);
            }
            if (locationType == LocationActivity.LOCATION_TYPE_GROUP) {
                sendLocationCell.setText(LocaleController.getString("ChatSetThisLocation", R.string.ChatSetThisLocation), address);
            } else {
                sendLocationCell.setText(LocaleController.getString("SendSelectedLocation", R.string.SendSelectedLocation), address);
            }
        } else {
            if (gpsLocation != null) {
                sendLocationCell.setText(LocaleController.getString("SendLocation", R.string.SendLocation), LocaleController.formatString("AccurateTo", R.string.AccurateTo, LocaleController.formatPluralString("Meters", (int) gpsLocation.getAccuracy())));
            } else {
                sendLocationCell.setText(LocaleController.getString("SendLocation", R.string.SendLocation), LocaleController.getString("Loading", R.string.Loading));
            }
        }
    }
}
 
Example 4
Source File: LocationActivityAdapter.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public Object getItem(int i) {
    if (locationType == LocationActivity.LOCATION_TYPE_GROUP) {
        if (addressName == null) {
            return null;
        } else {
            TLRPC.TL_messageMediaVenue venue = new TLRPC.TL_messageMediaVenue();
            venue.address = addressName;
            venue.geo = new TLRPC.TL_geoPoint();
            if (customLocation != null) {
                venue.geo.lat = customLocation.getLatitude();
                venue.geo._long = customLocation.getLongitude();
            } else if (gpsLocation != null) {
                venue.geo.lat = gpsLocation.getLatitude();
                venue.geo._long = gpsLocation.getLongitude();
            }
            return venue;
        }
    } else if (currentMessageObject != null) {
        if (i == 1) {
            return currentMessageObject;
        } else if (i > 4 && i < places.size() + 4) {
            return currentLiveLocations.get(i - 5);
        }
    } else if (locationType == 2) {
        if (i >= 2) {
            return currentLiveLocations.get(i - 2);
        }
        return null;
    } else if (locationType == 1) {
        if (i > 4 && i < places.size() + 5) {
            return places.get(i - 5);
        }
    } else {
        if (i > 3 && i < places.size() + 4) {
            return places.get(i - 4);
        }
    }
    return null;
}
 
Example 5
Source File: LocationActivityAdapter.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void updateCell() {
    if (sendLocationCell != null) {
        if (locationType == LocationActivity.LOCATION_TYPE_GROUP || customLocation != null) {
            String address;
            if (!TextUtils.isEmpty(addressName)) {
                address = addressName;
            } else if (customLocation == null && gpsLocation == null || fetchingLocation) {
                address = LocaleController.getString("Loading", R.string.Loading);
            } else if (customLocation != null) {
                address = String.format(Locale.US, "(%f,%f)", customLocation.getLatitude(), customLocation.getLongitude());
            } else if (gpsLocation != null) {
                address = String.format(Locale.US, "(%f,%f)", gpsLocation.getLatitude(), gpsLocation.getLongitude());
            } else {
                address = LocaleController.getString("Loading", R.string.Loading);
            }
            if (locationType == LocationActivity.LOCATION_TYPE_GROUP) {
                sendLocationCell.setText(LocaleController.getString("ChatSetThisLocation", R.string.ChatSetThisLocation), address);
            } else {
                sendLocationCell.setText(LocaleController.getString("SendSelectedLocation", R.string.SendSelectedLocation), address);
            }
        } else {
            if (gpsLocation != null) {
                sendLocationCell.setText(LocaleController.getString("SendLocation", R.string.SendLocation), LocaleController.formatString("AccurateTo", R.string.AccurateTo, LocaleController.formatPluralString("Meters", (int) gpsLocation.getAccuracy())));
            } else {
                sendLocationCell.setText(LocaleController.getString("SendLocation", R.string.SendLocation), LocaleController.getString("Loading", R.string.Loading));
            }
        }
    }
}
 
Example 6
Source File: LocationActivityAdapter.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public Object getItem(int i) {
    if (locationType == LocationActivity.LOCATION_TYPE_GROUP) {
        if (addressName == null) {
            return null;
        } else {
            TLRPC.TL_messageMediaVenue venue = new TLRPC.TL_messageMediaVenue();
            venue.address = addressName;
            venue.geo = new TLRPC.TL_geoPoint();
            if (customLocation != null) {
                venue.geo.lat = customLocation.getLatitude();
                venue.geo._long = customLocation.getLongitude();
            } else if (gpsLocation != null) {
                venue.geo.lat = gpsLocation.getLatitude();
                venue.geo._long = gpsLocation.getLongitude();
            }
            return venue;
        }
    } else if (currentMessageObject != null) {
        if (i == 1) {
            return currentMessageObject;
        } else if (i > 4 && i < places.size() + 4) {
            return currentLiveLocations.get(i - 5);
        }
    } else if (locationType == 2) {
        if (i >= 2) {
            return currentLiveLocations.get(i - 2);
        }
        return null;
    } else if (locationType == 1) {
        if (i > 4 && i < places.size() + 5) {
            return places.get(i - 5);
        }
    } else {
        if (i > 3 && i < places.size() + 4) {
            return places.get(i - 4);
        }
    }
    return null;
}
 
Example 7
Source File: LocationActivityAdapter.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public int getItemViewType(int position) {
    if (position == 0) {
        return 0;
    }
    if (needEmptyView && position == getItemCount() - 1) {
        return 10;
    }
    if (locationType == LocationActivity.LOCATION_TYPE_GROUP_VIEW) {
        return 7;
    }
    if (locationType == LocationActivity.LOCATION_TYPE_GROUP) {
        return 1;
    }
    if (currentMessageObject != null) {
        if (currentLiveLocations.isEmpty()) {
            if (position == 2) {
                return 8;
            }
        } else {
            if (position == 2) {
                return 9;
            } else if (position == 3) {
                return 2;
            } else if (position == 4) {
                shareLiveLocationPotistion = position;
                return 6;
            }
        }
        return 7;
    }
    if (locationType == 2) {
        if (position == 1) {
            shareLiveLocationPotistion = position;
            return 6;
        } else {
            return 7;
        }
    }
    if (locationType == LocationActivity.LOCATION_TYPE_SEND_WITH_LIVE) {
        if (position == 1) {
            return 1;
        } else if (position == 2) {
            shareLiveLocationPotistion = position;
            return 6;
        } else if (position == 3) {
            return 9;
        } else if (position == 4) {
            return 2;
        } else if (searching || !searching && places.isEmpty()) {
            return 4;
        } else if (position == places.size() + 5) {
            return 5;
        }
    } else {
        if (position == 1) {
            return 1;
        } else if (position == 2) {
            return 9;
        } else if (position == 3) {
            return 2;
        } else if (searching || !searching && places.isEmpty()) {
            return 4;
        } else if (position == places.size() + 4) {
            return 5;
        }
    }
    return 3;
}
 
Example 8
Source File: LocationActivityAdapter.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public int getItemViewType(int position) {
    if (position == 0) {
        return 0;
    }
    if (needEmptyView && position == getItemCount() - 1) {
        return 10;
    }
    if (locationType == LocationActivity.LOCATION_TYPE_GROUP_VIEW) {
        return 7;
    }
    if (locationType == LocationActivity.LOCATION_TYPE_GROUP) {
        return 1;
    }
    if (currentMessageObject != null) {
        if (currentLiveLocations.isEmpty()) {
            if (position == 2) {
                return 8;
            }
        } else {
            if (position == 2) {
                return 9;
            } else if (position == 3) {
                return 2;
            } else if (position == 4) {
                shareLiveLocationPotistion = position;
                return 6;
            }
        }
        return 7;
    }
    if (locationType == 2) {
        if (position == 1) {
            shareLiveLocationPotistion = position;
            return 6;
        } else {
            return 7;
        }
    }
    if (locationType == LocationActivity.LOCATION_TYPE_SEND_WITH_LIVE) {
        if (position == 1) {
            return 1;
        } else if (position == 2) {
            shareLiveLocationPotistion = position;
            return 6;
        } else if (position == 3) {
            return 9;
        } else if (position == 4) {
            return 2;
        } else if (searching || !searching && places.isEmpty()) {
            return 4;
        } else if (position == places.size() + 5) {
            return 5;
        }
    } else {
        if (position == 1) {
            return 1;
        } else if (position == 2) {
            return 9;
        } else if (position == 3) {
            return 2;
        } else if (searching || !searching && places.isEmpty()) {
            return 4;
        } else if (position == places.size() + 4) {
            return 5;
        }
    }
    return 3;
}