Android Open Source - socialcde4android Set Service Features Dialog






From Project

Back to project page socialcde4android.

License

The source code is released under:

MIT License

If you think the Android project socialcde4android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package it.uniba.socialcde4android.dialogs;
/* w  ww  .  j a v  a2  s.  c o  m*/
import java.util.Arrays;

import com.nostra13.universalimageloader.core.ImageLoader;


import it.uniba.socialcde4android.R;
import it.uniba.socialcde4android.adapters.ConfiguratedImageLoader;
import it.uniba.socialcde4android.adapters.FeaturesAdapter;
import it.uniba.socialcde4android.preferences.Preferences;
import it.uniba.socialcde4android.shared.library.WFeature;
import it.uniba.socialcde4android.shared.library.WService;
import android.app.Activity;
import android.app.DialogFragment;
import android.os.Bundle;
import android.os.Parcelable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

public class SetServiceFeaturesDialog extends DialogFragment{

  private static final String ARG_WFEAT = "arg wfeatures";
  private static final String ARG_WSERV = "arg wservice";
  private WFeature[] wfeature;
  private WService wservice;
  private ListView listview;
  private FeaturesAdapter adapter;
  private OnFeaturesDialogInteractionListener mListener;
  private ImageLoader imageloader;

  
  public static SetServiceFeaturesDialog newInstance(WFeature[] wfeature, WService wService) {
    SetServiceFeaturesDialog dialog = new SetServiceFeaturesDialog();
    Bundle args = new Bundle();
    args.putParcelableArray(ARG_WFEAT, wfeature);
    args.putParcelable(ARG_WSERV, wService);
    dialog.setArguments(args);
    return dialog;
  }

  public SetServiceFeaturesDialog(){
    
  }
  
  public interface OnFeaturesDialogInteractionListener{
    public void saveFeaturesStatus(int service_id, String active_features);
    
    public void unregisterService(int service_id);
  }
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setStyle(DialogFragment.STYLE_NO_FRAME, android.R.style.Theme_Holo_Light_Dialog); 
    if (getArguments() != null) {
      wservice = getArguments().getParcelable(ARG_WSERV);
      Parcelable[] parcelableArray =  getArguments().getParcelableArray(ARG_WFEAT);
      if (parcelableArray != null) 
        wfeature = Arrays.copyOf(parcelableArray, parcelableArray.length, WFeature[].class);
    }
    mListener = (OnFeaturesDialogInteractionListener) getActivity();
  }
  
  @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,  Bundle savedInstanceState) {
    imageloader = ConfiguratedImageLoader.getImageLoader((Activity)mListener);
        View v = inflater.inflate(R.layout.dialog_set_service_features, container, false);
        //getDialog().getWindow().setBackgroundDrawableResource(R.drawable.dialog_background);
        ImageView imageviewService = (ImageView) v.findViewById(R.id.imageView1_logoFEATURE); 
    imageloader.displayImage(Preferences.getSavedHost(getActivity())+wservice.getImage(), imageviewService);
        TextView title = (TextView) v.findViewById(R.id.textView1_title_FEATURES);
        title.setText(wservice.getName()+" features");
    listview = (ListView) v.findViewById(R.id.listViewCheckBoxFEATURES2);
        adapter = new FeaturesAdapter(getActivity(), android.R.layout.simple_list_item_1,  wfeature);
        listview.setAdapter(adapter);
        Button save_button = (Button) v.findViewById(R.id.button2_dialog_features_SAVE);
      Button unsub_button = (Button) v.findViewById(R.id.button1_dialog_features_UNSUBSCRIBE);
      
      save_button.setOnClickListener(new Button.OnClickListener() {
      @Override
      public void onClick(View v) {
        Boolean[] adapterFeatStatus = adapter.getFeaturesStatus();
        for(int i=0; i<wfeature.length;i++){
          if (wfeature[i].isIsChosen() != adapterFeatStatus[i]){
            //invia la richiesta di salvataggio..
            updateFeatures(adapterFeatStatus);
            break;
          }
        }
        SetServiceFeaturesDialog.this.dismiss();
      }
    });
      
      unsub_button.setOnClickListener(new Button.OnClickListener() {
      @Override
      public void onClick(View v) {

        mListener.unregisterService(wservice.getId());
        SetServiceFeaturesDialog.this.dismiss();
      }
    });
        return v;
    }

  
  protected void updateFeatures(Boolean[] adapterFeatStatus) {
    int count = 0;
    String features = "[";
    for (int i=0; i<adapterFeatStatus.length;i++){
      
      if (adapterFeatStatus[i] == true){
        if (count == 0){
          features += " \"" + wfeature[i].getName() + "\"";
          count++;
        }else{
          features += " , \"" + wfeature[i].getName() + "\"";
          
        }
      }
    }
    features += "]";
    mListener.saveFeaturesStatus(wservice.getId(), features);
  }
  
  
}




