Skip to content

Instantly share code, notes, and snippets.

View biodunalfet's full-sized avatar

Hamza Fetuga biodunalfet

View GitHub Profile
//Here's the sign-in button
Button s= (Button)findViewById(R.id.buttons);
access= new Access(this);
s.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view){
//Build the GitKitClient
client= access.startAuth();
@biodunalfet
biodunalfet / Deploy to live server
Last active May 14, 2016 11:51
Files for the Getting Started with Google App Engine for the Google Cloud Platform Next Extended 2016 Ibadan event delivered by Hamza Fetuga (hfetuga@gmail.com)
gcloud preview app deploy app.yaml
recycler.setAdapter(new RecyclerAdapter(recycler));
recycler.setLayoutManager(new LinearLayoutManager(this));
public void setParent(){
for (int x = 0; x < datas.size(); x++){
Person person = datas.get(x);
general.add(person);
children.add(0);
person.setChildrenVisible(false);
Friend[] friends = person.getFriends();
for (int y = 0; y < friends.length; y++){
Friend f = friends[y];
public static class ChildViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
public TextView viewID;
public TextView parentID;
public TextView text;
public ChildViewHolder(View itemView) {
super(itemView);
viewID = (TextView) itemView.findViewById(R.id.fid);
public int getItemViewType(int position) {
if (general.get(position).isParent()){
return PARENT;
}
else{
return CHILD;
}
}
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (holder.getItemViewType() == CHILD){
TextView viewID = ((ChildViewHolder)holder).viewID;
TextView parentID = ((ChildViewHolder)holder).parentID;
TextView text = ((ChildViewHolder)holder).text;
Friend friend = (Friend) general.get(position);
viewID.setText(friend.getId());
parentID.setText(friend.getParentID());
if (person.getFriends().length != 0){
//is view expanded?
if (person.isChildrenVisible()){
person.setChildrenVisible(false);
Friend[] friends = person.getFriends();
for (int i = id + 1; i < (id + 1 + friends.length); i++){
general.remove(id+1);
}
Log.d("general size is ", general.size()+"");
else {
person.setChildrenVisible(true);
Friend[] friends = person.getFriends();
int index = 0;
for (int i = id + 1; i < (id + 1 + friends.length); i++){
general.add(i, friends[index]);
index++;
}
int lastVisibleItemPosition = ((LinearLayoutManager)recyclerAdapter.recyclerView.
getLayoutManager()).findLastCompletelyVisibleItemPosition();
if ((id + 1) < general.size()) {
if ((id + 1) > lastVisibleItemPosition) {
recyclerAdapter.recyclerView.scrollToPosition(id + 1);
}
}