Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 初始滑动查看寻呼机后的错误位置_Android_Android Viewpager_Swipe - Fatal编程技术网

Android 初始滑动查看寻呼机后的错误位置

Android 初始滑动查看寻呼机后的错误位置,android,android-viewpager,swipe,Android,Android Viewpager,Swipe,我试着做一个像Pinterest一样的动作。一开始刷卡是正确的,我想在第一次刷卡后,位置总是会回到位置1 请提供一些建议。提前感谢您的帮助。:) 这是活动类: public class ProductV2Activity extends FragmentActivity { protected Integer productId; protected Integer prdPosition; protected ArrayList<String> productIdArray;

我试着做一个像Pinterest一样的动作。一开始刷卡是正确的,我想在第一次刷卡后,位置总是会回到位置1

请提供一些建议。提前感谢您的帮助。:)

这是活动类:

public class ProductV2Activity extends FragmentActivity
{

protected Integer productId;
protected Integer prdPosition;
protected ArrayList<String> productIdArray; 
protected String pageArg;
protected Integer productIdArraySize;
protected static Integer NUM_ITEMS;
protected ViewPager viewPager;
protected ProductV2FragmentPageAdapter productV2FragmentPageAdapter;

@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.product_v2_activity);

    // Get product id, product position and product ID Array passed from ExploreFragment.java
    Bundle extras = this.getIntent().getExtras();
    this.productId   = extras.getInt("target_product_id");
    this.prdPosition = extras.getInt("position");
    this.productIdArray = extras.getStringArrayList("productIdArray");
    this.pageArg = extras.getString("page_argument");
    this.productIdArraySize = productIdArray.size();

    // Initialise ViewPager
    viewPager = (ViewPager) findViewById(R.id.pager);

    // Get ProductID array size
    NUM_ITEMS = productIdArray.size();

    // Calling inner class function to initialize adapter and
    // setAdapter()
    initializeAdapter(prdPosition);

    // set number of page instances(fragment) to kept in memory
    viewPager.setOffscreenPageLimit(1);

    // make a trick by making padding between pages inside view-pager
    // fill-in the padding with black color
    viewPager.setPageMargin(60);
    viewPager.setPageMarginDrawable(R.color.black);

    this.viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        int prevPage = prdPosition;
        @Override
        public void onPageSelected(int position) {

            int newPosition = 0;

            // Detect swipe gesture to right or left
            // Move to Right
            if (position-1 == prevPage)
            {
                System.out.println("Swipe-Direction : Move to RIGHT (+1) " + position);
                prevPage = position;
            }

            // Move to Left
            if (position +1 == prevPage)
            {
                System.out.println("Swipe-Direction : Move to LEFT (-1) "  + position);
                prevPage = position;
            }

            // reinitialize adapter to create a new fragment 
            initializeAdapter(position);
            System.out.println("Swipe-Direction :- Current Position : " + position);

        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });

}

/**
 * Function to initialise and setAdapter for
 */
private void initializeAdapter(int position)
{
    Integer newProductId = Product.ProductStoredID.getProductIdOnPosition(position, pageArg);

    // initialize adapter
    productV2FragmentPageAdapter = new ProductV2FragmentPageAdapter(getSupportFragmentManager(), newProductId, position);

    viewPager.setAdapter(productV2FragmentPageAdapter);

    // displaying selected Product based on its position
    viewPager.setCurrentItem(position);
}

/**
 * A simple pager adapter that represents product {@link ProductV2SlidePageFragment} objects, in
 * sequence.
 *
 * FragmentStatePagerAdapter consumes less memory, it's perfect in the case where number of pages is high or undetermined
 */
private class ProductV2FragmentPageAdapter extends FragmentStatePagerAdapter
{
    private int productID;
    private int productPosition;

    public ProductV2FragmentPageAdapter(FragmentManager fm, Integer productId, Integer prdPosition) {
        super(fm);
        this.productID = productId;
        this.productPosition = prdPosition;
    }

    @Override
    // This method returns the fragment associated with
    // the specific position
    //
    // It is called when the Adapter needs a fragment
    // and it does not exists
    public Fragment getItem(int position) {
        return ProductV2SlidePageFragment.create(productPosition, productID);
    }

