mirror of
https://github.com/ChronosX88/Influence-P2P.git
synced 2024-11-24 00:02:19 +00:00
Added updating preferences view when username is changed
This commit is contained in:
parent
a5ef1569e6
commit
56297d2290
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,7 +1,7 @@
|
|||||||
*.iml
|
*.iml
|
||||||
.gradle
|
.gradle
|
||||||
/local.properties
|
/local.properties
|
||||||
/.idea/
|
/.idea
|
||||||
.DS_Store
|
.DS_Store
|
||||||
/build
|
/build
|
||||||
/captures
|
/captures
|
||||||
|
@ -87,5 +87,6 @@ interface CoreContracts {
|
|||||||
interface ISettingsView {
|
interface ISettingsView {
|
||||||
fun loadingScreen(state: Boolean)
|
fun loadingScreen(state: Boolean)
|
||||||
fun showMessage(message: String)
|
fun showMessage(message: String)
|
||||||
|
fun refreshScreen()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,7 @@ class SettingsPresenter(private val view: CoreContracts.ISettingsView) : CoreCon
|
|||||||
UIActions.USERNAME_AVAILABLE -> {
|
UIActions.USERNAME_AVAILABLE -> {
|
||||||
view.loadingScreen(false)
|
view.loadingScreen(false)
|
||||||
view.showMessage(AppHelper.getContext().getString(R.string.username_saved))
|
view.showMessage(AppHelper.getContext().getString(R.string.username_saved))
|
||||||
|
view.refreshScreen()
|
||||||
}
|
}
|
||||||
UIActions.USERNAME_ISNT_AVAILABLE -> {
|
UIActions.USERNAME_ISNT_AVAILABLE -> {
|
||||||
view.loadingScreen(false)
|
view.loadingScreen(false)
|
||||||
|
@ -13,6 +13,9 @@ import android.widget.Toast;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import androidx.preference.PreferenceFragmentCompat;
|
import androidx.preference.PreferenceFragmentCompat;
|
||||||
|
import androidx.preference.PreferenceScreen;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import io.github.chronosx88.influence.R;
|
import io.github.chronosx88.influence.R;
|
||||||
import io.github.chronosx88.influence.contracts.CoreContracts;
|
import io.github.chronosx88.influence.contracts.CoreContracts;
|
||||||
import io.github.chronosx88.influence.helpers.AppHelper;
|
import io.github.chronosx88.influence.helpers.AppHelper;
|
||||||
@ -43,6 +46,10 @@ public class SettingsFragment extends PreferenceFragmentCompat implements CoreCo
|
|||||||
setupUsernameEditDialog().show();
|
setupUsernameEditDialog().show();
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
getPreferenceScreen().getPreference(1).setOnPreferenceChangeListener((p, nV) -> {
|
||||||
|
getPreferenceScreen().getPreference(1).setSummary((String) nV);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -71,11 +78,15 @@ public class SettingsFragment extends PreferenceFragmentCompat implements CoreCo
|
|||||||
input.setText(AppHelper.getPreferences().getString("username", null));
|
input.setText(AppHelper.getPreferences().getString("username", null));
|
||||||
|
|
||||||
alertDialog.setView(input);
|
alertDialog.setView(input);
|
||||||
|
|
||||||
alertDialog.setPositiveButton(getContext().getString(R.string.ok), (dialog, which) -> presenter.updateUsername(input.getText().toString()));
|
alertDialog.setPositiveButton(getContext().getString(R.string.ok), (dialog, which) -> presenter.updateUsername(input.getText().toString()));
|
||||||
|
|
||||||
alertDialog.setNegativeButton(getContext().getString(R.string.cancel), (dialog, which) -> dialog.cancel());
|
alertDialog.setNegativeButton(getContext().getString(R.string.cancel), (dialog, which) -> dialog.cancel());
|
||||||
|
|
||||||
return alertDialog;
|
return alertDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void refreshScreen() {
|
||||||
|
getPreferenceScreen().getPreference(1).callChangeListener(AppHelper.getPreferences().getString("username", null));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user