Commit a059f3b0 authored by MUTTINENI NAVYA's avatar MUTTINENI NAVYA

fetching data from db in myposts

parent 9243683f
<component name="libraryTable">
<library name="Gradle: androidx.annotation:annotation:1.1.0@jar">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/androidx.annotation/annotation/1.1.0/e3a6fb2f40e3a3842e6b7472628ba4ce416ea4c8/annotation-1.1.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/androidx.annotation/annotation/1.1.0/408af38ec57369afe3fd6466e1c4bfdd5f15fc92/annotation-1.1.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/androidx.annotation/annotation/1.1.0/8b7bdc00eb4d998bfbc76767b098620990f2a805/annotation-1.1.0-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Gradle: com.google.firebase:firebase-common:19.2.0@aar">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/61c47ccf880e44b6c829a8c9a48ba20d/firebase-common-19.2.0/jars/classes.jar!/" />
<root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/61c47ccf880e44b6c829a8c9a48ba20d/firebase-common-19.2.0/res" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.firebase/firebase-common/19.2.0/c40d2fb997bcb31bc7666513543aa0ec3e698461/firebase-common-19.2.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.firebase/firebase-common/19.2.0/63c13ebb4ad7b1a2e0c317ae843eb342e4041511/firebase-common-19.2.0-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Gradle: com.google.firebase:firebase-database:19.2.0@aar">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/463da60977420e86b3b59aa784a805a0/firebase-database-19.2.0/jars/classes.jar!/" />
<root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/463da60977420e86b3b59aa784a805a0/firebase-database-19.2.0/res" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.firebase/firebase-database/19.2.0/bda77c37621ef4a9268924be507dc28e5328598c/firebase-database-19.2.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.firebase/firebase-database/19.2.0/7ecd17c12939ca0a6e20f902c3f726d914fb3aa1/firebase-database-19.2.0-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Gradle: com.google.firebase:firebase-database-collection:17.0.0@aar">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/a1c42ee6a43c1fec1cd0f12b759d080b/firebase-database-collection-17.0.0/jars/classes.jar!/" />
<root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/a1c42ee6a43c1fec1cd0f12b759d080b/firebase-database-collection-17.0.0/res" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.firebase/firebase-database-collection/17.0.0/e4dd7ee66b776966452b4760ca297fe1ea256bad/firebase-database-collection-17.0.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES />
</library>
</component>
\ No newline at end of file
<component name="libraryTable">
<library name="Gradle: com.google.firebase:firebase-storage:19.1.0@aar">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/1db2d38b309a85c11f57219f5bbd1ccf/firebase-storage-19.1.0/jars/classes.jar!/" />
<root url="file://$USER_HOME$/.gradle/caches/transforms-2/files-2.1/1db2d38b309a85c11f57219f5bbd1ccf/firebase-storage-19.1.0/res" />
</CLASSES>
<JAVADOC>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.firebase/firebase-storage/19.1.0/db75b30525f2fd559b56fd1a275c66f183969147/firebase-storage-19.1.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.google.firebase/firebase-storage/19.1.0/553c23659c39b1e6375f76b308e8dcdd3522e570/firebase-storage-19.1.0-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<activity android:name=".RedirectMyPosts"></activity> <activity android:name=".MyPostsFoundRV" />
<activity android:name=".RedirectMyPosts"/>
<activity android:name=".ItemDetails" /> <activity android:name=".ItemDetails" />
<activity android:name=".MyPosts" /> <activity android:name=".MyPosts" />
<activity <activity
......
package com.example.instilostandfound; package com.example.instilostandfound;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import android.os.Bundle; import android.os.Bundle;
import android.widget.Toast;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase; import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class MyPosts_rv extends AppCompatActivity { public class MyPostsFoundRV extends AppCompatActivity {
private RecyclerView mrecyclerView; private RecyclerView mrecyclerView;
private MyPostsAdaptor myPostsAdaptor; private MyPostsAdaptor mAdaptor;
private DatabaseReference mDatabaseRef; private DatabaseReference mDatabaseRef;
private List<CreateFoundObject> mPosts; private List<CreateFoundObject> mPosts;
...@@ -22,7 +27,7 @@ public class MyPosts_rv extends AppCompatActivity { ...@@ -22,7 +27,7 @@ public class MyPosts_rv extends AppCompatActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_posts_rv); setContentView(R.layout.activity_my_posts_found_rv);
mrecyclerView = findViewById(R.id.my_posts_rv); mrecyclerView = findViewById(R.id.my_posts_rv);
mrecyclerView.setHasFixedSize(true); mrecyclerView.setHasFixedSize(true);
...@@ -31,5 +36,24 @@ public class MyPosts_rv extends AppCompatActivity { ...@@ -31,5 +36,24 @@ public class MyPosts_rv extends AppCompatActivity {
mPosts = new ArrayList<>(); mPosts = new ArrayList<>();
mDatabaseRef = FirebaseDatabase.getInstance().getReference("FoundItems"); mDatabaseRef = FirebaseDatabase.getInstance().getReference("FoundItems");
mDatabaseRef.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for(DataSnapshot postSnapShot : dataSnapshot.getChildren()){
CreateFoundObject post = postSnapShot.getValue(CreateFoundObject.class);
mPosts.add(post);
}
mAdaptor = new MyPostsAdaptor(MyPostsFoundRV.this, mPosts);
mrecyclerView.setAdapter(mAdaptor);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
Toast.makeText(MyPostsFoundRV.this, databaseError.getMessage(), Toast.LENGTH_SHORT).show();
}
});
} }
} }
...@@ -29,7 +29,7 @@ public class RedirectMyPosts extends AppCompatActivity implements View.OnClickLi ...@@ -29,7 +29,7 @@ public class RedirectMyPosts extends AppCompatActivity implements View.OnClickLi
startActivity(intent); startActivity(intent);
break; break;
case R.id.found_button: case R.id.found_button:
intent = new Intent(RedirectMyPosts.this, MyPosts.class); intent = new Intent(RedirectMyPosts.this, MyPostsFoundRV.class);
intent.putExtra("username", username); intent.putExtra("username", username);
intent.putExtra("type", "found"); intent.putExtra("type", "found");
startActivity(intent); startActivity(intent);
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".MyPosts_rv"> tools:context=".MyPostsFoundRV">
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/my_posts_rv" android:id="@+id/my_posts_rv"
......
...@@ -4,5 +4,5 @@ ...@@ -4,5 +4,5 @@
# Location of the SDK. This is only used by Gradle. # Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the # For customization when using a Version Control System, please read the
# header note. # header note.
#Tue Oct 29 18:25:40 IST 2019 #Mon Nov 04 22:52:49 IST 2019
sdk.dir=/home/chikki/Android/Sdk sdk.dir=/home/navya/Android/Sdk
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