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 HistoryRecyclerViewAdapter historyRecyclerViewAdapter;
|
||||
private BottomSheetDialog bottomSheet;
|
||||
private Handler uiHandler;
|
||||
|
||||
private ArrayList<Video> historyObjects;
|
||||
private static final String TAG = "HistoryFragment";
|
||||
|
|
@ -87,6 +88,7 @@ public class HistoryFragment extends Fragment implements HistoryRecyclerViewAdap
|
|||
linearLayout = fragmentView.findViewById(R.id.historylinearLayout1);
|
||||
shimmerCards = fragmentView.findViewById(R.id.shimmer_history_framelayout);
|
||||
topAppBar = fragmentView.findViewById(R.id.history_toolbar);
|
||||
uiHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
dbManager = new DBManager(context);
|
||||
historyObjects = new ArrayList<>();
|
||||
|
|
@ -110,9 +112,7 @@ public class HistoryFragment extends Fragment implements HistoryRecyclerViewAdap
|
|||
linearLayout.removeAllViews();
|
||||
try{
|
||||
Thread thread = new Thread(() -> {
|
||||
Handler uiHandler = new Handler(Looper.getMainLooper());
|
||||
historyObjects = dbManager.getHistory("");
|
||||
|
||||
uiHandler.post(() -> {
|
||||
historyRecyclerViewAdapter.setVideoList(historyObjects);
|
||||
shimmerCards.stopShimmer();
|
||||
|
|
@ -120,11 +120,7 @@ public class HistoryFragment extends Fragment implements HistoryRecyclerViewAdap
|
|||
});
|
||||
|
||||
if(historyObjects.size() == 0){
|
||||
uiHandler.post(() -> {
|
||||
RelativeLayout no_results = new RelativeLayout(context);
|
||||
layoutinflater.inflate(R.layout.history_no_results, no_results);
|
||||
linearLayout.addView(no_results);
|
||||
});
|
||||
uiHandler.post(this::addNoResultsView);
|
||||
}
|
||||
});
|
||||
thread.start();
|
||||
|
|
@ -254,6 +250,10 @@ public class HistoryFragment extends Fragment implements HistoryRecyclerViewAdap
|
|||
historyRecyclerViewAdapter.notifyItemRemoved(position);
|
||||
historyRecyclerViewAdapter.notifyItemRangeChanged(position, historyObjects.size());
|
||||
dbManager.clearHistoryItem(v);
|
||||
|
||||
if(historyObjects.size() == 0){
|
||||
uiHandler.post(this::addNoResultsView);
|
||||
}
|
||||
});
|
||||
delete_dialog.show();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,16 +16,19 @@ import android.os.Looper;
|
|||
import android.text.InputType;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.view.menu.MenuBuilder;
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
|
|
@ -205,14 +208,17 @@ public class HomeFragment extends Fragment implements HomeRecyclerViewAdapter.On
|
|||
MenuItem.OnActionExpandListener onActionExpandListener = new MenuItem.OnActionExpandListener() {
|
||||
@Override
|
||||
public boolean onMenuItemActionExpand(MenuItem menuItem) {
|
||||
scrollView.setVisibility(View.GONE);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemActionCollapse(MenuItem menuItem) {
|
||||
scrollView.setVisibility(View.VISIBLE);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
topAppBar.getMenu().findItem(R.id.search).setOnActionExpandListener(onActionExpandListener);
|
||||
SearchView searchView = (SearchView) topAppBar.getMenu().findItem(R.id.search).getActionView();
|
||||
searchView.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ public class DBManager extends SQLiteOpenHelper {
|
|||
public ArrayList<Video> getHistory(String query){
|
||||
SQLiteDatabase db = this.getReadableDatabase();
|
||||
Cursor cursor = db.rawQuery("SELECT * FROM " + history_table_name
|
||||
+ " WHERE title LIKE '%"+query+"%'",
|
||||
+ " WHERE title LIKE '%"+query+"%' ORDER BY id DESC",
|
||||
null);
|
||||
ArrayList<Video> list = new ArrayList<>();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<vector android:height="24dp"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
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>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<vector android:height="24dp"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
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>
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
android:id="@+id/historylinearLayout1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_gravity="center"
|
||||
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" />
|
||||
|
||||
|
|
@ -99,6 +100,7 @@
|
|||
app:layout_scrollFlags="scroll|enterAlways|snap"
|
||||
app:title="@string/history"
|
||||
app:menu="@menu/history_menu"
|
||||
android:theme="@style/Toolbar"
|
||||
/>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@
|
|||
app:layout_scrollFlags="scroll|enterAlways|snap"
|
||||
app:title="@string/app_name"
|
||||
app:menu="@menu/main_menu"
|
||||
android:theme="@style/Toolbar"
|
||||
/>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
|
|
|||
|
|
@ -5,11 +5,15 @@
|
|||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="100dp"
|
||||
android:layout_marginTop="200dp"
|
||||
android:layout_marginEnd="100dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_marginBottom="200dp"
|
||||
android:gravity="center"
|
||||
android:layout_margin="100dp"
|
||||
android:orientation="vertical"
|
||||
tools:ignore="MissingConstraints">
|
||||
|
||||
<ImageView
|
||||
|
|
@ -21,11 +25,10 @@
|
|||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/no_results"
|
||||
android:textAlignment="center"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold"
|
||||
android:text="@string/no_results"
|
||||
/>
|
||||
android:textStyle="bold" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
android:id="@+id/search"
|
||||
android:title="@string/search"
|
||||
android:icon="@drawable/ic_search"
|
||||
app:showAsAction="collapseActionView|always"
|
||||
app:showAsAction="always|collapseActionView"
|
||||
app:actionViewClass="androidx.appcompat.widget.SearchView"/>
|
||||
|
||||
<item
|
||||
|
|
|
|||
|
|
@ -7,4 +7,13 @@
|
|||
<item name="android:color">@android:color/transparent</item>
|
||||
</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>
|
||||
|
|
|
|||
Loading…
Reference in a new issue