swipelayout working but no feed - android

I am using swipelayout from daimajia.I get some data from services.When the service has a date than will visible an icon that will open the left sideBut it do nothing when clicking the icon.I have no error that's the reason why cannot resolve it.The action is when clicking the icon,that visible a textview and start a chronometer.
Here is my swipeListener
private SwipeListener swipeListener = new SwipeListener() {
#Override
public void onStartOpen(SwipeLayout layout, SwipeLayout.DragEdge edge) {
if (edge == SwipeLayout.DragEdge.Left && viewHolder.discountText != null) {
**viewHolder.discountText.setTimeByTag().play();**
LogUtils.LogE("Left Open...");
}
}
#Override
public void onOpen(SwipeLayout layout, SwipeLayout.DragEdge edge) {
super.onOpen(layout, edge);
if (edge == SwipeLayout.DragEdge.Left && viewHolder.discountText != null) {
viewHolder.discountText.setTimeByTag().play();
LogUtils.LogE("Left Open...");
}
}
#Override
public void onClose(SwipeLayout layout, SwipeLayout.DragEdge edge) {
if (edge == SwipeLayout.DragEdge.Left && viewHolder.discountText != null) {
viewHolder.discountText.stop();
LogUtils.LogE("Left Close!");
}
}
};
public void openLeft() {
LogUtils.LogE("onClick openLeft-");
if (getSwipeLayout() == null){
LogUtils.LogE("onClick -null-");
return;
}
if (!getSwipeLayout().isOpen()) {
getSwipeLayout().open(true, SwipeLayout.DragEdge.Left);
LogUtils.LogE("onClick --");
}
}
all the codes working in other my fragments.I need some idea what's the reason that it not give true action that swipe to left.
EDIT:
Here is the Logs:
In this picture I have 2 items there which it's in my favorite page.The last one item has end date that will be visible the icon(ImageView).When pressing the icon,it should swipe to left side but it's not working and give the result like this picture which I'm shared.
EDIT
There is something more.I had looked the codes in debug mode and give here an message:
but put define swipeLayout into my code:
sl.setShowMode(SwipeLayout.ShowMode.LayDown);
sl.setDragEdges(SwipeLayout.DragEdge.Left, SwipeLayout.DragEdge.Right);
sl.setBottomViewIds(R.id.productBottomLeft, R.id.productBottomRight, SwipeLayout.EMPTY_LAYOUT, SwipeLayout.EMPTY_LAYOUT);

TextView button = SwipeLayout.findViewById(R.id.yourButtonId) //the bottom view;
button.setOnClickListener(v -> yourMethod());

Related

focus is not shifting to next edittext automatically?

I am trying to add and remove edittext through RecyclerView Adapter and it's working fine but I also want to shift the focus to next empty edittext when I click on adapter item which fills the edit text. It would be grateful if someone could help ,I am newbie to android.
Here is my focus next method:
private void focusNext() {
View view = getAdapterView(mAddDropPointAdapter.getCurrentFocusedPosition() + 1);
}
if (view != null) {
view.findViewById(R.id.fragment_google_autoc_et_destination).requestFocus();
} else if (getActivity() != null) {
KeyboardUtils.hideKeyboard(getActivity());
}
}
Here is from where I am calling this method.
#Override
public void onAdapterItemClick(int position, #NonNull GoogleAutoCompleteAddressDto addressDto) {
/// Doing some stuff
focusNext();
}
After clicking the adapter item , focus stays at the same edittext it doesn't shift to next.

Error with the keyboard on a WebView - when the keyboard is shown, it causes a white background

When i show comment facebook to my app, result below. But when i click to comment
filed, webview show background white when set keyboard android:windowSoftInputMode="adjustPan". Sometime, it is cause when scroll webview bottom.
I have to found solve with scroll parent view with bottom view when key board visible.
KeyboardVisibilityEvent.setEventListener(
getActivity(),
new KeyboardVisibilityEventListener() {
#Override
public void onVisibilityChanged(boolean isOpen) {
// some code depending on keyboard status
if ((isOpen) &&(getUserVisibleHint())) {
if (nestVPageDetail != null) {
nestVPageDetail.post(new Runnable() {
#Override
public void run() {
if ((nestVPageDetail != null) && (rvContentArrayDetail != null)) {
nestVPageDetail.scrollTo(0,
rvContentArrayDetail.getBottom());
}
}
});
}
}
}
});
This is lib check keyboard:
implementation 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:2.1.0'

Page focus scrolls back to AutoCompleteTextView

