small fixes
ordered history items in descending order changed menu item colors
This commit is contained in:
parent
8c3525c1d5
commit
e3f9e4bfb4
10 changed files with 39 additions and 18 deletions
|
|
@ -55,6 +55,7 @@ public class HistoryFragment extends Fragment implements HistoryRecyclerViewAdap
|
||||||
private RecyclerView recyclerView;
|
private RecyclerView recyclerView;
|
||||||
private HistoryRecyclerViewAdapter historyRecyclerViewAdapter;
|
private HistoryRecyclerViewAdapter historyRecyclerViewAdapter;
|
||||||
private BottomSheetDialog bottomSheet;
|
private BottomSheetDialog bottomSheet;
|
||||||
|
private Handler uiHandler;
|
||||||
|
|
||||||
private ArrayList<Video> historyObjects;
|
private ArrayList<Video> historyObjects;
|
||||||
private static final String TAG = "HistoryFragment";
|
private static final String TAG = "HistoryFragment";
|
||||||
|
|
@ -87,6 +88,7 @@ public class HistoryFragment extends Fragment implements HistoryRecyclerViewAdap
|
||||||
linearLayout = fragmentView.findViewById(R.id.historylinearLayout1);
|
linearLayout = fragmentView.findViewById(R.id.historylinearLayout1);
|
||||||
shimmerCards = fragmentView.findViewById(R.id.shimmer_history_framelayout);
|
shimmerCards = fragmentView.findViewById(R.id.shimmer_history_framelayout);
|
||||||
topAppBar = fragmentView.findViewById(R.id.history_toolbar);
|
topAppBar = fragmentView.findViewById(R.id.history_toolbar);
|
||||||
|
uiHandler = new Handler(Looper.getMainLooper());
|
||||||
|
|
||||||
dbManager = new DBManager(context);
|
dbManager = new DBManager(context);
|
||||||
historyObjects = new ArrayList<>();
|
historyObjects = new ArrayList<>();
|
||||||
|
|
@ -110,9 +112,7 @@ public class HistoryFragment extends Fragment implements HistoryRecyclerViewAdap
|
||||||
linearLayout.removeAllViews();
|
linearLayout.removeAllViews();
|
||||||
try{
|
try{
|
||||||
Thread thread = new Thread(() -> {
|
Thread thread = new Thread(() -> {
|
||||||
Handler uiHandler = new Handler(Looper.getMainLooper());
|
|
||||||
historyObjects = dbManager.getHistory("");
|
historyObjects = dbManager.getHistory("");
|
||||||
|
|
||||||
uiHandler.post(() -> {
|
uiHandler.post(() -> {
|
||||||
historyRecyclerViewAdapter.setVideoList(historyObjects);
|
historyRecyclerViewAdapter.setVideoList(historyObjects);
|
||||||
shimmerCards.stopShimmer();
|
shimmerCards.stopShimmer();
|
||||||
|
|
@ -120,11 +120,7 @@ public class HistoryFragment extends Fragment implements HistoryRecyclerViewAdap
|
||||||
});
|
});
|
||||||
|
|
||||||
if(historyObjects.size() == 0){
|
if(historyObjects.size() == 0){
|
||||||
uiHandler.post(() -> {
|
uiHandler.post(this::addNoResultsView);
|
||||||
RelativeLayout no_results = new RelativeLayout(context);
|
|
||||||
layoutinflater.inflate(R.layout.history_no_results, no_results);
|
|
||||||
linearLayout.addView(no_results);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
thread.start();
|
thread.start();
|
||||||
|
|
@ -254,6 +250,10 @@ public class HistoryFragment extends Fragment implements HistoryRecyclerViewAdap
|
||||||
historyRecyclerViewAdapter.notifyItemRemoved(position);
|
historyRecyclerViewAdapter.notifyItemRemoved(position);
|
||||||
historyRecyclerViewAdapter.notifyItemRangeChanged(position, historyObjects.size());
|
historyRecyclerViewAdapter.notifyItemRangeChanged(position, historyObjects.size());
|
||||||
dbManager.clearHistoryItem(v);
|
dbManager.clearHistoryItem(v);
|
||||||
|
|
||||||
|
if(historyObjects.size() == 0){
|
||||||
|
uiHandler.post(this::addNoResultsView);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
delete_dialog.show();
|
delete_dialog.show();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,16 +16,19 @@ import android.os.Looper;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.view.menu.MenuBuilder;
|
||||||
import androidx.appcompat.widget.SearchView;
|
import androidx.appcompat.widget.SearchView;
|
||||||
import androidx.cardview.widget.CardView;
|
import androidx.cardview.widget.CardView;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
|
|
@ -205,14 +208,17 @@ public class HomeFragment extends Fragment implements HomeRecyclerViewAdapter.On
|
||||||
MenuItem.OnActionExpandListener onActionExpandListener = new MenuItem.OnActionExpandListener() {
|
MenuItem.OnActionExpandListener onActionExpandListener = new MenuItem.OnActionExpandListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemActionExpand(MenuItem menuItem) {
|
public boolean onMenuItemActionExpand(MenuItem menuItem) {
|
||||||
|
scrollView.setVisibility(View.GONE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemActionCollapse(MenuItem menuItem) {
|
public boolean onMenuItemActionCollapse(MenuItem menuItem) {
|
||||||
|
scrollView.setVisibility(View.VISIBLE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
topAppBar.getMenu().findItem(R.id.search).setOnActionExpandListener(onActionExpandListener);
|
topAppBar.getMenu().findItem(R.id.search).setOnActionExpandListener(onActionExpandListener);
|
||||||
SearchView searchView = (SearchView) topAppBar.getMenu().findItem(R.id.search).getActionView();
|
SearchView searchView = (SearchView) topAppBar.getMenu().findItem(R.id.search).getActionView();
|
||||||
searchView.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
|
searchView.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ public class DBManager extends SQLiteOpenHelper {
|
||||||
public ArrayList<Video> getHistory(String query){
|
public ArrayList<Video> getHistory(String query){
|
||||||
SQLiteDatabase db = this.getReadableDatabase();
|
SQLiteDatabase db = this.getReadableDatabase();
|
||||||
Cursor cursor = db.rawQuery("SELECT * FROM " + history_table_name
|
Cursor cursor = db.rawQuery("SELECT * FROM " + history_table_name
|
||||||
+ " WHERE title LIKE '%"+query+"%'",
|
+ " WHERE title LIKE '%"+query+"%' ORDER BY id DESC",
|
||||||
null);
|
null);
|
||||||
ArrayList<Video> list = new ArrayList<>();
|
ArrayList<Video> list = new ArrayList<>();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<vector android:height="24dp"
|
<vector android:height="24dp"
|
||||||
android:viewportHeight="24" android:viewportWidth="24"
|
android:viewportHeight="24" android:viewportWidth="24"
|
||||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<path android:fillColor="?android:colorPrimary" android:pathData="M17.65,6.35C16.2,4.9 14.21,4 12,4c-4.42,0 -7.99,3.58 -7.99,8s3.57,8 7.99,8c3.73,0 6.84,-2.55 7.73,-6h-2.08c-0.82,2.33 -3.04,4 -5.65,4 -3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6c1.66,0 3.14,0.69 4.22,1.78L13,11h7V4l-2.35,2.35z"/>
|
<path android:fillColor="?android:textColorPrimary" android:pathData="M17.65,6.35C16.2,4.9 14.21,4 12,4c-4.42,0 -7.99,3.58 -7.99,8s3.57,8 7.99,8c3.73,0 6.84,-2.55 7.73,-6h-2.08c-0.82,2.33 -3.04,4 -5.65,4 -3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6c1.66,0 3.14,0.69 4.22,1.78L13,11h7V4l-2.35,2.35z"/>
|
||||||
</vector>
|
</vector>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<vector android:height="24dp"
|
<vector android:height="24dp"
|
||||||
android:viewportHeight="24" android:viewportWidth="24"
|
android:viewportHeight="24" android:viewportWidth="24"
|
||||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<path android:fillColor="?android:colorPrimary" android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z"/>
|
<path android:fillColor="?android:textColorPrimary" android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z"/>
|
||||||
</vector>
|
</vector>
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
android:id="@+id/historylinearLayout1"
|
android:id="@+id/historylinearLayout1"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
|
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical" />
|
android:orientation="vertical" />
|
||||||
|
|
||||||
|
|
@ -99,6 +100,7 @@
|
||||||
app:layout_scrollFlags="scroll|enterAlways|snap"
|
app:layout_scrollFlags="scroll|enterAlways|snap"
|
||||||
app:title="@string/history"
|
app:title="@string/history"
|
||||||
app:menu="@menu/history_menu"
|
app:menu="@menu/history_menu"
|
||||||
|
android:theme="@style/Toolbar"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,7 @@
|
||||||
app:layout_scrollFlags="scroll|enterAlways|snap"
|
app:layout_scrollFlags="scroll|enterAlways|snap"
|
||||||
app:title="@string/app_name"
|
app:title="@string/app_name"
|
||||||
app:menu="@menu/main_menu"
|
app:menu="@menu/main_menu"
|
||||||
|
android:theme="@style/Toolbar"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,15 @@
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:layout_marginStart="100dp"
|
||||||
|
android:layout_marginTop="200dp"
|
||||||
|
android:layout_marginEnd="100dp"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:layout_marginBottom="200dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:layout_margin="100dp"
|
android:orientation="vertical"
|
||||||
tools:ignore="MissingConstraints">
|
tools:ignore="MissingConstraints">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
|
@ -21,11 +25,10 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/no_results"
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold" />
|
||||||
android:text="@string/no_results"
|
|
||||||
/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
android:id="@+id/search"
|
android:id="@+id/search"
|
||||||
android:title="@string/search"
|
android:title="@string/search"
|
||||||
android:icon="@drawable/ic_search"
|
android:icon="@drawable/ic_search"
|
||||||
app:showAsAction="collapseActionView|always"
|
app:showAsAction="always|collapseActionView"
|
||||||
app:actionViewClass="androidx.appcompat.widget.SearchView"/>
|
app:actionViewClass="androidx.appcompat.widget.SearchView"/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
|
|
|
||||||
|
|
@ -7,4 +7,13 @@
|
||||||
<item name="android:color">@android:color/transparent</item>
|
<item name="android:color">@android:color/transparent</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="Toolbar" parent="Theme.Material3.DayNight.NoActionBar">
|
||||||
|
<item name="searchViewStyle">@style/searchStyle</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style name="searchStyle" parent="Widget.AppCompat.SearchView.ActionBar">
|
||||||
|
<item name="android:queryHint">@string/search</item>
|
||||||
|
<item name="android:searchIcon">@null</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue