mirror of
https://github.com/ChronosX88/Influence-P2P.git
synced 2024-11-22 07:12:19 +00:00
[WIP] Started realization initPeer in MVP Arch (and added Global Message Bus)
This commit is contained in:
parent
33f4f7bedf
commit
8194b27c2e
@ -3,9 +3,6 @@
|
|||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<compositeConfiguration>
|
|
||||||
<compositeBuild compositeDefinitionSource="SCRIPT" />
|
|
||||||
</compositeConfiguration>
|
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
|
@ -3,20 +3,26 @@ package io.github.chronosx88.influence;
|
|||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
|
import io.github.chronosx88.influence.observable.MainObservable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extended Application class which designed for getting Context from anywhere in the application.
|
* Extended Application class which designed for getting Context from anywhere in the application.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class AppHelper extends Application {
|
public class AppHelper extends Application {
|
||||||
private static Application instance;
|
private static Application instance;
|
||||||
|
private static MainObservable observable;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
instance = this;
|
instance = this;
|
||||||
|
observable = new MainObservable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Context getContext() {
|
public static Context getContext() {
|
||||||
return instance.getApplicationContext();
|
return instance.getApplicationContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static MainObservable getObservable() { return observable; }
|
||||||
}
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package io.github.chronosx88.influence.contracts;
|
||||||
|
|
||||||
|
public interface MainActivityContract {
|
||||||
|
//
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package io.github.chronosx88.influence.contracts;
|
||||||
|
|
||||||
|
public interface MainActivityModelContact {
|
||||||
|
void initPeer();
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package io.github.chronosx88.influence.contracts;
|
||||||
|
|
||||||
|
public interface MainActivityPresenterContract {
|
||||||
|
void initPeer();
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package io.github.chronosx88.influence.contracts.observer;
|
||||||
|
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
public interface Observable {
|
||||||
|
void register(Observer observer);
|
||||||
|
void unregister(Observer observer);
|
||||||
|
void notifyObservers(JSONObject jsonObject);
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package io.github.chronosx88.influence.contracts.observer;
|
||||||
|
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
public interface Observer {
|
||||||
|
void handleEvent(JSONObject object);
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package io.github.chronosx88.influence.models;
|
||||||
|
|
||||||
|
import io.github.chronosx88.influence.contracts.MainActivityModelContact;
|
||||||
|
|
||||||
|
public class MainActivityModel implements MainActivityModelContact {
|
||||||
|
@Override
|
||||||
|
public void initPeer() {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package io.github.chronosx88.influence.observable;
|
||||||
|
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import io.github.chronosx88.influence.contracts.observer.Observable;
|
||||||
|
import io.github.chronosx88.influence.contracts.observer.Observer;
|
||||||
|
|
||||||
|
public class MainObservable implements Observable {
|
||||||
|
private ArrayList<Observer> observers;
|
||||||
|
|
||||||
|
public MainObservable() {
|
||||||
|
this.observers = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void register(Observer observer) {
|
||||||
|
observers.add(observer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unregister(Observer observer) {
|
||||||
|
observers.remove(observer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void notifyObservers(JSONObject jsonObject) {
|
||||||
|
for (Observer observer : observers) {
|
||||||
|
observer.handleEvent(jsonObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package io.github.chronosx88.influence.presenters;
|
||||||
|
|
||||||
|
import io.github.chronosx88.influence.contracts.MainActivityPresenterContract;
|
||||||
|
|
||||||
|
public class MainActivityPresenter implements MainActivityPresenterContract {
|
||||||
|
@Override
|
||||||
|
public void initPeer() {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
}
|
@ -7,5 +7,28 @@
|
|||||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||||
<item name="colorAccent">@color/colorAccent</item>
|
<item name="colorAccent">@color/colorAccent</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="AlertDialogTheme" parent="Base.Theme.AppCompat.Dialog">
|
||||||
|
<item name="alertDialogStyle">@style/CustomAlertStyle</item>
|
||||||
|
<item name="android:windowBackground">@android:color/transparent</item>
|
||||||
|
<item name="android:textColorPrimary">#FFFFFF</item>
|
||||||
|
<item name="android:backgroundDimEnabled">false</item>
|
||||||
|
<item name="android:textColor">#FFFFFF</item>
|
||||||
|
<item name="android:textStyle">normal</item>
|
||||||
|
<item name="android:textSize">12sp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="CustomAlertStyle">
|
||||||
|
<item name="android:bottomBright">@android:color/transparent</item>
|
||||||
|
<item name="android:bottomDark">@android:color/transparent</item>
|
||||||
|
<item name="android:bottomMedium">@android:color/transparent</item>
|
||||||
|
<item name="android:centerBright">@android:color/transparent</item>
|
||||||
|
<item name="android:centerDark">@android:color/transparent</item>
|
||||||
|
<item name="android:centerMedium">@android:color/transparent</item>
|
||||||
|
<item name="android:fullBright">@android:color/transparent</item>
|
||||||
|
<item name="android:fullDark">@android:color/transparent</item>
|
||||||
|
<item name="android:topBright">@android:color/transparent</item>
|
||||||
|
<item name="android:topDark">@android:color/transparent</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user