mirror of
https://github.com/whyorean/AuroraStore.git
synced 2026-06-19 13:08:59 -04:00
Add Recent Search [2/2]
This commit is contained in:
@@ -19,6 +19,7 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
@@ -38,12 +39,16 @@ public class SearchFragment extends Fragment implements RecyclerItemTouchHelper.
|
||||
ArrayList<String> listHistory = new ArrayList<>();
|
||||
Set<String> setHistory = new HashSet<>();
|
||||
RecyclerView recyclerView;
|
||||
TextView emptyView;
|
||||
View view;
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
view = inflater.inflate(R.layout.fragment_search, container, false);
|
||||
searchToolbar = view.findViewById(R.id.search_apps);
|
||||
recyclerView = view.findViewById(R.id.searchHistory);
|
||||
emptyView = view.findViewById(R.id.emptyView);
|
||||
|
||||
RelativeLayout search_layout = view.findViewById(R.id.search_layout);
|
||||
search_layout.setOnClickListener(v -> {
|
||||
searchToolbar.setFocusable(true);
|
||||
@@ -52,8 +57,6 @@ public class SearchFragment extends Fragment implements RecyclerItemTouchHelper.
|
||||
searchToolbar.setQuery("", false);
|
||||
});
|
||||
addQueryTextListener(searchToolbar);
|
||||
recyclerView = view.findViewById(R.id.searchHistory);
|
||||
setupSearchHistory();
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -131,8 +134,10 @@ public class SearchFragment extends Fragment implements RecyclerItemTouchHelper.
|
||||
|
||||
if (listHistory.isEmpty()) {
|
||||
recyclerView.setVisibility(View.GONE);
|
||||
emptyView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
recyclerView.setVisibility(View.VISIBLE);
|
||||
emptyView.setVisibility(View.GONE);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
recyclerView.setItemAnimator(new DefaultItemAnimator());
|
||||
recyclerView.setAdapter(new SearchHistoryAdapter(listHistory));
|
||||
@@ -142,7 +147,6 @@ public class SearchFragment extends Fragment implements RecyclerItemTouchHelper.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void updateHistory() {
|
||||
setHistory.clear();
|
||||
setHistory.addAll(listHistory);
|
||||
|
||||
@@ -60,7 +60,6 @@ public abstract class UtilFragment extends Fragment {
|
||||
RefreshTokenTask task = new RefreshTokenTask();
|
||||
task.setCaller(playStoreTask);
|
||||
task.setContext(this.getActivity());
|
||||
task.prepareDialog(R.string.dialog_refresh_token_msg, R.string.dialog_refresh_token_title);
|
||||
task.execute();
|
||||
}
|
||||
|
||||
@@ -164,7 +163,6 @@ public abstract class UtilFragment extends Fragment {
|
||||
protected void onPostExecute(Void result) {
|
||||
InstalledAppsFragment.newInstance();
|
||||
UpdatableAppsFragment.newInstance();
|
||||
progressDialog.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="@dimen/appbar_bar_height"
|
||||
android:orientation="vertical"
|
||||
tools:context=".fragment.SearchFragment">
|
||||
|
||||
@@ -73,5 +74,17 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:nestedScrollingEnabled="false" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/emptyView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="96dp"
|
||||
android:layout_gravity="center"
|
||||
android:fontFamily="@font/google_sans_bold"
|
||||
android:gravity="center"
|
||||
android:padding="10dp"
|
||||
android:text="@string/list_empty_query"
|
||||
android:textSize="18sp"
|
||||
android:visibility="gone" />
|
||||
</android.support.v7.widget.CardView>
|
||||
</LinearLayout>
|
||||
@@ -11,6 +11,7 @@
|
||||
<string name="list_line_2_updatable">"Updated on %1$s"</string>
|
||||
<string name="list_empty_updates">No apps need to be updated</string>
|
||||
<string name="list_empty_search">No apps found</string>
|
||||
<string name="list_empty_query">No recent searches</string>
|
||||
<string name="list_incompatible">incompatible</string>
|
||||
<string name="list_check_updates">Check update</string>
|
||||
<string name="list_update_all">Update All</string>
|
||||
|
||||
Reference in New Issue
Block a user