mirror of https://github.com/M66B/FairEmail.git
parent
10e96f6a3f
commit
8d42f6809f
@ -0,0 +1,42 @@
|
||||
package eu.faircode.email;
|
||||
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
public class FragmentEx extends Fragment {
|
||||
private String subtitle = "";
|
||||
|
||||
protected void setSubtitle(int resid) {
|
||||
setSubtitle(getString(resid));
|
||||
}
|
||||
|
||||
protected void setSubtitle(String subtitle) {
|
||||
this.subtitle = subtitle;
|
||||
updateSubtitle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
updateSubtitle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
|
||||
InputMethodManager im = getContext().getSystemService(InputMethodManager.class);
|
||||
im.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
|
||||
}
|
||||
|
||||
private void updateSubtitle() {
|
||||
AppCompatActivity activity = (AppCompatActivity) getActivity();
|
||||
if (activity != null) {
|
||||
ActionBar actionbar = activity.getSupportActionBar();
|
||||
if (actionbar != null)
|
||||
actionbar.setSubtitle(subtitle);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue