[#215] hide keyboard after sending a chat message

This commit is contained in:
Negue 2015-12-14 22:09:05 +01:00
parent 89fc986efb
commit 7261860ea8
2 changed files with 14 additions and 0 deletions

View file

@ -12,6 +12,8 @@ import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import com.facebook.FacebookSdk;
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
@ -255,4 +257,12 @@ public class HabiticaApplication extends Application {
}
// endregion
public static void dismissKeyboard() {
InputMethodManager imm = (InputMethodManager) currentActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
View currentFocus = currentActivity.getCurrentFocus();
if (currentFocus != null) {
imm.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0);
}
}
}

View file

@ -14,6 +14,7 @@ import android.view.View;
import android.view.ViewGroup;
import com.habitrpg.android.habitica.APIHelper;
import com.habitrpg.android.habitica.HabiticaApplication;
import com.habitrpg.android.habitica.MainActivity;
import com.habitrpg.android.habitica.R;
import com.habitrpg.android.habitica.events.ToggledInnStateEvent;
@ -195,6 +196,7 @@ public class ChatListFragment extends Fragment implements SwipeRefreshLayout.OnR
}
public void onEvent(SendNewGroupMessageCommand cmd) {
apiHelper.apiService.postGroupChat(cmd.TargetGroupId, cmd.Message, new Callback<PostChatMessageResult>() {
@Override
public void success(PostChatMessageResult msg, Response response) {
@ -210,6 +212,8 @@ public class ChatListFragment extends Fragment implements SwipeRefreshLayout.OnR
}
});
HabiticaApplication.dismissKeyboard();
}
// If the ChatList is Tavern, we're able to toggle the sleep-mode