Free version banner removed from paid version. Removed unused fragments.

This commit is contained in:
GaidamakUA 2015-10-02 16:29:47 +03:00
parent c50397188f
commit 5b3ffc8da0
10 changed files with 52 additions and 504 deletions

View file

@ -1998,4 +1998,6 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
<string name="downloads_left_template">%1$s downloads left</string>
<string name="roads">Roads</string>
<string name="downloading_number_of_fiels">Downloding - %1$d file</string>
<string name="show_free_version_banner">Show free version banner</string>
<string name="show_free_version_banner_description">Even if you have paid version you still can see free version banner</string>
</resources>

View file

@ -1,21 +1,15 @@
package net.osmand.plus;
import java.io.File;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Configuration;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.os.Environment;
import net.osmand.IndexConstants;
import net.osmand.StateChangedListener;
@ -34,15 +28,22 @@ import net.osmand.plus.helpers.SearchHistoryHelper;
import net.osmand.plus.render.RendererRegistry;
import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.render.RenderingRulesStorage;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Configuration;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.os.Environment;
import java.io.File;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
public class OsmandSettings {
@ -1072,6 +1073,8 @@ public class OsmandSettings {
public CommonPreference<String> PREVIOUS_INSTALLED_VERSION = new StringPreference("previous_installed_version", "").makeGlobal();
public final OsmandPreference<Boolean> SHOULD_SHOW_FREE_VERSION_BANNER = new BooleanPreference("should_show_free_version_banner", false).makeGlobal().cache();
public ITileSource getMapTileSource(boolean warnWhenSelected) {
String tileName = MAP_TILE_SOURCES.get();
if (tileName != null) {

View file

@ -1,6 +1,7 @@
package net.osmand.plus.development;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Intent;
@ -142,6 +143,7 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
final Preference agpspref = new Preference(this);
agpspref.setTitle(R.string.agps_info);
if (settings.AGPS_DATA_LAST_TIME_DOWNLOADED.get() != 0L) {
@SuppressLint("SimpleDateFormat")
SimpleDateFormat prt = new SimpleDateFormat("yyyy-MM-dd HH:mm");
agpspref.setSummary(getString(R.string.agps_data_last_downloaded, prt.format(settings.AGPS_DATA_LAST_TIME_DOWNLOADED.get())));
} else {
@ -155,6 +157,7 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
public boolean onPreferenceClick(Preference preference) {
if(getMyApplication().getSettings().isInternetConnectionAvailable(true)) {
getMyApplication().getLocationProvider().redownloadAGPS();
@SuppressLint("SimpleDateFormat")
SimpleDateFormat prt = new SimpleDateFormat("yyyy-MM-dd HH:mm");
agpspref.setSummary(getString(R.string.agps_data_last_downloaded, prt.format(settings.AGPS_DATA_LAST_TIME_DOWNLOADED.get())));
}
@ -167,6 +170,7 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
pref = new Preference(this);
pref.setTitle(R.string.day_night_info);
if (sunriseSunset != null) {
@SuppressLint("SimpleDateFormat")
SimpleDateFormat prt = new SimpleDateFormat("yyyy-MM-dd HH:mm");
pref.setSummary(getString(R.string.day_night_info_description, prt.format(sunriseSunset.getSunrise()),
prt.format(sunriseSunset.getSunset())));
@ -176,7 +180,11 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
pref.setSelectable(false);
//setEnabled(false) creates bad readability on some devices
//pref.setEnabled(false);
cat.addPreference(pref);
cat.addPreference(pref);
cat.addPreference(createCheckBoxPreference(settings.SHOULD_SHOW_FREE_VERSION_BANNER,
R.string.show_free_version_banner,
R.string.show_free_version_banner_description));
}
protected void availableProfileDialog() {
@ -193,7 +201,7 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
StringBuilder vls = new StringBuilder(ApplicationMode.DEFAULT.getStringKey()+",");
for(ApplicationMode mode : modes) {
if(selected.contains(mode)) {
vls.append(mode.getStringKey()+",");
vls.append(mode.getStringKey()).append(",");
}
}
settings.AVAILABLE_APP_MODES.set(vls.toString());

View file

@ -34,7 +34,6 @@ import net.osmand.plus.activities.TabActivity;
import net.osmand.plus.base.BasicProgressAsyncTask;
import net.osmand.plus.download.items.WorldItemsFragment;
import net.osmand.plus.download.newimplementation.IndexItemCategoryWithSubcat;
import net.osmand.plus.download.newimplementation.NewLocalIndexesFragment;
import net.osmand.plus.srtmplugin.SRTMPlugin;
import net.osmand.plus.views.controls.PagerSlidingTabStrip;
@ -321,24 +320,6 @@ public class DownloadActivity extends BaseDownloadActivity {
}
}
@Override
public void onCategorizationFinished(List<IndexItem> filtered,
List<IndexItemCategoryWithSubcat> cats) {
boolean isPushed = false;
for (WeakReference<Fragment> ref : fragSet) {
Fragment f = ref.get();
if (f instanceof NewLocalIndexesFragment) {
if (f.isAdded()) {
isPushed = true;
((NewLocalIndexesFragment) f).onCategorizationFinished(filtered, cats);
}
}
}
if (!isPushed) {
this.cats = cats;
}
}
@Override
public void onCategorizationFinished() {
for (WeakReference<Fragment> ref : fragSet) {

View file

@ -72,14 +72,12 @@ public class RegionDialogFragment extends DialogFragment {
}
toolbar.setTitle(this.region.getName());
}
DownloadsUiHelper.initFreeVersionBanner(view, getMyApplication().getSettings(),
DownloadsUiHelper.initFreeVersionBanner(view, getMyApplication(),
getResources());
final WorldRegion finalRegion = region;
mProgressListener = new DownloadsUiHelper.MapDownloadListener(view, getResources()){
@Override
public void onProgressUpdate(int progressPercentage, int activeTasks) {
LOG.debug(finalRegion.getName() + " onProgressUpdate()");
super.onProgressUpdate(progressPercentage, activeTasks);
}
@ -87,7 +85,7 @@ public class RegionDialogFragment extends DialogFragment {
public void onFinished() {
super.onFinished();
DownloadsUiHelper.initFreeVersionBanner(view,
getMyApplication().getSettings(), getResources());
getMyApplication(), getResources());
}
};

View file

@ -84,7 +84,7 @@ public class WorldItemsFragment extends Fragment {
onCategorizationFinished();
DownloadsUiHelper.initFreeVersionBanner(view,
getMyApplication().getSettings(), getResources());
getMyApplication(), getResources());
return view;
}

View file

@ -12,6 +12,7 @@ import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.Version;
@ -22,8 +23,15 @@ public final class DownloadsUiHelper {
private DownloadsUiHelper() {
}
public static void initFreeVersionBanner(View header, OsmandSettings settings,
public static void initFreeVersionBanner(View header, OsmandApplication application,
Resources resources) {
final View freeVersionBanner = header.findViewById(R.id.freeVersionBanner);
OsmandSettings settings = application.getSettings();
if(!Version.isFreeVersion(application) && !settings.SHOULD_SHOW_FREE_VERSION_BANNER.get()) {
freeVersionBanner.setVisibility(View.GONE);
return;
}
TextView downloadsLeftTextView = (TextView) header.findViewById(R.id.downloadsLeftTextView);
final int downloadsLeft = BaseDownloadActivity.MAXIMUM_AVAILABLE_FREE_DOWNLOADS
- settings.NUMBER_OF_FREE_DOWNLOADS.get();
@ -35,8 +43,7 @@ public final class DownloadsUiHelper {
BaseDownloadActivity.MAXIMUM_AVAILABLE_FREE_DOWNLOADS));
final View buttonsLinearLayout = header.findViewById(R.id.buttonsLinearLayout);
header.findViewById(R.id.freeVersionBanner).setOnClickListener(
freeVersionBanner.setOnClickListener(
new ToggleCollapseFreeVersionBanner(freeVersionDescriptionTextView,
buttonsLinearLayout));

View file

@ -1,104 +0,0 @@
package net.osmand.plus.download.newimplementation;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.download.DownloadActivity;
import org.apache.commons.logging.Log;
public class MapsInCategoryFragment extends DialogFragment {
private static final Log LOG = PlatformUtil.getLog(IndexItemCategoryWithSubcat.class);
public static final String TAG = "MapsInCategoryFragment";
private static final String CATEGORY = "category";
private DownloadsUiHelper.MapDownloadListener mProgressListener;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
boolean isLightTheme = ((OsmandApplication) getActivity().getApplication())
.getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
int themeId = isLightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
setStyle(STYLE_NO_FRAME, themeId);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.maps_in_category_fragment, container, false);
IndexItemCategoryWithSubcat category = getArguments().getParcelable(CATEGORY);
assert category != null;
getChildFragmentManager().beginTransaction().add(R.id.fragmentContainer,
SubcategoriesFragment.createInstance(category)).commit();
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
toolbar.setTitle(category.getName());
toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
DownloadsUiHelper.initFreeVersionBanner(view,
getMyActivity().getMyApplication().getSettings(), getResources());
mProgressListener = new DownloadsUiHelper.MapDownloadListener(view, getResources()){
@Override
public void onFinished() {
super.onFinished();
DownloadsUiHelper.initFreeVersionBanner(view,
getMyActivity().getMyApplication().getSettings(), getResources());
}
};
view.findViewById(R.id.downloadProgressLayout).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
return view;
}
@Override
public void onResume() {
super.onResume();
getMyActivity().setOnProgressUpdateListener(mProgressListener);
}
@Override
public void onPause() {
super.onPause();
getMyActivity().setOnProgressUpdateListener(null);
}
private DownloadActivity getMyActivity() {
return (DownloadActivity) getActivity();
}
public void onCategorySelected(@NonNull IndexItemCategoryWithSubcat category) {
LOG.debug("onCategorySelected()");
createInstance(category).show(getChildFragmentManager(), TAG);
}
public static MapsInCategoryFragment createInstance(
@NonNull IndexItemCategoryWithSubcat category) {
Bundle bundle = new Bundle();
bundle.putParcelable(CATEGORY, category);
MapsInCategoryFragment fragment = new MapsInCategoryFragment();
fragment.setArguments(bundle);
return fragment;
}
}

View file

@ -1,180 +0,0 @@
package net.osmand.plus.download.newimplementation;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.StatFs;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.MenuItemCompat;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.OsmAndListFragment;
import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.IndexItem;
import org.apache.commons.logging.Log;
import java.io.File;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
public class NewLocalIndexesFragment extends OsmAndListFragment {
private static final Log LOG = PlatformUtil.getLog(NewLocalIndexesFragment.class);
public static final String CATEGORIES = "categories";
private static final MessageFormat formatGb = new MessageFormat("{0, number,<b>#.##</b>} GB", Locale.US);
public static final int RELOAD_ID = 0;
private CategoriesAdapter mAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.local_index_fragment, container, false);
ListView listView = (ListView) view.findViewById(android.R.id.list);
mAdapter = new CategoriesAdapter(getActivity(), getMyApplication());
listView.setAdapter(mAdapter);
List<IndexItemCategoryWithSubcat> cats = ((DownloadActivity) getActivity()).getCats();
if (cats != null) {
onCategorizationFinished(null, cats);
}
if (savedInstanceState != null) {
List<IndexItemCategoryWithSubcat> savedCats =
savedInstanceState.getParcelableArrayList(CATEGORIES);
onCategorizationFinished(null, savedCats);
}
View header = inflater.inflate(R.layout.local_index_fragment_header, listView, false);
initMemoryConsumedCard(header);
DownloadsUiHelper.initFreeVersionBanner(header, getMyApplication().getSettings(),
getResources());
listView.addHeaderView(header);
getDownloadActivity().setSupportProgressBarIndeterminateVisibility(false);
return view;
}
private void initMemoryConsumedCard(View header) {
ProgressBar sizeProgress = (ProgressBar) header.findViewById(R.id.progressBar);
File dir = getMyApplication().getAppPath("").getParentFile();
String size = formatGb.format(new Object[]{0});
int percent = 0;
if (dir.canRead()) {
StatFs statFs = new StatFs(dir.getAbsolutePath());
//noinspection deprecation
size = formatGb.format(new Object[]{(float) (statFs.getAvailableBlocks()) * statFs.getBlockSize() / (1 << 30)});
//noinspection deprecation
percent = statFs.getAvailableBlocks() * 100 / statFs.getBlockCount();
}
sizeProgress.setProgress(percent);
String text = getString(R.string.free, size);
TextView descriptionText = (TextView) header.findViewById(R.id.rightTextView);
descriptionText.setText(Html.fromHtml(text));
descriptionText.setMovementMethod(LinkMovementMethod.getInstance());
((TextView) header.findViewById(R.id.leftTextView)).setText(R.string.device_memory);
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
MenuItem item = menu.add(0, RELOAD_ID, 0, R.string.shared_string_refresh);
item.setIcon(R.drawable.ic_action_refresh_dark);
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == RELOAD_ID) {
// re-create the thread
DownloadActivity.downloadListIndexThread.runReloadIndexFiles();
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onSaveInstanceState(Bundle outState) {
LOG.debug("onSaveInstanceState()");
ArrayList<IndexItemCategoryWithSubcat> items = new ArrayList<>(mAdapter.getCount());
for (int i = 0; i < mAdapter.getCount(); i++) {
items.add(mAdapter.getItem(i));
}
outState.putParcelableArrayList(CATEGORIES, items);
super.onSaveInstanceState(outState);
}
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
FragmentTransaction fragmentTransaction = getChildFragmentManager().beginTransaction();
fragmentTransaction.addToBackStack(null);
MapsInCategoryFragment.createInstance(mAdapter.getItem(position - 1))
.show(fragmentTransaction, MapsInCategoryFragment.TAG);
}
private DownloadActivity getDownloadActivity() {
return (DownloadActivity) getActivity();
}
public void onCategorizationFinished(List<IndexItem> filtered, List<IndexItemCategoryWithSubcat> cats) {
if (mAdapter != null) {
mAdapter.clear();
mAdapter.addAll(cats);
}
}
private static class CategoriesAdapter extends ArrayAdapter<IndexItemCategoryWithSubcat> {
private final OsmandApplication osmandApplication;
public CategoriesAdapter(Context context, OsmandApplication osmandApplication) {
super(context, R.layout.simple_list_menu_item);
this.osmandApplication = osmandApplication;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder;
if (convertView == null) {
convertView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.simple_list_menu_item, parent, false);
viewHolder = new ViewHolder();
viewHolder.textView = (TextView) convertView.findViewById(R.id.title);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
Drawable iconLeft = osmandApplication.getIconsCache()
.getContentIcon(R.drawable.ic_world_globe_dark);
viewHolder.textView.setCompoundDrawablesWithIntrinsicBounds(iconLeft, null, null, null);
viewHolder.textView.setText(getItem(position).categoryStaticData.getName());
return convertView;
}
private static class ViewHolder {
TextView textView;
}
}
}

View file

@ -1,167 +0,0 @@
package net.osmand.plus.download.newimplementation;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.download.BaseDownloadActivity;
import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.DownloadActivityType;
import net.osmand.plus.download.IndexItem;
import net.osmand.plus.helpers.HasName;
public class SubcategoriesFragment extends Fragment {
private static final String CATEGORY = "category";
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
IndexItemCategoryWithSubcat category = getArguments().getParcelable(CATEGORY);
assert category != null;
ListView listView = new ListView(getActivity());
final OsmandApplication application = (OsmandApplication) getActivity().getApplication();
final MapFilesAdapter mAdapter = new MapFilesAdapter(getActivity(),
(MapsInCategoryFragment) getParentFragment());
listView.setAdapter(mAdapter);
mAdapter.addAll(category.items);
mAdapter.addAll(category.subcats);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
final HasName item = mAdapter.getItem(position);
if (item instanceof IndexItemCategoryWithSubcat) {
((MapsInCategoryFragment) getParentFragment())
.onCategorySelected((IndexItemCategoryWithSubcat) item);
}
}
});
return listView;
}
public static SubcategoriesFragment createInstance(
@NonNull IndexItemCategoryWithSubcat category) {
Bundle bundle = new Bundle();
bundle.putParcelable(CATEGORY, category);
SubcategoriesFragment fragment = new SubcategoriesFragment();
fragment.setArguments(bundle);
return fragment;
}
private static class MapFilesAdapter extends ArrayAdapter<HasName> {
final MapsInCategoryFragment fragment;
public MapFilesAdapter(Context context, MapsInCategoryFragment fragment) {
super(context, R.layout.two_line_with_images_list_item);
this.fragment = fragment;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder;
if (convertView == null) {
convertView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.two_line_with_images_list_item, parent, false);
viewHolder = new ViewHolder(convertView);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
HasName item = getItem(position);
if (item instanceof IndexItemCategoryWithSubcat) {
viewHolder.bindCategory((IndexItemCategoryWithSubcat) item,
(DownloadActivity) getContext());
} else if (item instanceof IndexItem) {
viewHolder.bindIndexItem((IndexItem) item, (DownloadActivity) getContext(),
fragment);
} else {
throw new IllegalArgumentException("Item must be of type IndexItem or " +
"IndexItemCategory but is of type:" + item.getClass());
}
return convertView;
}
private static class ViewHolder {
private final TextView nameTextView;
private final TextView descrTextView;
private final ImageView leftImageView;
private final ImageView rightImageButton;
private final ProgressBar progressBar;
public ViewHolder(View convertView) {
nameTextView = (TextView) convertView.findViewById(R.id.name);
descrTextView = (TextView) convertView.findViewById(R.id.description);
leftImageView = (ImageView) convertView.findViewById(R.id.leftImageView);
rightImageButton = (ImageView) convertView.findViewById(R.id.rightImageButton);
progressBar = (ProgressBar) convertView.findViewById(R.id.progressBar);
}
public void bindIndexItem(final IndexItem indexItem, final DownloadActivity context,
MapsInCategoryFragment fragment) {
if (indexItem.getType() == DownloadActivityType.VOICE_FILE) {
nameTextView.setText(indexItem.getVisibleName(context,
context.getMyApplication().getRegions()));
} else {
nameTextView.setText(indexItem.getType().getString(context));
}
descrTextView.setText(indexItem.getSizeDescription(context));
leftImageView.setImageDrawable(getContextIcon(context,
indexItem.getType().getIconResource()));
rightImageButton.setVisibility(View.VISIBLE);
rightImageButton.setImageDrawable(getContextIcon(context,
R.drawable.ic_action_import));
rightImageButton.setTag(R.id.index_item, indexItem);
rightImageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((BaseDownloadActivity) v.getContext())
.startDownload((IndexItem) v.getTag(R.id.index_item));
}
});
progressBar.setVisibility(View.GONE);
}
public void bindCategory(IndexItemCategoryWithSubcat category,
DownloadActivity context) {
nameTextView.setText(category.getName());
if (category.types.size() > 0) {
StringBuilder stringBuilder = new StringBuilder();
Resources resources = context.getResources();
for (Integer mapType : category.types) {
stringBuilder.append(resources.getString(mapType));
stringBuilder.append(", ");
}
stringBuilder.delete(stringBuilder.length() - 2, stringBuilder.capacity());
descrTextView.setText(stringBuilder.toString());
} else {
descrTextView.setText(R.string.shared_string_others);
}
leftImageView.setImageDrawable(getContextIcon(context, R.drawable.ic_map));
rightImageButton.setVisibility(View.GONE);
progressBar.setVisibility(View.GONE);
}
private Drawable getContextIcon(DownloadActivity context, int resourceId) {
return context.getMyApplication().getIconsCache().getContentIcon(resourceId);
}
}
}
}