    @Override
    public int getCount() {
        return NUM_ITEMS;
    }


} // private class ProductV2FragmentPageAdapter extends FragmentStatePagerAdapter

}
public class ProductV2SlidePageFragment extends Fragment implements View.OnClickListener, HttpRequestInterface
{

public static final String position   = "current_fragment_position";
public static final String product_id = "this_product_id";
protected static final String PRODUCT_DETAIL_CALLER           = "get_product_detail";
protected static final String PRODUCT_DETAIL_SAVED_COLLECTION = "get_who_saved_this_collection";
protected static final String PRODUCT_DETAIL_NEXT_CALLER      = "get_next_product_detail_contents";
protected static final String SET_LOVE_PRODUCT = "love_unlove_product";
protected Integer mPageNumber;
protected static final String VIEW_MORE_IMAGES = "view_more_product_images";
protected static final String VIEW_STORE       = "view_store";
protected static final String VIEW_PROFILE     = "view_profile";
protected static final String LOVE_ITEM        = "love_favorite_item";
protected static final String SAVE_ITEM        = "save_favorite_item";
protected static final String SHARE_ITEM       = "share_favorite_item";
protected static final String DETAILS_ROW      = "get_more_details_info_table_row";
protected static final String SHIPPING_ROW     = "get_shipping_info_details_table_row";
protected static final String BACK = "click_back";
protected LinearLayout fullPageLayout;
protected RelativeLayout middleContentLayout;
protected RelativeLayout storeInfoLayout;
protected Activity activity;
protected Integer productId;
protected Integer prd_ownerid;
protected Boolean isProfileOwner;
protected Boolean isUserLoggedIn;
protected Integer targetUserId;
protected Integer uid = 0;
protected User user;
protected Button pinterestButton;
protected RelativeLayout moreProductImagesLayout; 
protected LinearLayout arrowBackButton; 
protected LinearLayout loveButton; 
protected LinearLayout savesButton; 
protected LinearLayout shareButton; 
protected Button addToCartButton;
protected Button inCartButton;
protected Button disableAddToCartButton;
protected Button addToCartButtonTwo;
protected Button inCartButtonTwo;
protected Button disableAddToCartButtonTwo;
protected LinearLayout viewStoreButton;     
protected LinearLayout viewProfileButton;   
protected RelativeLayout storeLayoutButton; 
protected TextView moreImageNumText;
protected TextView loveText;
protected TextView lovedText;
protected ImageView loveImage;
protected ImageView lovedImage;
protected ImageView primaryProductImage;
protected TextView productName;
protected TextView productPrice;
protected TextView quantityAvailable;
protected ProductVariation productVariation;
protected LinearLayout productVariationSection;
protected LinearLayout firstSpinnerLayout;
protected LinearLayout secondSpinnerLayout;
protected TextView productDetailsDesc;
protected LinearLayout prdDetailsDescRow; 
protected Boolean showMoreFlag = false;   
protected ImageView arrowShowMore;
protected ImageView arrowShowLess;
protected TableRow shippingInfoLayout;  
protected TableLayout shippingPriceLayout;
protected TextView shippingInfoDetails;
protected Boolean showMoreShippingInfoFlag = false;  
protected ImageView arrowShowMoreShipping;
protected ImageView arrowShowLessShipping;
protected List<Product.ProductShipping> productShippingList = new ArrayList<>();
protected ImageView storeAvatarImg;
protected TextView storeName;
protected TextView storeItemCount;
protected GridView productItemGridView;
protected ProductDetailsV2Adapter adapter;
protected SortedMap<Integer, ProductPicked.ProductPickedLite> productItemList = new TreeMap<>();
protected RelativeLayout savedCollection;
protected GridView savedCollectionListView;
protected SavedCollectionAdapter savedCollectionAdapter;
protected ArrayList<Product.whoSavedCollections> savedCollectionList = new ArrayList<>();
protected RelativeLayout productTagsLayout;
protected ArrayList<String> tagNameList = new ArrayList<>();
protected ListView productTagsListView;
protected RelativeLayout similarItemsLayout;
protected GridView similarItemsGridView;
protected ArrayList<Product.ProductSimilarItems> similarItemList = new ArrayList<>();
protected FrameLayout progressBarLayout;
protected ProgressBar progressBar;
protected ProgressBar loveUnloveProgressBar;
protected RelativeLayout bottomProgressBar;  
protected LinearLayout loveUnloveLayout; 
protected Boolean isUpdateRequired = true;
protected PullToRefreshLayout pullToRefreshLayout;
protected RatingBar ratingBar;
protected TextView rateInFraction;
protected TextView totalReviews;

public static ProductV2SlidePageFragment create(int pageNumber,int productId)
{
    ProductV2SlidePageFragment fragment = new ProductV2SlidePageFragment();

    Bundle args = new Bundle();
    args.putInt(position, pageNumber);
    args.putInt(product_id, productId);
    fragment.setArguments(args);
    return fragment;
}

public void onAttach(Activity act)
{
    super.onAttach(act);
    activity = act;
}

@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    mPageNumber = getArguments().getInt(position);
    productId   = getArguments().getInt(product_id);
    this.user = User.getLoggedInUser();
    this.isUserLoggedIn = (this.user != null);
    if (isUserLoggedIn) {
        this.uid = user.getUid();
    }

    this.isProfileOwner = (this.uid.equals(targetUserId));
    this.adapter = new ProductDetailsV2Adapter(activity, productItemList);
    this.savedCollectionAdapter = new SavedCollectionAdapter(activity,savedCollectionList);
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
    final View swipeView = inflater.inflate(R.layout.product_v2_screen_slide_page, container, false);
    this.fullPageLayout = (LinearLayout) swipeView.findViewById(R.id.full_layout_container);
    this.middleContentLayout = (RelativeLayout) swipeView.findViewById(R.id.product_detail_middle_section);
    this.storeInfoLayout     = (RelativeLayout) swipeView.findViewById(R.id.store_info_layout);
    this.primaryProductImage = (ImageView) swipeView.findViewById(R.id.primary_product_image);
    this.moreImageNumText = (TextView) swipeView.findViewById(R.id.multiple_image_number);
    this.loveText  = (TextView) swipeView.findViewById(R.id.love_textview);
    this.lovedText = (TextView) swipeView.findViewById(R.id.loved_textview);
    this.loveImage  = (ImageView) swipeView.findViewById(R.id.love_pink_icon);
    this.lovedImage = (ImageView) swipeView.findViewById(R.id.love_fully_pink_icon);
    this.productName  = (TextView) swipeView.findViewById(R.id.product_name);
    this.productPrice = (TextView) swipeView.findViewById(R.id.product_price);
    this.quantityAvailable = (TextView) swipeView.findViewById(R.id.prd_available_quantity);
    this.productVariationSection = (LinearLayout) swipeView.findViewById(R.id.product_variation_section);
    this.firstSpinnerLayout  = (LinearLayout) swipeView.findViewById(R.id.first_spinner_layout);
    this.secondSpinnerLayout = (LinearLayout) swipeView.findViewById(R.id.second_spinner_layout);
    this.pinterestButton = (Button) swipeView.findViewById(R.id.pinterest_button);
    this.moreProductImagesLayout = (RelativeLayout) swipeView.findViewById(R.id.view_more_images_layout);
    this.arrowBackButton = (LinearLayout) swipeView.findViewById(R.id.arrow_left_back_layout);
    this.loveButton = (LinearLayout) swipeView.findViewById(R.id.love_button);
    this.savesButton = (LinearLayout) swipeView.findViewById(R.id.save_button);
    this.shareButton = (LinearLayout) swipeView.findViewById(R.id.share_button);
    this.addToCartButton = (Button) swipeView.findViewById(R.id.prd_detail_btn_add_to_cart);
    this.inCartButton = (Button) swipeView.findViewById(R.id.prd_detail_btn_in_cart);
    this.disableAddToCartButton = (Button) swipeView.findViewById(R.id.prd_detail_btn_add_to_cart_disable);
    this.addToCartButtonTwo = (Button) swipeView.findViewById(R.id.prd_detail_btn_add_to_cart_two);
    this.inCartButtonTwo = (Button) swipeView.findViewById(R.id.prd_detail_btn_in_cart_two);
    this.disableAddToCartButtonTwo = (Button) swipeView.findViewById(R.id.prd_detail_btn_add_to_cart_disable_two);
    this.viewStoreButton = (LinearLayout) swipeView.findViewById(R.id.view_store_btn);
    this.viewProfileButton = (LinearLayout) swipeView.findViewById(R.id.view_profile_btn);
    this.storeLayoutButton = (RelativeLayout) swipeView.findViewById(R.id.store_info_details);

    this.productDetailsDesc = (TextView) swipeView.findViewById(R.id.details_description);

