Progress Change When Switching Activity To Activity

progress-change-when-switching-activity-to-activity

progress-change-when-switching-activity-to-activity

Progress Change When Switching From An Activity To An Activity Like Facebook Lite App Using Android Studio

MainActivity.java

public class MainActivity extends AppCompatActivity {
    ImageView icon;
    EditText password;

    boolean isVisible = false;

    ConstraintLayout register_button;
    ProgressBar progressLoading;
    View loadingBackgroundColor;

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

        icon = findViewById(R.id.password_hide_view);
        password = findViewById(R.id.password);
        register_button = findViewById(R.id.register_button);
        progressLoading = findViewById(R.id.progressLoading);
        loadingBackgroundColor = findViewById(R.id.loadingBackgroundColor);



        icon.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (isVisible){
                    isVisible = false;
                    password.setTransformationMethod(PasswordTransformationMethod.getInstance());
                    icon.setImageResource(R.drawable.hide_password);
                } else {
                    isVisible = true;
                    password.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
                    icon.setImageResource(R.drawable.ic_baseline_remove_red_eye_24);
                }
            }
        });

        register_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                progressLoading.setVisibility(View.VISIBLE);
                loadingBackgroundColor.setVisibility(View.VISIBLE);

                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        progressLoading.setProgress(10);

                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                progressLoading.setProgress(20);

                                new Handler().postDelayed(new Runnable() {
                                    @Override
                                    public void run() {
                                        progressLoading.setProgress(30);

                                        new Handler().postDelayed(new Runnable() {
                                            @Override
                                            public void run() {
                                                progressLoading.setProgress(40);
                                                new Handler().postDelayed(new Runnable() {
                                                    @Override
                                                    public void run() {
                                                        progressLoading.setProgress(50);
                                                        new Handler().postDelayed(new Runnable() {
                                                            @Override
                                                            public void run() {
                                                                progressLoading.setProgress(60);
                                                                new Handler().postDelayed(new Runnable() {
                                                                    @Override
                                                                    public void run() {
                                                                        progressLoading.setProgress(80);
                                                                        new Handler().postDelayed(new Runnable() {
                                                                            @Override
                                                                            public void run() {
                                                                                progressLoading.setProgress(100);
                                                                                progressLoading.setVisibility(View.GONE);
                                                                                loadingBackgroundColor.setVisibility(View.GONE);
                                                                                startActivity(new Intent(MainActivity.this,RegisterScreen.class));

                                                                            }
                                                                        },50);
                                                                    }
                                                                },50);
                                                            }
                                                        },50);
                                                    }
                                                },50);
                                            }
                                        },50);
                                    }
                                },50);
                            }
                        },50);
                    }
                },50);
            }
        });


    }
}

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFF"
    tools:context=".MainActivity">

    <ProgressBar
        android:id="@+id/progressLoading"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:max="100"
        android:progress="5"
        android:progressTint="#0800EF"
        android:visibility="gone"
        style="@style/Widget.AppCompat.ProgressBar.Horizontal"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        />

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/title_layout"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/progressLoading"
        >

        <TextView
            android:id="@+id/fb_txt"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Facebook"
            android:textColor="#857C7C"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <View
            android:layout_width="0dp"
            android:layout_height="1dp"
            android:background="#B8B3B3"
            android:layout_marginTop="7dp"
            app:layout_constraintTop_toBottomOf="@+id/fb_txt"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            />

    </androidx.constraintlayout.widget.ConstraintLayout>

    <TextView
        android:id="@+id/username_txt"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="Mobile number or email"
        app:layout_constraintTop_toBottomOf="@+id/title_layout"
        android:textColor="#000"
        android:textSize="16sp"
        android:fontFamily="sans-serif-condensed"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        />

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/box1_layout"
        android:layout_width="0dp"
        android:layout_height="35dp"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        android:background="@drawable/border"
        app:layout_constraintTop_toBottomOf="@id/username_txt"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"

        >

        <EditText
            android:id="@+id/username"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:hint=""
            android:ellipsize="end"
            android:maxLines="1"
            android:paddingStart="5dp"
            android:paddingEnd="5dp"
            android:inputType="text"
            android:layout_margin="1dp"
            android:background="@color/white"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            />

    </androidx.constraintlayout.widget.ConstraintLayout>

    <TextView
        android:id="@+id/password_txt"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="Password"
        app:layout_constraintTop_toBottomOf="@+id/box1_layout"
        android:textColor="#000"
        android:textSize="16sp"
        android:fontFamily="sans-serif-condensed"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        />

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/box2_layout"
        android:layout_width="0dp"
        android:layout_height="35dp"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        android:background="@drawable/border"
        app:layout_constraintTop_toBottomOf="@id/password_txt"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"

        >

        <EditText
            android:id="@+id/password"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:hint=""
            android:ellipsize="end"
            android:maxLines="1"
            android:inputType="textPassword"
            android:paddingStart="5dp"
            android:paddingEnd="5dp"
            android:layout_margin="1dp"
            android:background="@color/white"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toStartOf="@+id/password_hide_view"
            />

        <ImageView
            android:id="@+id/password_hide_view"
            android:layout_width="20dp"
            android:layout_height="20dp"
            android:src="@drawable/hide_password"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            android:layout_marginEnd="5dp"
            />

    </androidx.constraintlayout.widget.ConstraintLayout>

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/login_button"
        android:layout_width="0dp"
        android:layout_height="30dp"
        android:background="#4255F4"
        android:layout_marginTop="8dp"
        app:layout_constraintTop_toBottomOf="@+id/box2_layout"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Log in"
            android:textColor="#FFFFFF"
            android:textStyle="bold"
            android:textSize="14sp"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintBottom_toBottomOf="parent"
            />

    </androidx.constraintlayout.widget.ConstraintLayout>
    <TextView
        android:id="@+id/btn_forgotten"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginTop="8dp"
        android:textColor="#000EFF"
        android:textStyle="bold"
        android:text="Forgot Password?"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/login_button"
        />

    <View
        android:layout_width="0dp"
        android:layout_height="1dp"
        android:background="#B8B3B3"
        app:layout_constraintEnd_toStartOf="@+id/or_txt"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@id/or_txt"
        app:layout_constraintBottom_toBottomOf="@id/or_txt"
        android:layout_marginStart="16dp"
        android:layout_marginEnd="8dp"
        android:layout_marginTop="8dp"
        />

    <TextView
        android:id="@+id/or_txt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="or"
        android:textSize="14sp"
        android:textColor="#000"
        android:textStyle="bold"
        app:layout_constraintTop_toBottomOf="@id/btn_forgotten"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        android:layout_marginTop="8dp"
        />

    <View
        android:layout_width="0dp"
        android:layout_height="1dp"
        android:background="#B8B3B3"
        app:layout_constraintStart_toEndOf="@+id/or_txt"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="@id/or_txt"
        app:layout_constraintBottom_toBottomOf="@id/or_txt"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="16dp"
        android:layout_marginTop="8dp"
        />

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/register_button"
        android:layout_width="wrap_content"
        android:layout_height="30dp"
        android:background="#00C119"
        android:layout_marginTop="8dp"
        app:layout_constraintTop_toBottomOf="@+id/or_txt"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Create new account"
            android:textColor="#FFFFFF"
            android:textStyle="bold"
            android:textSize="14sp"
            android:layout_marginStart="8dp"
            android:layout_marginEnd="8dp"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintBottom_toBottomOf="parent"
            />

    </androidx.constraintlayout.widget.ConstraintLayout>


    <TextView
        android:id="@+id/lang_en"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginTop="8dp"
        android:textColor="#000EFF"
        android:text="English (US)"
        android:fontFamily="sans-serif-condensed"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/register_button"
        />

    <TextView
        android:id="@+id/lang_bn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginTop="8dp"
        android:textColor="#000EFF"
        android:text="বাংলা"
        android:fontFamily="sans-serif-condensed"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/lang_en"
        />

    <TextView
        android:id="@+id/lang_osmia"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginTop="8dp"
        android:textColor="#000EFF"
        android:text="ওসমীয়া"
        android:fontFamily="sans-serif-condensed"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/lang_bn"
        />

    <TextView
        android:id="@+id/lang_more"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginTop="8dp"
        android:textColor="#000EFF"
        android:text="More Language..."
        android:fontFamily="sans-serif-condensed"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/lang_osmia"
        />


    <View
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:id="@+id/loadingBackgroundColor"
        android:background="#365A5858"
        android:visibility="gone"
        app:layout_constraintTop_toBottomOf="@+id/progressLoading"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        />

</androidx.constraintlayout.widget.ConstraintLayout>

YouTube Video :

https://youtu.be/Kq72oY9ID0g

Leave a Reply

Your email address will not be published. Required fields are marked *