Have an autocomplete textView in layout which is in a ScrollView.
mAutoCompleteTextView.addTextChangedListener(new TextValidator(mAutoCompleteTextView) {
#Override
public void validate(TextView textView, String text) {
if(text == null){
mAutoCompleteTextView.setError(text);
}
});
This shows a red error icon with a dropdown error message in case text is not valid. While error is visible and page is scrolled, the centre of page returns back to this view instead of scrolling up/down.
How to avoid this while error is still visible?
Try this ..
This will allow you to scroll smoothly, if setEnabled() doesnt work you can also user clearFocus() and requestFocus()
scrollLayout.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
#Override
public void onScrollChanged() {
Rect rect = new Rect();
mAutoCompleteTextView.setEnabled(false);
if (mAutoCompleteTextView.getGlobalVisibleRect(rect)
&& mAutoCompleteTextView.getHeight() == rect.height()
&& mAutoCompleteTextView.getWidth() == rect.width() && mAutoCompleteTextView.isShown()) {
mAutoCompleteTextView.setEnabled(true);
} else {
mAutoCompleteTextView.setEnabled(false);
}
}
});
Hope this helps
In the root Layout use this :
android:descendantFocusability="beforeDescendants"
And then in onCreate():
rootLayout.requestFocus();
Hope this helps.

SharedElements undesirable effect in RecyclerView

I have one activity with one RecyclerView (SuperSlim library) and a detail activity, when I click a item of that list, detail activity will be open. The problem is when I go back, I'm trying to set the clicked element as the first visible element in the list but I get this horrible animation:
This is my onActivityReenter()
#Override
public void onActivityReenter(int resultCode, Intent data) {
super.onActivityReenter(resultCode, data);
Log.d(TAG, "onActivityReenter() called with: resultCode = [" + resultCode + "], data = [" + data + "]");
mTmpReenterState = new Bundle(data.getExtras());
int startingPosition = mTmpReenterState.getInt(EXTRA_STARTING_ITEM_POSITION);
int currentPosition = mTmpReenterState.getInt(EXTRA_CURRENT_ITEM_POSITION);
mRecycler.scrollToPosition(currentPosition);
postponeEnterTransition();
mRecycler.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
#Override
public boolean onPreDraw() {
mRecycler.getViewTreeObserver().removeOnPreDrawListener(this);
// TODO: figure out why it is necessary to request layout here in order to get a smooth transition.
mRecycler.requestLayout();
startPostponedEnterTransition();
return true;
}
});
}
And my SharedElementCallback:
private final SharedElementCallback exitTransitionCallBack = new SharedElementCallback() {
#Override
public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
if (mTmpReenterState == null) {
// If mTmpReenterState is null, then the activity is exiting.
View navigationBar = findViewById(android.R.id.navigationBarBackground);
View statusBar = findViewById(android.R.id.statusBarBackground);
if (navigationBar != null) {
names.add(navigationBar.getTransitionName());
sharedElements.put(navigationBar.getTransitionName(), navigationBar);
}
if (statusBar != null) {
names.add(statusBar.getTransitionName());
sharedElements.put(statusBar.getTransitionName(), statusBar);
}
} else {
int startingPosition = mTmpReenterState.getInt(EXTRA_STARTING_ITEM_POSITION);
int currentPosition = mTmpReenterState.getInt(EXTRA_CURRENT_ITEM_POSITION);
if (startingPosition != currentPosition) {
// If startingPosition != currentPosition the user must have swiped to a
// different page in the DetailsActivity. We must update the shared element
// so that the correct one falls into place.
sharedElements.clear();
sharedElements.put("number", mLayoutManager.findViewByPosition(currentPosition).findViewById(R.id.text_number));
sharedElements.put("day", mLayoutManager.findViewByPosition(currentPosition).findViewById(R.id.text_day));
sharedElements.put("recycler", mLayoutManager.findViewByPosition(currentPosition + 1).findViewById(R.id.recycler));
}
mTmpReenterState = null;
}
}
};
I think the problem is that the activity try to make an animation from the original item position to the top to the list, but I don't know how avoid that.
Does anyone know how to fix this??
Thanks in advance guys!!!
After a while I've realized that the problem that I was updating the Main Activity list with a notifyItemChanged(int) by LocalBroadcast and the standard recyclerView animation made that glitch. I solve the problem using:
RecyclerView.setItemAnimator(null)
because the standard didn't work
((SimpleItemAnimator) RecyclerView.getItemAnimator())
.setSupportsChangeAnimations(false)
So the problem is nothing to do with SharedElements.

Android ListView clicking bottom item and increasing height of it

I have a listview where pople can click on items. When they do, they increase height and show more information.
However, when clicking the bottom item, it is not visible to the user that the item height has increased and there is content if you scroll down.
Using e.g. following code in onItemClick does not solve the problem:
if (position == myItemsDataArrayList.size() - 1) {
if (data.ui_flags == "clicked") {
catalogListView.smoothScrollToPosition(position);
}
}
Implement this function in your if statement.
private void scrollMyListViewToBottom() {
myListView.post(new Runnable() {
#Override
public void run() {
// Select the last row so it will scroll into view...
myListView.setSelection(myListAdapter.getCount() - 1);
}
});
}
code by: https://stackoverflow.com/a/7032341/2197087
Working code solution was this:
catalogListView.post(new Runnable() {
#Override
public void run() {
catalogListView.setSelection(position_final);
}
});

Categories

Resources