public void listPostForCurrentMemberService() {
    if (GeneralHelpers.isInternetAvailable(getActivity())) {
      if (GlobalVariables.isCurrentMember == true) {
        // spinner.setVisibility(View.VISIBLE);
        PostService postService = new PostService(accessToken);
        postService.listPostsForMe();
        loading.setVisibility(View.VISIBLE);
      } else {

        // spinner.setVisibility(View.VISIBLE);
        SharedPreferences preferences =
            getActivity().getSharedPreferences("CurrentUser", getActivity().MODE_PRIVATE);
        Member member =
            Member.createUserFromJson(
                createJsonElementFromString(preferences.getString("profile_member", "")));
        PostService postService = new PostService(accessToken);
        postService.listPostsForMember(member.id);
        loading.setVisibility(View.VISIBLE);
      }
    } else {
      // ViewHelpers.showProgress(false, this, contentFrame, membersSearchProgress);
      ViewHelpers.showPopup(
          getActivity(),
          getResources().getString(R.string.alert_title_network),
          getResources().getString(R.string.no_connection),
          true);
    }
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    getActivity().invalidateOptionsMenu();
    getActivity().getActionBar().setTitle("To do");
    BaseApplication.register(this);
    layoutInflater = inflater;
    preferences = getActivity().getSharedPreferences("CurrentUser", getActivity().MODE_PRIVATE);
    currentMember =
        Member.createUserFromJson(
            createJsonElementFromString(preferences.getString("current_member", "")));
    GlobalVariables.menuDeep = 1;
    getActivity().onPrepareOptionsMenu(GlobalVariables.menu);
    return null;
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    BaseApplication.register(this);

    SharedPreferences preferences =
        getActivity().getSharedPreferences("CurrentUser", getActivity().MODE_PRIVATE);
    currentUser =
        Member.createUserFromJson(
            createJsonElementFromString(preferences.getString("current_member", "")));
    accessToken = preferences.getString("access_token", "").replace("\"", "");

    PostsAdapter.lastClickedPosts = new ArrayList<Integer>();

    this.inflater = inflater;

    return null;
  }
Beispiel #4
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    this.inflater = inflater;

    if (getArguments() != null)
      hubToDisplay = (Hub) getArguments().getSerializable(NEW_INSTANCE_HUB_KEY);

    SharedPreferences preferences =
        getActivity().getSharedPreferences("CurrentUser", getActivity().MODE_PRIVATE);
    currentMember =
        Member.createUserFromJson(
            createJsonElementFromString(preferences.getString("current_member", "")));
    accessToken = preferences.getString("access_token", "").replace("\"", "");
    GlobalVariables.menuDeep = 1;
    getActivity().onPrepareOptionsMenu(GlobalVariables.menu);
    BaseApplication.register(this);
    return null;
  }
  @Subscribe
  public void onGetListMembersByPaginationEvent(MembersEvent event) {

    if (firstTime && firstTimeSearch) {

    } else {
      this.from += GlobalVariables.SEARCH_SIZE;
      waitForSearch = false;

      loading.setVisibility(View.INVISIBLE);
      listViewMembers.setVisibility(View.VISIBLE);
      emptySearch.setVisibility(View.INVISIBLE);

      membersList.addAll(event.members);

      members = Member.membersInfoForItem(getActivity(), members, membersList);

      GlobalVariables.finderList = false;
      adapter = new TodoAdapter(getActivity(), membersList, listViewMembers, concernedMembers);
      listViewMembers.setAdapter(adapter);

      ViewHelpers.setListViewHeightBasedOnChildren(listViewMembers);

      listViewMembers.removeFooterView(footer);

      if (adapter.isEmpty()) {
        emptySearch.setVisibility(View.VISIBLE);
      } else emptySearch.setVisibility(View.INVISIBLE);

      if (onRefresh) {
        // TODO scroll to end of list
        listViewMembers.setSelection(lastPosition);
      }
      onRefresh = false;

      if (members.size() < GlobalVariables.SEARCH_SIZE) {
        noMoreMembers = true;
      }
      if (event.members.size() == 0) noMoreMembers = true;
    }
    firstTime = false;
  }