    this.prdDetailsDescRow  = (LinearLayout) swipeView.findViewById(R.id.detail_desc_with_arrow_layout); // 'Details' table row that enable to click for more details
    this.shippingInfoLayout = (TableRow) swipeView.findViewById(R.id.shipping_second_row); // 'Shipping' table row that enable to click for more details
    this.shippingPriceLayout = (TableLayout) swipeView.findViewById(R.id.shipping_price_layout);
    this.arrowShowMore = (ImageView) swipeView.findViewById(R.id.arrow_down_show_more);
    this.arrowShowLess = (ImageView) swipeView.findViewById(R.id.arrow_up_show_less);
    this.arrowShowMoreShipping = (ImageView) swipeView.findViewById(R.id.shipping_arrow_down_show_more);
    this.arrowShowLessShipping = (ImageView) swipeView.findViewById(R.id.shipping_arrow_up_show_less);
    this.shippingInfoDetails = (TextView) swipeView.findViewById(R.id.shipping_info_description);
    this.storeAvatarImg = (ImageView) swipeView.findViewById(R.id.store_image);
    this.storeName = (TextView) swipeView.findViewById(R.id.prd_detail_store_name);
    this.storeItemCount = (TextView) swipeView.findViewById(R.id.prd_detail_store_item_count);
    this.productItemGridView = (GridView) swipeView.findViewById(R.id.prd_item_grid_view);
    this.productItemGridView.setAdapter(adapter);
    this.productItemGridView.setFocusable(false);

    this.progressBarLayout = (FrameLayout) swipeView.findViewById(R.id.product_details_progress_bar_layout);
    this.progressBar = (ProgressBar) swipeView.findViewById(R.id.product_details_progress_bar);
    this.loveUnloveProgressBar = (ProgressBar) swipeView.findViewById(R.id.love_unlove_progress_bar);
    this.bottomProgressBar = (RelativeLayout) swipeView.findViewById(R.id.bottom_progress_bar_layout);
    this.loveUnloveLayout = (LinearLayout) swipeView.findViewById(R.id.love_unlove_layout);
    this.ratingBar = (RatingBar) swipeView.findViewById(R.id.rating_bar);
    this.rateInFraction = (TextView) swipeView.findViewById(R.id.rating_result);
    this.totalReviews = (TextView) swipeView.findViewById(R.id.rating_reviews);
    this.savedCollection = (RelativeLayout) swipeView.findViewById(R.id.who_saved_this_container);
    this.savedCollectionListView = (GridView) swipeView.findViewById(R.id.saved_collection_list_view);
    this.savedCollectionListView.setAdapter(savedCollectionAdapter);

    this.moreProductImagesLayout.setTag(VIEW_MORE_IMAGES);
    this.viewStoreButton.setTag(VIEW_STORE);
    this.viewProfileButton.setTag(VIEW_PROFILE);
    this.storeLayoutButton.setTag(VIEW_STORE);
    this.loveButton.setTag(LOVE_ITEM);
    this.savesButton.setTag(SAVE_ITEM);
    this.shareButton.setTag(SHARE_ITEM);
    this.arrowBackButton.setTag(BACK);
    this.prdDetailsDescRow.setTag(DETAILS_ROW);    
    this.shippingInfoLayout.setTag(SHIPPING_ROW);  

    this.moreProductImagesLayout.setOnClickListener(this);
    this.viewStoreButton.setOnClickListener(this);
    this.viewProfileButton.setOnClickListener(this);
    this.storeLayoutButton.setOnClickListener(this);
    this.loveButton.setOnClickListener(this);
    this.savesButton.setOnClickListener(this);
    this.shareButton.setOnClickListener(this);
    this.prdDetailsDescRow.setOnClickListener(this);
    this.shippingInfoLayout.setOnClickListener(this);
    this.arrowBackButton.setOnClickListener(this);

    LoadProductDetailsAsynTask task = new LoadProductDetailsAsynTask(productId, false);
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

    return swipeView;
}

@Override
public void onClick(View v)
{
    String tag = (String) v.getTag();

    switch (tag)
    {
      // onclick performance 
    }
}

public void ProductDetailsSavedCollectionRequest(int product_id)
{
    Integer productId = product_id;
    String uid = "";
    String accessKey = "";
    String baseUrl = Utility.getBaseUrl(activity.getApplicationContext());

    if(isUserLoggedIn){
        uid = user.getUid().toString();
        accessKey = user.getAccessKey();
    }

    List<NameValuePair> gParams = new ArrayList<>();
    gParams.add(new BasicNameValuePair("api_key", Utility.getPublicKey()));         
    gParams.add(new BasicNameValuePair("caller", PRODUCT_DETAIL_SAVED_COLLECTION)); 
    gParams.add(new BasicNameValuePair("uid", uid));                                
    gParams.add(new BasicNameValuePair("access_key", accessKey));                   
    gParams.add(new BasicNameValuePair("productId", productId.toString()));         

    HttpRequestController httpClient = new HttpRequestController(ProductV2SlidePageFragment.this);
    String httpURL = "http://" + baseUrl +"/mobile/js/android/v1/product_v2/get_product_details_saved_collection";
    httpClient.performAsynRequest(httpURL, gParams);
}

public void ProductDetailsNextRequest(int product_id, int product_nid, int cat)
{
    Integer productId  = product_id;
    Integer productNID = product_nid;
    Integer category   = cat;
    String uid = "";
    String accessKey = "";
    String baseUrl = Utility.getBaseUrl(activity.getApplicationContext());

    if(isUserLoggedIn){
        uid = user.getUid().toString();
        accessKey = user.getAccessKey();
    }

    List<NameValuePair> gParams = new ArrayList<>();
    gParams.add(new BasicNameValuePair("api_key", Utility.getPublicKey())); 
    gParams.add(new BasicNameValuePair("caller", PRODUCT_DETAIL_NEXT_CALLER));
    gParams.add(new BasicNameValuePair("access_key", accessKey));               
    gParams.add(new BasicNameValuePair("productId", productId.toString()));     
    gParams.add(new BasicNameValuePair("productNid", productNID.toString()));   
    gParams.add(new BasicNameValuePair("category", category.toString()));       

    HttpRequestController httpClient = new HttpRequestController(ProductV2SlidePageFragment.this);
    String httpURL = "http://" + baseUrl +"/mobile/js/android/v1/product_v2/get_product_details_next_contents";
    httpClient.performAsynRequest(httpURL, gParams);

    bottomProgressBar.setVisibility(View.VISIBLE);
}

private class LoadProductDetailsAsynTask extends AsyncTask<Void, Void, Void>
{
    Integer productId;
    String baseUrl;
    Boolean isForceRefresh;
    String uid = "";
    String accessKey = "";

    public LoadProductDetailsAsynTask(Integer productId, Boolean isForceRefresh)
    {
        this.productId = productId;
        this.baseUrl = Utility.getBaseUrl(activity.getApplicationContext());
        this.isForceRefresh = isForceRefresh;
        if(isUserLoggedIn){
            this.uid = user.getUid().toString();
            this.accessKey = user.getAccessKey();
        }
    }

    @Override
    protected Void doInBackground(Void... params)
    {
        List<NameValuePair> gParams = new ArrayList<>();
        gParams.add(new BasicNameValuePair("api_key", Utility.getPublicKey()));    
        gParams.add(new BasicNameValuePair("caller", PRODUCT_DETAIL_CALLER));       
        gParams.add(new BasicNameValuePair("uid", uid));                            
        gParams.add(new BasicNameValuePair("access_key", accessKey));               
        gParams.add(new BasicNameValuePair("productId", productId.toString()));     
        gParams.add(new BasicNameValuePair("provider_type", "hugerect"));           

        HttpRequestController httpClient = new HttpRequestController(ProductV2SlidePageFragment.this);
        String httpURL = "http://" + baseUrl +"/mobile/js/android/v1/product_v2/get_product_details";
        httpClient.performAsynRequest(httpURL, gParams);

        return null;
    }
} 

@Override
public void HttpRequestPreExecute(String caller) {
}

@Override
public void HttpRequestDoInBackground(HttpReturnObject response) {
}

@Override
public void HttpRequestDoInBackgroundError(HttpReturnObject response) {
}

@Override
public void HttpRequestProgressUpdate(HttpReturnObject response) {
}

@Override
public void HttpRequestOnPostExecuteUpdate(HttpReturnObject response)
{
    try
    {
        JSONObject responseJson = response.getJSON();
        Integer statusCode = responseJson.getInt("status_code");

        switch (statusCode)
        {
            case 200:
                JSONObject returnVars = responseJson.getJSONObject("return_vars");

                String caller = responseJson.getString("caller");
                if(!returnVars.has("error"))
                {
                    switch (caller)
                    {
                        case PRODUCT_DETAIL_CALLER:
                        {
                            // Get all JSON data and 
                            // display details 

                            break;
                        } 

                        case PRODUCT_DETAIL_SAVED_COLLECTION:
                        {
                            // Get all JSON data and 
                            // display details 

                            break;
                        } 

                        case PRODUCT_DETAIL_NEXT_CALLER:
                        {
                            // Get all JSON data and 
                            // display details 

                            break;
                        } 

                        case SET_LOVE_PRODUCT:
                        {
                            break;
                        }

                break;

            case 403:
            default:
                Toast.makeText(activity, "You do not have permission to perform this action.", Toast.LENGTH_LONG).show();
                break;
        }
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }
} 

private void createSnackBar(Snackbar snackbar)
{
    Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout) snackbar.getView();
    layout.setBackgroundColor(Color.parseColor("#F50057"));

    TextView snackBarText = (TextView) layout.findViewById(android.support.design.R.id.snackbar_text);
    snackBarText.setTextColor(getResources().getColor(R.color.white));
    snackBarText.setTextSize(16);
    snackBarText.setGravity(Gravity.CENTER_HORIZONTAL);
    snackbar.show();
}

private void setProductRating(double totalRating, Integer totalReview)
{
    LayerDrawable stars = (LayerDrawable) ratingBar.getProgressDrawable();

    String reviews = "("+totalReview+" reviews)";

    String rate = totalRating+" / 5";

    ratingBar.setRating((float) totalRating);

    rateInFraction.setText(rate);
    totalReviews.setText(reviews);
}


private class ProductDetailsV2Adapter extends BaseAdapter
{
    private SortedMap<Integer,ProductPicked.ProductPickedLite> data;
    private LayoutInflater inflater;
    private ImageHandler image;

    public ProductDetailsV2Adapter(Activity activity, SortedMap<Integer, ProductPicked.ProductPickedLite> productItemList)
    {
        this.data = productItemList;
        this.inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        this.image = new ImageHandler(activity, ImageHandler.ScaleType.PICKED_PRODUCT);
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    public String getProductImage(int position)
    {
        return data.get(position).getImageSource();
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder;

        if(convertView==null)
        {
            holder = new ViewHolder();
            holder.imageView = (ImageView) convertView.findViewById(R.id.grid_view_image);
            convertView.setTag(holder);
        }
        else
        {
            holder = (ViewHolder) convertView.getTag();
        }

        String prdImageSource = getProductImage(position);
        holder.imageView.setTag(prdImageSource);
        image.displayImage(prdImageSource, holder.imageView, null);

        return convertView;
    }

    public class ViewHolder
    {
        ImageView imageView;
    }

    public void setMap(SortedMap<Integer,ProductPicked.ProductPickedLite> d)
    {
        data = d;
    }

} 

}
公共类ProductV2Activity扩展了碎片活动
{
受保护的整数productId;
保护整数位置;
受保护的阵列列表产品阵列;
受保护的字符串pageArg;
受保护的整数productiArraysize;
受保护的静态整数NUM_项;
受保护的ViewPager ViewPager;
受保护的ProductV2FragmentPageAdapter ProductV2FragmentPageAdapter;
@凌驾
创建时受保护的void(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.product_v2_活动);
//获取从ExploreFragment.java传递的产品id、产品位置和产品id数组
Bundle extras=this.getIntent().getExtras();
this.productId=extras.getInt(“目标产品id”);
this.prdPosition=extras.getInt(“位置”);
this.productIdArray=extras.getStringArrayList(“productIdArray”);
this.pageArg=extras.getString(“page_参数”);
this.productIdArraySize=productIdArray.size();
//初始化视图寻呼机
viewPager=(viewPager)findViewById(R.id.pager);
//获取ProductID数组大小
NUM_ITEMS=productIdArray.size();
//调用内部类函数初始化适配器和
//setAdapter()
初始化适配器(prdPosition);
//设置要保留在内存中的页实例(片段)数
viewPager.setOffscreenPageLimit(1);
//在“查看寻呼机”内的页面之间进行填充,从而实现一个技巧
//用黑色填充填充物
viewPager.setPageMargin(60);
viewPager.setPageMarginDrawable(R.color.black);
this.viewPager.addOnPageChangeListener(新的viewPager.OnPageChangeListener(){
@凌驾
已滚动页面上的公共无效(int-position、float-positionOffset、int-positionOffsetPixels){
}
int prevPage=prdPosition;
@凌驾
已选择页面上的公共无效(内部位置){
int newPosition=0;
//检测向右或向左的滑动手势
//向右移动
如果(位置-1==上一页)
{
System.out.println(“滑动方向:向右移动(+1)”+位置);
前页=位置;
}
//向左移动
如果(位置+1==上一页)
{
System.out.println(“滑动方向:向左移动(-1)”+位置);
前页=位置;
}
//重新初始化适配器以创建新片段
初始化适配器(位置);
System.out.println(“滑动方向:-当前位置:+位置”);
}
@凌驾
公共无效onPageScrollStateChanged(int状态){
}
});
}
/**
*用于初始化和设置适配器的函数
*/
私有void初始化适配器(内部位置)
{
整数newProductId=Product.ProductStoredID.getProductIdOnPosition(位置,pageArg);
//初始化适配器
productV2FragmentPageAdapter=新的productV2FragmentPageAdapter(getSupportFragmentManager(),newProductId,position);
setAdapter(productV2FragmentPageAdapter);
//根据所选产品的位置显示所选产品
viewPager.setCurrentItem(位置);
}
/**
*一个简单的寻呼机适配器,表示产品{@link ProductV2SlidePageFragment}对象,在
*顺序。
*
*FragmentStatePagerAdapter消耗更少的内存,在页面数量较多或不确定的情况下非常适合
*/
私有类ProductV2FragmentPageAdapter扩展了FragmentStatePagerAdapter
{
私有int-productID;
私人职位;
公共产品v2FragmentPageAdapter(FragmentManager fm、整数productId、整数prdPosition){
超级(fm);
this.productID=productID;
this.productPosition=prdPosition;
}
@凌驾
//此方法返回与关联的片段
//具体位置
//
//当适配器需要片段时调用它
//它并不存在
公共片段getItem(int位置){
返回ProductV2SlidePageFragment.create(productPosition,productID);
}
@凌驾
public int getCount(){
返回NUM_项;
}
}//私有类ProductV2FragmentPageAdapter扩展了FragmentStatePagerAdapter
}
下面是片段:

public class ProductV2Activity extends FragmentActivity
{

protected Integer productId;
protected Integer prdPosition;
protected ArrayList<String> productIdArray; 
protected String pageArg;
protected Integer productIdArraySize;
protected static Integer NUM_ITEMS;
protected ViewPager viewPager;
protected ProductV2FragmentPageAdapter productV2FragmentPageAdapter;

@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.product_v2_activity);

    // Get product id, product position and product ID Array passed from ExploreFragment.java
    Bundle extras = this.getIntent().getExtras();
    this.productId   = extras.getInt("target_product_id");
    this.prdPosition = extras.getInt("position");
    this.productIdArray = extras.getStringArrayList("productIdArray");
    this.pageArg = extras.getString("page_argument");
    this.productIdArraySize = productIdArray.size();

    // Initialise ViewPager
    viewPager = (ViewPager) findViewById(R.id.pager);

    // Get ProductID array size
    NUM_ITEMS = productIdArray.size();

    // Calling inner class function to initialize adapter and
    // setAdapter()
    initializeAdapter(prdPosition);

    // set number of page instances(fragment) to kept in memory
    viewPager.setOffscreenPageLimit(1);

    // make a trick by making padding between pages inside view-pager
    // fill-in the padding with black color
    viewPager.setPageMargin(60);
    viewPager.setPageMarginDrawable(R.color.black);

    this.viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        int prevPage = prdPosition;
        @Override
        public void onPageSelected(int position) {

            int newPosition = 0;

            // Detect swipe gesture to right or left
            // Move to Right
            if (position-1 == prevPage)
            {
                System.out.println("Swipe-Direction : Move to RIGHT (+1) " + position);
                prevPage = position;
            }

            // Move to Left
            if (position +1 == prevPage)
            {
                System.out.println("Swipe-Direction : Move to LEFT (-1) "  + position);
                prevPage = position;
            }

            // reinitialize adapter to create a new fragment 
            initializeAdapter(position);
            System.out.println("Swipe-Direction :- Current Position : " + position);

        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });

}

/**
 * Function to initialise and setAdapter for
 */
private void initializeAdapter(int position)
{
    Integer newProductId = Product.ProductStoredID.getProductIdOnPosition(position, pageArg);

    // initialize adapter
    productV2FragmentPageAdapter = new ProductV2FragmentPageAdapter(getSupportFragmentManager(), newProductId, position);

    viewPager.setAdapter(productV2FragmentPageAdapter);

    // displaying selected Product based on its position
    viewPager.setCurrentItem(position);
}

/**
 * A simple pager adapter that represents product {@link ProductV2SlidePageFragment} objects, in
 * sequence.
 *
 * FragmentStatePagerAdapter consumes less memory, it's perfect in the case where number of pages is high or undetermined
 */
private class ProductV2FragmentPageAdapter extends FragmentStatePagerAdapter
{
    private int productID;
    private int productPosition;

    public ProductV2FragmentPageAdapter(FragmentManager fm, Integer productId, Integer prdPosition) {
        super(fm);
        this.productID = productId;
        this.productPosition = prdPosition;
    }

    @Override
    // This method returns the fragment associated with
    // the specific position
    //
    // It is called when the Adapter needs a fragment
    // and it does not exists
    public Fragment getItem(int position) {
        return ProductV2SlidePageFragment.create(productPosition, productID);
    }

