From a8b8a3f9026469168ba386d557e441486689be56 Mon Sep 17 00:00:00 2001 From: ChronosX88 Date: Mon, 18 Mar 2019 16:46:07 +0400 Subject: [PATCH] Small refactoring (*Model -> *Logic) --- ...inModelContract.java => MainLogicContract.java} | 2 +- .../MainModel.java => logic/MainLogic.java} | 14 +++++++------- .../influence/presenters/MainPresenter.java | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) rename app/src/main/java/io/github/chronosx88/influence/contracts/{MainModelContract.java => MainLogicContract.java} (72%) rename app/src/main/java/io/github/chronosx88/influence/{models/MainModel.java => logic/MainLogic.java} (95%) diff --git a/app/src/main/java/io/github/chronosx88/influence/contracts/MainModelContract.java b/app/src/main/java/io/github/chronosx88/influence/contracts/MainLogicContract.java similarity index 72% rename from app/src/main/java/io/github/chronosx88/influence/contracts/MainModelContract.java rename to app/src/main/java/io/github/chronosx88/influence/contracts/MainLogicContract.java index 18f7ac0..3454894 100644 --- a/app/src/main/java/io/github/chronosx88/influence/contracts/MainModelContract.java +++ b/app/src/main/java/io/github/chronosx88/influence/contracts/MainLogicContract.java @@ -1,6 +1,6 @@ package io.github.chronosx88.influence.contracts; -public interface MainModelContract { +public interface MainLogicContract { void initPeer(); void shutdownPeer(); } diff --git a/app/src/main/java/io/github/chronosx88/influence/models/MainModel.java b/app/src/main/java/io/github/chronosx88/influence/logic/MainLogic.java similarity index 95% rename from app/src/main/java/io/github/chronosx88/influence/models/MainModel.java rename to app/src/main/java/io/github/chronosx88/influence/logic/MainLogic.java index 9ee5296..3bbfc09 100644 --- a/app/src/main/java/io/github/chronosx88/influence/models/MainModel.java +++ b/app/src/main/java/io/github/chronosx88/influence/logic/MainLogic.java @@ -1,4 +1,4 @@ -package io.github.chronosx88.influence.models; +package io.github.chronosx88.influence.logic; import android.content.Context; import android.content.SharedPreferences; @@ -25,13 +25,13 @@ import java.net.InetAddress; import java.net.UnknownHostException; import java.util.UUID; -import io.github.chronosx88.influence.contracts.MainModelContract; +import io.github.chronosx88.influence.contracts.MainLogicContract; import io.github.chronosx88.influence.helpers.AppHelper; import io.github.chronosx88.influence.helpers.MessageActions; import io.github.chronosx88.influence.helpers.StorageMVStore; -public class MainModel implements MainModelContract { - private static final String LOG_TAG = "MainModel"; +public class MainLogic implements MainLogicContract { + private static final String LOG_TAG = "MainLogic"; private SharedPreferences preferences; private Number160 peerID; @@ -40,7 +40,7 @@ public class MainModel implements MainModelContract { private InetAddress bootstrapAddress = null; private PeerAddress bootstrapPeerAddress = null; - public MainModel() { + public MainLogic() { this.context = AppHelper.getContext(); this.preferences = context.getSharedPreferences("io.github.chronosx88.influence_preferences", context.MODE_PRIVATE); } @@ -140,10 +140,10 @@ public class MainModel implements MainModelContract { FutureBootstrap futureBootstrap = peerDHT.peer().bootstrap().inetAddress(bootstrapAddress).ports(7243).start(); futureBootstrap.awaitUninterruptibly(); if(futureBootstrap.isSuccess()) { - Log.i("MainModel", "# Successfully bootstrapped to " + bootstrapAddress.toString()); + Log.i("MainLogic", "# Successfully bootstrapped to " + bootstrapAddress.toString()); return true; } else { - Log.e("MainModel", "# Cannot bootstrap to " + bootstrapAddress.toString() + ". Reason: " + futureBootstrap.failedReason()); + Log.e("MainLogic", "# Cannot bootstrap to " + bootstrapAddress.toString() + ". Reason: " + futureBootstrap.failedReason()); return false; } } diff --git a/app/src/main/java/io/github/chronosx88/influence/presenters/MainPresenter.java b/app/src/main/java/io/github/chronosx88/influence/presenters/MainPresenter.java index a6cdfe9..90967dd 100644 --- a/app/src/main/java/io/github/chronosx88/influence/presenters/MainPresenter.java +++ b/app/src/main/java/io/github/chronosx88/influence/presenters/MainPresenter.java @@ -1,26 +1,26 @@ package io.github.chronosx88.influence.presenters; -import io.github.chronosx88.influence.contracts.MainModelContract; +import io.github.chronosx88.influence.contracts.MainLogicContract; import io.github.chronosx88.influence.contracts.MainPresenterContract; import io.github.chronosx88.influence.contracts.MainViewContract; -import io.github.chronosx88.influence.models.MainModel; +import io.github.chronosx88.influence.logic.MainLogic; public class MainPresenter implements MainPresenterContract { - private MainModelContract model; + private MainLogicContract logic; private MainViewContract view; public MainPresenter(MainViewContract view) { this.view = view; - model = new MainModel(); + logic = new MainLogic(); } @Override public void initPeer() { - model.initPeer(); + logic.initPeer(); } @Override public void onDestroy() { - model.shutdownPeer(); + logic.shutdownPeer(); } }