use of org.gateshipone.malp.mpdservice.profilemanagement.MPDServerProfile in project malp by gateship-one.
the class ProfileAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
MPDServerProfile profile = (MPDServerProfile) getItem(position);
// Profile name
String profileName = profile.getProfileName();
int port = profile.getPort();
String portString = String.valueOf(port);
String hostname = profile.getHostname();
boolean checked = profile.getAutoconnect();
if (convertView != null) {
ProfileListItem profileListItem = (ProfileListItem) convertView;
profileListItem.setProfileName(profileName);
profileListItem.setHostname(hostname);
profileListItem.setPort(portString);
profileListItem.setChecked(checked);
} else {
convertView = new ProfileListItem(mContext, profileName, hostname, portString, checked);
}
return convertView;
}
use of org.gateshipone.malp.mpdservice.profilemanagement.MPDServerProfile in project malp by gateship-one.
the class BackgroundService method onProfileChanged.
/**
* Disconnects from the current server and rereads the default profile.
*/
private void onProfileChanged() {
onMPDDisconnect();
MPDServerProfile profile = MPDProfileManager.getInstance(this).getAutoconnectProfile();
ConnectionManager.getInstance(getApplicationContext()).setParameters(profile, this);
}
use of org.gateshipone.malp.mpdservice.profilemanagement.MPDServerProfile in project malp by gateship-one.
the class MainActivity method editProfile.
@Override
public void editProfile(MPDServerProfile profile) {
if (null == profile) {
profile = new MPDServerProfile(getString(R.string.fragment_profile_default_name), true);
ConnectionManager.getInstance(getApplicationContext()).addProfile(profile, this);
}
// Create fragment and give it an argument for the selected article
EditProfileFragment newFragment = new EditProfileFragment();
Bundle args = new Bundle();
if (null != profile) {
args.putParcelable(EditProfileFragment.EXTRA_PROFILE, profile);
}
newFragment.setArguments(args);
android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
newFragment.setEnterTransition(new Slide(GravityCompat.getAbsoluteGravity(GravityCompat.START, getResources().getConfiguration().getLayoutDirection())));
newFragment.setExitTransition(new Slide(GravityCompat.getAbsoluteGravity(GravityCompat.END, getResources().getConfiguration().getLayoutDirection())));
// Replace whatever is in the fragment_container view with this
// fragment,
// and add the transaction to the back stack so the user can navigate
// back
transaction.replace(R.id.fragment_container, newFragment, EditProfileFragment.TAG);
transaction.addToBackStack("EditProfileFragment");
// Commit the transaction
transaction.commit();
}
use of org.gateshipone.malp.mpdservice.profilemanagement.MPDServerProfile in project malp by gateship-one.
the class EditProfileFragment method checkChanged.
private void checkChanged() {
boolean profileChanged = false;
if (!mProfilenameView.getText().toString().equals(mProfilename)) {
profileChanged = true;
mProfilename = mProfilenameView.getText().toString();
}
if (!mHostnameView.getText().toString().equals(mHostname)) {
profileChanged = true;
mHostname = mHostnameView.getText().toString();
}
if (!mPasswordView.getText().toString().equals(mPassword)) {
profileChanged = true;
mPassword = mPasswordView.getText().toString();
}
if (!mPortView.getText().toString().isEmpty() && Integer.parseInt(mPortView.getText().toString()) != mPort) {
profileChanged = true;
mPort = Integer.parseInt(mPortView.getText().toString());
}
if (!mStreamingURLView.getText().toString().equals(mStreamingURL)) {
profileChanged = true;
mStreamingURL = mStreamingURLView.getText().toString();
}
if (mStreamingEnabledView.isChecked() != mStreamingEnabled) {
profileChanged = true;
mStreamingEnabled = mStreamingEnabledView.isChecked();
}
if (!mHTTPCoverRegexView.getText().toString().equals(mHTTPCoverRegex)) {
profileChanged = true;
mHTTPCoverRegex = mHTTPCoverRegexView.getText().toString();
}
if (mHTTPCoverEnabledView.isChecked() != mHTTPCoverEnabled) {
profileChanged = true;
mHTTPCoverEnabled = mHTTPCoverEnabledView.isChecked();
}
if (profileChanged) {
if (null != mOldProfile) {
ConnectionManager.getInstance(getContext().getApplicationContext()).removeProfile(mOldProfile, getActivity());
} else {
mOldProfile = new MPDServerProfile(mProfilename, true);
}
mOldProfile.setProfileName(mProfilename);
mOldProfile.setHostname(mHostname);
mOldProfile.setPassword(mPassword);
mOldProfile.setPort(mPort);
mOldProfile.setStreamingURL(mStreamingURL);
mOldProfile.setStreamingEnabled(mStreamingEnabled);
mOldProfile.setHTTPCoverEnabled(mHTTPCoverEnabled);
mOldProfile.setHTTPRegex(mHTTPCoverRegex);
ConnectionManager.getInstance(getContext().getApplicationContext()).addProfile(mOldProfile, getContext());
}
}
use of org.gateshipone.malp.mpdservice.profilemanagement.MPDServerProfile in project malp by gateship-one.
the class ProfileAdapter method setActive.
public void setActive(int position, boolean active) {
for (MPDServerProfile profile : mModelData) {
profile.setAutoconnect(false);
}
((MPDServerProfile) getItem(position)).setAutoconnect(active);
notifyDataSetChanged();
}
Aggregations