diff --git a/app/src/androidTest/java/net/schueller/peertube/ExampleInstrumentedTest.java b/app/src/androidTest/java/net/schueller/peertube/ExampleInstrumentedTest.java
deleted file mode 100644
index 0c0fe04..0000000
--- a/app/src/androidTest/java/net/schueller/peertube/ExampleInstrumentedTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package net.schueller.peertube;
-
-import android.content.Context;
-import androidx.test.InstrumentationRegistry;
-import androidx.test.runner.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.junit.Assert.*;
-
-/**
- * Instrumented test, which will execute on an Android device.
- *
- * @see Testing documentation
- */
-@RunWith(AndroidJUnit4.class)
-public class ExampleInstrumentedTest {
- @Test
- public void useAppContext() throws Exception {
- // Context of the app under test.
- Context appContext = InstrumentationRegistry.getTargetContext();
-
- assertEquals("net.schueller.peertube", appContext.getPackageName());
- }
-}
diff --git a/app/src/main/ic_launcher-web.png b/app/src/main/ic_launcher-web.png
deleted file mode 100644
index 8433983..0000000
Binary files a/app/src/main/ic_launcher-web.png and /dev/null differ
diff --git a/app/src/main/java/net/schueller/peertube/activity/AccountActivity.java b/app/src/main/java/net/schueller/peertube/activity/AccountActivity.java
deleted file mode 100644
index c14482e..0000000
--- a/app/src/main/java/net/schueller/peertube/activity/AccountActivity.java
+++ /dev/null
@@ -1,349 +0,0 @@
-/*
- * Copyright (C) 2020 Stefan Schüller
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package net.schueller.peertube.activity;
-
-import android.content.Intent;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.Menu;
-import android.view.View;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import com.google.android.material.bottomnavigation.BottomNavigationView;
-import com.google.android.material.bottomnavigation.LabelVisibilityMode;
-import com.google.android.material.navigation.NavigationBarView;
-import com.mikepenz.iconics.IconicsDrawable;
-import com.mikepenz.iconics.typeface.library.fontawesome.FontAwesome;
-import com.squareup.picasso.Picasso;
-
-import net.schueller.peertube.R;
-import net.schueller.peertube.adapter.ChannelAdapter;
-import net.schueller.peertube.adapter.MultiViewRecycleViewAdapter;
-import net.schueller.peertube.helper.APIUrlHelper;
-import net.schueller.peertube.helper.ErrorHelper;
-import net.schueller.peertube.helper.MetaDataHelper;
-import net.schueller.peertube.model.Account;
-import net.schueller.peertube.model.Avatar;
-import net.schueller.peertube.model.ChannelList;
-import net.schueller.peertube.model.VideoList;
-import net.schueller.peertube.network.GetUserService;
-import net.schueller.peertube.network.GetVideoDataService;
-import net.schueller.peertube.network.RetrofitInstance;
-
-
-import java.util.ArrayList;
-import java.util.Objects;
-import java.util.Set;
-
-import androidx.annotation.NonNull;
-import androidx.appcompat.widget.Toolbar;
-import androidx.coordinatorlayout.widget.CoordinatorLayout;
-import androidx.recyclerview.widget.LinearLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
-import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
-import retrofit2.Call;
-import retrofit2.Callback;
-import retrofit2.Response;
-
-
-public class AccountActivity extends CommonActivity {
-
- private String TAG = "AccountActivity";
- private String apiBaseURL;
-
- private Integer videosStart, videosCount, videosCurrentStart;
- private String videosFilter, videosSort, videosNsfw;
- private Set videosLanguages;
-
- private ChannelAdapter channelAdapter;
- private MultiViewRecycleViewAdapter mMultiViewRecycleViewAdapter;
-
- private RecyclerView recyclerViewVideos;
- private RecyclerView recyclerViewChannels;
-
- private SwipeRefreshLayout swipeRefreshLayoutVideos;
- private SwipeRefreshLayout swipeRefreshLayoutChannels;
- private CoordinatorLayout aboutView;
- //private TextView emptyView;
-
- private Boolean isLoadingVideos;
-
- private GetUserService userService;
-
- private String displayNameAndHost;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- setContentView(R.layout.activity_account);
-
- apiBaseURL = APIUrlHelper.getUrlWithVersion(this);
-
- userService = RetrofitInstance.getRetrofitInstance(apiBaseURL, APIUrlHelper.useInsecureConnection(this)).create(GetUserService.class);
-
- recyclerViewVideos = findViewById(R.id.account_video_recyclerView);
- recyclerViewChannels = findViewById(R.id.account_channel_recyclerView);
-
- swipeRefreshLayoutVideos = findViewById(R.id.account_swipeRefreshLayout_videos);
- swipeRefreshLayoutChannels = findViewById(R.id.account_swipeRefreshLayout_channels);
- aboutView = findViewById(R.id.account_about);
-
- RecyclerView.LayoutManager layoutManagerVideos = new LinearLayoutManager(AccountActivity.this);
- recyclerViewVideos.setLayoutManager(layoutManagerVideos);
-
- RecyclerView.LayoutManager layoutManagerVideosChannels = new LinearLayoutManager(AccountActivity.this);
- recyclerViewChannels.setLayoutManager(layoutManagerVideosChannels);
-
- mMultiViewRecycleViewAdapter = new MultiViewRecycleViewAdapter();
- recyclerViewVideos.setAdapter(mMultiViewRecycleViewAdapter);
-
- channelAdapter = new ChannelAdapter(new ArrayList<>(), AccountActivity.this);
- recyclerViewChannels.setAdapter(channelAdapter);
-
-
- swipeRefreshLayoutVideos.setOnRefreshListener(() -> {
- // Refresh items
- if (!isLoadingVideos) {
- videosCurrentStart = 0;
- loadAccountVideos(displayNameAndHost);
- }
- });
-
- // get video ID
- Intent intent = getIntent();
- displayNameAndHost = intent.getStringExtra(VideoListActivity.EXTRA_ACCOUNTDISPLAYNAME);
- Log.v(TAG, "click: " + displayNameAndHost);
-
-
- createBottomBarNavigation();
-
- videosStart = 0;
- videosCount = 25;
- videosCurrentStart = 0;
- videosFilter = "";
- videosSort = "-publishedAt";
- videosNsfw = "";
-
-
- // Attaching the layout to the toolbar object
- Toolbar toolbar = findViewById(R.id.tool_bar_account);
- // Setting toolbar as the ActionBar with setSupportActionBar() call
- setSupportActionBar(toolbar);
-
- Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
- getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_baseline_close_24);
- getSupportActionBar().setTitle(displayNameAndHost);
-
- loadAccountVideos(displayNameAndHost);
-
- }
-
- @Override
- public boolean onSupportNavigateUp() {
- finish(); // close this activity as oppose to navigating up
-
- return false;
- }
-
- private void loadAccount(String ownerString) {
-
- // get video details from api
- Call call = userService.getAccount(ownerString);
-
- call.enqueue(new Callback() {
- @Override
- public void onResponse(@NonNull Call call, @NonNull Response response) {
-
-
- if (response.isSuccessful()) {
- Account account = response.body();
-
- String owner = MetaDataHelper.getOwnerString(account,
- AccountActivity.this, true
- );
-
-
- // set view data
- TextView ownerStringView = findViewById(R.id.account_owner_string);
- ownerStringView.setText(owner);
-
- TextView followers = findViewById(R.id.account_followers);
- followers.setText(String.valueOf(account.getFollowersCount()));
-
- TextView description = findViewById(R.id.account_description);
- description.setText(account.getDescription());
-
- TextView joined = findViewById(R.id.account_joined);
- joined.setText(account.getCreatedAt().toString());
-
-
- ImageView accountAvatar = findViewById(R.id.account_avatar);
-
- // set Avatar
- Avatar avatar = account.getAvatar();
- if (avatar != null) {
- String avatarPath = avatar.getPath();
- Picasso.get()
- .load(APIUrlHelper.getUrl(AccountActivity.this) + avatarPath)
- .into(accountAvatar);
- }
-
- } else {
- ErrorHelper.showToastFromCommunicationError( AccountActivity.this, null );
- }
-
-
- }
-
- @Override
- public void onFailure(@NonNull Call call, @NonNull Throwable t) {
- Log.wtf(TAG, t.fillInStackTrace());
- ErrorHelper.showToastFromCommunicationError( AccountActivity.this, t );
- }
- });
-
- }
-
-
- private void loadAccountVideos(String displayNameAndHost) {
-
- isLoadingVideos = false;
-
- GetVideoDataService service = RetrofitInstance.getRetrofitInstance(apiBaseURL, APIUrlHelper.useInsecureConnection(this)).create(GetVideoDataService.class);
- Call call;
-
- call = service.getAccountVideosData(displayNameAndHost, videosStart, videosCount, videosSort);
-
- call.enqueue(new Callback() {
- @Override
- public void onResponse(@NonNull Call call, @NonNull Response response) {
-
- Log.v(TAG, response.toString());
-
- if (response.isSuccessful()) {
- if (videosCurrentStart == 0) {
- mMultiViewRecycleViewAdapter.clearData();
- }
-
- if (response.body() != null) {
- mMultiViewRecycleViewAdapter.setVideoData(response.body().getVideos());
- }
-
- } else{
- ErrorHelper.showToastFromCommunicationError( AccountActivity.this, null );
- }
-
- isLoadingVideos = false;
- swipeRefreshLayoutVideos.setRefreshing(false);
- }
-
- @Override
- public void onFailure(@NonNull Call call, @NonNull Throwable t) {
- Log.wtf("err", t.fillInStackTrace());
- ErrorHelper.showToastFromCommunicationError( AccountActivity.this, t );
- isLoadingVideos = false;
- swipeRefreshLayoutVideos.setRefreshing(false);
- }
- });
- }
-
- private void loadAccountChannels(String displayNameAndHost) {
-
- // get video details from api
- Call call = userService.getAccountChannels(displayNameAndHost);
-
- call.enqueue(new Callback() {
- @Override
- public void onResponse(@NonNull Call call, @NonNull Response response) {
-
-
- if (response.isSuccessful()) {
- ChannelList channelList = response.body();
-
-
-
- } else {
- ErrorHelper.showToastFromCommunicationError( AccountActivity.this, null );
- }
-
-
- }
-
- @Override
- public void onFailure(@NonNull Call call, @NonNull Throwable t) {
- Log.wtf(TAG, t.fillInStackTrace());
- ErrorHelper.showToastFromCommunicationError( AccountActivity.this, t );
- }
- });
- }
-
-
-
- private void createBottomBarNavigation() {
-
- // Get Bottom Navigation
- BottomNavigationView navigation = findViewById(R.id.account_navigation);
-
- // Always show text label
- navigation.setLabelVisibilityMode(NavigationBarView.LABEL_VISIBILITY_LABELED);
-
- // Add Icon font
- Menu navMenu = navigation.getMenu();
- navMenu.findItem(R.id.account_navigation_about).setIcon(
- new IconicsDrawable(this, FontAwesome.Icon.faw_user));
- navMenu.findItem(R.id.account_navigation_channels).setIcon(
- new IconicsDrawable(this, FontAwesome.Icon.faw_list));
- navMenu.findItem(R.id.account_navigation_videos).setIcon(
- new IconicsDrawable(this, FontAwesome.Icon.faw_video));
-
- // Click Listener
- navigation.setOnNavigationItemSelectedListener(menuItem -> {
- switch (menuItem.getItemId()) {
- case R.id.account_navigation_about:
-
- swipeRefreshLayoutVideos.setVisibility(View.GONE);
- swipeRefreshLayoutChannels.setVisibility(View.GONE);
- aboutView.setVisibility(View.VISIBLE);
- loadAccount(displayNameAndHost);
-
- return true;
- case R.id.account_navigation_channels:
-
- swipeRefreshLayoutVideos.setVisibility(View.GONE);
- swipeRefreshLayoutChannels.setVisibility(View.VISIBLE);
- aboutView.setVisibility(View.GONE);
- loadAccountChannels(displayNameAndHost);
-
- return true;
- case R.id.account_navigation_videos:
-
- swipeRefreshLayoutVideos.setVisibility(View.VISIBLE);
- swipeRefreshLayoutChannels.setVisibility(View.GONE);
- aboutView.setVisibility(View.GONE);
- loadAccountVideos(displayNameAndHost);
-
- return true;
-
- }
- return false;
- });
-
- }
-}
diff --git a/app/src/main/java/net/schueller/peertube/activity/CommonActivity.java b/app/src/main/java/net/schueller/peertube/activity/CommonActivity.java
deleted file mode 100644
index d68ffe4..0000000
--- a/app/src/main/java/net/schueller/peertube/activity/CommonActivity.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2020 Stefan Schüller
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package net.schueller.peertube.activity;
-
-import android.content.SharedPreferences;
-import android.content.res.Configuration;
-import android.content.res.Resources;
-import android.os.Bundle;
-import android.preference.PreferenceManager;
-
-import net.schueller.peertube.R;
-
-import java.util.Locale;
-
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.appcompat.app.AppCompatDelegate;
-
-public class CommonActivity extends AppCompatActivity {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // Set Night Mode
- SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
- AppCompatDelegate.setDefaultNightMode(sharedPref.getBoolean(getString(R.string.pref_dark_mode_key), false) ?
- AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_NO);
-
- // Set theme
- setTheme(getResources().getIdentifier(
- sharedPref.getString(
- getString(R.string.pref_theme_key),
- getString(R.string.app_default_theme)
- ),
- "style",
- getPackageName())
- );
-
- // Set language
- String countryCode = sharedPref.getString(getString(R.string.pref_language_app_key), null);
-
- if (countryCode == null) {
- return;
- }
-
- setLocale(countryCode);
- }
-
-
- public void setLocale(String languageCode) {
-
- Locale locale = new Locale(languageCode);
-
- //Neither Chinese language choice was working, found this fix on stack overflow
- if (languageCode.equals("zh-rCN"))
- locale = Locale.SIMPLIFIED_CHINESE;
- if (languageCode.equals("zh-rTW"))
- locale = Locale.TRADITIONAL_CHINESE;
-
- Locale.setDefault(locale);
-
- Resources resources = getResources();
- Configuration config = resources.getConfiguration();
- config.setLocale(locale);
- resources.updateConfiguration(config, resources.getDisplayMetrics());
- }
-}
diff --git a/app/src/main/java/net/schueller/peertube/activity/MeActivity.java b/app/src/main/java/net/schueller/peertube/activity/MeActivity.java
deleted file mode 100644
index 57bc0b4..0000000
--- a/app/src/main/java/net/schueller/peertube/activity/MeActivity.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright (C) 2020 Stefan Schüller
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-package net.schueller.peertube.activity;
-
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.View;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-import androidx.annotation.NonNull;
-import androidx.appcompat.widget.Toolbar;
-import com.squareup.picasso.Picasso;
-import net.schueller.peertube.R;
-import net.schueller.peertube.helper.APIUrlHelper;
-import net.schueller.peertube.helper.ErrorHelper;
-import net.schueller.peertube.model.Avatar;
-import net.schueller.peertube.model.Me;
-import net.schueller.peertube.network.GetUserService;
-import net.schueller.peertube.network.RetrofitInstance;
-import net.schueller.peertube.network.Session;
-import retrofit2.Call;
-import retrofit2.Callback;
-import retrofit2.Response;
-
-import java.util.Objects;
-
-import static net.schueller.peertube.application.AppApplication.getContext;
-
-public class MeActivity extends CommonActivity {
-
-
- private static final String TAG = "MeActivity";
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.menu_top_account, menu);
-
- return true;
- }
-
-
- @Override
- public boolean onSupportNavigateUp() {
- finish(); // close this activity as oppose to navigating up
-
- return false;
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- setContentView(R.layout.activity_me);
-
- // Attaching the layout to the toolbar object
- Toolbar toolbar = findViewById(R.id.tool_bar_me);
- // Setting toolbar as the ActionBar with setSupportActionBar() call
- setSupportActionBar(toolbar);
- Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
- getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_baseline_close_24);
-
- LinearLayout account = findViewById(R.id.a_me_account_line);
- LinearLayout playlist = findViewById(R.id.a_me_playlist);
- LinearLayout settings = findViewById(R.id.a_me_settings);
- LinearLayout help = findViewById(R.id.a_me_helpnfeedback);
-
- TextView logout = findViewById(R.id.a_me_logout);
-
- playlist.setOnClickListener(view -> {
- Intent playlistActivity = new Intent(getContext(), PlaylistActivity.class);
- startActivity(playlistActivity);
- });
-
- settings.setOnClickListener(view -> {
- Intent settingsActivity = new Intent(getContext(), SettingsActivity.class);
- //overridePendingTransition(R.anim.slide_in_bottom, 0);
- startActivity(settingsActivity);
- });
-
- help.setOnClickListener(view -> {
- String url = "https://github.com/sschueller/peertube-android/issues";
- Intent i = new Intent(Intent.ACTION_VIEW);
- i.setData(Uri.parse(url));
- startActivity(i);
- });
-
- logout.setOnClickListener(view -> {
- Session.getInstance().invalidate();
- account.setVisibility(View.GONE);
- });
-
- getUserData();
- }
-
- private void getUserData() {
-
-
- String apiBaseURL = APIUrlHelper.getUrlWithVersion(this);
- String baseURL = APIUrlHelper.getUrl(this);
-
- GetUserService service = RetrofitInstance.getRetrofitInstance(apiBaseURL, APIUrlHelper.useInsecureConnection(this)).create(GetUserService.class);
-
- Call call = service.getMe();
-
- call.enqueue(new Callback() {
-
- final LinearLayout account = findViewById(R.id.a_me_account_line);
-
- @Override
- public void onResponse(@NonNull Call call, @NonNull Response response) {
-
-
- if (response.isSuccessful()) {
-
- Me me = response.body();
-
- Log.d(TAG, response.body().toString());
-
- TextView username = findViewById(R.id.a_me_username);
- TextView email = findViewById(R.id.a_me_email);
- ImageView avatarView = findViewById(R.id.a_me_avatar);
-
-
- username.setText(me.getUsername());
- email.setText(me.getEmail());
-
- Avatar avatar = me.getAccount().getAvatar();
- if (avatar != null) {
- String avatarPath = avatar.getPath();
- Picasso.get()
- .load(baseURL + avatarPath)
- .into(avatarView);
- }
-
- account.setVisibility(View.VISIBLE);
-
- } else {
- account.setVisibility(View.GONE);
- }
-
- }
-
- @Override
- public void onFailure(@NonNull Call call, @NonNull Throwable t) {
- ErrorHelper.showToastFromCommunicationError(MeActivity.this, t);
- account.setVisibility(View.GONE);
- }
- });
-
- }
-
- @Override
- protected void onResume() {
- super.onResume();
-
- getUserData();
-
- }
-}
diff --git a/app/src/main/java/net/schueller/peertube/activity/PlaylistActivity.kt b/app/src/main/java/net/schueller/peertube/activity/PlaylistActivity.kt
deleted file mode 100644
index 30b364a..0000000
--- a/app/src/main/java/net/schueller/peertube/activity/PlaylistActivity.kt
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2020 Stefan Schüller
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-package net.schueller.peertube.activity
-
-import android.app.AlertDialog
-import android.content.DialogInterface
-import android.content.Intent
-import android.os.Bundle
-import androidx.activity.viewModels
-import androidx.recyclerview.widget.ItemTouchHelper
-import androidx.recyclerview.widget.RecyclerView
-import net.schueller.peertube.R
-import net.schueller.peertube.adapter.MultiViewRecyclerViewHolder
-import net.schueller.peertube.adapter.PlaylistAdapter
-import net.schueller.peertube.database.Video
-import net.schueller.peertube.database.VideoViewModel
-import net.schueller.peertube.databinding.ActivityPlaylistBinding
-
-class PlaylistActivity : CommonActivity() {
-
- private val TAG = "PlaylistAct"
-
- private val mVideoViewModel: VideoViewModel by viewModels()
-
- private lateinit var mBinding: ActivityPlaylistBinding
-
- override fun onSupportNavigateUp(): Boolean {
- finish() // close this activity as oppose to navigating up
- return false
- }
-
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
- mBinding = ActivityPlaylistBinding.inflate(layoutInflater)
- setContentView(mBinding.root)
-
- // Setting toolbar as the ActionBar with setSupportActionBar() call
- setSupportActionBar(mBinding.toolBarServerAddressBook)
- supportActionBar?.apply {
- setDisplayHomeAsUpEnabled(true)
- setHomeAsUpIndicator(R.drawable.ic_baseline_close_24)
- }
-
- showServers()
- }
-
- private fun onVideoClick(video: Video) {
- val intent = Intent(this, VideoPlayActivity::class.java)
- intent.putExtra(MultiViewRecyclerViewHolder.EXTRA_VIDEOID, video.videoUUID)
- startActivity(intent)
- }
-
- private fun showServers() {
- val adapter = PlaylistAdapter(mutableListOf(), { onVideoClick(it) }).also {
- mBinding.serverListRecyclerview.adapter = it
- }
-
- // Delete items on swipe
- val helper = ItemTouchHelper(
- object : ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT or ItemTouchHelper.RIGHT) {
- override fun onMove(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean {
- return false
- }
-
- override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {
- AlertDialog.Builder(this@PlaylistActivity)
- .setTitle(getString(R.string.remove_video))
- .setMessage(getString(R.string.remove_video_warning_message))
- .setPositiveButton(android.R.string.ok) { _: DialogInterface?, _: Int ->
- val position = viewHolder.bindingAdapterPosition
- val video = adapter.getVideoAtPosition(position)
- // Delete the video
- mVideoViewModel.delete(video)
- }
- .setNegativeButton(android.R.string.cancel) { _: DialogInterface?, _: Int -> adapter.notifyItemChanged(viewHolder.bindingAdapterPosition) }
- .setIcon(android.R.drawable.ic_dialog_alert)
- .show()
- }
- })
- helper.attachToRecyclerView(mBinding.serverListRecyclerview)
-
- // Update the cached copy of the words in the adapter.
- mVideoViewModel.allVideos.observe(this, { videos: List