當前位置: 首頁>>代碼示例>>Java>>正文


Java Subscribe類代碼示例

本文整理匯總了Java中com.squareup.otto.Subscribe的典型用法代碼示例。如果您正苦於以下問題:Java Subscribe類的具體用法?Java Subscribe怎麽用?Java Subscribe使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Subscribe類屬於com.squareup.otto包,在下文中一共展示了Subscribe類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onGetInactivePhotos

import com.squareup.otto.Subscribe; //導入依賴的package包/類
@Subscribe
public void onGetInactivePhotos(OnGetInactivePhotosEvent event) {
    handler.post(new Runnable() {
        @Override
        public void run() {
            List<MyPhoto> list = new ArrayList<>();
            if (event != null) {
                for (Photo p : event.photos) {
                    MyPhoto photo = new MyPhoto(p);
                    list.add(photo);
                }
                adapter.setData(list);
                adapter.notifyDataSetChanged();
            }
        }
    });
}
 
開發者ID:aliyun,項目名稱:aliyun-cloudphotos-android-demo,代碼行數:18,代碼來源:InactivePhotosActivity.java

示例2: onWSTrafficEvent

import com.squareup.otto.Subscribe; //導入依賴的package包/類
@Subscribe
public void onWSTrafficEvent(WSConnectionManager.WSTrafficEvent event) {

    boolean shouldRefresh = false;
    if (event.isSlowConnection()) {
        if (isWSTrafficSlow.compareAndSet(false, true)) {
            shouldRefresh = true;
            showToast("Bad Connection: " + event.getMessage() + "!");
        }
    } else {
        if (isWSTrafficSlow.compareAndSet(true, false)) {
            shouldRefresh = true;
        }
    }
    if (shouldRefresh) {
        refresh();
    }
}
 
開發者ID:dji-sdk,項目名稱:Android-Bridge-App,代碼行數:19,代碼來源:BridgeActivity.java

示例3: onOauthResult

import com.squareup.otto.Subscribe; //導入依賴的package包/類
@Subscribe
public void onOauthResult(SSOBusEvent event) {
    switch (event.getType()) {
        case SSOBusEvent.TYPE_GET_TOKEN:
            SocialToken token = event.getToken();
            Log.i(TAG, "onOauthResult#BusEvent.TYPE_GET_TOKEN " + token.toString());
            break;
        case SSOBusEvent.TYPE_GET_USER:
            SocialUser user = event.getUser();
            Log.i(TAG, "onOauthResult#BusEvent.TYPE_GET_USER " + user.toString());
            Toast.makeText(SsoAllActivity.this, "ShareBusEvent.TYPE_GET_USER \n\r" + user.toString(), Toast.LENGTH_SHORT).show();
            break;
        case SSOBusEvent.TYPE_FAILURE:
            Exception e = event.getException();
            Log.i(TAG, "onOauthResult#BusEvent.TYPE_FAILURE " + e.toString());
            break;
        case SSOBusEvent.TYPE_CANCEL:
            Log.i(TAG, "onOauthResult#BusEvent.TYPE_CANCEL");
            break;
    }
}
 
開發者ID:yangjie127,項目名稱:ESSocialSDK-master,代碼行數:22,代碼來源:SsoAllActivity.java

示例4: onOauthResult

import com.squareup.otto.Subscribe; //導入依賴的package包/類
@Subscribe
public void onOauthResult(SSOBusEvent event) {
    switch (event.getType()) {
        case SSOBusEvent.TYPE_GET_TOKEN:
            SocialToken token = event.getToken();
            Log.i(TAG, "onOauthResult#BusEvent.TYPE_GET_TOKEN " + token.toString());
            break;
        case SSOBusEvent.TYPE_GET_USER:
            SocialUser user = event.getUser();
            Log.i(TAG, "onOauthResult#BusEvent.TYPE_GET_USER " + user.toString());
            break;
        case SSOBusEvent.TYPE_FAILURE:
            Exception e = event.getException();
            Log.i(TAG, "onOauthResult#BusEvent.TYPE_FAILURE " + e.toString());
            break;
        case SSOBusEvent.TYPE_CANCEL:
            Log.i(TAG, "onOauthResult#BusEvent.TYPE_CANCEL");
            break;
    }
}
 
開發者ID:yangjie127,項目名稱:ESSocialSDK-master,代碼行數:21,代碼來源:SsoActivity.java

示例5: onPokemonListReceived

import com.squareup.otto.Subscribe; //導入依賴的package包/類
@Subscribe
public void onPokemonListReceived(PokemonList pokemonList) {
    /*
      Both GetPokemonListUseCase invocations end here, either we requested the first page
      or every next page
     */
    if (totalPokemon == 0) {
        // First time hide the screen loading
        screen.hideLoading();
    } else {
        // Every next time we remove the bottom list loading progress
        loadingNewPage = false;
        screen.hideListLoading();
    }

    // Adding the fetched data to the RecyclerView
    screen.addToPokemonList(pokemonList.getPokemonList());

    // We need these variables for infinite scrolling
    lastPageSize = pokemonList.getPageSize();
    totalPokemon += lastPageSize;
    nextPageLink = pokemonList.getNextLink();
}
 
