Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
LloydFinch committed Aug 7, 2015
1 parent 6912b6e commit 6d9496b
Show file tree
Hide file tree
Showing 60 changed files with 1,452 additions and 125 deletions.
1 change: 1 addition & 0 deletions ZhuFengFM/app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,6 @@
<orderEntry type="library" exported="" name="design-22.2.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-22.2.1" level="project" />
<orderEntry type="module" module-name="PullToRefresh" exported="" />
<orderEntry type="library" name="xUtils-2.6.14" level="project" />
</component>
</module>
Binary file added ZhuFengFM/app/libs/xUtils-2.6.14.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,12 +1,85 @@
package com.venn.zhufengfm.app.activity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ContentView;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.venn.zhufengfm.app.R;
import com.venn.zhufengfm.app.adapters.AlbumDetailAdapter;
import com.venn.zhufengfm.app.model.player.Album;
import com.venn.zhufengfm.app.model.player.AlbumDetail;
import com.venn.zhufengfm.app.parsers.DataParser;
import com.venn.zhufengfm.app.tasks.TaskCallback;
import com.venn.zhufengfm.app.tasks.TaskResult;
import com.venn.zhufengfm.app.tasks.impl.AlbumDetailTask;
import com.venn.zhufengfm.app.uitl.Constants;
import com.venn.zhufengfm.app.uitl.MyLog;
import com.venn.zhufengfm.app.uitl.SetImageUtil;
import com.venn.zhufengfm.app.uitl.SetTextUtil;
import org.json.JSONObject;

public class AlbumDetailActivity extends BaseActivity {
@ContentView(R.layout.activity_album_detail)
public class AlbumDetailActivity extends BaseActivity implements TaskCallback {

@ViewInject(R.id.album_detail_head_image)
private ImageView imageView;

@ViewInject(R.id.album_detail_image)
private ImageView imageViewHead;

@ViewInject(R.id.album_detail_author_name)
private TextView textViewName;

@ViewInject(R.id.album_detail_intro)
private TextView textViewIntro;

@ViewInject(R.id.album_detail_tags)
private TextView textViewTags;

@ViewInject(R.id.album_detail_list)
private ListView listView;

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_album_detail);

ViewUtils.inject(this);

Intent intent = getIntent();
int albumId = -1;
if (intent != null) {
albumId = intent.getIntExtra("albumId", -1);
}
AlbumDetailTask task = new AlbumDetailTask(this);
task.execute(String.valueOf(albumId));
}

