Skip to content

Commit

Permalink
Паттерн
Browse files Browse the repository at this point in the history
[+] Продолжаю переписывать на MVP.
  • Loading branch information
plumsoftware committed Sep 10, 2024
1 parent b6bac17 commit 512d95e
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 31 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "ru.plumsoftware.notebook"
minSdk 22
targetSdk 34
versionCode 28
versionName "2.0.5"
versionCode 29
versionName "2.0.6"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public MainPresenterImpl(Context context, @NonNull Activity activity, MainView m
this.activity = activity;
this.mainView = mainView;
filteredNotes = new ArrayList<>();
notes = new ArrayList<>();
}

@Override
Expand Down Expand Up @@ -89,6 +90,7 @@ public void initMobileSdk() {

@Override
public void initNotes(Conditions conditions) {
mainView.showProgressDialog();
if (conditions instanceof Conditions.Search) {
filteredNotes.clear();
String query = ((Conditions.Search) conditions).getQuery();
Expand All @@ -110,12 +112,10 @@ public void initNotes(Conditions conditions) {

mainView.initRecyclerView(filteredNotes, layoutManager);
} else if (conditions instanceof Conditions.All) {
mainView.showProgressDialog();
if (notes == null) {
SQLiteDatabaseManager sqLiteDatabaseManager = new SQLiteDatabaseManager(context);
sqLiteDatabaseNotes = sqLiteDatabaseManager.getWritableDatabase();
notes = loadNotes();
}
notes.clear();
SQLiteDatabaseManager sqLiteDatabaseManager = new SQLiteDatabaseManager(context);
sqLiteDatabaseNotes = sqLiteDatabaseManager.getWritableDatabase();
notes = loadNotes();

isList = true;
mainView.changeFilterButtonImage(R.drawable.ic_baseline_filter_list);
Expand Down Expand Up @@ -161,8 +161,8 @@ public void onAdImpression(@Nullable final ImpressionData impressionData) {
public void onAdLoaded(@NonNull final AppOpenAd appOpenAd) {
mainAppOpenAd = appOpenAd;
appOpenAd.setAdEventListener(appOpenAdEventListener);
mainAppOpenAd.show(activity);
mainView.dismissProgressDialog();
mainAppOpenAd.show(activity);
}

@Override
Expand All @@ -173,6 +173,7 @@ public void onAdFailedToLoad(@NonNull final AdRequestError adRequestError) {

appOpenAdLoader.setAdLoadListener(appOpenAdLoadListener);
appOpenAdLoader.loadAd(adRequestConfiguration);
mainView.dismissProgressDialog();
}

@NonNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ protected void onCreate(Bundle savedInstanceState) {
ImageButton addNote = findViewById(R.id.addNote);
progressDialog = new ProgressDialog(context, R.style.CustomProgressDialog);

presenter.initMobileSdk();
presenter.initNotes(new Conditions.All());

// load ad
presenter.initOpenAds();

Expand Down Expand Up @@ -107,4 +104,12 @@ public void showProgressDialog() {
public void dismissProgressDialog() {
progressDialog.dismiss();
}

@Override
protected void onResume() {
super.onResume();

presenter.initNotes(new Conditions.All());
presenter.initMobileSdk();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public void initNote() {
SQLiteDatabaseManager sqLiteDatabaseManager = new SQLiteDatabaseManager(addNoteModel.getContext());
sqLiteDatabaseNotes = sqLiteDatabaseManager.getWritableDatabase();

addNoteModel.setNote(addNoteModel.getActivity().getIntent().getParcelableExtra(ExtraNames.AddNoteActivity.note));
if (addNoteModel.getNote() != null) {
view.initNote(addNoteModel.getNote());
}

String title;
String textOnButton;
String time;
Expand All @@ -70,11 +75,6 @@ public void initNote() {
time = new SimpleDateFormat("dd.MM.yyyy HH:mm", Locale.getDefault()).format(new Date(System.currentTimeMillis()));
}
view.initToolbarTitle(title, textOnButton, time);

addNoteModel.setNote(addNoteModel.getActivity().getIntent().getParcelableExtra(ExtraNames.AddNoteActivity.note));
if (addNoteModel.getNote() != null) {
view.initNote(addNoteModel.getNote());
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,9 @@
import android.widget.GridView;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;

import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.google.android.material.snackbar.Snackbar;
import com.yandex.mobile.ads.common.AdError;
import com.yandex.mobile.ads.common.AdRequestConfiguration;
import com.yandex.mobile.ads.common.AdRequestError;
import com.yandex.mobile.ads.common.ImpressionData;
import com.yandex.mobile.ads.interstitial.InterstitialAd;
import com.yandex.mobile.ads.interstitial.InterstitialAdEventListener;
import com.yandex.mobile.ads.interstitial.InterstitialAdLoadListener;
import com.yandex.mobile.ads.interstitial.InterstitialAdLoader;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
Expand All @@ -51,7 +42,6 @@
import ru.plumsoftware.data.model.ui.Colors;
import ru.plumsoftware.data.model.ui.Note;
import ru.plumsoftware.data.model.ui.Shape;
import ru.plumsoftware.notebook.manager.ads.AdsIds;
import ru.plumsoftware.notebook.presentation.activities.note.presenter.AddNotePresenter;
import ru.plumsoftware.notebook.presentation.activities.note.presenter.AddNotePresenterImpl;
import ru.plumsoftware.notebook.presentation.dialogs.ProgressDialog;
Expand All @@ -70,18 +60,17 @@ public class AddNoteActivity extends AppCompatActivity implements AddNoteView {
color,
opacityRes = R.drawable.ic_coffee;

private ProgressDialog progressDialog;

private Calendar dateAndTime = Calendar.getInstance();

private long noteTime = 0L;
private long noteTime = System.currentTimeMillis();

private Toolbar toolbar;
private CardView cardViewBtnDone;
private CheckBox checkBox;
private TextView textViewOnButton;
private EditText tvTitle;
private EditText tvText;
private ProgressDialog progressDialog;

private AddNotePresenter presenter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ public void onClick(View view) {
intent.putExtra("isLoadAppOpenAd", false);
activity.startActivity(intent);
activity.overridePendingTransition(0, 0);
activity.finish();

// BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(context, R.style.BottomSheetTheme);
// bottomSheetDialog.setContentView(R.layout.add_note_layout);
Expand Down

0 comments on commit 512d95e

Please sign in to comment.