Added functionality framework for the profile pic button for Paul. He can now bind actions to the button.

This commit is contained in:
Niels Zwemmer
2017-06-21 12:04:26 +02:00
parent 291261fcee
commit 27416aae85
3 changed files with 37 additions and 13 deletions

View File

@@ -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 * Saves the Username to Firebase
* @param user The User object that needs to be updated * @param user The User object that needs to be updated

View File

@@ -1,12 +1,18 @@
package nl.myhyvesbookplus.tagram; package nl.myhyvesbookplus.tagram;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.app.Fragment; import android.app.Fragment;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; 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 mParam1;
private String mParam2; private String mParam2;
protected Button logOutButton, profilePicButton;
protected FirebaseAuth mAuth;
private OnFragmentInteractionListener mListener; private OnFragmentInteractionListener mListener;
public ProfileFragment() { public ProfileFragment() {
@@ -51,12 +60,7 @@ public class ProfileFragment extends Fragment implements View.OnClickListener{
return fragment; return fragment;
} }
protected void bindOnClick() { @Override
profilePicButton.setOnClickListener(this);
logOutButton.setOnClickListener(this);
}
@Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (getArguments() != null) { 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 @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
// Inflate the layout for this fragment // 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 // TODO: Rename method, update argument and hook method into UI event
@@ -86,11 +104,18 @@ public class ProfileFragment extends Fragment implements View.OnClickListener{
profilePicOnClick(); profilePicOnClick();
break; break;
case R.id.logout_button: case R.id.logout_button:
logOutOnClick(); // logOutOnClick();
break; break;
} }
} }
// TODO Make the function actually do something.
public void profilePicOnClick() {
}
@Override @Override
public void onAttach(Context context) { public void onAttach(Context context) {
super.onAttach(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 * fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that * to the activity and potentially other fragments contained in that
* activity. * activity.
* <p> * See the Android Training lesson http://developer.android.com/training/basics/fragments/communicating.html
* See the Android Training lesson <a href= * for more information.
* "http://developer.android.com/training/basics/fragments/communicating.html"
* >Communicating with Other Fragments</a> for more information.
*/ */
public interface OnFragmentInteractionListener { public interface OnFragmentInteractionListener {
// TODO: Update argument type and name // TODO: Update argument type and name

View File

@@ -7,7 +7,7 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
<ScrollView <ScrollView
android:layout_width="match_parent" android:layout_width="match_parent"