mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-02-24 05:23:56 +01:00
Fixed infinite loading duplicate posts when there is no more posts to load. Minor bugs fixed. Minor layout tweaks.
This commit is contained in:
parent
91e6174aa5
commit
f7a192dcbe
@ -87,7 +87,6 @@ class ParsePost {
|
|||||||
int previewWidth = -1;
|
int previewWidth = -1;
|
||||||
int previewHeight = -1;
|
int previewHeight = -1;
|
||||||
if(data.has(JSONUtils.PREVIEW_KEY)) {
|
if(data.has(JSONUtils.PREVIEW_KEY)) {
|
||||||
Log.i("haspreview", Integer.toString(i));
|
|
||||||
previewUrl = data.getJSONObject(JSONUtils.PREVIEW_KEY).getJSONArray(JSONUtils.IMAGES_KEY).getJSONObject(0)
|
previewUrl = data.getJSONObject(JSONUtils.PREVIEW_KEY).getJSONArray(JSONUtils.IMAGES_KEY).getJSONObject(0)
|
||||||
.getJSONObject(JSONUtils.SOURCE_KEY).getString(JSONUtils.URL_KEY);
|
.getJSONObject(JSONUtils.SOURCE_KEY).getString(JSONUtils.URL_KEY);
|
||||||
previewWidth = data.getJSONObject(JSONUtils.PREVIEW_KEY).getJSONArray(JSONUtils.IMAGES_KEY).getJSONObject(0)
|
previewWidth = data.getJSONObject(JSONUtils.PREVIEW_KEY).getJSONArray(JSONUtils.IMAGES_KEY).getJSONObject(0)
|
||||||
@ -95,7 +94,6 @@ class ParsePost {
|
|||||||
previewHeight = data.getJSONObject(JSONUtils.PREVIEW_KEY).getJSONArray(JSONUtils.IMAGES_KEY).getJSONObject(0)
|
previewHeight = data.getJSONObject(JSONUtils.PREVIEW_KEY).getJSONArray(JSONUtils.IMAGES_KEY).getJSONObject(0)
|
||||||
.getJSONObject(JSONUtils.SOURCE_KEY).getInt(JSONUtils.HEIGHT_KEY);
|
.getJSONObject(JSONUtils.SOURCE_KEY).getInt(JSONUtils.HEIGHT_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(data.has(JSONUtils.CROSSPOST_PARENT_LIST)) {
|
if(data.has(JSONUtils.CROSSPOST_PARENT_LIST)) {
|
||||||
//Cross post
|
//Cross post
|
||||||
data = data.getJSONArray(JSONUtils.CROSSPOST_PARENT_LIST).getJSONObject(0);
|
data = data.getJSONArray(JSONUtils.CROSSPOST_PARENT_LIST).getJSONObject(0);
|
||||||
@ -160,7 +158,13 @@ class ParsePost {
|
|||||||
}
|
}
|
||||||
bestPostData.add(linkPost);
|
bestPostData.add(linkPost);
|
||||||
}
|
}
|
||||||
} else if(isVideo) {
|
} else {
|
||||||
|
if(previewUrl.equals("")) {
|
||||||
|
previewUrl = data.getJSONObject(JSONUtils.PREVIEW_KEY).getJSONArray(JSONUtils.IMAGES_KEY).getJSONObject(0)
|
||||||
|
.getJSONObject(JSONUtils.SOURCE_KEY).getString(JSONUtils.URL_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isVideo) {
|
||||||
//Video post
|
//Video post
|
||||||
Log.i("video", Integer.toString(i));
|
Log.i("video", Integer.toString(i));
|
||||||
JSONObject redditVideoObject = data.getJSONObject(JSONUtils.MEDIA_KEY).getJSONObject(JSONUtils.REDDIT_VIDEO_KEY);
|
JSONObject redditVideoObject = data.getJSONObject(JSONUtils.MEDIA_KEY).getJSONObject(JSONUtils.REDDIT_VIDEO_KEY);
|
||||||
@ -286,3 +290,4 @@ class ParsePost {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -16,6 +16,7 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
static final int TYPE_FRONT_PAGE = 0;
|
static final int TYPE_FRONT_PAGE = 0;
|
||||||
static final int TYPE_SUBREDDIT = 1;
|
static final int TYPE_SUBREDDIT = 1;
|
||||||
static final int TYPE_USER = 2;
|
static final int TYPE_USER = 2;
|
||||||
|
|
||||||
private Retrofit retrofit;
|
private Retrofit retrofit;
|
||||||
private String accessToken;
|
private String accessToken;
|
||||||
private Locale locale;
|
private Locale locale;
|
||||||
@ -86,6 +87,10 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
|
|||||||
this.params = params;
|
this.params = params;
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
|
|
||||||
|
if(params.key.equals("null")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
paginationNetworkStateLiveData.postValue(NetworkState.LOADING);
|
paginationNetworkStateLiveData.postValue(NetworkState.LOADING);
|
||||||
|
|
||||||
switch (postType) {
|
switch (postType) {
|
||||||
|
@ -82,6 +82,7 @@
|
|||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:textSize="12sp"
|
android:textSize="12sp"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
app:chipBackgroundColor="@color/colorPrimaryDark"/>
|
app:chipBackgroundColor="@color/colorPrimaryDark"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
@ -90,6 +91,7 @@
|
|||||||
android:layout_height="24dp"
|
android:layout_height="24dp"
|
||||||
android:layout_toEndOf="@id/type_text_view_item_best_post"
|
android:layout_toEndOf="@id/type_text_view_item_best_post"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
android:visibility="gone"/>
|
android:visibility="gone"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -102,7 +104,8 @@
|
|||||||
android:layout_toEndOf="@id/gilded_image_view_item_best_post"
|
android:layout_toEndOf="@id/gilded_image_view_item_best_post"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
android:textColor="@color/gold"/>
|
android:textColor="@color/gold"
|
||||||
|
android:layout_centerVertical="true"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/crosspost_image_view_item_best_post"
|
android:id="@+id/crosspost_image_view_item_best_post"
|
||||||
@ -115,6 +118,7 @@
|
|||||||
android:layout_toEndOf="@id/gilded_number_text_view_item_best_post"
|
android:layout_toEndOf="@id/gilded_number_text_view_item_best_post"
|
||||||
android:src="@drawable/crosspost"
|
android:src="@drawable/crosspost"
|
||||||
android:tint="@color/colorAccent"
|
android:tint="@color/colorAccent"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
android:visibility="gone"/>
|
android:visibility="gone"/>
|
||||||
|
|
||||||
<android.support.design.chip.Chip
|
<android.support.design.chip.Chip
|
||||||
@ -128,6 +132,7 @@
|
|||||||
android:textSize="12sp"
|
android:textSize="12sp"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
app:chipBackgroundColor="@color/colorAccent"/>
|
app:chipBackgroundColor="@color/colorAccent"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user