Last fixes

This commit is contained in:
Thomas 2020-11-14 15:05:44 +01:00
parent 0f7438fa54
commit ddcbbfe670
5 changed files with 59 additions and 51 deletions

View File

@ -299,6 +299,7 @@
<item>Faible</item>
</string-array>
<string name="unfollow_confirm">Voulez-vous vous désabonner de ce compte ?</string>
<string name="no_playlist">Aucune liste de lecture !</string>
<string name="title_video_peertube">Titre de la vidéo</string>
<string name="join_peertube">Rejoignez Peertube</string>
<string name="agreement_check_peertube">J\'ai au moins 16 ans et je suis d\'accord avec les %1$s de cette instance</string>

View File

@ -292,6 +292,7 @@
<string name="export_notification_body">Open the attached file with TubeLab</string>
<string name="playlists">Playlists</string>
<string name="no_playlist">No playlists</string>
<string name="display_name">Display name</string>
<string name="action_playlist_add">You don\'t have any playlists. Tap on the \"+\" icon to add a new playlist</string>
<string name="error_display_name">You must provide a display name!</string>

View File

@ -19,7 +19,7 @@ import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.Toast;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.ViewModelProvider;
@ -35,7 +35,6 @@ import app.fedilab.fedilabtube.client.data.PlaylistData.Playlist;
import app.fedilab.fedilabtube.client.data.VideoPlaylistData;
import app.fedilab.fedilabtube.drawer.PlaylistAdapter;
import app.fedilab.fedilabtube.viewmodel.PlaylistsVM;
import es.dmoral.toasty.Toasty;
public class AllLocalPlaylistsActivity extends AppCompatActivity implements PlaylistAdapter.AllPlaylistRemoved {
@ -69,10 +68,12 @@ public class AllLocalPlaylistsActivity extends AppCompatActivity implements Play
FloatingActionButton add_new = findViewById(R.id.add_new);
add_new.setVisibility(View.GONE);
TextView no_action_text = findViewById(R.id.no_action_text);
no_action_text.setText(R.string.no_playlist);
playlists = new ArrayList<>();
RecyclerView lv_playlist = findViewById(R.id.lv_playlist);
playlistAdapter = new PlaylistAdapter(playlists, true);
playlistAdapter.allPlaylistRemoved = this;
lv_playlist.setAdapter(playlistAdapter);
LinearLayoutManager mLayoutManager = new LinearLayoutManager(AllLocalPlaylistsActivity.this);
lv_playlist.setLayoutManager(mLayoutManager);
@ -97,7 +98,7 @@ public class AllLocalPlaylistsActivity extends AppCompatActivity implements Play
public void manageVIewPlaylists(List<VideoPlaylistData.VideoPlaylistExport> videoPlaylistExports) {
mainLoader.setVisibility(View.GONE);
if (videoPlaylistExports == null) {
Toasty.error(AllLocalPlaylistsActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
textviewNoAction.setVisibility(View.VISIBLE);
return;
}
if (videoPlaylistExports.size() > 0) {

View File

@ -112,6 +112,7 @@ public class AllPlaylistsActivity extends AppCompatActivity implements PlaylistA
playlists = new ArrayList<>();
RecyclerView lv_playlist = findViewById(R.id.lv_playlist);
playlistAdapter = new PlaylistAdapter(playlists, false);
playlistAdapter.allPlaylistRemoved = this;
lv_playlist.setAdapter(playlistAdapter);
LinearLayoutManager mLayoutManager = new LinearLayoutManager(AllPlaylistsActivity.this);
lv_playlist.setLayoutManager(mLayoutManager);

View File

@ -65,6 +65,8 @@ import app.fedilab.fedilabtube.viewmodel.SearchVM;
import app.fedilab.fedilabtube.viewmodel.TimelineVM;
import es.dmoral.toasty.Toasty;
import static app.fedilab.fedilabtube.viewmodel.TimelineVM.TimelineType.VIDEOS_IN_LOCAL_PLAYLIST;
public class DisplayVideosFragment extends Fragment implements AccountsHorizontalListAdapter.EventListener, PeertubeAdapter.RelationShipListener, PeertubeAdapter.PlaylistListener {
@ -187,57 +189,59 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
});
lv_status.addOnScrollListener(new RecyclerView.OnScrollListener() {
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
if (type == TimelineVM.TimelineType.SUBSCRIBTIONS) {
if (dy > 0) {
if (check_ScrollingUp) {
top_account_container.setVisibility(View.GONE);
final Handler handler = new Handler();
handler.postDelayed(() -> check_ScrollingUp = false, 300);
if (type != VIDEOS_IN_LOCAL_PLAYLIST) {
lv_status.addOnScrollListener(new RecyclerView.OnScrollListener() {
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
if (type == TimelineVM.TimelineType.SUBSCRIBTIONS) {
if (dy > 0) {
if (check_ScrollingUp) {
top_account_container.setVisibility(View.GONE);
final Handler handler = new Handler();
handler.postDelayed(() -> check_ScrollingUp = false, 300);
}
} else {
if (!check_ScrollingUp) {
top_account_container.setVisibility(View.VISIBLE);
final Handler handler = new Handler();
handler.postDelayed(() -> check_ScrollingUp = true, 300);
}
}
} else {
if (!check_ScrollingUp) {
top_account_container.setVisibility(View.VISIBLE);
final Handler handler = new Handler();
handler.postDelayed(() -> check_ScrollingUp = true, 300);
}
if (mLayoutManager != null) {
int firstVisibleItem = mLayoutManager.findFirstVisibleItemPosition();
if (dy > 0) {
int visibleItemCount = mLayoutManager.getChildCount();
int totalItemCount = mLayoutManager.getItemCount();
if (firstVisibleItem + visibleItemCount == totalItemCount && context != null) {
if (!flag_loading) {
flag_loading = true;
loadTimeline(max_id);
nextElementLoader.setVisibility(View.VISIBLE);
}
} else {
nextElementLoader.setVisibility(View.GONE);
}
}
} else if (gLayoutManager != null) {
int firstVisibleItem = gLayoutManager.findFirstVisibleItemPosition();
if (dy > 0) {
int visibleItemCount = gLayoutManager.getChildCount();
int totalItemCount = gLayoutManager.getItemCount();
if (firstVisibleItem + visibleItemCount == totalItemCount && context != null) {
if (!flag_loading) {
flag_loading = true;
loadTimeline(max_id);
nextElementLoader.setVisibility(View.VISIBLE);
}
} else {
nextElementLoader.setVisibility(View.GONE);
}
}
}
}
if (mLayoutManager != null) {
int firstVisibleItem = mLayoutManager.findFirstVisibleItemPosition();
if (dy > 0) {
int visibleItemCount = mLayoutManager.getChildCount();
int totalItemCount = mLayoutManager.getItemCount();
if (firstVisibleItem + visibleItemCount == totalItemCount && context != null) {
if (!flag_loading) {
flag_loading = true;
loadTimeline(max_id);
nextElementLoader.setVisibility(View.VISIBLE);
}
} else {
nextElementLoader.setVisibility(View.GONE);
}
}
} else if (gLayoutManager != null) {
int firstVisibleItem = gLayoutManager.findFirstVisibleItemPosition();
if (dy > 0) {
int visibleItemCount = gLayoutManager.getChildCount();
int totalItemCount = gLayoutManager.getItemCount();
if (firstVisibleItem + visibleItemCount == totalItemCount && context != null) {
if (!flag_loading) {
flag_loading = true;
loadTimeline(max_id);
nextElementLoader.setVisibility(View.VISIBLE);
}
} else {
nextElementLoader.setVisibility(View.GONE);
}
}
}
}
});
});
}
if (type == TimelineVM.TimelineType.SUBSCRIBTIONS) {
AccountsVM viewModel = new ViewModelProvider(this).get(AccountsVM.class);
viewModel.getAccounts(RetrofitPeertubeAPI.DataType.SUBSCRIBER, max_id).observe(DisplayVideosFragment.this.requireActivity(), this::manageViewAccounts);
@ -506,7 +510,7 @@ public class DisplayVideosFragment extends Fragment implements AccountsHorizonta
viewModelFeeds.getVideosInChannel(sepiaSearch ? remoteInstance : null, channelId, max_id).observe(this.requireActivity(), this::manageVIewVideos);
} else if (type == TimelineVM.TimelineType.VIDEOS_IN_PLAYLIST) {
viewModelFeeds.loadVideosInPlaylist(playlistId, max_id).observe(this.requireActivity(), this::manageVIewVideos);
} else if (type == TimelineVM.TimelineType.VIDEOS_IN_LOCAL_PLAYLIST) {
} else if (type == VIDEOS_IN_LOCAL_PLAYLIST) {
viewModelFeeds.loadVideosInLocalPlaylist(playlistId).observe(this.requireActivity(), this::manageVIewVideos);
} else if (type == TimelineVM.TimelineType.HISTORY) {
viewModelFeeds.getVideoHistory(max_id, startDate, endDate).observe(this.requireActivity(), this::manageVIewVideos);