mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
887cc3a1bb
* Update messenger-backend submodule. * display a swipe able media gallery when one taps an image * display a tiled gallery from chat-menu and from preview gallery * changed some utility classes to handle the new situations
52 lines
1.7 KiB
Java
52 lines
1.7 KiB
Java
package org.thoughtcrime.securesms.database.loaders;
|
|
|
|
|
|
import android.content.Context;
|
|
import android.support.annotation.NonNull;
|
|
import android.support.annotation.Nullable;
|
|
import android.util.Log;
|
|
|
|
import com.b44t.messenger.DcContext;
|
|
import com.b44t.messenger.DcMediaGalleryElement;
|
|
import com.b44t.messenger.DcMsg;
|
|
|
|
import org.thoughtcrime.securesms.connect.DcHelper;
|
|
import org.thoughtcrime.securesms.util.AsyncLoader;
|
|
|
|
public class PagingMediaLoader extends AsyncLoader<DcMediaGalleryElement> {
|
|
|
|
@SuppressWarnings("unused")
|
|
private static final String TAG = PagingMediaLoader.class.getSimpleName();
|
|
|
|
private final DcMsg msg;
|
|
private final boolean leftIsRecent;
|
|
|
|
public PagingMediaLoader(@NonNull Context context, @NonNull DcMsg msg, boolean leftIsRecent) {
|
|
super(context);
|
|
this.msg = msg;
|
|
this.leftIsRecent = leftIsRecent;
|
|
}
|
|
|
|
@Nullable
|
|
@Override
|
|
public DcMediaGalleryElement loadInBackground() {
|
|
DcContext context = DcHelper.getContext(getContext());
|
|
int[] mediaMessages = context.getChatMedia(msg.getChatId(), DcMsg.DC_MSG_GIF, DcMsg.DC_MSG_IMAGE);
|
|
// first id is the oldest message.
|
|
int currentIndex = -1;
|
|
for(int ii = 0; ii < mediaMessages.length; ii++) {
|
|
if(mediaMessages[ii] == msg.getId()) {
|
|
currentIndex = ii;
|
|
break;
|
|
}
|
|
}
|
|
if(currentIndex == -1) {
|
|
currentIndex = 0;
|
|
DcMsg unfound = context.getMsg(msg.getId());
|
|
Log.d(TAG, "did not find message in list: " + unfound.getId() + " / " + unfound.getFile() + " / " + unfound.getText());
|
|
}
|
|
DcMediaGalleryElement retVal = new DcMediaGalleryElement(mediaMessages, currentIndex, context, leftIsRecent);
|
|
return retVal;
|
|
}
|
|
}
|