mirror of
https://github.com/ChronosX88/Influence-P2P.git
synced 2024-11-22 07:12:19 +00:00
Small refactoring (*Model -> *Logic)
This commit is contained in:
parent
64a527df78
commit
a8b8a3f902
@ -1,6 +1,6 @@
|
|||||||
package io.github.chronosx88.influence.contracts;
|
package io.github.chronosx88.influence.contracts;
|
||||||
|
|
||||||
public interface MainModelContract {
|
public interface MainLogicContract {
|
||||||
void initPeer();
|
void initPeer();
|
||||||
void shutdownPeer();
|
void shutdownPeer();
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package io.github.chronosx88.influence.models;
|
package io.github.chronosx88.influence.logic;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
@ -25,13 +25,13 @@ import java.net.InetAddress;
|
|||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.UUID;
|
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.AppHelper;
|
||||||
import io.github.chronosx88.influence.helpers.MessageActions;
|
import io.github.chronosx88.influence.helpers.MessageActions;
|
||||||
import io.github.chronosx88.influence.helpers.StorageMVStore;
|
import io.github.chronosx88.influence.helpers.StorageMVStore;
|
||||||
|
|
||||||
public class MainModel implements MainModelContract {
|
public class MainLogic implements MainLogicContract {
|
||||||
private static final String LOG_TAG = "MainModel";
|
private static final String LOG_TAG = "MainLogic";
|
||||||
|
|
||||||
private SharedPreferences preferences;
|
private SharedPreferences preferences;
|
||||||
private Number160 peerID;
|
private Number160 peerID;
|
||||||
@ -40,7 +40,7 @@ public class MainModel implements MainModelContract {
|
|||||||
private InetAddress bootstrapAddress = null;
|
private InetAddress bootstrapAddress = null;
|
||||||
private PeerAddress bootstrapPeerAddress = null;
|
private PeerAddress bootstrapPeerAddress = null;
|
||||||
|
|
||||||
public MainModel() {
|
public MainLogic() {
|
||||||
this.context = AppHelper.getContext();
|
this.context = AppHelper.getContext();
|
||||||
this.preferences = context.getSharedPreferences("io.github.chronosx88.influence_preferences", context.MODE_PRIVATE);
|
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 futureBootstrap = peerDHT.peer().bootstrap().inetAddress(bootstrapAddress).ports(7243).start();
|
||||||
futureBootstrap.awaitUninterruptibly();
|
futureBootstrap.awaitUninterruptibly();
|
||||||
if(futureBootstrap.isSuccess()) {
|
if(futureBootstrap.isSuccess()) {
|
||||||
Log.i("MainModel", "# Successfully bootstrapped to " + bootstrapAddress.toString());
|
Log.i("MainLogic", "# Successfully bootstrapped to " + bootstrapAddress.toString());
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} 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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,26 +1,26 @@
|
|||||||
package io.github.chronosx88.influence.presenters;
|
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.MainPresenterContract;
|
||||||
import io.github.chronosx88.influence.contracts.MainViewContract;
|
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 {
|
public class MainPresenter implements MainPresenterContract {
|
||||||
private MainModelContract model;
|
private MainLogicContract logic;
|
||||||
private MainViewContract view;
|
private MainViewContract view;
|
||||||
|
|
||||||
public MainPresenter(MainViewContract view) {
|
public MainPresenter(MainViewContract view) {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
model = new MainModel();
|
logic = new MainLogic();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initPeer() {
|
public void initPeer() {
|
||||||
model.initPeer();
|
logic.initPeer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
model.shutdownPeer();
|
logic.shutdownPeer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user