Android Open Source - Wardrobe_app Public Stream Fragment






From Project

Back to project page Wardrobe_app.

License

The source code is released under:

Apache License

If you think the Android project Wardrobe_app 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.android.busolo.apps.wardrobe.engine;
/* w  ww.j  a  v  a2s. co m*/
import android.animation.Animator;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.bluetooth.BluetoothAssignedNumbers;
import android.content.Context;
import android.content.DialogInterface;
import android.database.DataSetObserver;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.media.Image;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.util.TypedValue;
import android.view.*;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.TranslateAnimation;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.Filter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.TextView;
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.widget.Toast;

import com.android.busolo.apps.wardrobe.engine.adapter.ColorListAdapter;
import com.android.busolo.apps.wardrobe.engine.adapter.ColorSpinnerAdapter;
import com.android.busolo.apps.wardrobe.engine.model.ColorPicker;
import com.android.busolo.apps.wardrobe.engine.model.FilterParam;
import com.android.busolo.apps.wardrobe.utils.ImageLoader;
import com.android.busolo.apps.wardrobe.utils.UIUtils;
import com.android.busolo.apps.wardrobe.widget.BezelImageView;
import com.android.busolo.apps.wardrobe.widget.EllipsizedTextView;
import com.makeramen.RoundedImageView;

import org.w3c.dom.Text;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

import static com.android.busolo.apps.wardrobe.utils.LogUtils.LOGE;


