Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
InstiLostAndFound
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
MUTTINENI NAVYA
InstiLostAndFound
Commits
10ca7250
Commit
10ca7250
authored
Nov 26, 2019
by
ankitasingh
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
88051476
5c5f50ff
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
273 additions
and
115 deletions
+273
-115
app/src/main/java/com/example/instilostandfound/FoundItem.java
...rc/main/java/com/example/instilostandfound/FoundItem.java
+1
-11
app/src/main/java/com/example/instilostandfound/LostItem.java
...src/main/java/com/example/instilostandfound/LostItem.java
+11
-12
app/src/main/java/com/example/instilostandfound/MyPostsLostRV.java
...ain/java/com/example/instilostandfound/MyPostsLostRV.java
+137
-0
app/src/main/java/com/example/instilostandfound/NewsFeedLost.java
...main/java/com/example/instilostandfound/NewsFeedLost.java
+91
-0
app/src/main/java/com/example/instilostandfound/createDemo.java
...c/main/java/com/example/instilostandfound/createDemo.java
+0
-92
app/src/main/res/layout/activity_my_posts_lost_rv.xml
app/src/main/res/layout/activity_my_posts_lost_rv.xml
+17
-0
app/src/main/res/layout/activity_news_feed_lost.xml
app/src/main/res/layout/activity_news_feed_lost.xml
+16
-0
No files found.
app/src/main/java/com/example/instilostandfound/FoundItem.java
View file @
10ca7250
...
@@ -271,23 +271,13 @@ public class FoundItem extends AppCompatActivity implements View.OnClickListener
...
@@ -271,23 +271,13 @@ public class FoundItem extends AppCompatActivity implements View.OnClickListener
Toast
.
makeText
(
FoundItem
.
this
,
"SUBMIT SUCCESSFUL -NO IMAGE UPLOADED!"
,
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
FoundItem
.
this
,
"SUBMIT SUCCESSFUL -NO IMAGE UPLOADED!"
,
Toast
.
LENGTH_LONG
).
show
();
Intent
intent
=
new
Intent
(
FoundItem
.
this
,
MyPostsFoundRV
.
class
);
Intent
intent
=
new
Intent
(
FoundItem
.
this
,
MyPostsFoundRV
.
class
);
intent
.
putExtra
(
"username"
,
username
);
intent
.
putExtra
(
"username"
,
username
);
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
);
startActivity
(
intent
);
startActivity
(
intent
);
finish
();
finish
();
}
}
// String uploadurl = uploadSessionUri.toString();
// Log.v("Upload url",uploadurl);
/* createDemo upload = new createDemo(username,
Title, Desc, Place, Date);
String uploadId = myRef.push().getKey();
Log.v("UploadID", uploadId);
myRef.child(uploadId).setValue(upload);
title.setText("");
place.setText("");
desc.setText("");
Toast.makeText(FoundItem.this,"SUBMIT SUCCESSFUL",Toast.LENGTH_LONG).show();*/
}
}
private
String
getExtension
(
Uri
uri
)
private
String
getExtension
(
Uri
uri
)
...
...
app/src/main/java/com/example/instilostandfound/LostItem.java
View file @
10ca7250
...
@@ -9,7 +9,6 @@ import android.graphics.drawable.ColorDrawable;
...
@@ -9,7 +9,6 @@ import android.graphics.drawable.ColorDrawable;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
com.google.android.gms.tasks.OnFailureListener
;
import
com.google.android.gms.tasks.OnFailureListener
;
import
com.google.android.gms.tasks.OnSuccessListener
;
import
com.google.android.gms.tasks.OnSuccessListener
;
import
com.google.android.material.floatingactionbutton.FloatingActionButton
;
import
com.google.android.material.floatingactionbutton.FloatingActionButton
;
...
@@ -113,6 +112,10 @@ public class LostItem extends AppCompatActivity implements View.OnClickListener,
...
@@ -113,6 +112,10 @@ public class LostItem extends AppCompatActivity implements View.OnClickListener,
ArrayAdapter
<
String
>
adapter
=
new
ArrayAdapter
<>(
this
,
android
.
R
.
layout
.
simple_spinner_dropdown_item
,
items
);
ArrayAdapter
<
String
>
adapter
=
new
ArrayAdapter
<>(
this
,
android
.
R
.
layout
.
simple_spinner_dropdown_item
,
items
);
category
.
setAdapter
(
adapter
);
category
.
setAdapter
(
adapter
);
}
}
/**
*
*/
private
void
SubmitLost
()
{
private
void
SubmitLost
()
{
final
String
Title
=
title
.
getText
().
toString
().
trim
();
final
String
Title
=
title
.
getText
().
toString
().
trim
();
final
String
Place
=
place
.
getText
().
toString
().
trim
();
final
String
Place
=
place
.
getText
().
toString
().
trim
();
...
@@ -244,25 +247,21 @@ public class LostItem extends AppCompatActivity implements View.OnClickListener,
...
@@ -244,25 +247,21 @@ public class LostItem extends AppCompatActivity implements View.OnClickListener,
Toast
.
makeText
(
LostItem
.
this
,
"SUBMIT SUCCESSFUL -NO IMAGE UPLOADED!"
,
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
LostItem
.
this
,
"SUBMIT SUCCESSFUL -NO IMAGE UPLOADED!"
,
Toast
.
LENGTH_LONG
).
show
();
Intent
intent
=
new
Intent
(
LostItem
.
this
,
MyPostsLostRV
.
class
);
Intent
intent
=
new
Intent
(
LostItem
.
this
,
MyPostsLostRV
.
class
);
intent
.
putExtra
(
"username"
,
username
);
intent
.
putExtra
(
"username"
,
username
);
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
);
startActivity
(
intent
);
startActivity
(
intent
);
finish
();
finish
();
}
}
// String uploadurl = uploadSessionUri.toString();
// Log.v("Upload url",uploadurl);
/* createDemo upload = new createDemo(username,
Title, Desc, Place, Date);
String uploadId = myRef.push().getKey();
Log.v("UploadID", uploadId);
myRef.child(uploadId).setValue(upload);
title.setText("");
place.setText("");
desc.setText("");
Toast.makeText(FoundItem.this,"SUBMIT SUCCESSFUL",Toast.LENGTH_LONG).show();*/
}
}
/**
*
* @param uri
* @return
*/
private
String
getExtension
(
Uri
uri
)
private
String
getExtension
(
Uri
uri
)
{
{
ContentResolver
cr
=
getContentResolver
();
ContentResolver
cr
=
getContentResolver
();
...
...
app/src/main/java/com/example/instilostandfound/MyPostsLostRV.java
0 → 100644
View file @
10ca7250
package
com.example.instilostandfound
;
import
androidx.annotation.NonNull
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.view.View
;
import
android.widget.AdapterView
;
import
android.widget.Toast
;
import
com.google.android.gms.tasks.OnSuccessListener
;
import
com.google.firebase.database.ChildEventListener
;
import
com.google.firebase.database.DataSnapshot
;
import
com.google.firebase.database.DatabaseError
;
import
com.google.firebase.database.DatabaseReference
;
import
com.google.firebase.database.FirebaseDatabase
;
import
com.google.firebase.database.Query
;
import
com.google.firebase.database.ValueEventListener
;
import
com.google.firebase.storage.FirebaseStorage
;
import
com.google.firebase.storage.StorageReference
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
MyPostsLostRV
extends
AppCompatActivity
implements
MyPostsAdaptor
.
OnItemClickListener
,
Serializable
{
private
RecyclerView
mrecyclerView
;
private
MyPostsAdaptor
mAdaptor
;
private
DatabaseReference
mDatabaseRef
;
private
FirebaseStorage
mStorage
;
private
List
<
CreateFoundObject
>
mPosts
;
private
String
username
=
null
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_my_posts_lost_rv
);
username
=
getIntent
().
getStringExtra
(
"username"
);
mrecyclerView
=
findViewById
(
R
.
id
.
my_posts_rv
);
mrecyclerView
.
setHasFixedSize
(
true
);
mrecyclerView
.
setLayoutManager
(
new
LinearLayoutManager
(
this
));
mPosts
=
new
ArrayList
<>();
mDatabaseRef
=
FirebaseDatabase
.
getInstance
().
getReference
(
"LostData"
);
mStorage
=
FirebaseStorage
.
getInstance
();
Query
usernamequery
=
mDatabaseRef
.
orderByChild
(
"ldap"
).
equalTo
((
username
+
"@iitb.ac.in"
).
toLowerCase
());
Log
.
v
(
"query"
,
usernamequery
.
toString
());
usernamequery
.
addValueEventListener
(
new
ValueEventListener
()
{
@Override
public
void
onDataChange
(
@NonNull
DataSnapshot
dataSnapshot
)
{
for
(
DataSnapshot
postSnapShot
:
dataSnapshot
.
getChildren
()){
CreateFoundObject
post
=
postSnapShot
.
getValue
(
CreateFoundObject
.
class
);
post
.
setKey
(
postSnapShot
.
getKey
());
mPosts
.
add
(
post
);
}
mAdaptor
=
new
MyPostsAdaptor
(
MyPostsLostRV
.
this
,
mPosts
);
mrecyclerView
.
setAdapter
(
mAdaptor
);
mAdaptor
.
setOnItemClickListener
(
MyPostsLostRV
.
this
);
}
@Override
public
void
onCancelled
(
@NonNull
DatabaseError
databaseError
)
{
Toast
.
makeText
(
MyPostsLostRV
.
this
,
databaseError
.
getMessage
(),
Toast
.
LENGTH_SHORT
).
show
();
}
});
}
@Override
public
void
onItemClick
(
int
position
)
{
Log
.
v
(
"position ="
,
String
.
valueOf
(
position
));
CreateFoundObject
selectedItem
=
mPosts
.
get
(
position
);
final
String
selectedKey
=
selectedItem
.
getKey
();
Intent
intent
=
new
Intent
(
MyPostsLostRV
.
this
,
ItemDetails
.
class
);
intent
.
putExtra
(
"FoundObject"
,
selectedItem
);
intent
.
putExtra
(
"CallingClass"
,
"MyPosts"
);
intent
.
putExtra
(
"username"
,
username
);
startActivity
(
intent
);
}
@Override
public
void
oneditClick
(
int
position
)
{
Log
.
v
(
"position ="
,
String
.
valueOf
(
position
));
CreateFoundObject
selectedItem
=
mPosts
.
get
(
position
);
final
String
selectedKey
=
selectedItem
.
getKey
();
Intent
intent
=
new
Intent
(
MyPostsLostRV
.
this
,
LostItem
.
class
);
intent
.
putExtra
(
"FoundObject"
,
selectedItem
);
intent
.
putExtra
(
"CallingClass"
,
"MyPosts"
);
intent
.
putExtra
(
"username"
,
username
);
startActivity
(
intent
);
}
@Override
public
void
onDeleteClick
(
int
position
)
{
Log
.
v
(
"position ="
,
String
.
valueOf
(
position
));
CreateFoundObject
selectedItem
=
mPosts
.
get
(
position
);
final
String
selectedKey
=
selectedItem
.
getKey
();
Log
.
v
(
"selected key ="
,
selectedKey
);
Log
.
v
(
"url of image ="
,
selectedItem
.
getImageUrl
());
if
(
selectedItem
.
getImageUrl
()==
"NO-IMAGE"
)
{
StorageReference
imageRef
=
mStorage
.
getReferenceFromUrl
(
selectedItem
.
getImageUrl
());
imageRef
.
delete
().
addOnSuccessListener
(
new
OnSuccessListener
<
Void
>()
{
@Override
public
void
onSuccess
(
Void
aVoid
)
{
mDatabaseRef
.
child
(
selectedKey
).
removeValue
();
Toast
.
makeText
(
MyPostsLostRV
.
this
,
"Item deleted"
,
Toast
.
LENGTH_SHORT
).
show
();
Intent
intent
=
new
Intent
(
MyPostsLostRV
.
this
,
MyPostsLostRV
.
class
);
intent
.
putExtra
(
"username"
,
username
);
startActivity
(
intent
);
finish
();
}
});
}
else
{
mDatabaseRef
.
child
(
selectedKey
).
removeValue
();
Toast
.
makeText
(
MyPostsLostRV
.
this
,
"Item deleted"
,
Toast
.
LENGTH_SHORT
).
show
();
Intent
intent
=
new
Intent
(
MyPostsLostRV
.
this
,
MyPostsLostRV
.
class
);
intent
.
putExtra
(
"username"
,
username
);
startActivity
(
intent
);
finish
();
}
}
}
app/src/main/java/com/example/instilostandfound/NewsFeedLost.java
0 → 100644
View file @
10ca7250
package
com.example.instilostandfound
;
import
androidx.annotation.NonNull
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.util.Log
;
import
android.widget.Toast
;
import
com.google.android.gms.tasks.OnSuccessListener
;
import
com.google.firebase.database.DataSnapshot
;
import
com.google.firebase.database.DatabaseError
;
import
com.google.firebase.database.DatabaseReference
;
import
com.google.firebase.database.FirebaseDatabase
;
import
com.google.firebase.database.Query
;
import
com.google.firebase.database.ValueEventListener
;
import
com.google.firebase.storage.FirebaseStorage
;
import
com.google.firebase.storage.StorageReference
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
NewsFeedLost
extends
AppCompatActivity
implements
NewsfeedAdaptor
.
OnItemClickListener
,
Serializable
{
private
RecyclerView
mrecyclerView
;
private
NewsfeedAdaptor
mAdaptor
;
private
DatabaseReference
mDatabaseRef
;
private
FirebaseStorage
mStorage
;
private
List
<
CreateFoundObject
>
mPosts
;
private
String
username
=
null
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_news_feed_lost
);
username
=
getIntent
().
getStringExtra
(
"username"
);
mrecyclerView
=
findViewById
(
R
.
id
.
my_posts_rv
);
mrecyclerView
.
setHasFixedSize
(
true
);
mrecyclerView
.
setLayoutManager
(
new
LinearLayoutManager
(
this
));
mPosts
=
new
ArrayList
<>();
mDatabaseRef
=
FirebaseDatabase
.
getInstance
().
getReference
(
"LostData"
);
mStorage
=
FirebaseStorage
.
getInstance
();
//Query usernamequery = mDatabaseRef.orderByChild("ldap").equalTo((username+"@iitb.ac.in").toLowerCase());
//Log.v("query",usernamequery.toString());
mDatabaseRef
.
addValueEventListener
(
new
ValueEventListener
()
{
@Override
public
void
onDataChange
(
@NonNull
DataSnapshot
dataSnapshot
)
{
for
(
DataSnapshot
postSnapShot
:
dataSnapshot
.
getChildren
()){
CreateFoundObject
post
=
postSnapShot
.
getValue
(
CreateFoundObject
.
class
);
post
.
setKey
(
postSnapShot
.
getKey
());
mPosts
.
add
(
post
);
}
mAdaptor
=
new
NewsfeedAdaptor
(
NewsFeedLost
.
this
,
mPosts
);
mrecyclerView
.
setAdapter
(
mAdaptor
);
mAdaptor
.
setOnItemClickListener
(
NewsFeedLost
.
this
);
}
@Override
public
void
onCancelled
(
@NonNull
DatabaseError
databaseError
)
{
Toast
.
makeText
(
NewsFeedLost
.
this
,
databaseError
.
getMessage
(),
Toast
.
LENGTH_SHORT
).
show
();
}
});
}
@Override
public
void
onItemClick
(
int
position
)
{
Log
.
v
(
"position ="
,
String
.
valueOf
(
position
));
CreateFoundObject
selectedItem
=
mPosts
.
get
(
position
);
final
String
selectedKey
=
selectedItem
.
getKey
();
Intent
intent
=
new
Intent
(
NewsFeedLost
.
this
,
ItemClaim
.
class
);
intent
.
putExtra
(
"FoundObject"
,
selectedItem
);
intent
.
putExtra
(
"CallingClass"
,
"MyPosts"
);
intent
.
putExtra
(
"username"
,
username
);
startActivity
(
intent
);
}
}
app/src/main/java/com/example/instilostandfound/createDemo.java
deleted
100644 → 0
View file @
88051476
package
com.example.instilostandfound
;
import
com.google.firebase.auth.FirebaseAuth
;
import
com.google.firebase.database.Exclude
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
public
class
createDemo
{
//private String mImageUrl;
private
String
mKey
;
private
String
mTitle
;
private
String
mDate
;
private
String
mLDAP
;
private
String
mDescription
;
private
String
mLocation
;
// private String mCategory;
private
String
mDateFound
;
public
createDemo
()
{
}
public
createDemo
(
String
LDAPID
,
String
title
,
String
desc
,
String
location
,
String
datefound
)
{
if
(
LDAPID
.
trim
().
equals
(
""
))
{
mLDAP
=
"No Name"
;
}
//mLDAPID = LDAPID;
//mImageUrl = imageUrl;
mLDAP
=
LDAPID
;
mDescription
=
desc
;
mLocation
=
location
;
mDateFound
=
datefound
;
//mCategory = category;
mTitle
=
title
;
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"dd-MMM-yyyy"
);
Date
date
=
new
Date
();
mDate
=
df
.
format
(
date
);
}
public
String
getLDAP
()
{
return
mLDAP
;
}
public
void
setLDAP
(
String
LDAP
)
{
mLDAP
=
LDAP
;
}
public
String
getmTitle
()
{
return
mTitle
;
}
public
void
setmTitle
(
String
mTitle
)
{
this
.
mTitle
=
mTitle
;
}
public
String
getmDateFound
()
{
return
mDateFound
;
}
public
void
setmDateFound
(
String
dateFound
)
{
mDateFound
=
dateFound
;
}
public
String
getmDescription
()
{
return
mDescription
;
}
public
void
setmDescription
(
String
desc
)
{
mDescription
=
desc
;
}
public
String
getmLocation
()
{
return
mLocation
;}
public
void
setmLocation
(
String
location
)
{
mLocation
=
location
;}
@Exclude
public
String
getKey
()
{
return
mKey
;
}
@Exclude
public
void
setKey
(
String
key
)
{
mKey
=
key
;
}
public
String
getDate
()
{
return
mDate
;
}
public
void
setDate
(
String
date
)
{
mDate
=
date
;
}
}
app/src/main/res/layout/activity_my_posts_lost_rv.xml
0 → 100644
View file @
10ca7250
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
".MyPostsLostRV"
>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/my_posts_rv"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_alignParentStart=
"true"
android:layout_alignParentTop=
"true"
>
</androidx.recyclerview.widget.RecyclerView>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/layout/activity_news_feed_lost.xml
0 → 100644
View file @
10ca7250
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
".NewsFeedLost"
>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/my_posts_rv"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
</androidx.recyclerview.widget.RecyclerView>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment