mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-08 07:57:28 +00:00
restore dm button on profiles
This commit is contained in:
parent
9bf72b2781
commit
a55def53c5
@ -71,6 +71,7 @@ import awais.instagrabber.interfaces.FetchListener;
|
|||||||
import awais.instagrabber.models.IntentModel;
|
import awais.instagrabber.models.IntentModel;
|
||||||
import awais.instagrabber.models.SuggestionModel;
|
import awais.instagrabber.models.SuggestionModel;
|
||||||
import awais.instagrabber.models.enums.SuggestionType;
|
import awais.instagrabber.models.enums.SuggestionType;
|
||||||
|
import awais.instagrabber.repositories.responses.directmessages.DirectThread;
|
||||||
import awais.instagrabber.services.ActivityCheckerService;
|
import awais.instagrabber.services.ActivityCheckerService;
|
||||||
import awais.instagrabber.services.DMSyncAlarmReceiver;
|
import awais.instagrabber.services.DMSyncAlarmReceiver;
|
||||||
import awais.instagrabber.utils.AppExecutors;
|
import awais.instagrabber.utils.AppExecutors;
|
||||||
@ -573,10 +574,10 @@ public class MainActivity extends BaseLanguageActivity implements FragmentManage
|
|||||||
private void showThread(@NonNull final Intent intent) {
|
private void showThread(@NonNull final Intent intent) {
|
||||||
final String threadId = intent.getStringExtra(Constants.DM_THREAD_ACTION_EXTRA_THREAD_ID);
|
final String threadId = intent.getStringExtra(Constants.DM_THREAD_ACTION_EXTRA_THREAD_ID);
|
||||||
final String threadTitle = intent.getStringExtra(Constants.DM_THREAD_ACTION_EXTRA_THREAD_TITLE);
|
final String threadTitle = intent.getStringExtra(Constants.DM_THREAD_ACTION_EXTRA_THREAD_TITLE);
|
||||||
navigateToThread(threadId, threadTitle);
|
navigateToThread(threadId, threadTitle, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void navigateToThread(final String threadId, final String threadTitle) {
|
public void navigateToThread(final String threadId, final String threadTitle, final DirectThread backup) {
|
||||||
if (threadId == null || threadTitle == null) return;
|
if (threadId == null || threadTitle == null) return;
|
||||||
currentNavControllerLiveData.observe(this, new Observer<NavController>() {
|
currentNavControllerLiveData.observe(this, new Observer<NavController>() {
|
||||||
@Override
|
@Override
|
||||||
@ -590,7 +591,7 @@ public class MainActivity extends BaseLanguageActivity implements FragmentManage
|
|||||||
// need handler.post() to wait for the fragment manager to be ready to navigate
|
// need handler.post() to wait for the fragment manager to be ready to navigate
|
||||||
new Handler().post(() -> {
|
new Handler().post(() -> {
|
||||||
final DirectMessageInboxFragmentDirections.ActionInboxToThread action = DirectMessageInboxFragmentDirections
|
final DirectMessageInboxFragmentDirections.ActionInboxToThread action = DirectMessageInboxFragmentDirections
|
||||||
.actionInboxToThread(threadId, threadTitle);
|
.actionInboxToThread(threadId, threadTitle, backup);
|
||||||
navController.navigate(action);
|
navController.navigate(action);
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@ -603,7 +604,7 @@ public class MainActivity extends BaseLanguageActivity implements FragmentManage
|
|||||||
@Nullable final Bundle arguments) {
|
@Nullable final Bundle arguments) {
|
||||||
if (destination.getId() == R.id.directMessagesInboxFragment) {
|
if (destination.getId() == R.id.directMessagesInboxFragment) {
|
||||||
final DirectMessageInboxFragmentDirections.ActionInboxToThread action = DirectMessageInboxFragmentDirections
|
final DirectMessageInboxFragmentDirections.ActionInboxToThread action = DirectMessageInboxFragmentDirections
|
||||||
.actionInboxToThread(threadId, threadTitle);
|
.actionInboxToThread(threadId, threadTitle, backup);
|
||||||
controller.navigate(action);
|
controller.navigate(action);
|
||||||
controller.removeOnDestinationChangedListener(this);
|
controller.removeOnDestinationChangedListener(this);
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,7 @@ public class DirectMessageInboxFragment extends Fragment implements SwipeRefresh
|
|||||||
navigating = true;
|
navigating = true;
|
||||||
if (isAdded()) {
|
if (isAdded()) {
|
||||||
final DirectMessageInboxFragmentDirections.ActionInboxToThread directions = DirectMessageInboxFragmentDirections
|
final DirectMessageInboxFragmentDirections.ActionInboxToThread directions = DirectMessageInboxFragmentDirections
|
||||||
.actionInboxToThread(thread.getThreadId(), thread.getThreadTitle());
|
.actionInboxToThread(thread.getThreadId(), thread.getThreadTitle(), thread);
|
||||||
NavHostFragment.findNavController(this).navigate(directions);
|
NavHostFragment.findNavController(this).navigate(directions);
|
||||||
}
|
}
|
||||||
navigating = false;
|
navigating = false;
|
||||||
|
@ -79,6 +79,7 @@ public class DirectMessageSettingsFragment extends Fragment implements ConfirmDi
|
|||||||
final AppStateViewModel appStateViewModel = new ViewModelProvider(fragmentActivity).get(AppStateViewModel.class);
|
final AppStateViewModel appStateViewModel = new ViewModelProvider(fragmentActivity).get(AppStateViewModel.class);
|
||||||
viewModel = new ViewModelProvider(this, new DirectSettingsViewModelFactory(fragmentActivity.getApplication(),
|
viewModel = new ViewModelProvider(this, new DirectSettingsViewModelFactory(fragmentActivity.getApplication(),
|
||||||
args.getThreadId(),
|
args.getThreadId(),
|
||||||
|
args.getBackup(),
|
||||||
args.getPending(),
|
args.getPending(),
|
||||||
appStateViewModel.getCurrentUser()))
|
appStateViewModel.getCurrentUser()))
|
||||||
.get(DirectSettingsViewModel.class);
|
.get(DirectSettingsViewModel.class);
|
||||||
|
@ -327,6 +327,7 @@ public class DirectMessageThreadFragment extends Fragment implements DirectReact
|
|||||||
final DirectMessageThreadFragmentArgs fragmentArgs = DirectMessageThreadFragmentArgs.fromBundle(arguments);
|
final DirectMessageThreadFragmentArgs fragmentArgs = DirectMessageThreadFragmentArgs.fromBundle(arguments);
|
||||||
viewModel = new ViewModelProvider(this, new DirectThreadViewModelFactory(fragmentActivity.getApplication(),
|
viewModel = new ViewModelProvider(this, new DirectThreadViewModelFactory(fragmentActivity.getApplication(),
|
||||||
fragmentArgs.getThreadId(),
|
fragmentArgs.getThreadId(),
|
||||||
|
fragmentArgs.getBackup(),
|
||||||
fragmentArgs.getPending(),
|
fragmentArgs.getPending(),
|
||||||
appStateViewModel.getCurrentUser()))
|
appStateViewModel.getCurrentUser()))
|
||||||
.get(DirectThreadViewModel.class);
|
.get(DirectThreadViewModel.class);
|
||||||
@ -376,7 +377,7 @@ public class DirectMessageThreadFragment extends Fragment implements DirectReact
|
|||||||
final int itemId = item.getItemId();
|
final int itemId = item.getItemId();
|
||||||
if (itemId == R.id.info) {
|
if (itemId == R.id.info) {
|
||||||
final DirectMessageThreadFragmentDirections.ActionThreadToSettings directions = DirectMessageThreadFragmentDirections
|
final DirectMessageThreadFragmentDirections.ActionThreadToSettings directions = DirectMessageThreadFragmentDirections
|
||||||
.actionThreadToSettings(viewModel.getThreadId(), null);
|
.actionThreadToSettings(viewModel.getThreadId(), null, null);
|
||||||
final Boolean pending = viewModel.isPending().getValue();
|
final Boolean pending = viewModel.isPending().getValue();
|
||||||
directions.setPending(pending == null ? false : pending);
|
directions.setPending(pending == null ? false : pending);
|
||||||
NavHostFragment.findNavController(this).navigate(directions);
|
NavHostFragment.findNavController(this).navigate(directions);
|
||||||
|
@ -163,7 +163,7 @@ public class DirectPendingInboxFragment extends Fragment implements SwipeRefresh
|
|||||||
navigating = true;
|
navigating = true;
|
||||||
if (isAdded()) {
|
if (isAdded()) {
|
||||||
final DirectPendingInboxFragmentDirections.ActionPendingInboxToThread directions = DirectPendingInboxFragmentDirections
|
final DirectPendingInboxFragmentDirections.ActionPendingInboxToThread directions = DirectPendingInboxFragmentDirections
|
||||||
.actionPendingInboxToThread(thread.getThreadId(), thread.getThreadTitle());
|
.actionPendingInboxToThread(thread.getThreadId(), thread.getThreadTitle(), thread);
|
||||||
directions.setPending(true);
|
directions.setPending(true);
|
||||||
NavHostFragment.findNavController(this).navigate(directions);
|
NavHostFragment.findNavController(this).navigate(directions);
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,7 @@ import awais.instagrabber.R;
|
|||||||
import awais.instagrabber.activities.MainActivity;
|
import awais.instagrabber.activities.MainActivity;
|
||||||
import awais.instagrabber.adapters.FeedAdapterV2;
|
import awais.instagrabber.adapters.FeedAdapterV2;
|
||||||
import awais.instagrabber.adapters.HighlightsAdapter;
|
import awais.instagrabber.adapters.HighlightsAdapter;
|
||||||
|
import awais.instagrabber.asyncs.CreateThreadAction;
|
||||||
import awais.instagrabber.asyncs.ProfileFetcher;
|
import awais.instagrabber.asyncs.ProfileFetcher;
|
||||||
import awais.instagrabber.asyncs.ProfilePostFetchService;
|
import awais.instagrabber.asyncs.ProfilePostFetchService;
|
||||||
import awais.instagrabber.asyncs.UsernameFetcher;
|
import awais.instagrabber.asyncs.UsernameFetcher;
|
||||||
@ -911,19 +912,18 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
|||||||
|
|
||||||
private void setupButtons(final long profileId, final long myId) {
|
private void setupButtons(final long profileId, final long myId) {
|
||||||
profileDetailsBinding.btnTagged.setVisibility(isReallyPrivate() ? View.GONE : View.VISIBLE);
|
profileDetailsBinding.btnTagged.setVisibility(isReallyPrivate() ? View.GONE : View.VISIBLE);
|
||||||
profileDetailsBinding.btnDM.setVisibility(View.GONE); // temporary measure
|
|
||||||
if (isLoggedIn) {
|
if (isLoggedIn) {
|
||||||
if (Objects.equals(profileId, myId)) {
|
if (Objects.equals(profileId, myId)) {
|
||||||
profileDetailsBinding.btnTagged.setVisibility(View.VISIBLE);
|
profileDetailsBinding.btnTagged.setVisibility(View.VISIBLE);
|
||||||
profileDetailsBinding.btnSaved.setVisibility(View.VISIBLE);
|
profileDetailsBinding.btnSaved.setVisibility(View.VISIBLE);
|
||||||
profileDetailsBinding.btnLiked.setVisibility(View.VISIBLE);
|
profileDetailsBinding.btnLiked.setVisibility(View.VISIBLE);
|
||||||
// profileDetailsBinding.btnDM.setVisibility(View.GONE);
|
profileDetailsBinding.btnDM.setVisibility(View.GONE);
|
||||||
profileDetailsBinding.btnSaved.setText(R.string.saved);
|
profileDetailsBinding.btnSaved.setText(R.string.saved);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
profileDetailsBinding.btnSaved.setVisibility(View.GONE);
|
profileDetailsBinding.btnSaved.setVisibility(View.GONE);
|
||||||
profileDetailsBinding.btnLiked.setVisibility(View.GONE);
|
profileDetailsBinding.btnLiked.setVisibility(View.GONE);
|
||||||
// profileDetailsBinding.btnDM.setVisibility(View.VISIBLE);
|
profileDetailsBinding.btnDM.setVisibility(View.VISIBLE);
|
||||||
profileDetailsBinding.btnFollow.setVisibility(View.VISIBLE);
|
profileDetailsBinding.btnFollow.setVisibility(View.VISIBLE);
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
if (context == null) return;
|
if (context == null) return;
|
||||||
@ -1081,27 +1081,18 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
|||||||
PostItemType.TAGGED);
|
PostItemType.TAGGED);
|
||||||
NavHostFragment.findNavController(this).navigate(action);
|
NavHostFragment.findNavController(this).navigate(action);
|
||||||
});
|
});
|
||||||
// profileDetailsBinding.btnDM.setOnClickListener(v -> {
|
profileDetailsBinding.btnDM.setOnClickListener(v -> {
|
||||||
// profileDetailsBinding.btnDM.setEnabled(false);
|
profileDetailsBinding.btnDM.setEnabled(false);
|
||||||
// new CreateThreadAction(cookie, profileModel.getPk(), thread -> {
|
new CreateThreadAction(cookie, profileModel.getPk(), thread -> {
|
||||||
// if (thread == null) {
|
if (thread == null) {
|
||||||
// Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
||||||
// profileDetailsBinding.btnDM.setEnabled(true);
|
profileDetailsBinding.btnDM.setEnabled(true);
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
// if (isAdded()) {
|
fragmentActivity.navigateToThread(thread.getThreadId(), profileModel.getUsername(), thread);
|
||||||
// final Bundle bundle = new Bundle();
|
profileDetailsBinding.btnDM.setEnabled(true);
|
||||||
// bundle.putString("threadId", thread.getThreadId());
|
}).execute();
|
||||||
// bundle.putString("title", thread.getThreadTitle());
|
});
|
||||||
// if (isAdded()) {
|
|
||||||
// final NavDirections action = ProfileFragmentDirections
|
|
||||||
// .actionProfileFragmentToDMThreadFragment(thread.getThreadId(), profileModel.getUsername());
|
|
||||||
// NavHostFragment.findNavController(this).navigate(action);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// profileDetailsBinding.btnDM.setEnabled(true);
|
|
||||||
// }).execute();
|
|
||||||
// });
|
|
||||||
profileDetailsBinding.mainProfileImage.setOnClickListener(v -> {
|
profileDetailsBinding.mainProfileImage.setOnClickListener(v -> {
|
||||||
if (!hasStories) {
|
if (!hasStories) {
|
||||||
// show profile pic
|
// show profile pic
|
||||||
|
@ -74,8 +74,9 @@ public final class DirectMessagesManager {
|
|||||||
|
|
||||||
public ThreadManager getThreadManager(@NonNull final String threadId,
|
public ThreadManager getThreadManager(@NonNull final String threadId,
|
||||||
final boolean pending,
|
final boolean pending,
|
||||||
|
final DirectThread backup,
|
||||||
@NonNull final User currentUser,
|
@NonNull final User currentUser,
|
||||||
@NonNull final ContentResolver contentResolver) {
|
@NonNull final ContentResolver contentResolver) {
|
||||||
return ThreadManager.getInstance(threadId, pending, currentUser, contentResolver);
|
return ThreadManager.getInstance(threadId, pending, backup, currentUser, contentResolver);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,6 +122,7 @@ public final class ThreadManager {
|
|||||||
|
|
||||||
public static ThreadManager getInstance(@NonNull final String threadId,
|
public static ThreadManager getInstance(@NonNull final String threadId,
|
||||||
final boolean pending,
|
final boolean pending,
|
||||||
|
final DirectThread backup,
|
||||||
@NonNull final User currentUser,
|
@NonNull final User currentUser,
|
||||||
@NonNull final ContentResolver contentResolver) {
|
@NonNull final ContentResolver contentResolver) {
|
||||||
ThreadManager instance = INSTANCE_MAP.get(threadId);
|
ThreadManager instance = INSTANCE_MAP.get(threadId);
|
||||||
@ -129,7 +130,7 @@ public final class ThreadManager {
|
|||||||
synchronized (LOCK) {
|
synchronized (LOCK) {
|
||||||
instance = INSTANCE_MAP.get(threadId);
|
instance = INSTANCE_MAP.get(threadId);
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new ThreadManager(threadId, pending, currentUser, contentResolver);
|
instance = new ThreadManager(threadId, pending, backup, currentUser, contentResolver);
|
||||||
INSTANCE_MAP.put(threadId, instance);
|
INSTANCE_MAP.put(threadId, instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -143,6 +144,7 @@ public final class ThreadManager {
|
|||||||
|
|
||||||
private ThreadManager(@NonNull final String threadId,
|
private ThreadManager(@NonNull final String threadId,
|
||||||
final boolean pending,
|
final boolean pending,
|
||||||
|
final DirectThread backup,
|
||||||
@NonNull final User currentUser,
|
@NonNull final User currentUser,
|
||||||
@NonNull final ContentResolver contentResolver) {
|
@NonNull final ContentResolver contentResolver) {
|
||||||
final DirectMessagesManager messagesManager = DirectMessagesManager.getInstance();
|
final DirectMessagesManager messagesManager = DirectMessagesManager.getInstance();
|
||||||
@ -161,17 +163,17 @@ public final class ThreadManager {
|
|||||||
service = DirectMessagesService.getInstance(csrfToken, viewerId, deviceUuid);
|
service = DirectMessagesService.getInstance(csrfToken, viewerId, deviceUuid);
|
||||||
mediaService = MediaService.getInstance(deviceUuid, csrfToken, viewerId);
|
mediaService = MediaService.getInstance(deviceUuid, csrfToken, viewerId);
|
||||||
friendshipService = FriendshipService.getInstance(deviceUuid, csrfToken, viewerId);
|
friendshipService = FriendshipService.getInstance(deviceUuid, csrfToken, viewerId);
|
||||||
setupTransformations();
|
setupTransformations(backup);
|
||||||
// fetchChats();
|
// fetchChats();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void moveFromPending() {
|
public void moveFromPending() {
|
||||||
final DirectMessagesManager messagesManager = DirectMessagesManager.getInstance();
|
final DirectMessagesManager messagesManager = DirectMessagesManager.getInstance();
|
||||||
this.inboxManager = messagesManager.getInboxManager();
|
this.inboxManager = messagesManager.getInboxManager();
|
||||||
setupTransformations();
|
setupTransformations(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupTransformations() {
|
private void setupTransformations(final DirectThread backup) {
|
||||||
// Transformations
|
// Transformations
|
||||||
thread = distinctUntilChanged(map(inboxManager.getInbox(), inboxResource -> {
|
thread = distinctUntilChanged(map(inboxManager.getInbox(), inboxResource -> {
|
||||||
if (inboxResource == null) {
|
if (inboxResource == null) {
|
||||||
@ -185,7 +187,7 @@ public final class ThreadManager {
|
|||||||
final DirectThread thread = threads.stream()
|
final DirectThread thread = threads.stream()
|
||||||
.filter(t -> t.getThreadId().equals(threadId))
|
.filter(t -> t.getThreadId().equals(threadId))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(backup);
|
||||||
if (thread != null) {
|
if (thread != null) {
|
||||||
cursor = thread.getOldestCursor();
|
cursor = thread.getOldestCursor();
|
||||||
hasOlder = thread.hasOlder();
|
hasOlder = thread.hasOlder();
|
||||||
|
@ -45,6 +45,7 @@ public class DirectSettingsViewModel extends AndroidViewModel {
|
|||||||
|
|
||||||
public DirectSettingsViewModel(final Application application,
|
public DirectSettingsViewModel(final Application application,
|
||||||
@NonNull final String threadId,
|
@NonNull final String threadId,
|
||||||
|
final DirectThread backup,
|
||||||
final boolean pending,
|
final boolean pending,
|
||||||
@NonNull final User currentUser) {
|
@NonNull final User currentUser) {
|
||||||
super(application);
|
super(application);
|
||||||
@ -58,7 +59,7 @@ public class DirectSettingsViewModel extends AndroidViewModel {
|
|||||||
final ContentResolver contentResolver = application.getContentResolver();
|
final ContentResolver contentResolver = application.getContentResolver();
|
||||||
resources = getApplication().getResources();
|
resources = getApplication().getResources();
|
||||||
final DirectMessagesManager messagesManager = DirectMessagesManager.getInstance();
|
final DirectMessagesManager messagesManager = DirectMessagesManager.getInstance();
|
||||||
threadManager = messagesManager.getThreadManager(threadId, pending, currentUser, contentResolver);
|
threadManager = messagesManager.getThreadManager(threadId, pending, backup, currentUser, contentResolver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -53,6 +53,7 @@ public class DirectThreadViewModel extends AndroidViewModel {
|
|||||||
|
|
||||||
public DirectThreadViewModel(@NonNull final Application application,
|
public DirectThreadViewModel(@NonNull final Application application,
|
||||||
@NonNull final String threadId,
|
@NonNull final String threadId,
|
||||||
|
final DirectThread backup,
|
||||||
final boolean pending,
|
final boolean pending,
|
||||||
@NonNull final User currentUser) {
|
@NonNull final User currentUser) {
|
||||||
super(application);
|
super(application);
|
||||||
@ -69,7 +70,7 @@ public class DirectThreadViewModel extends AndroidViewModel {
|
|||||||
contentResolver = application.getContentResolver();
|
contentResolver = application.getContentResolver();
|
||||||
recordingsDir = DirectoryUtils.getOutputMediaDirectory(application, "Recordings");
|
recordingsDir = DirectoryUtils.getOutputMediaDirectory(application, "Recordings");
|
||||||
final DirectMessagesManager messagesManager = DirectMessagesManager.getInstance();
|
final DirectMessagesManager messagesManager = DirectMessagesManager.getInstance();
|
||||||
threadManager = messagesManager.getThreadManager(threadId, pending, currentUser, contentResolver);
|
threadManager = messagesManager.getThreadManager(threadId, pending, backup, currentUser, contentResolver);
|
||||||
threadManager.fetchPendingRequests();
|
threadManager.fetchPendingRequests();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,21 +7,25 @@ import androidx.lifecycle.ViewModel;
|
|||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
|
||||||
import awais.instagrabber.repositories.responses.User;
|
import awais.instagrabber.repositories.responses.User;
|
||||||
|
import awais.instagrabber.repositories.responses.directmessages.DirectThread;
|
||||||
import awais.instagrabber.viewmodels.DirectSettingsViewModel;
|
import awais.instagrabber.viewmodels.DirectSettingsViewModel;
|
||||||
|
|
||||||
public class DirectSettingsViewModelFactory implements ViewModelProvider.Factory {
|
public class DirectSettingsViewModelFactory implements ViewModelProvider.Factory {
|
||||||
|
|
||||||
private final Application application;
|
private final Application application;
|
||||||
private final String threadId;
|
private final String threadId;
|
||||||
|
private final DirectThread backup;
|
||||||
private final boolean pending;
|
private final boolean pending;
|
||||||
private final User currentUser;
|
private final User currentUser;
|
||||||
|
|
||||||
public DirectSettingsViewModelFactory(@NonNull final Application application,
|
public DirectSettingsViewModelFactory(@NonNull final Application application,
|
||||||
@NonNull final String threadId,
|
@NonNull final String threadId,
|
||||||
|
@NonNull final DirectThread backup,
|
||||||
final boolean pending,
|
final boolean pending,
|
||||||
@NonNull final User currentUser) {
|
@NonNull final User currentUser) {
|
||||||
this.application = application;
|
this.application = application;
|
||||||
this.threadId = threadId;
|
this.threadId = threadId;
|
||||||
|
this.backup = backup;
|
||||||
this.pending = pending;
|
this.pending = pending;
|
||||||
this.currentUser = currentUser;
|
this.currentUser = currentUser;
|
||||||
}
|
}
|
||||||
@ -30,6 +34,6 @@ public class DirectSettingsViewModelFactory implements ViewModelProvider.Factory
|
|||||||
@Override
|
@Override
|
||||||
public <T extends ViewModel> T create(@NonNull final Class<T> modelClass) {
|
public <T extends ViewModel> T create(@NonNull final Class<T> modelClass) {
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
return (T) new DirectSettingsViewModel(application, threadId, pending, currentUser);
|
return (T) new DirectSettingsViewModel(application, threadId, backup, pending, currentUser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,21 +7,25 @@ import androidx.lifecycle.ViewModel;
|
|||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
|
||||||
import awais.instagrabber.repositories.responses.User;
|
import awais.instagrabber.repositories.responses.User;
|
||||||
|
import awais.instagrabber.repositories.responses.directmessages.DirectThread;
|
||||||
import awais.instagrabber.viewmodels.DirectThreadViewModel;
|
import awais.instagrabber.viewmodels.DirectThreadViewModel;
|
||||||
|
|
||||||
public class DirectThreadViewModelFactory implements ViewModelProvider.Factory {
|
public class DirectThreadViewModelFactory implements ViewModelProvider.Factory {
|
||||||
|
|
||||||
private final Application application;
|
private final Application application;
|
||||||
private final String threadId;
|
private final String threadId;
|
||||||
|
private final DirectThread backup;
|
||||||
private final boolean pending;
|
private final boolean pending;
|
||||||
private final User currentUser;
|
private final User currentUser;
|
||||||
|
|
||||||
public DirectThreadViewModelFactory(@NonNull final Application application,
|
public DirectThreadViewModelFactory(@NonNull final Application application,
|
||||||
@NonNull final String threadId,
|
@NonNull final String threadId,
|
||||||
|
final DirectThread backup,
|
||||||
final boolean pending,
|
final boolean pending,
|
||||||
@NonNull final User currentUser) {
|
@NonNull final User currentUser) {
|
||||||
this.application = application;
|
this.application = application;
|
||||||
this.threadId = threadId;
|
this.threadId = threadId;
|
||||||
|
this.backup = backup;
|
||||||
this.pending = pending;
|
this.pending = pending;
|
||||||
this.currentUser = currentUser;
|
this.currentUser = currentUser;
|
||||||
}
|
}
|
||||||
@ -30,6 +34,6 @@ public class DirectThreadViewModelFactory implements ViewModelProvider.Factory {
|
|||||||
@Override
|
@Override
|
||||||
public <T extends ViewModel> T create(@NonNull final Class<T> modelClass) {
|
public <T extends ViewModel> T create(@NonNull final Class<T> modelClass) {
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
return (T) new DirectThreadViewModel(application, threadId, pending, currentUser);
|
return (T) new DirectThreadViewModel(application, threadId, backup, pending, currentUser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ public class DirectMessagesService extends BaseService {
|
|||||||
final String cursor) {
|
final String cursor) {
|
||||||
final ImmutableMap.Builder<String, Object> queryMapBuilder = ImmutableMap.<String, Object>builder()
|
final ImmutableMap.Builder<String, Object> queryMapBuilder = ImmutableMap.<String, Object>builder()
|
||||||
.put("visual_message_return_type", "unseen")
|
.put("visual_message_return_type", "unseen")
|
||||||
.put("limit", 10)
|
.put("limit", 20)
|
||||||
.put("direction", "older");
|
.put("direction", "older");
|
||||||
if (!TextUtils.isEmpty(cursor)) {
|
if (!TextUtils.isEmpty(cursor)) {
|
||||||
queryMapBuilder.put("cursor", cursor);
|
queryMapBuilder.put("cursor", cursor);
|
||||||
|
@ -122,6 +122,10 @@
|
|||||||
android:name="pending"
|
android:name="pending"
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
app:argType="boolean" />
|
app:argType="boolean" />
|
||||||
|
<argument
|
||||||
|
android:name="backup"
|
||||||
|
app:nullable="true"
|
||||||
|
app:argType="awais.instagrabber.repositories.responses.directmessages.DirectThread" />
|
||||||
<action
|
<action
|
||||||
android:id="@+id/action_thread_to_settings"
|
android:id="@+id/action_thread_to_settings"
|
||||||
app:destination="@id/directMessagesSettingsFragment" />
|
app:destination="@id/directMessagesSettingsFragment" />
|
||||||
@ -152,6 +156,11 @@
|
|||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
app:argType="boolean" />
|
app:argType="boolean" />
|
||||||
|
|
||||||
|
<argument
|
||||||
|
android:name="backup"
|
||||||
|
app:nullable="true"
|
||||||
|
app:argType="awais.instagrabber.repositories.responses.directmessages.DirectThread" />
|
||||||
|
|
||||||
<action
|
<action
|
||||||
android:id="@+id/action_settings_to_inbox"
|
android:id="@+id/action_settings_to_inbox"
|
||||||
app:destination="@id/directMessagesInboxFragment"
|
app:destination="@id/directMessagesInboxFragment"
|
||||||
|
Loading…
Reference in New Issue
Block a user