NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.widget.DrawerLayout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.abhiandroid.ecommercestore.Activities.AccountVerification;
import com.abhiandroid.ecommercestore.Common;
import com.abhiandroid.ecommercestore.Config;
import com.abhiandroid.ecommercestore.Activities.Login;
import com.abhiandroid.ecommercestore.MVP.SignUpResponse;
import com.abhiandroid.ecommercestore.MVP.UserProfileResponse;
import com.abhiandroid.ecommercestore.Activities.MainActivity;
import com.abhiandroid.ecommercestore.R;
import com.abhiandroid.ecommercestore.Retrofit.Api;
import com.abhiandroid.ecommercestore.Activities.SignUp;

import java.util.List;

import butterknife.BindView;
import butterknife.BindViews;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.pedant.SweetAlert.SweetAlertDialog;
import de.hdodenhof.circleimageview.CircleImageView;
import retrofit.Callback;
import retrofit.RetrofitError;
import retrofit.client.Response;
import retrofit.http.Field;

public class MyProfile extends Fragment {

View view;
@BindViews({R.id.etAd, R.id.etSoyad,R.id.etEmail, R.id.etPassword, R.id.etTelefon,})
List<EditText> editTexts;
UserProfileResponse userProfileResponseData;
@BindView(R.id.submitBtn)
Button submitBtn;
@BindViews({R.id.male, R.id.female})
List<CircleImageView> circleImageViews;
String gender = "";
@BindView(R.id.profileLayout)
LinearLayout profileLayout;
@BindView(R.id.loginLayout)
LinearLayout loginLayout;
@BindView(R.id.logout)
Button logout;

@BindView(R.id.verifyEmailLayout)
LinearLayout verifyEmailLayout;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
view = inflater.inflate(R.layout.fragment_my_profile, container, false);
ButterKnife.bind(this, view);
MainActivity.title.setText("Profilim");

if (!MainActivity.userId.equalsIgnoreCase("")) {
getUserProfileData();
} else {
profileLayout.setVisibility(View.INVISIBLE);
loginLayout.setVisibility(View.VISIBLE);
}
profileLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
hideKeyboard(view);

}
});
return view;
}
protected void hideKeyboard(View view)
{
InputMethodManager in = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
in.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
private void setUserProfileData() {
// logout.setText("Logout ( "+userProfileResponseData.get);
editTexts.get(0).setText(userProfileResponseData.getName());
editTexts.get(1).setText(userProfileResponseData.getSurname());
editTexts.get(2).setText(userProfileResponseData.getEmail());
editTexts.get(3).setText(userProfileResponseData.getPassword());
editTexts.get(4).setText(userProfileResponseData.getTelephone());
try {
if (userProfileResponseData.getGender().equalsIgnoreCase("Kadın")) {
circleImageViews.get(0).setImageResource(R.drawable.male_unselect);
circleImageViews.get(1).setImageResource(R.drawable.female_select);
gender = "kadın";
} else if (userProfileResponseData.getGender().equalsIgnoreCase("Erkek")) {

circleImageViews.get(0).setImageResource(R.drawable.male_select);
circleImageViews.get(1).setImageResource(R.drawable.female_unselect);
gender = "erkek";
}
} catch (Exception e) {

}
}

@OnClick({R.id.male, R.id.female, R.id.submitBtn, R.id.logout, R.id.loginNow, R.id.txtSignUp, R.id.verfiyNow})
public void onClick(View view) {
switch (view.getId()) {
case R.id.male:
circleImageViews.get(0).setImageResource(R.drawable.male_select);
circleImageViews.get(1).setImageResource(R.drawable.female_unselect);
gender = "erkek";
break;
case R.id.female:
circleImageViews.get(0).setImageResource(R.drawable.male_unselect);
circleImageViews.get(1).setImageResource(R.drawable.female_select);
gender = "kadın";
break;
case R.id.submitBtn:
if (gender.equalsIgnoreCase("")) {
Config.showCustomAlertDialog(getActivity(), "Profilinizi güncellemek için lütfen cinsiyetinizi seçin", "",
SweetAlertDialog.ERROR_TYPE);
} else if (validate(editTexts.get(0))
&& validate(editTexts.get(1))
&& validate(editTexts.get(2))
&& validate(editTexts.get(3))
&& validate(editTexts.get(4)))
updateProfile();
break;
case R.id.logout:
logout();
break;
case R.id.loginNow:
Config.moveTo(getActivity(), Login.class);
break;
case R.id.txtSignUp:
Config.moveTo(getActivity(), SignUp.class);
break;

case R.id.verfiyNow:
Config.moveTo(getActivity(), AccountVerification.class);
break;
}
}

private void logout() {

final SweetAlertDialog alertDialog = new SweetAlertDialog(getActivity(), SweetAlertDialog.WARNING_TYPE);
alertDialog.setTitleText("Çıkış yapmak istediğinizden emin misiniz?");
alertDialog.setCancelText("Vazgeç");
alertDialog.setCancelClickListener(new SweetAlertDialog.OnSweetClickListener() {
@Override
public void onClick(SweetAlertDialog sweetAlertDialog) {
alertDialog.dismissWithAnimation();
}
});
alertDialog.show();
Button btn = (Button) alertDialog.findViewById(R.id.confirm_button);
btn.setBackground(getResources().getDrawable(R.drawable.custom_dialog_button));
btn.setText("Çıkış Yap");
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Common.saveUserData(getActivity(), "email", "");
Common.saveUserData(getActivity(), "userId", "");
Config.moveTo(getActivity(), Login.class);
getActivity().finishAffinity();

}
});
}

