Move askForComprehensive from DrugListActivity.java to WelcomeActivity.java

This commit is contained in:
jacques 2023-01-10 12:09:21 +01:00
parent e9f5a373bb
commit 13453ff7e4

View file

@ -16,6 +16,7 @@ import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.viewpager.widget.PagerAdapter; import androidx.viewpager.widget.PagerAdapter;
@ -74,6 +75,12 @@ public class WelcomeActivity extends AppCompatActivity {
} }
prefManager.setFirstTimeLaunch(false); prefManager.setFirstTimeLaunch(false);
if (!prefManager.isUnderstood()) {
askForComprehensive();
prefManager.setUnderstood(true);
}
setContentView(R.layout.welcome_activity); setContentView(R.layout.welcome_activity);
setFullScreen(); setFullScreen();
@ -110,28 +117,31 @@ public class WelcomeActivity extends AppCompatActivity {
viewPager.setAdapter(myViewPagerAdapter); viewPager.setAdapter(myViewPagerAdapter);
viewPager.addOnPageChangeListener(viewPagerPageChangeListener); viewPager.addOnPageChangeListener(viewPagerPageChangeListener);
btnSkip.setOnClickListener(new View.OnClickListener() { btnSkip.setOnClickListener(v -> launchHomeScreen());
@Override
public void onClick(View v) { btnNext.setOnClickListener(v -> {
// checking for last page
// if last page home screen will be launched
int current = getItem();
if (current < layouts.length) {
// move to next screen
viewPager.setCurrentItem(current);
overridePendingTransition(R.anim.slide_from_left, R.anim.slide_to_right);
} else {
launchHomeScreen(); launchHomeScreen();
} }
}); });
}
btnNext.setOnClickListener(new View.OnClickListener() { private void askForComprehensive() {
@Override AlertDialog.Builder dlg = new AlertDialog.Builder(this);
public void onClick(View v) { dlg.setTitle(getString(R.string.app_name));
// checking for last page
// if last page home screen will be launched dlg.setMessage(R.string.understood);
int current = getItem(); dlg.setPositiveButton(R.string.Yes, (dialog, which) -> {
if (current < layouts.length) { // Nothing to do just dismiss dialog
// move to next screen
viewPager.setCurrentItem(current);
overridePendingTransition(R.anim.slide_from_left, R.anim.slide_to_right);
} else {
launchHomeScreen();
}
}
}); });
dlg.show();
} }
private void addBottomDots(int currentPage) { private void addBottomDots(int currentPage) {
@ -220,7 +230,7 @@ public class WelcomeActivity extends AppCompatActivity {
@Override @Override
public void destroyItem(ViewGroup container, int position, @NonNull Object object) { public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
View view = (View) object; View view = (View) object;
container.removeView(view); container.removeView(view);
} }