0

for some reason my activity is opening slowly, do you think that you can help me here? Now, this is not the only code in Java class, I have 30 buttons that are exactly the same like the one below, only their ID is different since I have 30 card views (widget) in the activity, here is the picture of the design. I also reduced the pictures to the right size for the card, but that did not help. May you please help me?

enter image description here

Java Class:

private Button crkvaspip;

 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_zavrsenilista);



        //Dashboard

        crkvaspip = (Button) findViewById(R.id.crkvaspip);
        crkvaspip.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) { openCrkvaSvetogPetraIPavla();
            }
        });

 public void openCrkvaSvetogPetraIPavla(){

        Intent intent = new Intent(zavrseni_category.this, bioskop_class.class);
        startActivity(intent);
    }

Android widget card view code:

<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/card_view"
            android:layout_width="match_parent"
            android:layout_height="210dp"
            app:cardCornerRadius="20dp"
            android:layout_margin="8dp">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <ImageView
                    android:id="@+id/thumbnail"
                    android:layout_width="match_parent"
                    android:layout_height="170dp"
                    android:layout_alignParentTop="true"
                    android:scaleType="centerCrop"
                    android:adjustViewBounds="true"
                    android:src="@drawable/bioskop1" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/thumbnail"
                    android:maxLines="1"
                    android:padding="8dp"
                    android:fontFamily="@font/baloo"
                    android:text="3D Bioskop"
                    android:textColor="#222"
                    android:textSize="20dp" />

                <Button
                    android:id="@+id/crkvaspip"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="#00000000" />


            </RelativeLayout>
        </androidx.cardview.widget.CardView>

UPDATE LOGCAT INFO CODE:

2022-08-28 20:21:51.524 4585-4629/com.visit.bp I/OpenGLRenderer: Davey! duration=4111ms; Flags=1, IntendedVsync=38769851610176, Vsync=38773584943360, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=38773585749700, AnimationStart=38773585821500, PerformTraversalsStart=38773586648100, DrawStart=38773756771500, SyncQueued=38773757001800, SyncStart=38773757217800, IssueDrawCommandsStart=38773825367800, SwapBuffers=38773938657200, FrameCompleted=38773963626600, DequeueBufferDuration=332000, QueueBufferDuration=535000, 
sweak
  • 1,369
  • 2
  • 6
  • 21
Scm
  • 29
  • 4
  • 1
    Does this answer your question? [loading image but slow speed on android](https://stackoverflow.com/questions/24115519/loading-image-but-slow-speed-on-android) – sweak Aug 28 '22 at 18:38
  • 3
    Use a `RecyclerView`, as my guess is that you have a layout loading all 30 of those images, when only a couple will be visible at any point in time. Also, make sure these large bitmaps are in a directory like `res/drawable-anydpi/`, not `res/drawable/`. – CommonsWare Aug 28 '22 at 18:42
  • Do you mean that you're using 30 `card view` to show 30 images? If yes then you `recycler Adapter` to show these images and buttons without creating 30 cards and buttons. Make sure that image size is no more then `1000px`. Load image using picasso or glide. – M DEV Aug 29 '22 at 12:23

1 Answers1

0

If the emulator is slow, have you tried disabling your antivirus? Another possibility is to optimize the local images, there are programs such as the free website: https://www.iloveimg.com/ and speed up loading.

Another idea would be to distribute the images in other tabs or activities, because your activity may be overloaded, or load them through other libraries like picasso (I believe it has already been mentioned).