    @Override
    public int getCount() {
        return NUM_ITEMS;
    }


} // private class ProductV2FragmentPageAdapter extends FragmentStatePagerAdapter

}
public class ProductV2SlidePageFragment extends Fragment implements View.OnClickListener, HttpRequestInterface
{

public static final String position   = "current_fragment_position";
public static final String product_id = "this_product_id";
protected static final String PRODUCT_DETAIL_CALLER           = "get_product_detail";
protected static final String PRODUCT_DETAIL_SAVED_COLLECTION = "get_who_saved_this_collection";
protected static final String PRODUCT_DETAIL_NEXT_CALLER      = "get_next_product_detail_contents";
protected static final String SET_LOVE_PRODUCT = "love_unlove_product";
protected Integer mPageNumber;
protected static final String VIEW_MORE_IMAGES = "view_more_product_images";
protected static final String VIEW_STORE       = "view_store";
protected static final String VIEW_PROFILE     = "view_profile";
protected static final String LOVE_ITEM        = "love_favorite_item";
protected static final String SAVE_ITEM        = "save_favorite_item";
protected static final String SHARE_ITEM       = "share_favorite_item";
protected static final String DETAILS_ROW      = "get_more_details_info_table_row";
protected static final String SHIPPING_ROW     = "get_shipping_info_details_table_row";
protected static final String BACK = "click_back";
protected LinearLayout fullPageLayout;
protected RelativeLayout middleContentLayout;
protected RelativeLayout storeInfoLayout;
protected Activity activity;
protected Integer productId;
protected Integer prd_ownerid;
protected Boolean isProfileOwner;
protected Boolean isUserLoggedIn;
protected Integer targetUserId;
protected Integer uid = 0;
protected User user;
protected Button pinterestButton;
protected RelativeLayout moreProductImagesLayout; 
protected LinearLayout arrowBackButton; 
protected LinearLayout loveButton; 
protected LinearLayout savesButton; 
protected LinearLayout shareButton; 
protected Button addToCartButton;
protected Button inCartButton;
protected Button disableAddToCartButton;
protected Button addToCartButtonTwo;
protected Button inCartButtonTwo;
protected Button disableAddToCartButtonTwo;
protected LinearLayout viewStoreButton;     
protected LinearLayout viewProfileButton;   
protected RelativeLayout storeLayoutButton; 
protected TextView moreImageNumText;
protected TextView loveText;
protected TextView lovedText;
protected ImageView loveImage;
protected ImageView lovedImage;
protected ImageView primaryProductImage;
protected TextView productName;
protected TextView productPrice;
protected TextView quantityAvailable;
protected ProductVariation productVariation;
protected LinearLayout productVariationSection;
protected LinearLayout firstSpinnerLayout;
protected LinearLayout secondSpinnerLayout;
protected TextView productDetailsDesc;
protected LinearLayout prdDetailsDescRow; 
protected Boolean showMoreFlag = false;   
protected ImageView arrowShowMore;
protected ImageView arrowShowLess;
protected TableRow shippingInfoLayout;  
protected TableLayout shippingPriceLayout;
protected TextView shippingInfoDetails;
protected Boolean showMoreShippingInfoFlag = false;  
protected ImageView arrowShowMoreShipping;
protected ImageView arrowShowLessShipping;
protected List<Product.ProductShipping> productShippingList = new ArrayList<>();
protected ImageView storeAvatarImg;
protected TextView storeName;
protected TextView storeItemCount;
protected GridView productItemGridView;
protected ProductDetailsV2Adapter adapter;
protected SortedMap<Integer, ProductPicked.ProductPickedLite> productItemList = new TreeMap<>();
protected RelativeLayout savedCollection;
protected GridView savedCollectionListView;
protected SavedCollectionAdapter savedCollectionAdapter;
protected ArrayList<Product.whoSavedCollections> savedCollectionList = new ArrayList<>();
protected RelativeLayout productTagsLayout;
protected ArrayList<String> tagNameList = new ArrayList<>();
protected ListView productTagsListView;
protected RelativeLayout similarItemsLayout;
protected GridView similarItemsGridView;
protected ArrayList<Product.ProductSimilarItems> similarItemList = new ArrayList<>();
protected FrameLayout progressBarLayout;
protected ProgressBar progressBar;
protected ProgressBar loveUnloveProgressBar;
protected RelativeLayout bottomProgressBar;  
protected LinearLayout loveUnloveLayout; 
protected Boolean isUpdateRequired = true;
protected PullToRefreshLayout pullToRefreshLayout;
protected RatingBar ratingBar;
protected TextView rateInFraction;
protected TextView totalReviews;

public static ProductV2SlidePageFragment create(int pageNumber,int productId)
{
    ProductV2SlidePageFragment fragment = new ProductV2SlidePageFragment();

    Bundle args = new Bundle();
    args.putInt(position, pageNumber);
    args.putInt(product_id, productId);
    fragment.setArguments(args);
    return fragment;
}

public void onAttach(Activity act)
{
    super.onAttach(act);
    activity = act;
}

@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    mPageNumber = getArguments().getInt(position);
    productId   = getArguments().getInt(product_id);
    this.user = User.getLoggedInUser();
    this.isUserLoggedIn = (this.user != null);
    if (isUserLoggedIn) {
        this.uid = user.getUid();
    }

    this.isProfileOwner = (this.uid.equals(targetUserId));
    this.adapter = new ProductDetailsV2Adapter(activity, productItemList);
    this.savedCollectionAdapter = new SavedCollectionAdapter(activity,savedCollectionList);
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
    final View swipeView = inflater.inflate(R.layout.product_v2_screen_slide_page, container, false);
    this.fullPageLayout = (LinearLayout) swipeView.findViewById(R.id.full_layout_container);
    this.middleContentLayout = (RelativeLayout) swipeView.findViewById(R.id.product_detail_middle_section);
    this.storeInfoLayout     = (RelativeLayout) swipeView.findViewById(R.id.store_info_layout);
    this.primaryProductImage = (ImageView) swipeView.findViewById(R.id.primary_product_image);
    this.moreImageNumText = (TextView) swipeView.findViewById(R.id.multiple_image_number);
    this.loveText  = (TextView) swipeView.findViewById(R.id.love_textview);
    this.lovedText = (TextView) swipeView.findViewById(R.id.loved_textview);
    this.loveImage  = (ImageView) swipeView.findViewById(R.id.love_pink_icon);
    this.lovedImage = (ImageView) swipeView.findViewById(R.id.love_fully_pink_icon);
    this.productName  = (TextView) swipeView.findViewById(R.id.product_name);
    this.productPrice = (TextView) swipeView.findViewById(R.id.product_price);
    this.quantityAvailable = (TextView) swipeView.findViewById(R.id.prd_available_quantity);
    this.productVariationSection = (LinearLayout) swipeView.findViewById(R.id.product_variation_section);
    this.firstSpinnerLayout  = (LinearLayout) swipeView.findViewById(R.id.first_spinner_layout);
    this.secondSpinnerLayout = (LinearLayout) swipeView.findViewById(R.id.second_spinner_layout);
    this.pinterestButton = (Button) swipeView.findViewById(R.id.pinterest_button);
    this.moreProductImagesLayout = (RelativeLayout) swipeView.findViewById(R.id.view_more_images_layout);
    this.arrowBackButton = (LinearLayout) swipeView.findViewById(R.id.arrow_left_back_layout);
    this.loveButton = (LinearLayout) swipeView.findViewById(R.id.love_button);
    this.savesButton = (LinearLayout) swipeView.findViewById(R.id.save_button);
    this.shareButton = (LinearLayout) swipeView.findViewById(R.id.share_button);
    this.addToCartButton = (Button) swipeView.findViewById(R.id.prd_detail_btn_add_to_cart);
    this.inCartButton = (Button) swipeView.findViewById(R.id.prd_detail_btn_in_cart);
    this.disableAddToCartButton = (Button) swipeView.findViewById(R.id.prd_detail_btn_add_to_cart_disable);
    this.addToCartButtonTwo = (Button) swipeView.findViewById(R.id.prd_detail_btn_add_to_cart_two);
    this.inCartButtonTwo = (Button) swipeView.findViewById(R.id.prd_detail_btn_in_cart_two);
    this.disableAddToCartButtonTwo = (Button) swipeView.findViewById(R.id.prd_detail_btn_add_to_cart_disable_two);
    this.viewStoreButton = (LinearLayout) swipeView.findViewById(R.id.view_store_btn);
    this.viewProfileButton = (LinearLayout) swipeView.findViewById(R.id.view_profile_btn);
    this.storeLayoutButton = (RelativeLayout) swipeView.findViewById(R.id.store_info_details);

