Исправь  : package com.example.myapp_2.Data.Discount_Get_table;

import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;

import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.ViewPager;

import com.example.myapp_2.Data.List_1.Product;
import com.example.myapp_2.R;

import java.util.ArrayList;
import java.util.List;

public class StocksFragment extends Fragment {

    ViewPager viewPager;
    StocksAdapter adapter;
    ArrayList<StocksModel> stocksModelArrayList;
    ProductAdapter1 productAdapter;
    List<Product> products;

    private List<Product> getProducts() {
        List<Product> products = new ArrayList<>();

        Product product1 = new Product("Product 1", "Description 1", R.drawable.food_3_1jpg, 0.0f);
        products.add(product1);

        Product product2 = new Product("Product 2", "Description 2", R.drawable.food_1_1, 0.0f);
        products.add(product2);

        Product product3 = new Product("Product 3", "Description 3", R.drawable.food_1_4, 0.0f);
        products.add(product3);

        Product product4 = new Product("Product 4", "Description 4", R.drawable.food_1_1, 0.0f);
        products.add(product4);

        Product product5 = new Product("Product 5", "Description 5", R.drawable.food_1_1, 0.0f);
        products.add(product5);

        Product product6 = new Product("Product 6", "Description 6", R.drawable.food_1_1,0.0f);
        products.add(product6);

        Product product7 = new Product("Product 7", "Description 7", R.drawable.food_3_2,0.0f);
        products.add(product7);

        Product product8 = new Product("Product 8", "Description 8", R.drawable.food_3_3,0.0f);
        products.add(product8);

        Product product9 = new Product("Product 9", "Description 9", R.drawable.food_1_1,0.0f);
        products.add(product9);

        Product product10 = new Product("Product 10", "Description 10", R.drawable.food_1_1,0.0f);
        products.add(product10);

        return products;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_stocks, container, false);
        Animation anim = AnimationUtils.loadAnimation(getActivity(), R.anim.fragment_transition_animation);
        anim.setDuration(200);
        view.startAnimation(anim);
         RecyclerView recyclerView = view.findViewById(R.id.recyclerView);

        stocksModelArrayList = new ArrayList<>();
        stocksModelArrayList.add(new StocksModel("Title1", "Description1", R.drawable.food_3));
        stocksModelArrayList.add(new StocksModel("Title2", "Description2", R.drawable.food_4));
        stocksModelArrayList.add(new StocksModel("Title2", "Description2", R.drawable.food_1_2));

        viewPager = view.findViewById(R.id.viewPager);
        adapter = new StocksAdapter(getContext(), stocksModelArrayList);
        viewPager.setAdapter(adapter);

        final Handler handler = new Handler();
        final Runnable runnable = new Runnable() {
            @Override
            public void run() {
                int currentItem = viewPager.getCurrentItem();
                int totalItems = viewPager.getAdapter().getCount();
                int nextItem = currentItem == totalItems - 1 ? 0 : currentItem + 1;
                viewPager.setCurrentItem(nextItem);
                handler.postDelayed(this, 3000);
            }
        };
        handler.postDelayed(runnable, 3000);

        products = getProducts();
        productAdapter = new ProductAdapter1(getContext(), products);
        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
        recyclerView.setAdapter(productAdapter);

        return view;
    }
}
package com.example.myapp_2.Data.Discount_Get_table;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Paint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.example.myapp_2.Data.List_1.Product;
import com.example.myapp_2.R;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class ProductAdapter1 extends RecyclerView.Adapter<ProductAdapter1.ProductViewHolder> {
    private List<Product> products;
    private Context context;

    public ProductAdapter1(Context context, List<Product> products) {
        this.context = context;
        this.products = products;
    }

    @Override
    public ProductViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_product3, parent, false);
        ProductViewHolder holder = new ProductViewHolder(view);
        return new ProductViewHolder(view);
    }

    @SuppressLint("StringFormatMatches")
    @Override
    public void onBindViewHolder(ProductViewHolder holder, int position) {
        Product product = products.get(position);
        holder.productImage.setImageResource(product.getImageResource());
        holder.productName.setText(product.getName());
        holder.productDescription.setText(product.getDescription());

        double oldPrice = product.getPrice() * (1 + product.getDiscount());
        double newPrice = oldPrice * (1 - product.getDiscount());

        holder.oldPriceTextView.setText(context.getString(R.string.old_price, String.format("%.2f", oldPrice)));
        holder.newPriceTextView.setText(context.getString(R.string.price, String.format("%.2f", newPrice)));
        holder.oldPriceTextView.setPaintFlags(Paint.STRIKE_THRU_TEXT_FLAG);

        double discount = product.getDiscount() * 100;
        holder.discountTextView.setText(context.getString(R.string.discount, String.format("%.0f", discount)));
    }

    @Override
    public int getItemCount() {
        return products.size();
    }

    public List<Product> getProducts() {
        List<Product> products = new ArrayList<>();

        Product product1 = new Product("Product 1", "Description 1", R.drawable.food_1, 0.3f);
        products.add(product1);

        Product product2 = new Product("Product 2", "Description 2", R.drawable.food_2, 0.2f);
        products.add(product2);

        Product product3 = new Product("Product 3", "Description 3", R.drawable.food_1_3, 0.1f);
        products.add(product3);

        Product product4 = new Product("Product 4", "Description 4", R.drawable.food_1_2, 0.4f);
        products.add(product4);

        Product product5 = new Product("Product 5", "Description 5", R.drawable.food_3_4, 0.5f);
        products.add(product5);

        return products;
    }

    public void sortProductsByPrice() {
        Collections.sort(products, new Comparator<Product>() {
            @Override
            public int compare(Product o1, Product o2) {
                return Double.compare(o1.getPrice(), o2.getPrice());
            }
        });
        notifyDataSetChanged();
    }

    public class ProductViewHolder extends RecyclerView.ViewHolder {
        public Button goToRestaurantButton;
        ImageView productImage;
        TextView productName;
        TextView productDescription;
        TextView oldPriceTextView;
        TextView newPriceTextView;
        TextView discountTextView;

        public ProductViewHolder(View view) {
            super(view);
            productImage = view.findViewById(R.id.product_image);
            productName = view.findViewById(R.id.product_name);
            productDescription = view.findViewById(R.id.product_description);
            discountTextView = view.findViewById(R.id.discount);
            goToRestaurantButton = itemView.findViewById(R.id.goRestaurantButton);
            oldPriceTextView = itemView.findViewById(R.id.old_price);
            newPriceTextView = itemView.findViewById(R.id.new_price);
        }
    }
}package com.example.myapp_2.Data.Discount_Get_table;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.viewpager.widget.PagerAdapter;

import com.example.myapp_2.R;

import java.util.ArrayList;

public class StocksAdapter extends PagerAdapter{

    private Context context;
    private ArrayList<StocksModel> stocksModelArrayList;
    private LayoutInflater layoutInflater;

    public StocksAdapter(Context context, ArrayList<StocksModel> stocksModelArrayList) {
        this.context = context;
        this.stocksModelArrayList = stocksModelArrayList;
    }

    @Override
    public int getCount() {
        return stocksModelArrayList.size();
    }

    @Override
    public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
        return view.equals(object);
    }

    @NonNull
    @Override
    public Object instantiateItem(@NonNull ViewGroup container, int position) {
        layoutInflater = LayoutInflater.from(context);
        View view = layoutInflater.inflate(R.layout.stock_item, container, false);

        ImageView imageView;
        TextView title, dascription;

        imageView = view.findViewById(R.id.img);


        imageView.setImageResource(stocksModelArrayList.get(position).getImage());


        container.addView(view, 0);

        return view;
    }

    @Override
    public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
        container.removeView((View) object);
    }
}