Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update:Remove static fields in MainActivity, replace as Listener call… #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -127,7 +127,7 @@ private void setInitialConfiguration() {
}
}

class getInstalledApps extends AsyncTask<Void, String, Void> {
class getInstalledApps extends AsyncTask<Void, String, Void> implements AppAdapter.ResultsMessageListener {
private Integer totalApps;
private Integer actualApps;

Expand Down Expand Up @@ -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);
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<AppInfo>) 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) {
Expand Down