Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #83

Merged
merged 60 commits into from
Nov 30, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
5c019fb
fix: [ #27 ] Current location will be set when app starts
CloudyPadmal Mar 30, 2017
64286b2
Merge pull request #29 from CloudyPadmal/currentLocation
Dilu9218 Apr 12, 2017
4473920
Added the switch activity switching between private and public reposi…
icancode23 Jun 19, 2017
81f2eed
resolving conflicts
icancode23 Jun 19, 2017
3a78807
Merge branch 'master' into develop
icancode23 Jun 19, 2017
26b85ae
ignore google services
icancode23 Jun 19, 2017
eb9d22b
added the original google services json
icancode23 Jun 19, 2017
f125c79
Minor change Switch activity for public and private vehicles ready
icancode23 Jun 19, 2017
4639492
Added the HomeBaseScreen
icancode23 Jun 19, 2017
5f86b14
Facebook profile extracted person registered as a user in firebase db
icancode23 Jun 23, 2017
ae64dfa
Merge pull request #70 from KuteGSOC/HomeBaseScreen
NickHub4017 Jun 23, 2017
af7dd27
Added Feature for Friend Profile Viewing also improved fragment flow…
icancode23 Jun 25, 2017
db1049a
Replaced google services json and removed my own keys
icancode23 Jun 25, 2017
e3dd479
Code Refactor to remove unnecessary spaces between brackets and unne…
icancode23 Jun 26, 2017
2c30d1d
Replaced google services json and removed my own keys
icancode23 Jun 26, 2017
6d18f95
Merge pull request #71 from KuteGSOC/ConnectViewFriends
NickHub4017 Jun 30, 2017
ab5d123
Some Changes
icancode23 Jul 3, 2017
cc50fe7
Added the feature for custom profile Image
icancode23 Jul 3, 2017
377c596
Changed the layout a bit
icancode23 Jul 3, 2017
b4fa3f9
minor change
icancode23 Jul 5, 2017
44e7266
check
icancode23 Jul 5, 2017
e3df3b7
minor change
icancode23 Jul 5, 2017
a4eb9bd
minor change
icancode23 Jul 5, 2017
d610803
Completed profile edit without integrating edit profile image
icancode23 Jul 6, 2017
14af78b
Merge pull request #72 from KuteGSOC/ProfilePictureEdit
NickHub4017 Jul 7, 2017
35af0b9
midway
icancode23 Jul 7, 2017
f5ed115
Replaced google services and removed self ids from strings
icancode23 Jul 7, 2017
2c303cd
few changes
icancode23 Jul 7, 2017
31bd401
dialog layouts done
icancode23 Jul 7, 2017
fffefde
Deleted some test data sent to git by mistake
icancode23 Jul 7, 2017
4418eac
Complete But not tested
icancode23 Jul 9, 2017
bd86bf1
Dynamic loading of friends using a pull to load recycler view
icancode23 Jul 11, 2017
b4d654e
minor change
icancode23 Jul 12, 2017
11b210e
Merge pull request #73 from KuteGSOC/UserSelfProfileFilling
NickHub4017 Jul 14, 2017
60dff52
small fix
icancode23 Jul 17, 2017
4139a2c
Support for base64 in recycler
icancode23 Jul 21, 2017
9ac333c
replaced google services json
icancode23 Jul 22, 2017
6f7bb5e
fix
icancode23 Jul 22, 2017
7d9e9f8
fix
icancode23 Jul 22, 2017
ef597b2
fix
icancode23 Jul 22, 2017
742ab5c
fix
icancode23 Jul 22, 2017
a73774b
Merge pull request #75 from KuteGSOC/WorkflowFix
NickHub4017 Jul 22, 2017
45a03f5
added routes backend
icancode23 Aug 3, 2017
c75a11d
added routes backend
icancode23 Aug 3, 2017
c65ff11
Merge pull request #76 from KuteGSOC/routesBackend
NickHub4017 Aug 4, 2017
ba5d489
check
icancode23 Aug 13, 2017
f7c04e6
Majorly Complete
icancode23 Aug 21, 2017
64d2e67
Majorly Complete
icancode23 Aug 21, 2017
061a655
Added backend project
icancode23 Aug 21, 2017
b94523a
Added backend project
icancode23 Aug 21, 2017
f0a44f6
Added backend project
icancode23 Aug 21, 2017
e8360b0
Added Send Notification end point on server
icancode23 Aug 22, 2017
7e687e7
Added Send Notification end point on server
icancode23 Aug 22, 2017
67fed75
Merge pull request #77 from KuteGSOC/TripUI
NickHub4017 Aug 23, 2017
dec96c8
Beta Done and completed
icancode23 Aug 26, 2017
b68a026
Beta Done and completed
icancode23 Aug 26, 2017
512d728
Beta Backend
icancode23 Aug 26, 2017
07cd0a8
Beta Backend
icancode23 Aug 26, 2017
ddf5023
Merge pull request #78 from KuteGSOC/BetaComplete
NickHub4017 Aug 26, 2017
b123d3e
Merge branch 'master' into develop
NickHub4017 Nov 30, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Dynamic loading of friends using a pull to load recycler view
  • Loading branch information
icancode23 committed Jul 11, 2017
commit bd86bf15871b7c88ea73f1e4d9d6429986682263
2 changes: 1 addition & 1 deletion kute-android-app/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions kute-android-app/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,15 @@
android:name=".PrivateVehicles.App.Activities.test"
android:label="@string/title_activity_test"
android:theme="@style/AppTheme">

</activity>
<activity android:name=".PrivateVehicles.App.Activities.ProfilePictureActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>

</activity>
<activity android:name=".PrivateVehicles.App.Activities.ProfilePictureActivity">

</activity>
</application>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
import android.widget.ProgressBar;

import com.scorelab.kute.kute.PrivateVehicles.App.Adapters.FriendRecyclerAdapter;
import com.scorelab.kute.kute.PrivateVehicles.App.AsyncTasks.LoadFirebaseFriends;
import com.scorelab.kute.kute.PrivateVehicles.App.DataModels.Person;
import com.scorelab.kute.kute.PrivateVehicles.App.Interfaces.AsyncTaskListener;
import com.scorelab.kute.kute.PrivateVehicles.App.Interfaces.RecyclerItemClick;
import com.scorelab.kute.kute.R;
import java.util.ArrayList;



public class CurrentFriendList extends AppCompatActivity implements RecyclerItemClick {
//We can optimize the loading of friends by restricting firebase content to return just two fields for each user and then retrieve detail only when specific persons detail activity is opened
public class CurrentFriendList extends AppCompatActivity implements RecyclerItemClick,AsyncTaskListener {
static String TAG = "CurrentFriendActivity";
ArrayList<String> person_list;
ArrayList<Person>person_detail_list;
Expand All @@ -29,15 +31,19 @@ public class CurrentFriendList extends AppCompatActivity implements RecyclerItem
final int[] pastVisiblesItems = new int[1];
final int[] visibleItemCount = new int[1];
final int[] totalItemCount = new int[1];
int start_index_async,last_index_async,range;
ProgressBar progressBar;
boolean is_async_task_running=false;// A boolean created to prevent a new asynctask being created everytime we scroll down
LoadFirebaseFriends load_friends_async;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.current_friends_activity);
person_list = new ArrayList<String>();
person_detail_list=(ArrayList<Person>) getIntent().getSerializableExtra("FriendList");
person_list = (ArrayList<String>)getIntent().getSerializableExtra("FriendList");
person_detail_list=(ArrayList<Person>) getIntent().getSerializableExtra("FriendDetailList");
/************** Initialise the views *********/
//TODO get friends from facebook and google and get their images
Log.d(TAG,"The length of the person list is:"+Integer.toString(person_list.size()));
progressBar=(ProgressBar)findViewById(R.id.progressBar);
back = (ImageButton) findViewById(R.id.backNav);
back.setOnClickListener(new View.OnClickListener() {
Expand All @@ -60,24 +66,18 @@ public void onScrolled(RecyclerView recyclerView,
visibleItemCount[0] = mLayoutManager.getChildCount();//Gives the number of children currently on the screen
totalItemCount[0] = mLayoutManager.getItemCount();//gives total items of recycler view
pastVisiblesItems[0] = mLayoutManager.findFirstVisibleItemPosition();//gives the index of item at the top of the screen

Log.d("Recycler",String.format("visible %d past visible %d total %d",visibleItemCount[0],pastVisiblesItems[0],totalItemCount[0]));
if ((visibleItemCount[0] + pastVisiblesItems[0]) >= totalItemCount[0]) {
Log.d("Check it",String.format("%d %d",mLayoutManager.findLastCompletelyVisibleItemPosition(),recycler_adapter.getItemCount()));
if ((visibleItemCount[0] + pastVisiblesItems[0]) >= totalItemCount[0]&& visibleItemCount[0]!=totalItemCount[0] ) {
if(mLayoutManager.findLastCompletelyVisibleItemPosition()==recycler_adapter.getItemCount()-1 /*&& recycleradapter.getItemCount()>5 You have your ofset values here*/){
//************************* Reached the End of recycler View ***********/
Log.d("Status","reached the Bottom");
//************** Set The visibility of progress bar as true *****/
progressBar.setVisibility(View.VISIBLE);
Log.d(TAG,"reached the Bottom");
//******************** Call The function to load more data *********//
loadRecyclerItems(recycler_adapter.getItemCount());


loadRecyclerItems(recycler_adapter.getItemCount()-1);
}

}
}
});

}

@Override
Expand All @@ -88,16 +88,61 @@ public void onRecyclerItemClick(int position) {
i.putExtra("isAFriend", true);
startActivity(i);
}
//Asynctask Interacting interface
@Override
public void onTaskStarted(Object...attachments) {
//toggle the boolean to show that asynctask is running
is_async_task_running=true;
//get the index from asynctask
start_index_async=(int)attachments[0];
last_index_async=(int)attachments[1];
range=last_index_async-last_index_async+1;

}

@Override
public void onTaskCompleted(Object attachment) {
Log.d(TAG,"The start indice is "+Integer.toString(start_index_async));
Person temp=(Person)attachment;
person_detail_list.add(temp);
Log.d(TAG,"Received in test Friend name: "+temp.name);
if(start_index_async>=last_index_async) {
recycler_adapter.notifyItemRangeInserted(recycler_adapter.getItemCount(),range);
is_async_task_running=false;
Log.d(TAG,"Current Length Of Recycler is"+Integer.toString(recycler_adapter.getItemCount()-1));
progressBar.setVisibility(View.GONE);
}
++start_index_async;

}

/***************** Custom Function ******/
private void loadRecyclerItems(Integer current_length)
{
Log.d(TAG,"Current size is "+Integer.toString(recycler_adapter.getItemCount()));
if(person_list.size()==current_length){
//When we have loaded all the items
Log.d("check","Yes");
}
else{

else {
//************** Set The visibility of progress bar as true *****/
progressBar.setVisibility(View.VISIBLE);
int difference = person_list.size() - current_length;
//we need to load more friends from facebook
if (!is_async_task_running) {
load_friends_async=new LoadFirebaseFriends(person_list,this);
if (difference < 9) {
load_friends_async.execute(current_length+1, (person_list.size()-1));
}else {
load_friends_async.execute(current_length+1,current_length+9);
}
}
}
}

@Override
protected void onStop() {
super.onStop();
load_friends_async.cancel(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,51 @@

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.Task;
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.ValueEventListener;
import com.scorelab.kute.kute.PrivateVehicles.App.AsyncTasks.LoadFirebaseFriends;
import com.scorelab.kute.kute.PrivateVehicles.App.DataModels.Person;
import com.scorelab.kute.kute.PrivateVehicles.App.Fragments.HomeBaseFragment;
import com.scorelab.kute.kute.PrivateVehicles.App.Interfaces.AsyncTaskListener;
import com.scorelab.kute.kute.R;

import java.util.ArrayList;

public class test extends AppCompatActivity {
public class test extends AppCompatActivity implements AsyncTaskListener {
Button b;
ArrayList<Person>list;
LoadFirebaseFriends load_friends_async;
ArrayList<String> friend_list;
String TAG="Test";
int start_index_async,last_index_async;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
b=(Button)findViewById(R.id.testButton);
friend_list=new ArrayList<String>();
list=new ArrayList<Person>();
for (int i=0;i<10;++i)
{
Person temp=new Person("Nipun","10110101010110101");
list.add(temp);

}

b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i=new Intent(getApplicationContext(),CurrentFriendList.class);
i.putExtra("FriendList",list);
startActivity(i);
//addTestFriends();
getFirebaseFriend();
}
});
setSupportActionBar(toolbar);
Expand All @@ -50,5 +60,75 @@ public void onClick(View view) {
});
}

private void addTestFriends(){
DatabaseReference ref= FirebaseDatabase.getInstance().getReference();
DatabaseReference friend_ref=ref.child("Friends/Nipun Arora");
DatabaseReference user_ref=ref.child("Users");
final String[]names={"Nipun","Harsh","Sukhad","Vishrut","jwalin","Shivam","Jatin","Archit","Shubham","Rajat"};
list=new ArrayList<Person>();
for (int i=0;i<10;++i)
{
String key=user_ref.push().getKey();
final Person temp=new Person(key,names[i]);
user_ref.child(key).setValue(temp).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.v("test","Failed as"+e.toString());
}
});
friend_ref.child(key).setValue("true");
Log.v("testit","Added "+names[i]);

}
}

