パルカワ2

最近はFlutterをやっています

履歴から自分のツイートを検索してヒットしたツイートを消す

自分のツイートの全履歴は、twitterからダウンロード出来る。

 ag 黒歴史  | perl -p  -e 's/tweets.csv:\d+:\"(\d+)\",\".*/$1/g;' | xargs ruby delete.rb
require "twitter"

client = Twitter::REST::Client.new do |config|
  config.consumer_key        = "..."
  config.consumer_secret     = "..."
  config.access_token        = "..."
  config.access_token_secret = "..."
end


ARGV.each do |id|
  begin
    p id
    client.destroy_status(id)
  rescue Twitter::Error::NotFound => e
    p e
  end
end

古のツイートとか消せるので便利

RxLifecycleとPresenter

Presenterにどう渡すべきか?と思ってたけど、lifecycleオブジェクトを渡せばいいだけだった。

// Activity
new HogePresenter(this, lifecycle())

// Presenter
class HogePresenter {
  public HogePresenter(HogeViewCallback viewCallback, Observable<ActivityEvent> lifecycle) {
    this.viewCallback = viewCallback;
    this.lifecycle = lifecycle;
  }
  
  public void onCreate() {
    ...
    .compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTORY))
    ...
  }
}

RxLifeCycle試してる

Single.just(10)
    .doOnDispose(() -> Log.i("TEST", "dispose"))
    compose(bindUntilEvent(ActivityEvent.CREATE))
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe(
        i -> Log.i("TEST", String.valueOf(i)),
        throwable -> Log.i("TEST", throwable.toString()));

Single と Completable のときは、 onErrorにCancellationExceptionがくる。

Observable.interval(1, TimeUnit.SECONDS)
    .doOnDispose(() -> Log.i("TEST", "dispose"))
    .compose(bindUntilEvent(ActivityEvent.CREATE))
    .observeOn(AndroidSchedulers.mainThread())
    .doOnComplete(() -> Log.i("TEST", "onComplete"))
    .subscribe(
        i -> Log.i("TEST", String.valueOf(i)),
        throwable -> Log.i("TEST", throwable.toString()),
        () -> Log.i("TEST", "onComplete"));

ObservableとFlowableとMaybeは、onComplete()が実行されるとのこと。

Unsubscription RxLifecycle does not actually unsubscribe the sequence. Instead it terminates the sequence. The way in which it does so varies based on the type: Observable, Flowable and Maybe - emits onCompleted() Single and Completable - emits onError(CancellationException) If a sequence requires the Subscription.unsubscribe() behavior, then it is suggested that you manually handle the Subscription yourself and call unsubscribe() when appropriate.

RxLifeCycleのREADME

実際の処理はPresenterがやるので、bindUntilEvent(ActivityEvent.CREATE) をPresenterに渡す必要があるけど、どうPresenterに渡すのか?? あたりがこれだ!というのが自分の中にない。

YAPC::Fukuoka 2017 HAKATA 行ってきた

ホテル1日分しか取らなくて、別のホテル改めて取ったりとかしたけど、良かった。



ペパボ福岡支社、仕事しやすそうで良かった。







激ウマだった。
tabelog.com





反省です。

温泉入って帰った。
運営のみなさん、お疲れ様でした。沖縄も行きたい。