public class PublicStreamFragment extends Fragment implements
        AbsListView.OnScrollListener, LoaderManager.LoaderCallbacks<ArrayList<String>>,
        AdapterView.OnItemClickListener, View.OnClickListener {

    public static final String KEY_STREAM_TYPE = "stream_type";
    public static final int STREAM_TYPE_PUBLIC = 1;
    public static final int STREAM_TYPE_PRIVATE = 0;
    private static int streamType;

    private static final String TAG_FRAG_FILTER = "filter_fragment";
    private static final String STATE_POSITION = "position";
    private static final String STATE_TOP = "top";

    private static final int POPUP_WINDOW_GENDER = 0;
    private static final int POPUP_WINDOW_ITEM = 1;

    public static final int MENU_GENDER_MALE = 0;
    public static final int MENU_GENDER_FEMALE = 1;
    public static final int MENU_GENDER_UNISEX = 2;
    public static final int MENU_GENDER_ALL = 99;
    private static int MENU_GENDER_SELECTED = -100;

    public static final int MENU_ITEM_ALL = 99;
    public static final int MENU_ITEM_CLOTHES = 0;
    public static final int MENU_ITEM_SHOES = 1;
    public static final int MENU_ITEM_ACCESSORIES = 2;
    private static int MENU_ITEM_SELECTED = -100;

    private static final long MAX_RESULTS_PER_REQUEST = 20;
    private static final int STREAM_LOADER_ID = 0;
    private static final String LOG_TAG = "PublicStreamFragment";

    private String mSearchString;
    private Activity activity;

    ArrayList<String>  mStream = new ArrayList<String>();
    private StreamAdapter mStreamAdapter =  new StreamAdapter();
    private int mListViewStatePosition;
    private int mListViewStateTop;
    private ImageLoader mImageLoader;

    private ListView listView;
    private ProgressBar loading;
    private View section_quick_filter;

    private Button btn_show_item;
    private Button btn_show_gender;
    private Button btn_show_filter;

    private Button popup_gender_all;
    private Button popup_gender_male;
    private Button popup_gender_female;
    private Button popup_gender_unisex;
    private Button popup_item_all;
    private Button popup_item_clothes;
    private Button popup_item_shoes;
    private Button popup_item_accessories;

    private PopupWindow activePopupWindow;
    private FilterStreamFragment filterStreamFragment;

    public PublicStreamFragment(){}

    public static PublicStreamFragment newInstance(int stream_type){
        PublicStreamFragment fragment = new PublicStreamFragment();
        Bundle args = new Bundle();
        args.putInt(KEY_STREAM_TYPE, stream_type);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onAttach(Activity activity){
        super.onAttach(activity);
        this.activity = activity;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setHasOptionsMenu(true);

        if(getArguments() != null){
            streamType = getArguments().getInt(KEY_STREAM_TYPE, STREAM_TYPE_PUBLIC);
        }
        mImageLoader = new ImageLoader(getActivity());
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View rootView = inflater.inflate(R.layout.frag_feeds, container, false);
        listView = (ListView)rootView.findViewById(R.id.feedListView);
        loading = (ProgressBar)rootView.findViewById(R.id.loading);
        section_quick_filter = (LinearLayout)rootView.findViewById(R.id.section_quick_filter);
        btn_show_item = (Button)rootView.findViewById(R.id.btn_show_item);
        btn_show_gender = (Button)rootView.findViewById(R.id.btn_show_gender);
        btn_show_filter = (Button)rootView.findViewById(R.id.btn_show_filter);

        btn_show_gender.setOnClickListener(this);
        btn_show_item.setOnClickListener(this);
        btn_show_filter.setOnClickListener(this);

        if (savedInstanceState != null) {
            mListViewStatePosition = savedInstanceState.getInt(STATE_POSITION, -1);
            mListViewStateTop = savedInstanceState.getInt(STATE_TOP, 0);
        } else {
            mListViewStatePosition = -1;
            mListViewStateTop = 0;
        }
        return rootView;
    }


    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
    }

    @Override
     public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        listView.setOnItemClickListener(this);
        if (!UIUtils.isTablet(getActivity())) {
            view.setBackgroundColor(getResources().getColor(R.color.plus_stream_spacer_color));
        }

        //dummy data
        for(int i=0; i<10;i++) mStream.add("");

        listView.setOnItemClickListener(this);
        listView.setOnScrollListener(this);
        listView.setAdapter(mStreamAdapter);

    }

    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        inflater.inflate(R.menu.social_stream, menu);
    }

    void showPopupMenu(View view, int type){
        activePopupWindow = new PopupWindow(getActivity());
        View menu;
        switch (type){
            case POPUP_WINDOW_GENDER:   //load gender popup menu view
                menu = getActivity().getLayoutInflater().inflate(R.layout.popup_menu_gender, null);
                initPopupUI(menu, POPUP_WINDOW_GENDER);
                break;

            case POPUP_WINDOW_ITEM:     //load item popup menu view
                menu = activity.getLayoutInflater().inflate(R.layout.popup_menu_item, null);
                initPopupUI(menu, POPUP_WINDOW_ITEM);
                break;
            default: return;
        }
        activePopupWindow.setContentView(menu);
        activePopupWindow.setWidth(WindowManager.LayoutParams.WRAP_CONTENT);
        activePopupWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
        activePopupWindow.setOutsideTouchable(true);
        activePopupWindow.setFocusable(true);
        activePopupWindow.setBackgroundDrawable(new BitmapDrawable());
        Rect location = locateView(view);
        activePopupWindow.showAtLocation(view, Gravity.TOP|Gravity.LEFT, 0, section_quick_filter.getBottom()+10);
    }

    private View.OnClickListener popUpClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switch (view.getId()){
                case R.id.popup_gender_all:
                    toast("show items for all genders");
                    MENU_GENDER_SELECTED = MENU_GENDER_ALL;
                    activePopupWindow.dismiss();
                    break;

                case R.id.popup_gender_male:
                    toast("show items for all men");
                    MENU_GENDER_SELECTED = MENU_GENDER_MALE;
                    activePopupWindow.dismiss();
                    break;

                case R.id.popup_gender_female:
                    activePopupWindow.dismiss();
                    MENU_GENDER_SELECTED = MENU_GENDER_FEMALE;
                    toast("show items for all chics");
                    break;

                case R.id.popup_gender_unisex:
                    toast("show items for all gays");
                    MENU_GENDER_SELECTED = MENU_GENDER_UNISEX;
                    activePopupWindow.dismiss();
                    break;

                case R.id.popup_item_all:
                    toast("show all items");
                    MENU_ITEM_SELECTED = MENU_ITEM_ALL;
                    activePopupWindow.dismiss();
                    break;

                case R.id.popup_item_clothes:
                    toast("show items clothes");
                    MENU_ITEM_SELECTED = MENU_ITEM_CLOTHES;
                    activePopupWindow.dismiss();
                    break;

                case R.id.popup_item_shoes:
                    toast("show items shoes");
                    MENU_ITEM_SELECTED = MENU_ITEM_SHOES;
                    activePopupWindow.dismiss();
                    break;

                case R.id.popup_item_accessories:
                    toast("show items accessories");
                    MENU_ITEM_SELECTED = MENU_ITEM_ACCESSORIES;
                    activePopupWindow.dismiss();
                    break;

                default: break;
            }
        }
    };

    void initPopupUI(View view, int type){
        switch (type){
            case POPUP_WINDOW_GENDER:
                popup_gender_all = (Button)view.findViewById(R.id.popup_gender_all);
                popup_gender_male = (Button)view.findViewById(R.id.popup_gender_male);
                popup_gender_female = (Button)view.findViewById(R.id.popup_gender_female);
                popup_gender_unisex = (Button)view.findViewById(R.id.popup_gender_unisex);
                popup_gender_all.setOnClickListener(popUpClickListener);
                popup_gender_male.setOnClickListener(popUpClickListener);
                popup_gender_female.setOnClickListener(popUpClickListener);
                popup_gender_unisex.setOnClickListener(popUpClickListener);
                break;

            case POPUP_WINDOW_ITEM:
                popup_item_all = (Button)view.findViewById(R.id.popup_item_all);
                popup_item_clothes = (Button)view.findViewById(R.id.popup_item_clothes);
                popup_item_shoes = (Button)view.findViewById(R.id.popup_item_shoes);
                popup_item_accessories = (Button)view.findViewById(R.id.popup_item_accessories);
                popup_item_all.setOnClickListener(popUpClickListener);
                popup_item_clothes.setOnClickListener(popUpClickListener);
                popup_item_shoes.setOnClickListener(popUpClickListener);
                popup_item_accessories.setOnClickListener(popUpClickListener);
                break;

            default: break;
        }
    }

    public static Rect locateView(View view){
        int[] loc_int = new int[2];
        if(view == null) return null;
        view.getLocationOnScreen(loc_int);
        Rect location = new Rect();
        location.left = loc_int[0];
        location.top = loc_int[1];
        location.right = location.left + view.getWidth();
        location.bottom = location.top + view.getHeight();
        return location;
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        if (isAdded()) {
            View v = listView.getChildAt(0);
            int top = (v == null) ? 0 : v.getTop();
            outState.putInt(STATE_POSITION, listView.getFirstVisiblePosition());
            outState.putInt(STATE_TOP, top);
        }
        super.onSaveInstanceState(outState);
    }

    void toggleFeedList(boolean show){
        if(show){
            listView.setVisibility(View.VISIBLE);
            loading.setVisibility(View.GONE);
        }else{
            listView.setVisibility(View.GONE);
            loading.setVisibility(View.VISIBLE);
        }
    }

    public void refresh(String newQuery) {
        mSearchString = newQuery;
        refresh(true);
    }

    public void refresh() {
        refresh(false);
    }

    public void refresh(boolean forceRefresh) {
        if (isStreamLoading() && !forceRefresh) {
            return;
        }

        // clear current items
        mStream.clear();
        mStreamAdapter.notifyDataSetInvalidated();

        if (isAdded()) {
            Loader loader = getLoaderManager().getLoader(STREAM_LOADER_ID);
            ((StreamLoader) loader).init(mSearchString);
        }

        loadMoreResults();
    }

    public void loadMoreResults() {
        if (isAdded()) {
            Loader loader = getLoaderManager().getLoader(STREAM_LOADER_ID);
            if (loader != null) {
                loader.forceLoad();
            }
        }
    }

    @Override
    public void onScrollStateChanged(AbsListView listView, int scrollState) {
        // Pause disk cache access to ensure smoother scrolling
        if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING) {
            mImageLoader.stopProcessingQueue();
        } else {
            mImageLoader.startProcessingQueue();
        }
    }

    @Override
    public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount,
                         int totalItemCount) {
        if (!isStreamLoading()
                && streamHasMoreResults()
                && visibleItemCount != 0
                && firstVisibleItem + visibleItemCount >= totalItemCount - 1) {
            loadMoreResults();
        }
    }

    //direction 1 => slide up , 0 => slide down
    void toggleQuickFilter(int direction){
        Animation slideUp = AnimationUtils.loadAnimation(this.activity, R.anim.slide_up);
        Animation slideDown = AnimationUtils.loadAnimation(this.activity, R.anim.slide_down);
        switch (direction){
            case 1: //slide up
                section_quick_filter.setAnimation(slideUp);
                break;
            case 2: //slide down
                section_quick_filter.setAnimation(slideDown);
                break;

            default: //show view
                break;
        }
    }

    // To animate view slide out from top to bottom
    public void slideToBottom(View view){
        TranslateAnimation animate = new TranslateAnimation(0,0,0,view.getHeight());
        animate.setDuration(500);
        animate.setFillAfter(true);
        view.startAnimation(animate);
        view.setVisibility(View.GONE);
    }

    // To animate view slide out from bottom to top
    public void slideToTop(View view){
        TranslateAnimation animate = new TranslateAnimation(0,0,0,-view.getHeight());
        animate.setDuration(500);
        animate.setFillAfter(true);
        view.startAnimation(animate);
        view.setVisibility(View.GONE);
    }

    @Override
    public Loader<ArrayList<String>> onCreateLoader(int id, Bundle args) {
        return new StreamLoader(getActivity(), mSearchString);

    }

    @Override
    public void onLoadFinished(Loader<ArrayList<String>> loader, ArrayList<String> data) {
        if (data != null) {
            mStream = data;
        }
        mStreamAdapter.notifyDataSetChanged();
        if (mListViewStatePosition != -1 && isAdded()) {
            listView.setSelectionFromTop(mListViewStatePosition, mListViewStateTop);
            mListViewStatePosition = -1;
        }
    }

    @Override
    public void onLoaderReset(Loader<ArrayList<String>> loader) {

    }

    private boolean isStreamLoading() {
        if (isAdded()) {
            final Loader loader = getLoaderManager().getLoader(STREAM_LOADER_ID);
            if (loader != null) {
                return ((StreamLoader) loader).isLoading();
            }
        }
        return true;
    }

    private boolean streamHasMoreResults() {
        if (isAdded()) {
            final Loader loader = getLoaderManager().getLoader(STREAM_LOADER_ID);
            if (loader != null) {
                return ((StreamLoader) loader).hasMoreResults();
            }
        }
        return false;
    }

    private boolean streamHasError() {
        if (isAdded()) {
            final Loader loader = getLoaderManager().getLoader(STREAM_LOADER_ID);
            if (loader != null) {
                return ((StreamLoader) loader).hasError();
            }
        }
        return false;
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.btn_show_item:   //show items
                showPopupMenu(view, POPUP_WINDOW_ITEM);
                //TODO add filter logic
                break;

            case R.id.btn_show_gender: //show gender
                showPopupMenu(view, POPUP_WINDOW_GENDER);
                //TODO add filter logic
                break;

            case R.id.btn_show_filter:    //show filter dlg
                //TODO filter
                MENU_GENDER_SELECTED = MENU_GENDER_SELECTED != -100 ? MENU_GENDER_SELECTED : MENU_GENDER_ALL;
                MENU_ITEM_SELECTED = MENU_ITEM_SELECTED != -100 ? MENU_ITEM_SELECTED : MENU_ITEM_ALL;
                filterStreamFragment = FilterStreamFragment.newInstance(fillColors(), MENU_GENDER_SELECTED, MENU_ITEM_SELECTED);
                filterStreamFragment.show(getFragmentManager(), TAG_FRAG_FILTER);
                break;

            default:break;
        }
    }

    ArrayList<ColorPicker> fillColors(){
        ArrayList<ColorPicker> colors = new ArrayList<ColorPicker>();
        String[] color_names = activity.getResources().getStringArray(R.array.color_names);
        String[] color_codes = activity.getResources().getStringArray(R.array.color_codes);
        for(int i=0; i<color_names.length && i<color_names.length; i++)
            colors.add(new ColorPicker(color_codes[i], color_names[i]));
        return colors;
    }

    void toast(String text){
        Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show();
    }

    public static class StreamLoader extends AsyncTaskLoader<ArrayList<String>> {
        ArrayList<String> mActivities;
        private String mSearchString;
        private String mNextPageToken;
        private boolean mIsLoading;
        private boolean mHasError;

        public StreamLoader(Context context, String searchString) {
            super(context);
            init(searchString);
        }

        private void init(String searchString) {
            mSearchString = searchString;
            mHasError = false;
            mNextPageToken = null;
            mIsLoading = true;
            mActivities = null;
        }

        @Override
        public ArrayList<String> loadInBackground() {
            mIsLoading = true;

            ArrayList<String> activities = new ArrayList<String>();
            for(int i = 0; i < 9; i++) activities.add("");

            return activities;
        }

        @Override
        public void deliverResult(ArrayList<String> activities) {
            mIsLoading = false;
            if (activities != null) {
                mActivities = null;
                if (mActivities == null) {
                    mActivities = activities;
                } else {
                    mActivities.addAll(activities);
                }
            }
            if (isStarted()) {
                // Need to return new ArrayList for some reason or onLoadFinished() is not called
                super.deliverResult(mActivities == null ?
                        null : new ArrayList<String>(mActivities));
            }
        }

        @Override
        protected void onStartLoading() {
            if (mActivities != null) {
                // If we already have results and are starting up, deliver what we already have.
                deliverResult(null);
            } else {
                forceLoad();
            }
        }

        @Override
        protected void onStopLoading() {
            mIsLoading = false;
            cancelLoad();
        }

        @Override
        protected void onReset() {
            super.onReset();
            onStopLoading();
            mActivities = null;
        }

        public boolean isLoading() {
            return mIsLoading;
        }

        public boolean hasMoreResults() {
            return mNextPageToken != null;
        }

        public boolean hasError() {
            return mHasError;
        }

        public void setSearchString(String searchString) {
            mSearchString = searchString;
        }

        public void refresh() {
            reset();
            startLoading();
        }
    }


    public class StreamAdapter extends BaseAdapter {
        private static final int VIEW_TYPE_ACTIVITY = 0;
        private static final int VIEW_TYPE_LOADING = 1;

        @Override
        public boolean areAllItemsEnabled() {
            return false;
        }

        @Override
        public boolean isEnabled(int position) {
            return getItemViewType(position) == VIEW_TYPE_ACTIVITY;
        }

        @Override
        public int getViewTypeCount() {
            return 2;
        }

        @Override
        public boolean hasStableIds() {
            return true;
        }

        @Override
        public int getCount() {
            return mStream.size() + (
                    // show the status list row if...
                    ((isStreamLoading() && mStream.size() == 0) // ...this is the first load
                            || streamHasMoreResults() // ...or there's another page
                            || streamHasError()) // ...or there's an error
                            ? 1 : 0);
        }

        @Override
        public int getItemViewType(int position) {
            return (position >= mStream.size())
                    ? VIEW_TYPE_LOADING
                    : VIEW_TYPE_ACTIVITY;
        }

        @Override
        public Object getItem(int position) {
            return (getItemViewType(position) == VIEW_TYPE_ACTIVITY)
                    ? mStream.get(position)
                    : null;
        }

        @Override
        public long getItemId(int position) {
            // TODO: better unique ID heuristic
            return position;
        }
        int pos = 0;
        public String getURL(){
            String url = "http://www.wwd.com/images/processed/footwear-news/2011/10/25/landscape/01-large/sexy-shoe01.jpg";
            switch (pos){
                case 1:
                    url="http://blogs.sun-sentinel.com/features_fashion/files/2011/12/SexyShoeJimmyChoo.jpg";
                    break;
                case 2:
                    url="http://buybestdesignerhandbags.com/wp-content/uploads/2013/08/Designer-Handbags.jpg";
                    break;
                case 3:
                    url="http://www.bharatmoms.com/uploads/Image/Latest%20handmade%20rose%20flower%202013%20collection%20of%20hand%20bags.jpg";
                    break;
                case 4:
                    url="http://fc09.deviantart.net/fs70/i/2013/219/9/d/dress_evora__somnia_romantica_by_marjolein_turin_by_somniaromantica-d6h1n04.jpg";
                    break;
                case 5:
                    url="http://www.handbagsexpert.com/wp-content/uploads/2013/03/277514_AKZ5A_2816_001_web_doublehero.png";
                    break;
                case 6:
                    url="http://images6.fanpop.com/image/photos/33900000/Sexy-shoes-womens-shoes-33981381-870-675.jpg";
                    break;
            }

            return url;
        }
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if (getItemViewType(position) == VIEW_TYPE_LOADING) {
                if (convertView == null) {
                    convertView = getActivity().getLayoutInflater().inflate(
                            R.layout.list_item_stream_status, parent, false);
                }

                if (streamHasError()) {
                    convertView.findViewById(android.R.id.progress).setVisibility(View.GONE);
                    ((TextView) convertView.findViewById(android.R.id.text1)).setText(
                            R.string.stream_error);
                } else {
                    convertView.findViewById(android.R.id.progress).setVisibility(View.VISIBLE);
                    ((TextView) convertView.findViewById(android.R.id.text1)).setText(
                            R.string.loading);
                }

                return convertView;

            } else {
                pos++;
                if (convertView == null) {
                    convertView = getActivity().getLayoutInflater().inflate(
                            R.layout.list_item_stream, parent, false);
                }

                //init list item ui
                RoundedImageView stream_user_image = (RoundedImageView) convertView.findViewById(R.id.stream_user_image);
                TextView txt_stream_username = (TextView) convertView.findViewById(R.id.stream_user_name);
                TextView txt_stream_time = (TextView) convertView.findViewById(R.id.stream_time);
                EllipsizedTextView txt_stream_content = (EllipsizedTextView) convertView.findViewById(R.id.stream_content);

                View stream_original_container = (LinearLayout)convertView.findViewById(R.id.stream_original_container);
                TextView stream_original_author = (TextView)convertView.findViewById(R.id.stream_original_author);
                EllipsizedTextView stream_original_content = (EllipsizedTextView)convertView.findViewById(R.id.stream_original_content);

                ImageView stream_media_background = (ImageView)convertView.findViewById(R.id.stream_media_background);
                ImageView stream_media_overlay = (ImageView)convertView.findViewById(R.id.stream_media_overlay);
                TextView stream_price = (TextView)convertView.findViewById(R.id.stream_price);
                TextView stream_size = (TextView)convertView.findViewById(R.id.stream_size);
                //View stream_color_viewer_1 = (View)convertView.findViewById(R.id.stream_color_viewer_1);
                //View stream_color_viewer_2 = (View)convertView.findViewById(R.id.stream_color_viewer_2);

                ImageView btn_stream_like = (ImageView)convertView.findViewById(R.id.btn_stream_like);
                ImageView btn_stream_comment = (ImageView)convertView.findViewById(R.id.btn_stream_comment);
                ImageView btn_stream_share = (ImageView)convertView.findViewById(R.id.btn_stream_share);

                txt_stream_username.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        toast("open user profile");
                    }
                });
                txt_stream_content.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        toast("expand view, if ellipsized");
                    }
                });
                stream_original_author.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        toast("open original stream");
                    }
                });
                stream_original_content.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        toast("open original stream");
                    }
                });
                btn_stream_like.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        toast("liking current item");
                    }
                });
                btn_stream_comment.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        toast("comment");
                    }
                });
                btn_stream_share.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        toast("reshare");
                    }
                });

                //TODO set data

                //Interactions
