-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
재생목록 리스트 표시 realm 저장방식 변경
- Loading branch information
Showing
16 changed files
with
424 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package kr.edcan.u_stream; | ||
|
||
import android.content.Context; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.widget.ListView; | ||
import android.widget.TextView; | ||
|
||
import com.orhanobut.logger.Logger; | ||
|
||
import java.util.ArrayList; | ||
|
||
import butterknife.Bind; | ||
import butterknife.ButterKnife; | ||
import butterknife.OnClick; | ||
import io.realm.Realm; | ||
import io.realm.RealmConfiguration; | ||
import kr.edcan.u_stream.adapter.PlaylistListAdapter; | ||
import kr.edcan.u_stream.model.MusicData; | ||
import kr.edcan.u_stream.model.RM_MusicData; | ||
|
||
/** | ||
* Created by LNTCS on 2016-07-08. | ||
*/ | ||
public class PlayListActivity extends AppCompatActivity { | ||
|
||
@Bind(R.id.toolbar_title) | ||
TextView toolbarTitle; | ||
@Bind(R.id.playlist_list) | ||
ListView listView; | ||
|
||
ArrayList<MusicData> mList = new ArrayList<>(); | ||
|
||
private Realm realm; | ||
private RealmConfiguration realmConfig; | ||
PlaylistListAdapter playlistListAdapter; | ||
|
||
Context mContext; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_playlist); | ||
ButterKnife.bind(this); | ||
Logger.init("asdf"); | ||
mContext = this; | ||
toolbarTitle.setText(getIntent().getStringExtra("title")); | ||
realmConfig = new RealmConfiguration.Builder(mContext).build(); | ||
realm = Realm.getInstance(realmConfig); | ||
for(RM_MusicData data : realm.where(RM_MusicData.class).equalTo("playListId", getIntent().getIntExtra("id",0)).findAll()){ | ||
mList.add(new MusicData(data)); | ||
} | ||
playlistListAdapter = new PlaylistListAdapter(mContext, mList, toolbarTitle.getText()); | ||
listView.setAdapter(playlistListAdapter); | ||
} | ||
|
||
@OnClick(R.id.toolbar_back) void back(){ | ||
onBackPressed(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
app/src/main/java/kr/edcan/u_stream/adapter/PlaylistListAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package kr.edcan.u_stream.adapter; | ||
|
||
import android.content.Context; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ArrayAdapter; | ||
import android.widget.ImageButton; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import com.bumptech.glide.Glide; | ||
import com.google.gson.Gson; | ||
import com.orhanobut.logger.Logger; | ||
|
||
import java.util.ArrayList; | ||
|
||
import kr.edcan.u_stream.R; | ||
import kr.edcan.u_stream.model.MusicData; | ||
import kr.edcan.u_stream.util.DialogUtil; | ||
import kr.edcan.u_stream.util.PlayUtil; | ||
|
||
/** | ||
* Created by LNTCS on 2016-03-16. | ||
*/ | ||
public class PlaylistListAdapter extends ArrayAdapter<MusicData> { | ||
// 레이아웃 XML을 읽어들이기 위한 객체 | ||
private LayoutInflater mInflater; | ||
Context mContext; | ||
String playlistTitle; | ||
|
||
public PlaylistListAdapter(Context context, ArrayList<MusicData> object, CharSequence title){ | ||
// 상위 클래스의 초기화 과정 | ||
// context, 0, 자료구조 | ||
super(context,0,object); | ||
mContext = context; | ||
mInflater=(LayoutInflater)context | ||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE); | ||
this.playlistTitle = title.toString(); | ||
} | ||
|
||
private PlaylistListAdapter getAdapter(){ | ||
return this; | ||
} | ||
@Override | ||
public View getView(final int position, View v, ViewGroup parent){ | ||
View view = null; | ||
if (v == null) { | ||
view = mInflater.inflate(R.layout.content_playlist_list, null); | ||
view.setTag(position); | ||
} else { | ||
view = v; | ||
} | ||
|
||
final MusicData data=this.getItem(position); | ||
|
||
if(data!=null){ | ||
final TextView title = (TextView)view.findViewById(R.id.playlist_list_title); | ||
TextView uploader = (TextView)view.findViewById(R.id.playlist_list_uploader); | ||
ImageView thumb = (ImageView) view.findViewById(R.id.playlist_list_img); | ||
ImageButton delete = (ImageButton)view.findViewById(R.id.playlist_list_delete); | ||
ImageButton play = (ImageButton)view.findViewById(R.id.playlist_list_play); | ||
|
||
title.setText(data.getTitle()); | ||
uploader.setText(data.getUploader()); | ||
Glide.with(mContext) | ||
.load(data.getThumbnail()) | ||
.crossFade() | ||
.into(thumb); | ||
|
||
play.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
Logger.json(new Gson().toJson(data)); | ||
PlayUtil.runService(mContext, data, true); | ||
} | ||
}); | ||
|
||
delete.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
DialogUtil.deletePlayListDialog(mContext, data, playlistTitle, getAdapter()); | ||
} | ||
}); | ||
} | ||
return view; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.