Merge pull request #140 from OHermesJunior/eventbus-index

Enable EventBus Index, avoids reflection, and better performance.
This commit is contained in:
Docile-Alligator
2020-06-22 23:41:20 +08:00
committed by GitHub
2 changed files with 12 additions and 1 deletions

View File

@@ -17,6 +17,7 @@ import org.greenrobot.eventbus.EventBus;
import ml.docilealligator.infinityforreddit.BroadcastReceiver.NetworkWifiStatusReceiver;
import ml.docilealligator.infinityforreddit.Event.ChangeWifiStatusEvent;
import ml.docilealligator.infinityforreddit.Utils.Utils;
import ml.docilealligator.inifinityforreddit.EventBusIndex;
public class Infinity extends Application {
private AppComponent mAppComponent;
@@ -42,6 +43,8 @@ public class Infinity extends Application {
}
});
EventBus.builder().addIndex(new EventBusIndex()).installDefaultEventBus();
mNetworkWifiStatusReceiver =
new NetworkWifiStatusReceiver(() -> EventBus.getDefault().post(new ChangeWifiStatusEvent(Utils.isConnectedToWifi(getApplicationContext()))));
registerReceiver(mNetworkWifiStatusReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));