開發者ID:micbakos,項目名稱:Pokemon-Clean-Architecture-Example,代碼行數:24,代碼來源:PokemonListPresenter.java

示例6: onPokemonListError

import com.squareup.otto.Subscribe; //導入依賴的package包/類
@Subscribe
public void onPokemonListError(PokemonListError error) {
    // Both GetPokemonListUseCase invocations end here

    // Hiding the appropriate loading progress
    if (totalPokemon == 0) {
        screen.hideLoading();
        screen.showNoInternetPanel();
    } else {
        loadingNewPage = false;
        screen.hideListLoading();

        // Showing the appropriate dialog
        if (error.isNetworkError()) {
            screen.showNoInternetError();
        } else {
            screen.showError(error);
        }
    }
}
 
開發者ID:micbakos,項目名稱:Pokemon-Clean-Architecture-Example,代碼行數:21,代碼來源:PokemonListPresenter.java

示例7: setSubscriber

import com.squareup.otto.Subscribe; //導入依賴的package包/類
@Override
protected Object setSubscriber() {
    return new Object() {
        @Subscribe
        public void onPokemonListReceived(PokemonList pokemonList) {
            // Just post back the response and unregister the listener
            post(pokemonList);
            unregisterUseCaseSubscriber();
        }

        @Subscribe
        public void onPokemonListError(PokemonListError error) {
            // Just post back the error and unregister the listener
            post(error);
            unregisterUseCaseSubscriber();
        }
    };
}
 
開發者ID:micbakos,項目名稱:Pokemon-Clean-Architecture-Example,代碼行數:19,代碼來源:GetPokemonListUseCase.java

示例8: setSubscriber

import com.squareup.otto.Subscribe; //導入依賴的package包/類
@Override
protected Object setSubscriber() {
    return new Object() {
        @Subscribe
        public void onPokemonDetailsReceived(PokemonDetails details) {
            // Save the data to the cache
            dataCache.addPokemonDetails(details);
            // Post it back to the PokemonDetailsPresenter
            post(details);
            // No need for the subscriber anymore
            unregisterUseCaseSubscriber();
        }

        @Subscribe
        public void onPokemonDetailsError(PokemonDetailsError error) {
            // Post the error back to the PokemonDetailsPresenter
            post(error);
            // No need for the subscriber anymore
            unregisterUseCaseSubscriber();
        }
    };
}
 
開發者ID:micbakos,項目名稱:Pokemon-Clean-Architecture-Example,代碼行數:23,代碼來源:GetPokemonDetailsUseCase.java

示例9: onDeletePostEvent

import com.squareup.otto.Subscribe; //導入依賴的package包/類
@Subscribe
public void onDeletePostEvent(DeletePostEvent event) {
    String postId = event.post.getId();
    Log.i(TAG, "[onDeletePostEvent] post id = %s", postId);

    Post realmPost = mRealm.where(Post.class).equalTo("id", postId).findFirst();
    if (realmPost == null) {
        RuntimeException e = new IllegalArgumentException("Trying to delete post with non-existent id = " + postId);
        Log.exception(e);
    } else if (realmPost.hasPendingAction(PendingAction.CREATE)) {
        deleteModel(realmPost);
        getBus().post(new PostDeletedEvent(postId));
    } else {
        // don't delete locally until the remote copy is deleted
        clearAndSetPendingActionOnPost(realmPost, PendingAction.DELETE);
        getBus().post(new PostDeletedEvent(postId));

        // DON'T trigger a sync here, because it is automatically triggered by the post list anyway
        // triggering it twice causes crashes due to invalid Realm objects (deleted twice)
        //getBus().post(new SyncPostsEvent(false));
    }
}
 
開發者ID:TryGhost,項目名稱:Ghost-Android,代碼行數:23,代碼來源:NetworkService.java

示例10: onFileUploadErrorEvent

import com.squareup.otto.Subscribe; //導入依賴的package包/類
@Subscribe
public void onFileUploadErrorEvent(FileUploadErrorEvent event) {
    if (event.apiFailure.error != null) {
        Log.exception(new FileUploadFailedException(event.apiFailure.error));
    } else if (event.apiFailure.response != null) {
        try {
            String responseStr = event.apiFailure.response.errorBody().string();
            Log.exception(new FileUploadFailedException(responseStr));
        } catch (IOException e) {
            Log.exception(new Exception("Error while recording file upload exception, " +
                    "see previous exception for details", e));
        }
    }
    Toast.makeText(mActivity, R.string.image_upload_failed, Toast.LENGTH_SHORT).show();
    // the activity could have been destroyed and re-created
    if (mUploadProgress != null) {
        mUploadProgress.dismiss();
        mUploadProgress = null;
    }
    mImageUploadDoneAction = null;
    mMarkdownEditSelectionState = null;
}
 
開發者ID:TryGhost,項目名稱:Ghost-Android,代碼行數:23,代碼來源:PostEditFragment.java

示例11: onUserLoadedEvent