//Asynctask Interacting interface
@Override
public void onTaskStarted(Object...attachments) {
//get the index from asynctask
start_index_async=(int)attachments[0];
last_index_async=(int)attachments[1];
}

@Override
public void onTaskCompleted(Object attachment) {
Log.d(TAG,"The start indice is "+Integer.toString(start_index_async));
Person temp=(Person)attachment;
list.add(temp);
Log.d(TAG,"Received in test Friend name: "+temp.name);
if(start_index_async>=last_index_async) {
Log.d(TAG,"called");
Intent i = new Intent(test.this, CurrentFriendList.class);
i.putExtra("FriendList", friend_list);
i.putExtra("FriendDetailList", list);
startActivity(i);
}
++start_index_async;

}

public void getFirebaseFriend() {
/******************** Getting Friends From Firebase *************/
String ref = "Friends/" +"Nipun Arora";
Log.d(TAG, "Firebase Reference :" + ref);
DatabaseReference friends = FirebaseDatabase.getInstance().getReference(ref);
friends.keepSynced(true);
friends.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot k : dataSnapshot.getChildren()) {
friend_list.add(k.getKey());
Log.d(TAG, "Debug Firebase data query" + k.getValue().toString());
}

Log.d(TAG, String.format("The Friend List Size is %d",friend_list.size()));
load_friends_async=new LoadFirebaseFriends(friend_list,test.this);
load_friends_async.execute(0,8);
}

