Android Open Source - Android_Yellow_Pages_App_Content_Provider Detail Fragment






From Project

Back to project page Android_Yellow_Pages_App_Content_Provider.

License

The source code is released under:

Apache License

If you think the Android project Android_Yellow_Pages_App_Content_Provider 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 com.tddrampup.fragments;
//from  w w w  . j  av  a  2 s .c o  m
import android.database.Cursor;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.tddrampup.R;
import com.tddrampup.contentProviders.YellowContentProvider;
import com.tddrampup.databases.ListingsTable;
import com.tddrampup.databases.ListingsTableHelper;
import com.tddrampup.databases.SearchTable;
import com.tddrampup.databases.SearchTableHelper;

import roboguice.fragment.RoboFragment;

/**
 * Created by: WX009-PC
 * on: 2/21/14.
 */
public class DetailFragment extends RoboFragment {

    private final String mListingId;
    private TextView nameTextView;
    private TextView locationTextView;
    private TextView websiteTextView;
    private final boolean mIsSearchQuery;

    public DetailFragment(String listingId, boolean isSearchQuery) {
        mListingId = listingId;
        mIsSearchQuery = isSearchQuery;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.detail_fragment, container, false);
        nameTextView = (TextView) rootView.findViewById(R.id.name_detail_fragment);
        locationTextView = (TextView) rootView.findViewById(R.id.location_detail_fragment);
        websiteTextView = (TextView) rootView.findViewById(R.id.website_detail_fragment);
        populateTextViews();
        return rootView;
    }

    private void populateTextViews() {
        Cursor cursor;
        int nameIdIndex;
        int streetIdIndex;
        int cityIdIndex;
        int websiteIdIndex;
        if (mIsSearchQuery) {
            cursor = getActivity().getContentResolver().query(YellowContentProvider.CONTENT_URI_SEARCH_LISTINGS, SearchTableHelper.searchTableDetailProjection, SearchTable.COLUMN_LISTING_ID + "=" + mListingId, null, null);
            nameIdIndex = cursor.getColumnIndex(SearchTable.COLUMN_NAME);
            streetIdIndex = cursor.getColumnIndex(SearchTable.COLUMN_STREET);
            cityIdIndex = cursor.getColumnIndex(SearchTable.COLUMN_CITY);
            websiteIdIndex = cursor.getColumnIndex(SearchTable.COLUMN_MERCHANT_URL);
        } else {
            cursor = getActivity().getContentResolver().query(YellowContentProvider.CONTENT_URI_LISTINGS, ListingsTableHelper.listingsTableDetailProjection, ListingsTable.COLUMN_LISTING_ID + "=" + mListingId, null, null);
            nameIdIndex = cursor.getColumnIndex(ListingsTable.COLUMN_NAME);
            streetIdIndex = cursor.getColumnIndex(ListingsTable.COLUMN_STREET);
            cityIdIndex = cursor.getColumnIndex(ListingsTable.COLUMN_CITY);
            websiteIdIndex = cursor.getColumnIndex(ListingsTable.COLUMN_MERCHANT_URL);
        }
        cursor.moveToFirst();
        String name = cursor.getString(nameIdIndex);
        String street = cursor.getString(streetIdIndex);
        String city = cursor.getString(cityIdIndex);
        String website = cursor.getString(websiteIdIndex);
        cursor.close();
        nameTextView.setText(name);
        locationTextView.setText(street + ", " + city);
        websiteTextView.setText(website);
    }
}




Java Source Code List

android.UnusedStub.java
com.tddrampup.ApplicationModule.java
com.tddrampup.YellowApplication.java
com.tddrampup.activities.MainActivity.java
com.tddrampup.contentProviders.YellowContentProvider.java
com.tddrampup.databases.ListingsTableHelper.java
com.tddrampup.databases.ListingsTable.java
com.tddrampup.databases.PreviousQueryTableHelper.java
com.tddrampup.databases.PreviousQueryTable.java
com.tddrampup.databases.SearchTableHelper.java
com.tddrampup.databases.SearchTable.java
com.tddrampup.databases.YellowDatabaseHelper.java
com.tddrampup.factories.CameraUpdateFactoryWrapperInterface.java
com.tddrampup.factories.CameraUpdateFactoryWrapper.java
com.tddrampup.factories.MarkerOptionsFactoryWrapperInterface.java
com.tddrampup.factories.MarkerOptionsFactoryWrapper.java
com.tddrampup.fragments.DetailFragment.java
com.tddrampup.fragments.GoogleMapFragment.java
com.tddrampup.fragments.HomeFragment.java
com.tddrampup.fragments.ListFragment.java
com.tddrampup.models.Address.java
com.tddrampup.models.GeoCode.java
com.tddrampup.models.Keywords.java
com.tddrampup.models.Listing.java
com.tddrampup.models.Phone.java
com.tddrampup.models.Products.java
com.tddrampup.models.Profile.java
com.tddrampup.models.Summary.java
com.tddrampup.models.YellowResponse.java
com.tddrampup.serviceLayers.VolleyServiceLayerCallback.java
com.tddrampup.serviceLayers.VolleyServiceLayer.java
com.tddrampup.views.MapView.java