From c42a00e6b791bea01865029a0d55cbdbd215e7df Mon Sep 17 00:00:00 2001 From: ChronosX88 Date: Fri, 29 Mar 2019 12:40:24 +0400 Subject: [PATCH] Small refactoring (now interfaces have prefix "I") --- ...kListener.java => IItemClickListener.java} | 2 +- ...cContract.java => IChatLogicContract.java} | 2 +- ...tract.java => IChatPresenterContract.java} | 2 +- ...ewContract.java => IChatViewContract.java} | 2 +- ...tract.java => IChatListLogicContract.java} | 2 +- ...t.java => IChatListPresenterContract.java} | 2 +- ...ntract.java => IChatListViewContract.java} | 2 +- ...cContract.java => IMainLogicContract.java} | 2 +- ...tract.java => IMainPresenterContract.java} | 2 +- ...ewContract.java => IMainViewContract.java} | 2 +- ...orkObserver.java => INetworkObserver.java} | 2 +- .../contracts/observer/IObservable.java | 12 ++++++++++ .../{Observer.java => IObserver.java} | 2 +- .../contracts/observer/Observable.java | 12 ---------- ...ract.java => IStartChatLogicContract.java} | 2 +- ....java => IStartChatPresenterContract.java} | 2 +- ...tract.java => IStartChatViewContract.java} | 2 +- .../influence/helpers/ChatListAdapter.java | 6 ++--- .../influence/helpers/NetworkHandler.java | 4 ++-- .../influence/logic/ChatListLogic.java | 4 ++-- .../chronosx88/influence/logic/ChatLogic.java | 4 ++-- .../chronosx88/influence/logic/MainLogic.java | 4 ++-- .../influence/logic/StartChatLogic.java | 10 ++------ .../influence/observable/MainObservable.java | 24 +++++++++---------- .../presenters/ChatListPresenter.java | 17 ++++++------- .../influence/presenters/ChatPresenter.java | 16 ++++++------- .../influence/presenters/MainPresenter.java | 14 +++++------ .../presenters/StartChatPresenter.java | 16 ++++++------- .../influence/views/ChatActivity.java | 4 ++-- .../influence/views/MainActivity.java | 10 ++++---- .../views/fragments/ChatListFragment.java | 10 ++++---- .../views/fragments/StartChatFragment.java | 5 ++-- 32 files changed, 96 insertions(+), 106 deletions(-) rename app/src/main/java/io/github/chronosx88/influence/contracts/{ItemClickListener.java => IItemClickListener.java} (76%) rename app/src/main/java/io/github/chronosx88/influence/contracts/chatactivity/{ChatLogicContract.java => IChatLogicContract.java} (86%) rename app/src/main/java/io/github/chronosx88/influence/contracts/chatactivity/{ChatPresenterContract.java => IChatPresenterContract.java} (75%) rename app/src/main/java/io/github/chronosx88/influence/contracts/chatactivity/{ChatViewContract.java => IChatViewContract.java} (88%) rename app/src/main/java/io/github/chronosx88/influence/contracts/chatlist/{ChatListLogicContract.java => IChatListLogicContract.java} (82%) rename app/src/main/java/io/github/chronosx88/influence/contracts/chatlist/{ChatListPresenterContract.java => IChatListPresenterContract.java} (81%) rename app/src/main/java/io/github/chronosx88/influence/contracts/chatlist/{ChatListViewContract.java => IChatListViewContract.java} (91%) rename app/src/main/java/io/github/chronosx88/influence/contracts/mainactivity/{MainLogicContract.java => IMainLogicContract.java} (74%) rename app/src/main/java/io/github/chronosx88/influence/contracts/mainactivity/{MainPresenterContract.java => IMainPresenterContract.java} (72%) rename app/src/main/java/io/github/chronosx88/influence/contracts/mainactivity/{MainViewContract.java => IMainViewContract.java} (66%) rename app/src/main/java/io/github/chronosx88/influence/contracts/observer/{NetworkObserver.java => INetworkObserver.java} (73%) create mode 100644 app/src/main/java/io/github/chronosx88/influence/contracts/observer/IObservable.java rename app/src/main/java/io/github/chronosx88/influence/contracts/observer/{Observer.java => IObserver.java} (82%) delete mode 100644 app/src/main/java/io/github/chronosx88/influence/contracts/observer/Observable.java rename app/src/main/java/io/github/chronosx88/influence/contracts/startchat/{StartChatLogicContract.java => IStartChatLogicContract.java} (71%) rename app/src/main/java/io/github/chronosx88/influence/contracts/startchat/{StartChatPresenterContract.java => IStartChatPresenterContract.java} (69%) rename app/src/main/java/io/github/chronosx88/influence/contracts/startchat/{StartChatViewContract.java => IStartChatViewContract.java} (77%) diff --git a/app/src/main/java/io/github/chronosx88/influence/contracts/ItemClickListener.java b/app/src/main/java/io/github/chronosx88/influence/contracts/IItemClickListener.java similarity index 76% rename from app/src/main/java/io/github/chronosx88/influence/contracts/ItemClickListener.java rename to app/src/main/java/io/github/chronosx88/influence/contracts/IItemClickListener.java index 1788dfd..2474dcb 100644 --- a/app/src/main/java/io/github/chronosx88/influence/contracts/ItemClickListener.java +++ b/app/src/main/java/io/github/chronosx88/influence/contracts/IItemClickListener.java @@ -2,6 +2,6 @@ package io.github.chronosx88.influence.contracts; import android.view.View; -public interface ItemClickListener { +public interface IItemClickListener { void onItemClick(View view, int position); } \ No newline at end of file diff --git a/app/src/main/java/io/github/chronosx88/influence/contracts/chatactivity/ChatLogicContract.java b/app/src/main/java/io/github/chronosx88/influence/contracts/chatactivity/IChatLogicContract.java similarity index 86% rename from app/src/main/java/io/github/chronosx88/influence/contracts/chatactivity/ChatLogicContract.java rename to app/src/main/java/io/github/chronosx88/influence/contracts/chatactivity/IChatLogicContract.java index ab26d70..c1484d2 100644 --- a/app/src/main/java/io/github/chronosx88/influence/contracts/chatactivity/ChatLogicContract.java +++ b/app/src/main/java/io/github/chronosx88/influence/contracts/chatactivity/IChatLogicContract.java @@ -4,6 +4,6 @@ import net.tomp2p.peers.PeerAddress; import io.github.chronosx88.influence.models.roomEntities.MessageEntity; -public interface ChatLogicContract { +public interface IChatLogicContract { void sendMessage(PeerAddress address, MessageEntity message); } diff --git a/app/src/main/java/io/github/chronosx88/influence/contracts/chatactivity/ChatPresenterContract.java b/app/src/main/java/io/github/chronosx88/influence/contracts/chatactivity/IChatPresenterContract.java similarity index 75% rename from app/src/main/java/io/github/chronosx88/influence/contracts/chatactivity/ChatPresenterContract.java rename to app/src/main/java/io/github/chronosx88/influence/contracts/chatactivity/IChatPresenterContract.java index 9668c33..a4487d6 100644 --- a/app/src/main/java/io/github/chronosx88/influence/contracts/chatactivity/ChatPresenterContract.java +++ b/app/src/main/java/io/github/chronosx88/influence/contracts/chatactivity/IChatPresenterContract.java @@ -1,6 +1,6 @@ package io.github.chronosx88.influence.contracts.chatactivity; -public interface ChatPresenterContract { +public interface IChatPresenterContract { void sendMessage(String text); void updateAdapter(); } diff --git a/app/src/main/java/io/github/chronosx88/influence/contracts/chatactivity/ChatViewContract.java b/app/src/main/java/io/github/chronosx88/influence/contracts/chatactivity/IChatViewContract.java similarity index 88% rename from app/src/main/java/io/github/chronosx88/influence/contracts/chatactivity/ChatViewContract.java rename to app/src/main/java/io/github/chronosx88/influence/contracts/chatactivity/IChatViewContract.java index 4600a7a..871de0a 100644 --- a/app/src/main/java/io/github/chronosx88/influence/contracts/chatactivity/ChatViewContract.java +++ b/app/src/main/java/io/github/chronosx88/influence/contracts/chatactivity/IChatViewContract.java @@ -4,7 +4,7 @@ import java.util.List; import io.github.chronosx88.influence.models.roomEntities.MessageEntity; -public interface ChatViewContract { +public interface IChatViewContract { void updateMessageList(MessageEntity message); void updateMessageList(List messages); } diff --git a/app/src/main/java/io/github/chronosx88/influence/contracts/chatlist/ChatListLogicContract.java b/app/src/main/java/io/github/chronosx88/influence/contracts/chatlist/IChatListLogicContract.java similarity index 82% rename from app/src/main/java/io/github/chronosx88/influence/contracts/chatlist/ChatListLogicContract.java rename to app/src/main/java/io/github/chronosx88/influence/contracts/chatlist/IChatListLogicContract.java index a618335..eff7c8b 100644 --- a/app/src/main/java/io/github/chronosx88/influence/contracts/chatlist/ChatListLogicContract.java +++ b/app/src/main/java/io/github/chronosx88/influence/contracts/chatlist/IChatListLogicContract.java @@ -4,6 +4,6 @@ import java.util.List; import io.github.chronosx88.influence.models.roomEntities.ChatEntity; -public interface ChatListLogicContract { +public interface IChatListLogicContract { List loadAllChats(); } diff --git a/app/src/main/java/io/github/chronosx88/influence/contracts/chatlist/ChatListPresenterContract.java b/app/src/main/java/io/github/chronosx88/influence/contracts/chatlist/IChatListPresenterContract.java similarity index 81% rename from app/src/main/java/io/github/chronosx88/influence/contracts/chatlist/ChatListPresenterContract.java rename to app/src/main/java/io/github/chronosx88/influence/contracts/chatlist/IChatListPresenterContract.java index 15a8bbd..125a767 100644 --- a/app/src/main/java/io/github/chronosx88/influence/contracts/chatlist/ChatListPresenterContract.java +++ b/app/src/main/java/io/github/chronosx88/influence/contracts/chatlist/IChatListPresenterContract.java @@ -2,7 +2,7 @@ package io.github.chronosx88.influence.contracts.chatlist; import android.view.MenuItem; -public interface ChatListPresenterContract { +public interface IChatListPresenterContract { void updateChatList(); void openChat(String chatID); void onContextItemSelected(MenuItem item); diff --git a/app/src/main/java/io/github/chronosx88/influence/contracts/chatlist/ChatListViewContract.java b/app/src/main/java/io/github/chronosx88/influence/contracts/chatlist/IChatListViewContract.java similarity index 91% rename from app/src/main/java/io/github/chronosx88/influence/contracts/chatlist/ChatListViewContract.java rename to app/src/main/java/io/github/chronosx88/influence/contracts/chatlist/IChatListViewContract.java index acf1740..4a7a544 100644 --- a/app/src/main/java/io/github/chronosx88/influence/contracts/chatlist/ChatListViewContract.java +++ b/app/src/main/java/io/github/chronosx88/influence/contracts/chatlist/IChatListViewContract.java @@ -7,7 +7,7 @@ import java.util.List; import io.github.chronosx88.influence.helpers.ChatListAdapter; import io.github.chronosx88.influence.models.roomEntities.ChatEntity; -public interface ChatListViewContract { +public interface IChatListViewContract { void setRecycleAdapter(ChatListAdapter adapter); void startActivity(Intent intent); void updateChatList(ChatListAdapter adapter, List chats); diff --git a/app/src/main/java/io/github/chronosx88/influence/contracts/mainactivity/MainLogicContract.java b/app/src/main/java/io/github/chronosx88/influence/contracts/mainactivity/IMainLogicContract.java similarity index 74% rename from app/src/main/java/io/github/chronosx88/influence/contracts/mainactivity/MainLogicContract.java rename to app/src/main/java/io/github/chronosx88/influence/contracts/mainactivity/IMainLogicContract.java index 497828a..65ad0c9 100644 --- a/app/src/main/java/io/github/chronosx88/influence/contracts/mainactivity/MainLogicContract.java +++ b/app/src/main/java/io/github/chronosx88/influence/contracts/mainactivity/IMainLogicContract.java @@ -1,6 +1,6 @@ package io.github.chronosx88.influence.contracts.mainactivity; -public interface MainLogicContract { +public interface IMainLogicContract { void initPeer(); void shutdownPeer(); } diff --git a/app/src/main/java/io/github/chronosx88/influence/contracts/mainactivity/MainPresenterContract.java b/app/src/main/java/io/github/chronosx88/influence/contracts/mainactivity/IMainPresenterContract.java similarity index 72% rename from app/src/main/java/io/github/chronosx88/influence/contracts/mainactivity/MainPresenterContract.java rename to app/src/main/java/io/github/chronosx88/influence/contracts/mainactivity/IMainPresenterContract.java index 23ff888..69bd549 100644 --- a/app/src/main/java/io/github/chronosx88/influence/contracts/mainactivity/MainPresenterContract.java +++ b/app/src/main/java/io/github/chronosx88/influence/contracts/mainactivity/IMainPresenterContract.java @@ -1,6 +1,6 @@ package io.github.chronosx88.influence.contracts.mainactivity; -public interface MainPresenterContract { +public interface IMainPresenterContract { void initPeer(); void onDestroy(); } diff --git a/app/src/main/java/io/github/chronosx88/influence/contracts/mainactivity/MainViewContract.java b/app/src/main/java/io/github/chronosx88/influence/contracts/mainactivity/IMainViewContract.java similarity index 66% rename from app/src/main/java/io/github/chronosx88/influence/contracts/mainactivity/MainViewContract.java rename to app/src/main/java/io/github/chronosx88/influence/contracts/mainactivity/IMainViewContract.java index 8f290ff..ee49885 100644 --- a/app/src/main/java/io/github/chronosx88/influence/contracts/mainactivity/MainViewContract.java +++ b/app/src/main/java/io/github/chronosx88/influence/contracts/mainactivity/IMainViewContract.java @@ -1,5 +1,5 @@ package io.github.chronosx88.influence.contracts.mainactivity; -public interface MainViewContract { +public interface IMainViewContract { // } diff --git a/app/src/main/java/io/github/chronosx88/influence/contracts/observer/NetworkObserver.java b/app/src/main/java/io/github/chronosx88/influence/contracts/observer/INetworkObserver.java similarity index 73% rename from app/src/main/java/io/github/chronosx88/influence/contracts/observer/NetworkObserver.java rename to app/src/main/java/io/github/chronosx88/influence/contracts/observer/INetworkObserver.java index c398b1d..3a2d0fe 100644 --- a/app/src/main/java/io/github/chronosx88/influence/contracts/observer/NetworkObserver.java +++ b/app/src/main/java/io/github/chronosx88/influence/contracts/observer/INetworkObserver.java @@ -1,5 +1,5 @@ package io.github.chronosx88.influence.contracts.observer; -public interface NetworkObserver { +public interface INetworkObserver { void handleEvent(Object object); } diff --git a/app/src/main/java/io/github/chronosx88/influence/contracts/observer/IObservable.java b/app/src/main/java/io/github/chronosx88/influence/contracts/observer/IObservable.java new file mode 100644 index 0000000..68a8126 --- /dev/null +++ b/app/src/main/java/io/github/chronosx88/influence/contracts/observer/IObservable.java @@ -0,0 +1,12 @@ +package io.github.chronosx88.influence.contracts.observer; + +import com.google.gson.JsonObject; + +public interface IObservable { + void register(IObserver observer); + void register(INetworkObserver networkObserver); + void unregister(IObserver observer); + void unregister(INetworkObserver networkObserver); + void notifyUIObservers(JsonObject jsonObject); + void notifyNetworkObservers(Object object); +} diff --git a/app/src/main/java/io/github/chronosx88/influence/contracts/observer/Observer.java b/app/src/main/java/io/github/chronosx88/influence/contracts/observer/IObserver.java similarity index 82% rename from app/src/main/java/io/github/chronosx88/influence/contracts/observer/Observer.java rename to app/src/main/java/io/github/chronosx88/influence/contracts/observer/IObserver.java index 969e2fb..0ffa003 100644 --- a/app/src/main/java/io/github/chronosx88/influence/contracts/observer/Observer.java +++ b/app/src/main/java/io/github/chronosx88/influence/contracts/observer/IObserver.java @@ -2,6 +2,6 @@ package io.github.chronosx88.influence.contracts.observer; import com.google.gson.JsonObject; -public interface Observer { +public interface IObserver { void handleEvent(JsonObject object); } \ No newline at end of file diff --git a/app/src/main/java/io/github/chronosx88/influence/contracts/observer/Observable.java b/app/src/main/java/io/github/chronosx88/influence/contracts/observer/Observable.java deleted file mode 100644 index 72d14ee..0000000 --- a/app/src/main/java/io/github/chronosx88/influence/contracts/observer/Observable.java +++ /dev/null @@ -1,12 +0,0 @@ -package io.github.chronosx88.influence.contracts.observer; - -import com.google.gson.JsonObject; - -public interface Observable { - void register(Observer observer); - void register(NetworkObserver networkObserver); - void unregister(Observer observer); - void unregister(NetworkObserver networkObserver); - void notifyUIObservers(JsonObject jsonObject); - void notifyNetworkObservers(Object object); -} diff --git a/app/src/main/java/io/github/chronosx88/influence/contracts/startchat/StartChatLogicContract.java b/app/src/main/java/io/github/chronosx88/influence/contracts/startchat/IStartChatLogicContract.java similarity index 71% rename from app/src/main/java/io/github/chronosx88/influence/contracts/startchat/StartChatLogicContract.java rename to app/src/main/java/io/github/chronosx88/influence/contracts/startchat/IStartChatLogicContract.java index ea509c0..59763b3 100644 --- a/app/src/main/java/io/github/chronosx88/influence/contracts/startchat/StartChatLogicContract.java +++ b/app/src/main/java/io/github/chronosx88/influence/contracts/startchat/IStartChatLogicContract.java @@ -1,5 +1,5 @@ package io.github.chronosx88.influence.contracts.startchat; -public interface StartChatLogicContract { +public interface IStartChatLogicContract { void sendStartChatMessage(String peerID); } diff --git a/app/src/main/java/io/github/chronosx88/influence/contracts/startchat/StartChatPresenterContract.java b/app/src/main/java/io/github/chronosx88/influence/contracts/startchat/IStartChatPresenterContract.java similarity index 69% rename from app/src/main/java/io/github/chronosx88/influence/contracts/startchat/StartChatPresenterContract.java rename to app/src/main/java/io/github/chronosx88/influence/contracts/startchat/IStartChatPresenterContract.java index 607f78a..de736b8 100644 --- a/app/src/main/java/io/github/chronosx88/influence/contracts/startchat/StartChatPresenterContract.java +++ b/app/src/main/java/io/github/chronosx88/influence/contracts/startchat/IStartChatPresenterContract.java @@ -1,5 +1,5 @@ package io.github.chronosx88.influence.contracts.startchat; -public interface StartChatPresenterContract { +public interface IStartChatPresenterContract { void startChatWithPeer(String peerID); } diff --git a/app/src/main/java/io/github/chronosx88/influence/contracts/startchat/StartChatViewContract.java b/app/src/main/java/io/github/chronosx88/influence/contracts/startchat/IStartChatViewContract.java similarity index 77% rename from app/src/main/java/io/github/chronosx88/influence/contracts/startchat/StartChatViewContract.java rename to app/src/main/java/io/github/chronosx88/influence/contracts/startchat/IStartChatViewContract.java index 20327d0..cdf5bf3 100644 --- a/app/src/main/java/io/github/chronosx88/influence/contracts/startchat/StartChatViewContract.java +++ b/app/src/main/java/io/github/chronosx88/influence/contracts/startchat/IStartChatViewContract.java @@ -1,6 +1,6 @@ package io.github.chronosx88.influence.contracts.startchat; -public interface StartChatViewContract { +public interface IStartChatViewContract { void showMessage(String message); void showProgressDialog(boolean enabled); } diff --git a/app/src/main/java/io/github/chronosx88/influence/helpers/ChatListAdapter.java b/app/src/main/java/io/github/chronosx88/influence/helpers/ChatListAdapter.java index 29942aa..5593f18 100644 --- a/app/src/main/java/io/github/chronosx88/influence/helpers/ChatListAdapter.java +++ b/app/src/main/java/io/github/chronosx88/influence/helpers/ChatListAdapter.java @@ -12,15 +12,15 @@ import java.util.List; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import io.github.chronosx88.influence.R; -import io.github.chronosx88.influence.contracts.ItemClickListener; +import io.github.chronosx88.influence.contracts.IItemClickListener; import io.github.chronosx88.influence.models.roomEntities.ChatEntity; public class ChatListAdapter extends RecyclerView.Adapter { List chatList = new ArrayList<>(); public int onClickPosition = -1; - private ItemClickListener itemClickListener; + private IItemClickListener itemClickListener; - public ChatListAdapter(ItemClickListener itemClickListener) { + public ChatListAdapter(IItemClickListener itemClickListener) { this.itemClickListener = itemClickListener; } diff --git a/app/src/main/java/io/github/chronosx88/influence/helpers/NetworkHandler.java b/app/src/main/java/io/github/chronosx88/influence/helpers/NetworkHandler.java index cbc8259..3a15e55 100644 --- a/app/src/main/java/io/github/chronosx88/influence/helpers/NetworkHandler.java +++ b/app/src/main/java/io/github/chronosx88/influence/helpers/NetworkHandler.java @@ -15,14 +15,14 @@ import net.tomp2p.storage.Data; import java.io.IOException; import java.util.Map; -import io.github.chronosx88.influence.contracts.observer.NetworkObserver; +import io.github.chronosx88.influence.contracts.observer.INetworkObserver; import io.github.chronosx88.influence.helpers.actions.NetworkActions; import io.github.chronosx88.influence.helpers.actions.UIActions; import io.github.chronosx88.influence.models.NewChatRequestMessage; import io.github.chronosx88.influence.models.SendMessage; import io.github.chronosx88.influence.models.SuccessfullySentMessage; -public class NetworkHandler implements NetworkObserver { +public class NetworkHandler implements INetworkObserver { private final static String LOG_TAG = "NetworkHandler"; private static Gson gson = new Gson(); private static PeerDHT peerDHT = AppHelper.getPeerDHT(); diff --git a/app/src/main/java/io/github/chronosx88/influence/logic/ChatListLogic.java b/app/src/main/java/io/github/chronosx88/influence/logic/ChatListLogic.java index 1834ff3..0f74550 100644 --- a/app/src/main/java/io/github/chronosx88/influence/logic/ChatListLogic.java +++ b/app/src/main/java/io/github/chronosx88/influence/logic/ChatListLogic.java @@ -2,11 +2,11 @@ package io.github.chronosx88.influence.logic; import java.util.List; -import io.github.chronosx88.influence.contracts.chatlist.ChatListLogicContract; +import io.github.chronosx88.influence.contracts.chatlist.IChatListLogicContract; import io.github.chronosx88.influence.helpers.AppHelper; import io.github.chronosx88.influence.models.roomEntities.ChatEntity; -public class ChatListLogic implements ChatListLogicContract { +public class ChatListLogic implements IChatListLogicContract { @Override public List loadAllChats() { diff --git a/app/src/main/java/io/github/chronosx88/influence/logic/ChatLogic.java b/app/src/main/java/io/github/chronosx88/influence/logic/ChatLogic.java index 88cdea9..ab361f0 100644 --- a/app/src/main/java/io/github/chronosx88/influence/logic/ChatLogic.java +++ b/app/src/main/java/io/github/chronosx88/influence/logic/ChatLogic.java @@ -4,13 +4,13 @@ import com.google.gson.Gson; import net.tomp2p.peers.PeerAddress; -import io.github.chronosx88.influence.contracts.chatactivity.ChatLogicContract; +import io.github.chronosx88.influence.contracts.chatactivity.IChatLogicContract; import io.github.chronosx88.influence.helpers.AppHelper; import io.github.chronosx88.influence.helpers.P2PUtils; import io.github.chronosx88.influence.models.SendMessage; import io.github.chronosx88.influence.models.roomEntities.MessageEntity; -public class ChatLogic implements ChatLogicContract { +public class ChatLogic implements IChatLogicContract { private static Gson gson = new Gson(); @Override public void sendMessage(PeerAddress address, MessageEntity message) { diff --git a/app/src/main/java/io/github/chronosx88/influence/logic/MainLogic.java b/app/src/main/java/io/github/chronosx88/influence/logic/MainLogic.java index a281c3e..112c621 100644 --- a/app/src/main/java/io/github/chronosx88/influence/logic/MainLogic.java +++ b/app/src/main/java/io/github/chronosx88/influence/logic/MainLogic.java @@ -32,7 +32,7 @@ import java.security.spec.DSAPublicKeySpec; import java.security.spec.InvalidKeySpecException; import java.util.UUID; -import io.github.chronosx88.influence.contracts.mainactivity.MainLogicContract; +import io.github.chronosx88.influence.contracts.mainactivity.IMainLogicContract; import io.github.chronosx88.influence.helpers.AppHelper; import io.github.chronosx88.influence.helpers.DSAKey; import io.github.chronosx88.influence.helpers.KeyPairManager; @@ -42,7 +42,7 @@ import io.github.chronosx88.influence.helpers.StorageMVStore; import io.github.chronosx88.influence.helpers.actions.UIActions; import io.github.chronosx88.influence.models.PublicUserProfile; -public class MainLogic implements MainLogicContract { +public class MainLogic implements IMainLogicContract { private static final String LOG_TAG = "MainLogic"; private SharedPreferences preferences; diff --git a/app/src/main/java/io/github/chronosx88/influence/logic/StartChatLogic.java b/app/src/main/java/io/github/chronosx88/influence/logic/StartChatLogic.java index 8a00a84..196c63a 100644 --- a/app/src/main/java/io/github/chronosx88/influence/logic/StartChatLogic.java +++ b/app/src/main/java/io/github/chronosx88/influence/logic/StartChatLogic.java @@ -3,13 +3,8 @@ package io.github.chronosx88.influence.logic; import android.util.Log; import com.google.gson.Gson; -import com.google.gson.JsonObject; -import net.tomp2p.dht.FutureGet; -import net.tomp2p.dht.FuturePut; import net.tomp2p.dht.PeerDHT; -import net.tomp2p.futures.FuturePing; -import net.tomp2p.peers.Number160; import net.tomp2p.peers.Number640; import net.tomp2p.peers.PeerAddress; import net.tomp2p.storage.Data; @@ -18,18 +13,17 @@ import java.io.IOException; import java.util.Map; import java.util.UUID; -import io.github.chronosx88.influence.contracts.startchat.StartChatLogicContract; +import io.github.chronosx88.influence.contracts.startchat.IStartChatLogicContract; import io.github.chronosx88.influence.helpers.AppHelper; import io.github.chronosx88.influence.helpers.KeyPairManager; import io.github.chronosx88.influence.helpers.LocalDBWrapper; -import io.github.chronosx88.influence.helpers.NetworkHandler; import io.github.chronosx88.influence.helpers.ObservableUtils; import io.github.chronosx88.influence.helpers.P2PUtils; import io.github.chronosx88.influence.helpers.actions.UIActions; import io.github.chronosx88.influence.models.NewChatRequestMessage; import io.github.chronosx88.influence.models.PublicUserProfile; -public class StartChatLogic implements StartChatLogicContract { +public class StartChatLogic implements IStartChatLogicContract { private PeerDHT peerDHT; private Gson gson; private KeyPairManager keyPairManager; diff --git a/app/src/main/java/io/github/chronosx88/influence/observable/MainObservable.java b/app/src/main/java/io/github/chronosx88/influence/observable/MainObservable.java index 16ff221..5d40190 100644 --- a/app/src/main/java/io/github/chronosx88/influence/observable/MainObservable.java +++ b/app/src/main/java/io/github/chronosx88/influence/observable/MainObservable.java @@ -4,16 +4,16 @@ import com.google.gson.JsonObject; import java.util.ArrayList; -import io.github.chronosx88.influence.contracts.observer.NetworkObserver; -import io.github.chronosx88.influence.contracts.observer.Observable; -import io.github.chronosx88.influence.contracts.observer.Observer; +import io.github.chronosx88.influence.contracts.observer.INetworkObserver; +import io.github.chronosx88.influence.contracts.observer.IObservable; +import io.github.chronosx88.influence.contracts.observer.IObserver; -public class MainObservable implements Observable { +public class MainObservable implements IObservable { public static final int UI_ACTIONS_CHANNEL = 0; public static final int OTHER_ACTIONS_CHANNEL = 1; - private ArrayList uiObservers; - private ArrayList networkObservers; + private ArrayList uiObservers; + private ArrayList networkObservers; public MainObservable() { this.uiObservers = new ArrayList<>(); @@ -21,35 +21,35 @@ public class MainObservable implements Observable { } @Override - public void register(Observer observer) { + public void register(IObserver observer) { uiObservers.add(observer); } @Override - public void register(NetworkObserver observer) { + public void register(INetworkObserver observer) { networkObservers.add(observer); } @Override - public void unregister(Observer observer) { + public void unregister(IObserver observer) { uiObservers.remove(observer); } @Override - public void unregister(NetworkObserver observer) { + public void unregister(INetworkObserver observer) { networkObservers.remove(observer); } @Override public void notifyUIObservers(JsonObject jsonObject) { - for (Observer observer : uiObservers) { + for (IObserver observer : uiObservers) { observer.handleEvent(jsonObject); } } @Override public void notifyNetworkObservers(Object object) { - for (NetworkObserver observer : networkObservers) { + for (INetworkObserver observer : networkObservers) { observer.handleEvent(object); } } diff --git a/app/src/main/java/io/github/chronosx88/influence/presenters/ChatListPresenter.java b/app/src/main/java/io/github/chronosx88/influence/presenters/ChatListPresenter.java index b42c15b..5f58903 100644 --- a/app/src/main/java/io/github/chronosx88/influence/presenters/ChatListPresenter.java +++ b/app/src/main/java/io/github/chronosx88/influence/presenters/ChatListPresenter.java @@ -3,12 +3,9 @@ package io.github.chronosx88.influence.presenters; import android.content.Intent; import android.view.MenuItem; -import net.tomp2p.dht.FutureRemove; -import net.tomp2p.peers.Number160; - -import io.github.chronosx88.influence.contracts.chatlist.ChatListLogicContract; -import io.github.chronosx88.influence.contracts.chatlist.ChatListPresenterContract; -import io.github.chronosx88.influence.contracts.chatlist.ChatListViewContract; +import io.github.chronosx88.influence.contracts.chatlist.IChatListLogicContract; +import io.github.chronosx88.influence.contracts.chatlist.IChatListPresenterContract; +import io.github.chronosx88.influence.contracts.chatlist.IChatListViewContract; import io.github.chronosx88.influence.helpers.AppHelper; import io.github.chronosx88.influence.helpers.ChatListAdapter; import io.github.chronosx88.influence.helpers.LocalDBWrapper; @@ -16,12 +13,12 @@ import io.github.chronosx88.influence.logic.ChatListLogic; import io.github.chronosx88.influence.models.roomEntities.ChatEntity; import io.github.chronosx88.influence.views.ChatActivity; -public class ChatListPresenter implements ChatListPresenterContract { - private ChatListViewContract view; - private ChatListLogicContract logic; +public class ChatListPresenter implements IChatListPresenterContract { + private IChatListViewContract view; + private IChatListLogicContract logic; private ChatListAdapter chatListAdapter; - public ChatListPresenter(ChatListViewContract view) { + public ChatListPresenter(IChatListViewContract view) { this.view = view; chatListAdapter = new ChatListAdapter((v, p)-> { openChat(chatListAdapter.getChatEntity(p).chatID); diff --git a/app/src/main/java/io/github/chronosx88/influence/presenters/ChatPresenter.java b/app/src/main/java/io/github/chronosx88/influence/presenters/ChatPresenter.java index 626a00b..2b6d910 100644 --- a/app/src/main/java/io/github/chronosx88/influence/presenters/ChatPresenter.java +++ b/app/src/main/java/io/github/chronosx88/influence/presenters/ChatPresenter.java @@ -8,10 +8,10 @@ import net.tomp2p.peers.PeerAddress; import java.util.ArrayList; import java.util.List; -import io.github.chronosx88.influence.contracts.chatactivity.ChatLogicContract; -import io.github.chronosx88.influence.contracts.chatactivity.ChatPresenterContract; -import io.github.chronosx88.influence.contracts.chatactivity.ChatViewContract; -import io.github.chronosx88.influence.contracts.observer.Observer; +import io.github.chronosx88.influence.contracts.chatactivity.IChatLogicContract; +import io.github.chronosx88.influence.contracts.chatactivity.IChatPresenterContract; +import io.github.chronosx88.influence.contracts.chatactivity.IChatViewContract; +import io.github.chronosx88.influence.contracts.observer.IObserver; import io.github.chronosx88.influence.helpers.AppHelper; import io.github.chronosx88.influence.helpers.LocalDBWrapper; import io.github.chronosx88.influence.helpers.MessageTypes; @@ -20,14 +20,14 @@ import io.github.chronosx88.influence.helpers.actions.UIActions; import io.github.chronosx88.influence.logic.ChatLogic; import io.github.chronosx88.influence.models.roomEntities.MessageEntity; -public class ChatPresenter implements ChatPresenterContract, Observer { - private ChatLogicContract logic; - private ChatViewContract view; +public class ChatPresenter implements IChatPresenterContract, IObserver { + private IChatLogicContract logic; + private IChatViewContract view; private PeerAddress receiverAddress; private String chatID; private Gson gson; - public ChatPresenter(ChatViewContract view, String chatID) { + public ChatPresenter(IChatViewContract view, String chatID) { this.logic = new ChatLogic(); this.view = view; this.chatID = chatID; 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 c24d6a7..9262726 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,15 +1,15 @@ package io.github.chronosx88.influence.presenters; -import io.github.chronosx88.influence.contracts.mainactivity.MainLogicContract; -import io.github.chronosx88.influence.contracts.mainactivity.MainPresenterContract; -import io.github.chronosx88.influence.contracts.mainactivity.MainViewContract; +import io.github.chronosx88.influence.contracts.mainactivity.IMainLogicContract; +import io.github.chronosx88.influence.contracts.mainactivity.IMainPresenterContract; +import io.github.chronosx88.influence.contracts.mainactivity.IMainViewContract; import io.github.chronosx88.influence.logic.MainLogic; -public class MainPresenter implements MainPresenterContract { - private MainLogicContract logic; - private MainViewContract view; +public class MainPresenter implements IMainPresenterContract { + private IMainLogicContract logic; + private IMainViewContract view; - public MainPresenter(MainViewContract view) { + public MainPresenter(IMainViewContract view) { this.view = view; logic = new MainLogic(); } diff --git a/app/src/main/java/io/github/chronosx88/influence/presenters/StartChatPresenter.java b/app/src/main/java/io/github/chronosx88/influence/presenters/StartChatPresenter.java index 2269214..26f8c82 100644 --- a/app/src/main/java/io/github/chronosx88/influence/presenters/StartChatPresenter.java +++ b/app/src/main/java/io/github/chronosx88/influence/presenters/StartChatPresenter.java @@ -2,19 +2,19 @@ package io.github.chronosx88.influence.presenters; import com.google.gson.JsonObject; -import io.github.chronosx88.influence.contracts.observer.Observer; -import io.github.chronosx88.influence.contracts.startchat.StartChatLogicContract; -import io.github.chronosx88.influence.contracts.startchat.StartChatPresenterContract; -import io.github.chronosx88.influence.contracts.startchat.StartChatViewContract; +import io.github.chronosx88.influence.contracts.observer.IObserver; +import io.github.chronosx88.influence.contracts.startchat.IStartChatLogicContract; +import io.github.chronosx88.influence.contracts.startchat.IStartChatPresenterContract; +import io.github.chronosx88.influence.contracts.startchat.IStartChatViewContract; import io.github.chronosx88.influence.helpers.AppHelper; import io.github.chronosx88.influence.helpers.actions.UIActions; import io.github.chronosx88.influence.logic.StartChatLogic; -public class StartChatPresenter implements StartChatPresenterContract, Observer { - private StartChatViewContract view; - private StartChatLogicContract logic; +public class StartChatPresenter implements IStartChatPresenterContract, IObserver { + private IStartChatViewContract view; + private IStartChatLogicContract logic; - public StartChatPresenter(StartChatViewContract view) { + public StartChatPresenter(IStartChatViewContract view) { this.view = view; this.logic = new StartChatLogic(); AppHelper.getObservable().register(this); diff --git a/app/src/main/java/io/github/chronosx88/influence/views/ChatActivity.java b/app/src/main/java/io/github/chronosx88/influence/views/ChatActivity.java index 8180435..66e19be 100644 --- a/app/src/main/java/io/github/chronosx88/influence/views/ChatActivity.java +++ b/app/src/main/java/io/github/chronosx88/influence/views/ChatActivity.java @@ -14,12 +14,12 @@ import androidx.appcompat.widget.Toolbar; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import io.github.chronosx88.influence.R; -import io.github.chronosx88.influence.contracts.chatactivity.ChatViewContract; +import io.github.chronosx88.influence.contracts.chatactivity.IChatViewContract; import io.github.chronosx88.influence.helpers.ChatAdapter; import io.github.chronosx88.influence.models.roomEntities.MessageEntity; import io.github.chronosx88.influence.presenters.ChatPresenter; -public class ChatActivity extends AppCompatActivity implements ChatViewContract { +public class ChatActivity extends AppCompatActivity implements IChatViewContract { private ChatAdapter chatAdapter; private RecyclerView messageList; private ImageButton sendMessageButton; diff --git a/app/src/main/java/io/github/chronosx88/influence/views/MainActivity.java b/app/src/main/java/io/github/chronosx88/influence/views/MainActivity.java index 100d6da..95ef21c 100644 --- a/app/src/main/java/io/github/chronosx88/influence/views/MainActivity.java +++ b/app/src/main/java/io/github/chronosx88/influence/views/MainActivity.java @@ -13,9 +13,9 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentTransaction; import io.github.chronosx88.influence.R; -import io.github.chronosx88.influence.contracts.mainactivity.MainPresenterContract; -import io.github.chronosx88.influence.contracts.mainactivity.MainViewContract; -import io.github.chronosx88.influence.contracts.observer.Observer; +import io.github.chronosx88.influence.contracts.mainactivity.IMainPresenterContract; +import io.github.chronosx88.influence.contracts.mainactivity.IMainViewContract; +import io.github.chronosx88.influence.contracts.observer.IObserver; import io.github.chronosx88.influence.helpers.AppHelper; import io.github.chronosx88.influence.helpers.actions.UIActions; import io.github.chronosx88.influence.presenters.MainPresenter; @@ -23,9 +23,9 @@ import io.github.chronosx88.influence.views.fragments.ChatListFragment; import io.github.chronosx88.influence.views.fragments.SettingsFragment; import io.github.chronosx88.influence.views.fragments.StartChatFragment; -public class MainActivity extends AppCompatActivity implements Observer, MainViewContract { +public class MainActivity extends AppCompatActivity implements IObserver, IMainViewContract { - private MainPresenterContract presenter; + private IMainPresenterContract presenter; private ProgressDialog progressDialog; private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener = new BottomNavigationView.OnNavigationItemSelectedListener() { diff --git a/app/src/main/java/io/github/chronosx88/influence/views/fragments/ChatListFragment.java b/app/src/main/java/io/github/chronosx88/influence/views/fragments/ChatListFragment.java index 0038231..7407b8f 100644 --- a/app/src/main/java/io/github/chronosx88/influence/views/fragments/ChatListFragment.java +++ b/app/src/main/java/io/github/chronosx88/influence/views/fragments/ChatListFragment.java @@ -17,17 +17,17 @@ import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import io.github.chronosx88.influence.R; -import io.github.chronosx88.influence.contracts.chatlist.ChatListPresenterContract; -import io.github.chronosx88.influence.contracts.chatlist.ChatListViewContract; -import io.github.chronosx88.influence.contracts.observer.Observer; +import io.github.chronosx88.influence.contracts.chatlist.IChatListPresenterContract; +import io.github.chronosx88.influence.contracts.chatlist.IChatListViewContract; +import io.github.chronosx88.influence.contracts.observer.IObserver; import io.github.chronosx88.influence.helpers.AppHelper; import io.github.chronosx88.influence.helpers.ChatListAdapter; import io.github.chronosx88.influence.helpers.actions.UIActions; import io.github.chronosx88.influence.models.roomEntities.ChatEntity; import io.github.chronosx88.influence.presenters.ChatListPresenter; -public class ChatListFragment extends Fragment implements ChatListViewContract, Observer { - private ChatListPresenterContract presenter; +public class ChatListFragment extends Fragment implements IChatListViewContract, IObserver { + private IChatListPresenterContract presenter; private RecyclerView chatList; private Handler mainThreadHandler; diff --git a/app/src/main/java/io/github/chronosx88/influence/views/fragments/StartChatFragment.java b/app/src/main/java/io/github/chronosx88/influence/views/fragments/StartChatFragment.java index 0c74ab8..ff93cd1 100644 --- a/app/src/main/java/io/github/chronosx88/influence/views/fragments/StartChatFragment.java +++ b/app/src/main/java/io/github/chronosx88/influence/views/fragments/StartChatFragment.java @@ -3,7 +3,6 @@ package io.github.chronosx88.influence.views.fragments; import android.app.ProgressDialog; import android.os.Bundle; import android.os.Handler; -import android.os.Looper; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -17,10 +16,10 @@ import androidx.annotation.Nullable; import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.fragment.app.Fragment; import io.github.chronosx88.influence.R; -import io.github.chronosx88.influence.contracts.startchat.StartChatViewContract; +import io.github.chronosx88.influence.contracts.startchat.IStartChatViewContract; import io.github.chronosx88.influence.presenters.StartChatPresenter; -public class StartChatFragment extends Fragment implements StartChatViewContract { +public class StartChatFragment extends Fragment implements IStartChatViewContract { private TextInputLayout textInputPeerID; private ProgressDialog progressDialog; private Button createChatButton;