mirror of
https://github.com/whyorean/AuroraStore.git
synced 2026-06-20 13:39:36 -04:00
A bit of refactoring
This commit is contained in:
@@ -25,11 +25,8 @@ abstract public class AppListActivity extends YalpStoreActivity {
|
||||
protected List<Map<String, Object>> data = new ArrayList<>();
|
||||
protected Map<String, App> apps = new HashMap<>();
|
||||
|
||||
protected ListAdapter listAdapter;
|
||||
protected ListView listView;
|
||||
|
||||
private boolean finishedStart = false;
|
||||
|
||||
abstract protected void loadApps();
|
||||
|
||||
@Override
|
||||
@@ -37,7 +34,6 @@ abstract public class AppListActivity extends YalpStoreActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.applist_activity_layout);
|
||||
|
||||
setListAdapter(getSimpleListAdapter());
|
||||
getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
@@ -59,10 +55,9 @@ abstract public class AppListActivity extends YalpStoreActivity {
|
||||
if (emptyView != null) {
|
||||
listView.setEmptyView(emptyView);
|
||||
}
|
||||
if (finishedStart) {
|
||||
setListAdapter(listAdapter);
|
||||
if (null == listView.getAdapter()) {
|
||||
listView.setAdapter(getSimpleListAdapter());
|
||||
}
|
||||
finishedStart = true;
|
||||
}
|
||||
|
||||
protected Map<String, Object> formatApp(App app) {
|
||||
@@ -77,13 +72,13 @@ abstract public class AppListActivity extends YalpStoreActivity {
|
||||
data.add(this.formatApp(app));
|
||||
apps.put(app.getPackageName(), app);
|
||||
}
|
||||
((SimpleAdapter) getListAdapter()).notifyDataSetChanged();
|
||||
((SimpleAdapter) getListView().getAdapter()).notifyDataSetChanged();
|
||||
}
|
||||
|
||||
protected void clearApps() {
|
||||
apps.clear();
|
||||
data.clear();
|
||||
((SimpleAdapter) getListAdapter()).notifyDataSetChanged();
|
||||
((SimpleAdapter) getListView().getAdapter()).notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private SimpleAdapter getSimpleListAdapter() {
|
||||
@@ -102,18 +97,7 @@ abstract public class AppListActivity extends YalpStoreActivity {
|
||||
return adapter;
|
||||
}
|
||||
|
||||
public void setListAdapter(ListAdapter adapter) {
|
||||
synchronized (this) {
|
||||
listAdapter = adapter;
|
||||
listView.setAdapter(adapter);
|
||||
}
|
||||
}
|
||||
|
||||
public ListView getListView() {
|
||||
return listView;
|
||||
}
|
||||
|
||||
public ListAdapter getListAdapter() {
|
||||
return listAdapter;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class CategoryAppsActivity extends EndlessScrollActivity {
|
||||
categoryId = newCategoryId;
|
||||
setTitle(new CategoryManager(this).getCategoryName(categoryId));
|
||||
loadApps();
|
||||
((SimpleAdapter) getListAdapter()).notifyDataSetChanged();
|
||||
((SimpleAdapter) getListView().getAdapter()).notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -80,10 +80,14 @@ public class DownloadOrInstallFragment extends DetailsFragment {
|
||||
}
|
||||
|
||||
public void unregisterReceivers() {
|
||||
activity.unregisterReceiver(downloadReceiver);
|
||||
downloadReceiver = null;
|
||||
activity.unregisterReceiver(installReceiver);
|
||||
installReceiver = null;
|
||||
if (null != downloadReceiver) {
|
||||
activity.unregisterReceiver(downloadReceiver);
|
||||
downloadReceiver = null;
|
||||
}
|
||||
if (null != installReceiver) {
|
||||
activity.unregisterReceiver(installReceiver);
|
||||
installReceiver = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void registerReceivers() {
|
||||
|
||||
@@ -65,7 +65,7 @@ public class SearchResultActivity extends EndlessScrollActivity {
|
||||
};
|
||||
task.setCategoryManager(new CategoryManager(this));
|
||||
prepareTask(task).execute(query, categoryId);
|
||||
((SimpleAdapter) getListAdapter()).notifyDataSetChanged();
|
||||
((SimpleAdapter) getListView().getAdapter()).notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private String getQuery(Intent intent) {
|
||||
|
||||
@@ -93,8 +93,6 @@ class UpdatableAppsTask extends GoogleApiAsyncTask {
|
||||
installedApp.setOfferType(appFromMarket.getOfferType());
|
||||
installedApp.setPermissions(appFromMarket.getPermissions());
|
||||
if (installedApp.getVersionCode() < appFromMarket.getVersionCode()) {
|
||||
installedApp.setUpdated(appFromMarket.getUpdated());
|
||||
installedApp.setVersionCode(appFromMarket.getVersionCode());
|
||||
appFromMarket.setDisplayName(installedApp.getDisplayName());
|
||||
appFromMarket.setIcon(installedApp.getIcon());
|
||||
appFromMarket.setInstalled(true);
|
||||
|
||||
Reference in New Issue
Block a user