@@ -72,9 +72,11 @@ public class AddNoteActivity extends AppCompatActivity {
7272 private String notificationChannelId = "" ;
7373
7474 private int
75- color = 0xFFFFFF ,
75+ color ,
7676 opacityRes = R .drawable .ic_coffee ;
7777 private long noteTime = 0L ;
78+
79+ private boolean isLoadIntAds = true ;
7880 private CardView cardViewBtnDone ;
7981 private SQLiteDatabase sqLiteDatabaseNotes ;
8082 @ Nullable
@@ -95,6 +97,8 @@ protected void onCreate(Bundle savedInstanceState) {
9597
9698 });
9799
100+ color = getResources ().getColor (R .color .note_green );
101+
98102 toolbar = (androidx .appcompat .widget .Toolbar ) findViewById (R .id .toolbar );
99103 toolbar = findViewById (R .id .toolbar );
100104 setSupportActionBar (toolbar );
@@ -113,9 +117,13 @@ protected void onCreate(Bundle savedInstanceState) {
113117 boolean isUpdate = getIntent ().getBooleanExtra ("update" , false );
114118
115119 Intent intent = new Intent (AddNoteActivity .this , MainActivity .class );
116- if (!getIntent ().getBooleanExtra ("isLoadAppOpenAd" , false )){
120+ if (!getIntent ().getBooleanExtra ("isLoadAppOpenAd" , false )) {
117121 intent .putExtra ("isLoadAppOpenAd" , false );
118122 }
123+ isLoadIntAds = getIntent ().getBooleanExtra ("LoadInterstitialAd" , true );
124+ if (isLoadIntAds ) {
125+ intent .putExtra ("LoadInterstitialAd" , false );
126+ }
119127
120128 if (isUpdate ) {
121129 toolbar .setTitle ("Редактировать заметку" );
@@ -139,57 +147,58 @@ protected void onCreate(Bundle savedInstanceState) {
139147 toolbar .setSubtitle (new SimpleDateFormat ("dd.MM.yyyy HH.mm" , Locale .getDefault ()).format (new Date (noteTime )));
140148 }
141149
142- mInterstitialAdLoader = new InterstitialAdLoader (this );
143-
144- mInterstitialAdLoader .setAdLoadListener (new InterstitialAdLoadListener () {
145- @ Override
146- public void onAdLoaded (@ NonNull final InterstitialAd interstitialAd ) {
147- mInterstitialAd = interstitialAd ;
148- progressDialog .dismiss ();
149- if (mInterstitialAd != null ) {
150- mInterstitialAd .setAdEventListener (new InterstitialAdEventListener () {
151- @ Override
152- public void onAdShown () {
153-
154- }
155-
156- @ Override
157- public void onAdFailedToShow (@ NonNull AdError adError ) {
158-
159- }
160-
161- @ Override
162- public void onAdDismissed () {
163- startActivity (intent );
164- overridePendingTransition (0 , 0 );
165- finish ();
166- }
167-
168- @ Override
169- public void onAdClicked () {
170- startActivity (intent );
171- overridePendingTransition (0 , 0 );
172- finish ();
173- }
174-
175- @ Override
176- public void onAdImpression (@ Nullable ImpressionData impressionData ) {
177-
178- }
179- });
150+ if (isLoadIntAds ) {
151+ mInterstitialAdLoader = new InterstitialAdLoader (this );
152+
153+ mInterstitialAdLoader .setAdLoadListener (new InterstitialAdLoadListener () {
154+ @ Override
155+ public void onAdLoaded (@ NonNull final InterstitialAd interstitialAd ) {
156+ mInterstitialAd = interstitialAd ;
157+ progressDialog .dismiss ();
158+ if (mInterstitialAd != null ) {
159+ mInterstitialAd .setAdEventListener (new InterstitialAdEventListener () {
160+ @ Override
161+ public void onAdShown () {
162+
163+ }
164+
165+ @ Override
166+ public void onAdFailedToShow (@ NonNull AdError adError ) {
167+
168+ }
169+
170+ @ Override
171+ public void onAdDismissed () {
172+ startActivity (intent );
173+ overridePendingTransition (0 , 0 );
174+ finish ();
175+ }
176+
177+ @ Override
178+ public void onAdClicked () {
179+ startActivity (intent );
180+ overridePendingTransition (0 , 0 );
181+ finish ();
182+ }
183+
184+ @ Override
185+ public void onAdImpression (@ Nullable ImpressionData impressionData ) {
186+
187+ }
188+ });
189+ }
190+ mInterstitialAd .show (AddNoteActivity .this );
180191 }
181- mInterstitialAd .show (AddNoteActivity .this );
182- }
183-
184- @ Override
185- public void onAdFailedToLoad (@ NonNull final AdRequestError adRequestError ) {
186- Toast .makeText (AddNoteActivity .this , adRequestError .getDescription (), Toast .LENGTH_SHORT ).show ();
187- startActivity (intent );
188- overridePendingTransition (0 , 0 );
189- finish ();
190- }
191- });
192192
193+ @ Override
194+ public void onAdFailedToLoad (@ NonNull final AdRequestError adRequestError ) {
195+ Toast .makeText (AddNoteActivity .this , adRequestError .getDescription (), Toast .LENGTH_SHORT ).show ();
196+ startActivity (intent );
197+ overridePendingTransition (0 , 0 );
198+ finish ();
199+ }
200+ });
201+ }
193202// interstitialAd.setAdUnitId("R-M-1957919-2");
194203
195204 cardViewBtnDone .setOnClickListener (new View .OnClickListener () {
@@ -424,13 +433,25 @@ public boolean onCreateOptionsMenu(Menu menu) {
424433
425434 @ Override
426435 public void onBackPressed () {
436+ Intent intent = new Intent (AddNoteActivity .this , MainActivity .class );
437+ if (!getIntent ().getBooleanExtra ("isLoadAppOpenAd" , false )) {
438+ intent .putExtra ("isLoadAppOpenAd" , false );
439+ }
440+ if (isLoadIntAds ) {
441+ intent .putExtra ("LoadInterstitialAd" , false );
442+ }
427443// super.onBackPressed();
428444 progressDialog .showDialog ();
429- if (mInterstitialAdLoader != null ) {
430- final AdRequestConfiguration adRequestConfiguration =
431- new AdRequestConfiguration .Builder ("R-M-1957919-2" ).build ();
432- mInterstitialAdLoader .loadAd (adRequestConfiguration );
433- }
445+ if (isLoadIntAds )
446+ if (mInterstitialAdLoader != null ) {
447+ final AdRequestConfiguration adRequestConfiguration =
448+ new AdRequestConfiguration .Builder ("R-M-1957919-2" ).build ();
449+ mInterstitialAdLoader .loadAd (adRequestConfiguration );
450+ } else {
451+ startActivity (intent );
452+ overridePendingTransition (0 , 0 );
453+ finish ();
454+ }
434455 }
435456
436457 private void setDateAndTime () {
0 commit comments