From 27416aae8523806390bc4bace43e7ffff9d1eb93 Mon Sep 17 00:00:00 2001 From: Niels Zwemmer Date: Wed, 21 Jun 2017 12:04:26 +0200 Subject: [PATCH] Added functionality framework for the profile pic button for Paul. He can now bind actions to the button. --- .../myhyvesbookplus/tagram/LoginActivity.java | 1 + .../tagram/ProfileFragment.java | 47 ++++++++++++++----- .../src/main/res/layout/fragment_profile.xml | 2 +- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/LoginActivity.java b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/LoginActivity.java index c1f417d..69e99c5 100644 --- a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/LoginActivity.java +++ b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/LoginActivity.java @@ -221,6 +221,7 @@ public class LoginActivity extends AppCompatActivity implements View.OnClickList }); } + //TODO Make modular for use with Profile fragment. /** * Saves the Username to Firebase * @param user The User object that needs to be updated diff --git a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileFragment.java b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileFragment.java index 877d756..55f6974 100644 --- a/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileFragment.java +++ b/app/MyHyvesBookPlusStagram/app/src/main/java/nl/myhyvesbookplus/tagram/ProfileFragment.java @@ -1,12 +1,18 @@ package nl.myhyvesbookplus.tagram; import android.content.Context; +import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Button; +import android.widget.EditText; +import android.widget.TextView; + +import com.google.firebase.auth.FirebaseAuth; /** @@ -27,6 +33,9 @@ public class ProfileFragment extends Fragment implements View.OnClickListener{ private String mParam1; private String mParam2; + protected Button logOutButton, profilePicButton; + protected FirebaseAuth mAuth; + private OnFragmentInteractionListener mListener; public ProfileFragment() { @@ -51,12 +60,7 @@ public class ProfileFragment extends Fragment implements View.OnClickListener{ return fragment; } - protected void bindOnClick() { - profilePicButton.setOnClickListener(this); - logOutButton.setOnClickListener(this); - } - - @Override + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (getArguments() != null) { @@ -65,11 +69,25 @@ public class ProfileFragment extends Fragment implements View.OnClickListener{ } } + /** + * Assigns all views. + */ + protected void findViews(View view) { + profilePicButton = (Button) view.findViewById(R.id.profile_pic_button); + bindOnClick(); + } + + protected void bindOnClick() { + profilePicButton.setOnClickListener(this); + } + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_profile, container, false); + View view = inflater.inflate(R.layout.fragment_profile, container, false); + findViews(view); + return view; } // TODO: Rename method, update argument and hook method into UI event @@ -86,11 +104,18 @@ public class ProfileFragment extends Fragment implements View.OnClickListener{ profilePicOnClick(); break; case R.id.logout_button: - logOutOnClick(); +// logOutOnClick(); break; } } + // TODO Make the function actually do something. + public void profilePicOnClick() { + + } + + + @Override public void onAttach(Context context) { super.onAttach(context); @@ -113,10 +138,8 @@ public class ProfileFragment extends Fragment implements View.OnClickListener{ * fragment to allow an interaction in this fragment to be communicated * to the activity and potentially other fragments contained in that * activity. - *

- * See the Android Training lesson Communicating with Other Fragments for more information. + * See the Android Training lesson http://developer.android.com/training/basics/fragments/communicating.html + * for more information. */ public interface OnFragmentInteractionListener { // TODO: Update argument type and name diff --git a/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile.xml b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile.xml index 919249f..bb2fadd 100644 --- a/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile.xml +++ b/app/MyHyvesBookPlusStagram/app/src/main/res/layout/fragment_profile.xml @@ -7,7 +7,7 @@