Remove pre-loader
This commit is contained in:
parent
b2c8336a0f
commit
fd0d44c136
|
@ -24,7 +24,6 @@ import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.provider.ContactsContract;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -42,7 +41,6 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.ListPreloader;
|
import com.bumptech.glide.ListPreloader;
|
||||||
import com.bumptech.glide.RequestBuilder;
|
import com.bumptech.glide.RequestBuilder;
|
||||||
import com.bumptech.glide.integration.recyclerview.RecyclerViewPreloader;
|
|
||||||
import com.bumptech.glide.util.FixedPreloadSizeProvider;
|
import com.bumptech.glide.util.FixedPreloadSizeProvider;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
@ -58,7 +56,6 @@ import app.fedilab.android.asynctasks.RetrieveNotificationsAsyncTask;
|
||||||
import app.fedilab.android.asynctasks.UpdateAccountInfoAsyncTask;
|
import app.fedilab.android.asynctasks.UpdateAccountInfoAsyncTask;
|
||||||
import app.fedilab.android.client.APIResponse;
|
import app.fedilab.android.client.APIResponse;
|
||||||
import app.fedilab.android.client.Entities.Account;
|
import app.fedilab.android.client.Entities.Account;
|
||||||
import app.fedilab.android.client.Entities.Attachment;
|
|
||||||
import app.fedilab.android.client.Entities.Notification;
|
import app.fedilab.android.client.Entities.Notification;
|
||||||
import app.fedilab.android.client.Entities.Status;
|
import app.fedilab.android.client.Entities.Status;
|
||||||
import app.fedilab.android.drawers.NotificationsListAdapter;
|
import app.fedilab.android.drawers.NotificationsListAdapter;
|
||||||
|
@ -125,15 +122,7 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
||||||
if (bundle != null) {
|
if (bundle != null) {
|
||||||
type = (Type) bundle.get("type");
|
type = (Type) bundle.get("type");
|
||||||
}
|
}
|
||||||
RelativeLayout main_timeline_container;
|
|
||||||
lv_notifications = rootView.findViewById(R.id.lv_notifications);
|
lv_notifications = rootView.findViewById(R.id.lv_notifications);
|
||||||
ListPreloader.PreloadSizeProvider sizeProvider =
|
|
||||||
new FixedPreloadSizeProvider(640, 480);
|
|
||||||
ListPreloader.PreloadModelProvider modelProvider = new MyPreloadModelProvider();
|
|
||||||
RecyclerViewPreloader<ContactsContract.CommonDataKinds.Photo> preloader =
|
|
||||||
new RecyclerViewPreloader<>(
|
|
||||||
Glide.with(context), modelProvider, sizeProvider, 20 );
|
|
||||||
lv_notifications.addOnScrollListener(preloader);
|
|
||||||
mainLoader = rootView.findViewById(R.id.loader);
|
mainLoader = rootView.findViewById(R.id.loader);
|
||||||
nextElementLoader = rootView.findViewById(R.id.loading_next_notifications);
|
nextElementLoader = rootView.findViewById(R.id.loading_next_notifications);
|
||||||
textviewNoAction = rootView.findViewById(R.id.no_action);
|
textviewNoAction = rootView.findViewById(R.id.no_action);
|
||||||
|
@ -517,32 +506,6 @@ public class DisplayNotificationsFragment extends Fragment implements OnRetrieve
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MyPreloadModelProvider implements ListPreloader.PreloadModelProvider<String> {
|
|
||||||
@Override
|
|
||||||
@NonNull
|
|
||||||
public List<String> getPreloadItems(int position) {
|
|
||||||
Status status = notifications.get(position).getStatus();
|
|
||||||
if (status == null || status.getMedia_attachments() == null || status.getMedia_attachments().size() ==0) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
List<String> preloaded_urls = new ArrayList<>();
|
|
||||||
for(Attachment attachment: status.getMedia_attachments()) {
|
|
||||||
preloaded_urls.add(attachment.getPreview_url());
|
|
||||||
}
|
|
||||||
return preloaded_urls;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public RequestBuilder<?> getPreloadRequestBuilder(@NonNull String url) {
|
|
||||||
return Glide.with(context)
|
|
||||||
.load(url)
|
|
||||||
.override(640, 480);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public enum Type {
|
public enum Type {
|
||||||
ALL,
|
ALL,
|
||||||
MENTION,
|
MENTION,
|
||||||
|
|
|
@ -35,21 +35,14 @@ import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
|
||||||
import com.bumptech.glide.ListPreloader;
|
|
||||||
import com.bumptech.glide.RequestBuilder;
|
|
||||||
import com.bumptech.glide.integration.recyclerview.RecyclerViewPreloader;
|
|
||||||
import com.bumptech.glide.util.FixedPreloadSizeProvider;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -65,7 +58,6 @@ import app.fedilab.android.asynctasks.RetrievePeertubeSearchAsyncTask;
|
||||||
import app.fedilab.android.asynctasks.UpdateAccountInfoAsyncTask;
|
import app.fedilab.android.asynctasks.UpdateAccountInfoAsyncTask;
|
||||||
import app.fedilab.android.client.APIResponse;
|
import app.fedilab.android.client.APIResponse;
|
||||||
import app.fedilab.android.client.Entities.Account;
|
import app.fedilab.android.client.Entities.Account;
|
||||||
import app.fedilab.android.client.Entities.Attachment;
|
|
||||||
import app.fedilab.android.client.Entities.Conversation;
|
import app.fedilab.android.client.Entities.Conversation;
|
||||||
import app.fedilab.android.client.Entities.Peertube;
|
import app.fedilab.android.client.Entities.Peertube;
|
||||||
import app.fedilab.android.client.Entities.RemoteInstance;
|
import app.fedilab.android.client.Entities.RemoteInstance;
|
||||||
|
@ -141,33 +133,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private class MyPreloadModelProvider implements ListPreloader.PreloadModelProvider<String> {
|
|
||||||
@Override
|
|
||||||
@NonNull
|
|
||||||
public List<String> getPreloadItems(int position) {
|
|
||||||
if( statuses == null || statuses.size() == 0){
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
Status status = statuses.get(position);
|
|
||||||
if (status.getMedia_attachments() == null || status.getMedia_attachments().size() ==0) {
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
List<String> preloaded_urls = new ArrayList<>();
|
|
||||||
for(Attachment attachment: status.getMedia_attachments()) {
|
|
||||||
preloaded_urls.add(attachment.getPreview_url());
|
|
||||||
}
|
|
||||||
return preloaded_urls;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public RequestBuilder<?> getPreloadRequestBuilder(@NonNull String url) {
|
|
||||||
return Glide.with(context)
|
|
||||||
.load(url)
|
|
||||||
.override(640, 480);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
@ -228,13 +194,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
||||||
c1, c2, c1
|
c1, c2, c1
|
||||||
);
|
);
|
||||||
lv_status = rootView.findViewById(R.id.lv_status);
|
lv_status = rootView.findViewById(R.id.lv_status);
|
||||||
ListPreloader.PreloadSizeProvider sizeProvider =
|
|
||||||
new FixedPreloadSizeProvider(640, 480);
|
|
||||||
ListPreloader.PreloadModelProvider modelProvider = new MyPreloadModelProvider();
|
|
||||||
RecyclerViewPreloader<ContactsContract.CommonDataKinds.Photo> preloader =
|
|
||||||
new RecyclerViewPreloader<>(
|
|
||||||
Glide.with(context), modelProvider, sizeProvider, 20 );
|
|
||||||
lv_status.addOnScrollListener(preloader);
|
|
||||||
mainLoader = rootView.findViewById(R.id.loader);
|
mainLoader = rootView.findViewById(R.id.loader);
|
||||||
nextElementLoader = rootView.findViewById(R.id.loading_next_status);
|
nextElementLoader = rootView.findViewById(R.id.loading_next_status);
|
||||||
textviewNoAction = rootView.findViewById(R.id.no_action);
|
textviewNoAction = rootView.findViewById(R.id.no_action);
|
||||||
|
|
Loading…
Reference in New Issue