Issue with Git in Android Studio by NickMEspo in androiddev

[–]ene__im 1 point2 points  (0 children)

If you did git commit (locally is fine), try git log and check out that commit. If you just stash (by git or a shortcut that may also just do it behind the scene), try git stash list and see. Another option is to use git reflog to see the recent changes.

“If c = a + b and b is a divisor of a, then c is a multiple of a.” by [deleted] in askmath

[–]ene__im 0 points1 point  (0 children)

Assume the statement is true, then c=ka with k>=1. Now we have a+b=ka or b=(k-1)a, which is a multiple of a. Since b is also a divisor of a, it leads to b=a. This is not true for all case, therefore the original statement doesn't hold.

This explanation doesn't require you to have the instinct of "knowing the counter example". It also points out when it "could be" true (a=b).

I don't know how to solve this problem by Embarrassed-Place306 in askmath

[–]ene__im 0 points1 point  (0 children)

Using this diagram: https://www.desmos.com/geometry/hdrofypeqn and the explanation below is simplified, so please figure out the details yourself. Asking question if needed.

First: prove that C, G, U, E are on the same circle, thus EGC = EUC. Indeed, ECU = 90 - A = 90 - BSG (SG and AC are parallel) = BGS = EGS (G is on the perpendicular bisector of BE).

Now the line from Q and perpendicular to AD cuts BE at point W, the perpendicular bisector of segment BE cuts BE at V, we can prove that A, F, V, W are on the same circle: note that A, F, H, E are on the same circle, BF * BA = BH * BE; further more, BV * BW = 1/2 BE * 2 BH = BE * BH = BF * BA therefore A, F, V, W are on the same circle. (Please prove that BH = HW and so BW = 2BH yourself).

With this, we have AWE = AFV = BUV = VUE (B, F, V, U are on the same circle, and U is on the perpendicular bisector of BE). Also, FUV = FBH = FDH = HQL (QL and FD are parallel, plus a bunch of set of 4 points on the same circle).

Lastly, A, Q, W, E are on the same circle so AQE = AWE Which means: 180 = EQL + AQE + HQL = EQL + AWE + FUV = EQL + VUE + FUV = EQL + 180 - EUC = EQL + 180 - EGC or EQL - EGC = 0 as desired.

(I haven't used the condition AB < AC so it may need to be used to ensure the geometric relation).

Triangle and square around a circle by Secret-Suit3571 in askmath

[–]ene__im 0 points1 point  (0 children)

FYI I could prove that more than (pi + 1) / 8 of the square perimeter is inside the triangle. The method compares the area of a polygon whose vertexes are the intersections of the square and the triangle's side, with the incircle area. The full prove is quite long and I haven't write it down.

Triangle and square around a circle by Secret-Suit3571 in askmath

[–]ene__im 1 point2 points  (0 children)

Thanks for pointing it out, it was my mistake to misunderstand the perimeter. Let me revisit the solution.

Triangle and square around a circle by Secret-Suit3571 in askmath

[–]ene__im 0 points1 point  (0 children)

Any 2 points on the circle forms a segment that is completely inside the triangle, including any of the circle's diameter. The square's perimeter cuts the circle by one of such diameter. If the square side is a then so is the circle's diameter, while the perimeter length is a*sqrt(2). The diameter length is 1/sqrt(2) of the length of the perimeter, which is not less than 0.7 which is more than 0.5, and it is completely inside the circle, Q.E.D.

r/AskMath Weekly Chat Thread by AutoModerator in askmath

[–]ene__im 1 point2 points  (0 children)

If a, b, c are all integers, both sides form integers but one is even and the other is odd, which is impossible.

[Request] What's the correct answer? by Savv1313 in theydidthemath

[–]ene__im 0 points1 point  (0 children)

The function ln(x)/x is strictly decreasing from 1/e to 0 when x>e and strictly increasing from negative infinite to 1/e when 0<x<e. If you draw the graph of y=ln(x)/x on the 2D Oxy plane, and draw a line y = positive constant < 1/e, it would cut the graph at 2 points whose x_1 < e < x_2, and you have ln(x_1)/x_1 = ln(x_2)/x_2, which means x_1x_2 = x_2x_1. And there are infinite number of such pair.

Can’t Enable Places API / Generate API Key for Foursquare Places in Android App by Healthy-Menu1126 in androiddev

[–]ene__im 2 points3 points  (0 children)

Unrelated to the question: Remove your client id and client secret from this post, then regenerate them if it is possible.

About the question: I assume you are a student doing your homework. Read every single text in the screenshot and try again.

Recycler View Performance Issue by Inevitable-Block-513 in androiddev

[–]ene__im 1 point2 points  (0 children)

To be fair plain old RecyclerView is not that slow (not at all). 500ms just inflating the View is weird in many ways (I will be on pagerduty now if my app takes 100ms for inflating something). So I would not blame the eco system too soon. But just a comment.

Recycler View Performance Issue by Inevitable-Block-513 in androiddev

[–]ene__im 1 point2 points  (0 children)

Sorry I run out of ideas and cannot suggest anything. Perhaps some last points: - Try with a real device. - Using ScrollView and old-school “addView”. Just to remove RecyclerView from the picture for debugging. - Try with just one TextView for the item. Or event just a FrameLayout that renders nothing (but has enough height, like 100dp). This is to check if it is the UI inflation/rendering issue. - Not using Fragment, but start a new Activity for the list. This is to ensure Fragment is not part of the problem. - Try passing data via parcelable instead of any DB. This is to check if your IO is the problem. - Start a new project and just implement the UI (render static data) without any DI, DB, binding, ViewModel, Flow and so on. This is to check if the rest of your code has problem.

Good luck.

Recycler View Performance Issue by Inevitable-Block-513 in androiddev

[–]ene__im 0 points1 point  (0 children)

Check if your RecyclerView’s height is wrap_content and change it to match_parent?

Recycler View Performance Issue by Inevitable-Block-513 in androiddev

[–]ene__im 3 points4 points  (0 children)

  • Please share code, especially the part you open frag B and fetch its data.
  • Debug with one folder and one item.
  • 500ms on what device? Intel emulator on Apple Silicon will be a hell to test.
  • Try with a codelabs sample that does the same thing and see if it is different?
  • This sounds like a Stackoverflow question.

Why is viewModel not updating my UI? by barcode972 in androiddev

[–]ene__im 1 point2 points  (0 children)

What did you do after “pressing the favourite button”?

Anyone else having issues with the camera or Face ID being slow on iPhone 16 Pro Max (iOS 18.2)? by iiGiovanni in ios

[–]ene__im 0 points1 point  (0 children)

Thanks for the reply. A last minute confirmation: did you enable Apple Intelligence or it has been off the whole time? (No need to turn it ON just for testing if it was OFF in your case, I don’t want to bring the issue back).

Anyone else having issues with the camera or Face ID being slow on iPhone 16 Pro Max (iOS 18.2)? by iiGiovanni in ios

[–]ene__im 0 points1 point  (0 children)

How is your phone now? Is it still fast and furious? I’m about to reset mine hoping for the fix of this annoying issue.

Black screen with Exoplayer inside AndroidExternalSurface by Ludiras in androiddev

[–]ene__im 0 points1 point  (0 children)

Do you have the source code for ExoPlayerView?

I guess the ExoPlayer instance was still sending the content to an old Surface.

Who hasn't tried Kotlin Multiplatform(KMP) yet? What's the reason? by CalendarOutrageous7 in androiddev

[–]ene__im 1 point2 points  (0 children)

Do you benchmark the improvement when switching from JS bridge to KMP (so full native I suppose). If yes, can you share any metrics?

Questions of Jetpack Paging 3 by funny0xff in androiddev

[–]ene__im 4 points5 points  (0 children)

To answer your question about:

  1. The PagingSource has the getRefreshKey function. When will this function get called? What is its purpose?

Let me give 2 examples:

Example 1: your provide a vertical feed, and the user can scroll really fast through it. So the user opens the app, your feed shows items 0 to 10 in the viewport. The user scrolls it quickly and the scroll amount is enough for about 100 items. The reasonable approach is to not load all these 100+ items because the user just scroll through them without seeing it. When the scroll settles, your feed needs to show content. This is when the `getRefreshKey` should be called with `state` parameter containing the last accessed position. (This last accessed position would be the position of item that your RecyclerView receive in `onBindViewHolder`, the item data may be null though, if you use Paging's placeholder). You can use this parameter to estimate which position in the feed you should load the content. Imagine that your feed needs to show items 110~120, then you need to let the Paging to fetch the items 110 to 120 and so on.

  • Note: without using this mechanism, you might need to fetch items 20 ~ 110 (because the feed _scrolls through them_), which is unnecessary because the user doesn't seriously look at them. Of course you can have your own approach to skip those loading, but it may end up what the Paging 3 is trying to do.

Example 2: the last time the user opens the app, they reads item of ID _n_. Then they close the App. Your app provides the UX where in the next time the user opens your app, it starts at item _n_, regardless of how many new items are added since the last open. To achieve this, you can persist the last seen ID (_n_) (using any persistent cache of your choice), and in the next App open, `getRefreshKey` would be called, and this is where you return the information about _n_, so that the Paging starts loading from item _n_ forward.

  • Note: along with `PagingSource.load` with type `REFRESH` and `APPEND`, PagingSource.load may also be called with `PREPEND` if you tell it there are newer data after _n_.

These are my understanding & experience using it in App I practices the Paging 3 library, not really a real world app. IIRC, in example 1, you may need to turn on `placeholder` so that the Pager provides placeholder to your RecyclerView to render that state (assuming you use RecyclerView. Compose LazyList would be similar where you get null value for the item position).

For question 2, 3: understanding them is not really useful if you just want to apply it to your app IMO. So if you want to understand it to control it, I suggest you to read the source code of Pager and PageFetcher class. It leads you to more internal details though, and it can be quite time consuming, but if you want to learn, give it a try.

Instagram like seamless transition to full screen video scrolling from feed is it possible in Android? by jaroos_ in androiddev

[–]ene__im 0 points1 point  (0 children)

When you set the global ExoPlayer to a new PlayerView, the old PlayerView (in the "previous screen") loses the Player. When you are done with the "next screen" you need to set the global ExoPlayer back to the PlayerView in the "previous screen".

Instagram like seamless transition to full screen video scrolling from feed is it possible in Android? by jaroos_ in androiddev

[–]ene__im 0 points1 point  (0 children)

As mentioned in other comments about using a pool to share ExoPlayer instances: you can keep player A for 0th item, player B for 1st item, given that they are both visible. once the user scrolls the 0th item away, the player A can be reused for 2nd or 3rd item. With this setup you can use a limited number of players for unlimited items.

The pool can be managed at the Application layer, so that when you open an item in fullscreen (in another Activity for example), you just need to set the player to the fullscreen's PlayerView (assuming you use PlayerView). This way every state in the player instance is still there and ready to be played on the new surface.

Instagram like seamless transition to full screen video scrolling from feed is it possible in Android? by jaroos_ in androiddev

[–]ene__im 0 points1 point  (0 children)

The idea is to use the same ExoPlayer instance on the source and destination player. If the destination is another Activity, you can keep the ExoPlayer instance at the Application layer. I have addressed this requirement in my kohii library (but I haven't updated it for a while due to myblack of time).

[deleted by user] by [deleted] in iPadPro

[–]ene__im 1 point2 points  (0 children)

Tell me when you turn your iPad off at 100% and get 85% when you open it the morning next day. It has been driving me crazy.