- 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
android:name=".activity.SearchActivity"
android:label="@string/title_activity_search"
android:launchMode="singleTop">
android:launchMode="singleTop"
android:parentActivityName=".activity.VideoListActivity">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>

View File

@ -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<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>() {
@Override
public void onResponse(@NonNull Call<VideoList> call, @NonNull Response<VideoList> 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);
}

View File

@ -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();

View File

@ -13,6 +13,15 @@
android:orientation="vertical"
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.v4.widget.SwipeRefreshLayout
@ -28,9 +37,17 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
>
</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.constraint.ConstraintLayout>

View File

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