public void onContactsChanged(Integer[] contacts) {
   int[] res = new int[contacts.length];
   for (int i = 0; i < res.length; i++) {
     res[i] = contacts[i];
   }
   actorRef.send(new SearchActor.OnContactsUpdated(res));
 }
示例#2
0
 private void reportComplete(FileReference location, FileSystemReference reference) {
   if (isCompleted) {
     return;
   }
   isCompleted = true;
   manager.send(new UploadManager.UploadTaskComplete(rid, location, reference));
 }
示例#3
0
 private void reportError() {
   if (LOG) {
     Log.d(TAG, "Reporting error");
   }
   if (isCompleted) {
     return;
   }
   isCompleted = true;
   manager.send(new UploadManager.UploadTaskError(rid));
 }
 private void changeValue(String key, String val) {
   String s = readValue(key);
   if (s == null && val == null) {
     return;
   }
   if (s != null && val != null && s.equals(val)) {
     return;
   }
   settingsSync.send(new SettingsSyncActor.ChangeSettings(key, val));
   onUpdatedSetting(key, val);
 }
 public void removeAvatar() {
   avatarChangeActor.send(new OwnAvatarChangeActor.RemoveAvatar());
 }
 public void changeAvatar(String descriptor) {
   avatarChangeActor.send(new OwnAvatarChangeActor.ChangeAvatar(descriptor));
 }
 public void onVisible() {
   idleActor.send(new IdleActor.OnVisible());
 }
 public void onHidden() {
   idleActor.send(new IdleActor.OnHidden());
 }
示例#9
0
 private void performReportProgress() {
   if (isCompleted) {
     return;
   }
   manager.send(new UploadManager.UploadTaskProgress(rid, currentProgress));
 }
示例#10
0
 public void onDialogsChanged(List<Dialog> dialogs) {
   actorRef.send(new SearchActor.OnDialogsUpdated(dialogs));
 }
示例#11
0
 public void resetModule() {
   actorRef.send(new SearchActor.Clear());
 }
  public AndroidMessenger(Context context, im.actor.core.Configuration configuration) {
    super(configuration);

    this.context = context;

    this.appStateActor =
        system()
            .actorOf(
                Props.create(
                    new ActorCreator() {
                      @Override
                      public AppStateActor create() {
                        return new AppStateActor(AndroidMessenger.this);
                      }
                    }),
                "actor/android/state");

    // Catch all phone book changes
    context
        .getContentResolver()
        .registerContentObserver(
            ContactsContract.Contacts.CONTENT_URI,
            true,
            new ContentObserver(null) {
              @Override
              public void onChange(boolean selfChange) {
                onPhoneBookChanged();
              }
            });

    // Catch network change
    context.registerReceiver(
        new BroadcastReceiver() {
          @Override
          public void onReceive(Context context, Intent intent) {
            ConnectivityManager cm =
                (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);

            NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
            boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting();

            NetworkState state;
            if (isConnected) {
              switch (activeNetwork.getType()) {
                case ConnectivityManager.TYPE_WIFI:
                case ConnectivityManager.TYPE_WIMAX:
                case ConnectivityManager.TYPE_ETHERNET:
                  state = NetworkState.WI_FI;
                  break;
                case ConnectivityManager.TYPE_MOBILE:
                  state = NetworkState.MOBILE;
                  break;
                default:
                  state = NetworkState.UNKNOWN;
              }
            } else {
              state = NetworkState.NO_CONNECTION;
            }
            onNetworkChanged(state);
          }
        },
        new IntentFilter(android.net.ConnectivityManager.CONNECTIVITY_ACTION));

    // Screen change processor
    IntentFilter screenFilter = new IntentFilter();
    screenFilter.addAction(Intent.ACTION_SCREEN_OFF);
    screenFilter.addAction(Intent.ACTION_SCREEN_ON);
    context.registerReceiver(
        new BroadcastReceiver() {
          @Override
          public void onReceive(Context context, Intent intent) {
            if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
              appStateActor.send(new AppStateActor.OnScreenOn());
            } else if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
              appStateActor.send(new AppStateActor.OnScreenOff());
            }
          }
        },
        screenFilter);
    if (isScreenOn()) {
      appStateActor.send(new AppStateActor.OnScreenOn());
    } else {
      appStateActor.send(new AppStateActor.OnScreenOff());
    }

    modules
        .getAppStateModule()
        .getAppStateVM()
        .getGlobalCounter()
        .subscribe(
            new ValueChangedListener<Integer>() {
              @Override
              public void onChanged(Integer val, Value<Integer> valueModel) {
                ShortcutBadger.with(AndroidContext.getContext()).count(val);
              }
            });
    //        modules.getAppStateModule().getAppStateVM().getGlobalCounter().subscribe(new
    // ValueChangedListener<Integer>() {
    //            @Override
    //            public void onChanged(Integer val, ValueModel<Integer> valueModel) {
    //                ShortcutBadger.with(AndroidContext.getContext()).count(val);
    //            }
    //        });
  }
 public void onActivityClosed() {
   appStateActor.send(new AppStateActor.OnActivityClosed());
 }
 public void onActivityOpen() {
   appStateActor.send(new AppStateActor.OnActivityOpened());
 }