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) {
DisplayChannelsFragment displayChannelsFragment = new DisplayChannelsFragment();
bundle.putString("name", account.getAcct());
bundle.putBoolean("myChannels", false);
displayChannelsFragment.setArguments(bundle);
return displayChannelsFragment;
}

View File

@ -132,9 +132,8 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
} else if (account != null) {
channelId = account.getAcct();
}
max_id = "0";
// forChannel = type == TimelineVM.TimelineType.ACCOUNT_VIDEOS ? channelId : null;
//forChannel = type == TimelineVM.TimelineType.ACCOUNT_VIDEOS ? channelId : null;
max_id_accounts = null;
flag_loading = true;
firstLoad = true;
@ -498,7 +497,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
} else if (type == TimelineVM.TimelineType.HISTORY) {
viewModelFeeds.getVideoHistory(max_id, startDate, endDate).observe(this.requireActivity(), this::manageVIewVideos);
} 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 {
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.RetrofitPeertubeAPI;
import app.fedilab.fedilabtube.client.data.AccountData;
import app.fedilab.fedilabtube.client.data.ChannelData;
import app.fedilab.fedilabtube.client.data.VideoData;
import app.fedilab.fedilabtube.helper.Helper;
@ -46,9 +47,9 @@ public class TimelineVM extends AndroidViewModel {
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<>();
loadVideos(action, max_id, forChannel);
loadVideos(action, max_id, forChannel, forAccount);
return apiResponseMutableLiveData;
}
@ -190,20 +191,25 @@ public class TimelineVM extends AndroidViewModel {
}).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();
new Thread(() -> {
try {
RetrofitPeertubeAPI retrofitPeertubeAPI;
String acct = null;
if (forChannel != 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 {
retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext);
}
if (timeline == null)
return;
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());
Runnable myRunnable = () -> apiResponseMutableLiveData.setValue(apiResponse);
mainHandler.post(myRunnable);