Search in sources :

Example 1 with SharingLiveLocationCell

use of org.telegram.ui.Cells.SharingLiveLocationCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class LocationActivityAdapter method onCreateViewHolder.

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view;
    switch(viewType) {
        case 0:
            // view = emptyCell = new EmptyCell(mContext) {
            // @Override
            // public ViewPropertyAnimator animate() {
            // ViewPropertyAnimator animator = super.animate();
            // if (Build.VERSION.SDK_INT >= 19) {
            // animator.setUpdateListener(animation -> {
            // if (updateRunnable != null) {
            // updateRunnable.run();
            // }
            // });
            // }
            // return animator;
            // }
            // };
            view = emptyCell = new FrameLayout(mContext);
            emptyCell.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, overScrollHeight));
            break;
        case 1:
            view = new SendLocationCell(mContext, false, resourcesProvider);
            break;
        case 2:
            view = new HeaderCell(mContext, resourcesProvider);
            break;
        case 3:
            LocationCell locationCell = new LocationCell(mContext, false, resourcesProvider);
            view = locationCell;
            break;
        case 4:
            view = new LocationLoadingCell(mContext, resourcesProvider);
            break;
        case 5:
            view = new LocationPoweredCell(mContext, resourcesProvider);
            break;
        case 6:
            {
                SendLocationCell cell = new SendLocationCell(mContext, true, resourcesProvider);
                cell.setDialogId(dialogId);
                view = cell;
                break;
            }
        case 7:
            view = new SharingLiveLocationCell(mContext, true, locationType == LocationActivity.LOCATION_TYPE_GROUP || locationType == LocationActivity.LOCATION_TYPE_GROUP_VIEW ? 16 : 54, resourcesProvider);
            break;
        case 8:
            {
                LocationDirectionCell cell = new LocationDirectionCell(mContext, resourcesProvider);
                cell.setOnButtonClick(v -> onDirectionClick());
                view = cell;
                break;
            }
        case 9:
            {
                view = new ShadowSectionCell(mContext);
                Drawable drawable = Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow);
                CombinedDrawable combinedDrawable = new CombinedDrawable(new ColorDrawable(getThemedColor(Theme.key_windowBackgroundGray)), drawable);
                combinedDrawable.setFullsize(true);
                view.setBackgroundDrawable(combinedDrawable);
                break;
            }
        case 10:
        default:
            {
                view = new View(mContext);
                break;
            }
    }
    return new RecyclerListView.Holder(view);
}
Also used : Context(android.content.Context) LocationActivity(org.telegram.ui.LocationActivity) Theme(org.telegram.ui.ActionBar.Theme) FrameLayout(android.widget.FrameLayout) AndroidUtilities(org.telegram.messenger.AndroidUtilities) ColorDrawable(android.graphics.drawable.ColorDrawable) LocaleController(org.telegram.messenger.LocaleController) LocationController(org.telegram.messenger.LocationController) HeaderCell(org.telegram.ui.Cells.HeaderCell) Drawable(android.graphics.drawable.Drawable) ArrayList(java.util.ArrayList) LocationDirectionCell(org.telegram.ui.Cells.LocationDirectionCell) ShadowSectionCell(org.telegram.ui.Cells.ShadowSectionCell) SendLocationCell(org.telegram.ui.Cells.SendLocationCell) TLRPC(org.telegram.tgnet.TLRPC) Locale(java.util.Locale) View(android.view.View) MessageObject(org.telegram.messenger.MessageObject) RecyclerView(androidx.recyclerview.widget.RecyclerView) Build(android.os.Build) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) LocationLoadingCell(org.telegram.ui.Cells.LocationLoadingCell) LocationPoweredCell(org.telegram.ui.Cells.LocationPoweredCell) R(org.telegram.messenger.R) TextUtils(android.text.TextUtils) SharingLiveLocationCell(org.telegram.ui.Cells.SharingLiveLocationCell) ViewGroup(android.view.ViewGroup) FlickerLoadingView(org.telegram.ui.Components.FlickerLoadingView) UserConfig(org.telegram.messenger.UserConfig) LocationCell(org.telegram.ui.Cells.LocationCell) ViewPropertyAnimator(android.view.ViewPropertyAnimator) Location(android.location.Location) EmptyCell(org.telegram.ui.Cells.EmptyCell) RecyclerListView(org.telegram.ui.Components.RecyclerListView) SharingLiveLocationCell(org.telegram.ui.Cells.SharingLiveLocationCell) ShadowSectionCell(org.telegram.ui.Cells.ShadowSectionCell) HeaderCell(org.telegram.ui.Cells.HeaderCell) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) FlickerLoadingView(org.telegram.ui.Components.FlickerLoadingView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) LocationLoadingCell(org.telegram.ui.Cells.LocationLoadingCell) LocationDirectionCell(org.telegram.ui.Cells.LocationDirectionCell) ColorDrawable(android.graphics.drawable.ColorDrawable) FrameLayout(android.widget.FrameLayout) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) RecyclerView(androidx.recyclerview.widget.RecyclerView) LocationPoweredCell(org.telegram.ui.Cells.LocationPoweredCell) SendLocationCell(org.telegram.ui.Cells.SendLocationCell) SharingLiveLocationCell(org.telegram.ui.Cells.SharingLiveLocationCell) LocationCell(org.telegram.ui.Cells.LocationCell) SendLocationCell(org.telegram.ui.Cells.SendLocationCell)

