Back to project page Wardrobe_app.
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.
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); } } }