diff --git a/ZhuFengFM/app/app.iml b/ZhuFengFM/app/app.iml index 80beb5d..22a8854 100644 --- a/ZhuFengFM/app/app.iml +++ b/ZhuFengFM/app/app.iml @@ -113,5 +113,6 @@ + \ No newline at end of file diff --git a/ZhuFengFM/app/libs/xUtils-2.6.14.jar b/ZhuFengFM/app/libs/xUtils-2.6.14.jar new file mode 100644 index 0000000..0e8d26f Binary files /dev/null and b/ZhuFengFM/app/libs/xUtils-2.6.14.jar differ diff --git a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/activity/AlbumDetailActivity.java b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/activity/AlbumDetailActivity.java index bcdd316..d8add49 100644 --- a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/activity/AlbumDetailActivity.java +++ b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/activity/AlbumDetailActivity.java @@ -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 { + + } + } } } diff --git a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/activity/MainActivity.java b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/activity/MainActivity.java index 6e134fa..df31191 100644 --- a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/activity/MainActivity.java +++ b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/activity/MainActivity.java @@ -1,13 +1,15 @@ 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; @@ -15,9 +17,11 @@ 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; @@ -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); @@ -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) { @@ -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; + } } diff --git a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/adapters/AlbumDetailAdapter.java b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/adapters/AlbumDetailAdapter.java new file mode 100644 index 0000000..781022c --- /dev/null +++ b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/adapters/AlbumDetailAdapter.java @@ -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 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; + } +} diff --git a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/adapters/DiscoverRecommendAdapter.java b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/adapters/DiscoverRecommendAdapter.java index bf2a383..d32c410 100644 --- a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/adapters/DiscoverRecommendAdapter.java +++ b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/adapters/DiscoverRecommendAdapter.java @@ -166,6 +166,11 @@ private View bindEditorRecommendView(Object item, View convertView, ViewGroup pa holderType1.button1 = (ImageButton) view.findViewById(R.id.item_disc_rec_line1_image); holderType1.button2 = (ImageButton) view.findViewById(R.id.item_disc_rec_line2_image); holderType1.button3 = (ImageButton) view.findViewById(R.id.item_disc_rec_line3_image); + + holderType1.button1.setOnClickListener(clickListener); + holderType1.button2.setOnClickListener(clickListener); + holderType1.button3.setOnClickListener(clickListener); + holderType1.textView1 = (TextView) view.findViewById(R.id.item_disc_rec_line1_text); holderType1.textView2 = (TextView) view.findViewById(R.id.item_disc_rec_line2_text); holderType1.textView3 = (TextView) view.findViewById(R.id.item_disc_rec_line3_text); @@ -194,9 +199,13 @@ private View bindEditorRecommendView(Object item, View convertView, ViewGroup pa SetTextUtil.setText(holderType1.textView2, item1.getTrackTitle()); SetTextUtil.setText(holderType1.textView3, item2.getTrackTitle()); - SetImageUtil.setImage(holderType1.button1, item0.getCoverLarge(), context); - SetImageUtil.setImage(holderType1.button2, item1.getCoverLarge(), context); - SetImageUtil.setImage(holderType1.button3, item2.getCoverLarge(), context); + SetImageUtil.setImage(false, holderType1.button1, item0.getCoverLarge(), context); + SetImageUtil.setImage(false, holderType1.button2, item1.getCoverLarge(), context); + SetImageUtil.setImage(false, holderType1.button3, item2.getCoverLarge(), context); + + holderType1.button1.setTag(item0.getAlbumId()); + holderType1.button2.setTag(item1.getAlbumId()); + holderType1.button3.setTag(item2.getAlbumId()); } else { MyLog.d("albums state", "albums is null"); @@ -230,6 +239,9 @@ private View bindSpecialColumnsView(Object item, View convertView, ViewGroup par holderType2.block2text2 = (TextView) view.findViewById(R.id.item_disc_rec_spec_line2_right_text2); holderType2.block2text3 = (TextView) view.findViewById(R.id.item_disc_rec_spec_line2_right_text3); + holderType2.imageView1.setOnClickListener(clickListener); + holderType2.imageView2.setOnClickListener(clickListener); + view.setTag(holderType2); } @@ -250,11 +262,10 @@ private View bindSpecialColumnsView(Object item, View convertView, ViewGroup par SetTextUtil.setText(holderType2.block2text2, item1.getSubtitle()); SetTextUtil.setText(holderType2.block2text3, item1.getFootnote()); - //holderType2.imageView1.setImageResource(R.mipmap.ic_launcher); - //holderType2.imageView2.setImageResource(R.mipmap.ic_launcher); + SetImageUtil.setImage(false, holderType2.imageView1, item0.getCoverPath(), context); + SetImageUtil.setImage(false, holderType2.imageView2, item1.getCoverPath(), context); - SetImageUtil.setImage(holderType2.imageView1, item0.getCoverPath(), context); - SetImageUtil.setImage(holderType2.imageView2, item1.getCoverPath(), context); + //TODO 点击精品听单跳转到相关的介绍页面 return view; } @@ -277,6 +288,11 @@ private View bindDiscoverColumnsView(Object item, View convertView, ViewGroup pa holderType3.imageView3 = (ImageView) view.findViewById(R.id.item_disc_rec_disc_image3); holderType3.imageView4 = (ImageView) view.findViewById(R.id.item_disc_rec_disc_image4); + holderType3.imageView1.setOnClickListener(clickListener); + holderType3.imageView2.setOnClickListener(clickListener); + holderType3.imageView3.setOnClickListener(clickListener); + holderType3.imageView4.setOnClickListener(clickListener); + holderType3.line1Text1 = (TextView) view.findViewById(R.id.item_disc_rec_disc_line1_right_text1); holderType3.line1Text2 = (TextView) view.findViewById(R.id.item_disc_rec_disc_line1_right_text2); holderType3.line2Text1 = (TextView) view.findViewById(R.id.item_disc_rec_disc_line2_right_text1); @@ -307,11 +323,12 @@ private View bindDiscoverColumnsView(Object item, View convertView, ViewGroup pa SetTextUtil.setText(holderType3.line4Text1, item3.getTitle()); SetTextUtil.setText(holderType3.line4Text2, item3.getSubtitle()); - SetImageUtil.setImage(holderType3.imageView1, item0.getCoverPath(), context); - SetImageUtil.setImage(holderType3.imageView2, item1.getCoverPath(), context); - SetImageUtil.setImage(holderType3.imageView3, item2.getCoverPath(), context); - SetImageUtil.setImage(holderType3.imageView4, item3.getCoverPath(), context); + SetImageUtil.setImage(false, holderType3.imageView1, item0.getCoverPath(), context); + SetImageUtil.setImage(false, holderType3.imageView2, item1.getCoverPath(), context); + SetImageUtil.setImage(false, holderType3.imageView3, item2.getCoverPath(), context); + SetImageUtil.setImage(false, holderType3.imageView4, item3.getCoverPath(), context); + //TODO 点击发现新奇跳转到相应的介绍页面 return view; } @@ -330,6 +347,11 @@ private View bindHotColumnsView(Object item, View convertView, ViewGroup parent) holderType1.button1 = (ImageButton) view.findViewById(R.id.item_disc_rec_line1_image); holderType1.button2 = (ImageButton) view.findViewById(R.id.item_disc_rec_line2_image); holderType1.button3 = (ImageButton) view.findViewById(R.id.item_disc_rec_line3_image); + + holderType1.button1.setOnClickListener(clickListener); + holderType1.button2.setOnClickListener(clickListener); + holderType1.button3.setOnClickListener(clickListener); + holderType1.textView1 = (TextView) view.findViewById(R.id.item_disc_rec_line1_text); holderType1.textView2 = (TextView) view.findViewById(R.id.item_disc_rec_line2_text); holderType1.textView3 = (TextView) view.findViewById(R.id.item_disc_rec_line3_text); @@ -356,9 +378,13 @@ private View bindHotColumnsView(Object item, View convertView, ViewGroup parent) SetTextUtil.setText(holderType1.textView2, item1.getTrackTitle()); SetTextUtil.setText(holderType1.textView3, item2.getTrackTitle()); - SetImageUtil.setImage(holderType1.button1, item0.getCoverLarge(), context); - SetImageUtil.setImage(holderType1.button2, item1.getCoverLarge(), context); - SetImageUtil.setImage(holderType1.button3, item2.getCoverLarge(), context); + SetImageUtil.setImage(false, holderType1.button1, item0.getCoverLarge(), context); + SetImageUtil.setImage(false, holderType1.button2, item1.getCoverLarge(), context); + SetImageUtil.setImage(false, holderType1.button3, item2.getCoverLarge(), context); + + holderType1.button1.setTag(item0.getAlbumId()); + holderType1.button1.setTag(item1.getAlbumId()); + holderType1.button1.setTag(item2.getAlbumId()); return view; } @@ -384,14 +410,17 @@ private View bindFocusImage(Object item, View convertView, ViewGroup parent) { String path = itemList.get(i).getPic(); ImageView imageView = new ImageView(context); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); - SetImageUtil.setImage(imageView, path, context); + SetImageUtil.setImage(false, imageView, path, context); imageViewList.add(imageView); } myViewPager.setAdapter(new MyViewPagerAdapter(imageViewList)); myViewPager.setCurrentItem(0); ImageView imageView = (ImageView) view.findViewById(R.id.focus); - DiscoverRecommendFragment.setView(imageView, myViewPager); + if (imageView != null) { + imageView.setOnClickListener(clickListener); + DiscoverRecommendFragment.setView(imageView, myViewPager); + } return view; } diff --git a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/client/ClientJSONAPI.java b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/client/ClientJSONAPI.java new file mode 100644 index 0000000..12fc8fc --- /dev/null +++ b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/client/ClientJSONAPI.java @@ -0,0 +1,65 @@ +package com.venn.zhufengfm.app.client; + +import com.venn.zhufengfm.app.uitl.MyLog; + +/** + * Created by VennUser on 2015/7/28. + */ + +//发现部分的API接口,返回Json字符串 +public class ClientJSONAPI { + + public static final String SERVER_MOBILE = "http://mobile.ximalaya.com"; + + private ClientJSONAPI() { + + } + + //获取分类Tag菜单 + //调用接口http://mobile.ximalaya.com/m/category_tag_menu + //GET方法xgcui + //type 可选,默认为user + public static String getCategoryTagMenu(String type) { + StringBuilder sb = new StringBuilder(); + sb.append(SERVER_MOBILE).append("/m/category_tag_menu"); + if (type != null) { + sb.append("?type=" + type).append("&device=android"); + } + String path = sb.toString(); + return getJsonString(path); + } + + //获取发现Tab菜单 + //调用接口:http://mobile.ximalaya.com/mobile/discovery/v1/tabs?device=android + public static String getDiscoverTabs() { + String path = SERVER_MOBILE + "/mobile/discovery/v1/tabs?device=android"; + return getJsonString(path); + } + + //发现中的分类部分 + public static String getDiscoverCategories() { + String path = SERVER_MOBILE + "/mobile/discovery/v1/categories?device=android&picVersion=10&scale=2"; + return getJsonString(path); + } + + public static String getDiscoverRecommends() { + String path = SERVER_MOBILE + "/mobile/discovery/v1/recommends?channel=and-f6" + + "&device=android&includeActivity=true&includeSpecial=true&scale=2&version=4.1.7.1"; + return getJsonString(path); + } + + public static String getAlbumDetail(String ret) { + String path = SERVER_MOBILE + "/mobile/others/ca/album/track/203355/true/1/20?device=android&pageSize=20" + + "&albumId=" + ret + "&isAsc=true"; + return getJsonString(path); + } + + private static String getJsonString(String path) { + byte[] buffer = HttpUtils.doGet(path); + String data = null; + if (buffer != null) { + data = new String(buffer); + } + return data; + } +} diff --git a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/client/HttpUtils.java b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/client/HttpUtils.java index 57d47d0..4cebbc1 100644 --- a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/client/HttpUtils.java +++ b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/client/HttpUtils.java @@ -30,18 +30,17 @@ private HttpUtils() { public static byte[] doGet(String path) { byte[] data = null; - URL url = null; if (path != null) { HttpURLConnection connection = null; InputStream inputStream = null; try { - url = new URL(path); + URL url = new URL(path); connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); - connection.setRequestProperty("Accept:Encoding", "gzip"); + connection.setRequestProperty("Accept-Encoding", "gzip"); connection.setRequestProperty("User-Agent", "ting_4.1.7(MI2, Android" + Build.VERSION.SDK_INT + ")"); //Socket打开连接的时间 @@ -74,12 +73,8 @@ public static byte[] doGet(String path) { //读取inputStream中的数据 data = StreamUtil.readStream(inputStream); - MyLog.d("HttpUtil1", "--" + (data == null)); } } - catch (MalformedURLException e) { - e.printStackTrace(); - } catch (IOException e) { e.printStackTrace(); } diff --git a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/fragments/discover/DiscoverRecommendFragment.java b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/fragments/discover/DiscoverRecommendFragment.java index 0ad6620..719dfb1 100644 --- a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/fragments/discover/DiscoverRecommendFragment.java +++ b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/fragments/discover/DiscoverRecommendFragment.java @@ -73,22 +73,33 @@ public void onTaskFinished(TaskResult result) { } public void onClick(View view) { - String s = (String) view.getTag(); + + int albumId = -1; int id = view.getId(); if (view instanceof TextView) { switch (id) { case R.id.item_dis_rec_more: - startActivity(new Intent(activity, AlbumDetailActivity.class)); + + //TODO 点击小编推荐部分的更多 break; } } else if (view instanceof ImageView) { Toast.makeText(activity, "点击了图片", Toast.LENGTH_SHORT).show(); - switch (id) { - //TODO 点击了图片 + try { + albumId = (Integer) view.getTag(); + } + catch (Exception e) { } + Intent intent = new Intent(activity, AlbumDetailActivity.class); + intent.putExtra("albumId", albumId); + startActivity(intent); + } + + if (albumId != -1) { + } } @@ -102,16 +113,12 @@ public void onPageSelected(int position) { animator = AnimatorInflater.loadAnimator(activity, R.animator.animator_focus_image_slide); animator.setTarget(focusImageView); - //focusImageView.setLeft(0); switch (position) { case 0: case 1: case 2: case 3: case 4: - if (focusImageView != null) { - animator.start(); - } break; case 5: break; @@ -124,6 +131,7 @@ public void onPageScrollStateChanged(int position) { } + //给顶部广告部分的ViewPager添加ImageView public static void setView(ImageView focusImage, ViewPager viewP) { focusImageView = focusImage; viewPager = viewP; diff --git a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/model/player/Album.java b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/model/player/Album.java new file mode 100644 index 0000000..50dda39 --- /dev/null +++ b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/model/player/Album.java @@ -0,0 +1,258 @@ +package com.venn.zhufengfm.app.model.player; + +import com.venn.zhufengfm.app.model.jsontool.ParseJsonTool; +import org.json.JSONException; +import org.json.JSONObject; + +/** + * Created by VennUser on 2015/8/5. + */ +public class Album implements ParseJsonTool { + + private int albumId; + private int categoryId; + private String categoryName; + private String title; + private String coverOrigin; + private String coverSmall; + private String coverLarge; + private String coverWebLarge; + private long createdAt; + private long updatedAt; + private int uid; + private String nickname; + private boolean isVerified; + private String avatarPath; + private String intro; + private String introRich; + private String tags; + private int tracks; + private int shares; + private boolean hasNew; + private boolean isFavorite; + private int playTimes; + private int status; + private int serializeStatus; + + public Album() { + } + + public void parseJSON(JSONObject json) throws JSONException { + albumId = json.getInt("albumId"); + categoryId = json.getInt("categoryId"); + categoryName = json.getString("categoryName"); + title = json.getString("title"); + coverOrigin = json.getString("coverOrigin"); + coverSmall = json.getString("coverSmall"); + coverLarge = json.getString("coverLarge"); + coverWebLarge = json.getString("coverWebLarge"); + createdAt = json.getLong("createdAt"); + updatedAt = json.getLong("updatedAt"); + uid = json.getInt("uid"); + nickname = json.getString("nickname"); + isVerified = json.getBoolean("isVerified"); + avatarPath = json.getString("avatarPath"); + intro = json.getString("intro"); + introRich = json.getString("introRich"); + tags = json.getString("tags"); + tracks = json.getInt("tracks"); + shares = json.getInt("shares"); + hasNew = json.getBoolean("hasNew"); + isFavorite = json.getBoolean("isFavorite"); + playTimes = json.getInt("playTimes"); + status = json.getInt("status"); + serializeStatus = json.getInt("serializeStatus"); + } + + public int getAlbumId() { + return albumId; + } + + public void setAlbumId(int albumId) { + this.albumId = albumId; + } + + public int getCategoryId() { + return categoryId; + } + + public void setCategoryId(int categoryId) { + this.categoryId = categoryId; + } + + public String getCategoryName() { + return categoryName; + } + + public void setCategoryName(String categoryName) { + this.categoryName = categoryName; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getCoverOrigin() { + return coverOrigin; + } + + public void setCoverOrigin(String coverOrigin) { + this.coverOrigin = coverOrigin; + } + + public String getCoverSmall() { + return coverSmall; + } + + public void setCoverSmall(String coverSmall) { + this.coverSmall = coverSmall; + } + + public String getCoverLarge() { + return coverLarge; + } + + public void setCoverLarge(String coverLarge) { + this.coverLarge = coverLarge; + } + + public String getCoverWebLarge() { + return coverWebLarge; + } + + public void setCoverWebLarge(String coverWebLarge) { + this.coverWebLarge = coverWebLarge; + } + + public long getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(long createdAt) { + this.createdAt = createdAt; + } + + public long getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(long updatedAt) { + this.updatedAt = updatedAt; + } + + public int getUid() { + return uid; + } + + public void setUid(int uid) { + this.uid = uid; + } + + public String getNickname() { + return nickname; + } + + public void setNickname(String nickname) { + this.nickname = nickname; + } + + public boolean isVerified() { + return isVerified; + } + + public void setIsVerified(boolean isVerified) { + this.isVerified = isVerified; + } + + public String getAvatarPath() { + return avatarPath; + } + + public void setAvatarPath(String avatarPath) { + this.avatarPath = avatarPath; + } + + public String getIntro() { + return intro; + } + + public void setIntro(String intro) { + this.intro = intro; + } + + public String getIntroRich() { + return introRich; + } + + public void setIntroRich(String introRich) { + this.introRich = introRich; + } + + public String getTags() { + return tags; + } + + public void setTags(String tags) { + this.tags = tags; + } + + public int getTracks() { + return tracks; + } + + public void setTracks(int tracks) { + this.tracks = tracks; + } + + public int getShares() { + return shares; + } + + public void setShares(int shares) { + this.shares = shares; + } + + public boolean isHasNew() { + return hasNew; + } + + public void setHasNew(boolean hasNew) { + this.hasNew = hasNew; + } + + public boolean isFavorite() { + return isFavorite; + } + + public void setIsFavorite(boolean isFavorite) { + this.isFavorite = isFavorite; + } + + public int getPlayTimes() { + return playTimes; + } + + public void setPlayTimes(int playTimes) { + this.playTimes = playTimes; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public int getSerializeStatus() { + return serializeStatus; + } + + public void setSerializeStatus(int serializeStatus) { + this.serializeStatus = serializeStatus; + } +} diff --git a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/model/player/AlbumDetail.java b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/model/player/AlbumDetail.java new file mode 100644 index 0000000..a38e064 --- /dev/null +++ b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/model/player/AlbumDetail.java @@ -0,0 +1,60 @@ +package com.venn.zhufengfm.app.model.player; + +import com.venn.zhufengfm.app.model.jsontool.ParseJsonTool; +import org.json.JSONException; +import org.json.JSONObject; + +/** + * Created by VennUser on 2015/8/5. + */ +public class AlbumDetail implements ParseJsonTool { + + private int ret; + private Album album; + private Tracks tracks; + private String msg; + + public AlbumDetail() { + album = new Album(); + tracks = new Tracks(); + } + + public void parseJSON(JSONObject json) throws JSONException { + ret = json.getInt("ret"); + album.parseJSON(json.getJSONObject("album")); + tracks.parseJSON(json.getJSONObject("tracks")); + msg = json.getString("msg"); + } + + public int getRet() { + return ret; + } + + public void setRet(int ret) { + this.ret = ret; + } + + public Album getAlbum() { + return album; + } + + public void setAlbum(Album album) { + this.album = album; + } + + public Tracks getTracks() { + return tracks; + } + + public void setTracks(Tracks tracks) { + this.tracks = tracks; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } +} diff --git a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/model/player/TrackItem.java b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/model/player/TrackItem.java new file mode 100644 index 0000000..b398c86 --- /dev/null +++ b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/model/player/TrackItem.java @@ -0,0 +1,320 @@ +package com.venn.zhufengfm.app.model.player; + +import com.venn.zhufengfm.app.model.jsontool.ParseJsonTool; +import org.json.JSONException; +import org.json.JSONObject; + +/** + * Created by VennUser on 2015/8/5. + */ +public class TrackItem implements ParseJsonTool { + + private int trackId; + private int uid; + private String playUrl64; + private String playUrl32; + private String downloadUrl; + private String playPathAacv164; + private String playPathAacv224; + private String downloadAacUrl; + private String title; + private double duration; + private int processState; + private long createdAt; + private String coverSmall; + private String coverLarge; + private String nickname; + private String smallLogo; + private int userSource; + private int albumId; + private String albumTitle; + private String albumImage; + private int orderNum; + private int opType; + private boolean isPublic; + private int likes; + private int playTimes; + private int comments; + private int shares; + private int status; + private int downloadSize; + private int downloadAacSize; + + + public TrackItem() { + + } + + public void parseJSON(JSONObject json) throws JSONException { + trackId = json.getInt("trackId"); + uid = json.getInt("uid"); + playUrl64 = json.getString("playUrl64"); + playUrl32 = json.getString("playUrl32"); + downloadUrl = json.getString("downloadUrl"); + playPathAacv164 = json.getString("playPathAacv164"); + playPathAacv224 = json.getString("playPathAacv224"); + downloadAacUrl = json.getString("downloadAacUrl"); + title = json.getString("title"); + duration = json.getDouble("duration"); + processState = json.getInt("processState"); + createdAt = json.getLong("createdAt"); + coverSmall = json.getString("coverSmall"); + coverLarge = json.getString("coverLarge"); + nickname = json.getString("nickname"); + smallLogo = json.getString("smallLogo"); + userSource = json.getInt("userSource"); + albumId = json.getInt("albumId"); + albumTitle = json.getString("albumTitle"); + albumImage = json.getString("albumImage"); + orderNum = json.getInt("orderNum"); + opType = json.getInt("opType"); + isPublic = json.getBoolean("isPublic"); + likes = json.getInt("likes"); + playTimes = json.getInt("playtimes"); + comments = json.getInt("comments"); + shares = json.getInt("shares"); + status = json.getInt("status"); + downloadSize = json.getInt("downloadSize"); + downloadAacSize = json.getInt("downloadAacSize"); + } + + public int getTrackId() { + return trackId; + } + + public void setTrackId(int trackId) { + this.trackId = trackId; + } + + public int getUid() { + return uid; + } + + public void setUid(int uid) { + this.uid = uid; + } + + public String getPlayUrl64() { + return playUrl64; + } + + public void setPlayUrl64(String playUrl64) { + this.playUrl64 = playUrl64; + } + + public String getPlayUrl32() { + return playUrl32; + } + + public void setPlayUrl32(String playUrl32) { + this.playUrl32 = playUrl32; + } + + public String getDownloadUrl() { + return downloadUrl; + } + + public void setDownloadUrl(String downloadUrl) { + this.downloadUrl = downloadUrl; + } + + public String getPlayPathAacv164() { + return playPathAacv164; + } + + public void setPlayPathAacv164(String playPathAacv164) { + this.playPathAacv164 = playPathAacv164; + } + + public String getPlayPathAacv224() { + return playPathAacv224; + } + + public void setPlayPathAacv224(String playPathAacv224) { + this.playPathAacv224 = playPathAacv224; + } + + public String getDownloadAacUrl() { + return downloadAacUrl; + } + + public void setDownloadAacUrl(String downloadAacUrl) { + this.downloadAacUrl = downloadAacUrl; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public double getDuration() { + return duration; + } + + public void setDuration(double duration) { + this.duration = duration; + } + + public int getProcessState() { + return processState; + } + + public void setProcessState(int processState) { + this.processState = processState; + } + + public long getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(long createdAt) { + this.createdAt = createdAt; + } + + public String getCoverSmall() { + return coverSmall; + } + + public void setCoverSmall(String coverSmall) { + this.coverSmall = coverSmall; + } + + public String getCoverLarge() { + return coverLarge; + } + + public void setCoverLarge(String coverLarge) { + this.coverLarge = coverLarge; + } + + public String getNickname() { + return nickname; + } + + public void setNickname(String nickname) { + this.nickname = nickname; + } + + public String getSmallLogo() { + return smallLogo; + } + + public void setSmallLogo(String smallLogo) { + this.smallLogo = smallLogo; + } + + public int getUserSource() { + return userSource; + } + + public void setUserSource(int userSource) { + this.userSource = userSource; + } + + public int getAlbumId() { + return albumId; + } + + public void setAlbumId(int albumId) { + this.albumId = albumId; + } + + public String getAlbumTitle() { + return albumTitle; + } + + public void setAlbumTitle(String albumTitle) { + this.albumTitle = albumTitle; + } + + public String getAlbumImage() { + return albumImage; + } + + public void setAlbumImage(String albumImage) { + this.albumImage = albumImage; + } + + public int getOrderNum() { + return orderNum; + } + + public void setOrderNum(int orderNum) { + this.orderNum = orderNum; + } + + public int getOpType() { + return opType; + } + + public void setOpType(int opType) { + this.opType = opType; + } + + public boolean isPublic() { + return isPublic; + } + + public void setIsPublic(boolean isPublic) { + this.isPublic = isPublic; + } + + public int getLikes() { + return likes; + } + + public void setLikes(int likes) { + this.likes = likes; + } + + public int getPlayTimes() { + return playTimes; + } + + public void setPlayTimes(int playTimes) { + this.playTimes = playTimes; + } + + public int getComments() { + return comments; + } + + public void setComments(int comments) { + this.comments = comments; + } + + public int getShares() { + return shares; + } + + public void setShares(int shares) { + this.shares = shares; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public int getDownloadSize() { + return downloadSize; + } + + public void setDownloadSize(int downloadSize) { + this.downloadSize = downloadSize; + } + + public int getDownloadAacSize() { + return downloadAacSize; + } + + public void setDownloadAacSize(int downloadAacSize) { + this.downloadAacSize = downloadAacSize; + } +} diff --git a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/model/player/Tracks.java b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/model/player/Tracks.java new file mode 100644 index 0000000..964f1e7 --- /dev/null +++ b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/model/player/Tracks.java @@ -0,0 +1,74 @@ +package com.venn.zhufengfm.app.model.player; + +import com.venn.zhufengfm.app.model.jsontool.JsonArrayTool; +import com.venn.zhufengfm.app.model.jsontool.ParseJsonTool; +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by VennUser on 2015/8/5. + */ +public class Tracks implements ParseJsonTool { + + private List trackItemList; + private int pageId; + private int pageSize; + private int maxPageId; + private int totalCount; + + public Tracks() { + trackItemList = new ArrayList(); + } + + public void parseJSON(JSONObject json) throws JSONException { + pageId = json.getInt("pageId"); + pageSize = json.getInt("pageSize"); + maxPageId = json.getInt("maxPageId"); + totalCount = json.getInt("totalCount"); + + JsonArrayTool.getJsonArray(trackItemList, TrackItem.class, json); + } + + public List getTrackItemList() { + return trackItemList; + } + + public void setTrackItemList(List trackItemList) { + this.trackItemList = trackItemList; + } + + public int getPageId() { + return pageId; + } + + public void setPageId(int pageId) { + this.pageId = pageId; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getMaxPageId() { + return maxPageId; + } + + public void setMaxPageId(int maxPageId) { + this.maxPageId = maxPageId; + } + + public int getTotalCount() { + return totalCount; + } + + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } +} diff --git a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/parsers/DataParser.java b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/parsers/DataParser.java index c604fa3..1fd6d42 100644 --- a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/parsers/DataParser.java +++ b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/parsers/DataParser.java @@ -1,10 +1,10 @@ package com.venn.zhufengfm.app.parsers; -import android.util.Log; import com.venn.zhufengfm.app.model.discover.CategoryTagMenu; import com.venn.zhufengfm.app.model.discover.DiscoverCategory; import com.venn.zhufengfm.app.model.discover.DiscoverTab; import com.venn.zhufengfm.app.model.discover.recommend.DiscoverRecommend; +import com.venn.zhufengfm.app.model.player.AlbumDetail; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -104,4 +104,15 @@ public static DiscoverRecommend parseDiscoverRecommend(JSONObject jsonObject) { } return discoverRecommend; } + + public static AlbumDetail parseAlbumDetail(JSONObject jsonObject) { + AlbumDetail albumDetail = new AlbumDetail(); + try { + albumDetail.parseJSON(jsonObject); + } + catch (JSONException e) { + e.printStackTrace(); + } + return albumDetail; + } } diff --git a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/tasks/DiscoverCategoryTask.java b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/tasks/DiscoverCategoryTask.java index 4a8b53b..c463c98 100644 --- a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/tasks/DiscoverCategoryTask.java +++ b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/tasks/DiscoverCategoryTask.java @@ -1,7 +1,6 @@ package com.venn.zhufengfm.app.tasks; -import com.venn.zhufengfm.app.client.ClientDiscoverAPI; -import com.venn.zhufengfm.app.client.HttpUtils; +import com.venn.zhufengfm.app.client.ClientJSONAPI; import com.venn.zhufengfm.app.uitl.Constants; import org.json.JSONException; import org.json.JSONObject; @@ -19,7 +18,7 @@ protected TaskResult doInBackground(String... params) { TaskResult result = new TaskResult(); result.setTaskId(Constants.TASK_DISCOVER_CATEGORY); - String categories = ClientDiscoverAPI.getDiscoverCategories(); + String categories = ClientJSONAPI.getDiscoverCategories(); try { JSONObject jsonObject = new JSONObject(categories); result.setData(jsonObject); diff --git a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/tasks/DiscoverRecommendTask.java b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/tasks/DiscoverRecommendTask.java index e5218d8..6b87a84 100644 --- a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/tasks/DiscoverRecommendTask.java +++ b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/tasks/DiscoverRecommendTask.java @@ -1,9 +1,6 @@ package com.venn.zhufengfm.app.tasks; -import com.venn.zhufengfm.app.client.ClientDiscoverAPI; -import com.venn.zhufengfm.app.tasks.BaseTask; -import com.venn.zhufengfm.app.tasks.TaskCallback; -import com.venn.zhufengfm.app.tasks.TaskResult; +import com.venn.zhufengfm.app.client.ClientJSONAPI; import com.venn.zhufengfm.app.uitl.Constants; import org.json.JSONException; import org.json.JSONObject; @@ -20,7 +17,7 @@ public DiscoverRecommendTask(TaskCallback taskCallback) { protected TaskResult doInBackground(String... params) { TaskResult result = new TaskResult(); result.setTaskId(Constants.TASK_DISCOVER_RECOMMEND); - String recommends = ClientDiscoverAPI.getDiscoverRecommends(); + String recommends = ClientJSONAPI.getDiscoverRecommends(); try { JSONObject jsonObject = new JSONObject(recommends); result.setData(jsonObject); diff --git a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/tasks/DiscoverTabTask.java b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/tasks/DiscoverTabTask.java index 7755a8e..32805ab 100644 --- a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/tasks/DiscoverTabTask.java +++ b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/tasks/DiscoverTabTask.java @@ -1,6 +1,6 @@ package com.venn.zhufengfm.app.tasks; -import com.venn.zhufengfm.app.client.ClientDiscoverAPI; +import com.venn.zhufengfm.app.client.ClientJSONAPI; import com.venn.zhufengfm.app.uitl.Constants; import org.json.JSONException; import org.json.JSONObject; @@ -21,7 +21,7 @@ protected TaskResult doInBackground(String... params) { TaskResult result = new TaskResult(); result.setTaskId(Constants.TASK_DISCOVER_TAB); - String tabs = ClientDiscoverAPI.getDiscoverTabs(); + String tabs = ClientJSONAPI.getDiscoverTabs(); if (tabs != null) { try { result.setData(new JSONObject(tabs)); diff --git a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/tasks/ImageLoadTask.java b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/tasks/ImageLoadTask.java index e14726e..f825e9b 100644 --- a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/tasks/ImageLoadTask.java +++ b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/tasks/ImageLoadTask.java @@ -47,24 +47,24 @@ protected Bitmap doInBackground(String... params) { bitmap = BitmapFactory.decodeByteArray(data, 0, data.length); } - //进行二次采样 - - //1 只获取尺寸 - BitmapFactory.Options options = new BitmapFactory.Options(); - - //2 计算采样比率 - //3 设置Options为实际解析图片并设置采样比率 - options.inJustDecodeBounds = false; - options.inPurgeable = true; - - //设置解码器可以使用的解码像素颜色,注意透明度与颜色的管理 - //不能使用将自动使用ARGB_8888 - //options.inPreferredConfig = Bitmap.Config.ARGB_4444; - - options.inSampleSize = ImageSampleUtil.calculateInSampleSize(options, imageView.getWidth(), imageView - .getHeight()); - - BitmapFactory.decodeByteArray(data, 0, data.length, options); +// //进行二次采样 +// +// //1 只获取尺寸 +// BitmapFactory.Options options = new BitmapFactory.Options(); +// +// //2 计算采样比率 +// //3 设置Options为实际解析图片并设置采样比率 +// options.inJustDecodeBounds = false; +// options.inPurgeable = true; +// +// //设置解码器可以使用的解码像素颜色,注意透明度与颜色的管理 +// //不能使用将自动使用ARGB_8888 +// //options.inPreferredConfig = Bitmap.Config.ARGB_4444; +// +// options.inSampleSize = ImageSampleUtil.calculateInSampleSize(options, imageView.getWidth(), imageView +// .getHeight()); +// +// BitmapFactory.decodeByteArray(data, 0, data.length, options); } MyLog.d("bitmap", "--" + (bitmap == null)); diff --git a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/tasks/impl/AlbumDetailTask.java b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/tasks/impl/AlbumDetailTask.java new file mode 100644 index 0000000..5c9a5df --- /dev/null +++ b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/tasks/impl/AlbumDetailTask.java @@ -0,0 +1,39 @@ +package com.venn.zhufengfm.app.tasks.impl; + +import com.venn.zhufengfm.app.client.ClientJSONAPI; +import com.venn.zhufengfm.app.tasks.BaseTask; +import com.venn.zhufengfm.app.tasks.TaskCallback; +import com.venn.zhufengfm.app.tasks.TaskResult; +import com.venn.zhufengfm.app.uitl.Constants; +import com.venn.zhufengfm.app.uitl.MyLog; +import org.json.JSONException; +import org.json.JSONObject; + +/** + * Created by VennUser on 2015/8/5. + */ +public class AlbumDetailTask extends BaseTask { + public AlbumDetailTask(TaskCallback taskCallback) { + super(taskCallback); + } + + protected TaskResult doInBackground(String... params) { + TaskResult result = new TaskResult(); + + String ret = params[0]; + result.setTaskId(Constants.TASK_ALBUM_DETAIL); + String album = ClientJSONAPI.getAlbumDetail(ret); + try { + if (album != null) { + JSONObject json = new JSONObject(album); + result.setData(json); + } else { + MyLog.d("TaskResult doInBackground", "album is null"); + } + } + catch (JSONException e) { + e.printStackTrace(); + } + return result; + } +} diff --git a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/tasks/impl/CategoryTagMenuTask.java b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/tasks/impl/CategoryTagMenuTask.java index af9b577..a0c9667 100644 --- a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/tasks/impl/CategoryTagMenuTask.java +++ b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/tasks/impl/CategoryTagMenuTask.java @@ -1,6 +1,6 @@ package com.venn.zhufengfm.app.tasks.impl; -import com.venn.zhufengfm.app.client.ClientDiscoverAPI; +import com.venn.zhufengfm.app.client.ClientJSONAPI; import com.venn.zhufengfm.app.tasks.BaseTask; import com.venn.zhufengfm.app.tasks.TaskCallback; import com.venn.zhufengfm.app.tasks.TaskResult; @@ -27,7 +27,7 @@ protected TaskResult doInBackground(String... params) { if (params != null && params.length > 0) { type = params[0]; } - String str = ClientDiscoverAPI.getCategoryTagMenu(type); + String str = ClientJSONAPI.getCategoryTagMenu(type); if (str != null) { try { diff --git a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/uitl/Constants.java b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/uitl/Constants.java index c58a6f0..4f38149 100644 --- a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/uitl/Constants.java +++ b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/uitl/Constants.java @@ -12,6 +12,8 @@ public class Constants { public static final int TASK_DISCOVER_TAB = 2; public static final int TASK_DISCOVER_CATEGORY = 3; public static final int TASK_DISCOVER_RECOMMEND = 4; + public static final int TASK_ALBUM_DETAIL = 5; + public static final String SP_NAME = "app"; public static final String SP_KEY_GUIDE_LAST_SHOW_VER = "glsv"; public static final String EDITOR = "editor"; diff --git a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/uitl/SetImageUtil.java b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/uitl/SetImageUtil.java index 613c307..3571e11 100644 --- a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/uitl/SetImageUtil.java +++ b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/uitl/SetImageUtil.java @@ -15,38 +15,48 @@ * Created by VennUser on 2015/8/1. */ public final class SetImageUtil { - public static void setImage(ImageView imageView, String path, Context context) { - boolean needLoad = true; + public static void setImage(boolean needLoad, ImageView imageView, String path, Context context) { Object tag = imageView.getTag(); - Bitmap bitmap = MemoryCache.getInstance().getBitmapFromMemory(path); - if (bitmap == null) { - byte[] data = FileCache.createInstance(context).loadFile(path); - if (data != null) { - bitmap = BitmapFactory.decodeByteArray(data, 0, data.length); + if (needLoad) { + imageView.setTag(tag); + ImageLoadTask task = new ImageLoadTask(imageView, context); + if (Build.VERSION.SDK_INT >= 11) { + task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, path); + } else { + task.execute(path); } + } else { + + boolean otherLoad = true; + Bitmap bitmap = MemoryCache.getInstance().getBitmapFromMemory(path); if (bitmap == null) { - if (tag != null) { - if (tag instanceof String) { - if (tag.equals(path)) { - needLoad = false; + byte[] data = FileCache.createInstance(context).loadFile(path); + if (data != null) { + bitmap = BitmapFactory.decodeByteArray(data, 0, data.length); + } + if (bitmap == null) { + if (tag != null) { + if (tag instanceof String) { + if (tag.equals(path)) { + otherLoad = false; + } } } + } else { + imageView.setImageBitmap(bitmap); } } else { imageView.setImageBitmap(bitmap); } - } else { - imageView.setImageBitmap(bitmap); - } - - if (needLoad) { - imageView.setTag(tag); - ImageLoadTask task = new ImageLoadTask(imageView, context); - if (Build.VERSION.SDK_INT >= 11) { - task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, path); - } else { - task.execute(path); + if (otherLoad) { + imageView.setTag(tag); + ImageLoadTask task = new ImageLoadTask(imageView, context); + if (Build.VERSION.SDK_INT >= 11) { + task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, path); + } else { + task.execute(path); + } } } } diff --git a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/uitl/SetTextUtil.java b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/uitl/SetTextUtil.java index ac2e88f..8f5d8ed 100644 --- a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/uitl/SetTextUtil.java +++ b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/uitl/SetTextUtil.java @@ -1,6 +1,7 @@ package com.venn.zhufengfm.app.uitl; import android.view.View; +import android.view.ViewGroup; import android.widget.TextView; /** diff --git a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/uitl/StreamUtil.java b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/uitl/StreamUtil.java index a4347ff..d18b738 100644 --- a/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/uitl/StreamUtil.java +++ b/ZhuFengFM/app/src/main/java/com/venn/zhufengfm/app/uitl/StreamUtil.java @@ -15,7 +15,6 @@ private StreamUtil() { } public static byte[] readStream(InputStream in) { - byte[] data = null; ByteArrayOutputStream baos = null; if (in != null) { @@ -47,7 +46,6 @@ public static byte[] readStream(InputStream in) { public static void close(Object stream) { if (stream != null) { - try { if (stream instanceof InputStream) { ((InputStream) stream).close(); diff --git a/ZhuFengFM/app/src/main/res/drawable/album_play_count.png b/ZhuFengFM/app/src/main/res/drawable/album_play_count.png new file mode 100644 index 0000000..b81074d Binary files /dev/null and b/ZhuFengFM/app/src/main/res/drawable/album_play_count.png differ diff --git a/ZhuFengFM/app/src/main/res/drawable/bg_myitem_comments.png b/ZhuFengFM/app/src/main/res/drawable/bg_myitem_comments.png new file mode 100644 index 0000000..f104d3a Binary files /dev/null and b/ZhuFengFM/app/src/main/res/drawable/bg_myitem_comments.png differ diff --git a/ZhuFengFM/app/src/main/res/drawable/bg_myitem_playtimes_new.png b/ZhuFengFM/app/src/main/res/drawable/bg_myitem_playtimes_new.png new file mode 100644 index 0000000..709800a Binary files /dev/null and b/ZhuFengFM/app/src/main/res/drawable/bg_myitem_playtimes_new.png differ diff --git a/ZhuFengFM/app/src/main/res/drawable/download_item_normal.png b/ZhuFengFM/app/src/main/res/drawable/download_item_normal.png new file mode 100644 index 0000000..41bb97b Binary files /dev/null and b/ZhuFengFM/app/src/main/res/drawable/download_item_normal.png differ diff --git a/ZhuFengFM/app/src/main/res/drawable/live_play_num.png b/ZhuFengFM/app/src/main/res/drawable/live_play_num.png new file mode 100644 index 0000000..7099993 Binary files /dev/null and b/ZhuFengFM/app/src/main/res/drawable/live_play_num.png differ diff --git a/ZhuFengFM/app/src/main/res/drawable/load_wait.png b/ZhuFengFM/app/src/main/res/drawable/load_wait.png new file mode 100644 index 0000000..3504363 Binary files /dev/null and b/ZhuFengFM/app/src/main/res/drawable/load_wait.png differ diff --git a/ZhuFengFM/app/src/main/res/drawable/selector_album_head1.xml b/ZhuFengFM/app/src/main/res/drawable/selector_album_head1.xml new file mode 100644 index 0000000..b486b51 --- /dev/null +++ b/ZhuFengFM/app/src/main/res/drawable/selector_album_head1.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ZhuFengFM/app/src/main/res/drawable/selector_album_head2.xml b/ZhuFengFM/app/src/main/res/drawable/selector_album_head2.xml new file mode 100644 index 0000000..f709ae7 --- /dev/null +++ b/ZhuFengFM/app/src/main/res/drawable/selector_album_head2.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/ZhuFengFM/app/src/main/res/drawable/selector_album_tab1.xml b/ZhuFengFM/app/src/main/res/drawable/selector_album_tab1.xml new file mode 100644 index 0000000..f1e9f04 --- /dev/null +++ b/ZhuFengFM/app/src/main/res/drawable/selector_album_tab1.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/ZhuFengFM/app/src/main/res/drawable/selector_album_tab2.xml b/ZhuFengFM/app/src/main/res/drawable/selector_album_tab2.xml new file mode 100644 index 0000000..12f5784 --- /dev/null +++ b/ZhuFengFM/app/src/main/res/drawable/selector_album_tab2.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/ZhuFengFM/app/src/main/res/drawable/selector_album_tab3.xml b/ZhuFengFM/app/src/main/res/drawable/selector_album_tab3.xml new file mode 100644 index 0000000..752be7a --- /dev/null +++ b/ZhuFengFM/app/src/main/res/drawable/selector_album_tab3.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/ZhuFengFM/app/src/main/res/layout/activity_album_detail.xml b/ZhuFengFM/app/src/main/res/layout/activity_album_detail.xml index 9bdb4d7..5fc8870 100644 --- a/ZhuFengFM/app/src/main/res/layout/activity_album_detail.xml +++ b/ZhuFengFM/app/src/main/res/layout/activity_album_detail.xml @@ -2,34 +2,32 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:paddingLeft="@dimen/activity_horizontal_margin" - android:paddingRight="@dimen/activity_horizontal_margin" - android:paddingTop="@dimen/activity_vertical_margin" - android:paddingBottom="@dimen/activity_vertical_margin" android:orientation="vertical" tools:context="com.venn.zhufengfm.app.activity.AlbumDetailActivity" + android:background="@mipmap/album_head_bg" > @@ -98,47 +96,28 @@ > - - - - + diff --git a/ZhuFengFM/app/src/main/res/layout/activity_main.xml b/ZhuFengFM/app/src/main/res/layout/activity_main.xml index 6450da5..cc33e44 100644 --- a/ZhuFengFM/app/src/main/res/layout/activity_main.xml +++ b/ZhuFengFM/app/src/main/res/layout/activity_main.xml @@ -24,7 +24,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" - android:gravity="center" + android:gravity="center" > diff --git a/ZhuFengFM/app/src/main/res/layout/album_detail_item.xml b/ZhuFengFM/app/src/main/res/layout/album_detail_item.xml new file mode 100644 index 0000000..ea1b467 --- /dev/null +++ b/ZhuFengFM/app/src/main/res/layout/album_detail_item.xml @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ZhuFengFM/app/src/main/res/layout/item_album_player_head.xml b/ZhuFengFM/app/src/main/res/layout/item_album_player_head.xml new file mode 100644 index 0000000..c5612a3 --- /dev/null +++ b/ZhuFengFM/app/src/main/res/layout/item_album_player_head.xml @@ -0,0 +1,42 @@ + + + + + + + + + \ No newline at end of file diff --git a/ZhuFengFM/app/src/main/res/layout/item_album_player_tab.xml b/ZhuFengFM/app/src/main/res/layout/item_album_player_tab.xml new file mode 100644 index 0000000..478c9c0 --- /dev/null +++ b/ZhuFengFM/app/src/main/res/layout/item_album_player_tab.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ZhuFengFM/app/src/main/res/mipmap-hdpi/album_head_bg.jpg b/ZhuFengFM/app/src/main/res/mipmap-hdpi/album_head_bg.jpg new file mode 100644 index 0000000..0f2ee17 Binary files /dev/null and b/ZhuFengFM/app/src/main/res/mipmap-hdpi/album_head_bg.jpg differ diff --git a/ZhuFengFM/app/src/main/res/mipmap-hdpi/bg_myitem_comments.png b/ZhuFengFM/app/src/main/res/mipmap-hdpi/bg_myitem_comments.png new file mode 100644 index 0000000..f104d3a Binary files /dev/null and b/ZhuFengFM/app/src/main/res/mipmap-hdpi/bg_myitem_comments.png differ diff --git a/ZhuFengFM/app/src/main/res/mipmap-hdpi/bg_recommend_album.png b/ZhuFengFM/app/src/main/res/mipmap-hdpi/bg_recommend_album.png new file mode 100644 index 0000000..91ddaa9 Binary files /dev/null and b/ZhuFengFM/app/src/main/res/mipmap-hdpi/bg_recommend_album.png differ diff --git a/ZhuFengFM/app/src/main/res/mipmap-hdpi/download_down.png b/ZhuFengFM/app/src/main/res/mipmap-hdpi/download_down.png index 5f5e0aa..576eed2 100644 Binary files a/ZhuFengFM/app/src/main/res/mipmap-hdpi/download_down.png and b/ZhuFengFM/app/src/main/res/mipmap-hdpi/download_down.png differ diff --git a/ZhuFengFM/app/src/main/res/mipmap-hdpi/download_item_disable.png b/ZhuFengFM/app/src/main/res/mipmap-hdpi/download_item_disable.png index 3475d50..9032417 100644 Binary files a/ZhuFengFM/app/src/main/res/mipmap-hdpi/download_item_disable.png and b/ZhuFengFM/app/src/main/res/mipmap-hdpi/download_item_disable.png differ diff --git a/ZhuFengFM/app/src/main/res/mipmap-hdpi/download_item_normal.png b/ZhuFengFM/app/src/main/res/mipmap-hdpi/download_item_normal.png index 70aa414..41bb97b 100644 Binary files a/ZhuFengFM/app/src/main/res/mipmap-hdpi/download_item_normal.png and b/ZhuFengFM/app/src/main/res/mipmap-hdpi/download_item_normal.png differ diff --git a/ZhuFengFM/app/src/main/res/mipmap-hdpi/download_item_pressed.png b/ZhuFengFM/app/src/main/res/mipmap-hdpi/download_item_pressed.png index 7876aae..b190ae9 100644 Binary files a/ZhuFengFM/app/src/main/res/mipmap-hdpi/download_item_pressed.png and b/ZhuFengFM/app/src/main/res/mipmap-hdpi/download_item_pressed.png differ diff --git a/ZhuFengFM/app/src/main/res/mipmap-hdpi/ic_album_collect.png b/ZhuFengFM/app/src/main/res/mipmap-hdpi/ic_album_collect.png new file mode 100644 index 0000000..5fce25c Binary files /dev/null and b/ZhuFengFM/app/src/main/res/mipmap-hdpi/ic_album_collect.png differ diff --git a/ZhuFengFM/app/src/main/res/mipmap-hdpi/ic_album_collected.png b/ZhuFengFM/app/src/main/res/mipmap-hdpi/ic_album_collected.png new file mode 100644 index 0000000..566ffae Binary files /dev/null and b/ZhuFengFM/app/src/main/res/mipmap-hdpi/ic_album_collected.png differ diff --git a/ZhuFengFM/app/src/main/res/mipmap-hdpi/ic_album_download_normal.png b/ZhuFengFM/app/src/main/res/mipmap-hdpi/ic_album_download_normal.png new file mode 100644 index 0000000..238b038 Binary files /dev/null and b/ZhuFengFM/app/src/main/res/mipmap-hdpi/ic_album_download_normal.png differ diff --git a/ZhuFengFM/app/src/main/res/mipmap-hdpi/ic_album_sort_asc.png b/ZhuFengFM/app/src/main/res/mipmap-hdpi/ic_album_sort_asc.png new file mode 100644 index 0000000..17dc528 Binary files /dev/null and b/ZhuFengFM/app/src/main/res/mipmap-hdpi/ic_album_sort_asc.png differ diff --git a/ZhuFengFM/app/src/main/res/mipmap-hdpi/ic_album_sort_asc_disable.png b/ZhuFengFM/app/src/main/res/mipmap-hdpi/ic_album_sort_asc_disable.png new file mode 100644 index 0000000..fece138 Binary files /dev/null and b/ZhuFengFM/app/src/main/res/mipmap-hdpi/ic_album_sort_asc_disable.png differ diff --git a/ZhuFengFM/app/src/main/res/mipmap-hdpi/ic_album_sort_desc.png b/ZhuFengFM/app/src/main/res/mipmap-hdpi/ic_album_sort_desc.png new file mode 100644 index 0000000..e266572 Binary files /dev/null and b/ZhuFengFM/app/src/main/res/mipmap-hdpi/ic_album_sort_desc.png differ diff --git a/ZhuFengFM/app/src/main/res/mipmap-hdpi/ic_album_sort_desc_disable.png b/ZhuFengFM/app/src/main/res/mipmap-hdpi/ic_album_sort_desc_disable.png new file mode 100644 index 0000000..e023851 Binary files /dev/null and b/ZhuFengFM/app/src/main/res/mipmap-hdpi/ic_album_sort_desc_disable.png differ diff --git a/ZhuFengFM/app/src/main/res/mipmap-hdpi/load_wait.png b/ZhuFengFM/app/src/main/res/mipmap-hdpi/load_wait.png new file mode 100644 index 0000000..3504363 Binary files /dev/null and b/ZhuFengFM/app/src/main/res/mipmap-hdpi/load_wait.png differ diff --git a/ZhuFengFM/app/src/main/res/mipmap-hdpi/pager_selector.png b/ZhuFengFM/app/src/main/res/mipmap-hdpi/pager_selector.png new file mode 100644 index 0000000..2fff337 Binary files /dev/null and b/ZhuFengFM/app/src/main/res/mipmap-hdpi/pager_selector.png differ diff --git a/ZhuFengFM/app/src/main/res/mipmap-hdpi/play_icon_whtie.png b/ZhuFengFM/app/src/main/res/mipmap-hdpi/play_icon_whtie.png new file mode 100644 index 0000000..dbfa671 Binary files /dev/null and b/ZhuFengFM/app/src/main/res/mipmap-hdpi/play_icon_whtie.png differ diff --git a/ZhuFengFM/app/src/main/res/mipmap-hdpi/play_times_white.png b/ZhuFengFM/app/src/main/res/mipmap-hdpi/play_times_white.png new file mode 100644 index 0000000..e495ace Binary files /dev/null and b/ZhuFengFM/app/src/main/res/mipmap-hdpi/play_times_white.png differ diff --git a/ZhuFengFM/app/src/main/res/mipmap-hdpi/recommend.png b/ZhuFengFM/app/src/main/res/mipmap-hdpi/recommend.png new file mode 100644 index 0000000..fc904b9 Binary files /dev/null and b/ZhuFengFM/app/src/main/res/mipmap-hdpi/recommend.png differ diff --git a/ZhuFengFM/docs/design/04-interface/api.txt b/ZhuFengFM/docs/design/04-interface/api.txt index d10b632..ce45a1c 100644 --- a/ZhuFengFM/docs/design/04-interface/api.txt +++ b/ZhuFengFM/docs/design/04-interface/api.txt @@ -216,7 +216,7 @@ http://mobile.ximalaya.com/mobile/discovery/v1/category/album URL: - http://mobile.ximalaya.com/mobile/others/ca/album/track/203355/true/1/20?device=android&pageSize=20&albumId=203355&isAsc=true + http://mobile.ximalaya.com/mobile/others/ca/album/track/203355/true/1/20?device=android&pageSize=20&albumId=276377&isAsc=true 参数顺序