Search in sources :

Example 1 with MPDServerProfile

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;
}
Also used : ProfileListItem(org.gateshipone.malp.application.listviewitems.ProfileListItem) MPDServerProfile(org.gateshipone.malp.mpdservice.profilemanagement.MPDServerProfile)

Example 2 with MPDServerProfile

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);
}
Also used : MPDServerProfile(org.gateshipone.malp.mpdservice.profilemanagement.MPDServerProfile)

Example 3 with MPDServerProfile

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();
}
Also used : Slide(android.transition.Slide) Bundle(android.os.Bundle) FragmentTransaction(android.support.v4.app.FragmentTransaction) MPDServerProfile(org.gateshipone.malp.mpdservice.profilemanagement.MPDServerProfile) EditProfileFragment(org.gateshipone.malp.application.fragments.EditProfileFragment)

Example 4 with MPDServerProfile

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());
    }
}
Also used : MPDServerProfile(org.gateshipone.malp.mpdservice.profilemanagement.MPDServerProfile)

Example 5 with MPDServerProfile

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();
}
Also used : MPDServerProfile(org.gateshipone.malp.mpdservice.profilemanagement.MPDServerProfile)

Aggregations

MPDServerProfile (org.gateshipone.malp.mpdservice.profilemanagement.MPDServerProfile)6 Bundle (android.os.Bundle)1 FragmentTransaction (android.support.v4.app.FragmentTransaction)1 Slide (android.transition.Slide)1 EditProfileFragment (org.gateshipone.malp.application.fragments.EditProfileFragment)1 ProfileListItem (org.gateshipone.malp.application.listviewitems.ProfileListItem)1