public void loadMore2() {
    int i = next;
    if (dataItems.size()
        < fragmentdat2
            .size()) { // Limit the number of items to 100 (stop loading when reaching 100 items)

      try {
        for (i = next; i < next + 10; i++) {
          dataItems.add(sortedData.get(i));
        }
      } catch (Exception e) {
        Toast.makeText(
                DetailedDisplayActivity.this, "You have reach to last record", Toast.LENGTH_SHORT)
            .show();
        tipsList.removeFooterView(footerView);
      }

      // Notify the ListView of data changed
      adapter.notifyDataSetChanged();
      isLoading = false;
      // Update next
      next = i;

    } else {
      Toast.makeText(
              DetailedDisplayActivity.this, "You have reach to last record", Toast.LENGTH_SHORT)
          .show();
      tipsList.removeFooterView(footerView);
    }
  }
Пример #2
0
  /**
   * Pushes data into list adapter.
   *
   * @param data the data to push
   */
  @UiThread
  protected void updateListView(PaginatedList<Artist> data) {
    if (loadingProgressBar.getVisibility() == View.VISIBLE)
      loadingProgressBar.setVisibility(View.INVISIBLE);

    if (data.getCount() <= 0) {
      Toast.makeText(this, "No singer was found", Toast.LENGTH_LONG).show();
      this.finish();
      return;
    }

    if (artistsFound == null) artistsFound = new PaginatedList<Artist>(data);
    else artistsFound.addItems(data.getItems());

    list = (ListView) findViewById(android.R.id.list);

    // If the adapter doesn't exist, we create one with the initial data.
    // If it exists, we update it.
    int currentPosition = -1;
    if (adapter == null) {
      adapter = new ArtistsListAdapter(this, data.getItems());
    } else {
      currentPosition = list.getFirstVisiblePosition();
      adapter.addItems(data.getItems());
    }
    list.setAdapter(adapter);

    list.setSelectionFromTop(currentPosition + 1, 0);

    if (artistsFound.getPaging().isLast()) list.removeFooterView(loadMoreProgress);

    this.isLoading = false;
  }
Пример #3
0
  @Subscribe
  public void onSearchForMemberByPaginationEvent(MembersSearchEvent event) {

    this.from += GlobalVariables.SEARCH_SIZE;

    loading.setVisibility(View.INVISIBLE);
    listViewMembers.setVisibility(View.VISIBLE);
    emptySearch.setVisibility(View.INVISIBLE);
    membersList.addAll(event.members);

    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;

    waitForSearch = false;
  }
Пример #4
0
  public void setLoadingMore(boolean loading) {
    isLoading = loading;
    if (loading) {

      if (isRefreshing()) {
        return;
      }
      if (mListView.getFooterViewsCount() == 0) {
        mListView.addFooterView(mListViewFooter);
      }
      mListView.setSelection(mListView.getAdapter().getCount() - 1);
      showMaterialProgressBar();
      //            if (isRefreshing()) {
      //                setRefreshing(false);
      //            }
      //            if (mListView.getFooterViewsCount() == 0) {
      //                mListView.addFooterView(mListViewFooter);
      //                mListView.setSelection(mListView.getAdapter().getCount() - 1);
      //            } else {
      //                mListViewFooter.setVisibility(VISIBLE);
      //                showMaterialProgressBar();
      //                //mListView.addFooterView(mListViewFooter);
      //            }
    } else {
      //            if (mListView.getAdapter() instanceof HeaderViewListAdapter) {
      //                mListView.removeFooterView(mListViewFooter);
      //            } else {
      //                mListViewFooter.setVisibility(View.GONE);
      //            }
      mListView.removeFooterView(mListViewFooter);
      mYDown = 0;
      mLastY = 0;
    }
  }
 public void showLoadingFooter() {
   if (listFooter != null) {
     lvUser.removeFooterView(listFooter);
   }
   listFooter = getLayoutInflater().inflate(R.layout.list_item_loading, null);
   ThemeUtil.setListViewLoading(listFooter);
   lvUser.addFooterView(listFooter);
 }
 public void showNoMoreFooter() {
   if (listFooter != null) {
     lvUser.removeFooterView(listFooter);
   }
   listFooter = getLayoutInflater().inflate(R.layout.list_item_more, null);
   ThemeUtil.setListViewMore(listFooter);
   TextView tvFooter = (TextView) listFooter.findViewById(R.id.tvFooter);
   tvFooter.setText(R.string.label_no_more);
   lvUser.addFooterView(listFooter);
 }
Пример #7
0
 protected void deleteTwo() {
   mNosearch.setVisibility(View.VISIBLE);
   mHistoryTwo.removeFooterView(mViewFooter);
   mListTwo.clear();
   mBoolean = true;
   // setAdapterTwo();
   Editor edit = mSpTwo.edit();
   edit.clear();
   edit.commit();
 }
Пример #8
0
 protected void deleteOne() {
   b = true;
   mNosearch.setVisibility(View.VISIBLE);
   mHistoryOne.removeFooterView(mViewFooter);
   mListOne.clear();
   // setAdapterOne();
   Editor edit = mSpOne.edit();
   edit.clear();
   edit.commit();
 }
  private void add2removeFooterView() {

    ListView lv = listView.getRefreshableView();
    adapter.notifyDataSetChanged();

    if (data.size() % 20 == 0 && data.size() != 0 && jsonArray.length() != 0) {
      lv.addFooterView(footView);
    } else {
      lv.removeFooterView(footView);
    }
  }
Пример #10
0
  private void addmore() {
    pageIndex++;

    if (pageIndex > allPage) {
      pageIndex = allPage - 1;
      listview.removeFooterView(moreView);
      Toast.makeText(HelpTitles.this, R.string.usercenter_hasgonelast, Toast.LENGTH_SHORT).show();
    } else {
      getJSONByLotno();
    }
  }
Пример #11
0
  /** 初始化列表 */
  private void addmore() {
    isfirst = false;
    pageindex++;
    if (pageindex < allPage) {

      netting(pageindex);
    } else {
      pageindex = allPage - 1;
      progressbar.setVisibility(view.INVISIBLE);
      queryinfolist.removeFooterView(view);
      Toast.makeText(TrackQueryActivity.this, R.string.usercenter_hasgonelast, Toast.LENGTH_SHORT)
          .show();
    }
  }
 /**
  * 点击底部按钮
  *
  * @param v
  */
 public void onClick(View v) {
   Log.d("debug", "isLastRow -->> " + isLastRow);
   if (adapter.getCount() < totalCount) { // 当前加载的数据条数小于总条数
     // 加载更多分页的课程成绩信息
     dlg.loadMoreData(adapter.getCount());
     // 进度条可见,按钮不可见
     pbFoot.setVisibility(View.VISIBLE);
     btnFoot.setVisibility(View.GONE);
     isLastRow = false;
   } else if (isLastRow) { // 所有的条目已经和最大条数相等,则移除底部的View,弹出提示信息
     lvCourseScore.removeFooterView(listfoot);
     Toast.makeText(ac, R.string.complete_loading_all_data, Toast.LENGTH_SHORT).show();
   }
 }
Пример #13
0
 private void addData() {
   for (int i = a + 1; i < a + 10; i++) {
     Map<String, Object> map = new HashMap<>();
     map.put("one", i);
     data.add(map);
     isLoadingOver = true;
   }
   a += 9;
   if (isLoadingOver) {
     Log.i("onScrollStateChanged", "=======2======");
     listview.removeFooterView(FootView);
     simpleAdapter.notifyDataSetChanged();
     isLoadingOver = false;
     isLoadingMore = false;
   }
 }
Пример #14
0
  private void addToHistory(final Geopoint coords) {
    // Add locations to history
    cgDestination loc = new cgDestination();
    loc.setCoords(coords);

    if (!getHistoryOfSearchedLocations().contains(loc)) {
      loc.setDate(System.currentTimeMillis());
      getHistoryOfSearchedLocations().add(0, loc);

      // Save location
      app.saveSearchedDestination(loc);

      // Ensure to remove the footer
      historyListView.removeFooterView(getEmptyHistoryFooter());
    }
  }
  public void showMoreFooter() {
    if (listFooter != null) {
      lvUser.removeFooterView(listFooter);
    }

    listFooter = getLayoutInflater().inflate(R.layout.list_item_more, null);
    ThemeUtil.setListViewMore(listFooter);
    listFooter.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            executeTask();
          }
        });
    lvUser.addFooterView(listFooter);
  }
 /** 点击向后按钮调用的方法 */
 private void addmore() {
   int pageIndex = getNewPage();
   int allpagenum = getAllPage();
   List<AccountDetailQueryInfo> typelist = getList();
   pageIndex++;
   if (pageIndex > allpagenum - 1) {
     pageIndex = allpagenum - 1;
     setNewPage(pageIndex);
     progressbar.setVisibility(view.INVISIBLE);
     tabSpecListView.removeFooterView(view);
     Toast.makeText(
             AccountDetailsActivity.this, R.string.usercenter_hasgonelast, Toast.LENGTH_SHORT)
         .show();
   } else {
     netting(pageIndex);
   }
 }
Пример #17
0
 @Override
 public void handleMessage(Message msg) {
   // TODO Auto-generated method stub
   switch (msg.what) {
     case 1:
       if (adapter.count <= 41) {
         adapter.count += 10;
         int currentPage = adapter.count / 10;
         Toast.makeText(getApplicationContext(), "第" + currentPage + "页", Toast.LENGTH_LONG)
             .show();
       } else {
         listView.removeFooterView(loadingLayout);
       }
       // 重新刷新Listview的adapter里面数据
       adapter.notifyDataSetChanged();
       break;
     default:
       break;
   }
 }
    private void searchNextPage() {
      isLoading = true;
      final FlightOrderListActivity actitivty = (FlightOrderListActivity) getActivity();

      if (actitivty.request.pageIndex < actitivty.pageCount) {
        actitivty.request.pageIndex++;
      } else {
        isLoading = false;
        footerContent.setVisibility(View.GONE);
        mContentView.removeFooterView(footerView);
        return;
      }

      AsyncHttpClient client = AsyncHttpClient.getInstance();
      client.excuteRequest(
          actitivty,
          actitivty.request,
          new ResponseHandler() {

            public void onSuccess() {
              GetFlightOrderListResponse reponse =
                  (GetFlightOrderListResponse)
                      BusinessCacheManager.getInstance()
                          .getBeanByName(GetFlightOrderListResponse.class.getName());
              for (FlightOrderModel model : reponse.flightOrders) {
                actitivty.adapter.add(model);
              }
              isLoading = false;
              footerContent.setVisibility(View.GONE);
            }

            public void onFailed(String error) {
              actitivty.request.pageIndex--;
              isLoading = false;
              footerContent.setVisibility(View.GONE);
            }

            public void onCanceled() {}
          });
    }
Пример #19
0
 @Override
 public void handleMessage(Message msg) {
   switch (msg.what) {
     case 0:
       try {
         Thread.sleep(3000);
       } catch (InterruptedException e) {
         e.printStackTrace();
       }
       loadMoreData();
       adapter.notifyDataSetChanged();
       moreView.setVisibility(View.GONE);
       if (count > 30) {
         Toast.makeText(MyActivity.this, "没有更多数据!", Toast.LENGTH_LONG).show();
         listView.removeFooterView(moreView);
       }
       Log.i(TAG, "加载更多数据...");
     case 1:
       break;
     default:
       break;
   }
 }
Пример #20
0
  @OnClick({R.id.btn_reload, R.id.btn_load_more, R.id.btn_add_footer})
  public void btnClick(View view) {
    switch (view.getId()) {
      case R.id.btn_load_more:
        loadOriginalData();
        adapter.notifyDataSetChanged();
        break;
      case R.id.btn_reload:
        refresh();
        break;
      case R.id.btn_add_footer:
        //                footer.setVisibility(footerIsVisiable ? View.INVISIBLE:View.VISIBLE);
        if (footerIsVisiable) {
          listView.removeFooterView(footer);
        } else {
          listView.addFooterView(footer);
        }
        listView.deferNotifyDataSetChanged();
        footerIsVisiable = !footerIsVisiable;

        break;
    }
  }
Пример #21
0
  @Override
  public void setAdapter(ListAdapter adapter) {
    if (!(adapter instanceof AmazingAdapter)) {
      throw new IllegalArgumentException(
          AmazingListView.class.getSimpleName()
              + " must use adapter of type "
              + AmazingAdapter.class.getSimpleName());
    }

    // previous adapter
    if (this.adapter != null) {
      this.adapter.setHasMorePagesListener(null);
      this.setOnScrollListener(null);
    }

    this.adapter = (AmazingAdapter) adapter;
    ((AmazingAdapter) adapter).setHasMorePagesListener(this);
    this.setOnScrollListener((AmazingAdapter) adapter);

    View dummy = new View(getContext());
    super.addFooterView(dummy);
    super.setAdapter(adapter);
    super.removeFooterView(dummy);
  }
Пример #22
0
        @Override
        public void handleMessage(Message msg) {
          switch (msg.what) {
            case GlobalParam.SHOW_SCROLLREFRESH:
              if (mIsRefreshing) {
                mContainer.onRefreshComplete();
                break;
              }
              mIsRefreshing = true;
              if (mWeibo != null) {
                mWeibo = null;
              }
              getPublishWeiboData(GlobalParam.LIST_LOAD_REFERSH);
              break;

            case GlobalParam.HIDE_SCROLLREFRESH:
              mIsRefreshing = false;
              mContainer.onRefreshComplete();
              updateListView();
              break;

            case GlobalParam.SHOW_PROGRESS_DIALOG:
              String dialogMsg = (String) msg.obj;
              showProgressDialog(dialogMsg);
              break;
            case GlobalParam.HIDE_PROGRESS_DIALOG:
              hideProgressDialog();
              // updateListView();
              break;
            case GlobalParam.MSG_CHECK_STATE:
              // mHandler.sendEmptyMessage(HIDE_PROGRESS_DIALOG);
              hideProgressDialog();
              if (mFootView != null) {
                mListView.removeFooterView(mFootView);
              }
              if (mAdapter != null) {
                mAdapter.notifyDataSetChanged();
              }
              // Toast.makeText(mContext, "没有更多数据了", Toast.LENGTH_LONG);
              break;
            case GlobalParam.MSG_SHOW_LISTVIEW_DATA:
              updateListView();
              break;

            case GlobalParam.MSG_LOAD_ERROR:
              String error_Detail = (String) msg.obj;
              if (error_Detail != null && !error_Detail.equals("")) {
                Toast.makeText(mContext, error_Detail, Toast.LENGTH_LONG).show();
              } else {
                Toast.makeText(mContext, R.string.load_error, Toast.LENGTH_LONG).show();
              }
              break;
            case GlobalParam.MSG_NETWORK_ERROR:
              Toast.makeText(mContext, R.string.network_error, Toast.LENGTH_LONG).show();
              break;
            case GlobalParam.MSG_TICE_OUT_EXCEPTION:
              String message = (String) msg.obj;
              if (message == null || message.equals("")) {
                message = mContext.getResources().getString(R.string.timeout);
              }
              Toast.makeText(mContext, message, Toast.LENGTH_LONG).show();
              break;
            case GlobalParam.SHOW_LOADINGMORE_INDECATOR:
              LinearLayout footView = (LinearLayout) msg.obj;
              ProgressBar pb =
                  (ProgressBar) footView.findViewById(R.id.hometab_addmore_progressbar);
              pb.setVisibility(View.VISIBLE);
              TextView more = (TextView) footView.findViewById(R.id.hometab_footer_text);
              more.setText(mContext.getString(R.string.add_more_loading));
              // getLoveList(GlobalParam.LIST_LOAD_MORE);
              getPublishWeiboData(GlobalParam.LIST_LOAD_MORE);
              break;
            case GlobalParam.HIDE_LOADINGMORE_INDECATOR:
              if (mFootView != null) {
                ProgressBar pbar =
                    (ProgressBar) mFootView.findViewById(R.id.hometab_addmore_progressbar);
                pbar.setVisibility(View.GONE);
                TextView moreView = (TextView) mFootView.findViewById(R.id.hometab_footer_text);
                moreView.setText(R.string.add_more);
              }

              if (mAdapter != null) {
                mAdapter.notifyDataSetChanged();
              }
              break;
            case GlobalParam.MSG_CHECK_FAVORITE_STATUS:
              IMJiaState canclefavResult = (IMJiaState) msg.obj;
              if (canclefavResult == null) {
                Toast.makeText(mContext, R.string.commit_dataing, Toast.LENGTH_LONG).show();
                return;
              }
              if (canclefavResult.code != 0) {
                Toast.makeText(mContext, canclefavResult.errorMsg, Toast.LENGTH_LONG).show();
                return;
              } else {

                mWeiboList.remove(canclefavResult.positon);
                if (mAdapter != null) {
                  mAdapter.notifyDataSetChanged();
                }
              }
              break;
            default:
              break;
          }
        }
Пример #23
0
  @Override
  public void onStart() {
    super.onStart();
    final Activity activity = this;
    Intent intent = getIntent();
    roomId = intent.getStringExtra("roomId");

    Map<String, String> parameterMap = new HashMap<String, String>();
    parameterMap.put("page", String.valueOf(page));
    YouRoomCommandProxy proxy = new YouRoomCommandProxy(this);
    ArrayList<YouRoomEntry> dataList = proxy.getRoomEntryListFromCache(roomId, parameterMap);

    adapter = new YouRoomEntryAdapter(this, R.layout.room_list_item, dataList);
    listView.setAdapter(adapter);

    if (dataList.size() < MAX_ROOM_COUNT) {
      listView.removeFooterView(footerView);
      listView.removeFooterView(emptyView);
    }

    GetRoomEntryTask task = new GetRoomEntryTask(roomId, parameterMap, activity);
    task.execute();
    page++;

    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (view == footerView) {
              if (reloadButton.isClickable()) {
                Map<String, String> parameterMap = new HashMap<String, String>();
                parameterMap.put("page", String.valueOf(page));
                ProgressBar progress = (ProgressBar) footerView.findViewById(R.id.progbar);
                progress.setVisibility(View.VISIBLE);
                TextView footerText = (TextView) footerView.findViewById(R.id.footer_text_view);
                footerText.setText(getBaseContext().getString(R.string.now_loading));
                GetRoomEntryTask task = new GetRoomEntryTask(roomId, parameterMap, activity);
                task.execute();
                page++;
              }
            } else {
              ListView listView = (ListView) parent;
              YouRoomEntry item = (YouRoomEntry) listView.getItemAtPosition(position);
              if (item.getDescendantsCount() == -1) {
                Toast.makeText(getApplication(), "読み込み中です。もう少しおまちください。", Toast.LENGTH_SHORT).show();

              } else if (item.getDescendantsCount() == 0) {
                Intent intent = new Intent(getApplication(), CreateEntryActivity.class);
                intent.putExtra("action", "create");
                intent.putExtra("roomId", String.valueOf(roomId));
                intent.putExtra("youRoomEntry", item);

                startActivity(intent);
              } else {

                /*
                 * UserSession session = UserSession.getInstance();
                 * String lastAccessTime =
                 * youRoomUtil.getRoomAccessTime(roomId);
                 * session.setRoomAccessTime(roomId, lastAccessTime);
                 * String time = YouRoomUtil.getRFC3339FormattedTime();
                 * youRoomUtil.storeRoomAccessTime(roomId, time);
                 */
                UserSession session = UserSession.getInstance();
                String roomAccessTime = session.getRoomAccessTime(roomId);
                Intent intent = new Intent(getApplication(), EntryActivity.class);
                if (roomAccessTime != null) {
                  int compareResult =
                      YouRoomUtil.calendarCompareTo(roomAccessTime, item.getUpdatedTime());
                  if (compareResult < 0) {
                    intent.putExtra("update_flag", true);
                  }
                }
                intent.putExtra("roomId", String.valueOf(roomId));
                intent.putExtra("youRoomEntry", item);
                startActivity(intent);
              }
            }
          }
        });

    listView.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {

          @Override
          public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            ListView listView = (ListView) parent;
            YouRoomEntry item = (YouRoomEntry) listView.getItemAtPosition(position);
            if (item == null) return false;
            // String entryId = String.valueOf(item.getId());
            // SQLiteDatabase cacheDb = ((AppHolder)
            // getApplication()).getCacheDb();
            // cacheDb.execSQL("delete from entries where entryId = ? and roomId = ? ;",
            // new String[] { entryId, roomId });
            contentsDialogUtil.showContentsDialog(item, roomId);
            return true;
          }
        });
  }
Пример #24
0
 private void removeFootView(PullToRefreshListView plv, View footView) {
   ListView lv = plv.getRefreshableView();
   if (lv.getFooterViewsCount() > 1) {
     lv.removeFooterView(footView);
   }
 }