Search in sources :

Example 1 with MethodCallHelper

use of chat.rocket.android.api.MethodCallHelper in project Rocket.Chat.Android by RocketChat.

the class SidebarMainFragment method onCreate.

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle args = getArguments();
    hostname = args == null ? null : args.getString(HOSTNAME);
    methodCallHelper = new MethodCallHelper(getContext(), hostname);
    realmSpotlightRoomRepository = new RealmSpotlightRoomRepository(hostname);
    RealmUserRepository userRepository = new RealmUserRepository(hostname);
    AbsoluteUrlHelper absoluteUrlHelper = new AbsoluteUrlHelper(hostname, new RealmServerInfoRepository(), userRepository, new SessionInteractor(new RealmSessionRepository(hostname)));
    presenter = new SidebarMainPresenter(hostname, new RoomInteractor(new RealmRoomRepository(hostname)), userRepository, new RocketChatCache(getContext()), absoluteUrlHelper, TextUtils.isEmpty(hostname) ? null : new MethodCallHelper(getContext(), hostname));
}
Also used : SessionInteractor(chat.rocket.core.interactors.SessionInteractor) MethodCallHelper(chat.rocket.android.api.MethodCallHelper) RealmSpotlightRoomRepository(chat.rocket.persistence.realm.repositories.RealmSpotlightRoomRepository) AbsoluteUrlHelper(chat.rocket.android.helper.AbsoluteUrlHelper) RealmSessionRepository(chat.rocket.persistence.realm.repositories.RealmSessionRepository) RoomInteractor(chat.rocket.core.interactors.RoomInteractor) Bundle(android.os.Bundle) RocketChatCache(chat.rocket.android.RocketChatCache) RealmRoomRepository(chat.rocket.persistence.realm.repositories.RealmRoomRepository) RealmServerInfoRepository(chat.rocket.persistence.realm.repositories.RealmServerInfoRepository) RealmUserRepository(chat.rocket.persistence.realm.repositories.RealmUserRepository)

Example 2 with MethodCallHelper

use of chat.rocket.android.api.MethodCallHelper in project Rocket.Chat.Android by RocketChat.

the class AbstractAddRoomDialogFragment method handleArgs.

protected void handleArgs(@NonNull Bundle args) {
    hostname = args.getString("hostname");
    realmHelper = RealmStore.get(hostname);
    methodCall = new MethodCallHelper(getContext(), hostname);
}
Also used : MethodCallHelper(chat.rocket.android.api.MethodCallHelper)

Example 3 with MethodCallHelper

use of chat.rocket.android.api.MethodCallHelper in project Rocket.Chat.Android by RocketChat.

the class TwoStepAuthFragment method onCreate.

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle args = getArguments();
    if (args == null || !args.containsKey(ARG_USERNAME_OR_EMAIL) || !args.containsKey(ARG_PASSWORD)) {
        finish();
        return;
    }
    presenter = new TwoStepAuthPresenter(new MethodCallHelper(getContext(), hostname), args.getString(ARG_USERNAME_OR_EMAIL), args.getString(ARG_PASSWORD));
}
Also used : MethodCallHelper(chat.rocket.android.api.MethodCallHelper) Bundle(android.os.Bundle)

Example 4 with MethodCallHelper

use of chat.rocket.android.api.MethodCallHelper in project Rocket.Chat.Android by RocketChat.

the class UserRegistrationDialogFragment method createDialogView.

