diff --git a/app/src/main/java/org/ntlab/amaryllis/client/fragment/AccountFragment.java b/app/src/main/java/org/ntlab/amaryllis/client/fragment/AccountFragment.java index c12eed2..6766874 100644 --- a/app/src/main/java/org/ntlab/amaryllis/client/fragment/AccountFragment.java +++ b/app/src/main/java/org/ntlab/amaryllis/client/fragment/AccountFragment.java @@ -1,14 +1,29 @@ package org.ntlab.amaryllis.client.fragment; +import android.content.Intent; import android.os.Bundle; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; - import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Button; +import org.ntlab.amaryllis.client.Amaryllis; +import org.ntlab.amaryllis.client.MainActivity; import org.ntlab.amaryllis.client.R; +import org.ntlab.amaryllis.client.SignUpActivity; +import org.ntlab.amaryllis.client.entities.SignUpJson; +import org.ntlab.amaryllis.client.resources.AccountsRest; + + +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; +import retrofit2.Retrofit; +import retrofit2.converter.jackson.JacksonConverterFactory; /** * A simple {@link Fragment} subclass. @@ -25,7 +40,9 @@ // TODO: Rename and change types of parameters private String mParam1; private String mParam2; + Button logoutButton; + private static final int READ_REQUEST_CODE = 42; public AccountFragment() { // Required empty public constructor } @@ -56,11 +73,32 @@ mParam2 = getArguments().getString(ARG_PARAM2); } } + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + Retrofit retrofit = new Retrofit.Builder() + .baseUrl("http://nitta-lab-www.is.konan-u.ac.jp/amaryllis/") + .addConverterFactory(JacksonConverterFactory.create()) + .build(); + logoutButton = (Button)view.findViewById(R.id.logout); + logoutButton.setOnClickListener(new View.OnClickListener() { + + public void onClick(View v) { + Amaryllis amaryllis =(Amaryllis) getActivity().getApplication(); + amaryllis.setUid(null); + amaryllis.setPassword(null); + Intent intent = new Intent(getActivity().getApplication(), SignUpActivity.class); + getContext().startActivity(intent); + } + }); + + } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_account, container, false); } } \ No newline at end of file