-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Your Name
committed
Apr 23, 2018
1 parent
84aa31d
commit 0ccb970
Showing
31 changed files
with
333 additions
and
19 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
12 changes: 12 additions & 0 deletions
12
.idea/libraries/Gradle__com_android_support_design_27_1_1.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 4 additions & 4 deletions
8
...d_support_support_media_compat_26_1_0.xml → ...d_support_support_media_compat_27_1_1.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 4 additions & 4 deletions
8
...com_android_support_support_v4_26_1_0.xml → ...com_android_support_support_v4_27_1_1.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
.idea/libraries/Gradle__com_android_support_transition_27_1_1.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
app/src/main/java/com/project/wanderlust/JourneyLsitAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.project.wanderlust; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.graphics.Bitmap; | ||
import android.support.annotation.NonNull; | ||
import android.support.annotation.Nullable; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ArrayAdapter; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.ArrayList; | ||
import java.util.Date; | ||
|
||
public class JourneyLsitAdapter extends ArrayAdapter<JourneyMini> { | ||
private ArrayList<JourneyMini> items; | ||
private Bitmap userPic; | ||
private String userName; | ||
private LayoutInflater inflater; | ||
|
||
public JourneyLsitAdapter(Context context, ArrayList<JourneyMini> items, Bitmap userPic, String userName) { | ||
super(context, 0, items); | ||
this.items = items; | ||
this.userPic = userPic; | ||
this.userName = userName; | ||
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public JourneyMini getItem(int position) { | ||
return super.getItem(position); | ||
} | ||
|
||
@Override | ||
public int getCount() { | ||
return super.getCount(); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { | ||
if(position == 1) | ||
convertView = convertView; | ||
if(convertView == null) | ||
convertView = inflater.inflate(R.layout.journey_cell, null); | ||
JourneyMini item = getItem(position); | ||
((ImageView) convertView.findViewById(R.id.photo)).setImageBitmap(userPic); | ||
((TextView) convertView.findViewById(R.id.userName)).setText(userName); | ||
((TextView) convertView.findViewById(R.id.location)).setText(item.getLocation()); | ||
((TextView) convertView.findViewById(R.id.locationBroader)).setText(item.getBroaderLocation()); | ||
((TextView) convertView.findViewById(R.id.date)).setText(SharedFunctions.months[item.getDate().getMonth() - 1] + " " + item.getDate().getDate()); | ||
((TextView) convertView.findViewById(R.id.title)).setText(item.getTitle()); | ||
if(item.getBitmap() != null) { | ||
ImageView imageView = convertView.findViewById(R.id.journeyPic); | ||
imageView.setImageURI(item.getBitmap()); | ||
ViewGroup.LayoutParams layoutParams = imageView.getLayoutParams(); | ||
layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT; | ||
imageView.setLayoutParams(layoutParams); | ||
} | ||
|
||
convertView.setTag(item); | ||
convertView.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
JourneyMini journey = (JourneyMini) v.getTag(); | ||
if(journey != null) { | ||
Intent intent = new Intent(getContext(), ShowJourney.class); | ||
intent.putExtra("timestamp", new SimpleDateFormat(CreateJourneyActivity.DATE_FORMAT).format(journey.getDate())); | ||
getContext().startActivity(intent); | ||
} | ||
} | ||
}); | ||
return convertView; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.project.wanderlust; | ||
|
||
import android.net.Uri; | ||
|
||
import java.util.Date; | ||
|
||
public class JourneyMini { | ||
private String title; | ||
private Date date; | ||
private String location; | ||
private String broaderLoocation; | ||
private Uri bitmap; | ||
|
||
public JourneyMini(String title, Date date, String location, String broaderLocation, Uri bitmap) { | ||
this.title = title; | ||
this.date = date; | ||
this.location = location; | ||
this.broaderLoocation = broaderLocation; | ||
this.bitmap = bitmap; | ||
} | ||
|
||
public String getTitle() { return title; } | ||
|
||
public Date getDate() { return date; } | ||
|
||
public Uri getBitmap() { return bitmap; } | ||
|
||
public String getLocation() { return location; } | ||
|
||
public String getBroaderLocation() { return broaderLoocation; } | ||
} |
62 changes: 62 additions & 0 deletions
62
app/src/main/java/com/project/wanderlust/JourneysLsitActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,75 @@ | ||
package com.project.wanderlust; | ||
|
||
import android.content.Context; | ||
import android.content.ContextWrapper; | ||
import android.content.Intent; | ||
import android.graphics.Bitmap; | ||
import android.net.Uri; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.ListView; | ||
|
||
import com.google.firebase.auth.FirebaseAuth; | ||
import com.google.firebase.database.DataSnapshot; | ||
import com.google.firebase.database.DatabaseError; | ||
import com.google.firebase.database.FirebaseDatabase; | ||
import com.google.firebase.database.ValueEventListener; | ||
|
||
import java.io.File; | ||
import java.lang.reflect.Array; | ||
import java.text.ParseException; | ||
import java.text.SimpleDateFormat; | ||
import java.util.ArrayList; | ||
import java.util.Date; | ||
|
||
import de.hdodenhof.circleimageview.CircleImageView; | ||
|
||
public class JourneysLsitActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_journeys_lsit); | ||
|
||
ContextWrapper wrapper = new ContextWrapper(getApplicationContext()); | ||
File file = wrapper.getDir("profilePictures",MODE_PRIVATE); | ||
file = new File(file, FirebaseAuth.getInstance().getCurrentUser().getPhoneNumber() + ".jpg"); | ||
final Bitmap bitmap = SharedFunctions.decodeBitmapFromFile(file, 100, 100); | ||
//((CircleImageView) findViewById(R.id.userPhoto)).setImageBitmap(bitmap); | ||
final Context context = this; | ||
|
||
FirebaseDatabase.getInstance().getReference("Journeys").child(FirebaseAuth.getInstance().getCurrentUser().getPhoneNumber()) | ||
.addListenerForSingleValueEvent(new ValueEventListener() { | ||
@Override | ||
public void onDataChange(DataSnapshot dataSnapshot) { | ||
ContextWrapper wrapper = new ContextWrapper(getApplicationContext()); | ||
ArrayList<JourneyMini> journeys = new ArrayList<>(); | ||
SimpleDateFormat format = new SimpleDateFormat(CreateJourneyActivity.DATE_FORMAT); | ||
for(DataSnapshot ds : dataSnapshot.getChildren()) { | ||
try { | ||
Date date = format.parse(ds.getKey()); | ||
String title = ds.child(CreateJourneyActivity.TITLE).getValue(String.class); | ||
File file = wrapper.getDir(ds.getKey(), MODE_PRIVATE); | ||
Uri photo = null; | ||
if (file.isDirectory()) { | ||
String[] images = file.list(); | ||
if(images.length > 0) | ||
photo = Uri.parse(new File(file, images[0]).getAbsolutePath()); | ||
} | ||
journeys.add(new JourneyMini(title, date, "Faisal Town", "Lahore", photo)); | ||
} catch (ParseException e) {} | ||
} | ||
JourneyLsitAdapter adapter = new JourneyLsitAdapter(context, journeys, bitmap, "Farhan"); | ||
ListView view = findViewById(R.id.journeysList); | ||
view.setAdapter(adapter); | ||
} | ||
|
||
@Override public void onCancelled(DatabaseError databaseError) { } | ||
}); | ||
} | ||
|
||
public void createJourney(View view) { | ||
startActivity(new Intent(this, CreateJourneyActivity.class)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<!-- drawable/plus.xml --> | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:height="24dp" | ||
android:width="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24"> | ||
<path android:fillColor="#FFFFFF" android:pathData="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z" /> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.