Exemple #1
0
  @Override
  public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    view.setClickable(true);

    Bundle bundle = getArguments();
    if (bundle == null) {
      return;
    }

    mEvent = (Event) bundle.getSerializable(ARG_EVENT);

    mListView = (ListView) view.findViewById(R.id.listView);
    mListView.setOnScrollListener(new ScrollListener());
    mAdapter = new EventNewsAdapter();
    mListView.setAdapter(mAdapter);
    mLoaderCallback = new EventNewsLoaderCallback();
    mRestService = HttpHelper.getRestAdapter().create(RestHelper.class);

    Profile profile = User.currentUser().getProfile();
    if (profile != null && profile.getIsAdmin() == 1) {
      setHasOptionsMenu(true);
      registerForContextMenu(mListView);
    }

    onLoadBegins();
    loadEventNews(0);
  }
Exemple #2
0
  private void removeNew(AdapterView.AdapterContextMenuInfo info) {
    EventNew news = mAdapter.getItem(info.position);

    onLoadBegins();
    mRestService.removeEventNews(
        User.currentUser().getUserId(),
        news.getId(),
        new HttpHelper.RestCallback<Status>() {
          @Override
          public void failure(Status restError) {
            onLoadFinished();
          }

          @Override
          public void success(Status status, Response response) {
            Toast.makeText(getActivity(), R.string.enf_new_removed_success, Toast.LENGTH_SHORT)
                .show();

            mAdapter.resetData();
            loadEventNews(0);
            onLoadFinished();
          }
        });
  }
Exemple #3
0
  private void sendNews(String newsMessage) {
    onLoadBegins();
    mRestService.addEventNews(
        User.currentUser().getUserId(),
        mEvent.getId(),
        newsMessage,
        new HttpHelper.RestCallback<Status>() {
          @Override
          public void failure(Status restError) {
            onLoadFinished();
          }

          @Override
          public void success(Status status, Response response) {
            Toast.makeText(getActivity(), R.string.enf_new_added_success, Toast.LENGTH_SHORT)
                .show();

            mAdapter.resetData();
            loadEventNews(0);

            onLoadFinished();
          }
        });
  }