Java Source Code List

it.uniba.socialcde4android.activity.HomeActivity.java
it.uniba.socialcde4android.activity.LoginActivity.java
it.uniba.socialcde4android.activity.RegistrationActivity.java
it.uniba.socialcde4android.activity.WebViewActivity.java
it.uniba.socialcde4android.adapters.ConfiguratedImageLoader.java
it.uniba.socialcde4android.adapters.FeaturesAdapter.java
it.uniba.socialcde4android.adapters.ServicesAdapter.java
it.uniba.socialcde4android.adapters.SquareImageView.java
it.uniba.socialcde4android.adapters.TimeLineAdapter.java
it.uniba.socialcde4android.adapters.UserAvatarsAdapter.java
it.uniba.socialcde4android.adapters.UsersAdapter.java
it.uniba.socialcde4android.config.Config.java
it.uniba.socialcde4android.costants.Consts.java
it.uniba.socialcde4android.costants.Error_consts.java
it.uniba.socialcde4android.costants.Services_id.java
it.uniba.socialcde4android.data.operation.Authorize_Operation.java
it.uniba.socialcde4android.data.operation.ChangePasswordWithPassword_Operation.java
it.uniba.socialcde4android.data.operation.GetAvailableAvatars_Operation.java
it.uniba.socialcde4android.data.operation.GetColleagueProfile_Operation.java
it.uniba.socialcde4android.data.operation.GetFeatures_Operation.java
it.uniba.socialcde4android.data.operation.GetFriends_Operation.java
it.uniba.socialcde4android.data.operation.GetHideSettings_Operation.java
it.uniba.socialcde4android.data.operation.GetOAuthData_Operation.java
it.uniba.socialcde4android.data.operation.GetUser_Operation.java
it.uniba.socialcde4android.data.operation.IsUsernameAvailable_Operation.java
it.uniba.socialcde4android.data.operation.IsWebServiceRunning_Operation.java
it.uniba.socialcde4android.data.operation.RecordService_Operation.java
it.uniba.socialcde4android.data.operation.RetrieveServices_Operation.java
it.uniba.socialcde4android.data.operation.SendTFSpost_Operation.java
it.uniba.socialcde4android.data.operation.SetActiveFeatures_Operation.java
it.uniba.socialcde4android.data.operation.SetAvatar_Operation.java
it.uniba.socialcde4android.data.operation.SetFollowed_Operation.java
it.uniba.socialcde4android.data.operation.SetHideSettings_Operation.java
it.uniba.socialcde4android.data.operation.SubscribeUser_Operation.java
it.uniba.socialcde4android.data.operation.UnregisterService_Operation.java
it.uniba.socialcde4android.data.requestmanager.SocialCDERequestFactory.java
it.uniba.socialcde4android.data.requestmanager.SocialCDERequestManager.java
it.uniba.socialcde4android.data.service.SocialCDERequestService.java
it.uniba.socialcde4android.dialogs.ChangePasswordDialog.java
it.uniba.socialcde4android.dialogs.ChooseAvatarDialog.java
it.uniba.socialcde4android.dialogs.HideUnhideDialog.java
it.uniba.socialcde4android.dialogs.NoNetworkDialog.java
it.uniba.socialcde4android.dialogs.SetServiceFeaturesDialog.java
it.uniba.socialcde4android.dialogs.TFSAuthDialog.java
it.uniba.socialcde4android.fragments.TimeLine_AbstractFragment.java
it.uniba.socialcde4android.fragments.TimeLine_Fragment.java
it.uniba.socialcde4android.fragments.WUserColleagueProfile_Fragment.java
it.uniba.socialcde4android.fragments.WUserProfile_Fragment.java
it.uniba.socialcde4android.preferences.Preferences.java
it.uniba.socialcde4android.shared.library.JsonDateDeserializer.java
it.uniba.socialcde4android.shared.library.WFeature.java
it.uniba.socialcde4android.shared.library.WHidden.java
it.uniba.socialcde4android.shared.library.WOAuthData.java
it.uniba.socialcde4android.shared.library.WPost.java
it.uniba.socialcde4android.shared.library.WService.java
it.uniba.socialcde4android.shared.library.WUser.java
it.uniba.socialcde4android.utility.ScreenUtility.java