Fix some bugs

This commit is contained in:
Thomas 2020-11-28 16:41:21 +01:00
parent 964b0f2690
commit 962462ff84
3 changed files with 12 additions and 8 deletions

View File

@ -288,7 +288,6 @@ public class ShowAccountActivity extends AppCompatActivity {
if (position == 0) { if (position == 0) {
DisplayChannelsFragment displayChannelsFragment = new DisplayChannelsFragment(); DisplayChannelsFragment displayChannelsFragment = new DisplayChannelsFragment();
bundle.putString("name", account.getAcct()); bundle.putString("name", account.getAcct());
bundle.putBoolean("myChannels", false);
displayChannelsFragment.setArguments(bundle); displayChannelsFragment.setArguments(bundle);
return displayChannelsFragment; return displayChannelsFragment;
} }

View File

@ -132,9 +132,8 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
} else if (account != null) { } else if (account != null) {
channelId = account.getAcct(); channelId = account.getAcct();
} }
max_id = "0"; max_id = "0";
// forChannel = type == TimelineVM.TimelineType.ACCOUNT_VIDEOS ? channelId : null; //forChannel = type == TimelineVM.TimelineType.ACCOUNT_VIDEOS ? channelId : null;
max_id_accounts = null; max_id_accounts = null;
flag_loading = true; flag_loading = true;
firstLoad = true; firstLoad = true;
@ -498,7 +497,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
} else if (type == TimelineVM.TimelineType.HISTORY) { } else if (type == TimelineVM.TimelineType.HISTORY) {
viewModelFeeds.getVideoHistory(max_id, startDate, endDate).observe(this.requireActivity(), this::manageVIewVideos); viewModelFeeds.getVideoHistory(max_id, startDate, endDate).observe(this.requireActivity(), this::manageVIewVideos);
} else { } else {
viewModelFeeds.getVideos(type, max_id, forChannel).observe(this.requireActivity(), this::manageVIewVideos); viewModelFeeds.getVideos(type, max_id, forChannel, account).observe(this.requireActivity(), this::manageVIewVideos);
} }
} else { } else {
viewModelSearch.getVideos(max_id, search_peertube).observe(this.requireActivity(), this::manageVIewVideos); viewModelSearch.getVideos(max_id, search_peertube).observe(this.requireActivity(), this::manageVIewVideos);

View File

@ -30,6 +30,7 @@ import java.util.List;
import app.fedilab.fedilabtube.client.APIResponse; import app.fedilab.fedilabtube.client.APIResponse;
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI; import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
import app.fedilab.fedilabtube.client.data.AccountData;
import app.fedilab.fedilabtube.client.data.ChannelData; import app.fedilab.fedilabtube.client.data.ChannelData;
import app.fedilab.fedilabtube.client.data.VideoData; import app.fedilab.fedilabtube.client.data.VideoData;
import app.fedilab.fedilabtube.helper.Helper; import app.fedilab.fedilabtube.helper.Helper;
@ -46,9 +47,9 @@ public class TimelineVM extends AndroidViewModel {
super(application); super(application);
} }
public LiveData<APIResponse> getVideos(TimelineType action, String max_id, ChannelData.Channel forChannel) { public LiveData<APIResponse> getVideos(TimelineType action, String max_id, ChannelData.Channel forChannel, AccountData.Account forAccount) {
apiResponseMutableLiveData = new MutableLiveData<>(); apiResponseMutableLiveData = new MutableLiveData<>();
loadVideos(action, max_id, forChannel); loadVideos(action, max_id, forChannel, forAccount);
return apiResponseMutableLiveData; return apiResponseMutableLiveData;
} }
@ -190,20 +191,25 @@ public class TimelineVM extends AndroidViewModel {
}).start(); }).start();
} }
private void loadVideos(TimelineType timeline, String max_id, ChannelData.Channel forChannel) { private void loadVideos(TimelineType timeline, String max_id, ChannelData.Channel forChannel, AccountData.Account forAccount) {
Context _mContext = getApplication().getApplicationContext(); Context _mContext = getApplication().getApplicationContext();
new Thread(() -> { new Thread(() -> {
try { try {
RetrofitPeertubeAPI retrofitPeertubeAPI; RetrofitPeertubeAPI retrofitPeertubeAPI;
String acct = null;
if (forChannel != null) { if (forChannel != null) {
retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext, forChannel.getHost(), null); retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext, forChannel.getHost(), null);
acct = forChannel.getAcct();
} else if (forAccount != null) {
retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext, forAccount.getHost(), null);
acct = forAccount.getAcct();
} else { } else {
retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext); retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext);
} }
if (timeline == null) if (timeline == null)
return; return;
APIResponse apiResponse; APIResponse apiResponse;
apiResponse = retrofitPeertubeAPI.getTL(timeline, max_id, forChannel != null ? forChannel.getAcct() : null); apiResponse = retrofitPeertubeAPI.getTL(timeline, max_id, acct);
Handler mainHandler = new Handler(Looper.getMainLooper()); Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> apiResponseMutableLiveData.setValue(apiResponse); Runnable myRunnable = () -> apiResponseMutableLiveData.setValue(apiResponse);
mainHandler.post(myRunnable); mainHandler.post(myRunnable);