public void onTaskFinished(TaskResult result) {
if (result.getTaskId() == Constants.TASK_ALBUM_DETAIL) {
Object data = result.getData();
if (data != null) {
AlbumDetail albumDetail = DataParser.parseAlbumDetail((JSONObject) data);
//TODO 利用albumDetail中的数据填充相应的布局

Album album = albumDetail.getAlbum();

SetTextUtil.setText(textViewName, album.getNickname());
SetTextUtil.setText(textViewIntro, album.getIntro());
SetTextUtil.setText(textViewTags, album.getTags());

SetImageUtil.setImage(true, imageView, album.getCoverSmall(), this);
SetImageUtil.setImage(true, imageViewHead, album.getAvatarPath(), this);

AlbumDetailAdapter adapter = new AlbumDetailAdapter(albumDetail.getTracks(), this);
listView.setAdapter(adapter);

} else {

}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
package com.venn.zhufengfm.app.activity;

import android.database.sqlite.SQLiteException;
import android.media.MediaPlayer;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.Button;
import android.widget.RadioGroup;
import android.widget.*;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.venn.zhufengfm.app.R;
import com.venn.zhufengfm.app.activity.BaseActivity;
import com.venn.zhufengfm.app.fragments.CustomFragment;
import com.venn.zhufengfm.app.fragments.DiscoverFragment;
import com.venn.zhufengfm.app.fragments.DownLoadListenFragment;
import com.venn.zhufengfm.app.fragments.ProfileFragment;

import java.io.IOException;


//主界面
public class MainActivity extends BaseActivity implements RadioGroup.OnCheckedChangeListener {
public class MainActivity extends BaseActivity implements View.OnClickListener, RadioGroup.OnCheckedChangeListener {

private RadioGroup radioGroup;

Expand All @@ -26,6 +30,9 @@ public class MainActivity extends BaseActivity implements RadioGroup.OnCheckedCh
private DownLoadListenFragment downLoadListenFragment;
private ProfileFragment profileFragment;

private CheckBox checkBoxPlay;
private MediaPlayer mediaPlayer;

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Expand All @@ -35,6 +42,26 @@ protected void onCreate(Bundle savedInstanceState) {
radioGroup = (RadioGroup) this.findViewById(R.id.main_tab_bar);
radioGroup.setOnCheckedChangeListener(this);
radioGroup.check(R.id.main_tab_item_discover);

checkBoxPlay = (CheckBox) this.findViewById(R.id.main_tab_item_play);
checkBoxPlay.setOnClickListener(this);
}

protected void onResume() {
super.onResume();
mediaPlayer = new MediaPlayer();
try {
mediaPlayer.setDataSource("http://fdfs.xmcdn.com/group8/M08/52/5B/wKgDYFW2envSiMSyATE0a1NxlgI220.mp3");
mediaPlayer.prepare();
}
catch (IOException e) {
e.printStackTrace();
}
}

protected void onStop() {
mediaPlayer.release();
super.onStop();
}

public void onCheckedChanged(RadioGroup group, int checkedId) {
Expand Down Expand Up @@ -68,4 +95,20 @@ public void onCheckedChanged(RadioGroup group, int checkedId) {
protected int getExitAnimationId() {
return 0;
}


private boolean isPlay = true;

public void onClick(View v) {
if (isPlay) {
Toast.makeText(this, "Play", Toast.LENGTH_SHORT).show();
mediaPlayer.start();
} else {
if (mediaPlayer.isPlaying()) {
Toast.makeText(this, "Stop", Toast.LENGTH_SHORT).show();
mediaPlayer.pause();
}
}
isPlay = !isPlay;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
package com.venn.zhufengfm.app.adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.*;
import com.venn.zhufengfm.app.R;
import com.venn.zhufengfm.app.model.player.TrackItem;
import com.venn.zhufengfm.app.model.player.Tracks;
import com.venn.zhufengfm.app.uitl.SetTextUtil;

import java.util.List;

/**
* Created by VennUser on 2015/8/6.
*/
public class AlbumDetailAdapter extends BaseAdapter {

private Tracks tracks;
private Context context;
private List<TrackItem> trackItemList;

public AlbumDetailAdapter(Tracks tracks, Context context) {
this.tracks = tracks;
this.context = context;
trackItemList = tracks.getTrackItemList();
}

public int getCount() {

return trackItemList.size();
}

public Object getItem(int position) {
return trackItemList.get(position);
}

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

public int getItemViewType(int position) {
int type = 0;
switch (position) {
case 0:
type = 0;
break;
case 1:
type = 1;
break;
default:
type = 2;
break;
}

return type;
}

public int getViewTypeCount() {
return 3;
}

public View getView(int position, View convertView, ViewGroup parent) {
View view = null;
int type = getItemViewType(position);
Object item = getItem(position);
switch (type) {
case 0:
view = bindAlbumTab(convertView, parent);
break;
case 1:
view = bindHead(convertView, parent);
break;
default:
view = bindItem(item, convertView, parent);
break;
}

return view;
}

private View bindAlbumTab(View convertView, ViewGroup parent) {
View view = convertView == null ? LayoutInflater.from(context).inflate(R.layout.item_album_player_tab, parent,
false) : convertView;

HolderView1 holderView1 = (HolderView1) view.getTag();
if (holderView1 == null) {
holderView1 = new HolderView1();
holderView1.checkBox1 = (CheckBox) view.findViewById(R.id.album_detail_tab1);
holderView1.checkBox2 = (CheckBox) view.findViewById(R.id.album_detail_tab2);
holderView1.checkBox3 = (CheckBox) view.findViewById(R.id.album_detail_tab3);

view.setTag(holderView1);
}

return view;
}

private View bindHead(View convertView, ViewGroup parent) {
View view = convertView == null ? LayoutInflater.from(context).inflate(R.layout.item_album_player_head, parent,
false) : convertView;

HolderView2 holderView2 = (HolderView2) view.getTag();
if (holderView2 == null) {
holderView2 = new HolderView2();
holderView2.textView = (TextView) view.findViewById(R.id.album_detail_head_count);
holderView2.checkBox1 = (CheckBox) view.findViewById(R.id.album_detail_head_choose);
holderView2.checkBox2 = (CheckBox) view.findViewById(R.id.album_detail_head_sort);

view.setTag(holderView2);
}

holderView2.textView.setText("共" + tracks.getTotalCount() + "集");
return view;
}

private View bindItem(Object item, View convertView, ViewGroup parent) {
View view = convertView == null ? LayoutInflater.from(context).inflate(R.layout.album_detail_item, parent,
false) : convertView;

HolderView3 holderView3 = (HolderView3) view.getTag();
if (holderView3 == null) {
holderView3 = new HolderView3();
holderView3.textViewIntro = (TextView) view.findViewById(R.id.album_detail_item_intro);
holderView3.textViewDays = (TextView) view.findViewById(R.id.album_detail_item_day);
holderView3.checkBox1 = (CheckBox) view.findViewById(R.id.album_detail_item_playTimes);
holderView3.checkBox2 = (CheckBox) view.findViewById(R.id.album_detail_item_duration);
holderView3.checkBox3 = (CheckBox) view.findViewById(R.id.album_detail_item_comment);
holderView3.checkBox4 = (CheckBox) view.findViewById(R.id.album_detail_item_download);

view.setTag(holderView3);
}

TrackItem trackItem = (TrackItem) item;

SetTextUtil.setText(holderView3.textViewIntro, trackItem.getTitle());
SetTextUtil.setText(holderView3.textViewDays, "" + trackItem.getProcessState());
SetTextUtil.setText(holderView3.checkBox1, "" + trackItem.getPlayTimes());
SetTextUtil.setText(holderView3.checkBox2, "" + trackItem.getDuration() / 3600);
SetTextUtil.setText(holderView3.checkBox3, "" + trackItem.getComments());

return view;
}

public static class HolderView1 {
CheckBox checkBox1, checkBox2, checkBox3;
}

public static class HolderView2 {
TextView textView;
CheckBox checkBox1, checkBox2;
}

public static class HolderView3 {
TextView textViewIntro, textViewDays;
CheckBox checkBox1, checkBox2, checkBox3, checkBox4;
}
}
Loading

0 comments on commit 6d9496b

Please sign in to comment.