use of net.iGap.helper.HelperFragment in project iGap-Android by KianIranian-STDG.
the class MyStatusStoryListFragment method onClick.
@Override
public void onClick(View view, int position) {
StoryCell storyCell = (StoryCell) view;
new HelperFragment(getActivity().getSupportFragmentManager(), new StoryViewFragment(storyCell.getUserId(), storyCell.getRoomId(), true, !storyCell.isRoom(), storyCell.isRoom(), false, storyCell.getStoryId() != 0 ? storyCell.getStoryId() : storyCell.getStoryIndex(), 0)).setReplace(false).load();
}
use of net.iGap.helper.HelperFragment in project iGap-Android by KianIranian-STDG.
the class MyStatusStoryListFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
getEventManager().addObserver(EventManager.STORY_LIST_FETCHED, this);
getEventManager().addObserver(EventManager.STORY_USER_ADD_NEW, this);
getEventManager().addObserver(EventManager.STORY_USER_ADD_VIEW, this);
getEventManager().addObserver(EventManager.STORY_DELETED, this);
getEventManager().addObserver(EventManager.STORY_UPLOADED_FAILED, this);
getEventManager().addObserver(EventManager.STORY_UPLOAD, this);
getEventManager().addObserver(EventManager.STORY_SENDING, this);
getEventManager().addObserver(EventManager.STORY_USER_INFO, this);
getEventManager().addObserver(EventManager.STORY_STATUS_UPLOAD, this);
getEventManager().addObserver(EventManager.STORY_ROOM_IMAGE_UPLOAD, this);
getEventManager().addObserver(EventManager.STORY_ROOM_UPLOAD, this);
progressBar.setVisibility(View.VISIBLE);
sendRoomStory();
loadStories();
AbstractObject req = null;
IG_RPC.Story_Get_Own_Story_Views story_get_own_story_views = new IG_RPC.Story_Get_Own_Story_Views();
story_get_own_story_views.offset = 0;
story_get_own_story_views.limit = 50;
req = story_get_own_story_views;
getRequestManager().sendRequest(req, (response, error) -> {
if (error == null) {
IG_RPC.Res_Story_Get_Own_Story_Views res = (IG_RPC.Res_Story_Get_Own_Story_Views) response;
getMessageDataStorage().updateOwnViews(res.groupedViews);
// G.runOnUiThread(() -> loadStories());
} else {
progressBar.setVisibility(View.GONE);
}
});
floatActionLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (listMode == 1) {
new HelperFragment(getActivity().getSupportFragmentManager(), new StoryPagerFragment(true, roomId, 1, roomTitle)).setReplace(false).load();
} else {
new HelperFragment(getActivity().getSupportFragmentManager(), new StoryPagerFragment(false)).setReplace(false).load();
}
}
});
customStatusActionLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (listMode == 1) {
new HelperFragment(getActivity().getSupportFragmentManager(), new StatusTextFragment(true, roomId, 1, roomTitle)).setReplace(false).load();
} else {
new HelperFragment(getActivity().getSupportFragmentManager(), new StatusTextFragment(false)).setReplace(false).load();
}
}
});
mOffset = 0;
recyclerListView.addOnScrollListener(new RecyclerView.OnScrollListener() {
private boolean scrollUpdated;
private boolean scrollingManually;
private int prevTop;
private int prevPosition;
@Override
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
scrollingManually = newState == RecyclerView.SCROLL_STATE_DRAGGING;
}
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
View view = layoutManager.getChildAt(0);
if (firstVisibleItemPosition > 0 && view != null) {
firstVisibleItemPositionOffset = view.getTop();
}
if (!storyListFetched) {
if (mOffset > 0) {
int lastVisiblePosition = ((LinearLayoutManager) recyclerView.getLayoutManager()).findLastVisibleItemPosition();
if (lastVisiblePosition + 10 >= mOffset) {
// GetStoryList(mOffset, 50);
}
}
}
int firstVisibleItem = layoutManager.findFirstVisibleItemPosition();
if (firstVisibleItem != RecyclerView.NO_POSITION) {
RecyclerView.ViewHolder holder = recyclerView.findViewHolderForAdapterPosition(firstVisibleItem);
if (holder != null && holder.getAdapterPosition() != 0) {
int firstViewTop = holder.itemView.getTop();
boolean goingDown;
boolean changed = true;
if (prevPosition == firstVisibleItem) {
final int topDelta = prevTop - firstViewTop;
goingDown = firstViewTop < prevTop;
changed = Math.abs(topDelta) > 1;
} else {
goingDown = firstVisibleItem > prevPosition;
}
if (changed && scrollUpdated && (goingDown || scrollingManually)) {
hideFloatingButton(goingDown);
}
prevPosition = firstVisibleItem;
prevTop = firstViewTop;
scrollUpdated = true;
}
}
}
});
}
use of net.iGap.helper.HelperFragment in project iGap-Android by KianIranian-STDG.
the class PhotoViewer method setCreatedFinalBitmap.
private void setCreatedFinalBitmap(String path) {
if (counter < itemGalleryList.size() && textImageList.containsKey(itemGalleryList.get(counter).getPath())) {
String message = textImageList.get(itemGalleryList.get(counter).getPath()).getText();
int id = textImageList.get(itemGalleryList.get(counter).getPath()).getId();
textImageList.remove(itemGalleryList.get(counter).getPath());
StructBottomSheet item = new StructBottomSheet();
item.setPath(path);
item.setText(message);
item.setId(id);
textImageList.put(path, item);
}
itemGalleryList.get(counter).setPath(path);
finalBitmapsPaths.add(path);
counter++;
if (counter == itemGalleryList.size()) {
if (isForRoom && listMode == 0) {
new HelperFragment(getActivity().getSupportFragmentManager(), PhotoViewer.this).popBackStack(2);
new HelperFragment(getActivity().getSupportFragmentManager(), new MyStatusStoryListFragment(finalBitmapsPaths, itemGalleryList, roomId, 0, roomTitle)).setReplace(false).load();
} else if (isForRoom && listMode == 1) {
new HelperFragment(getActivity().getSupportFragmentManager(), PhotoViewer.this).popBackStack(2);
EventManager.getInstance(AccountManager.selectedAccount).postEvent(EventManager.STORY_ROOM_IMAGE_UPLOAD, finalBitmapsPaths, itemGalleryList, roomId, 1, roomTitle);
} else {
EventManager.getInstance(AccountManager.selectedAccount).postEvent(EventManager.STORY_UPLOAD, finalBitmapsPaths, itemGalleryList, isForRoom, roomId, listMode, roomTitle);
new HelperFragment(getActivity().getSupportFragmentManager(), PhotoViewer.this).popBackStack(2);
}
}
}
use of net.iGap.helper.HelperFragment in project iGap-Android by KianIranian-STDG.
the class PhotoViewer method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
addedViews = new HashMap<>();
modes = new HashMap<>();
redoViews = new ArrayList<>();
path = getArguments().getString(PATH);
this.isForRoom = getArguments().getBoolean(IS_ROOM, false);
this.roomId = getArguments().getLong(ROOM_ID, 0);
this.listMode = getArguments().getInt(LIST_MODE, 0);
this.roomTitle = getArguments().getString(ROOM_TITLE, "");
selectedPhotos = (List<GalleryItemModel>) getArguments().getSerializable(SELECTED_PHOTOS);
brushConfigDialog = new BrushConfigDialog();
brushConfigDialog.setPropertiesChangeListener(this);
mode = StoryModes.NONE;
modes.put(viewHolderPostion, StoryModes.NONE);
if (!HelperPermission.grantedUseStorage()) {
try {
HelperPermission.getStoragePermission(getContext(), new OnGetPermission() {
@Override
public void Allow() throws IOException {
openPhotoForEdit(path, null, false);
}
@Override
public void deny() {
showDeniedPermissionMessage(G.context.getString(R.string.permission_storage));
}
});
} catch (IOException e) {
e.printStackTrace();
}
}
if (getActivity() != null) {
emojiSharedPreferences = getActivity().getSharedPreferences(SHP_SETTING.EMOJI, MODE_PRIVATE);
}
if (path != null) {
openPhotoForEdit(path, null, false);
} else {
openPhotoForEdit(selectedPhotos, null, false);
for (int i = 0; i < itemGalleryList.size(); i++) {
modes.put(i, StoryModes.NONE);
}
}
captionEditText.setListener(new EventEditText.Listener() {
@Override
public void onInternalTouchEvent(MotionEvent event) {
if (!isPopupShowing() && event.getAction() == MotionEvent.ACTION_DOWN) {
showPopUPView(KeyboardView.MODE_KEYBOARD);
}
}
});
addTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showPopUPView(-1);
viewPager.setPagingEnabled(true);
paintTextView.setBackground(null);
textStickersParentView = viewHolders.get(viewHolderPostion).findViewById(R.id.textstickerView);
if (mode == StoryModes.PAINT || mode == StoryModes.ADD_TEXT || mode == StoryModes.EMOJI || mode == StoryModes.FILTER || mode == StoryModes.CROP) {
textStickersParentView.setPaintMode(false, "");
} else {
textStickersParentView.setPaintMode(false, "");
autoScaleImageToFitBounds();
}
mode = StoryModes.ADD_TEXT;
modes.put(viewHolderPostion, StoryModes.ADD_TEXT);
TextEditorDialogFragment textEditorDialogFragment = TextEditorDialogFragment.newInstance(requireActivity());
textEditorDialogFragment.setOnTextEditorListener((inputText, colorCode, width) -> {
FrameLayout rootView = new FrameLayout(context);
stickerBorder = new FrameLayout(context);
stickerBorder.setPadding(10, 10, 10, 10);
rootView.addView(stickerBorder, LayoutCreator.createFrame(LayoutCreator.MATCH_PARENT, LayoutCreator.MATCH_PARENT, Gravity.CENTER, 8, 8, 8, 8));
textTv = new TextView(context);
textTv.setId(R.id.story_added_text);
textTv.setTextColor(colorCode);
textTv.setText(inputText);
textTv.setGravity(Gravity.CENTER);
textTv.setTypeface(ResourcesCompat.getFont(context, R.font.main_font_bold));
textTv.setTextSize(30);
TextViewCompat.setAutoSizeTextTypeUniformWithConfiguration(textTv, 22, 30, 1, TypedValue.COMPLEX_UNIT_DIP);
stickerBorder.addView(textTv, LayoutCreator.createFrame(LayoutCreator.WRAP_CONTENT, LayoutCreator.WRAP_CONTENT, Gravity.CENTER, 14, 14, 14, 14));
onEditActions.addText(rootView, inputText, colorCode);
});
}
});
paintTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showPopUPView(-1);
viewPager.setPagingEnabled(false);
textStickersParentView = viewHolders.get(viewHolderPostion).findViewById(R.id.textstickerView);
if (mode == StoryModes.PAINT || mode == StoryModes.ADD_TEXT || mode == StoryModes.EMOJI || mode == StoryModes.FILTER || mode == StoryModes.CROP) {
textStickersParentView.setPaintMode(true, "");
} else {
textStickersParentView.setPaintMode(true, "");
}
mode = StoryModes.PAINT;
modes.put(viewHolderPostion, StoryModes.PAINT);
textStickersParentView.getmBrushDrawingView().setBrushViewChangeListener(PhotoViewer.this);
String tag = brushConfigDialog.getTag();
// Avoid IllegalStateException "Fragment already added"
if (brushConfigDialog.isAdded())
return;
brushConfigDialog.setBrushColor(brushColor);
brushConfigDialog.setBrushOpacity(opacitySize);
brushConfigDialog.setBrushSize(brushSize);
brushConfigDialog.show(getParentFragmentManager(), tag);
onEditActions.paint();
updateBrushParams();
}
});
revertTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
textStickersParentView = viewHolders.get(viewHolderPostion).findViewById(R.id.textstickerView);
boolean revert = undo();
if (addedViews.get(viewHolderPostion).size() == 0) {
paintTextView.setBackground(null);
}
revertTextView.setVisibility(addedViews.get(viewHolderPostion).size() > 0 ? View.VISIBLE : View.GONE);
}
});
rippleView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
closeKeyboard();
if (getActivity() != null) {
new HelperFragment(getParentFragmentManager(), PhotoViewer.this).remove();
}
}
});
emoji.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showPopUPView(-1);
paintTextView.setBackground(null);
viewPager.setPagingEnabled(true);
textStickersParentView = viewHolders.get(viewHolderPostion).findViewById(R.id.textstickerView);
if (mode == StoryModes.PAINT) {
textStickersParentView.setPaintMode(false, "");
} else if (mode == StoryModes.ADD_TEXT) {
textStickersParentView.setPaintMode(false, "");
} else {
textStickersParentView.setPaintMode(false, "");
}
mode = StoryModes.EMOJI;
modes.put(viewHolderPostion, StoryModes.EMOJI);
EmojiDialogFrag emojiDialogFrag = new EmojiDialogFrag();
emojiDialogFrag.setEmojiListener(PhotoViewer.this::onEmojiClick);
emojiDialogFrag.show(getParentFragmentManager(), emojiDialogFrag.getTag());
onEditActions.emoji();
}
});
editTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showPopUPView(-1);
paintTextView.setBackground(null);
viewPager.setPagingEnabled(true);
mode = StoryModes.FILTER;
modes.put(viewHolderPostion, StoryModes.FILTER);
new HelperFragment(getActivity().getSupportFragmentManager(), FragmentFilterImage.newInstance(itemGalleryList.get(viewHolderPostion).getPath())).setReplace(false).load();
}
});
cropTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showPopUPView(-1);
paintTextView.setBackground(null);
viewPager.setPagingEnabled(true);
mode = StoryModes.CROP;
modes.put(viewHolderPostion, StoryModes.CROP);
goToCropPage(view);
}
});
updateImage = new UpdateImage() {
@Override
public void result(Bitmap finalBitmap) {
textStickersParentView = viewHolders.get(viewHolderPostion).findViewById(R.id.textstickerView);
textStickersParentView.updateImageBitmap(finalBitmap);
}
@Override
public void resultWithPath(String path) {
textStickersParentView = viewHolders.get(viewHolderPostion).findViewById(R.id.textstickerView);
serFilterImage(path);
}
};
pickerViewSendButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
HelperTracker.sendTracker(HelperTracker.TRACKER_MOMENTS_SUBMIT_PICTURE_PAGE);
pickerViewSendButton.setVisibility(View.GONE);
progressBar.setVisibility(VISIBLE);
for (int i = 0; i < itemGalleryList.size(); i++) {
if (viewHolders.get(i) != null) {
reservedView = viewHolders.get(i);
new SaveBitmapAsync(itemGalleryList.get(i).path, null, viewHolders.get(i).findViewById(R.id.textstickerView), modes.get(i)).execute();
} else {
zoomLayout = new ZoomLayout(context);
zoomLayout.measure(View.MeasureSpec.makeMeasureSpec(viewPager.getMeasuredWidth(), View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(viewPager.getMeasuredHeight(), View.MeasureSpec.EXACTLY));
zoomLayout.layout(0, 0, viewPager.getMeasuredWidth(), viewPager.getMeasuredHeight());
textStickersParentView = new TextStickerView(context, false);
textStickersParentView.setId(R.id.textstickerView);
zoomLayout.addView(textStickersParentView);
if (itemGalleryList.get(i).path != null && !viewHolders.containsKey(i)) {
String oldPath = itemGalleryList.get(i).path;
String finalPath = attachFile.saveGalleryPicToLocal(oldPath);
// check if old path available in selected list , replace new path with that
if (!oldPath.equals(finalPath)) {
StructBottomSheet item = textImageList.get(oldPath);
if (item != null) {
textImageList.remove(oldPath);
textImageList.put(finalPath, item);
}
}
itemGalleryList.get(i).path = finalPath;
textStickersParentView.measure(View.MeasureSpec.makeMeasureSpec(viewPager.getMeasuredWidth(), View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(viewPager.getMeasuredHeight(), View.MeasureSpec.EXACTLY));
textStickersParentView.layout(0, 0, viewPager.getMeasuredWidth(), viewPager.getMeasuredHeight());
Palette palette = Palette.from(BitmapFactory.decodeFile(finalPath)).generate();
GradientDrawable gd = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { palette.getLightMutedColor(0xFF616261), palette.getMutedColor(0xFF616261), palette.getDarkMutedColor(0xFF616261) });
textStickersParentView.setBackground(gd);
textStickersParentView.setPaintMode(false, finalPath);
Bitmap b = Bitmap.createBitmap(textStickersParentView.getMeasuredWidth(), textStickersParentView.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
Canvas mCanvas = new Canvas(b);
mCanvas.translate((-textStickersParentView.getScrollX()), (-textStickersParentView.getScrollY()));
textStickersParentView.draw(mCanvas);
new SaveBitmapAsync(itemGalleryList.get(i).path, b, textStickersParentView, modes.get(i)).execute();
}
}
}
}
});
captionEditText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (isPopupShowing()) {
keyboardEmoji.performClick();
}
}
});
keyboardEmoji.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!isPopupShowing()) {
showPopUPView(KeyboardView.MODE_EMOJI);
} else {
showPopUPView(KeyboardView.MODE_KEYBOARD);
}
}
});
captionEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
StructBottomSheet item = new StructBottomSheet();
item.setText(s.toString());
item.setPath(itemGalleryList.get(viewHolderPostion).path);
item.setId(itemGalleryList.get(viewHolderPostion).getId());
itemGalleryList.get(viewHolderPostion).setText(s.toString());
textImageList.put(itemGalleryList.get(viewHolderPostion).path, item);
}
});
}
use of net.iGap.helper.HelperFragment in project iGap-Android by KianIranian-STDG.
the class StatusTextFragment method writeTextOnDrawable.
private Bitmap writeTextOnDrawable(String text) {
Rect bounds = new Rect(textLayoutRoot.getLeft(), textLayoutRoot.getTop(), textLayoutRoot.getRight(), textLayoutRoot.getBottom());
textLayoutRoot.setDrawingCacheEnabled(true);
Bitmap b = Bitmap.createBitmap(textLayoutRoot.getDrawingCache());
Bitmap alteredBitmap = b.copy(Bitmap.Config.ARGB_8888, true);
try {
String savedPath = G.DIR_TEMP + "/" + System.currentTimeMillis() + "_edited_image.jpg";
File imageFile = new File(savedPath);
imageFile.createNewFile();
File file = new File(imageFile.getAbsolutePath());
FileOutputStream out = new FileOutputStream(file, false);
alteredBitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
alteredBitmap = BitmapFactory.decodeFile(imageFile.getAbsolutePath());
if (getActivity() != null) {
getActivity().onBackPressed();
}
if (isFromRoom && listMode == 0) {
new HelperFragment(getActivity().getSupportFragmentManager(), new MyStatusStoryListFragment(isFromRoom, imageFile.getAbsolutePath(), roomId, roomTitle, 0)).setReplace(false).load();
} else if (isFromRoom && listMode == 1) {
EventManager.getInstance(AccountManager.selectedAccount).postEvent(EventManager.STORY_ROOM_UPLOAD, imageFile.getAbsolutePath(), roomId, roomTitle);
} else {
EventManager.getInstance(AccountManager.selectedAccount).postEvent(EventManager.STORY_STATUS_UPLOAD, imageFile.getAbsolutePath(), isFromRoom);
}
} catch (Exception e) {
}
return alteredBitmap;
}
Aggregations