mirror of
https://framagit.org/tom79/fedilab-tube
synced 2025-04-14 02:21:59 +02:00
Refresh subscription
This commit is contained in:
parent
fc95708a84
commit
b089ae93e1
@ -8,7 +8,7 @@
|
||||
<string name="set_video_cache_choice" translatable="false">set_video_cache_choice</string>
|
||||
|
||||
<string name="title_home">Locale</string>
|
||||
<string name="title_local">Local</string>
|
||||
<string name="title_local">Locale</string>
|
||||
<string name="title_discover">Découvrir</string>
|
||||
<string name="title_notifications">Notifications</string>
|
||||
<string name="title_recently_added">Nouveautés</string>
|
||||
|
@ -377,6 +377,14 @@ public class MainActivity extends AppCompatActivity {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
public void setActive(DisplayVideosFragment displayVideosFragment){
|
||||
this.active = displayVideosFragment;
|
||||
}
|
||||
|
||||
public void setSubscriptionFragment(DisplayVideosFragment displayVideosFragment) {
|
||||
this.subscriptionFragment = displayVideosFragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
|
@ -29,8 +29,10 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
@ -44,6 +46,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import app.fedilab.fedilabtube.MainActivity;
|
||||
import app.fedilab.fedilabtube.R;
|
||||
import app.fedilab.fedilabtube.client.APIResponse;
|
||||
import app.fedilab.fedilabtube.client.RetrofitPeertubeAPI;
|
||||
@ -158,7 +161,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
|
||||
viewModelAccounts = new ViewModelProvider(DisplayVideosFragment.this).get(AccountsVM.class);
|
||||
viewModelFeeds = new ViewModelProvider(DisplayVideosFragment.this).get(TimelineVM.class);
|
||||
viewModelSearch = new ViewModelProvider(DisplayVideosFragment.this).get(SearchVM.class);
|
||||
swipeRefreshLayout.setOnRefreshListener(this::pullToRefresh);
|
||||
swipeRefreshLayout.setOnRefreshListener(() -> pullToRefresh(true));
|
||||
|
||||
lv_accounts.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||||
@ -232,7 +235,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
|
||||
loadTimeline(max_id);
|
||||
display_all.setOnClickListener(v -> {
|
||||
forAccount = null;
|
||||
pullToRefresh();
|
||||
pullToRefresh(false);
|
||||
});
|
||||
return rootView;
|
||||
}
|
||||
@ -427,25 +430,44 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
|
||||
}
|
||||
|
||||
|
||||
public void pullToRefresh() {
|
||||
int size = peertubes.size();
|
||||
peertubes.clear();
|
||||
peertubes = new ArrayList<>();
|
||||
max_id = "0";
|
||||
peertubeAdapater.notifyItemRangeRemoved(0, size);
|
||||
if (forAccount == null) {
|
||||
for (ChannelData.Channel channel : channels) {
|
||||
channel.setSelected(false);
|
||||
public void pullToRefresh(boolean reload) {
|
||||
if( type == TimelineVM.TimelineType.SUBSCRIBTIONS && reload) {
|
||||
Fragment fragment = ((AppCompatActivity)context).getSupportFragmentManager().findFragmentByTag("2");
|
||||
if(fragment != null) {
|
||||
if( context instanceof MainActivity) {
|
||||
FragmentManager fm = ((MainActivity) context).getSupportFragmentManager();
|
||||
fm.beginTransaction().remove(fragment).commit();
|
||||
DisplayVideosFragment subscriptionFragment = new DisplayVideosFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable(Helper.TIMELINE_TYPE, TimelineVM.TimelineType.SUBSCRIBTIONS);
|
||||
subscriptionFragment.setArguments(bundle);
|
||||
((MainActivity) context).setActive(subscriptionFragment);
|
||||
((MainActivity) context).setSubscriptionFragment(subscriptionFragment);
|
||||
fm.beginTransaction().add(R.id.nav_host_fragment, subscriptionFragment, "2").commit();
|
||||
}
|
||||
}
|
||||
accountsHorizontalListAdapter.notifyItemRangeRemoved(0, channels.size());
|
||||
|
||||
}else {
|
||||
int size = peertubes.size();
|
||||
peertubes.clear();
|
||||
peertubes = new ArrayList<>();
|
||||
max_id = "0";
|
||||
peertubeAdapater.notifyItemRangeRemoved(0, size);
|
||||
if (forAccount == null) {
|
||||
for (ChannelData.Channel channel : channels) {
|
||||
channel.setSelected(false);
|
||||
}
|
||||
accountsHorizontalListAdapter.notifyItemRangeRemoved(0, channels.size());
|
||||
}
|
||||
loadTimeline("0");
|
||||
}
|
||||
loadTimeline("0");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click(String forAccount) {
|
||||
this.forAccount = forAccount;
|
||||
pullToRefresh();
|
||||
pullToRefresh(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user