From 914c247463506394d6e66103054ec393d0ae32d0 Mon Sep 17 00:00:00 2001 From: Stefan Schueller Date: Sun, 2 Dec 2018 14:27:00 +0100 Subject: [PATCH] - loing WIP --- app/src/main/AndroidManifest.xml | 3 +- .../peertube/activity/SearchActivity.java | 33 ++++++++++++++++--- .../peertube/activity/VideoListActivity.java | 3 +- app/src/main/res/layout/activity_search.xml | 19 ++++++++++- app/src/main/res/values/strings.xml | 1 + 5 files changed, 51 insertions(+), 8 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 80cd260..5ef9e6b 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -30,7 +30,8 @@ + android:launchMode="singleTop" + android:parentActivityName=".activity.VideoListActivity"> diff --git a/app/src/main/java/net/schueller/peertube/activity/SearchActivity.java b/app/src/main/java/net/schueller/peertube/activity/SearchActivity.java index 976d00f..2456599 100644 --- a/app/src/main/java/net/schueller/peertube/activity/SearchActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/SearchActivity.java @@ -11,7 +11,10 @@ import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.Toolbar; import android.util.Log; +import android.view.View; +import android.widget.TextView; import android.widget.Toast; @@ -43,6 +46,9 @@ public class SearchActivity extends AppCompatActivity { private boolean isLoading = false; + private TextView emptyView; + private RecyclerView recyclerView; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -53,6 +59,11 @@ public class SearchActivity extends AppCompatActivity { // do search handleIntent(intent); + // toolbar + Toolbar toolbar = findViewById(R.id.tool_bar); + setSupportActionBar(toolbar); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + // handle search suggestions if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); @@ -66,9 +77,11 @@ public class SearchActivity extends AppCompatActivity { } private void createList(String query) { - RecyclerView recyclerView = findViewById(R.id.recyclerView); + recyclerView = findViewById(R.id.recyclerView); swipeRefreshLayout = findViewById(R.id.swipeRefreshLayout); + emptyView = findViewById(R.id.empty_view); + RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(SearchActivity.this); recyclerView.setLayoutManager(layoutManager); @@ -123,10 +136,6 @@ public class SearchActivity extends AppCompatActivity { Call call = service.searchVideosData(start, count, sort, nsfw, search); - /*Log the URL called*/ - Log.d("URL Called", call.request().url() + ""); -// Toast.makeText(VideoListActivity.this, "URL Called: " + call.request().url(), Toast.LENGTH_SHORT).show(); - call.enqueue(new Callback() { @Override public void onResponse(@NonNull Call call, @NonNull Response response) { @@ -138,6 +147,20 @@ public class SearchActivity extends AppCompatActivity { if (response.body() != null) { videoAdapter.setData(response.body().getVideoArrayList()); } + + Log.d("SearchActivity", "getItemCount: " + videoAdapter.getItemCount()); + Log.d("SearchActivity", "response: " + response.body()); + + // no results show no results message + if (response.body() == null && videoAdapter.getItemCount() == 0) { + emptyView.setVisibility(View.VISIBLE); + recyclerView.setVisibility(View.GONE); + + } else { + emptyView.setVisibility(View.GONE); + recyclerView.setVisibility(View.VISIBLE); + } + isLoading = false; swipeRefreshLayout.setRefreshing(false); } diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java index 31a09c1..8135f6e 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoListActivity.java @@ -7,6 +7,7 @@ import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.preference.PreferenceManager; import android.support.annotation.NonNull; +import android.support.design.bottomnavigation.LabelVisibilityMode; import android.support.v4.app.ActivityCompat; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.app.AppCompatActivity; @@ -124,7 +125,7 @@ public class VideoListActivity extends AppCompatActivity { BottomNavigationViewEx navigation = findViewById(R.id.navigation); navigation.enableAnimation(false); - navigation.setLabelVisibilityMode(1); // enableShiftingMode + navigation.setLabelVisibilityMode(LabelVisibilityMode.LABEL_VISIBILITY_LABELED); // enableShiftingMode navigation.setItemHorizontalTranslationEnabled(false); // enableItemShiftingMode Menu navMenu = navigation.getMenu(); diff --git a/app/src/main/res/layout/activity_search.xml b/app/src/main/res/layout/activity_search.xml index 66a4a72..19a336b 100644 --- a/app/src/main/res/layout/activity_search.xml +++ b/app/src/main/res/layout/activity_search.xml @@ -13,6 +13,15 @@ android:orientation="vertical" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> + + - + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 92814a4..c4ee486 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -55,5 +55,6 @@ Version Search PeerTube Search + No Results