First attempt at ProfileAdapter. Not in working state.
This commit is contained in:
@@ -0,0 +1,78 @@
|
|||||||
|
package nl.myhyvesbookplus.tagram;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.BaseAdapter;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
|
import com.firebase.ui.storage.images.FirebaseImageLoader;
|
||||||
|
import com.google.firebase.storage.FirebaseStorage;
|
||||||
|
import com.google.firebase.storage.StorageReference;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import nl.myhyvesbookplus.tagram.model.UriPost;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by niels on 27-6-17.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ProfileAdapter extends BaseAdapter {
|
||||||
|
|
||||||
|
private static final String TAG = "ProfileAdapter";
|
||||||
|
private LayoutInflater mInflater;
|
||||||
|
private Context mContext;
|
||||||
|
private ArrayList<UriPost> mData;
|
||||||
|
protected TextView comment;
|
||||||
|
protected TextView nietSlechts;
|
||||||
|
protected ImageView photo;
|
||||||
|
|
||||||
|
ProfileAdapter(Context context, ArrayList<UriPost> data) {
|
||||||
|
mContext = context;
|
||||||
|
mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
mData = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
return mData.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getItem(int position) {
|
||||||
|
return mData.get(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getItemId(int position) {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
View rowView = mInflater.inflate(R.layout.list_item_timeline_profile, parent, false);
|
||||||
|
View newRowView = findViews(rowView);
|
||||||
|
UriPost post = (UriPost) getItem(position);
|
||||||
|
comment.setText(post.getComment());
|
||||||
|
StorageReference ref = FirebaseStorage.getInstance().getReferenceFromUrl(post.getUri());
|
||||||
|
Glide.with(mContext)
|
||||||
|
.using(new FirebaseImageLoader())
|
||||||
|
.load(ref)
|
||||||
|
.into(photo);
|
||||||
|
|
||||||
|
return newRowView;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected View findViews(View rowView) {
|
||||||
|
comment = (TextView) rowView.findViewById(R.id.comment_timeline_profile);
|
||||||
|
nietSlechts = (TextView) rowView.findViewById(R.id.niet_slecht_count_profile);
|
||||||
|
photo = (ImageView) rowView.findViewById(R.id.timeline_image_profile);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
@@ -29,6 +30,7 @@ import com.google.firebase.storage.StorageReference;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import nl.myhyvesbookplus.tagram.controller.DownloadClass;
|
||||||
import nl.myhyvesbookplus.tagram.controller.ProfilePictureUploader;
|
import nl.myhyvesbookplus.tagram.controller.ProfilePictureUploader;
|
||||||
|
|
||||||
import static android.app.Activity.RESULT_OK;
|
import static android.app.Activity.RESULT_OK;
|
||||||
@@ -44,6 +46,8 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
|
|||||||
protected ImageView profilePicture;
|
protected ImageView profilePicture;
|
||||||
protected FirebaseUser user;
|
protected FirebaseUser user;
|
||||||
protected File photoFile = null;
|
protected File photoFile = null;
|
||||||
|
private ListView listView;
|
||||||
|
private DownloadClass downloadClass;
|
||||||
|
|
||||||
ProgressDialog progressDialog;
|
ProgressDialog progressDialog;
|
||||||
|
|
||||||
@@ -55,6 +59,7 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
user = FirebaseAuth.getInstance().getCurrentUser();
|
user = FirebaseAuth.getInstance().getCurrentUser();
|
||||||
|
loadPersonalPosts();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,6 +70,7 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
|
|||||||
profilePicture = (ImageView) view.findViewById(R.id.imageView_profile_picture);
|
profilePicture = (ImageView) view.findViewById(R.id.imageView_profile_picture);
|
||||||
profileName = (TextView) view.findViewById(R.id.profile_name);
|
profileName = (TextView) view.findViewById(R.id.profile_name);
|
||||||
changePwdButton = (Button) view.findViewById(R.id.change_psw_button);
|
changePwdButton = (Button) view.findViewById(R.id.change_psw_button);
|
||||||
|
listView = (ListView) view.findViewById(R.id.listview);
|
||||||
bindOnClick();
|
bindOnClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,6 +105,8 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
profilePicture.invalidate();
|
profilePicture.invalidate();
|
||||||
|
downloadClass = new DownloadClass(getActivity());
|
||||||
|
downloadClass.getPostsFromServer();
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
@@ -143,6 +151,12 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void startList() {
|
||||||
|
ProfileAdapter adapter = new ProfileAdapter(getActivity(), downloadClass.getmList());
|
||||||
|
listView.setAdapter(adapter);
|
||||||
|
listView.addHeaderView(adapter);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grabs the image just taken by the built-in camera and pushes this image to the user account.
|
* Grabs the image just taken by the built-in camera and pushes this image to the user account.
|
||||||
* @param requestCode The code which corresponds to REQUEST_TAKE_PHOTO. Used as indicator.
|
* @param requestCode The code which corresponds to REQUEST_TAKE_PHOTO. Used as indicator.
|
||||||
@@ -158,6 +172,10 @@ public class ProfileFragment extends Fragment implements View.OnClickListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void loadPersonalPosts() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private File createImageFile() throws IOException {
|
private File createImageFile() throws IOException {
|
||||||
// Create an image file name
|
// Create an image file name
|
||||||
|
|||||||
Reference in New Issue
Block a user