Also hide the coloured bar below the category spinner.
In addition, added a @Nullable constraint on the categorySpinner and a null guard when resuming the fragment to handle possible null cases (though I don't think there will be any).
This commit is contained in:
parent
58205fefec
commit
35f73f3786
@ -4,27 +4,35 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<Spinner
|
<RelativeLayout
|
||||||
android:id="@+id/category_spinner"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="48dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="8dp"
|
android:id="@+id/category_wrapper"
|
||||||
android:layout_marginRight="8dp"
|
android:layout_alignParentTop="true">
|
||||||
android:paddingBottom="1dp" />
|
|
||||||
|
|
||||||
<View
|
<Spinner
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/category_spinner"
|
||||||
android:layout_height="2dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_alignBottom="@id/category_spinner"
|
android:layout_height="48dp"
|
||||||
android:background="@color/fdroid_green" />
|
android:layout_marginLeft="8dp"
|
||||||
|
android:layout_marginRight="8dp"
|
||||||
|
android:paddingBottom="1dp" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="2dp"
|
||||||
|
android:layout_alignBottom="@id/category_spinner"
|
||||||
|
android:background="@color/fdroid_green" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<ListView
|
<ListView
|
||||||
style="@style/AppList"
|
style="@style/AppList"
|
||||||
android:layout_below="@id/category_spinner" />
|
android:layout_below="@id/category_wrapper" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
style="@style/AppListEmptyText"
|
style="@style/AppListEmptyText"
|
||||||
android:layout_below="@id/category_spinner"
|
android:layout_below="@id/category_wrapper"
|
||||||
android:text="@string/empty_available_app_list" />
|
android:text="@string/empty_available_app_list" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
@ -8,6 +8,7 @@ import android.database.ContentObserver;
|
|||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.LoaderManager;
|
import android.support.v4.app.LoaderManager;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -37,6 +38,11 @@ public class AvailableAppsFragment extends AppListFragment implements
|
|||||||
private static String defaultCategory;
|
private static String defaultCategory;
|
||||||
|
|
||||||
private List<String> categories;
|
private List<String> categories;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private View categoryWrapper;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
private Spinner categorySpinner;
|
private Spinner categorySpinner;
|
||||||
private String currentCategory;
|
private String currentCategory;
|
||||||
private AppListAdapter adapter;
|
private AppListAdapter adapter;
|
||||||
@ -147,6 +153,7 @@ public class AvailableAppsFragment extends AppListFragment implements
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.available_app_list, container, false);
|
View view = inflater.inflate(R.layout.available_app_list, container, false);
|
||||||
|
|
||||||
|
categoryWrapper = view.findViewById(R.id.category_wrapper);
|
||||||
setupCategorySpinner((Spinner) view.findViewById(R.id.category_spinner));
|
setupCategorySpinner((Spinner) view.findViewById(R.id.category_spinner));
|
||||||
defaultCategory = AppProvider.Helper.getCategoryWhatsNew(getActivity());
|
defaultCategory = AppProvider.Helper.getCategoryWhatsNew(getActivity());
|
||||||
|
|
||||||
@ -180,15 +187,18 @@ public class AvailableAppsFragment extends AppListFragment implements
|
|||||||
super.onResume();
|
super.onResume();
|
||||||
/* restore the saved Category Spinner position */
|
/* restore the saved Category Spinner position */
|
||||||
Activity activity = getActivity();
|
Activity activity = getActivity();
|
||||||
SharedPreferences p = activity.getSharedPreferences(PREFERENCES_FILE,
|
SharedPreferences p = activity.getSharedPreferences(PREFERENCES_FILE, Context.MODE_PRIVATE);
|
||||||
Context.MODE_PRIVATE);
|
|
||||||
currentCategory = p.getString(CATEGORY_KEY, defaultCategory);
|
currentCategory = p.getString(CATEGORY_KEY, defaultCategory);
|
||||||
for (int i = 0; i < categorySpinner.getCount(); i++) {
|
|
||||||
if (currentCategory.equals(categorySpinner.getItemAtPosition(i).toString())) {
|
if (categorySpinner != null) {
|
||||||
categorySpinner.setSelection(i);
|
for (int i = 0; i < categorySpinner.getCount(); i++) {
|
||||||
break;
|
if (currentCategory.equals(categorySpinner.getItemAtPosition(i).toString())) {
|
||||||
|
categorySpinner.setSelection(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setCurrentCategory(currentCategory);
|
setCurrentCategory(currentCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,15 +215,15 @@ public class AvailableAppsFragment extends AppListFragment implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSearch() {
|
protected void onSearch() {
|
||||||
if (categorySpinner != null) {
|
if (categoryWrapper != null) {
|
||||||
categorySpinner.setVisibility(View.GONE);
|
categoryWrapper.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSearchStopped() {
|
protected void onSearchStopped() {
|
||||||
if (categorySpinner != null) {
|
if (categoryWrapper != null) {
|
||||||
categorySpinner.setVisibility(View.VISIBLE);
|
categoryWrapper.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user