Example 2 with SharingLiveLocationCell

use of org.telegram.ui.Cells.SharingLiveLocationCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class LocationActivityAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch(holder.getItemViewType()) {
        case 0:
            RecyclerView.LayoutParams lp = (RecyclerView.LayoutParams) holder.itemView.getLayoutParams();
            if (lp == null) {
                lp = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, overScrollHeight);
            } else {
                lp.height = overScrollHeight;
            }
            holder.itemView.setLayoutParams(lp);
            break;
        case 1:
            sendLocationCell = (SendLocationCell) holder.itemView;
            updateCell();
            break;
        case 2:
            {
                HeaderCell cell = (HeaderCell) holder.itemView;
                if (currentMessageObject != null) {
                    cell.setText(LocaleController.getString("LiveLocations", R.string.LiveLocations));
                } else {
                    cell.setText(LocaleController.getString("NearbyVenue", R.string.NearbyVenue));
                }
                break;
            }
        case 3:
            {
                LocationCell cell = (LocationCell) holder.itemView;
                if (locationType == 0) {
                    position -= 4;
                } else {
                    position -= 5;
                }
                TLRPC.TL_messageMediaVenue place = position < 0 || position >= places.size() || !searched ? null : places.get(position);
                String iconUrl = position < 0 || position >= iconUrls.size() || !searched ? null : iconUrls.get(position);
                cell.setLocation(place, iconUrl, position, true);
                break;
            }
        case 4:
            ((LocationLoadingCell) holder.itemView).setLoading(searching);
            break;
        case 6:
            ((SendLocationCell) holder.itemView).setHasLocation(gpsLocation != null);
            break;
        case 7:
            SharingLiveLocationCell locationCell = (SharingLiveLocationCell) holder.itemView;
            if (locationType == LocationActivity.LOCATION_TYPE_LIVE_VIEW) {
                locationCell.setDialog(currentMessageObject, gpsLocation, myLocationDenied);
            } else if (chatLocation != null) {
                locationCell.setDialog(dialogId, chatLocation);
            } else if (currentMessageObject != null && position == 1) {
                locationCell.setDialog(currentMessageObject, gpsLocation, myLocationDenied);
            } else {
                locationCell.setDialog(currentLiveLocations.get(position - (currentMessageObject != null ? 5 : 2)), gpsLocation);
            }
            break;
        case 10:
            View emptyView = holder.itemView;
            emptyView.setBackgroundColor(Theme.getColor(myLocationDenied ? Theme.key_dialogBackgroundGray : Theme.key_dialogBackground));
            break;
    }
}
Also used : SharingLiveLocationCell(org.telegram.ui.Cells.SharingLiveLocationCell) HeaderCell(org.telegram.ui.Cells.HeaderCell) RecyclerView(androidx.recyclerview.widget.RecyclerView) SendLocationCell(org.telegram.ui.Cells.SendLocationCell) SharingLiveLocationCell(org.telegram.ui.Cells.SharingLiveLocationCell) LocationCell(org.telegram.ui.Cells.LocationCell) LocationLoadingCell(org.telegram.ui.Cells.LocationLoadingCell) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) FlickerLoadingView(org.telegram.ui.Components.FlickerLoadingView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) SendLocationCell(org.telegram.ui.Cells.SendLocationCell)

Aggregations

View (android.view.View)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)2 HeaderCell (org.telegram.ui.Cells.HeaderCell)2 LocationCell (org.telegram.ui.Cells.LocationCell)2 LocationLoadingCell (org.telegram.ui.Cells.LocationLoadingCell)2 SendLocationCell (org.telegram.ui.Cells.SendLocationCell)2 SharingLiveLocationCell (org.telegram.ui.Cells.SharingLiveLocationCell)2 FlickerLoadingView (org.telegram.ui.Components.FlickerLoadingView)2 RecyclerListView (org.telegram.ui.Components.RecyclerListView)2 Context (android.content.Context)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Drawable (android.graphics.drawable.Drawable)1 Location (android.location.Location)1 Build (android.os.Build)1 TextUtils (android.text.TextUtils)1 ViewGroup (android.view.ViewGroup)1 ViewPropertyAnimator (android.view.ViewPropertyAnimator)1 FrameLayout (android.widget.FrameLayout)1 ArrayList (java.util.ArrayList)1 Locale (java.util.Locale)1