Android Open Source - socialcde4android Choose Avatar 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;
//from  w w  w  .j  a v a  2 s .c o m


import it.uniba.socialcde4android.R;
import it.uniba.socialcde4android.adapters.UserAvatarsAdapter;
import android.app.DialogFragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.Toast;

public class ChooseAvatarDialog extends DialogFragment{

  private static final String ARG_AVATARURLS = "avatar URLs";
  private static final String ARG_OLD_AVATARURLS = "old avatar URLs";

  private String[] avatarURLs;
  private String old_uri;
  private OnChooseAvatarListener mListener;
  private GridView imagesGridView;

  public static ChooseAvatarDialog newInstance(String[] uri, String old_uri) {
    ChooseAvatarDialog dialog = new ChooseAvatarDialog();
    Bundle args = new Bundle();
    args.putStringArray(ARG_AVATARURLS, uri);
    args.putString(ARG_OLD_AVATARURLS, old_uri);
    dialog.setArguments(args);
    return dialog;
  }

  
  
  public ChooseAvatarDialog(){

  }

  public interface OnChooseAvatarListener{
    public void setAvatar(String uri);
  }

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setStyle(DialogFragment.STYLE_NO_FRAME, android.R.style.Theme_Holo_Light_Dialog); 
    if (getArguments() != null) {
        avatarURLs = getArguments().getStringArray(ARG_AVATARURLS);
        old_uri= getArguments().getString(ARG_OLD_AVATARURLS);
    }
    mListener = (OnChooseAvatarListener) getActivity();
  }

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,  Bundle savedInstanceState) {
    View v = null;

    v = inflater.inflate(R.layout.dialog_choose_avatar, container, false);

    imagesGridView = (GridView) v.findViewById(R.id.gridViewGALLERY);
    UserAvatarsAdapter avatarAdapter = new UserAvatarsAdapter(getActivity(), android.R.layout.simple_list_item_1, avatarURLs);
    imagesGridView.setAdapter(avatarAdapter);
    imagesGridView.setOnItemClickListener(new GridView.OnItemClickListener(){

      @Override
      public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {
        String uri = (String) imagesGridView.getAdapter().getItem(position);
        //adesso richiamo dall'activity il metodo per settare il nuovo indirizzo
        if (!uri.equals(old_uri)){
        mListener.setAvatar(uri);
        }else{
          Toast.makeText(ChooseAvatarDialog.this.getActivity(), "No Avatar change is required."  , Toast.LENGTH_SHORT).show();
        }
        ChooseAvatarDialog.this.dismiss();
      }

      
    });

    return v;
  }


}




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