mirror of
https://framagit.org/tom79/fedilab-tube
synced 2025-04-15 10:57:57 +02:00
comment #5 - Add searches
This commit is contained in:
parent
fd7632f001
commit
056092ac71
@ -160,6 +160,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
private boolean isMyVideo;
|
private boolean isMyVideo;
|
||||||
private List<Comment> comments;
|
private List<Comment> comments;
|
||||||
private CommentListAdapter commentListAdapter;
|
private CommentListAdapter commentListAdapter;
|
||||||
|
private boolean sepiaSearch;
|
||||||
|
|
||||||
public static void hideKeyboard(Activity activity) {
|
public static void hideKeyboard(Activity activity) {
|
||||||
if (activity != null && activity.getWindow() != null) {
|
if (activity != null && activity.getWindow() != null) {
|
||||||
@ -198,7 +199,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||||
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
|
||||||
String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
|
String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
|
||||||
if (Helper.isLoggedIn(PeertubeActivity.this)) {
|
if (Helper.isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
|
||||||
Account account = new AccountDAO(PeertubeActivity.this, db).getAccountByToken(token);
|
Account account = new AccountDAO(PeertubeActivity.this, db).getAccountByToken(token);
|
||||||
Helper.loadGiF(PeertubeActivity.this, account.getAvatar() != null ? account.getAvatar().getPath() : null, my_pp);
|
Helper.loadGiF(PeertubeActivity.this, account.getAvatar() != null ? account.getAvatar().getPath() : null, my_pp);
|
||||||
}
|
}
|
||||||
@ -224,6 +225,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
peertubeInstance = b.getString("peertube_instance", Helper.getLiveInstance(PeertubeActivity.this));
|
peertubeInstance = b.getString("peertube_instance", Helper.getLiveInstance(PeertubeActivity.this));
|
||||||
videoUuid = b.getString("video_uuid", null);
|
videoUuid = b.getString("video_uuid", null);
|
||||||
isMyVideo = b.getBoolean("isMyVideo", false);
|
isMyVideo = b.getBoolean("isMyVideo", false);
|
||||||
|
sepiaSearch = b.getBoolean("sepia_search", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -299,7 +301,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
if (firstVisibleItem + visibleItemCount == totalItemCount) {
|
if (firstVisibleItem + visibleItemCount == totalItemCount) {
|
||||||
if (!flag_loading) {
|
if (!flag_loading) {
|
||||||
CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class);
|
CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class);
|
||||||
commentViewModel.getThread(videoUuid, max_id).observe(PeertubeActivity.this, apiresponse -> manageVIewComment(apiresponse));
|
commentViewModel.getThread(sepiaSearch?peertubeInstance:null, videoUuid, max_id).observe(PeertubeActivity.this, apiresponse -> manageVIewComment(apiresponse));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -360,9 +362,9 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
peertube_playlist.setVisibility(View.VISIBLE);
|
peertube_playlist.setVisibility(View.VISIBLE);
|
||||||
peertube_bookmark.setVisibility(View.GONE);
|
peertube_bookmark.setVisibility(View.GONE);
|
||||||
TimelineVM feedsViewModel = new ViewModelProvider(PeertubeActivity.this).get(TimelineVM.class);
|
TimelineVM feedsViewModel = new ViewModelProvider(PeertubeActivity.this).get(TimelineVM.class);
|
||||||
feedsViewModel.getVideo(videoUuid, isMyVideo).observe(PeertubeActivity.this, this::manageVIewVideo);
|
feedsViewModel.getVideo(sepiaSearch?peertubeInstance:null, videoUuid, isMyVideo).observe(PeertubeActivity.this, this::manageVIewVideo);
|
||||||
CaptionsVM captionsViewModel = new ViewModelProvider(PeertubeActivity.this).get(CaptionsVM.class);
|
CaptionsVM captionsViewModel = new ViewModelProvider(PeertubeActivity.this).get(CaptionsVM.class);
|
||||||
captionsViewModel.getCaptions(videoUuid).observe(PeertubeActivity.this, this::manageCaptions);
|
captionsViewModel.getCaptions(sepiaSearch?peertubeInstance:null, videoUuid).observe(PeertubeActivity.this, this::manageCaptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void change() {
|
public void change() {
|
||||||
@ -502,7 +504,9 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
|
|
||||||
|
|
||||||
peertube = apiResponse.getPeertubes().get(0);
|
peertube = apiResponse.getPeertubes().get(0);
|
||||||
|
if( sepiaSearch) {
|
||||||
|
peertubeInstance = peertube.getAccount().getHost();
|
||||||
|
}
|
||||||
List<String> videoIds = new ArrayList<>();
|
List<String> videoIds = new ArrayList<>();
|
||||||
videoIds.add(peertube.getId());
|
videoIds.add(peertube.getId());
|
||||||
PlaylistsVM viewModel = new ViewModelProvider(this).get(PlaylistsVM.class);
|
PlaylistsVM viewModel = new ViewModelProvider(this).get(PlaylistsVM.class);
|
||||||
@ -510,7 +514,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
|
|
||||||
|
|
||||||
add_comment_read.setOnClickListener(v -> {
|
add_comment_read.setOnClickListener(v -> {
|
||||||
if (isLoggedIn(PeertubeActivity.this)) {
|
if (isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
|
||||||
add_comment_read.setVisibility(View.GONE);
|
add_comment_read.setVisibility(View.GONE);
|
||||||
add_comment_write.setVisibility(View.VISIBLE);
|
add_comment_write.setVisibility(View.VISIBLE);
|
||||||
send.setVisibility(View.VISIBLE);
|
send.setVisibility(View.VISIBLE);
|
||||||
@ -522,7 +526,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
|
|
||||||
});
|
});
|
||||||
send.setOnClickListener(v -> {
|
send.setOnClickListener(v -> {
|
||||||
if (isLoggedIn(PeertubeActivity.this)) {
|
if (isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
|
||||||
String comment = add_comment_write.getText().toString();
|
String comment = add_comment_write.getText().toString();
|
||||||
if (comment.trim().length() > 0) {
|
if (comment.trim().length() > 0) {
|
||||||
PostActionsVM viewModelComment = new ViewModelProvider(PeertubeActivity.this).get(PostActionsVM.class);
|
PostActionsVM viewModelComment = new ViewModelProvider(PeertubeActivity.this).get(PostActionsVM.class);
|
||||||
@ -547,7 +551,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
|
|
||||||
if (peertube.isCommentsEnabled()) {
|
if (peertube.isCommentsEnabled()) {
|
||||||
CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class);
|
CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class);
|
||||||
commentViewModel.getThread(videoUuid, max_id).observe(PeertubeActivity.this, this::manageVIewComment);
|
commentViewModel.getThread(sepiaSearch?peertubeInstance:null, videoUuid, max_id).observe(PeertubeActivity.this, this::manageVIewComment);
|
||||||
write_comment_container.setVisibility(View.VISIBLE);
|
write_comment_container.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -570,7 +574,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
initResolution();
|
initResolution();
|
||||||
|
|
||||||
peertube_like_count.setOnClickListener(v -> {
|
peertube_like_count.setOnClickListener(v -> {
|
||||||
if (isLoggedIn(PeertubeActivity.this)) {
|
if (isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
|
||||||
String newState = peertube.getMyRating().equals("like") ? "none" : "like";
|
String newState = peertube.getMyRating().equals("like") ? "none" : "like";
|
||||||
PostActionsVM viewModelLike = new ViewModelProvider(PeertubeActivity.this).get(PostActionsVM.class);
|
PostActionsVM viewModelLike = new ViewModelProvider(PeertubeActivity.this).get(PostActionsVM.class);
|
||||||
viewModelLike.post(RATEVIDEO, peertube.getId(), newState).observe(PeertubeActivity.this, apiResponse1 -> manageVIewPostActions(RATEVIDEO, apiResponse1));
|
viewModelLike.post(RATEVIDEO, peertube.getId(), newState).observe(PeertubeActivity.this, apiResponse1 -> manageVIewPostActions(RATEVIDEO, apiResponse1));
|
||||||
@ -591,7 +595,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
peertube_dislike_count.setOnClickListener(v -> {
|
peertube_dislike_count.setOnClickListener(v -> {
|
||||||
if (isLoggedIn(PeertubeActivity.this)) {
|
if (isLoggedIn(PeertubeActivity.this) && !sepiaSearch) {
|
||||||
String newState = peertube.getMyRating().equals("dislike") ? "none" : "dislike";
|
String newState = peertube.getMyRating().equals("dislike") ? "none" : "dislike";
|
||||||
PostActionsVM viewModelLike = new ViewModelProvider(PeertubeActivity.this).get(PostActionsVM.class);
|
PostActionsVM viewModelLike = new ViewModelProvider(PeertubeActivity.this).get(PostActionsVM.class);
|
||||||
viewModelLike.post(RATEVIDEO, peertube.getId(), newState).observe(PeertubeActivity.this, apiResponse1 -> manageVIewPostActions(RATEVIDEO, apiResponse1));
|
viewModelLike.post(RATEVIDEO, peertube.getId(), newState).observe(PeertubeActivity.this, apiResponse1 -> manageVIewPostActions(RATEVIDEO, apiResponse1));
|
||||||
@ -712,7 +716,11 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
|
|
||||||
Uri uri = null;
|
Uri uri = null;
|
||||||
if (which > 0) {
|
if (which > 0) {
|
||||||
uri = Uri.parse("https://" + getLiveInstance(PeertubeActivity.this) + captions.get(which - 1).getCaptionPath());
|
if( !sepiaSearch) {
|
||||||
|
uri = Uri.parse("https://" + getLiveInstance(PeertubeActivity.this) + captions.get(which - 1).getCaptionPath());
|
||||||
|
}else{
|
||||||
|
uri = Uri.parse("https://" + peertubeInstance + captions.get(which - 1).getCaptionPath());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int video_cache = sharedpreferences.getInt(Helper.SET_VIDEO_CACHE, Helper.DEFAULT_VIDEO_CACHE_MB);
|
int video_cache = sharedpreferences.getInt(Helper.SET_VIDEO_CACHE, Helper.DEFAULT_VIDEO_CACHE_MB);
|
||||||
@ -934,7 +942,7 @@ public class PeertubeActivity extends AppCompatActivity implements CommentListAd
|
|||||||
|
|
||||||
if (peertube.isCommentsEnabled() && statusAction == ADD_COMMENT) {
|
if (peertube.isCommentsEnabled() && statusAction == ADD_COMMENT) {
|
||||||
CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class);
|
CommentVM commentViewModel = new ViewModelProvider(PeertubeActivity.this).get(CommentVM.class);
|
||||||
commentViewModel.getThread(videoUuid, max_id).observe(PeertubeActivity.this, this::manageVIewComment);
|
commentViewModel.getThread(sepiaSearch?peertubeInstance:null, videoUuid, max_id).observe(PeertubeActivity.this, this::manageVIewComment);
|
||||||
} else if (statusAction == RetrofitPeertubeAPI.ActionType.REPORT_ACCOUNT) {
|
} else if (statusAction == RetrofitPeertubeAPI.ActionType.REPORT_ACCOUNT) {
|
||||||
Toasty.success(PeertubeActivity.this, getString(R.string.successful_report), Toasty.LENGTH_LONG).show();
|
Toasty.success(PeertubeActivity.this, getString(R.string.successful_report), Toasty.LENGTH_LONG).show();
|
||||||
} else if (statusAction == RetrofitPeertubeAPI.ActionType.REPORT_VIDEO) {
|
} else if (statusAction == RetrofitPeertubeAPI.ActionType.REPORT_VIDEO) {
|
||||||
|
@ -224,7 +224,7 @@ public class PeertubeEditUploadActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
|
|
||||||
TimelineVM feedsViewModel = new ViewModelProvider(PeertubeEditUploadActivity.this).get(TimelineVM.class);
|
TimelineVM feedsViewModel = new ViewModelProvider(PeertubeEditUploadActivity.this).get(TimelineVM.class);
|
||||||
feedsViewModel.getMyVideo(videoId).observe(PeertubeEditUploadActivity.this, this::manageVIewVideo);
|
feedsViewModel.getMyVideo(null, videoId).observe(PeertubeEditUploadActivity.this, this::manageVIewVideo);
|
||||||
channels = new LinkedHashMap<>();
|
channels = new LinkedHashMap<>();
|
||||||
|
|
||||||
setTitle(R.string.edit_video);
|
setTitle(R.string.edit_video);
|
||||||
|
@ -14,6 +14,8 @@ package app.fedilab.fedilabtube;
|
|||||||
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
* see <http://www.gnu.org/licenses>. */
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -25,7 +27,9 @@ import android.widget.Spinner;
|
|||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
|
|
||||||
|
import com.mancj.materialsearchbar.MaterialSearchBar;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
@ -36,10 +40,9 @@ import java.util.LinkedHashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import app.fedilab.fedilabtube.client.data.VideoData;
|
|
||||||
import app.fedilab.fedilabtube.client.entities.SepiaSearch;
|
import app.fedilab.fedilabtube.client.entities.SepiaSearch;
|
||||||
|
import app.fedilab.fedilabtube.fragment.DisplaySepiaSearchFragment;
|
||||||
import app.fedilab.fedilabtube.helper.Helper;
|
import app.fedilab.fedilabtube.helper.Helper;
|
||||||
import app.fedilab.fedilabtube.viewmodel.SepiaSearchVM;
|
|
||||||
import mabbas007.tagsedittext.TagsEditText;
|
import mabbas007.tagsedittext.TagsEditText;
|
||||||
|
|
||||||
import static app.fedilab.fedilabtube.MainActivity.peertubeInformation;
|
import static app.fedilab.fedilabtube.MainActivity.peertubeInformation;
|
||||||
@ -48,10 +51,10 @@ import static app.fedilab.fedilabtube.MainActivity.peertubeInformation;
|
|||||||
public class SepiaSearchActivity extends AppCompatActivity {
|
public class SepiaSearchActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
|
||||||
private SepiaSearch sepiaSearchVideo;
|
private SepiaSearch sepiaSearchVideo, sepiaSearchChannel;
|
||||||
private SepiaSearch sepiaSearchChannel;
|
private TagsEditText sepia_element_all_of_tags, sepia_element_one_of_tags;
|
||||||
|
private MaterialSearchBar searchBar;
|
||||||
|
private ConstraintLayout filter_elements;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -61,12 +64,17 @@ public class SepiaSearchActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
sepiaSearchVideo = new SepiaSearch();
|
sepiaSearchVideo = new SepiaSearch();
|
||||||
sepiaSearchChannel = new SepiaSearch();
|
sepiaSearchChannel = new SepiaSearch();
|
||||||
|
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
||||||
|
sepiaSearchVideo.setCount(String.valueOf(sharedpreferences.getInt(Helper.SET_VIDEOS_PER_PAGE, Helper.VIDEOS_PER_PAGE)));
|
||||||
|
sepiaSearchVideo.setDurationMin(0);
|
||||||
|
sepiaSearchVideo.setDurationMax(9999999);
|
||||||
|
sepiaSearchVideo.setSort("-match");
|
||||||
if (getSupportActionBar() != null)
|
if (getSupportActionBar() != null)
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
|
|
||||||
Button filter = findViewById(R.id.filter);
|
Button filter = findViewById(R.id.filter);
|
||||||
ConstraintLayout filter_elements = findViewById(R.id.filter_elements);
|
filter_elements = findViewById(R.id.filter_elements);
|
||||||
filter.setOnClickListener(view -> {
|
filter.setOnClickListener(view -> {
|
||||||
if( filter_elements.getVisibility() == View.VISIBLE) {
|
if( filter_elements.getVisibility() == View.VISIBLE) {
|
||||||
filter_elements.setVisibility(View.GONE);
|
filter_elements.setVisibility(View.GONE);
|
||||||
@ -178,8 +186,8 @@ public class SepiaSearchActivity extends AppCompatActivity {
|
|||||||
Spinner sepia_element_license = findViewById(R.id.sepia_element_license);
|
Spinner sepia_element_license = findViewById(R.id.sepia_element_license);
|
||||||
Spinner sepia_element_language = findViewById(R.id.sepia_element_language);
|
Spinner sepia_element_language = findViewById(R.id.sepia_element_language);
|
||||||
|
|
||||||
TagsEditText sepia_element_all_of_tags = findViewById(R.id.sepia_element_all_of_tags);
|
sepia_element_all_of_tags = findViewById(R.id.sepia_element_all_of_tags);
|
||||||
TagsEditText sepia_element_one_of_tags = findViewById(R.id.sepia_element_one_of_tags);
|
sepia_element_one_of_tags = findViewById(R.id.sepia_element_one_of_tags);
|
||||||
|
|
||||||
LinkedHashMap<Integer, String> categories = new LinkedHashMap<>(peertubeInformation.getCategories());
|
LinkedHashMap<Integer, String> categories = new LinkedHashMap<>(peertubeInformation.getCategories());
|
||||||
LinkedHashMap<Integer, String> licences = new LinkedHashMap<>(peertubeInformation.getLicences());
|
LinkedHashMap<Integer, String> licences = new LinkedHashMap<>(peertubeInformation.getLicences());
|
||||||
@ -281,23 +289,48 @@ public class SepiaSearchActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Button apply_filter = findViewById(R.id.apply_filter);
|
searchBar = findViewById(R.id.searchBar);
|
||||||
apply_filter.setOnClickListener(v->{
|
|
||||||
if( sepia_element_one_of_tags.getTags().size() > 0 ) {
|
searchBar.setOnSearchActionListener(new MaterialSearchBar.OnSearchActionListener() {
|
||||||
sepiaSearchVideo.setTagsOneOf(sepia_element_one_of_tags.getTags());
|
@Override
|
||||||
}else{
|
public void onSearchStateChanged(boolean enabled) {
|
||||||
sepiaSearchVideo.setTagsOneOf(null);
|
|
||||||
}
|
}
|
||||||
if( sepia_element_all_of_tags.getTags().size() > 0 ) {
|
|
||||||
sepiaSearchVideo.setTagsAllOf(sepia_element_all_of_tags.getTags());
|
@Override
|
||||||
}else{
|
public void onSearchConfirmed(CharSequence text) {
|
||||||
sepiaSearchVideo.setTagsAllOf(null);
|
makeSearch();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onButtonClicked(int buttonCode) {
|
||||||
|
makeSearch();
|
||||||
}
|
}
|
||||||
SepiaSearchVM sepiaSearchVM = new ViewModelProvider(SepiaSearchActivity.this).get(SepiaSearchVM.class);
|
|
||||||
sepiaSearchVM.sepiaSearch(sepiaSearchVideo).observe(SepiaSearchActivity.this, this::manageVideos);
|
|
||||||
});
|
});
|
||||||
|
Button apply_filter = findViewById(R.id.apply_filter);
|
||||||
|
apply_filter.setOnClickListener(v-> makeSearch());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void makeSearch(){
|
||||||
|
if( sepia_element_one_of_tags.getTags().size() > 0 ) {
|
||||||
|
sepiaSearchVideo.setTagsOneOf(sepia_element_one_of_tags.getTags());
|
||||||
|
}else{
|
||||||
|
sepiaSearchVideo.setTagsOneOf(null);
|
||||||
|
}
|
||||||
|
if( sepia_element_all_of_tags.getTags().size() > 0 ) {
|
||||||
|
sepiaSearchVideo.setTagsAllOf(sepia_element_all_of_tags.getTags());
|
||||||
|
}else{
|
||||||
|
sepiaSearchVideo.setTagsAllOf(null);
|
||||||
|
}
|
||||||
|
filter_elements.setVisibility(View.GONE);
|
||||||
|
sepiaSearchVideo.setSearch(searchBar.getText());
|
||||||
|
DisplaySepiaSearchFragment displaySepiaSearchFragment = new DisplaySepiaSearchFragment();
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putParcelable("sepiaSearchVideo", sepiaSearchVideo);
|
||||||
|
displaySepiaSearchFragment.setArguments(bundle);
|
||||||
|
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||||
|
ft.add(R.id.container, displaySepiaSearchFragment).commit();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
@ -308,10 +341,6 @@ public class SepiaSearchActivity extends AppCompatActivity {
|
|||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void manageVideos(VideoData videoData) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateLanguagesPosition(int position) {
|
private void updateLanguagesPosition(int position) {
|
||||||
LinkedHashMap<String, String> languagesCheck = new LinkedHashMap<>(peertubeInformation.getLanguages());
|
LinkedHashMap<String, String> languagesCheck = new LinkedHashMap<>(peertubeInformation.getLanguages());
|
||||||
Iterator<Map.Entry<String, String>> it = languagesCheck.entrySet().iterator();
|
Iterator<Map.Entry<String, String>> it = languagesCheck.entrySet().iterator();
|
||||||
|
@ -86,7 +86,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
private String instance;
|
private String instance;
|
||||||
private String token;
|
private String token;
|
||||||
private Set<String> selection;
|
private Set<String> selection;
|
||||||
private String count = String.valueOf(Helper.VIDEOS_PER_PAGE);
|
private String count;
|
||||||
|
|
||||||
public RetrofitPeertubeAPI(Context context) {
|
public RetrofitPeertubeAPI(Context context) {
|
||||||
_context = context;
|
_context = context;
|
||||||
@ -1334,6 +1334,7 @@ public class RetrofitPeertubeAPI {
|
|||||||
APIResponse apiResponse = new APIResponse();
|
APIResponse apiResponse = new APIResponse();
|
||||||
try {
|
try {
|
||||||
Response<VideoData.Video> response = video.execute();
|
Response<VideoData.Video> response = video.execute();
|
||||||
|
|
||||||
if (response.isSuccessful()) {
|
if (response.isSuccessful()) {
|
||||||
List<VideoData.Video> videos = new ArrayList<>();
|
List<VideoData.Video> videos = new ArrayList<>();
|
||||||
videos.add(response.body());
|
videos.add(response.body());
|
||||||
|
@ -14,10 +14,11 @@ package app.fedilab.fedilabtube.client;
|
|||||||
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
* You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
* see <http://www.gnu.org/licenses>. */
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import app.fedilab.fedilabtube.client.data.VideoData;
|
import app.fedilab.fedilabtube.client.data.VideoData;
|
||||||
import app.fedilab.fedilabtube.client.entities.SepiaSearch;
|
import app.fedilab.fedilabtube.client.entities.SepiaSearch;
|
||||||
import app.fedilab.fedilabtube.helper.Helper;
|
import app.fedilab.fedilabtube.helper.Helper;
|
||||||
@ -30,13 +31,10 @@ public class RetrofitSepiaSearchAPI {
|
|||||||
|
|
||||||
|
|
||||||
private String finalUrl;
|
private String finalUrl;
|
||||||
private String count;
|
|
||||||
|
|
||||||
|
|
||||||
public RetrofitSepiaSearchAPI(Context context) {
|
public RetrofitSepiaSearchAPI() {
|
||||||
finalUrl = "https://search.joinpeertube.org/api/v1/";
|
finalUrl = "https://search.joinpeertube.org/api/v1/";
|
||||||
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
|
|
||||||
count = String.valueOf(sharedpreferences.getInt(Helper.SET_VIDEOS_PER_PAGE, Helper.VIDEOS_PER_PAGE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private SepiaSearchService init() {
|
private SepiaSearchService init() {
|
||||||
@ -54,12 +52,18 @@ public class RetrofitSepiaSearchAPI {
|
|||||||
*/
|
*/
|
||||||
public VideoData getVideos(SepiaSearch sepiaSearch) {
|
public VideoData getVideos(SepiaSearch sepiaSearch) {
|
||||||
SepiaSearchService sepiaSearchService = init();
|
SepiaSearchService sepiaSearchService = init();
|
||||||
|
SimpleDateFormat fmtOut = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH);
|
||||||
|
String startDate = null;
|
||||||
|
if(sepiaSearch.getStartDate() != null) {
|
||||||
|
startDate = fmtOut.format(sepiaSearch.getStartDate());
|
||||||
|
}
|
||||||
Call<VideoData> videoDataCall = sepiaSearchService.getVideos(
|
Call<VideoData> videoDataCall = sepiaSearchService.getVideos(
|
||||||
sepiaSearch.getStart(),
|
sepiaSearch.getStart(),
|
||||||
count,
|
sepiaSearch.getCount(),
|
||||||
sepiaSearch.getSearch(),
|
sepiaSearch.getSearch(),
|
||||||
|
sepiaSearch.getDurationMin(),
|
||||||
sepiaSearch.getDurationMax(),
|
sepiaSearch.getDurationMax(),
|
||||||
sepiaSearch.getStartDate(),
|
startDate,
|
||||||
sepiaSearch.getBoostLanguages(),
|
sepiaSearch.getBoostLanguages(),
|
||||||
sepiaSearch.getCategoryOneOf(),
|
sepiaSearch.getCategoryOneOf(),
|
||||||
sepiaSearch.getLicenceOneOf(),
|
sepiaSearch.getLicenceOneOf(),
|
||||||
@ -67,6 +71,7 @@ public class RetrofitSepiaSearchAPI {
|
|||||||
sepiaSearch.getTagsAllOf(),
|
sepiaSearch.getTagsAllOf(),
|
||||||
sepiaSearch.isNsfw(),
|
sepiaSearch.isNsfw(),
|
||||||
sepiaSearch.getSort());
|
sepiaSearch.getSort());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Response<VideoData> response = videoDataCall.execute();
|
Response<VideoData> response = videoDataCall.execute();
|
||||||
if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
|
@ -30,8 +30,9 @@ interface SepiaSearchService {
|
|||||||
@Query("start") String maxId,
|
@Query("start") String maxId,
|
||||||
@Query("count") String count,
|
@Query("count") String count,
|
||||||
@Query("search") String search,
|
@Query("search") String search,
|
||||||
|
@Query("durationMin") int durationMin,
|
||||||
@Query("durationMax") int durationMax,
|
@Query("durationMax") int durationMax,
|
||||||
@Query("startDate") Date startDate,
|
@Query("startDate") String startDate,
|
||||||
@Query("boostLanguages") List<String> languageOneOf,
|
@Query("boostLanguages") List<String> languageOneOf,
|
||||||
@Query("categoryOneOf") List<Integer> categoryOneOf,
|
@Query("categoryOneOf") List<Integer> categoryOneOf,
|
||||||
@Query("licenceOneOf") List<Integer> licenceOneOf,
|
@Query("licenceOneOf") List<Integer> licenceOneOf,
|
||||||
|
@ -58,6 +58,7 @@ import es.dmoral.toasty.Toasty;
|
|||||||
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.FOLLOW;
|
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.FOLLOW;
|
||||||
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.UNFOLLOW;
|
import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.UNFOLLOW;
|
||||||
import static app.fedilab.fedilabtube.viewmodel.TimelineVM.TimelineType.MY_VIDEOS;
|
import static app.fedilab.fedilabtube.viewmodel.TimelineVM.TimelineType.MY_VIDEOS;
|
||||||
|
import static app.fedilab.fedilabtube.viewmodel.TimelineVM.TimelineType.SEPIA_SEARCH;
|
||||||
|
|
||||||
|
|
||||||
public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
@ -107,15 +108,20 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||||||
ownVideos = video.getAccount() != null && video.getAccount().getId() != null && video.getAccount().getHost().compareTo(Helper.getLiveInstance(context)) == 0 && video.getAccount().getId().compareTo(userId) == 0;
|
ownVideos = video.getAccount() != null && video.getAccount().getId() != null && video.getAccount().getHost().compareTo(Helper.getLiveInstance(context)) == 0 && video.getAccount().getId().compareTo(userId) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String instance = null;
|
||||||
|
if( timelineType == SEPIA_SEARCH) {
|
||||||
|
instance = video.getAccount().getHost();
|
||||||
|
}
|
||||||
|
|
||||||
holder.peertube_account_name.setText(video.getChannel().getAcct());
|
holder.peertube_account_name.setText(video.getChannel().getAcct());
|
||||||
Helper.loadGiF(context, video.getChannel().getAvatar() != null ? video.getChannel().getAvatar().getPath() : null, holder.peertube_profile);
|
Helper.loadGiF(context, instance, video.getChannel().getAvatar() != null ? video.getChannel().getAvatar().getPath() : null, holder.peertube_profile);
|
||||||
|
|
||||||
holder.peertube_title.setText(video.getName());
|
holder.peertube_title.setText(video.getName());
|
||||||
holder.peertube_duration.setText(Helper.secondsToString(video.getDuration()));
|
holder.peertube_duration.setText(Helper.secondsToString(video.getDuration()));
|
||||||
holder.peertube_date.setText(String.format(" - %s", Helper.dateDiff(context, video.getCreatedAt())));
|
holder.peertube_date.setText(String.format(" - %s", Helper.dateDiff(context, video.getCreatedAt())));
|
||||||
holder.peertube_views.setText(context.getString(R.string.number_view_video, Helper.withSuffix(video.getViews())));
|
holder.peertube_views.setText(context.getString(R.string.number_view_video, Helper.withSuffix(video.getViews())));
|
||||||
|
|
||||||
Helper.loadGiF(context, video.getThumbnailPath(), holder.peertube_video_image);
|
Helper.loadGiF(context, instance, video.getThumbnailPath(), holder.peertube_video_image);
|
||||||
|
|
||||||
//For Overview Videos: boolean values for displaying title is managed in the fragment
|
//For Overview Videos: boolean values for displaying title is managed in the fragment
|
||||||
if (video.isHasTitle()) {
|
if (video.isHasTitle()) {
|
||||||
@ -138,6 +144,7 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||||||
Intent intent = new Intent(context, ShowChannelActivity.class);
|
Intent intent = new Intent(context, ShowChannelActivity.class);
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
b.putParcelable("channel", video.getChannel());
|
b.putParcelable("channel", video.getChannel());
|
||||||
|
b.putBoolean("sepia_search", timelineType == SEPIA_SEARCH);
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
});
|
});
|
||||||
@ -245,6 +252,10 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||||||
b.putString("video_id", video.getId());
|
b.putString("video_id", video.getId());
|
||||||
b.putString("video_uuid", video.getUuid());
|
b.putString("video_uuid", video.getUuid());
|
||||||
b.putBoolean("isMyVideo", ownVideos);
|
b.putBoolean("isMyVideo", ownVideos);
|
||||||
|
b.putBoolean("sepia_search", timelineType == SEPIA_SEARCH);
|
||||||
|
if( timelineType == SEPIA_SEARCH) {
|
||||||
|
b.putString("peertube_instance", video.getAccount().getHost());
|
||||||
|
}
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
});
|
});
|
||||||
@ -254,6 +265,10 @@ public class PeertubeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
|
|||||||
b.putString("video_id", video.getId());
|
b.putString("video_id", video.getId());
|
||||||
b.putString("video_uuid", video.getUuid());
|
b.putString("video_uuid", video.getUuid());
|
||||||
b.putBoolean("isMyVideo", ownVideos);
|
b.putBoolean("isMyVideo", ownVideos);
|
||||||
|
b.putBoolean("sepia_search", timelineType == SEPIA_SEARCH);
|
||||||
|
if( timelineType == SEPIA_SEARCH) {
|
||||||
|
b.putString("peertube_instance", video.getAccount().getHost());
|
||||||
|
}
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
});
|
});
|
||||||
|
@ -48,6 +48,8 @@ import app.fedilab.fedilabtube.helper.Helper;
|
|||||||
import app.fedilab.fedilabtube.viewmodel.SepiaSearchVM;
|
import app.fedilab.fedilabtube.viewmodel.SepiaSearchVM;
|
||||||
import es.dmoral.toasty.Toasty;
|
import es.dmoral.toasty.Toasty;
|
||||||
|
|
||||||
|
import static app.fedilab.fedilabtube.viewmodel.TimelineVM.TimelineType.SEPIA_SEARCH;
|
||||||
|
|
||||||
|
|
||||||
public class DisplaySepiaSearchFragment extends Fragment implements AccountsHorizontalListAdapter.EventListener {
|
public class DisplaySepiaSearchFragment extends Fragment implements AccountsHorizontalListAdapter.EventListener {
|
||||||
|
|
||||||
@ -100,7 +102,7 @@ public class DisplaySepiaSearchFragment extends Fragment implements AccountsHori
|
|||||||
mainLoader.setVisibility(View.VISIBLE);
|
mainLoader.setVisibility(View.VISIBLE);
|
||||||
nextElementLoader.setVisibility(View.GONE);
|
nextElementLoader.setVisibility(View.GONE);
|
||||||
|
|
||||||
peertubeAdapater = new PeertubeAdapter(this.peertubes);
|
peertubeAdapater = new PeertubeAdapter(this.peertubes, SEPIA_SEARCH);
|
||||||
lv_status.setAdapter(peertubeAdapater);
|
lv_status.setAdapter(peertubeAdapater);
|
||||||
|
|
||||||
|
|
||||||
@ -220,10 +222,11 @@ public class DisplaySepiaSearchFragment extends Fragment implements AccountsHori
|
|||||||
this.peertubes.addAll(videoData.data);
|
this.peertubes.addAll(videoData.data);
|
||||||
//If no item were inserted previously the adapter is created
|
//If no item were inserted previously the adapter is created
|
||||||
if (previousPosition == 0) {
|
if (previousPosition == 0) {
|
||||||
peertubeAdapater = new PeertubeAdapter(this.peertubes);
|
peertubeAdapater = new PeertubeAdapter(this.peertubes, SEPIA_SEARCH);
|
||||||
lv_status.setAdapter(peertubeAdapater);
|
lv_status.setAdapter(peertubeAdapater);
|
||||||
} else
|
} else
|
||||||
peertubeAdapater.notifyItemRangeInserted(previousPosition, videoData.data.size());
|
peertubeAdapater.notifyItemRangeInserted(previousPosition, videoData.data.size());
|
||||||
|
|
||||||
//remove handlers
|
//remove handlers
|
||||||
swipeRefreshLayout.setRefreshing(false);
|
swipeRefreshLayout.setRefreshing(false);
|
||||||
textviewNoAction.setVisibility(View.GONE);
|
textviewNoAction.setVisibility(View.GONE);
|
||||||
|
@ -72,7 +72,7 @@ public class Helper {
|
|||||||
public static final int RELOAD_MYVIDEOS = 10;
|
public static final int RELOAD_MYVIDEOS = 10;
|
||||||
public static final String SET_VIDEO_MODE = "set_video_mode";
|
public static final String SET_VIDEO_MODE = "set_video_mode";
|
||||||
public static final String SET_QUALITY_MODE = "set_quality_mode";
|
public static final String SET_QUALITY_MODE = "set_quality_mode";
|
||||||
public static final String TIMELINE_TYPE = Helper.TIMELINE_TYPE;
|
public static final String TIMELINE_TYPE = "timeline_type";
|
||||||
public static final int VIDEO_MODE_NORMAL = 0;
|
public static final int VIDEO_MODE_NORMAL = 0;
|
||||||
public static final int VIDEO_MODE_STREAMING = 2;
|
public static final int VIDEO_MODE_STREAMING = 2;
|
||||||
public static final int VIDEO_MODE_WEBVIEW = 1;
|
public static final int VIDEO_MODE_WEBVIEW = 1;
|
||||||
@ -370,7 +370,16 @@ public class Helper {
|
|||||||
loadGiF(context, url, imageView, 10);
|
loadGiF(context, url, imageView, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void loadGiF(final Context context, String instance, String url, final ImageView imageView) {
|
||||||
|
loadGif(context, instance, url, imageView, 10);
|
||||||
|
}
|
||||||
|
|
||||||
public static void loadGiF(final Context context, String url, final ImageView imageView, int round) {
|
public static void loadGiF(final Context context, String url, final ImageView imageView, int round) {
|
||||||
|
loadGif(context, null, url, imageView, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("SameParameterValue")
|
||||||
|
private static void loadGif(final Context context, String instance, String url, final ImageView imageView, int round) {
|
||||||
if (url == null || url.trim().toLowerCase().compareTo("null") == 0) {
|
if (url == null || url.trim().toLowerCase().compareTo("null") == 0) {
|
||||||
Glide.with(imageView.getContext())
|
Glide.with(imageView.getContext())
|
||||||
.asDrawable()
|
.asDrawable()
|
||||||
@ -380,7 +389,7 @@ public class Helper {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (url.startsWith("/")) {
|
if (url.startsWith("/")) {
|
||||||
url = Helper.getLiveInstance(context) + url;
|
url = instance!=null?instance+ url:Helper.getLiveInstance(context) + url;
|
||||||
}
|
}
|
||||||
if (!url.startsWith("http")) {
|
if (!url.startsWith("http")) {
|
||||||
url = "https://" + url;
|
url = "https://" + url;
|
||||||
|
@ -35,18 +35,23 @@ public class CaptionsVM extends AndroidViewModel {
|
|||||||
super(application);
|
super(application);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<APIResponse> getCaptions(String videoId) {
|
public LiveData<APIResponse> getCaptions(String instance, String videoId) {
|
||||||
apiResponseMutableLiveData = new MutableLiveData<>();
|
apiResponseMutableLiveData = new MutableLiveData<>();
|
||||||
loadCaptions(videoId);
|
loadCaptions(instance, videoId);
|
||||||
return apiResponseMutableLiveData;
|
return apiResponseMutableLiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadCaptions(String videoId) {
|
private void loadCaptions(String instance, String videoId) {
|
||||||
Context _mContext = getApplication().getApplicationContext();
|
Context _mContext = getApplication().getApplicationContext();
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
RetrofitPeertubeAPI peertubeAPI = new RetrofitPeertubeAPI(_mContext);
|
RetrofitPeertubeAPI retrofitPeertubeAPI;
|
||||||
APIResponse apiResponse = peertubeAPI.getCaptions(videoId);
|
if( instance == null) {
|
||||||
|
retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext);
|
||||||
|
}else{
|
||||||
|
retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext, instance, null);
|
||||||
|
}
|
||||||
|
APIResponse apiResponse = retrofitPeertubeAPI.getCaptions(videoId);
|
||||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
Runnable myRunnable = () -> apiResponseMutableLiveData.setValue(apiResponse);
|
Runnable myRunnable = () -> apiResponseMutableLiveData.setValue(apiResponse);
|
||||||
mainHandler.post(myRunnable);
|
mainHandler.post(myRunnable);
|
||||||
|
@ -35,9 +35,9 @@ public class CommentVM extends AndroidViewModel {
|
|||||||
super(application);
|
super(application);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<APIResponse> getThread(String videoId, String max_Id) {
|
public LiveData<APIResponse> getThread(String instance, String videoId, String max_Id) {
|
||||||
apiResponseMutableLiveData = new MutableLiveData<>();
|
apiResponseMutableLiveData = new MutableLiveData<>();
|
||||||
getThreadComments(videoId, max_Id);
|
getThreadComments(instance, videoId, max_Id);
|
||||||
return apiResponseMutableLiveData;
|
return apiResponseMutableLiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,12 +48,17 @@ public class CommentVM extends AndroidViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void getThreadComments(String videoId, String max_id) {
|
private void getThreadComments(String instance, String videoId, String max_id) {
|
||||||
Context _mContext = getApplication().getApplicationContext();
|
Context _mContext = getApplication().getApplicationContext();
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
RetrofitPeertubeAPI api = new RetrofitPeertubeAPI(_mContext);
|
RetrofitPeertubeAPI retrofitPeertubeAPI;
|
||||||
APIResponse apiResponse = api.getComments(CommentVM.action.GET_THREAD, videoId, null, max_id);
|
if( instance == null) {
|
||||||
|
retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext);
|
||||||
|
}else{
|
||||||
|
retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext, instance, null);
|
||||||
|
}
|
||||||
|
APIResponse apiResponse = retrofitPeertubeAPI.getComments(CommentVM.action.GET_THREAD, videoId, null, max_id);
|
||||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
Runnable myRunnable = () -> apiResponseMutableLiveData.setValue(apiResponse);
|
Runnable myRunnable = () -> apiResponseMutableLiveData.setValue(apiResponse);
|
||||||
mainHandler.post(myRunnable);
|
mainHandler.post(myRunnable);
|
||||||
|
@ -42,10 +42,9 @@ public class SepiaSearchVM extends AndroidViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void getVideos(SepiaSearch sepiaSearch) {
|
private void getVideos(SepiaSearch sepiaSearch) {
|
||||||
Context _mContext = getApplication().getApplicationContext();
|
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
VideoData videoData = new RetrofitSepiaSearchAPI(_mContext).getVideos(sepiaSearch);
|
VideoData videoData = new RetrofitSepiaSearchAPI().getVideos(sepiaSearch);
|
||||||
Handler mainHandler = new Handler(Looper.getMainLooper());
|
Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||||
Runnable myRunnable = () -> apiResponseMutableLiveData.setValue(videoData);
|
Runnable myRunnable = () -> apiResponseMutableLiveData.setValue(videoData);
|
||||||
mainHandler.post(myRunnable);
|
mainHandler.post(myRunnable);
|
||||||
|
@ -51,9 +51,9 @@ public class TimelineVM extends AndroidViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public LiveData<APIResponse> getVideo(String videoId, boolean isMyVideo) {
|
public LiveData<APIResponse> getVideo(String instance, String videoId, boolean isMyVideo) {
|
||||||
apiResponseMutableLiveData = new MutableLiveData<>();
|
apiResponseMutableLiveData = new MutableLiveData<>();
|
||||||
getSingle(videoId, isMyVideo);
|
getSingle(instance, videoId, isMyVideo);
|
||||||
return apiResponseMutableLiveData;
|
return apiResponseMutableLiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,9 +63,9 @@ public class TimelineVM extends AndroidViewModel {
|
|||||||
return apiResponseMutableLiveData;
|
return apiResponseMutableLiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<APIResponse> getMyVideo(String videoId) {
|
public LiveData<APIResponse> getMyVideo(String instance, String videoId) {
|
||||||
apiResponseMutableLiveData = new MutableLiveData<>();
|
apiResponseMutableLiveData = new MutableLiveData<>();
|
||||||
getSingle(videoId, true);
|
getSingle(instance, videoId, true);
|
||||||
return apiResponseMutableLiveData;
|
return apiResponseMutableLiveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,13 +90,18 @@ public class TimelineVM extends AndroidViewModel {
|
|||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getSingle(String videoId, boolean myVideo) {
|
private void getSingle(String instance, String videoId, boolean myVideo) {
|
||||||
Context _mContext = getApplication().getApplicationContext();
|
Context _mContext = getApplication().getApplicationContext();
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
RetrofitPeertubeAPI retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext);
|
RetrofitPeertubeAPI retrofitPeertubeAPI;
|
||||||
|
if( instance == null) {
|
||||||
|
retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext);
|
||||||
|
}else{
|
||||||
|
retrofitPeertubeAPI = new RetrofitPeertubeAPI(_mContext, instance, null);
|
||||||
|
}
|
||||||
APIResponse apiResponse = retrofitPeertubeAPI.getVideos(videoId, myVideo);
|
APIResponse apiResponse = retrofitPeertubeAPI.getVideos(videoId, myVideo);
|
||||||
if (Helper.isLoggedIn(_mContext) && !myVideo) {
|
if (Helper.isLoggedIn(_mContext) && !myVideo && instance == null) {
|
||||||
if (apiResponse.getPeertubes() != null && apiResponse.getPeertubes().size() > 0 && apiResponse.getPeertubes().get(0) != null) {
|
if (apiResponse.getPeertubes() != null && apiResponse.getPeertubes().size() > 0 && apiResponse.getPeertubes().get(0) != null) {
|
||||||
APIResponse response = new RetrofitPeertubeAPI(_mContext).getRating(videoId);
|
APIResponse response = new RetrofitPeertubeAPI(_mContext).getRating(videoId);
|
||||||
if (response != null)
|
if (response != null)
|
||||||
@ -172,6 +177,7 @@ public class TimelineVM extends AndroidViewModel {
|
|||||||
MOST_LIKED,
|
MOST_LIKED,
|
||||||
HISTORY,
|
HISTORY,
|
||||||
RECENT,
|
RECENT,
|
||||||
VIDEOS_IN_PLAYLIST
|
VIDEOS_IN_PLAYLIST,
|
||||||
|
SEPIA_SEARCH
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,84 +14,98 @@
|
|||||||
You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
You should have received a copy of the GNU General Public License along with TubeLab; if not,
|
||||||
see <http://www.gnu.org/licenses>.
|
see <http://www.gnu.org/licenses>.
|
||||||
-->
|
-->
|
||||||
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
|
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:TagsEditText="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginStart="@dimen/fab_margin"
|
android:fitsSystemWindows="true"
|
||||||
android:layout_marginEnd="@dimen/fab_margin"
|
tools:context=".SepiaSearchActivity">
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
xmlns:TagsEditText="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:fitsSystemWindows="true">
|
|
||||||
<ScrollView
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
android:fitsSystemWindows="true"
|
||||||
android:layout_width="match_parent"
|
app:theme="@style/ThemeOverlay.AppCompat.Light">
|
||||||
android:layout_height="wrap_content">
|
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fitsSystemWindows="true"
|
||||||
|
app:contentScrim="?attr/colorPrimary"
|
||||||
|
app:expandedTitleMarginEnd="64dp"
|
||||||
|
app:expandedTitleMarginStart="48dp"
|
||||||
|
android:background="@color/white"
|
||||||
|
app:layout_scrollFlags="scroll|exitUntilCollapsed">
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_marginStart="@dimen/fab_margin"
|
||||||
|
android:layout_marginEnd="@dimen/fab_margin"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content">
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/header"
|
|
||||||
android:animateLayoutChanges="true"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent">
|
|
||||||
<com.mancj.materialsearchbar.MaterialSearchBar
|
|
||||||
style="@style/MaterialSearchBarLight"
|
|
||||||
app:mt_speechMode="false"
|
|
||||||
app:mt_hint="@string/sepia_search_hint"
|
|
||||||
app:mt_maxSuggestionsCount="10"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
android:id="@+id/header"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent">
|
||||||
android:id="@+id/searchBar" />
|
<com.mancj.materialsearchbar.MaterialSearchBar
|
||||||
<TextView
|
style="@style/MaterialSearchBarLight"
|
||||||
android:layout_marginTop="5dp"
|
app:mt_speechMode="false"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/searchBar"
|
app:mt_hint="@string/sepia_search_hint"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:mt_maxSuggestionsCount="10"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
android:textColor="?attr/colorAccent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
android:id="@+id/explanations"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
android:text="@string/sepia_indication"
|
android:animateLayoutChanges="false"
|
||||||
/>
|
android:id="@+id/searchBar" />
|
||||||
<Button
|
<TextView
|
||||||
android:id="@+id/filter"
|
android:layout_marginTop="5dp"
|
||||||
style="@style/Base.Widget.AppCompat.Button.Colored"
|
app:layout_constraintTop_toBottomOf="@+id/searchBar"
|
||||||
android:layout_width="wrap_content"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
android:layout_height="wrap_content"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
android:text="@string/filter"
|
android:layout_width="match_parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/explanations"
|
android:textColor="?attr/colorAccent"
|
||||||
android:drawableEnd="@drawable/ic_baseline_arrow_drop_down_24"
|
android:id="@+id/explanations"
|
||||||
/>
|
android:text="@string/sepia_indication"
|
||||||
|
/>
|
||||||
<TextView
|
<Button
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/filter"
|
||||||
android:layout_height="wrap_content"
|
style="@style/Base.Widget.AppCompat.Button.Colored"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
android:layout_width="wrap_content"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/explanations"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/sort_by"
|
android:text="@string/filter"
|
||||||
android:text="@string/sort_by"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
android:labelFor="@+id/sort_by"/>
|
app:layout_constraintTop_toBottomOf="@+id/explanations"
|
||||||
<Spinner
|
android:drawableEnd="@drawable/ic_baseline_arrow_drop_down_24"
|
||||||
android:id="@+id/sort_by"
|
/>
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/explanations"
|
|
||||||
/>
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/explanations"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/sort_by"
|
||||||
|
android:text="@string/sort_by"
|
||||||
|
android:labelFor="@+id/sort_by"/>
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/sort_by"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/explanations"
|
||||||
|
/>
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/filter_elements"
|
android:id="@+id/filter_elements"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:animateLayoutChanges="true"
|
android:animateLayoutChanges="true"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/filter"
|
app:layout_constraintTop_toBottomOf="@+id/header"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent">
|
app:layout_constraintEnd_toEndOf="parent">
|
||||||
|
|
||||||
@ -341,21 +355,17 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
</com.google.android.material.appbar.CollapsingToolbarLayout>
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
<fragment
|
<FrameLayout
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
android:layout_marginStart="@dimen/fab_margin"
|
||||||
android:id="@+id/nav_host_fragment"
|
android:layout_marginEnd="@dimen/fab_margin"
|
||||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/container"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="match_parent"
|
||||||
app:defaultNavHost="true"
|
android:layout_height="match_parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/header"
|
android:layout_marginBottom="?attr/actionBarSize"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
/>
|
||||||
app:layout_constraintEnd_toEndOf="parent"/>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
</ScrollView>
|
|
||||||
|
|
||||||
</androidx.drawerlayout.widget.DrawerLayout>
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user