本文实例分享了一个简单的朋友圈程序,包含了朋友圈的列表实现,视频的录制、预览与上传,图片可选择拍照,供大家参考,具体内容如下
FriendsListActivity 代码 如下
public class FriendsListActivity extends BaseActivity implements OnRefreshListener<ListView>, PostListener { private InteractionAdapter mAdapter; private PullToRefreshListView mRefreshListView; private View mFooter; private Context mContext; private Button btnToPost; protected int mPage = 0; private boolean isRefreshing = false; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.friends_list); mContext=getApplicationContext(); mAdapter = new InteractionAdapter(mContext); mAdapter.setListener(this); btnToPost=(Button) findViewById(R.id.btn_topost); mRefreshListView = (PullToRefreshListView) findViewById(R.id.friends_list); FriendsApi.getFriendsList(mContext, mCallBack); mRefreshListView.setOnRefreshListener(this); mFooter = LayoutInflater.from(mContext).inflate(R.layout.loading_footer, null); // mRefreshListView.getRefreshableView().addFooterView(mFooter); mRefreshListView.setAdapter(mAdapter); // mRefreshListView.setOnLastItemVisibleListener(mLastListener); // mRefreshListView.getRefreshableView().setDividerHeight(40); btnToPost.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { myPosts(); } }); } protected void myPosts() { new AlertDialog.Builder(this).setItems(new String[]{"图片","视频","文字"}, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent intent=new Intent(); switch (which) { case 0: intent.setClass(FriendsListActivity.this, CreatePostActivity.class); break; case 1: intent.setClass(FriendsListActivity.this, RecorderActivity.class); break; case 2: intent.setClass(FriendsListActivity.this, RecorderActivity.class); break; default: break; } startActivity(intent); } }).show(); } /** * 查看更多操作 */ @Override public void show(Interaction interaction) { } @Override public void delete(Interaction interaction) { // TODO Auto-generated method stub } @Override public void onRefresh(PullToRefreshBase<ListView> refreshView) { if (!isRefreshing) { isRefreshing = true; mPage = 0; FriendsApi.getFriendsList(mContext, mCallBack); } } protected NetCallBack mCallBack = new NetCallBack() { public void friendslist(ArrayList<Interaction> friends) { Log.i("friends size>>>>",friends.size()+"-------------"); mAdapter.setInteractions(friends); // mRefreshListView.getLoadingLayoutProxy().setLastUpdatedLabel(null); mRefreshListView.onRefreshComplete(); isRefreshing = false; dismissLoading(); }; public void start() { showLoading(); }; public void failed(String message) { loadFailed(); }; }; @Override public void play(Interaction interaction) { Intent mIntent=new Intent(); mIntent.setClass(FriendsListActivity.this, RecorderPlayActivity.class); Bundle data = new Bundle(); data.putString("path", interaction.videoPath); mIntent.putExtras(data); startActivity(mIntent); } }
查看更多关于我也有微信朋友圈了Android实现的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did32620