com.eveningoutpost.dexdrip.ShareModels.Models.ExistingFollower Java Examples

The following examples show how to use com.eveningoutpost.dexdrip.ShareModels.Models.ExistingFollower. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ShareRest.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
public void getContacts(Callback<List<ExistingFollower>> existingFollowerListener) {
    dexcomShareApi.getContacts(getSessionId()).enqueue(new AuthenticatingCallback<List<ExistingFollower>>(existingFollowerListener) {
        @Override
        public void onRetry() {
            dexcomShareApi.getContacts(getSessionId()).enqueue(this);
        }
    });
}
 
Example #2
Source File: FollowerManagementActivity.java    From xDrip-Experimental with GNU General Public License v3.0 5 votes vote down vote up
private void populateFollowerList() {
    existingFollowerListener = new Callback<List<ExistingFollower>>() {
        @Override
        public void onResponse(Response<List<ExistingFollower>> response, Retrofit retrofit) {
            List<ExistingFollower> existingFollowers = response.body();
            if (followerListAdapter != null) {
                existingFollowerList.clear();
                if (existingFollowers != null && existingFollowers.size() > 0)
                    existingFollowerList.addAll(existingFollowers);
                followerListAdapter.notifyDataSetChanged();
            } else {
                if (existingFollowers != null && existingFollowers.size() > 0) {
                    existingFollowerList = existingFollowers;
                    followerListAdapter = new FollowerListAdapter(getApplicationContext(), shareRest, existingFollowerList);
                    existingFollowersView.setAdapter(followerListAdapter);
                }
            }
        }

        @Override
        public void onFailure(Throwable t) {
            Toast.makeText(FollowerManagementActivity.this, "Failed to retrieve follower list: " + t.getMessage(), Toast.LENGTH_LONG).show();
            // If it fails, don't show followers.
        }
    };

    shareRest.getContacts(existingFollowerListener);

}
 
Example #3
Source File: FollowerListAdapter.java    From xDrip-Experimental with GNU General Public License v3.0 5 votes vote down vote up
@Override
public View getView(final int position, final View convertView, ViewGroup parent) {
    View view = convertView;
    if (view == null) {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = inflater.inflate(R.layout.item_follower, null);
    }
    TextView followerName = (TextView) view.findViewById(R.id.follwerName);
    Button deleteButton = (Button) view.findViewById(R.id.deleteFollower);

    final ExistingFollower follower = list.get(position);

    followerName.setText(follower.ContactName);
    deleteButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Callback<ResponseBody> deleteFollowerListener = new Callback<ResponseBody>() {
                @Override
                public void onResponse(Response<ResponseBody> response, Retrofit retrofit) {
                    if (response.isSuccess()) {
                        Toast.makeText(context, "Follower deleted succesfully", Toast.LENGTH_LONG).show();
                        list.remove(position);
                        notifyDataSetChanged();
                    } else {
                        Toast.makeText(context, "Failed to delete follower", Toast.LENGTH_LONG).show();
                    }
                }

                @Override
                public void onFailure(Throwable t) {
                    Toast.makeText(context, "Failed to delete follower", Toast.LENGTH_LONG).show();
                }
            };
            shareRest.deleteContact(follower.ContactId, deleteFollowerListener);
        }
    });
    return view;
}
 
Example #4
Source File: ShareRest.java    From xDrip-Experimental with GNU General Public License v3.0 5 votes vote down vote up
public void getContacts(Callback<List<ExistingFollower>> existingFollowerListener) {
    try {
        dexcomShareApi.getContacts(getSessionId()).enqueue(new AuthenticatingCallback<List<ExistingFollower>>(existingFollowerListener) {
            @Override
            public void onRetry() {
                dexcomShareApi.getContacts(getSessionId()).enqueue(this);
            }
        });
    } catch (ShareException e) {
        existingFollowerListener.onFailure(e);
    }
}
 
Example #5
Source File: FollowerManagementActivity.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private void populateFollowerList() {
    existingFollowerListener = new Callback<List<ExistingFollower>>() {
        @Override
        public void onResponse(Response<List<ExistingFollower>> response, Retrofit retrofit) {
            List<ExistingFollower> existingFollowers = response.body();
            if (followerListAdapter != null) {
                existingFollowerList.clear();
                if (existingFollowers != null && existingFollowers.size() > 0)
                    existingFollowerList.addAll(existingFollowers);
                followerListAdapter.notifyDataSetChanged();
            } else {
                if (existingFollowers != null && existingFollowers.size() > 0) {
                    existingFollowerList = existingFollowers;
                    followerListAdapter = new FollowerListAdapter(getApplicationContext(), shareRest, existingFollowerList);
                    existingFollowersView.setAdapter(followerListAdapter);
                }
            }
        }

        @Override
        public void onFailure(Throwable t) {
            // If it fails, don't show followers.
        }
    };

    shareRest.getContacts(existingFollowerListener);

}
 
Example #6
Source File: FollowerListAdapter.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
@Override
public View getView(final int position, final View convertView, ViewGroup parent) {
    View view = convertView;
    if (view == null) {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = inflater.inflate(R.layout.item_follower, null);
    }
    TextView followerName = (TextView) view.findViewById(R.id.follwerName);
    Button deleteButton = (Button) view.findViewById(R.id.deleteFollower);

    final ExistingFollower follower = list.get(position);

    followerName.setText(follower.ContactName);
    deleteButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Callback<ResponseBody> deleteFollowerListener = new Callback<ResponseBody>() {
                @Override
                public void onResponse(Response<ResponseBody> response, Retrofit retrofit) {
                    if (response.isSuccess()) {
                        Toast.makeText(context, gs(R.string.follower_deleted_succesfully), Toast.LENGTH_LONG).show();
                        list.remove(position);
                        notifyDataSetChanged();
                    } else {
                        Toast.makeText(context, gs(R.string.failed_to_delete_follower), Toast.LENGTH_LONG).show();
                    }
                }

                @Override
                public void onFailure(Throwable t) {
                    Toast.makeText(context, gs(R.string.failed_to_delete_follower), Toast.LENGTH_LONG).show();
                }
            };
            shareRest.deleteContact(follower.ContactId, deleteFollowerListener);
        }
    });
    return view;
}
 
Example #7
Source File: ShareRest.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public void getContacts(Callback<List<ExistingFollower>> existingFollowerListener) {
    dexcomShareApi.getContacts(getSessionId()).enqueue(new AuthenticatingCallback<List<ExistingFollower>>(existingFollowerListener) {
        @Override
        public void onRetry() {
            dexcomShareApi.getContacts(getSessionId()).enqueue(this);
        }
    });
}
 
Example #8
Source File: FollowerManagementActivity.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
private void populateFollowerList() {
    existingFollowerListener = new Callback<List<ExistingFollower>>() {
        @Override
        public void onResponse(Response<List<ExistingFollower>> response, Retrofit retrofit) {
            List<ExistingFollower> existingFollowers = response.body();
            if (followerListAdapter != null) {
                existingFollowerList.clear();
                if (existingFollowers != null && existingFollowers.size() > 0)
                    existingFollowerList.addAll(existingFollowers);
                followerListAdapter.notifyDataSetChanged();
            } else {
                if (existingFollowers != null && existingFollowers.size() > 0) {
                    existingFollowerList = existingFollowers;
                    followerListAdapter = new FollowerListAdapter(getApplicationContext(), shareRest, existingFollowerList);
                    existingFollowersView.setAdapter(followerListAdapter);
                }
            }
        }

        @Override
        public void onFailure(Throwable t) {
            // If it fails, don't show followers.
        }
    };

    shareRest.getContacts(existingFollowerListener);

}
 
Example #9
Source File: FollowerListAdapter.java    From xDrip with GNU General Public License v3.0 5 votes vote down vote up
@Override
public View getView(final int position, final View convertView, ViewGroup parent) {
    View view = convertView;
    if (view == null) {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = inflater.inflate(R.layout.item_follower, null);
    }
    TextView followerName = (TextView) view.findViewById(R.id.follwerName);
    Button deleteButton = (Button) view.findViewById(R.id.deleteFollower);

    final ExistingFollower follower = list.get(position);

    followerName.setText(follower.ContactName);
    deleteButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Callback<ResponseBody> deleteFollowerListener = new Callback<ResponseBody>() {
                @Override
                public void onResponse(Response<ResponseBody> response, Retrofit retrofit) {
                    if (response.isSuccess()) {
                        Toast.makeText(context, gs(R.string.follower_deleted_succesfully), Toast.LENGTH_LONG).show();
                        list.remove(position);
                        notifyDataSetChanged();
                    } else {
                        Toast.makeText(context, gs(R.string.failed_to_delete_follower), Toast.LENGTH_LONG).show();
                    }
                }

                @Override
                public void onFailure(Throwable t) {
                    Toast.makeText(context, gs(R.string.failed_to_delete_follower), Toast.LENGTH_LONG).show();
                }
            };
            shareRest.deleteContact(follower.ContactId, deleteFollowerListener);
        }
    });
    return view;
}
 
Example #10
Source File: DexcomShare.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
@POST("Publisher/ListPublisherAccountSubscriptions")
Call<List<ExistingFollower>> getContacts(@Query("sessionId") String sessionId);
 
Example #11
Source File: FollowerListAdapter.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
public FollowerListAdapter(Context context, ShareRest shareRest, List<ExistingFollower> list) {
    this.context = context;
    this.list = list;
    this.shareRest = shareRest;
}
 
Example #12
Source File: FollowerListAdapter.java    From xDrip-plus with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ExistingFollower getItem(int pos) {
    return list.get(pos);
}
 
Example #13
Source File: DexcomShare.java    From xDrip-Experimental with GNU General Public License v3.0 4 votes vote down vote up
@POST("Publisher/ListPublisherAccountSubscriptions")
Call<List<ExistingFollower>> getContacts(@Query("sessionId") String sessionId);
 
Example #14
Source File: FollowerListAdapter.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ExistingFollower getItem(int pos) {
    return list.get(pos);
}
 
Example #15
Source File: FollowerListAdapter.java    From xDrip-Experimental with GNU General Public License v3.0 4 votes vote down vote up
public FollowerListAdapter(Context context, ShareRest shareRest, List<ExistingFollower> list) {
    this.context = context;
    this.list = list;
    this.shareRest = shareRest;
}
 
Example #16
Source File: FollowerListAdapter.java    From xDrip-Experimental with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ExistingFollower getItem(int pos) {
    return list.get(pos);
}
 
Example #17
Source File: FollowerListAdapter.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
public FollowerListAdapter(Context context, ShareRest shareRest, List<ExistingFollower> list) {
    this.context = context;
    this.list = list;
    this.shareRest = shareRest;
}
 
Example #18
Source File: DexcomShare.java    From xDrip with GNU General Public License v3.0 4 votes vote down vote up
@POST("Publisher/ListPublisherAccountSubscriptions")
Call<List<ExistingFollower>> getContacts(@Query("sessionId") String sessionId);