- loing WIP

This commit is contained in:
Stefan Schueller 2018-12-02 14:27:00 +01:00
parent c0dd67167a
commit 914c247463
5 changed files with 51 additions and 8 deletions

View File

@ -30,7 +30,8 @@
<activity <activity
android:name=".activity.SearchActivity" android:name=".activity.SearchActivity"
android:label="@string/title_activity_search" android:label="@string/title_activity_search"
android:launchMode="singleTop"> android:launchMode="singleTop"
android:parentActivityName=".activity.VideoListActivity">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.SEARCH" /> <action android:name="android.intent.action.SEARCH" />
</intent-filter> </intent-filter>

View File

@ -11,7 +11,10 @@ import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.util.Log; import android.util.Log;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@ -43,6 +46,9 @@ public class SearchActivity extends AppCompatActivity {
private boolean isLoading = false; private boolean isLoading = false;
private TextView emptyView;
private RecyclerView recyclerView;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -53,6 +59,11 @@ public class SearchActivity extends AppCompatActivity {
// do search // do search
handleIntent(intent); handleIntent(intent);
// toolbar
Toolbar toolbar = findViewById(R.id.tool_bar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// handle search suggestions // handle search suggestions
if (Intent.ACTION_SEARCH.equals(intent.getAction())) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
String query = intent.getStringExtra(SearchManager.QUERY); String query = intent.getStringExtra(SearchManager.QUERY);
@ -66,9 +77,11 @@ public class SearchActivity extends AppCompatActivity {
} }
private void createList(String query) { private void createList(String query) {
RecyclerView recyclerView = findViewById(R.id.recyclerView); recyclerView = findViewById(R.id.recyclerView);
swipeRefreshLayout = findViewById(R.id.swipeRefreshLayout); swipeRefreshLayout = findViewById(R.id.swipeRefreshLayout);
emptyView = findViewById(R.id.empty_view);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(SearchActivity.this); RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(SearchActivity.this);
recyclerView.setLayoutManager(layoutManager); recyclerView.setLayoutManager(layoutManager);
@ -123,10 +136,6 @@ public class SearchActivity extends AppCompatActivity {
Call<VideoList> call = service.searchVideosData(start, count, sort, nsfw, search); Call<VideoList> 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<VideoList>() { call.enqueue(new Callback<VideoList>() {
@Override @Override
public void onResponse(@NonNull Call<VideoList> call, @NonNull Response<VideoList> response) { public void onResponse(@NonNull Call<VideoList> call, @NonNull Response<VideoList> response) {
@ -138,6 +147,20 @@ public class SearchActivity extends AppCompatActivity {
if (response.body() != null) { if (response.body() != null) {
videoAdapter.setData(response.body().getVideoArrayList()); 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; isLoading = false;
swipeRefreshLayout.setRefreshing(false); swipeRefreshLayout.setRefreshing(false);
} }

View File

@ -7,6 +7,7 @@ import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.design.bottomnavigation.LabelVisibilityMode;
import android.support.v4.app.ActivityCompat; import android.support.v4.app.ActivityCompat;
import android.support.v4.widget.SwipeRefreshLayout; import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
@ -124,7 +125,7 @@ public class VideoListActivity extends AppCompatActivity {
BottomNavigationViewEx navigation = findViewById(R.id.navigation); BottomNavigationViewEx navigation = findViewById(R.id.navigation);
navigation.enableAnimation(false); navigation.enableAnimation(false);
navigation.setLabelVisibilityMode(1); // enableShiftingMode navigation.setLabelVisibilityMode(LabelVisibilityMode.LABEL_VISIBILITY_LABELED); // enableShiftingMode
navigation.setItemHorizontalTranslationEnabled(false); // enableItemShiftingMode navigation.setItemHorizontalTranslationEnabled(false); // enableItemShiftingMode
Menu navMenu = navigation.getMenu(); Menu navMenu = navigation.getMenu();

View File

@ -13,6 +13,15 @@
android:orientation="vertical" android:orientation="vertical"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tool_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
android:elevation="4dp" />
</android.support.design.widget.AppBarLayout> </android.support.design.widget.AppBarLayout>
<android.support.v4.widget.SwipeRefreshLayout <android.support.v4.widget.SwipeRefreshLayout
@ -28,9 +37,17 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
> >
</android.support.v7.widget.RecyclerView> </android.support.v7.widget.RecyclerView>
<TextView
android:id="@+id/empty_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:visibility="gone"
android:textColor="@color/black"
android:text="@string/no_data_available" />
</android.support.v4.widget.SwipeRefreshLayout> </android.support.v4.widget.SwipeRefreshLayout>
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>

View File

@ -55,5 +55,6 @@
<string name="pref_title_version">Version</string> <string name="pref_title_version">Version</string>
<string name="search_hint">Search PeerTube</string> <string name="search_hint">Search PeerTube</string>
<string name="title_activity_search">Search</string> <string name="title_activity_search">Search</string>
<string name="no_data_available">No Results</string>
</resources> </resources>