Search in sources :

Example 6 with RetrofitBucket

use of com.nextcloud.talk.models.RetrofitBucket in project talk-android by nextcloud.

the class ApiUtils method getRetrofitBucketForContactsSearch.

public static RetrofitBucket getRetrofitBucketForContactsSearch(String baseUrl, String searchQuery) {
    RetrofitBucket retrofitBucket = new RetrofitBucket();
    retrofitBucket.setUrl(baseUrl + ocsApiVersion + "/apps/files_sharing/api/v1/sharees");
    Map<String, String> queryMap = new HashMap<>();
    queryMap.put("format", "json");
    queryMap.put("search", searchQuery);
    queryMap.put("perPage", "200");
    queryMap.put("itemType", "call");
    retrofitBucket.setQueryMap(queryMap);
    return retrofitBucket;
}
Also used : RetrofitBucket(com.nextcloud.talk.models.RetrofitBucket) HashMap(java.util.HashMap)

Example 7 with RetrofitBucket

use of com.nextcloud.talk.models.RetrofitBucket in project talk-android by nextcloud.

the class ContactsController method onItemClick.

@Override
public boolean onItemClick(View view, int position) {
    if (adapter.getItem(position) instanceof UserItem) {
        if (!isNewConversationView) {
            UserItem userItem = (UserItem) adapter.getItem(position);
            RetrofitBucket retrofitBucket = ApiUtils.getRetrofitBucketForCreateRoom(userEntity.getBaseUrl(), "1", userItem.getModel().getUserId(), null);
            ncApi.createRoom(ApiUtils.getCredentials(userEntity.getUsername(), userEntity.getToken()), retrofitBucket.getUrl(), retrofitBucket.getQueryMap()).subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<RoomOverall>() {

                @Override
                public void onSubscribe(Disposable d) {
                }

                @Override
                public void onNext(RoomOverall roomOverall) {
                    if (getActivity() != null) {
                        Intent callIntent = new Intent(getActivity(), CallActivity.class);
                        Bundle bundle = new Bundle();
                        bundle.putString(BundleKeys.KEY_ROOM_TOKEN, roomOverall.getOcs().getData().getToken());
                        bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, Parcels.wrap(userEntity));
                        callIntent.putExtras(bundle);
                        startActivity(callIntent);
                    }
                }

                @Override
                public void onError(Throwable e) {
                }

                @Override
                public void onComplete() {
                }
            });
        } else {
            ((UserItem) adapter.getItem(position)).flipItemSelection();
            adapter.toggleSelection(position);
            checkAndHandleBottomButtons();
        }
    } else if (adapter.getItem(position) instanceof NewCallHeaderItem) {
        adapter.toggleSelection(position);
        isPublicCall = adapter.isSelected(position);
        ((NewCallHeaderItem) adapter.getItem(position)).togglePublicCall(isPublicCall);
        checkAndHandleBottomButtons();
    }
    return true;
}
Also used : RoomOverall(com.nextcloud.talk.models.json.rooms.RoomOverall) Disposable(io.reactivex.disposables.Disposable) RetrofitBucket(com.nextcloud.talk.models.RetrofitBucket) Bundle(android.os.Bundle) NewCallHeaderItem(com.nextcloud.talk.adapters.items.NewCallHeaderItem) Intent(android.content.Intent) CallActivity(com.nextcloud.talk.activities.CallActivity) UserItem(com.nextcloud.talk.adapters.items.UserItem)

Example 8 with RetrofitBucket

use of com.nextcloud.talk.models.RetrofitBucket in project talk-android by nextcloud.

the class ApiUtils method getRetrofitBucketForCreateRoom.

public static RetrofitBucket getRetrofitBucketForCreateRoom(String baseUrl, String roomType, @Nullable String invite, @Nullable String conversationName) {
    RetrofitBucket retrofitBucket = new RetrofitBucket();
    retrofitBucket.setUrl(baseUrl + ocsApiVersion + spreedApiVersion + "/room");
    Map<String, String> queryMap = new HashMap<>();
    queryMap.put("roomType", roomType);
    if (invite != null) {
        queryMap.put("invite", invite);
    }
    if (conversationName != null) {
        queryMap.put("roomName", conversationName);
    }
    retrofitBucket.setQueryMap(queryMap);
    return retrofitBucket;
}
Also used : RetrofitBucket(com.nextcloud.talk.models.RetrofitBucket) HashMap(java.util.HashMap)

Aggregations

RetrofitBucket (com.nextcloud.talk.models.RetrofitBucket)8 Disposable (io.reactivex.disposables.Disposable)5 RoomOverall (com.nextcloud.talk.models.json.rooms.RoomOverall)4 HashMap (java.util.HashMap)4 Intent (android.content.Intent)3 Bundle (android.os.Bundle)3 CallActivity (com.nextcloud.talk.activities.CallActivity)3 UserItem (com.nextcloud.talk.adapters.items.UserItem)3 Handler (android.os.Handler)2 OnClick (butterknife.OnClick)2 Optional (butterknife.Optional)2 HorizontalChangeHandler (com.bluelinelabs.conductor.changehandler.HorizontalChangeHandler)2 VerticalChangeHandler (com.bluelinelabs.conductor.changehandler.VerticalChangeHandler)2 Room (com.nextcloud.talk.models.json.rooms.Room)2 ArrayList (java.util.ArrayList)2 SearchManager (android.app.SearchManager)1 Context (android.content.Context)1 NonNull (android.support.annotation.NonNull)1 Nullable (android.support.annotation.Nullable)1 BottomNavigationView (android.support.design.widget.BottomNavigationView)1