private boolean validate(EditText editText) {
if (editText.getText().toString().trim().length() > 0) {
return true;
}
editText.setError("Lütfen tüm alanları doldurunuz!");
editText.requestFocus();
return false;
}

@Override
public void onStart() {
super.onStart();
((MainActivity) getActivity()).lockUnlockDrawer(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
// Config.getCartList(getActivity(), true);

}


public void getUserProfileData() {
final SweetAlertDialog pDialog = new SweetAlertDialog(getActivity(), SweetAlertDialog.PROGRESS_TYPE);
pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.colorPrimary));
pDialog.setTitleText("Yükleniyor..");
pDialog.setCancelable(false);
pDialog.show();
Api.getClient2().getUserProfile(
MainActivity.userId, new Callback<UserProfileResponse>() {
@Override
public void success(UserProfileResponse userProfileResponse, Response response) {
userProfileResponseData = userProfileResponse;
pDialog.dismiss();
if (userProfileResponse.getMessage().equalsIgnoreCase("false")) {
profileLayout.setVisibility(View.INVISIBLE);
verifyEmailLayout.setVisibility(View.VISIBLE);
} else
setUserProfileData();


}

@Override
public void failure(RetrofitError error) {
pDialog.dismiss();

}
});
}

public void updateProfile() {
final SweetAlertDialog pDialog = new SweetAlertDialog(getActivity(), SweetAlertDialog.PROGRESS_TYPE);
pDialog.getProgressHelper().setBarColor(getResources().getColor(R.color.colorPrimary));
pDialog.setTitleText("Güncelleniyor...");
pDialog.setCancelable(false);

pDialog.show();
Api.getClient2().updateProfile(
MainActivity.userId,
editTexts.get(0).getText().toString().trim(),
editTexts.get(1).getText().toString().trim(),
editTexts.get(2).getText().toString().trim(),
editTexts.get(3).getText().toString().trim(),
editTexts.get(4).getText().toString().trim(),
gender,
new Callback<UserProfileResponse>() {
@Override
public void success(UserProfileResponse userProfileResponse, Response response) {
pDialog.dismiss();
if (userProfileResponse.getMessage().equalsIgnoreCase("true")) {
Config.showCustomAlertDialog(getActivity(),
"Profil Durumu",
"Profil güncellendi",
SweetAlertDialog.SUCCESS_TYPE);
} else {
Toast.makeText(getActivity(), "Sorun oluştu!", Toast.LENGTH_SHORT).show();
}
}

@Override
public void failure(RetrofitError error) {
pDialog.dismiss();

}
});
}

}

     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.