janheinrichmerker / material-intro

A simple material design app intro with cool animations and a fluent API.
https://jitpack.io/#com.heinrichreimer/material-intro
MIT License
1.74k stars 305 forks source link

Freeze when switching Activity #304

Open ahmadraza330 opened 3 years ago

ahmadraza330 commented 3 years ago

When I use the slider in my project and go from one activity to another Emulator freeze and I cannot see an error message in logact

janheinrichmerker commented 3 years ago

If you cannot record a log, please record a screencast. And post the relevant code to help reproduce the issue. It would also help to know the specific versions of Android on the emulator and of material-intro.

ahmadraza330 commented 3 years ago
package com.example.organize.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.example.organize.R;
import com.heinrichreimersoftware.materialintro.app.IntroActivity;
import com.heinrichreimersoftware.materialintro.slide.FragmentSlide;

public class MainActivity extends IntroActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.activity_main);
        setButtonBackVisible(false);
        setButtonNextVisible(false);

        addSlide(new FragmentSlide.Builder()
                .background(android.R.color.white)
                .fragment(R.layout.intro_1)
        .build());

        addSlide(new FragmentSlide.Builder()
                .background(android.R.color.white)
                .fragment(R.layout.intro_2)
                .build());

        addSlide(new FragmentSlide.Builder()
                .background(android.R.color.white)
                .fragment(R.layout.intro_3)
                .build());

        addSlide(new FragmentSlide.Builder()
                .background(android.R.color.white)
                .fragment(R.layout.intro_4)
                .build());

        addSlide(new FragmentSlide.Builder()
                .background(android.R.color.white)
                .fragment(R.layout.register_intro)
                .build());
    }

    public void btnLogin(View view) {
        Intent i = new Intent(MainActivity.this, LoginActivity.class);
        startActivity(i);
    }

    public void btnRegister(View view) {
        Intent i = new Intent(MainActivity.this, RegisterActivity.class);
        startActivity(i);
    }
}

As you see in my code when I press the button for another activity my emulator is freeze and I didn't see any error message

ahmadraza330 commented 3 years ago

I use material intro version 2.0.0 and API level 30

janheinrichmerker commented 3 years ago

Sorry, I still can't reproduce your issue. What code is calling btnLogin then? Please record a screencast.

janheinrichmerker commented 3 years ago

Another relevant detail would be the startup code of both LoginActivity and RegisterActivity. Because on Android the screen only changes visibly after the new activity has started.

ahmadraza330 commented 3 years ago

Screenshot_1607141633 When I press the button the login screen cannot open and the emulator stuck.

janheinrichmerker commented 3 years ago

Sorry for the confusion: I meant a video recording of the emulator screen, so that I can see when exactly the freeze occurs. I still can't reproduce the issue. Did you test this with different emulators/devices? And could you please test, if the activity switches correctly when you start the same Intent from a standard Activity? It seems to me at the moment that this is not caused by material-intro but rather by the emulator or the LoginActivity/RegisterActivity startup code. Because I am not able to reproduce the issue with the code you sent.

janheinrichmerker commented 3 years ago

By the way, I reformatted the code snippet in your previous comment. You can do that yourself. Just refer to the GitHub Markdown guide.