Android Open Source - Wardrobe_app Follow Activity






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;
//from   w  ww. ja v  a2s . c  o m
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.android.busolo.apps.wardrobe.engine.adapter.GridViewPhotoAdapter;
import com.android.busolo.apps.wardrobe.engine.adapter.ViewInflaterBaseAdapter;
import com.makeramen.RoundedImageView;

import java.util.ArrayList;

public class FollowActivity extends ActionBarActivity {

    static final String LOG_TAG = "FollowActivity";
    public static final String FOLLOW_TYPE = "following_followers";
    public static final int KEY_PRIV_FOLLOWER = 0;
    public static final int KEY_PRIV_FOLLOWING = 1;
    public static final int KEY_BIZ_FOLLOWER = 2;

    private ListView listView;
    private FollowListAdapter listAdapter;
    private ArrayList<String> data = new ArrayList<String>();

    private int follow_type = KEY_PRIV_FOLLOWER;

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

        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        try{
            Bundle args = getIntent().getExtras();
            if(args != null){
                follow_type = args.getInt(FOLLOW_TYPE);
            }else{
                finish();
            }
        }catch (NullPointerException ex){
            Log.e(LOG_TAG, "No data passed", ex);
        }

        setTitle();
        listView = (ListView)findViewById(R.id.followListView);

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

        listAdapter = new FollowListAdapter(new Inflater(),data);
        listView.setAdapter(listAdapter);
    }

    void setTitle(){
        switch (follow_type){
            case KEY_BIZ_FOLLOWER:
                getSupportActionBar().setTitle("Business Followers");
                break;
            case KEY_PRIV_FOLLOWER:
                getSupportActionBar().setTitle("Followers");
                break;
            case KEY_PRIV_FOLLOWING:
                getSupportActionBar().setTitle("Following");
                break;
            default: break;
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.follow, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        switch (item.getItemId()){
            case R.id.action_settings:
                return true;

            case android.R.id.home:
                onBackPressed();
                return true;

            default: break;
        }
        return super.onOptionsItemSelected(item);
    }

    //inflater
    private class Inflater implements ViewInflaterBaseAdapter.ViewInflater{

        private class ViewHolder{
            RoundedImageView profilePic;
            TextView userName;
            ImageView follow;
            Button unfollow;
        }

        @Override
        public View inflate(ViewInflaterBaseAdapter adapter, int pos, View ConvertView, ViewGroup parent) {
            LayoutInflater inflater = LayoutInflater.from(parent.getContext());
            View rowView = ConvertView;

            if(rowView == null) {
                rowView = inflater.inflate(R.layout.list_item_follow, parent, false);

                //init UI
                ViewHolder viewHolder = new ViewHolder();
                viewHolder.profilePic = (RoundedImageView)rowView.findViewById(R.id.profile_pic);
                viewHolder.userName = (TextView)rowView.findViewById(R.id.txt_name);
                viewHolder.follow = (ImageView)rowView.findViewById(R.id.btn_follow);
                viewHolder.unfollow = (Button)rowView.findViewById(R.id.btn_following);

                rowView.setTag(viewHolder);
            }

            ViewHolder viewHolder = (ViewHolder)rowView.getTag();
            //TODO set data
            if(follow_type==KEY_BIZ_FOLLOWER)
                viewHolder.unfollow.setVisibility(View.GONE);

            //TODO set click listeners

            return rowView;
        }
    }

    //list adapter
    public class FollowListAdapter extends ViewInflaterBaseAdapter<String>{

        public FollowListAdapter(ViewInflater inflater, ArrayList<String> data) {
            super(inflater, data);
            super.setInflater(inflater);
        }
    }
}




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