@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package com.scorelab.kute.kute.PrivateVehicles.App.AsyncTasks;

import android.content.Intent;
import android.content.IntentFilter;
import android.os.AsyncTask;
import android.util.Log;

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.scorelab.kute.kute.PrivateVehicles.App.DataModels.Person;
import com.scorelab.kute.kute.PrivateVehicles.App.Interfaces.AsyncTaskListener;

import java.lang.ref.WeakReference;
import java.util.ArrayList;

/**
* Created by nipunarora on 10/07/17.
*/

public class LoadFirebaseFriends extends AsyncTask<Integer,Void,Void> {
ArrayList<String>friend_list;
WeakReference<AsyncTaskListener> async_task_listener;
String TAG="LoadFirebaseFriend";

public LoadFirebaseFriends(ArrayList<String>friend_list, AsyncTaskListener asyncTaskListener) {
this.friend_list=friend_list;
this.async_task_listener=new WeakReference<AsyncTaskListener>(asyncTaskListener);

}

@Override
protected Void doInBackground(Integer... params) {
//Through params we can pass the indices for which data is required
Log.v(TAG,"The indices received here are "+Integer.toString(params[0])+"and "+Integer.toString(params[1]));
final ArrayList<Person>person_detail_list=new ArrayList<Person>();
DatabaseReference users= FirebaseDatabase.getInstance().getReference("Users");
final AsyncTaskListener taskListener=async_task_listener.get();
taskListener.onTaskStarted(params[0],params[1]);
for(int i=params[0];i<=params[1];++i) {
Log.v(TAG,"The size in asynctask is"+Integer.toString(friend_list.size()));
if (i<friend_list.size()) {
Log.v(TAG,"Status:entered");
String first_friend_key = friend_list.get(i);
Query get_friend = users.orderByKey().equalTo(first_friend_key);
get_friend.keepSynced(true);
get_friend.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Person p = dataSnapshot.getChildren().iterator().next().getValue(Person.class);
if(async_task_listener!=null){
//Check if the weak reference still exists
Log.v(TAG,"Retrieved Friend "+p.name);
taskListener.onTaskCompleted(p);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
else {
Log.v(TAG,"All Friends Already Downloaded");
break;
}
}
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ public Person(String id, String name) {
this.other_details="--";
this.route_list=null;*/
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ public void onDetach() {
}
/********************* Custom Functions *************/
//Receive Message from Activity and other fragments
public void receiveMessage(String Action,Object friend_list,Object person_detail_list )
public void receiveMessage(String Action,Object...attachment )
{
Log.d(TAG,"Message Received : "+Action);
switch (Action)
{
case "Friends_Ready":
friendslist=(ArrayList<String>)friend_list;
friend_detail_list=(ArrayList<Person>) person_detail_list;
friendslist=(ArrayList<String>)attachment[0];
friend_detail_list=(ArrayList<Person>)attachment[1];
if(friendslist.size()>0) {
setupCurrentFriends();
}
Expand Down
Loading