private View createDialogView() {
    View dialog = LayoutInflater.from(getContext()).inflate(R.layout.dialog_user_registration, null, false);
    final TextView txtUsername = (TextView) dialog.findViewById(R.id.editor_username);
    final TextView txtEmail = (TextView) dialog.findViewById(R.id.editor_email);
    final TextView txtPasswd = (TextView) dialog.findViewById(R.id.editor_passwd);
    if (!TextUtils.isEmpty(username)) {
        txtUsername.setText(username);
    }
    if (!TextUtils.isEmpty(email)) {
        txtEmail.setText(email);
    }
    if (!TextUtils.isEmpty(password)) {
        txtPasswd.setText(password);
    }
    final View waitingView = dialog.findViewById(R.id.waiting);
    waitingView.setVisibility(View.GONE);
    dialog.findViewById(R.id.btn_register_user).setOnClickListener(view -> {
        view.setEnabled(false);
        waitingView.setVisibility(View.VISIBLE);
        username = txtUsername.getText().toString();
        email = txtEmail.getText().toString();
        password = txtPasswd.getText().toString();
        MethodCallHelper methodCallHelper = new MethodCallHelper(getContext(), hostname);
        methodCallHelper.registerUser(username, email, password, password).onSuccessTask(task -> methodCallHelper.loginWithEmail(email, password)).onSuccessTask(task -> methodCallHelper.setUsername(username)).onSuccessTask(task -> methodCallHelper.joinDefaultChannels()).onSuccessTask(task -> {
            dismiss();
            return task;
        }).continueWith(task -> {
            if (task.isFaulted()) {
                Exception exception = task.getError();
                showError(exception.getMessage());
                view.setEnabled(true);
                waitingView.setVisibility(View.GONE);
            }
            return null;
        });
    });
    return dialog;
}
Also used : Bundle(android.os.Bundle) LayoutInflater(android.view.LayoutInflater) Dialog(android.app.Dialog) NonNull(android.support.annotation.NonNull) DialogFragment(android.support.v4.app.DialogFragment) MethodCallHelper(chat.rocket.android.api.MethodCallHelper) AlertDialog(android.support.v7.app.AlertDialog) Patterns(android.util.Patterns) TextView(android.widget.TextView) Toast(android.widget.Toast) View(android.view.View) Nullable(android.support.annotation.Nullable) R(chat.rocket.android.R) TextUtils(chat.rocket.android.helper.TextUtils) MethodCallHelper(chat.rocket.android.api.MethodCallHelper) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View)

Example 5 with MethodCallHelper

use of chat.rocket.android.api.MethodCallHelper in project Rocket.Chat.Android by RocketChat.

the class RetryLoginFragment method onCreate.

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    presenter = new RetryLoginPresenter(new SessionInteractor(new RealmSessionRepository(hostname)), new MethodCallHelper(getContext(), hostname));
}
Also used : SessionInteractor(chat.rocket.core.interactors.SessionInteractor) MethodCallHelper(chat.rocket.android.api.MethodCallHelper) RealmSessionRepository(chat.rocket.persistence.realm.repositories.RealmSessionRepository)

Aggregations

MethodCallHelper (chat.rocket.android.api.MethodCallHelper)8 Bundle (android.os.Bundle)5 SessionInteractor (chat.rocket.core.interactors.SessionInteractor)4 RealmSessionRepository (chat.rocket.persistence.realm.repositories.RealmSessionRepository)4 RealmRoomRepository (chat.rocket.persistence.realm.repositories.RealmRoomRepository)3 RealmUserRepository (chat.rocket.persistence.realm.repositories.RealmUserRepository)3 RocketChatCache (chat.rocket.android.RocketChatCache)2 AbsoluteUrlHelper (chat.rocket.android.helper.AbsoluteUrlHelper)2 RoomInteractor (chat.rocket.core.interactors.RoomInteractor)2 RealmServerInfoRepository (chat.rocket.persistence.realm.repositories.RealmServerInfoRepository)2 Dialog (android.app.Dialog)1 NonNull (android.support.annotation.NonNull)1 Nullable (android.support.annotation.Nullable)1 DialogFragment (android.support.v4.app.DialogFragment)1 AlertDialog (android.support.v7.app.AlertDialog)1 Patterns (android.util.Patterns)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 TextView (android.widget.TextView)1 Toast (android.widget.Toast)1