import com.squareup.otto.Subscribe; //導入依賴的package包/類
@Subscribe
public void onUserLoadedEvent(UserLoadedEvent event) {
    if (event.user.getProfileImage() != null) {
        if (event.user.getProfileImage().isEmpty()) {
            return;
        }
        String blogUrl = AccountManager.getActiveBlogUrl();
        String imageUrl = NetworkUtils.makeAbsoluteUrl(blogUrl, event.user.getProfileImage());
        getPicasso()
                .load(imageUrl)
                .transform(new BorderedCircleTransformation())
                .fit()
                .into(mUserImageView);
    } else {
        // Crashlytics issue #77
        Log.w(TAG, "user image is null!");
    }
}
 
開發者ID:TryGhost,項目名稱:Ghost-Android,代碼行數:19,代碼來源:PostListActivity.java

示例12: onPostsLoadedEvent

import com.squareup.otto.Subscribe; //導入依賴的package包/類
@Subscribe
public void onPostsLoadedEvent(PostsLoadedEvent event) {
    // this exists to let animation run to completion because posts are loaded
    // twice on launch: once cached data, and once from the network
    if (mPosts.equals(event.posts)) {
        return;
    }
    mPosts.clear();
    mPosts.addAll(event.posts);
    if (mPosts.size() >= event.postsFetchLimit) {
        CharSequence message = Html.fromHtml(getString(R.string.post_limit_exceeded,
                getString(R.string.app_name), event.postsFetchLimit,
                "https://github.com/vickychijwani/quill/issues/81"));
        mPostAdapter.showFooter(message);
    } else {
        mPostAdapter.hideFooter();
    }
    mPostAdapter.notifyDataSetChanged();
}
 
開發者ID:TryGhost,項目名稱:Ghost-Android,代碼行數:20,代碼來源:PostListActivity.java

示例13: onLogoutStatusEvent

import com.squareup.otto.Subscribe; //導入依賴的package包/類
@Subscribe
public void onLogoutStatusEvent(LogoutStatusEvent event) {
    if (!event.succeeded && event.hasPendingActions) {
        final AlertDialog alertDialog = new AlertDialog.Builder(this)
                .setMessage(getString(R.string.unsynced_changes_msg))
                .setPositiveButton(R.string.dont_logout, (dialog, which) -> {
                    dialog.dismiss();
                })
                .setNegativeButton(R.string.logout, (dialog, which) -> {
                    dialog.dismiss();
                    getBus().post(new LogoutEvent(AccountManager.getActiveBlogUrl(), true));
                })
                .create();
        alertDialog.show();
    } else {
        finish();
        Intent logoutIntent = new Intent(this, LoginActivity.class);
        startActivity(logoutIntent);
    }
}
 
開發者ID:TryGhost,項目名稱:Ghost-Android,代碼行數:21,代碼來源:PostListActivity.java

示例14: onPostSyncedEvent

import com.squareup.otto.Subscribe; //導入依賴的package包/類
@Subscribe
public void onPostSyncedEvent(PostSyncedEvent event) {
    if (event.post != null && event.post.getId().equals(mPost.getId())) {
        // Use the synced post, as the server could have modified it (e.g., if the slug clashes).
        // Since syncing happens *asynchronously* (relative to the time the SavePostEvent was
        // fired), using unsafeUpdatePost() WILL overwrite the user's edits! So, update the
        // existing post with whatever properties *could* have been updated by the server *and*
        // are NOT user-modifiable. The change will automatically propagate to the editor and
        // other fragments because they share the object reference directly.
        mPost.setSlug(event.post.getSlug());

        if (mbPreviewPost) {
            mHandler.removeCallbacks(mSaveTimeoutRunnable);
            startBrowserActivity(PostUtils.getPostUrl(mPost));
            if (mProgressDialog != null) {
                mProgressDialog.dismiss();
            }
            mbPreviewPost = false;
        }
    }
}
 
開發者ID:TryGhost,項目名稱:Ghost-Android,代碼行數:22,代碼來源:PostViewActivity.java

示例15: postCommentLike

import com.squareup.otto.Subscribe; //導入依賴的package包/類
@Subscribe
public void postCommentLike(Account.sendCommentLike sendReply) throws Exception {

    application.getWebService()
            .sendCommentLike(sendReply.id_post_comment, MySharedPreferences.getUserId(preferences), "1",MySharedPreferences.getUserId(preferences),  MySharedPreferences.getUserToken(preferences), sendReply.id_post_comment)
            .observeOn(AndroidSchedulers.mainThread())
            .retryWhen(new RetryWithDelay(3,2000))
            .subscribe(new BaseSubscriber<SuccessResponse>() {
                @Override
                public void onNext(SuccessResponse userResponse) {


                    // Send notification to user with id_user_name ID
                  //  Toast.makeText(PostsDetailsActivity.this, "success comment like", Toast.LENGTH_SHORT).show();

                }
                @Override
                public void onError(Throwable e) {
                    Crashlytics.logException(e);

                }
            });
}
 
開發者ID:sciage,項目名稱:FinalProject,代碼行數:24,代碼來源:PostsDetailsActivity.java


注:本文中的com.squareup.otto.Subscribe類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。