@Override public boolean onFragmentCreate() { loading = true; MediaController.loadGalleryPhotosAlbums(classGuid); NotificationCenter.getInstance().addObserver(this, NotificationCenter.albumsDidLoaded); NotificationCenter.getInstance().addObserver(this, NotificationCenter.recentImagesDidLoaded); NotificationCenter.getInstance().addObserver(this, NotificationCenter.closeChats); return super.onFragmentCreate(); }
public void onRevealAnimationEnd(boolean open) { if (open && Build.VERSION.SDK_INT <= 19 && MediaController.allPhotosAlbumEntry == null) { MediaController.loadGalleryPhotosAlbums(0); } }
public ChatAttachView(Context context) { super(context); NotificationCenter.getInstance().addObserver(this, NotificationCenter.albumsDidLoaded); if (MediaController.allPhotosAlbumEntry == null) { if (Build.VERSION.SDK_INT >= 21) { MediaController.loadGalleryPhotosAlbums(0); } loading = true; } views[8] = attachPhotoRecyclerView = new RecyclerListView(context); attachPhotoRecyclerView.setVerticalScrollBarEnabled(true); attachPhotoRecyclerView.setAdapter(photoAttachAdapter = new PhotoAttachAdapter(context)); attachPhotoRecyclerView.setClipToPadding(false); attachPhotoRecyclerView.setPadding(AndroidUtilities.dp(8), 0, AndroidUtilities.dp(8), 0); attachPhotoRecyclerView.setItemAnimator(null); attachPhotoRecyclerView.setLayoutAnimation(null); if (Build.VERSION.SDK_INT >= 9) { attachPhotoRecyclerView.setOverScrollMode(RecyclerListView.OVER_SCROLL_NEVER); } addView(attachPhotoRecyclerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 80)); attachPhotoLayoutManager = new LinearLayoutManager(context) { @Override public boolean supportsPredictiveItemAnimations() { return false; } }; attachPhotoLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); attachPhotoRecyclerView.setLayoutManager(attachPhotoLayoutManager); photoAttachAdapter.setDelegate( new PhotoAttachAdapter.PhotoAttachAdapterDelegate() { @Override public void selectedPhotosChanged() { updatePhotosButton(); } }); attachPhotoRecyclerView.setOnItemClickListener( new RecyclerListView.OnItemClickListener() { @SuppressWarnings("unchecked") @Override public void onItemClick(View view, int position) { if (baseFragment == null || baseFragment.getParentActivity() == null) { return; } ArrayList<Object> arrayList = (ArrayList) MediaController.allPhotosAlbumEntry.photos; if (position < 0 || position >= arrayList.size()) { return; } PhotoViewer.getInstance().setParentActivity(baseFragment.getParentActivity()); PhotoViewer.getInstance() .openPhotoForSelect(arrayList, position, 0, ChatAttachView.this, baseFragment); AndroidUtilities.hideKeyboard(baseFragment.getFragmentView().findFocus()); } }); views[9] = progressView = new EmptyTextProgressView(context); if (Build.VERSION.SDK_INT >= 23 && getContext().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { progressView.setText( LocaleController.getString("PermissionStorage", R.string.PermissionStorage)); progressView.setTextSize(16); } else { progressView.setText(LocaleController.getString("NoPhotos", R.string.NoPhotos)); progressView.setTextSize(20); } addView(progressView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 80)); attachPhotoRecyclerView.setEmptyView(progressView); views[10] = lineView = new View(getContext()); lineView.setBackgroundColor(0xffd2d2d2); addView( lineView, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, 1, Gravity.TOP | Gravity.LEFT)); CharSequence[] items = new CharSequence[] { LocaleController.getString("ChatCamera", R.string.ChatCamera), LocaleController.getString("ChatGallery", R.string.ChatGallery), LocaleController.getString("ChatVideo", R.string.ChatVideo), LocaleController.getString("AttachAudio", R.string.AttachAudio), LocaleController.getString("ChatDocument", R.string.ChatDocument), LocaleController.getString("AttachContact", R.string.AttachContact), LocaleController.getString("ChatLocation", R.string.ChatLocation), "" }; int itemIcons[] = new int[] { R.drawable.attach_camera_states, R.drawable.attach_gallery_states, R.drawable.attach_video_states, R.drawable.attach_audio_states, R.drawable.attach_file_states, R.drawable.attach_contact_states, R.drawable.attach_location_states, R.drawable.attach_hide_states, }; for (int a = 0; a < 8; a++) { AttachButton attachButton = new AttachButton(context); attachButton.setTextAndIcon(items[a], itemIcons[a]); addView(attachButton, LayoutHelper.createFrame(85, 90, Gravity.LEFT | Gravity.TOP)); attachButton.setTag(a); views[a] = attachButton; if (a == 7) { sendPhotosButton = attachButton; sendPhotosButton.imageView.setPadding(0, AndroidUtilities.dp(4), 0, 0); } attachButton.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { if (delegate != null) { delegate.didPressedButton((Integer) v.getTag()); } } }); } setOnTouchListener( new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); if (loading) { progressView.showProgress(); } else { progressView.showTextView(); } }