Exemplo n.º 1
0
 @Override
 public void onResume() {
   super.onResume();
   if (listAdapter != null) {
     listAdapter.notifyDataSetChanged();
   }
 }
  private void fixLayoutInternal() {
    if (getParentActivity() == null) {
      return;
    }

    WindowManager manager =
        (WindowManager)
            ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE);
    int rotation = manager.getDefaultDisplay().getRotation();
    columnsCount = 2;
    if (!AndroidUtilities.isTablet()
        && (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90)) {
      columnsCount = 4;
    }
    listAdapter.notifyDataSetChanged();

    if (dropDownContainer != null) {
      if (!AndroidUtilities.isTablet()) {
        FrameLayout.LayoutParams layoutParams =
            (FrameLayout.LayoutParams) dropDownContainer.getLayoutParams();
        layoutParams.topMargin =
            (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0);
        dropDownContainer.setLayoutParams(layoutParams);
      }

      if (!AndroidUtilities.isTablet()
          && ApplicationLoader.applicationContext.getResources().getConfiguration().orientation
              == Configuration.ORIENTATION_LANDSCAPE) {
        dropDown.setTextSize(18);
      } else {
        dropDown.setTextSize(20);
      }
    }
  }
 @Override
 public void onResume() {
   super.onResume();
   if (listAdapter != null) {
     listAdapter.notifyDataSetChanged();
   }
   processSelectedBackground();
   fixLayout();
 }
Exemplo n.º 4
0
 @Override
 public void onResume() {
     super.onResume();
     if (getActivity() == null) {
         return;
     }
     if (!firstStart && listAdapter != null) {
         listAdapter.notifyDataSetChanged();
     }
     firstStart = false;
Exemplo n.º 5
0
 private void updateSearchInterface() {
   if (listAdapter != null) {
     listAdapter.notifyDataSetChanged();
   }
   if (searching && searchResult.isEmpty() || loadingRecent && lastSearchString == null) {
     progressView.setVisibility(View.VISIBLE);
     listView.setEmptyView(null);
     emptyView.setVisibility(View.GONE);
   } else {
     progressView.setVisibility(View.GONE);
     emptyView.setVisibility(View.VISIBLE);
     listView.setEmptyView(emptyView);
   }
 }
Exemplo n.º 6
0
 @Override
 public void onResume() {
   super.onResume();
   if (listAdapter != null) {
     listAdapter.notifyDataSetChanged();
   }
   if (searchItem != null) {
     searchItem.openSearch();
     getParentActivity()
         .getWindow()
         .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
   }
   fixLayout();
 }
Exemplo n.º 7
0
 private void updateRows() {
   rowCount = 0;
   ArrayList<TLRPC.TL_messages_stickerSet> stickerSets = StickersQuery.getStickerSets();
   if (!stickerSets.isEmpty()) {
     stickersStartRow = 0;
     stickersEndRow = stickerSets.size();
     rowCount += stickerSets.size();
   } else {
     stickersStartRow = -1;
     stickersEndRow = -1;
   }
   stickersInfoRow = rowCount++;
   if (listAdapter != null) {
     listAdapter.notifyDataSetChanged();
   }
 }
Exemplo n.º 8
0
  private void fixLayoutInternal() {
    if (getParentActivity() == null) {
      return;
    }
    int position = listView.getFirstVisiblePosition();
    WindowManager manager =
        (WindowManager)
            ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE);
    int rotation = manager.getDefaultDisplay().getRotation();

    int columnsCount;
    if (AndroidUtilities.isTablet()) {
      columnsCount = 3;
    } else {
      if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
        columnsCount = 5;
      } else {
        columnsCount = 3;
      }
    }
    listView.setNumColumns(columnsCount);
    if (AndroidUtilities.isTablet()) {
      itemWidth =
          (AndroidUtilities.dp(490) - ((columnsCount + 1) * AndroidUtilities.dp(4))) / columnsCount;
    } else {
      itemWidth =
          (AndroidUtilities.displaySize.x - ((columnsCount + 1) * AndroidUtilities.dp(4)))
              / columnsCount;
    }
    listView.setColumnWidth(itemWidth);

    listAdapter.notifyDataSetChanged();
    listView.setSelection(position);

    if (selectedAlbum == null) {
      emptyView.setPadding(
          0,
          0,
          0,
          (int) ((AndroidUtilities.displaySize.y - ActionBar.getCurrentActionBarHeight()) * 0.4f));
    }
  }
 @SuppressWarnings("unchecked")
 @Override
 public void didReceivedNotification(int id, Object... args) {
   if (id == NotificationCenter.albumsDidLoaded) {
     int guid = (Integer) args[0];
     if (classGuid == guid) {
       albumsSorted = (ArrayList<MediaController.AlbumEntry>) args[1];
       videoAlbumsSorted = (ArrayList<MediaController.AlbumEntry>) args[3];
       if (progressView != null) {
         progressView.setVisibility(View.GONE);
       }
       if (listView != null && listView.getEmptyView() == null) {
         listView.setEmptyView(emptyView);
       }
       if (listAdapter != null) {
         listAdapter.notifyDataSetChanged();
       }
       loading = false;
     }
   } else if (id == NotificationCenter.closeChats) {
     removeSelfFromStack();
   } else if (id == NotificationCenter.recentImagesDidLoaded) {
     int type = (Integer) args[0];
     if (type == 0) {
       recentWebImages = (ArrayList<MediaController.SearchImage>) args[1];
       recentImagesWebKeys.clear();
       for (MediaController.SearchImage searchImage : recentWebImages) {
         recentImagesWebKeys.put(searchImage.id, searchImage);
       }
     } else if (type == 1) {
       recentGifImages = (ArrayList<MediaController.SearchImage>) args[1];
       recentImagesGifKeys.clear();
       for (MediaController.SearchImage searchImage : recentGifImages) {
         recentImagesGifKeys.put(searchImage.id, searchImage);
       }
     }
   }
 }
Exemplo n.º 10
0
 public void didReceivedNotification(int id, Object... args) {
   if (id == MessagesController.updateInterfaces) {
     int mask = (Integer) args[0];
     if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0
         || (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
       if (listView != null) {
         listView.invalidateViews();
       }
     }
   } else if (id == MessagesController.contactsDidLoaded) {
     createActionBarMenu();
   } else if (id == MessagesController.mediaCountDidLoaded) {
     long uid = (Long) args[0];
     if (uid > 0 && user_id == uid && dialog_id == 0 || dialog_id != 0 && dialog_id == uid) {
       totalMediaCount = (Integer) args[1];
       if (listView != null) {
         listView.invalidateViews();
       }
     }
   } else if (id == MessagesController.encryptedChatCreated) {
     if (creatingChat) {
       NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
       TLRPC.EncryptedChat encryptedChat = (TLRPC.EncryptedChat) args[0];
       Bundle args2 = new Bundle();
       args2.putInt("enc_id", encryptedChat.id);
       presentFragment(new ChatActivity(args2), true);
     }
   } else if (id == MessagesController.encryptedChatUpdated) {
     TLRPC.EncryptedChat chat = (TLRPC.EncryptedChat) args[0];
     if (currentEncryptedChat != null && chat.id == currentEncryptedChat.id) {
       currentEncryptedChat = chat;
       updateRowsIds();
       if (listAdapter != null) {
         listAdapter.notifyDataSetChanged();
       }
     }
   }
 }
Exemplo n.º 11
0
 @Override
 public void willHidePhotoViewer() {
   if (listAdapter != null) {
     listAdapter.notifyDataSetChanged();
   }
 }
Exemplo n.º 12
0
    @SuppressWarnings("unchecked")
    @Override
    public void didReceivedNotification(int id, Object... args) {
        if (id == MessagesController.mediaDidLoaded) {
            long uid = (Long)args[0];
            int guid = (Integer)args[4];
            if (uid == dialog_id && guid == classGuid) {
                loading = false;
                totalCount = (Integer)args[1];
                @SuppressWarnings("uchecked")
                ArrayList<MessageObject> arr = (ArrayList<MessageObject>)args[2];
                boolean added = false;
                for (MessageObject message : arr) {
                    if (!messagesDict.containsKey(message.messageOwner.id)) {
                        if (max_id == 0 || message.messageOwner.id < max_id) {
                            max_id = message.messageOwner.id;
                        }
                        messagesDict.put(message.messageOwner.id, message);
                        messages.add(message);
                        added = true;
                    }
                }
                if (!added) {
                    endReached = true;
                }
                cacheEndReached = !(Boolean)args[3];
                if (progressView != null) {
                    progressView.setVisibility(View.GONE);
                }
                if (listView != null) {
                    if (listView.getEmptyView() == null) {
                        listView.setEmptyView(emptyView);
                    }
                }
                if (listAdapter != null) {
                    listAdapter.notifyDataSetChanged();
                }
            }
        } else if (id == MessagesController.messagesDeleted) {
            @SuppressWarnings("unchecked")
            ArrayList<Integer> markAsDeletedMessages = (ArrayList<Integer>)args[0];
            boolean updated = false;
            for (Integer ids : markAsDeletedMessages) {
                MessageObject obj = messagesDict.get(ids);
                if (obj != null) {
                    messages.remove(obj);
                    messagesDict.remove(ids);
                    totalCount--;
                    updated = true;
                }
            }
            if (updated && listAdapter != null) {
                listAdapter.notifyDataSetChanged();
            }
        } else if (id == MessagesController.didReceivedNewMessages) {
            long uid = (Long)args[0];
            if (uid == dialog_id) {
                boolean markAsRead = false;
                @SuppressWarnings("unchecked")
                ArrayList<MessageObject> arr = (ArrayList<MessageObject>)args[1];

                for (MessageObject obj : arr) {
                    if (obj.messageOwner.media == null || !(obj.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) && !(obj.messageOwner.media instanceof TLRPC.TL_messageMediaVideo)) {
                        continue;
                    }
                    if (messagesDict.containsKey(obj.messageOwner.id)) {
                        continue;
                    }
                    if ((max_id == 0 || obj.messageOwner.id < max_id) && obj.messageOwner.id > 0) {
                        max_id = obj.messageOwner.id;
                    }
                    messagesDict.put(obj.messageOwner.id, obj);
                    messages.add(0, obj);
                }
                if (listAdapter != null) {
                    listAdapter.notifyDataSetChanged();
                }
            }
        } else if (id == MessagesController.messageReceivedByServer) {
            Integer msgId = (Integer)args[0];
            MessageObject obj = messagesDict.get(msgId);
            if (obj != null) {
                Integer newMsgId = (Integer)args[1];
                messagesDict.remove(msgId);
                messagesDict.put(newMsgId, obj);
                obj.messageOwner.id = newMsgId;
            }
        }
    }