mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-21 21:29:00 +00:00
Move 'dismissKeyboard()' to UiUtils class.
This commit is contained in:
parent
4c34e72fe3
commit
2bd46a42aa
3 changed files with 30 additions and 11 deletions
|
|
@ -13,12 +13,12 @@ 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;
|
||||
import com.raizlabs.android.dbflow.config.FlowManager;
|
||||
import com.squareup.leakcanary.LeakCanary;
|
||||
|
||||
import org.solovyev.android.checkout.Billing;
|
||||
import org.solovyev.android.checkout.Cache;
|
||||
import org.solovyev.android.checkout.Checkout;
|
||||
|
|
@ -268,12 +268,4 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
26
Habitica/src/com/habitrpg/android/habitica/ui/UiUtils.java
Normal file
26
Habitica/src/com/habitrpg/android/habitica/ui/UiUtils.java
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package com.habitrpg.android.habitica.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
/**
|
||||
* Simple utilities class for UI related stuff.
|
||||
*/
|
||||
public class UiUtils {
|
||||
|
||||
/**
|
||||
* Hides soft keyboard if it's opened.
|
||||
*
|
||||
* @param activity Currently visible activity.
|
||||
*/
|
||||
public static void dismissKeyboard(Activity activity) {
|
||||
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
View currentFocus = activity.getCurrentFocus();
|
||||
if (currentFocus != null) {
|
||||
imm.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -23,6 +23,7 @@ import com.habitrpg.android.habitica.events.commands.FlagChatMessageCommand;
|
|||
import com.habitrpg.android.habitica.events.commands.SendNewGroupMessageCommand;
|
||||
import com.habitrpg.android.habitica.events.commands.ToggleInnCommand;
|
||||
import com.habitrpg.android.habitica.events.commands.ToggleLikeMessageCommand;
|
||||
import com.habitrpg.android.habitica.ui.UiUtils;
|
||||
import com.habitrpg.android.habitica.ui.adapter.ChatRecyclerViewAdapter;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.ChatMessage;
|
||||
import com.magicmicky.habitrpgwrapper.lib.models.HabitRPGUser;
|
||||
|
|
@ -213,7 +214,7 @@ public class ChatListFragment extends Fragment implements SwipeRefreshLayout.OnR
|
|||
}
|
||||
});
|
||||
|
||||
HabiticaApplication.dismissKeyboard();
|
||||
UiUtils.dismissKeyboard(HabiticaApplication.currentActivity);
|
||||
}
|
||||
|
||||
// If the ChatList is Tavern, we're able to toggle the sleep-mode
|
||||
|
|
|
|||
Loading…
Reference in a new issue