Skip to content

Repository files navigation

Check Before Intent - Check Form Before Leave Activity


Check Form Before Leave Activity


Content List


Download

Add maven jitpack.io and dependencies in build.gradle (Project) :

// build.gradle projectallprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
// build.gradle app/moduledependencies {
...
implementation 'com.github.gzeinnumer:CheckBeforeIntent:version'
}

Feature List


Usage

Check Form Before Leave Activity

Use .addView(editText) to add view that you want to check

  • Single View
newCheckBeforeIntent()
.addView(editText1)
.isSaveToLeave(...).build();

Example

EditTexteditText1 = findViewById(R.id.ed1);
EditTexteditText2 = findViewById(R.id.ed2);
Buttonbtn = findViewById(R.id.btn);
btn.setOnClickListener(newView.OnClickListener() {
@OverridepublicvoidonClick(Viewv) {
newCheckBeforeIntent()
.addView(editText1)
.addView(editText2)
.isSaveToLeave(newCheckBeforeIntent.CheckBeforeIntentCallBack() {
@OverridepublicvoidisSaveToLeave(booleanisSave) {
if (isSave) //true -> free to leasestartActivity(newIntent(getApplicationContext(), MainActivity.class));
else//false -> not free to leaveToast.makeText(MainActivity.this, "Are you sure leave the activity", Toast.LENGTH_SHORT).show();
}
}).build();
}
});
  • Multiple View
newCheckBeforeIntent()
.addView(editText1)
.addView(editText2)
.isSaveToLeave(...).build();
List<View> views = newArrayList<>();
...
newCheckBeforeIntent()
.addView(views)
.isSaveToLeave(...).build();
View[] views = newView[size];
...
newCheckBeforeIntent()
.addView(views)
.isSaveToLeave(...).build();

FullCodeMainActivity


Example Code/app

Sample Code And App


Version

  • 1.0.0
    • First Release

Contribution

You can sent your constibution to branchopen-pull.


Copyright 2021 M. Fadli Zein

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages