Some fixes
This commit is contained in:
parent
9629b694eb
commit
52f026aa75
|
@ -93,6 +93,10 @@ dependencies {
|
|||
implementation 'androidx.exifinterface:exifinterface:1.1.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
implementation "com.github.bumptech.glide:glide:$glideLibraryVersion"
|
||||
implementation ("com.github.bumptech.glide:recyclerview-integration:$glideLibraryVersion") {
|
||||
// Excludes the support library because it's already included by Glide.
|
||||
transitive = false
|
||||
}
|
||||
annotationProcessor "com.github.bumptech.glide:compiler:$glideLibraryVersion"
|
||||
annotationProcessor 'com.android.support:support-annotations:28.0.0'
|
||||
implementation "org.conscrypt:conscrypt-android:$conscryptLibraryVersion"
|
||||
|
|
|
@ -911,7 +911,9 @@ public class HttpsConnection {
|
|||
// always check HTTP response code first
|
||||
if (responseCode == HttpURLConnection.HTTP_OK) {
|
||||
// opens input stream from the HTTP connection
|
||||
return httpsURLConnection.getInputStream();
|
||||
InputStream inputStream = httpsURLConnection.getInputStream();
|
||||
httpsURLConnection.getInputStream().close();
|
||||
return inputStream;
|
||||
}
|
||||
httpsURLConnection.getInputStream().close();
|
||||
} catch (IOException | NoSuchAlgorithmException | KeyManagementException ignored) {
|
||||
|
|
|
@ -150,6 +150,7 @@ import app.fedilab.android.client.Entities.Relationship;
|
|||
import app.fedilab.android.client.Entities.Status;
|
||||
import app.fedilab.android.client.Entities.StoredStatus;
|
||||
import app.fedilab.android.client.Entities.TagTimeline;
|
||||
import app.fedilab.android.client.Glide.GlideApp;
|
||||
import app.fedilab.android.fragments.DisplayStatusFragment;
|
||||
import app.fedilab.android.helper.CrossActions;
|
||||
import app.fedilab.android.helper.CustomTextView;
|
||||
|
@ -3506,10 +3507,11 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
imageView.setImageBitmap(null);
|
||||
if (!url.trim().contains("missing.png") && !((Activity) context).isFinishing()) {
|
||||
if (!blur) {
|
||||
Glide.with(imageView.getContext())
|
||||
GlideApp.with(imageView.getContext())
|
||||
.asBitmap()
|
||||
.load(!attachment.getType().toLowerCase().equals("audio") ? url : R.drawable.ic_audio_wave)
|
||||
.thumbnail(0.1f)
|
||||
.override(640, 480)
|
||||
.apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10)))
|
||||
.into(new SimpleTarget<Bitmap>() {
|
||||
@Override
|
||||
|
@ -3529,10 +3531,11 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
}
|
||||
});
|
||||
} else {
|
||||
Glide.with(imageView.getContext())
|
||||
GlideApp.with(imageView.getContext())
|
||||
.asBitmap()
|
||||
.load(!attachment.getType().toLowerCase().equals("audio") ? url : R.drawable.ic_audio_wave)
|
||||
.thumbnail(0.1f)
|
||||
.override(640, 480)
|
||||
.apply(new RequestOptions().transforms(new BlurTransformation(50, 3), new RoundedCorners(10)))
|
||||
.into(new SimpleTarget<Bitmap>() {
|
||||
@Override
|
||||
|
@ -3555,16 +3558,18 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
} else {
|
||||
if (!url.trim().contains("missing.png") && !((Activity) context).isFinishing()) {
|
||||
if (!blur) {
|
||||
Glide.with(imageView.getContext())
|
||||
GlideApp.with(imageView.getContext())
|
||||
.load(!attachment.getType().toLowerCase().equals("audio") ? url : R.drawable.ic_audio_wave)
|
||||
.thumbnail(0.1f)
|
||||
.override(640, 480)
|
||||
.apply(new RequestOptions().transforms(new CenterCrop(), new RoundedCorners(10)))
|
||||
.transition(DrawableTransitionOptions.withCrossFade())
|
||||
.into(imageView);
|
||||
} else {
|
||||
Glide.with(imageView.getContext())
|
||||
GlideApp.with(imageView.getContext())
|
||||
.load(!attachment.getType().toLowerCase().equals("audio") ? url : R.drawable.ic_audio_wave)
|
||||
.thumbnail(0.1f)
|
||||
.override(640, 480)
|
||||
.apply(new RequestOptions().transforms(new BlurTransformation(50, 3), new RoundedCorners(10)))
|
||||
.transition(DrawableTransitionOptions.withCrossFade())
|
||||
.into(imageView);
|
||||
|
|
|
@ -25,6 +25,7 @@ import android.os.AsyncTask;
|
|||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.provider.ContactsContract;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -34,13 +35,21 @@ import android.widget.TextView;
|
|||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
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.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -56,12 +65,14 @@ import app.fedilab.android.asynctasks.RetrievePeertubeSearchAsyncTask;
|
|||
import app.fedilab.android.asynctasks.UpdateAccountInfoAsyncTask;
|
||||
import app.fedilab.android.client.APIResponse;
|
||||
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.Peertube;
|
||||
import app.fedilab.android.client.Entities.RemoteInstance;
|
||||
import app.fedilab.android.client.Entities.RetrieveFeedsParam;
|
||||
import app.fedilab.android.client.Entities.Status;
|
||||
import app.fedilab.android.client.Entities.TagTimeline;
|
||||
import app.fedilab.android.client.Glide.GlideApp;
|
||||
import app.fedilab.android.drawers.ArtListAdapter;
|
||||
import app.fedilab.android.drawers.PeertubeAdapter;
|
||||
import app.fedilab.android.drawers.PixelfedListAdapter;
|
||||
|
@ -130,6 +141,32 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
public DisplayStatusFragment() {
|
||||
}
|
||||
|
||||
|
||||
private class MyPreloadModelProvider implements ListPreloader.PreloadModelProvider<String> {
|
||||
@Override
|
||||
@NonNull
|
||||
public List<String> getPreloadItems(int position) {
|
||||
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 GlideApp.with(context)
|
||||
.load(url)
|
||||
.override(640, 480);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View rootView = inflater.inflate(R.layout.fragment_status, container, false);
|
||||
|
@ -189,6 +226,13 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
c1, c2, c1
|
||||
);
|
||||
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);
|
||||
nextElementLoader = rootView.findViewById(R.id.loading_next_status);
|
||||
textviewNoAction = rootView.findViewById(R.id.no_action);
|
||||
|
|
Loading…
Reference in New Issue