Tony Starkisi

Greenhorn
+ Follow
since Jul 01, 2018
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
3
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tony Starkisi

Im using the Glide library inside my recyclerView adapter like this:

And i also using the Volley library to do some http requests.
When i use those two libraries together i get the following message:

**W/OkHttpClient: A connection to http:/// was leaked. Did you forget to close a response body?**

**Note** Both libraries make requests to the same server.

But when i use those two seperately i get no warnings. This means that the my code does not leak memory. But when combined it does.

Is something to worry about or one library sees that a connection from the other is still open before it closes and in some point it will close it?

Thank you.

5 years ago


In the following code i have a recycler view with a custom adapter. Each item in adapter has onclick listener. Also recycler implements OnFling Gesture.

The problem
Each time OnFling gets called, the MotionEvent e1 is null. I found out this is because of the onItemClick implementation in adapter. It consumes the down click.

How can i solve this? I want to pass down to recycler the event, so the MotionEvent e1 to not be null.

MainActivity

Adapter
5 years ago


I have the following code in my recycler adapter. When scrolling down, recycler starts to lag while glide loads asynchronous images. If i remove glide then is all perfect. Any ideas?

Thank you


5 years ago


I have a question regarding memory leaks. I have the below anonymous class. As you might know anonymous class hold reference from the outside object(here is Activity). Does this code causes memory leak or not? In case of orientation this will hold the old activity. Right?

Thank you

public class MainActivity extends AppCompatActivity{

5 years ago
I was reading about the 2-way binding and came across to this article https://www.bignerdranch.com/blog/two-way-data-binding-on-android-observing-your-view-with-xml/.

So i ran the code and i have a question.

This @BindingAdapter is only created once and scrollListener is always null. Why it checks for null or why this IF exists in the first place?



Thank you

   
5 years ago
"So when the application runs, if a scroll change occurs in that ScrollView object then the new listener is informed about it. The new listener passes the scroll change information to the original listener and notifies the InverseBindingListener that a change occurs" There is no original listener ,scrollListener inside of onScrollChange is always null.
5 years ago


I was reading about the 2-way binding and came across to this article https://www.bignerdranch.com/blog/two-way-data-binding-on-android-observing-your-view-with-xml/. It has the following code but i cant understand why it calls onScrollChange inside of onScrollChange. Im new to this, i would to like to learn more about this topic.

1. Does this create a loop? ScrollView's listener executes onScrollChange  which contains the same onScrollChange.
2. Could this work with the alternative?

Thank you


**ALTERNATIVE**
5 years ago
I was reading about the 2-way binding and came across to this article. It has the following code but i cant understand why it calls *onScrollChange* inside of *onScrollChange*. Im new to this, i would to like to learn more about this topic.

Thank you


5 years ago
Thank you for your reply. One more question. Why we need to register every time a new listener? Can a one time listener do the job when color changes?
5 years ago
I have this code below which uses the DiffUtil.calculateDiff between two lists. Each time i scroll further down the list, new data comes and added to the list. But when the result notifies changes, the adapter leads me to the top of the list each time.

1. How can i  remain to the position which the new data was added?
2. This example is the right usage of DiffUtil.calculateDiff?or  simply do i need to use :


without the DiffUtil.calculateDiff.
5 years ago
  I want to search some data when user writes on the search View. Below there is way of doing that but it is the wrong way. Every time the user clicks enter, a new observer registers and this is totally wrong. If the users does that 20 times then 20 observers will be registered. Is there another clean way ?

Thank you

5 years ago


I was reading about 2-way binding in Android and most of the articles were using same techniques. https://medium.com/google-developers/android-data-binding-2-way-your-way-ccac20f6313

Specifically,when they hooking the event for inverseBindingListener , they do the folowing :

Why they check if inverseBindingListener is null?. It will never be null

Thank you
5 years ago
I try to delete a table that has 10.000.000 records inside.

Code:
5 years ago
I have the following code using Room library to handle sqldatabase. I waSthe downloadCustomers method many times but all of a sudden i got the following message inside at the mDatabase.repoCustomer().deleteCustomers() :

**Message:**

*The connection pool for database has been unable to grant a connection to thread room android*

This happened only once and i wiped the emulator so i can run it again.
I read in forums that "*a transaction might be open by a thread*", but Room library handles automatically situations like these.

Any ideas?

**Emulator:** Emulator API 27 with Google Play (not Google APIs)

**Something to consider:** Sometimes when i run apps with Google play strange things happen e.x runs an app with 2 instances at the same time. But i dont want to make quick assumptions.


Thank you.


5 years ago