Some fixes
This commit is contained in:
parent
a1b816030a
commit
4027a8b725
|
@ -202,6 +202,8 @@ public class DisplayStatusFragment extends Fragment implements AccountsHorizonta
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
FeedsVM viewModelFeeds = new ViewModelProvider(DisplayStatusFragment.this).get(FeedsVM.class);
|
||||||
|
SearchVM viewModelSearch = new ViewModelProvider(DisplayStatusFragment.this).get(SearchVM.class);
|
||||||
if (mLayoutManager != null) {
|
if (mLayoutManager != null) {
|
||||||
int firstVisibleItem = mLayoutManager.findFirstVisibleItemPosition();
|
int firstVisibleItem = mLayoutManager.findFirstVisibleItemPosition();
|
||||||
if (dy > 0) {
|
if (dy > 0) {
|
||||||
|
@ -211,11 +213,9 @@ public class DisplayStatusFragment extends Fragment implements AccountsHorizonta
|
||||||
if (!flag_loading) {
|
if (!flag_loading) {
|
||||||
flag_loading = true;
|
flag_loading = true;
|
||||||
if (search_peertube == null) { //Not a Peertube search
|
if (search_peertube == null) { //Not a Peertube search
|
||||||
FeedsVM viewModel = new ViewModelProvider(DisplayStatusFragment.this).get(FeedsVM.class);
|
viewModelFeeds.getVideos(type, max_id, null, null).observe(DisplayStatusFragment.this.requireActivity(), apiResponse -> manageVIewVideos(apiResponse));
|
||||||
viewModel.getVideos(type, max_id, null, null).observe(DisplayStatusFragment.this.requireActivity(), apiResponse -> manageVIewVideos(apiResponse));
|
|
||||||
} else {
|
} else {
|
||||||
SearchVM viewModel = new ViewModelProvider(DisplayStatusFragment.this).get(SearchVM.class);
|
viewModelSearch.getVideos(max_id, search_peertube).observe(DisplayStatusFragment.this.requireActivity(), apiResponse -> manageVIewVideos(apiResponse));
|
||||||
viewModel.getVideos(max_id, search_peertube).observe(DisplayStatusFragment.this.requireActivity(), apiResponse -> manageVIewVideos(apiResponse));
|
|
||||||
}
|
}
|
||||||
nextElementLoader.setVisibility(View.VISIBLE);
|
nextElementLoader.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,23 +30,19 @@ import app.fedilab.fedilabtube.client.PeertubeAPI;
|
||||||
|
|
||||||
public class AccountsVM extends AndroidViewModel {
|
public class AccountsVM extends AndroidViewModel {
|
||||||
private MutableLiveData<APIResponse> apiResponseMutableLiveData;
|
private MutableLiveData<APIResponse> apiResponseMutableLiveData;
|
||||||
private Application application;
|
|
||||||
|
|
||||||
public AccountsVM(@NonNull Application application) {
|
public AccountsVM(@NonNull Application application) {
|
||||||
super(application);
|
super(application);
|
||||||
this.application = application;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<APIResponse> getAccounts(String max_id, String name, accountFetch type) {
|
public LiveData<APIResponse> getAccounts(String max_id, String name, accountFetch type) {
|
||||||
if (apiResponseMutableLiveData == null) {
|
apiResponseMutableLiveData = new MutableLiveData<>();
|
||||||
apiResponseMutableLiveData = new MutableLiveData<>();
|
loadAccounts(max_id, name, type);
|
||||||
loadAccounts(max_id, name, type);
|
|
||||||
}
|
|
||||||
return apiResponseMutableLiveData;
|
return apiResponseMutableLiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadAccounts(String max_id, String name, accountFetch type) {
|
private void loadAccounts(String max_id, String name, accountFetch type) {
|
||||||
Context _mContext = this.application.getApplicationContext();
|
Context _mContext = getApplication().getApplicationContext();
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
PeertubeAPI peertubeAPI = new PeertubeAPI(_mContext);
|
PeertubeAPI peertubeAPI = new PeertubeAPI(_mContext);
|
||||||
|
|
|
@ -36,23 +36,19 @@ import app.fedilab.fedilabtube.sqlite.Sqlite;
|
||||||
|
|
||||||
public class ChannelsVM extends AndroidViewModel {
|
public class ChannelsVM extends AndroidViewModel {
|
||||||
private MutableLiveData<APIResponse> apiResponseMutableLiveData;
|
private MutableLiveData<APIResponse> apiResponseMutableLiveData;
|
||||||
private Application application;
|
|
||||||
|
|
||||||
public ChannelsVM(@NonNull Application application) {
|
public ChannelsVM(@NonNull Application application) {
|
||||||
super(application);
|
super(application);
|
||||||
this.application = application;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<APIResponse> get() {
|
public LiveData<APIResponse> get() {
|
||||||
if (apiResponseMutableLiveData == null) {
|
apiResponseMutableLiveData = new MutableLiveData<>();
|
||||||
apiResponseMutableLiveData = new MutableLiveData<>();
|
getChannels();
|
||||||
getChannels();
|
|
||||||
}
|
|
||||||
return apiResponseMutableLiveData;
|
return apiResponseMutableLiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getChannels() {
|
private void getChannels() {
|
||||||
Context _mContext = this.application.getApplicationContext();
|
Context _mContext = getApplication().getApplicationContext();
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
PeertubeAPI peertubeAPI = new PeertubeAPI(_mContext);
|
PeertubeAPI peertubeAPI = new PeertubeAPI(_mContext);
|
||||||
|
|
|
@ -30,24 +30,20 @@ import app.fedilab.fedilabtube.client.PeertubeAPI;
|
||||||
|
|
||||||
public class CommentVM extends AndroidViewModel {
|
public class CommentVM extends AndroidViewModel {
|
||||||
private MutableLiveData<APIResponse> apiResponseMutableLiveData;
|
private MutableLiveData<APIResponse> apiResponseMutableLiveData;
|
||||||
private Application application;
|
|
||||||
|
|
||||||
public CommentVM(@NonNull Application application) {
|
public CommentVM(@NonNull Application application) {
|
||||||
super(application);
|
super(application);
|
||||||
this.application = application;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<APIResponse> getComment(String instanceName, String videoId) {
|
public LiveData<APIResponse> getComment(String instanceName, String videoId) {
|
||||||
if (apiResponseMutableLiveData == null) {
|
apiResponseMutableLiveData = new MutableLiveData<>();
|
||||||
apiResponseMutableLiveData = new MutableLiveData<>();
|
getSingle(instanceName, videoId);
|
||||||
getSingle(instanceName, videoId);
|
|
||||||
}
|
|
||||||
return apiResponseMutableLiveData;
|
return apiResponseMutableLiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void getSingle(String instanceName, String videoId) {
|
private void getSingle(String instanceName, String videoId) {
|
||||||
Context _mContext = this.application.getApplicationContext();
|
Context _mContext = getApplication().getApplicationContext();
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
PeertubeAPI api = new PeertubeAPI(_mContext);
|
PeertubeAPI api = new PeertubeAPI(_mContext);
|
||||||
|
|
|
@ -38,18 +38,14 @@ import app.fedilab.fedilabtube.sqlite.Sqlite;
|
||||||
|
|
||||||
public class FeedsVM extends AndroidViewModel {
|
public class FeedsVM extends AndroidViewModel {
|
||||||
private MutableLiveData<APIResponse> apiResponseMutableLiveData;
|
private MutableLiveData<APIResponse> apiResponseMutableLiveData;
|
||||||
private Application application;
|
|
||||||
|
|
||||||
public FeedsVM(@NonNull Application application) {
|
public FeedsVM(@NonNull Application application) {
|
||||||
super(application);
|
super(application);
|
||||||
this.application = application;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<APIResponse> getVideos(Type action, String max_id, String target, String forAccount) {
|
public LiveData<APIResponse> getVideos(Type action, String max_id, String target, String forAccount) {
|
||||||
if (apiResponseMutableLiveData == null) {
|
apiResponseMutableLiveData = new MutableLiveData<>();
|
||||||
apiResponseMutableLiveData = new MutableLiveData<>();
|
loadVideos(action, max_id, target, forAccount);
|
||||||
loadVideos(action, max_id, target, forAccount);
|
|
||||||
}
|
|
||||||
return apiResponseMutableLiveData;
|
return apiResponseMutableLiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +63,7 @@ public class FeedsVM extends AndroidViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void update(Peertube peertube) {
|
private void update(Peertube peertube) {
|
||||||
Context _mContext = this.application.getApplicationContext();
|
Context _mContext = getApplication().getApplicationContext();
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
PeertubeAPI peertubeAPI = new PeertubeAPI(_mContext);
|
PeertubeAPI peertubeAPI = new PeertubeAPI(_mContext);
|
||||||
|
@ -85,7 +81,7 @@ public class FeedsVM extends AndroidViewModel {
|
||||||
|
|
||||||
|
|
||||||
private void getSingle(String instanceName, String videoId) {
|
private void getSingle(String instanceName, String videoId) {
|
||||||
Context _mContext = this.application.getApplicationContext();
|
Context _mContext = getApplication().getApplicationContext();
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
PeertubeAPI peertubeAPI = new PeertubeAPI(_mContext);
|
PeertubeAPI peertubeAPI = new PeertubeAPI(_mContext);
|
||||||
|
@ -107,7 +103,7 @@ public class FeedsVM extends AndroidViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadVideos(Type action, String max_id, String target, String forAccount) {
|
private void loadVideos(Type action, String max_id, String target, String forAccount) {
|
||||||
Context _mContext = this.application.getApplicationContext();
|
Context _mContext = getApplication().getApplicationContext();
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
PeertubeAPI peertubeAPI = new PeertubeAPI(_mContext);
|
PeertubeAPI peertubeAPI = new PeertubeAPI(_mContext);
|
||||||
|
|
|
@ -32,23 +32,19 @@ import app.fedilab.fedilabtube.client.entities.Error;
|
||||||
|
|
||||||
public class NotificationsVM extends AndroidViewModel {
|
public class NotificationsVM extends AndroidViewModel {
|
||||||
private MutableLiveData<APIResponse> apiResponseMutableLiveData;
|
private MutableLiveData<APIResponse> apiResponseMutableLiveData;
|
||||||
private Application application;
|
|
||||||
|
|
||||||
public NotificationsVM(@NonNull Application application) {
|
public NotificationsVM(@NonNull Application application) {
|
||||||
super(application);
|
super(application);
|
||||||
this.application = application;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<APIResponse> getNotifications(Account account, String max_id) {
|
public LiveData<APIResponse> getNotifications(Account account, String max_id) {
|
||||||
if (apiResponseMutableLiveData == null) {
|
apiResponseMutableLiveData = new MutableLiveData<>();
|
||||||
apiResponseMutableLiveData = new MutableLiveData<>();
|
loadNotifications(account, max_id);
|
||||||
loadNotifications(account, max_id);
|
|
||||||
}
|
|
||||||
return apiResponseMutableLiveData;
|
return apiResponseMutableLiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadNotifications(Account account, String max_id) {
|
private void loadNotifications(Account account, String max_id) {
|
||||||
Context _mContext = this.application.getApplicationContext();
|
Context _mContext = getApplication().getApplicationContext();
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
PeertubeAPI api;
|
PeertubeAPI api;
|
||||||
|
|
|
@ -39,23 +39,19 @@ import app.fedilab.fedilabtube.sqlite.Sqlite;
|
||||||
|
|
||||||
public class PlaylistsVM extends AndroidViewModel {
|
public class PlaylistsVM extends AndroidViewModel {
|
||||||
private MutableLiveData<APIResponse> apiResponseMutableLiveData;
|
private MutableLiveData<APIResponse> apiResponseMutableLiveData;
|
||||||
private Application application;
|
|
||||||
|
|
||||||
public PlaylistsVM(@NonNull Application application) {
|
public PlaylistsVM(@NonNull Application application) {
|
||||||
super(application);
|
super(application);
|
||||||
this.application = application;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<APIResponse> manage(action apiAction, Playlist playlist, String videoId, String max_id) {
|
public LiveData<APIResponse> manage(action apiAction, Playlist playlist, String videoId, String max_id) {
|
||||||
if (apiResponseMutableLiveData == null) {
|
apiResponseMutableLiveData = new MutableLiveData<>();
|
||||||
apiResponseMutableLiveData = new MutableLiveData<>();
|
managePlaylists(apiAction, playlist, videoId, max_id);
|
||||||
managePlaylists(apiAction, playlist, videoId, max_id);
|
|
||||||
}
|
|
||||||
return apiResponseMutableLiveData;
|
return apiResponseMutableLiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void managePlaylists(action apiAction, Playlist playlist, String videoId, String max_id) {
|
private void managePlaylists(action apiAction, Playlist playlist, String videoId, String max_id) {
|
||||||
Context _mContext = this.application.getApplicationContext();
|
Context _mContext = getApplication().getApplicationContext();
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
SharedPreferences sharedpreferences = _mContext.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
SharedPreferences sharedpreferences = _mContext.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
|
|
|
@ -30,23 +30,19 @@ import app.fedilab.fedilabtube.client.PeertubeAPI;
|
||||||
|
|
||||||
public class PostActionsVM extends AndroidViewModel {
|
public class PostActionsVM extends AndroidViewModel {
|
||||||
private MutableLiveData<APIResponse> apiResponseMutableLiveData;
|
private MutableLiveData<APIResponse> apiResponseMutableLiveData;
|
||||||
private Application application;
|
|
||||||
|
|
||||||
public PostActionsVM(@NonNull Application application) {
|
public PostActionsVM(@NonNull Application application) {
|
||||||
super(application);
|
super(application);
|
||||||
this.application = application;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<APIResponse> post(PeertubeAPI.StatusAction apiAction, String targetedId, String comment, String targetedComment) {
|
public LiveData<APIResponse> post(PeertubeAPI.StatusAction apiAction, String targetedId, String comment, String targetedComment) {
|
||||||
if (apiResponseMutableLiveData == null) {
|
apiResponseMutableLiveData = new MutableLiveData<>();
|
||||||
apiResponseMutableLiveData = new MutableLiveData<>();
|
makeAction(apiAction, targetedId, comment, targetedComment);
|
||||||
makeAction(apiAction, targetedId, comment, targetedComment);
|
|
||||||
}
|
|
||||||
return apiResponseMutableLiveData;
|
return apiResponseMutableLiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void makeAction(PeertubeAPI.StatusAction apiAction, String targetedId, String comment, String targetedComment) {
|
private void makeAction(PeertubeAPI.StatusAction apiAction, String targetedId, String comment, String targetedComment) {
|
||||||
Context _mContext = this.application.getApplicationContext();
|
Context _mContext = getApplication().getApplicationContext();
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
PeertubeAPI peertubeAPI = new PeertubeAPI(_mContext);
|
PeertubeAPI peertubeAPI = new PeertubeAPI(_mContext);
|
||||||
|
|
|
@ -34,23 +34,19 @@ import app.fedilab.fedilabtube.client.entities.Relationship;
|
||||||
|
|
||||||
public class RelationshipVM extends AndroidViewModel {
|
public class RelationshipVM extends AndroidViewModel {
|
||||||
private MutableLiveData<APIResponse> apiResponseMutableLiveData;
|
private MutableLiveData<APIResponse> apiResponseMutableLiveData;
|
||||||
private Application application;
|
|
||||||
|
|
||||||
public RelationshipVM(@NonNull Application application) {
|
public RelationshipVM(@NonNull Application application) {
|
||||||
super(application);
|
super(application);
|
||||||
this.application = application;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<APIResponse> get(String targetedId) {
|
public LiveData<APIResponse> get(String targetedId) {
|
||||||
if (apiResponseMutableLiveData == null) {
|
apiResponseMutableLiveData = new MutableLiveData<>();
|
||||||
apiResponseMutableLiveData = new MutableLiveData<>();
|
getRelationShip(targetedId);
|
||||||
getRelationShip(targetedId);
|
|
||||||
}
|
|
||||||
return apiResponseMutableLiveData;
|
return apiResponseMutableLiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getRelationShip(String targetedId) {
|
private void getRelationShip(String targetedId) {
|
||||||
Context _mContext = this.application.getApplicationContext();
|
Context _mContext = getApplication().getApplicationContext();
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
PeertubeAPI api = new PeertubeAPI(_mContext);
|
PeertubeAPI api = new PeertubeAPI(_mContext);
|
||||||
|
|
|
@ -30,23 +30,19 @@ import app.fedilab.fedilabtube.client.PeertubeAPI;
|
||||||
|
|
||||||
public class SearchVM extends AndroidViewModel {
|
public class SearchVM extends AndroidViewModel {
|
||||||
private MutableLiveData<APIResponse> apiResponseMutableLiveData;
|
private MutableLiveData<APIResponse> apiResponseMutableLiveData;
|
||||||
private Application application;
|
|
||||||
|
|
||||||
public SearchVM(@NonNull Application application) {
|
public SearchVM(@NonNull Application application) {
|
||||||
super(application);
|
super(application);
|
||||||
this.application = application;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<APIResponse> getVideos(String max_id, String query) {
|
public LiveData<APIResponse> getVideos(String max_id, String query) {
|
||||||
if (apiResponseMutableLiveData == null) {
|
apiResponseMutableLiveData = new MutableLiveData<>();
|
||||||
apiResponseMutableLiveData = new MutableLiveData<>();
|
loadVideos(max_id, query);
|
||||||
loadVideos(max_id, query);
|
|
||||||
}
|
|
||||||
return apiResponseMutableLiveData;
|
return apiResponseMutableLiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadVideos(String max_id, String query) {
|
private void loadVideos(String max_id, String query) {
|
||||||
Context _mContext = this.application.getApplicationContext();
|
Context _mContext = getApplication().getApplicationContext();
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
PeertubeAPI api = new PeertubeAPI(_mContext);
|
PeertubeAPI api = new PeertubeAPI(_mContext);
|
||||||
|
|
Loading…
Reference in New Issue