    this.productDetailsDesc = (TextView) swipeView.findViewById(R.id.details_description);

    this.prdDetailsDescRow  = (LinearLayout) swipeView.findViewById(R.id.detail_desc_with_arrow_layout); // 'Details' table row that enable to click for more details
    this.shippingInfoLayout = (TableRow) swipeView.findViewById(R.id.shipping_second_row); // 'Shipping' table row that enable to click for more details
    this.shippingPriceLayout = (TableLayout) swipeView.findViewById(R.id.shipping_price_layout);
    this.arrowShowMore = (ImageView) swipeView.findViewById(R.id.arrow_down_show_more);
    this.arrowShowLess = (ImageView) swipeView.findViewById(R.id.arrow_up_show_less);
    this.arrowShowMoreShipping = (ImageView) swipeView.findViewById(R.id.shipping_arrow_down_show_more);
    this.arrowShowLessShipping = (ImageView) swipeView.findViewById(R.id.shipping_arrow_up_show_less);
    this.shippingInfoDetails = (TextView) swipeView.findViewById(R.id.shipping_info_description);
    this.storeAvatarImg = (ImageView) swipeView.findViewById(R.id.store_image);
    this.storeName = (TextView) swipeView.findViewById(R.id.prd_detail_store_name);
    this.storeItemCount = (TextView) swipeView.findViewById(R.id.prd_detail_store_item_count);
    this.productItemGridView = (GridView) swipeView.findViewById(R.id.prd_item_grid_view);
    this.productItemGridView.setAdapter(adapter);
    this.productItemGridView.setFocusable(false);

    this.progressBarLayout = (FrameLayout) swipeView.findViewById(R.id.product_details_progress_bar_layout);
    this.progressBar = (ProgressBar) swipeView.findViewById(R.id.product_details_progress_bar);
    this.loveUnloveProgressBar = (ProgressBar) swipeView.findViewById(R.id.love_unlove_progress_bar);
    this.bottomProgressBar = (RelativeLayout) swipeView.findViewById(R.id.bottom_progress_bar_layout);
    this.loveUnloveLayout = (LinearLayout) swipeView.findViewById(R.id.love_unlove_layout);
    this.ratingBar = (RatingBar) swipeView.findViewById(R.id.rating_bar);
    this.rateInFraction = (TextView) swipeView.findViewById(R.id.rating_result);
    this.totalReviews = (TextView) swipeView.findViewById(R.id.rating_reviews);
    this.savedCollection = (RelativeLayout) swipeView.findViewById(R.id.who_saved_this_container);
    this.savedCollectionListView = (GridView) swipeView.findViewById(R.id.saved_collection_list_view);
    this.savedCollectionListView.setAdapter(savedCollectionAdapter);

    this.moreProductImagesLayout.setTag(VIEW_MORE_IMAGES);
    this.viewStoreButton.setTag(VIEW_STORE);
    this.viewProfileButton.setTag(VIEW_PROFILE);
    this.storeLayoutButton.setTag(VIEW_STORE);
    this.loveButton.setTag(LOVE_ITEM);
    this.savesButton.setTag(SAVE_ITEM);
    this.shareButton.setTag(SHARE_ITEM);
    this.arrowBackButton.setTag(BACK);
    this.prdDetailsDescRow.setTag(DETAILS_ROW);    
    this.shippingInfoLayout.setTag(SHIPPING_ROW);  

    this.moreProductImagesLayout.setOnClickListener(this);
    this.viewStoreButton.setOnClickListener(this);
    this.viewProfileButton.setOnClickListener(this);
    this.storeLayoutButton.setOnClickListener(this);
    this.loveButton.setOnClickListener(this);
    this.savesButton.setOnClickListener(this);
    this.shareButton.setOnClickListener(this);
    this.prdDetailsDescRow.setOnClickListener(this);
    this.shippingInfoLayout.setOnClickListener(this);
    this.arrowBackButton.setOnClickListener(this);

    LoadProductDetailsAsynTask task = new LoadProductDetailsAsynTask(productId, false);
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

    return swipeView;
}

@Override
public void onClick(View v)
{
    String tag = (String) v.getTag();

    switch (tag)
    {
      // onclick performance 
    }
}

public void ProductDetailsSavedCollectionRequest(int product_id)
{
    Integer productId = product_id;
    String uid = "";
    String accessKey = "";
    String baseUrl = Utility.getBaseUrl(activity.getApplicationContext());

    if(isUserLoggedIn){
        uid = user.getUid().toString();
        accessKey = user.getAccessKey();
    }

    List<NameValuePair> gParams = new ArrayList<>();
    gParams.add(new BasicNameValuePair("api_key", Utility.getPublicKey()));         
    gParams.add(new BasicNameValuePair("caller", PRODUCT_DETAIL_SAVED_COLLECTION)); 
    gParams.add(new BasicNameValuePair("uid", uid));                                
    gParams.add(new BasicNameValuePair("access_key", accessKey));                   
    gParams.add(new BasicNameValuePair("productId", productId.toString()));         

    HttpRequestController httpClient = new HttpRequestController(ProductV2SlidePageFragment.this);
    String httpURL = "http://" + baseUrl +"/mobile/js/android/v1/product_v2/get_product_details_saved_collection";
    httpClient.performAsynRequest(httpURL, gParams);
}

public void ProductDetailsNextRequest(int product_id, int product_nid, int cat)
{
    Integer productId  = product_id;
    Integer productNID = product_nid;
    Integer category   = cat;
    String uid = "";
    String accessKey = "";
    String baseUrl = Utility.getBaseUrl(activity.getApplicationContext());

    if(isUserLoggedIn){
        uid = user.getUid().toString();
        accessKey = user.getAccessKey();
    }

    List<NameValuePair> gParams = new ArrayList<>();
    gParams.add(new BasicNameValuePair("api_key", Utility.getPublicKey())); 
    gParams.add(new BasicNameValuePair("caller", PRODUCT_DETAIL_NEXT_CALLER));
    gParams.add(new BasicNameValuePair("access_key", accessKey));               
    gParams.add(new BasicNameValuePair("productId", productId.toString()));     
    gParams.add(new BasicNameValuePair("productNid", productNID.toString()));   
    gParams.add(new BasicNameValuePair("category", category.toString()));       

    HttpRequestController httpClient = new HttpRequestController(ProductV2SlidePageFragment.this);
    String httpURL = "http://" + baseUrl +"/mobile/js/android/v1/product_v2/get_product_details_next_contents";
    httpClient.performAsynRequest(httpURL, gParams);

    bottomProgressBar.setVisibility(View.VISIBLE);
}

private class LoadProductDetailsAsynTask extends AsyncTask<Void, Void, Void>
{
    Integer productId;
    String baseUrl;
    Boolean isForceRefresh;
    String uid = "";
    String accessKey = "";

    public LoadProductDetailsAsynTask(Integer productId, Boolean isForceRefresh)
    {
        this.productId = productId;
        this.baseUrl = Utility.getBaseUrl(activity.getApplicationContext());
        this.isForceRefresh = isForceRefresh;
        if(isUserLoggedIn){
            this.uid = user.getUid().toString();
            this.accessKey = user.getAccessKey();
        }
    }

    @Override
    protected Void doInBackground(Void... params)
    {
        List<NameValuePair> gParams = new ArrayList<>();
        gParams.add(new BasicNameValuePair("api_key", Utility.getPublicKey()));    
        gParams.add(new BasicNameValuePair("caller", PRODUCT_DETAIL_CALLER));       
        gParams.add(new BasicNameValuePair("uid", uid));                            
        gParams.add(new BasicNameValuePair("access_key", accessKey));               
        gParams.add(new BasicNameValuePair("productId", productId.toString()));     
        gParams.add(new BasicNameValuePair("provider_type", "hugerect"));           

        HttpRequestController httpClient = new HttpRequestController(ProductV2SlidePageFragment.this);
        String httpURL = "http://" + baseUrl +"/mobile/js/android/v1/product_v2/get_product_details";
        httpClient.performAsynRequest(httpURL, gParams);

        return null;
    }
} 

@Override
public void HttpRequestPreExecute(String caller) {
}

@Override
public void HttpRequestDoInBackground(HttpReturnObject response) {
}

@Override
public void HttpRequestDoInBackgroundError(HttpReturnObject response) {
}

@Override
public void HttpRequestProgressUpdate(HttpReturnObject response) {
}

@Override
public void HttpRequestOnPostExecuteUpdate(HttpReturnObject response)
{
    try
    {
        JSONObject responseJson = response.getJSON();
        Integer statusCode = responseJson.getInt("status_code");

        switch (statusCode)
        {
            case 200:
                JSONObject returnVars = responseJson.getJSONObject("return_vars");

                String caller = responseJson.getString("caller");
                if(!returnVars.has("error"))
                {
                    switch (caller)
                    {
                        case PRODUCT_DETAIL_CALLER:
                        {
                            // Get all JSON data and 
                            // display details 

                            break;
                        } 

                        case PRODUCT_DETAIL_SAVED_COLLECTION:
                        {
                            // Get all JSON data and 
                            // display details 

                            break;
                        } 

                        case PRODUCT_DETAIL_NEXT_CALLER:
                        {
                            // Get all JSON data and 
                            // display details 

                            break;
                        } 

                        case SET_LOVE_PRODUCT:
                        {
                            break;
                        }

                break;

            case 403:
            default:
                Toast.makeText(activity, "You do not have permission to perform this action.", Toast.LENGTH_LONG).show();
                break;
        }
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }
} 

private void createSnackBar(Snackbar snackbar)
{
    Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout) snackbar.getView();
    layout.setBackgroundColor(Color.parseColor("#F50057"));

    TextView snackBarText = (TextView) layout.findViewById(android.support.design.R.id.snackbar_text);
    snackBarText.setTextColor(getResources().getColor(R.color.white));
    snackBarText.setTextSize(16);
    snackBarText.setGravity(Gravity.CENTER_HORIZONTAL);
    snackbar.show();
}

private void setProductRating(double totalRating, Integer totalReview)
{
    LayerDrawable stars = (LayerDrawable) ratingBar.getProgressDrawable();

    String reviews = "("+totalReview+" reviews)";

    String rate = totalRating+" / 5";

    ratingBar.setRating((float) totalRating);

    rateInFraction.setText(rate);
    totalReviews.setText(reviews);
}


private class ProductDetailsV2Adapter extends BaseAdapter
{
    private SortedMap<Integer,ProductPicked.ProductPickedLite> data;
    private LayoutInflater inflater;
    private ImageHandler image;

    public ProductDetailsV2Adapter(Activity activity, SortedMap<Integer, ProductPicked.ProductPickedLite> productItemList)
    {
        this.data = productItemList;
        this.inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        this.image = new ImageHandler(activity, ImageHandler.ScaleType.PICKED_PRODUCT);
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    public String getProductImage(int position)
    {
        return data.get(position).getImageSource();
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder;

        if(convertView==null)
        {
            holder = new ViewHolder();
            holder.imageView = (ImageView) convertView.findViewById(R.id.grid_view_image);
            convertView.setTag(holder);
        }
        else
        {
            holder = (ViewHolder) convertView.getTag();
        }

        String prdImageSource = getProductImage(position);
        holder.imageView.setTag(prdImageSource);
        image.displayImage(prdImageSource, holder.imageView, null);

        return convertView;
    }

    public class ViewHolder
    {
        ImageView imageView;
    }

    public void setMap(SortedMap<Integer,ProductPicked.ProductPickedLite> d)
    {
        data = d;
    }

} 

}
公共类ProductV2SlidePageFragment扩展片段实现View.OnClickListener,HttpRequestInterface
{
公共静态最终字符串位置=“当前位置”;
公共静态最终字符串product\u id=“this\u product\u id”;
受保护的静态最终字符串PRODUCT\u DETAIL\u CALLER=“get\u PRODUCT\u DETAIL”;
受保护的静态最终字符串产品\u详细信息\u保存的\u集合=“获取\u谁保存的\u此集合”;
受保护的静态最终字符串PRODUCT\u DETAIL\u NEXT\u CALLER=“get\u NEXT\u PRODUCT\u DETAIL\u contents”;
受保护的静态最终字符串集\u LOVE\u PRODUCT=“LOVE\u unlove\u PRODUCT”;
受保护整数个数;
受保护的静态最终字符串VIEW\u MORE\u IMAGES=“VIEW\u MORE\u product\u IMAGES”;
受保护的静态最终字符串VIEW\u STORE=“VIEW\u STORE”;
受保护的静态最终字符串视图\u PROFILE=“查看\u PROFILE”;
受保护的静态最终字符串LOVE\u ITEM=“LOVE\u favorite\u ITEM”;
受保护的静态最终字符串SAVE\u ITEM=“SAVE\u favorite\u ITEM”;
受保护的静态最终字符串SHARE\u ITEM=“SHARE\u favorite\u ITEM”;
受保护的静态最终字符串详细信息\u行=“获取\u更多\u详细信息\u信息\u表\u行”;
受保护的静态最终字符串SHIPPING\u ROW=“get\u SHIPPING\u info\u details\u table\u ROW”;
受保护的静态最终字符串返回=“单击返回”;
受保护的线性布局完整页面布局;
受保护的相对性布局;
受保护的RelativeLayout storeInfoL