Java 类android.content.ClipboardManager.OnPrimaryClipChangedListener 实例源码

项目:RxClipboard    文件:ClipboardHtmlOnSubscribe.java   
@Override public void call(final Subscriber<? super String> subscriber) {
  final OnPrimaryClipChangedListener listener = new OnPrimaryClipChangedListener() {
    @Override public void onPrimaryClipChanged() {
      if (!subscriber.isUnsubscribed()) {
        propagate(subscriber);
      }
    }
  };
  clipboard.addPrimaryClipChangedListener(listener);

  subscriber.add(new BaseUnsubscription() {
    @Override protected void onUnsubscribe() {
      clipboard.removePrimaryClipChangedListener(listener);
    }
  });

  propagate(subscriber);
}
项目:RxClipboard    文件:ClipboardIntentOnSubscribe.java   
@Override public void call(final Subscriber<? super Intent> subscriber) {
  final OnPrimaryClipChangedListener listener = new OnPrimaryClipChangedListener() {
    @Override public void onPrimaryClipChanged() {
      if (!subscriber.isUnsubscribed()) {
        propagate(subscriber);
      }
    }
  };
  clipboard.addPrimaryClipChangedListener(listener);

  subscriber.add(new BaseUnsubscription() {
    @Override protected void onUnsubscribe() {
      clipboard.removePrimaryClipChangedListener(listener);
    }
  });

  propagate(subscriber);
}
项目:RxClipboard    文件:ClipboardClipOnSubscribe.java   
@Override public void call(final Subscriber<? super ClipData> subscriber) {
  final OnPrimaryClipChangedListener listener = new OnPrimaryClipChangedListener() {
    @Override public void onPrimaryClipChanged() {
      if (!subscriber.isUnsubscribed()) {
        propagate(subscriber);
      }
    }
  };
  clipboard.addPrimaryClipChangedListener(listener);

  subscriber.add(new BaseUnsubscription() {
    @Override protected void onUnsubscribe() {
      clipboard.removePrimaryClipChangedListener(listener);
    }
  });

  propagate(subscriber);
}
项目:RxClipboard    文件:ClipboardUriOnSubscribe.java   
@Override public void call(final Subscriber<? super Uri> subscriber) {
  final OnPrimaryClipChangedListener listener = new OnPrimaryClipChangedListener() {
    @Override public void onPrimaryClipChanged() {
      if (!subscriber.isUnsubscribed()) {
        propagate(subscriber);
      }
    }
  };
  clipboard.addPrimaryClipChangedListener(listener);

  subscriber.add(new BaseUnsubscription() {
    @Override protected void onUnsubscribe() {
      clipboard.removePrimaryClipChangedListener(listener);
    }
  });

  propagate(subscriber);
}
项目:RxClipboard    文件:ClipboardStringOnSubscribe.java   
@Override public void call(final Subscriber<? super String> subscriber) {
  final OnPrimaryClipChangedListener listener = new OnPrimaryClipChangedListener() {
    @Override public void onPrimaryClipChanged() {
      if (!subscriber.isUnsubscribed()) {
        propagate(subscriber);
      }
    }
  };
  clipboard.addPrimaryClipChangedListener(listener);

  subscriber.add(new BaseUnsubscription() {
    @Override protected void onUnsubscribe() {
      clipboard.removePrimaryClipChangedListener(listener);
    }
  });

  propagate(subscriber);
}
项目:aDictOnCopy    文件:DictionaryOnCopyService.java   
@Override
protected OnPrimaryClipChangedListener createListener() {
    return new OnPrimaryClipChangedListener() {
        public void onPrimaryClipChanged() {
            performClipboardCheck();
        }
    };
}
项目:NeoTerm    文件:Clipboard.java   
public void setListener(final Context context, final Runnable listener)
{
    ClipboardManager clipboard = (ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
    clipboard.addPrimaryClipChangedListener(new OnPrimaryClipChangedListener()
    {
        public void onPrimaryClipChanged()
        {
            listener.run();
        }
    });
}
项目:FullRobolectricTestSample    文件:ShadowClipboardManager.java   
@Implementation
public void setPrimaryClip(ClipData clip) {
  if (clip != null) {
     clip.prepareToLeaveProcess();
  }
  this.clip = clip;

  for (OnPrimaryClipChangedListener listener : listeners) {
    listener.onPrimaryClipChanged();
  }
}
项目:FullRobolectricTestSample    文件:ShadowClipboardManager.java   
@Implementation
public void addPrimaryClipChangedListener(OnPrimaryClipChangedListener listener) {
  listeners.add(listener);
}
项目:FullRobolectricTestSample    文件:ShadowClipboardManager.java   
@Implementation
public void removePrimaryClipChangedListener(OnPrimaryClipChangedListener listener) {
  listeners.remove(listener);
}