//                LinearLayout stream_interactions_container = (LinearLayout) convertView.findViewById(R.id.stream_interactions_container);
//                stream_interactions_container.setVisibility(View.VISIBLE);
//                TextView stream_likes = (TextView) convertView.findViewById(R.id.stream_likes);
//                stream_likes.setVisibility(View.VISIBLE);
//                stream_likes.setText(" 25");
//                TextView stream_shares = (TextView) convertView.findViewById(R.id.stream_shares);
//                stream_shares.setText(" 18");
//                stream_shares.setVisibility(View.VISIBLE);
//                TextView stream_comments = (TextView) convertView.findViewById(R.id.stream_comments);
//                stream_comments.setText(" 31");
//                stream_comments.setVisibility(View.VISIBLE);

                //Media shit
                RelativeLayout stream_media_container = (RelativeLayout) convertView.findViewById(R.id.stream_media_container);
                stream_media_container.setVisibility(View.VISIBLE);

                // show The Image
//                new DownloadImageTask(stream_media_overlay).execute(getURL());
//                stream_media_overlay.setVisibility(View.VISIBLE);


//                txt_stream_username.setText("User name");
//                txt_stream_time.setText("May 25");
//                txt_stream_content.setText("A sample stream from user!!");
//                txt_stream_content.setVisibility(View.VISIBLE);
//                txt_stream_content.animate();

                String DUMMY_IMG_URL = "https://avatars0.githubusercontent.com/u/4123209?s=140";

                if (mImageLoader != null) {
                    String url = getURL();
                    LOGE("streamFrag", "URL: "+url);
                    mImageLoader.get(DUMMY_IMG_URL, stream_user_image, getResources().getDrawable(R.drawable.person_image_empty));
                    mImageLoader.get(getURL(), stream_media_background,getResources().getDrawable(R.drawable.shoes_4));
                }else{
                    LOGE("streamFrag", "ImageLoader is empty!");
                }

                return convertView;
            }
        }
    }

    public class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
        ImageView bmImage;

        public DownloadImageTask(ImageView bmImage) {
            this.bmImage = bmImage;
        }

        protected Bitmap doInBackground(String... urls) {
            String urldisplay = urls[0];
            Bitmap mIcon11 = null;
            try {
                InputStream in = new java.net.URL(urldisplay).openStream();
                mIcon11 = BitmapFactory.decodeStream(in);
            } catch (Exception e) {
                LOGE("Error", e.getMessage());
                e.printStackTrace();
            }
            return mIcon11;
        }

        protected void onPostExecute(Bitmap result) {
            bmImage.setImageBitmap(result);
        }
    }


    //filter dialog
    public static class FilterStreamFragment extends DialogFragment{
        static final String LOG_TAG = "FilterStreamFragment";
        static final String KEY_COLORS = "colors";
        static final String KEY_GENDER_TYPE = "gender";
        static final String KEY_ITEM_TYPE = "item";

        private ArrayList<ColorPicker> colors = new ArrayList<ColorPicker>();
        private int genderType;
        private int itemType;

        View flt_section_gender;
        Spinner spinner_gender;
        View flt_section_item;
        Spinner spinner_item;
        View flt_section_type;
        Spinner spinner_type;
        View flt_section_price;
        SeekBar seeker_price_range;
        View flt_section_color;
        Spinner spinner_color;
        View flt_section_size;
        Spinner spinner_size;

        static FilterParam filterParam = new FilterParam();

        public static FilterStreamFragment newInstance(ArrayList<ColorPicker> colors,
                                                       int genderType, int itemType){
            FilterStreamFragment  fragment = new FilterStreamFragment();
            Bundle args = new Bundle();
            args.putParcelableArrayList(KEY_COLORS, colors);
            args.putInt(KEY_GENDER_TYPE, genderType);
            args.putInt(KEY_ITEM_TYPE, itemType);
            //TODO set data
            fragment.setArguments(args);
            return fragment;
        }

        public FilterStreamFragment() {}

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            if (getArguments() != null) {
                //TODO get args
                colors = getArguments().getParcelableArrayList(KEY_COLORS);
                genderType = getArguments().getInt(KEY_GENDER_TYPE);
                itemType = getArguments().getInt(KEY_ITEM_TYPE);
            }
        }

        @Override
        public Dialog onCreateDialog(Bundle savedInstanceState){
            super.onCreateDialog(savedInstanceState);
            if (getArguments() != null) {
                //TODO get args
                colors = getArguments().getParcelableArrayList(KEY_COLORS);
            }

            View rootView = getActivity().getLayoutInflater().inflate(R.layout.fragment_filter, null);
            //TODO init UI
            flt_section_gender = (LinearLayout)rootView.findViewById(R.id.flt_section_gender);

            flt_section_item = (LinearLayout)rootView.findViewById(R.id.flt_section_item);
            flt_section_type = (LinearLayout)rootView.findViewById(R.id.flt_section_type);
            flt_section_price = (LinearLayout)rootView.findViewById(R.id.flt_section_price);
            flt_section_color = (LinearLayout)rootView.findViewById(R.id.flt_section_color);
            flt_section_size = (LinearLayout)rootView.findViewById(R.id.flt_section_size);

            spinner_gender = (Spinner)rootView.findViewById(R.id.spinner_gender);
            spinner_item = (Spinner)rootView.findViewById(R.id.spinner_item);
            spinner_type = (Spinner)rootView.findViewById(R.id.spinner_type);
            seeker_price_range = (SeekBar)rootView.findViewById(R.id.seeker_price_range);
            spinner_color = (Spinner)rootView.findViewById(R.id.spinner_color);
            spinner_size = (Spinner)rootView.findViewById(R.id.spinner_size);

            //TODO set data...change UI
            setParams(genderType, itemType);
            spinner_color.setAdapter(new ColorSpinnerAdapter(getActivity(), colors));

            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            builder.setView(rootView);
            builder.setTitle("Filter Items");
            builder.setIcon(getActivity().getResources().getDrawable(R.drawable.ic_action_filter));
            builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });

            builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {

                    //TODO get filter params
                    getFilterParams();

                    dialog.dismiss();
                }
            });

            return builder.create();
        }

        void getFilterParams(){
            switch (spinner_gender.getSelectedItemPosition()){
                case 0:
                    MENU_GENDER_SELECTED = MENU_GENDER_ALL;
                    break;
                case 1:
                    MENU_GENDER_SELECTED = MENU_GENDER_MALE;
                    break;
                case 2:
                    MENU_GENDER_SELECTED = MENU_GENDER_FEMALE;
                    break;
                case 3:
                    MENU_GENDER_SELECTED = MENU_GENDER_UNISEX;
                    break;
                default: break;
            }

            switch (spinner_item.getSelectedItemPosition()){
                case 0:
                    MENU_ITEM_SELECTED = MENU_ITEM_ALL;
                    break;
                case 1:
                    MENU_ITEM_SELECTED = MENU_ITEM_CLOTHES;
                    break;
                case 2:
                    MENU_ITEM_SELECTED = MENU_ITEM_SHOES;
                    break;
                case 3:
                    MENU_ITEM_SELECTED = MENU_ITEM_ACCESSORIES;
                    break;
                default: break;
            }

            filterParam.setGender(MENU_GENDER_SELECTED);
            filterParam.setItem(MENU_ITEM_SELECTED);
            filterParam.setPrice(seeker_price_range.getProgress());
            filterParam.setSize(Integer.parseInt(spinner_size.getSelectedItem().toString()));
            LOGE(LOG_TAG, "size: "+filterParam.getSize());
            filterParam.setColor((ColorPicker)spinner_color.getSelectedItem());
        }

        void setParams(int genderType, int itemType){
            ArrayAdapter<String> spinnerAdapter;
            String[] item_types;
            switch (genderType){
                case MENU_GENDER_ALL:
                    spinner_gender.setSelection(0, true);
                    break;
                case MENU_GENDER_MALE:
                    spinner_gender.setSelection(1, true);
                    break;
                case MENU_GENDER_FEMALE:
                    spinner_gender.setSelection(2, true);
                    break;
                case MENU_GENDER_UNISEX:
                    spinner_gender.setSelection(3, true);
                    break;
                default:
                    spinner_gender.setSelection(0, true);
                    break;
            }

            switch (itemType){
                case MENU_ITEM_ALL:
                    spinner_item.setSelection(0);
                    flt_section_type.setVisibility(View.GONE);
                    break;
                case MENU_ITEM_CLOTHES:
                    item_types = getActivity().getResources().getStringArray(R.array.type_clothes);
                    spinnerAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, item_types);
                    spinner_type.setAdapter(spinnerAdapter);
                    spinner_item.setSelection(1);
                    break;
                case MENU_ITEM_SHOES:
                    item_types = getActivity().getResources().getStringArray(R.array.type_shoes);
                    spinnerAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, item_types);
                    spinner_type.setAdapter(spinnerAdapter);
                    spinner_item.setSelection(2);
                    break;
                case MENU_ITEM_ACCESSORIES:
                    item_types = getActivity().getResources().getStringArray(R.array.type_accessories);
                    spinnerAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_dropdown_item, item_types);
                    spinner_type.setAdapter(spinnerAdapter);
                    spinner_item.setSelection(3);
                    break;
                default: break;
            }
        }
    }
}




