diff --git a/app/src/main/java/com/javiersantos/mlmanager/activities/MainActivity.java b/app/src/main/java/com/javiersantos/mlmanager/activities/MainActivity.java index c08ff79..5abf0ba 100644 --- a/app/src/main/java/com/javiersantos/mlmanager/activities/MainActivity.java +++ b/app/src/main/java/com/javiersantos/mlmanager/activities/MainActivity.java @@ -74,8 +74,8 @@ public class MainActivity extends AppCompatActivity implements SearchView.OnQuer private Drawer drawer; private MenuItem searchItem; private SearchView searchView; - private static VerticalRecyclerViewFastScroller fastScroller; - private static LinearLayout noResults; + private VerticalRecyclerViewFastScroller fastScroller; + private LinearLayout noResults; @Override protected void onCreate(Bundle savedInstanceState) { @@ -127,7 +127,7 @@ private void setInitialConfiguration() { } } - class getInstalledApps extends AsyncTask { + class getInstalledApps extends AsyncTask implements AppAdapter.ResultsMessageListener { private Integer totalApps; private Integer actualApps; @@ -247,9 +247,13 @@ protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); appAdapter = new AppAdapter(appList, context); + appAdapter.setResultsMessageListener(this); appSystemAdapter = new AppAdapter(appSystemList, context); + appSystemAdapter.setResultsMessageListener(this); appFavoriteAdapter = new AppAdapter(getFavoriteList(appList, appSystemList), context); + appFavoriteAdapter.setResultsMessageListener(this); appHiddenAdapter = new AppAdapter(appHiddenList, context); + appHiddenAdapter.setResultsMessageListener(this); fastScroller.setVisibility(View.VISIBLE); recyclerView.setAdapter(appAdapter); @@ -265,6 +269,10 @@ protected void onPostExecute(Void aVoid) { drawer = UtilsUI.setNavigationDrawer((Activity) context, context, toolbar, appAdapter, appSystemAdapter, appFavoriteAdapter, appHiddenAdapter, recyclerView); } + @Override + public void setResultsMessage(Boolean result) { + MainActivity.this.setResultsMessage(result); + } } private void setPullToRefreshView(final PullToRefreshView pullToRefreshView) { @@ -326,7 +334,7 @@ public boolean onQueryTextChange(String search) { return false; } - public static void setResultsMessage(Boolean result) { + private void setResultsMessage(Boolean result) { if (result) { noResults.setVisibility(View.VISIBLE); fastScroller.setVisibility(View.GONE); diff --git a/app/src/main/java/com/javiersantos/mlmanager/adapters/AppAdapter.java b/app/src/main/java/com/javiersantos/mlmanager/adapters/AppAdapter.java index 23bceb0..7bbfac1 100644 --- a/app/src/main/java/com/javiersantos/mlmanager/adapters/AppAdapter.java +++ b/app/src/main/java/com/javiersantos/mlmanager/adapters/AppAdapter.java @@ -19,11 +19,10 @@ import com.afollestad.materialdialogs.MaterialDialog; import com.gc.materialdesign.views.ButtonFlat; -import com.javiersantos.mlmanager.MLManagerApplication; -import com.javiersantos.mlmanager.activities.AppActivity; import com.javiersantos.mlmanager.AppInfo; +import com.javiersantos.mlmanager.MLManagerApplication; import com.javiersantos.mlmanager.R; -import com.javiersantos.mlmanager.activities.MainActivity; +import com.javiersantos.mlmanager.activities.AppActivity; import com.javiersantos.mlmanager.async.ExtractFileInBackground; import com.javiersantos.mlmanager.utils.AppPreferences; import com.javiersantos.mlmanager.utils.UtilsApp; @@ -150,15 +149,28 @@ protected FilterResults performFiltering(CharSequence charSequence) { @Override protected void publishResults(CharSequence charSequence, FilterResults filterResults) { if (filterResults.count > 0) { - MainActivity.setResultsMessage(false); + if(resultsMessageListener != null){ + resultsMessageListener.setResultsMessage(false); + } } else { - MainActivity.setResultsMessage(true); + if(resultsMessageListener != null){ + resultsMessageListener.setResultsMessage(true); + } } appList = (ArrayList) filterResults.values; notifyDataSetChanged(); } }; } + private ResultsMessageListener resultsMessageListener; + + public void setResultsMessageListener(ResultsMessageListener resultsMessageListener) { + this.resultsMessageListener = resultsMessageListener; + } + + public interface ResultsMessageListener { + void setResultsMessage(Boolean result); + } @Override public AppViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {