Android Open Source - downtown Websites






From Project

Back to project page downtown.

License

The source code is released under:

GNU General Public License

If you think the Android project downtown listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.dklisiaris.downtown;
//from   w  ww.  j av  a2 s .c  om
import java.util.ArrayList;
import org.dklisiaris.downtown.R;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.ListFragment;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.AsyncTaskLoader;
import android.support.v4.content.Loader;
import android.support.v4.widget.SearchViewCompat.OnQueryTextListenerCompat;
import android.support.v7.app.ActionBarActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class Websites extends ActionBarActivity{

    // XML node keys
    static final String KEY_CATEGORY = "category"; // parent node
    static final String KEY_SUBTITLE = "subtitle";
    static final String KEY_NAME = "name";
    static final String KEY_SUBCATEGORY = "subcategory";
    static final String KEY_CATEGORIES = "categories";    
    static final String KEY_SITE = "eshop";
    static final String KEY_AVAIL = "availability";
    protected static ArrayList<String> menuItems = new ArrayList<String>();  
    
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

        FragmentManager fm = getSupportFragmentManager();

        // Create the list fragment and add it as our sole content.
        if (fm.findFragmentById(android.R.id.content) == null) {
            WebsitesFragment sites = new WebsitesFragment();
            fm.beginTransaction().add(android.R.id.content, sites).commit();
        }
  }

    public static class ItemLoader extends AsyncTaskLoader<ArrayList<String>> {

        ArrayList<String> mItems;
        Context ct;

        public ItemLoader(Context context) {
            super(context);
            ct = context;
            menuItems = new ArrayList<String>();
        }

        /**
         * This is where the bulk of our work is done.  This function is
         * called in a background thread and should generate a new set of
         * data to be published by the loader.
         */
        @Override public ArrayList<String> loadInBackground() {
            
          menuItems.add("?????????");
          menuItems.add("?? ?????????");
            // Done!
            return menuItems;
        }

        /**
         * Called when there is new data to deliver to the client.  The
         * super class will take care of delivering it; the implementation
         * here just adds a little more logic.
         */
        @Override public void deliverResult(ArrayList<String> items) {
            if (isReset()) {
                // An async query came in while the loader is stopped.  We
                // don't need the result.
                if (items != null) {
                    onReleaseResources(items);
                }
            }
            ArrayList<String> olditems = items;
            mItems = items;

            if (isStarted()) {
                // If the Loader is currently started, we can immediately
                // deliver its results.
                super.deliverResult(items);
            }

            // At this point we can release the resources associated with
            // 'olditems' if needed; now that the new result is delivered we
            // know that it is no longer in use.
            if (olditems != null) {
                onReleaseResources(olditems);
            }
        }

        /**
         * Handles a request to start the Loader.
         */
        @Override protected void onStartLoading() {
            if (mItems != null) {
                // If we currently have a result available, deliver it
                // immediately.
                deliverResult(mItems);
            }
            else{
              forceLoad();
            }
        }

        /**
         * Handles a request to stop the Loader.
         */
        @Override protected void onStopLoading() {
            // Attempt to cancel the current load task if possible.
            cancelLoad();
        }

        /**
         * Handles a request to cancel a load.
         */
        @Override public void onCanceled(ArrayList<String> items) {
            super.onCanceled(items);

            // At this point we can release the resources associated with 'items'
            // if needed.
            onReleaseResources(items);
        }

        /**
         * Handles a request to completely reset the Loader.
         */
        @Override protected void onReset() {
            super.onReset();

            // Ensure the loader is stopped
            onStopLoading();

            // At this point we can release the resources associated with 'items'
            // if needed.
            if (mItems != null) {
                onReleaseResources(mItems);
                mItems = null;
            }

        }

        /**
         * Helper function to take care of releasing resources associated
         * with an actively loaded data set.
         */
        protected void onReleaseResources(ArrayList<String> items) {
            // For a simple List<> there is nothing to do.  For something
            // like a Cursor, we would close it here.
        }
    }
  
    public static class CustomAdapter extends ArrayAdapter<String> {
        private final LayoutInflater mInflater;

        public CustomAdapter(Context context) {
            super(context, R.layout.tab_list);
            mInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        }

        public void setData(ArrayList<String> data) {
            clear();
            if (data != null) {
                for (String entry : data) {
                    add(entry);
                    //Log.d("Added by cAdapter",entry);
                }
            }
        }

        /**
         * Populate new items in the list.
         */
        @Override public View getView(int position, View convertView, ViewGroup parent) {
            View view;

            if (convertView == null) {
                view = mInflater.inflate(R.layout.list_item, parent, false);
            } else {
                view = convertView;
            }

            String item = getItem(position);
            ((TextView)view.findViewById(R.id.category)).setText(item);

            return view;
        }
    }
    
    public static class WebsitesFragment extends ListFragment implements LoaderManager.LoaderCallbacks<ArrayList<String>> {
        // This is the Adapter being used to display the list's data.
        CustomAdapter mAdapter;
        // If non-null, this is the current filter the user has provided.
        String mCurFilter;
        OnQueryTextListenerCompat mOnQueryTextListenerCompat;
        
        @Override 
        public void onActivityCreated(Bundle savedInstanceState) {
            super.onActivityCreated(savedInstanceState);

            // Give some text to display if there is no data.
            //setEmptyText("??? ????????? ????????????...");
 
            // We have a menu item to show in action bar.
            setHasOptionsMenu(true);
            setListAdapter(null);
            // Create an empty adapter we will use to display the loaded data.
            View header_view = View.inflate(getActivity(), R.layout.tabs_header, null);
            TextView hv = ((TextView)header_view.findViewById(R.id.ctgr));
            hv.setText(((GlobalData)getActivity().getApplicationContext()).getCategory());
            getListView().addHeaderView(header_view);
            
            // Create an empty adapter we will use to display the loaded data.
            if (mAdapter == null) {
                mAdapter = new CustomAdapter(getActivity());
            }
            setListAdapter(mAdapter);

            // Start out with a progress indicator.
            setListShown(false);
            
            // Prepare the loader.  Either re-connect with an existing one,
            // or start a new one.
            getLoaderManager().initLoader(0, null, this);

        
          //Intent i = getParent().getIntent();
          // getting attached intent data

        }

        @Override 
        public void onListItemClick(ListView l, View v, int position, long id) {
            // Insert desired behavior here.
            //Log.d("Subcats..", "Item clicked: " + id);
        // selected item 
          if((TextView)v.findViewById(R.id.category)!=null){
        TextView tv = (TextView)v.findViewById(R.id.category);
        String product = (tv.getText().toString()).equals("?????????")? "yes" : "no";
        String avail = (tv.getText().toString()).equals("?????????")? "1" : "0";
        String category = ((GlobalData)getActivity().getApplicationContext()).getCategory();
        String cat_id = ((GlobalData)getActivity().getApplicationContext()).getCatID();
        // Launching new Activity on selecting single List Item
        Intent i = new Intent(getActivity(), Products.class);
        // sending data to new activity
        i.putExtra("category", category);
        i.putExtra("product", product);
        i.putExtra("key", KEY_AVAIL);
        
        i.putExtra("company", avail);
        i.putExtra("catID",cat_id);
        i.putExtra("col", "co_availability");
        startActivity(i);
          }
        }
        
        @Override public Loader<ArrayList<String>> onCreateLoader(int id, Bundle args) {
            // This is called when a new Loader needs to be created.  This
            // sample only has one Loader with no arguments, so it is simple.
            return new ItemLoader(getActivity());
        }

        @Override public void onLoadFinished(Loader<ArrayList<String>> loader, ArrayList<String> data) {
            // Set the new data in the adapter.
            mAdapter.setData(data);

            // The list should now be shown.
            if (isResumed()) {
                setListShown(true);
            } else {
                setListShownNoAnimation(true);
            }
        }

        @Override public void onLoaderReset(Loader<ArrayList<String>> loader) {
            // Clear the data in the adapter.
            mAdapter.setData(null);
        }

    }
  
  
}




Java Source Code List

com.google.maps.android.BuildConfig.java
com.google.maps.android.BuildConfig.java
com.google.maps.android.MarkerManager.java
com.google.maps.android.MathUtil.java
com.google.maps.android.PolyUtil.java
com.google.maps.android.SphericalUtil.java
com.google.maps.android.clustering.ClusterItem.java
com.google.maps.android.clustering.ClusterManager.java
com.google.maps.android.clustering.Cluster.java
com.google.maps.android.clustering.algo.Algorithm.java
com.google.maps.android.clustering.algo.GridBasedAlgorithm.java
com.google.maps.android.clustering.algo.NonHierarchicalDistanceBasedAlgorithm.java
com.google.maps.android.clustering.algo.PreCachingAlgorithmDecorator.java
com.google.maps.android.clustering.algo.StaticCluster.java
com.google.maps.android.clustering.view.ClusterRenderer.java
com.google.maps.android.clustering.view.DefaultClusterRenderer.java
com.google.maps.android.geometry.Bounds.java
com.google.maps.android.geometry.Point.java
com.google.maps.android.projection.Point.java
com.google.maps.android.projection.SphericalMercatorProjection.java
com.google.maps.android.quadtree.PointQuadTree.java
com.google.maps.android.ui.BubbleIconFactory.java
com.google.maps.android.ui.IconGenerator.java
com.google.maps.android.ui.RotationLayout.java
com.google.maps.android.ui.SquareTextView.java
com.sothree.slidinguppanel.SlidingUpPanelLayout.java
com.sothree.slidinguppanel.library.BuildConfig.java
com.sothree.slidinguppanel.library.BuildConfig.java
org.dklisiaris.downtown.Addresses.java
org.dklisiaris.downtown.BuildConfig.java
org.dklisiaris.downtown.FavsActivity.java
org.dklisiaris.downtown.GlobalData.java
org.dklisiaris.downtown.Intro.java
org.dklisiaris.downtown.MainActivity.java
org.dklisiaris.downtown.Manifest.java
org.dklisiaris.downtown.MapActivity.java
org.dklisiaris.downtown.MoreActivity.java
org.dklisiaris.downtown.Products.java
org.dklisiaris.downtown.SearchActivity.java
org.dklisiaris.downtown.Search.java
org.dklisiaris.downtown.SingleListItem.java
org.dklisiaris.downtown.Subcategories.java
org.dklisiaris.downtown.SubcatsAndFilters.java
org.dklisiaris.downtown.Tabs.java
org.dklisiaris.downtown.TestActivity.java
org.dklisiaris.downtown.WebViewActivity.java
org.dklisiaris.downtown.Websites.java
org.dklisiaris.downtown.actionbar.ActionBar.java
org.dklisiaris.downtown.actionbar.ScrollingTextView.java
org.dklisiaris.downtown.adapters.AddressFilterAdapter.java
org.dklisiaris.downtown.adapters.CustomAdapter.java
org.dklisiaris.downtown.adapters.CustomStringAdapter.java
org.dklisiaris.downtown.adapters.CustomSuggestionsAdapter.java
org.dklisiaris.downtown.adapters.MultiSelectionAdapter.java
org.dklisiaris.downtown.adapters.SubcatsAdapter.java
org.dklisiaris.downtown.db.Banner.java
org.dklisiaris.downtown.db.Category.java
org.dklisiaris.downtown.db.Company.java
org.dklisiaris.downtown.db.DBHandler.java
org.dklisiaris.downtown.db.DBInterface.java
org.dklisiaris.downtown.db.Image.java
org.dklisiaris.downtown.db.InitData.java
org.dklisiaris.downtown.db.Keyword.java
org.dklisiaris.downtown.db.Mapping.java
org.dklisiaris.downtown.db.Product.java
org.dklisiaris.downtown.db.QueryBuilder.java
org.dklisiaris.downtown.downloader.DownloadTask.java
org.dklisiaris.downtown.downloader.NotificationHelper.java
org.dklisiaris.downtown.helper.AccessAssets.java
org.dklisiaris.downtown.helper.AlertDialogManager.java
org.dklisiaris.downtown.helper.ConnectionDetector.java
org.dklisiaris.downtown.helper.FileCache.java
org.dklisiaris.downtown.helper.ImageLoader.java
org.dklisiaris.downtown.helper.InfoHelper.java
org.dklisiaris.downtown.helper.KeyboardUtil.java
org.dklisiaris.downtown.helper.MemoryCache.java
org.dklisiaris.downtown.helper.ShareHelper.java
org.dklisiaris.downtown.helper.UpdateConfirmDialog.java
org.dklisiaris.downtown.helper.UpdateHelper.java
org.dklisiaris.downtown.helper.Utils.java
org.dklisiaris.downtown.helper.XMLParser.java
org.dklisiaris.downtown.maps.AbstractMapActivity.java
org.dklisiaris.downtown.maps.CompanyMarker.java
org.dklisiaris.downtown.maps.DirectionsInfo.java
org.dklisiaris.downtown.maps.GMapV2Direction.java
org.dklisiaris.downtown.maps.Nearby.java
org.dklisiaris.downtown.maps.PopupAdapter.java
org.dklisiaris.downtown.providers.KeywordContract.java
org.dklisiaris.downtown.providers.KeywordProvider.java
org.dklisiaris.downtown.widgets.AspectRatioImageView.java
org.dklisiaris.downtown.widgets.CheckableRelativeLayout.java
org.dklisiaris.downtown.widgets.CustomScrollView.java
org.dklisiaris.downtown.widgets.FlipAnimator.java
org.dklisiaris.downtown.widgets.InertCheckBox.java
org.dklisiaris.downtown.widgets.MultiSpinner.java