Java Source Code List

com.android.busolo.apps.wardrobe.Config.java
com.android.busolo.apps.wardrobe.engine.BaseActivity.java
com.android.busolo.apps.wardrobe.engine.ColorPickerFragment.java
com.android.busolo.apps.wardrobe.engine.CommentsFragment.java
com.android.busolo.apps.wardrobe.engine.FollowActivity.java
com.android.busolo.apps.wardrobe.engine.HomeActivity.java
com.android.busolo.apps.wardrobe.engine.ItemDetailsActivity.java
com.android.busolo.apps.wardrobe.engine.LoginFragment.java
com.android.busolo.apps.wardrobe.engine.MatchFragment.java
com.android.busolo.apps.wardrobe.engine.NewPostActivity.java
com.android.busolo.apps.wardrobe.engine.PrivateStreamFragment.java
com.android.busolo.apps.wardrobe.engine.ProfileFragment.java
com.android.busolo.apps.wardrobe.engine.PublicStreamActivity.java
com.android.busolo.apps.wardrobe.engine.PublicStreamFragment.java
com.android.busolo.apps.wardrobe.engine.SignupFragment.java
com.android.busolo.apps.wardrobe.engine.StepOneFragment.java
com.android.busolo.apps.wardrobe.engine.StepTwoFragment.java
com.android.busolo.apps.wardrobe.engine.UserAccountActivity.java
com.android.busolo.apps.wardrobe.engine.adapter.ColorListAdapter.java
com.android.busolo.apps.wardrobe.engine.adapter.ColorSpinnerAdapter.java
com.android.busolo.apps.wardrobe.engine.adapter.FeedsListAdapter.java
com.android.busolo.apps.wardrobe.engine.adapter.GridViewPhotoAdapter.java
com.android.busolo.apps.wardrobe.engine.adapter.ViewInflaterBaseAdapter.java
com.android.busolo.apps.wardrobe.engine.model.ColorPicker.java
com.android.busolo.apps.wardrobe.engine.model.FilterParam.java
com.android.busolo.apps.wardrobe.engine.model.Follow.java
com.android.busolo.apps.wardrobe.engine.model.Stream.java
com.android.busolo.apps.wardrobe.sync.SyncHelper.java
com.android.busolo.apps.wardrobe.sync.SyncService.java
com.android.busolo.apps.wardrobe.utils.AccountUtils.java
com.android.busolo.apps.wardrobe.utils.BitmapCache.java
com.android.busolo.apps.wardrobe.utils.ImageLoader.java
com.android.busolo.apps.wardrobe.utils.LogUtils.java
com.android.busolo.apps.wardrobe.utils.LruBitmapCache.java
com.android.busolo.apps.wardrobe.utils.NetUtils.java
com.android.busolo.apps.wardrobe.utils.ParserUtils.java
com.android.busolo.apps.wardrobe.utils.PrefUtils.java
com.android.busolo.apps.wardrobe.utils.ServerResponse.java
com.android.busolo.apps.wardrobe.utils.UIUtils.java
com.android.busolo.apps.wardrobe.utils.VolleyAppController.java
com.android.busolo.apps.wardrobe.utils.model.FeedResult.java
com.android.busolo.apps.wardrobe.widget.BezelImageView.java
com.android.busolo.apps.wardrobe.widget.CheckableFrameLayout.java
com.android.busolo.apps.wardrobe.widget.EllipsizedTextView.java
com.android.busolo.apps.wardrobe.widget.ObservableScrollView.java
com.android.busolo.apps.wardrobe.widget.SquareImageView.java