Commit 044b4f26 authored by ankitasingh's avatar ankitasingh

Image adapter added with image_item.xml+ gradle changes

parent c85889b4
<component name="libraryTable">
<library name="Gradle: com.squareup.picasso:picasso:2.5.2@jar">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.squareup.picasso/picasso/2.5.2/7446d06ec8d4f7ffcc53f1da37c95f200dcb9387/picasso-2.5.2.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.squareup.picasso/picasso/2.5.2/c9487622e575822182ce402f84a2f915958c52c3/picasso-2.5.2-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.squareup.picasso/picasso/2.5.2/3f998a26355e4138e3e7a880a5dac57fc4370339/picasso-2.5.2-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
......@@ -108,11 +108,13 @@
<orderEntry type="library" name="Gradle: androidx.lifecycle:lifecycle-common:2.1.0@jar" level="project" />
<orderEntry type="library" name="Gradle: androidx.arch.core:core-common:2.1.0@jar" level="project" />
<orderEntry type="library" name="Gradle: androidx.annotation:annotation:1.1.0@jar" level="project" />
<orderEntry type="library" name="Gradle: com.squareup.picasso:picasso:2.5.2@jar" level="project" />
<orderEntry type="library" name="Gradle: androidx.constraintlayout:constraintlayout-solver:1.1.3@jar" level="project" />
<orderEntry type="library" name="Gradle: com.google.auto.value:auto-value-annotations:1.6.5@jar" level="project" />
<orderEntry type="library" name="Gradle: com.google.android.material:material:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.appcompat:appcompat:1.1.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.cardview:cardview:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.recyclerview:recyclerview:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.google.firebase:firebase-database:19.2.0@aar" level="project" />
<orderEntry type="library" name="Gradle: com.google.firebase:firebase-storage:19.1.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.legacy:legacy-support-v4:1.0.0@aar" level="project" />
......@@ -124,7 +126,6 @@
<orderEntry type="library" name="Gradle: com.google.android.gms:play-services-basement:17.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.fragment:fragment:1.1.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.appcompat:appcompat-resources:1.1.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.recyclerview:recyclerview:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.legacy:legacy-support-core-ui:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.drawerlayout:drawerlayout:1.0.0@aar" level="project" />
<orderEntry type="library" name="Gradle: androidx.legacy:legacy-support-core-utils:1.0.0@aar" level="project" />
......
......@@ -25,6 +25,8 @@ dependencies {
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.firebase:firebase-auth:19.1.0'
......
......@@ -18,13 +18,14 @@ public class CreateFoundObject {
private String mLocation;
private String mCategory;
private Date mDateFound;
private String mtype;
public CreateFoundObject() {
}
public CreateFoundObject(String LDAPID,String title ,String imageUrl, String location, String desc,
String category, Date datefound) {
String category, Date datefound,String type) {
if (LDAPID.trim().equals("")) {
mLDAP = "No Name";
}
......@@ -37,6 +38,7 @@ public class CreateFoundObject {
mDateFound = datefound;
mCategory = category;
mTitle = title;
mtype = type;
SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy");
Date date = new Date();
......
......@@ -153,7 +153,7 @@ public class FoundItem extends AppCompatActivity implements View.OnClickListener
Date datef = new Date();
CreateFoundObject upload = new CreateFoundObject(username,Title ,uri.toString(),"location", Desc,
"category", datef);
"category", datef,"found");
String uploadId = myRef.push().getKey();
Log.v("UploadID", uploadId);
myRef.child(uploadId).setValue(upload);
......@@ -188,7 +188,7 @@ public class FoundItem extends AppCompatActivity implements View.OnClickListener
Date datef = new Date();
Toast.makeText(FoundItem.this, "No file selected", Toast.LENGTH_SHORT).show();
CreateFoundObject upload = new CreateFoundObject(username,Title ,"NO-IMAGE","location", Desc,
"category", datef);
"category", datef,"found");
String uploadId = myRef.push().getKey();
Log.v("UploadID", uploadId);
myRef.child(uploadId).setValue(upload);
......
package com.example.instilostandfound;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import com.squareup.picasso.Picasso;
import java.util.List;
public class ImageAdapter extends RecyclerView.Adapter<ImageAdapter.ImageViewHolder> {
private Context mContext;
private List<CreateFoundObject> mUploads;
public ImageAdapter(Context context, List<CreateFoundObject> uploads) {
mContext = context;
mUploads = uploads;
}
@Override
public ImageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(mContext).inflate(R.layout.image_item, parent, false);
return new ImageViewHolder(v);
}
@Override
public void onBindViewHolder(ImageViewHolder holder, int position) {
CreateFoundObject uploadCurrent = mUploads.get(position);
holder.textViewName.setText(uploadCurrent.getmTitle());
Picasso.with(mContext)
.load(uploadCurrent.getImageUrl())
.placeholder(R.mipmap.ic_launcher)
.fit()
.centerCrop()
.into(holder.imageView);
}
@Override
public int getItemCount() {
return mUploads.size();
}
public class ImageViewHolder extends RecyclerView.ViewHolder {
public TextView textViewName;
public ImageView imageView;
public ImageViewHolder(View itemView) {
super(itemView);
textViewName = itemView.findViewById(R.id.text_view_name);
imageView = itemView.findViewById(R.id.image_view_upload);
}
}
}
......@@ -10,6 +10,10 @@ import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.Query;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
......@@ -22,6 +26,8 @@ public class MyPosts extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_posts);
DatabaseReference myRef = FirebaseDatabase.getInstance().getReference("FoundData");
Query queryRef = myRef.orderByChild("FoundData").equalTo("gooner");
final List<Map<String, String>> of = new ArrayList<Map<String, String>>();
final List<Map<String, String>> ol = new ArrayList<Map<String, String>>();
Map<String, String> of1 = new HashMap<String, String>();
......
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/text_view_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:text="Name"
android:textColor="@android:color/black"
android:textSize="20sp" />
<ImageView
android:id="@+id/image_view_upload"
android:layout_width="match_parent"
android:layout_height="200dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment