Exemplo n.º 1
0
 @Override
 public void onReadBoardsSuccess(BoardCategory[] boardCategories) {
   readTask = null;
   getListView().getWrapper().cancelBusyState();
   switchView(ViewType.LIST, null);
   JSONArray jsonArray = null;
   if (boardCategories != null && boardCategories.length > 0) {
     try {
       for (BoardCategory boardCategory : boardCategories) {
         Board[] boards = boardCategory.getBoards();
         if (boards != null && boards.length > 0) {
           JSONObject jsonObject = new JSONObject();
           jsonObject.put(
               BoardsAdapter.KEY_TITLE, StringUtils.emptyIfNull(boardCategory.getTitle()));
           JSONArray boardsArray = new JSONArray();
           for (Board board : boards) {
             boardsArray.put(board.getBoardName());
           }
           jsonObject.put(BoardsAdapter.KEY_BOARDS, boardsArray);
           if (jsonArray == null) {
             jsonArray = new JSONArray();
           }
           jsonArray.put(jsonObject);
         }
       }
     } catch (JSONException e) {
       // Invalid data, ignore exception
     }
   }
   ChanConfiguration configuration = getChanConfiguration();
   configuration.storeBoards(jsonArray);
   configuration.commit();
   getAdapter().update();
   getListView().setSelection(0);
 }
Exemplo n.º 2
0
 @Override
 public boolean onContextItemSelected(MenuItem item, int position, View targetView) {
   String boardName = getAdapter().getItem(position).boardName;
   if (boardName != null) {
     switch (item.getItemId()) {
       case CONTEXT_MENU_COPY_LINK:
         {
           Uri uri = getChanLocator().safe(true).createBoardUri(boardName, 0);
           if (uri != null) {
             StringUtils.copyToClipboard(getActivity(), uri.toString());
           }
           return true;
         }
       case CONTEXT_MENU_ADD_FAVORITES:
         {
           FavoritesStorage.getInstance().add(getPageHolder().chanName, boardName);
           return true;
         }
     }
   }
   return false;
 }