提交 8bb10d59 编写于 作者: W wm

修复一些问题

上级 d51904b2
无法预览此类型文件
......@@ -32,7 +32,7 @@ import com.wm.remusic.R;
/**
* @author xyczero617@gmail.com
* @time 16/2/1
* <p/>
* <p>
* special view for replacing view in preference , not recommend to use it in common
* layout: select_dialog_singlechoice_xxx
*/
......
......@@ -27,7 +27,7 @@ import com.wm.remusic.uitl.ThemeHelper;
*/
public class MainApplication extends Application implements ThemeUtils.switchColor {
public static Context context;
// private RefWatcher refWatcher;
// private RefWatcher refWatcher;
private static int MAX_MEM = (int) Runtime.getRuntime().maxMemory() / 4;
//private static int MAX_MEM = 60 * ByteConstants.MB;
private long favPlaylist = IConstants.FAV_PLAYLIST;
......@@ -155,7 +155,7 @@ public class MainApplication extends Application implements ThemeUtils.switchCol
}
ThemeUtils.setSwitchColor(this);
// refWatcher = LeakCanary.install(this);
// LeakCanary.install(this);
// LeakCanary.install(this);
initCatchException();
if (!PreferencesUtility.getInstance(this).getFavriateMusicPlaylist()) {
......
......@@ -609,7 +609,7 @@ public class PlayingActivity extends BaseActivity implements IConstants {
//修复从playactivity回到Main界面null
if (needleAnim == null) {
needleAnim = ObjectAnimator.ofFloat(needle, "rotation", -30, 0);
needleAnim.setDuration(60);
needleAnim.setDuration(200);
needleAnim.setRepeatMode(0);
needleAnim.setInterpolator(new LinearInterpolator());
}
......
package com.wm.remusic.adapter;
import android.app.Activity;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
......@@ -19,10 +19,10 @@ import java.util.List;
public class MusicFlowAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements View.OnClickListener {
private List<OverFlowItem> mList;
private MusicInfo musicInfo;
private Activity mContext;
private Context mContext;
private OnRecyclerViewItemClickListener mOnItemClickListener = null;
public MusicFlowAdapter(Activity context, List<OverFlowItem> list, MusicInfo info) {
public MusicFlowAdapter(Context context, List<OverFlowItem> list, MusicInfo info) {
mList = list;
musicInfo = info;
mContext = context;
......
package com.wm.remusic.adapter;
import android.app.Activity;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
......@@ -21,10 +20,10 @@ public class OverFlowAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
private List<OverFlowItem> mList;
private List<MusicInfo> musicInfos;
private Context mContext;
private Activity activity;
private Context activity;
private OnRecyclerViewItemClickListener mOnItemClickListener = null;
public OverFlowAdapter(Activity activity, List<OverFlowItem> list, List<MusicInfo> info) {
public OverFlowAdapter(Context activity, List<OverFlowItem> list, List<MusicInfo> info) {
mList = list;
musicInfos = info;
this.activity = activity;
......
......@@ -69,27 +69,28 @@ public class AlbumDetailFragment extends BaseFragment {
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
layoutManager = new LinearLayoutManager(getActivity());
layoutManager = new LinearLayoutManager(mContext);
recyclerView.setLayoutManager(layoutManager);
mAdapter = new AlbumDetailAdapter(null);
recyclerView.setAdapter(mAdapter);
itemDecoration = new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST);
itemDecoration = new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST);
recyclerView.addItemDecoration(itemDecoration);
recyclerView.setHasFixedSize(true);
reloadAdapter();
AlbumInfo albumInfo = MusicUtils.getAlbumInfo(getContext(), albumID);
AlbumInfo albumInfo = MusicUtils.getAlbumInfo(mContext, albumID);
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
toolbar.setPadding(0, CommonUtils.getStatusHeight(getActivity()), 0, 0);
((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
ab = ((AppCompatActivity) getActivity()).getSupportActionBar();
toolbar.setPadding(0, CommonUtils.getStatusHeight(mContext), 0, 0);
((AppCompatActivity) mContext).setSupportActionBar(toolbar);
ab = ((AppCompatActivity) mContext).getSupportActionBar();
ab.setHomeAsUpIndicator(R.drawable.actionbar_back);
ab.setDisplayHomeAsUpEnabled(true);
ab.setTitle(albumInfo.album_name);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().onBackPressed();
if (getActivity() != null)
getActivity().onBackPressed();
}
});
......@@ -108,7 +109,7 @@ public class AlbumDetailFragment extends BaseFragment {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(final Void... unused) {
List<MusicInfo> albumList = MusicUtils.queryMusic(getActivity(), albumID + "", IConstants.START_FROM_ALBUM);
List<MusicInfo> albumList = MusicUtils.queryMusic(mContext, albumID + "", IConstants.START_FROM_ALBUM);
mAdapter.updateDataSet((ArrayList) albumList);
return null;
}
......@@ -157,9 +158,9 @@ public class AlbumDetailFragment extends BaseFragment {
((CommonItemViewHolder) holder).select.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), SelectActivity.class);
Intent intent = new Intent(mContext, SelectActivity.class);
intent.putParcelableArrayListExtra("ids", mList);
getActivity().startActivity(intent);
mContext.startActivity(intent);
}
});
}
......@@ -198,7 +199,7 @@ public class AlbumDetailFragment extends BaseFragment {
//播放专辑
@Override
public void onClick(View v) {
HandlerUtil.getInstance(getContext()).postDelayed(new Runnable() {
HandlerUtil.getInstance(mContext).postDelayed(new Runnable() {
@Override
public void run() {
long[] list = new long[mList.size()];
......@@ -245,7 +246,7 @@ public class AlbumDetailFragment extends BaseFragment {
//播放歌曲
@Override
public void onClick(View v) {
HandlerUtil.getInstance(getContext()).postDelayed(new Runnable() {
HandlerUtil.getInstance(mContext).postDelayed(new Runnable() {
@Override
public void run() {
long[] list = new long[mList.size()];
......
......@@ -63,7 +63,7 @@ public class AlbumFragment extends BaseFragment {
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mPreferences = PreferencesUtility.getInstance(getActivity());
mPreferences = PreferencesUtility.getInstance(mContext);
}
@Override
......@@ -71,7 +71,7 @@ public class AlbumFragment extends BaseFragment {
View view = inflater.inflate(R.layout.recylerview, container, false);
isAZSort = mPreferences.getAlbumSortOrder().equals(SortOrder.AlbumSortOrder.ALBUM_A_Z);
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
layoutManager = new LinearLayoutManager(getActivity());
layoutManager = new LinearLayoutManager(mContext);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setHasFixedSize(true);
mAdapter = new AlbumAdapter(null);
......@@ -141,7 +141,7 @@ public class AlbumFragment extends BaseFragment {
//设置分割线
private void setItemDecoration() {
itemDecoration = new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST);
itemDecoration = new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST);
recyclerView.addItemDecoration(itemDecoration);
}
......@@ -152,7 +152,7 @@ public class AlbumFragment extends BaseFragment {
protected Void doInBackground(final Void... unused) {
isAZSort = mPreferences.getAlbumSortOrder().equals(SortOrder.AlbumSortOrder.ALBUM_A_Z);
Log.e("sort", isAZSort + "");
List<AlbumInfo> albumList = MusicUtils.queryAlbums(getContext());
List<AlbumInfo> albumList = MusicUtils.queryAlbums(mContext);
if (isAZSort) {
Collections.sort(albumList, new AlbumComparator());
for (int i = 0; i < albumList.size(); i++) {
......@@ -182,16 +182,16 @@ public class AlbumFragment extends BaseFragment {
@Override
protected String doInBackground(String... params) {
if (getActivity() != null)
if (mContext != null)
mAdapter = new AlbumAdapter(mAlbumList);
mAlbumList = MusicUtils.queryAlbums(getContext());
mAlbumList = MusicUtils.queryAlbums(mContext);
return "Executed";
}
@Override
protected void onPostExecute(String result) {
recyclerView.setAdapter(mAdapter);
if (getActivity() != null) {
if (mContext != null) {
setItemDecoration();
}
}
......@@ -284,9 +284,9 @@ public class AlbumFragment extends BaseFragment {
@Override
public void onClick(View v) {
FragmentTransaction transaction = ((AppCompatActivity) getContext()).getSupportFragmentManager().beginTransaction();
FragmentTransaction transaction = ((AppCompatActivity) mContext).getSupportFragmentManager().beginTransaction();
AlbumDetailFragment fragment = AlbumDetailFragment.newInstance(mList.get(getAdapterPosition()).album_id, false, null);
transaction.hide(((AppCompatActivity) getContext()).getSupportFragmentManager().findFragmentById(R.id.tab_container));
transaction.hide(((AppCompatActivity) mContext).getSupportFragmentManager().findFragmentById(R.id.tab_container));
transaction.add(R.id.tab_container, fragment);
transaction.addToBackStack(null).commit();
}
......
......@@ -65,7 +65,7 @@ public class ArtistDetailFragment extends BaseFragment {
View view = inflater.inflate(R.layout.fragment_common, container, false);
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
layoutManager = new LinearLayoutManager(getActivity());
layoutManager = new LinearLayoutManager(mContext);
recyclerView.setLayoutManager(layoutManager);
artDetailAdapter = new ArtDetailAdapter(null);
recyclerView.setAdapter(artDetailAdapter);
......@@ -73,18 +73,19 @@ public class ArtistDetailFragment extends BaseFragment {
setItemDecoration();
reloadAdapter();
ArtistInfo artistInfo = MusicUtils.getArtistinfo(getContext(), artistID);
ArtistInfo artistInfo = MusicUtils.getArtistinfo(mContext, artistID);
toolbar = (Toolbar) view.findViewById(R.id.toolbar);
toolbar.setPadding(0, CommonUtils.getStatusHeight(getActivity()), 0, 0);
((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
ab = ((AppCompatActivity) getActivity()).getSupportActionBar();
toolbar.setPadding(0, CommonUtils.getStatusHeight(mContext), 0, 0);
((AppCompatActivity) mContext).setSupportActionBar(toolbar);
ab = ((AppCompatActivity) mContext).getSupportActionBar();
ab.setHomeAsUpIndicator(R.drawable.actionbar_back);
ab.setDisplayHomeAsUpEnabled(true);
ab.setTitle(artistInfo.artist_name);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().onBackPressed();
if (getActivity() != null)
getActivity().onBackPressed();
}
});
return view;
......@@ -100,7 +101,7 @@ public class ArtistDetailFragment extends BaseFragment {
//设置分割线
private void setItemDecoration() {
RecyclerView.ItemDecoration itemDecoration = new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST);
RecyclerView.ItemDecoration itemDecoration = new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST);
recyclerView.addItemDecoration(itemDecoration);
}
......@@ -110,7 +111,7 @@ public class ArtistDetailFragment extends BaseFragment {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(final Void... unused) {
ArrayList<MusicInfo> artistList = (ArrayList) MusicUtils.queryMusic(getActivity(), artistID + "", IConstants.START_FROM_ARTIST);
ArrayList<MusicInfo> artistList = (ArrayList) MusicUtils.queryMusic(mContext, artistID + "", IConstants.START_FROM_ARTIST);
artDetailAdapter.updateDataSet(artistList);
return null;
}
......@@ -159,9 +160,9 @@ public class ArtistDetailFragment extends BaseFragment {
((CommonItemViewHolder) holder).select.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), SelectActivity.class);
Intent intent = new Intent(mContext, SelectActivity.class);
intent.putParcelableArrayListExtra("ids", mList);
getActivity().startActivity(intent);
mContext.startActivity(intent);
}
});
......@@ -204,7 +205,7 @@ public class ArtistDetailFragment extends BaseFragment {
//播放歌手所有歌曲
@Override
public void onClick(View v) {
HandlerUtil.getInstance(getContext()).postDelayed(new Runnable() {
HandlerUtil.getInstance(mContext).postDelayed(new Runnable() {
@Override
public void run() {
long[] list = new long[mList.size()];
......@@ -251,7 +252,7 @@ public class ArtistDetailFragment extends BaseFragment {
//播放歌曲
@Override
public void onClick(View v) {
HandlerUtil.getInstance(getContext()).postDelayed(new Runnable() {
HandlerUtil.getInstance(mContext).postDelayed(new Runnable() {
@Override
public void run() {
long[] list = new long[mList.size()];
......
......@@ -59,7 +59,7 @@ public class ArtistFragment extends BaseFragment {
View view = inflater.inflate(R.layout.recylerview, container, false);
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
layoutManager = new LinearLayoutManager(getActivity());
layoutManager = new LinearLayoutManager(mContext);
recyclerView.setLayoutManager(layoutManager);
//fastScroller = (FastScroller) view.findViewById(R.id.fastscroller);
//new loadArtists().execute("");
......@@ -103,7 +103,7 @@ public class ArtistFragment extends BaseFragment {
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mPreferences = PreferencesUtility.getInstance(getActivity());
mPreferences = PreferencesUtility.getInstance(mContext);
}
......@@ -138,7 +138,7 @@ public class ArtistFragment extends BaseFragment {
//设置分割线
private void setItemDecoration() {
itemDecoration = new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST);
itemDecoration = new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST);
recyclerView.addItemDecoration(itemDecoration);
}
......@@ -148,7 +148,7 @@ public class ArtistFragment extends BaseFragment {
@Override
protected Void doInBackground(final Void... unused) {
isAZSort = mPreferences.getArtistSortOrder().equals(SortOrder.ArtistSortOrder.ARTIST_A_Z);
List<ArtistInfo> artList = MusicUtils.queryArtist(getActivity());
List<ArtistInfo> artList = MusicUtils.queryArtist(mContext);
if (isAZSort) {
Collections.sort(artList, new ArtistComparator());
for (int i = 0; i < artList.size(); i++) {
......@@ -179,8 +179,8 @@ public class ArtistFragment extends BaseFragment {
@Override
protected String doInBackground(String... params) {
if (getActivity() != null) {
artistInfos = MusicUtils.queryArtist(getActivity());
if (mContext != null) {
artistInfos = MusicUtils.queryArtist(mContext);
if (artistInfos != null)
mAdapter = new ArtistAdapter(artistInfos);
}
......@@ -191,7 +191,7 @@ public class ArtistFragment extends BaseFragment {
@Override
protected void onPostExecute(String result) {
recyclerView.setAdapter(mAdapter);
if (getActivity() != null) {
if (mContext != null) {
setItemDecoration();
}
}
......@@ -239,7 +239,7 @@ public class ArtistFragment extends BaseFragment {
}
//lastFm api加载歌手图片
LastFmClient.getInstance(getContext()).getArtistInfo(new ArtistQuery(model.artist_name.toString()), new ArtistInfoListener() {
LastFmClient.getInstance(mContext).getArtistInfo(new ArtistQuery(model.artist_name.toString()), new ArtistInfoListener() {
@Override
public void artistInfoSucess(LastfmArtist artist) {
if (artist != null && artist.mArtwork != null) {
......@@ -294,9 +294,9 @@ public class ArtistFragment extends BaseFragment {
@Override
public void onClick(View v) {
if (getAdapterPosition() != -1) {
FragmentTransaction transaction = ((AppCompatActivity) getContext()).getSupportFragmentManager().beginTransaction();
FragmentTransaction transaction = ((AppCompatActivity) mContext).getSupportFragmentManager().beginTransaction();
ArtistDetailFragment fragment = ArtistDetailFragment.newInstance(mList.get(getAdapterPosition()).artist_id);
transaction.hide(((AppCompatActivity) getContext()).getSupportFragmentManager().findFragmentById(R.id.tab_container));
transaction.hide(((AppCompatActivity) mContext).getSupportFragmentManager().findFragmentById(R.id.tab_container));
transaction.add(R.id.tab_container, fragment);
transaction.addToBackStack(null).commit();
}
......
package com.wm.remusic.fragment;
import android.app.Activity;
import android.support.v4.app.DialogFragment;
/**
* Created by wm on 2016/3/17.
*/
public class AttachDialogFragment extends DialogFragment {
public Activity mContext;
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
this.mContext = activity;
}
}
package com.wm.remusic.fragment;
import android.app.Activity;
import android.support.v4.app.Fragment;
/**
* Created by wm on 2016/3/17.
*/
public class AttachFragment extends Fragment {
public Activity mContext;
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
this.mContext = activity;
}
}
package com.wm.remusic.fragment;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
......@@ -12,6 +13,13 @@ import com.wm.remusic.activity.MusicStateListener;
*/
public class BaseFragment extends Fragment implements MusicStateListener {
public Activity mContext;
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
this.mContext = activity;
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
......
package com.wm.remusic.fragment;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
......@@ -8,6 +9,7 @@ import android.view.ViewGroup;
import android.view.Window;
import android.widget.TextView;
import com.wm.remusic.MainApplication;
import com.wm.remusic.R;
import com.wm.remusic.uitl.PreferencesUtility;
......@@ -17,6 +19,7 @@ import com.wm.remusic.uitl.PreferencesUtility;
public class BitSetFragment extends DialogFragment implements View.OnClickListener {
private TextView bit1, bit2, bit3, bit256, bit320;
private Context mContext;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
......@@ -35,7 +38,8 @@ public class BitSetFragment extends DialogFragment implements View.OnClickListen
bit3.setOnClickListener(this);
bit256.setOnClickListener(this);
bit320.setOnClickListener(this);
switch (PreferencesUtility.getInstance(getContext()).getDownMusicBit()) {
mContext = MainApplication.context;
switch (PreferencesUtility.getInstance(mContext).getDownMusicBit()) {
case 64:
// TypedValue outValue = new TypedValue();
// getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground,outValue, true);
......@@ -65,23 +69,23 @@ public class BitSetFragment extends DialogFragment implements View.OnClickListen
public void onClick(View v) {
switch (v.getId()) {
case R.id.timing_10min:
PreferencesUtility.getInstance(getContext()).setDownMusicBit(64);
PreferencesUtility.getInstance(mContext).setDownMusicBit(64);
dismiss();
break;
case R.id.timing_20min:
PreferencesUtility.getInstance(getContext()).setDownMusicBit(128);
PreferencesUtility.getInstance(mContext).setDownMusicBit(128);
dismiss();
break;
case R.id.timing_30min:
PreferencesUtility.getInstance(getContext()).setDownMusicBit(192);
PreferencesUtility.getInstance(mContext).setDownMusicBit(192);
dismiss();
break;
case R.id.timing_45min:
PreferencesUtility.getInstance(getContext()).setDownMusicBit(256);
PreferencesUtility.getInstance(mContext).setDownMusicBit(256);
dismiss();
break;
case R.id.timing_60min:
PreferencesUtility.getInstance(getContext()).setDownMusicBit(320);
PreferencesUtility.getInstance(mContext).setDownMusicBit(320);
dismiss();
break;
}
......
package com.wm.remusic.fragment;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
......@@ -43,10 +44,10 @@ public class DownFragment extends Fragment {
private DownLoadAdapter adapter;
private DownFileStore downFileStore;
private DownStatus downStatus;
private Context mContext;
private int downPosition = -1;
private String TAG = "DownFragment";
private boolean d = true;
public Activity mContext;
@Nullable
......@@ -62,7 +63,7 @@ public class DownFragment extends Fragment {
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
recyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(getActivity());
layoutManager = new LinearLayoutManager(mContext);
recyclerView.setLayoutManager(layoutManager);
adapter = new DownLoadAdapter(null, null);
recyclerView.setAdapter(adapter);
......@@ -74,12 +75,12 @@ public class DownFragment extends Fragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mContext = getContext();
public void onAttach(Activity activity) {
super.onAttach(activity);
this.mContext = activity;
}
@Override
public void onStart() {
super.onStart();
......@@ -102,7 +103,7 @@ public class DownFragment extends Fragment {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
downFileStore = DownFileStore.getInstance(getContext());
downFileStore = DownFileStore.getInstance(mContext);
mList = downFileStore.getDownLoadedListAllDowning();
L.D(d, TAG, " mlist size = " + mList.size());
return null;
......@@ -247,8 +248,8 @@ public class DownFragment extends Fragment {
((ItemViewHolder) holder).clear.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new AlertDialog.Builder(getActivity()).setTitle("要清除下载吗")
.setPositiveButton(getActivity().getString(R.string.sure), new DialogInterface.OnClickListener() {
new AlertDialog.Builder(mContext).setTitle("要清除下载吗")
.setPositiveButton(mContext.getString(R.string.sure), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(DownService.CANCLE_DOWNTASK);
......@@ -258,7 +259,7 @@ public class DownFragment extends Fragment {
dialog.dismiss();
}
})
.setNegativeButton(getActivity().getString(R.string.cancel), new DialogInterface.OnClickListener() {
.setNegativeButton(mContext.getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
......
......@@ -59,7 +59,7 @@ public class DownMusicFragment extends BaseFragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.down_music_recylerview, container, false);
layoutManager = new LinearLayoutManager(getActivity());
layoutManager = new LinearLayoutManager(mContext);
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
recyclerView.setLayoutManager(layoutManager);
folderDetailAdapter = new FolderDetailAdapter(null);
......@@ -86,7 +86,7 @@ public class DownMusicFragment extends BaseFragment {
//设置分割线
private void setItemDecoration() {
RecyclerView.ItemDecoration itemDecoration = new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST);
RecyclerView.ItemDecoration itemDecoration = new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST);
recyclerView.addItemDecoration(itemDecoration);
}
......@@ -95,7 +95,7 @@ public class DownMusicFragment extends BaseFragment {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(final Void... unused) {
List<MusicInfo> albumList = MusicUtils.queryMusic(getActivity(), folder_path, IConstants.START_FROM_FOLDER);
List<MusicInfo> albumList = MusicUtils.queryMusic(mContext, folder_path, IConstants.START_FROM_FOLDER);
folderDetailAdapter.updateDataSet(albumList);
return null;
}
......@@ -145,9 +145,9 @@ public class DownMusicFragment extends BaseFragment {
((CommonItemViewHolder) holder).select.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), SelectActivity.class);
Intent intent = new Intent(mContext, SelectActivity.class);
intent.putParcelableArrayListExtra("ids", (ArrayList) mList);
getActivity().startActivity(intent);
mContext.startActivity(intent);
}
});
}
......@@ -188,7 +188,7 @@ public class DownMusicFragment extends BaseFragment {
//播放文件夹
@Override
public void onClick(View v) {
HandlerUtil.getInstance(getContext()).postDelayed(new Runnable() {
HandlerUtil.getInstance(mContext).postDelayed(new Runnable() {
@Override
public void run() {
long[] list = new long[mList.size()];
......@@ -236,7 +236,7 @@ public class DownMusicFragment extends BaseFragment {
//播放歌曲
@Override
public void onClick(View v) {
HandlerUtil.getInstance(getContext()).postDelayed(new Runnable() {
HandlerUtil.getInstance(mContext).postDelayed(new Runnable() {
@Override
public void run() {
long[] list = new long[mList.size()];
......
......@@ -68,7 +68,7 @@ public class FolderDetailFragment extends BaseFragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_common, container, false);
layoutManager = new LinearLayoutManager(getActivity());
layoutManager = new LinearLayoutManager(mContext);
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
recyclerView.setLayoutManager(layoutManager);
folderDetailAdapter = new FolderDetailAdapter(null);
......@@ -77,9 +77,9 @@ public class FolderDetailFragment extends BaseFragment {
reloadAdapter();
recyclerView.setHasFixedSize(true);
toolbar = (Toolbar) view.findViewById(R.id.toolbar);
((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
toolbar.setPadding(0, CommonUtils.getStatusHeight(getActivity()), 0, 0);
ab = ((AppCompatActivity) getActivity()).getSupportActionBar();
((AppCompatActivity) mContext).setSupportActionBar(toolbar);
toolbar.setPadding(0, CommonUtils.getStatusHeight(mContext), 0, 0);
ab = ((AppCompatActivity) mContext).getSupportActionBar();
ab.setHomeAsUpIndicator(R.drawable.actionbar_back);
ab.setDisplayHomeAsUpEnabled(true);
String folder = folder_path.substring(folder_path.lastIndexOf(File.separator), folder_path.length());
......@@ -87,7 +87,7 @@ public class FolderDetailFragment extends BaseFragment {
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().onBackPressed();
mContext.onBackPressed();
}
});
......@@ -103,7 +103,7 @@ public class FolderDetailFragment extends BaseFragment {
//设置分割线
private void setItemDecoration() {
RecyclerView.ItemDecoration itemDecoration = new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST);
RecyclerView.ItemDecoration itemDecoration = new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST);
recyclerView.addItemDecoration(itemDecoration);
}
......@@ -112,7 +112,7 @@ public class FolderDetailFragment extends BaseFragment {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(final Void... unused) {
List<MusicInfo> albumList = MusicUtils.queryMusic(getActivity(), folder_path, IConstants.START_FROM_FOLDER);
List<MusicInfo> albumList = MusicUtils.queryMusic(mContext, folder_path, IConstants.START_FROM_FOLDER);
folderDetailAdapter.updateDataSet(albumList);
return null;
}
......@@ -162,9 +162,9 @@ public class FolderDetailFragment extends BaseFragment {
((CommonItemViewHolder) holder).select.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), SelectActivity.class);
Intent intent = new Intent(mContext, SelectActivity.class);
intent.putParcelableArrayListExtra("ids", (ArrayList) mList);
getActivity().startActivity(intent);
mContext.startActivity(intent);
}
});
}
......@@ -205,7 +205,7 @@ public class FolderDetailFragment extends BaseFragment {
//播放文件夹
@Override
public void onClick(View v) {
HandlerUtil.getInstance(getContext()).postDelayed(new Runnable() {
HandlerUtil.getInstance(mContext).postDelayed(new Runnable() {
@Override
public void run() {
long[] list = new long[mList.size()];
......@@ -253,7 +253,7 @@ public class FolderDetailFragment extends BaseFragment {
//播放歌曲
@Override
public void onClick(View v) {
HandlerUtil.getInstance(getContext()).postDelayed(new Runnable() {
HandlerUtil.getInstance(mContext).postDelayed(new Runnable() {
@Override
public void run() {
long[] list = new long[mList.size()];
......
......@@ -56,16 +56,16 @@ public class FolderFragment extends BaseFragment {
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mPreferences = PreferencesUtility.getInstance(getActivity());
mPreferences = PreferencesUtility.getInstance(mContext);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.recylerview, container, false);
// folderInfos = MusicUtils.queryFolder(getActivity());
// folderInfos = MusicUtils.queryFolder(mContext);
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
layoutManager = new LinearLayoutManager(getActivity());
layoutManager = new LinearLayoutManager(mContext);
recyclerView.setLayoutManager(layoutManager);
mAdapter = new Adapter(null);
......@@ -118,7 +118,7 @@ public class FolderFragment extends BaseFragment {
//设置分割线
private void setItemDecoration() {
itemDecoration = new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST);
itemDecoration = new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST);
recyclerView.addItemDecoration(itemDecoration);
}
......@@ -157,7 +157,7 @@ public class FolderFragment extends BaseFragment {
protected Void doInBackground(final Void... unused) {
isAZSort = mPreferences.getFoloerSortOrder().equals(SortOrder.FolderSortOrder.FOLDER_A_Z);
Log.e("sort", "foler" + isAZSort);
List<FolderInfo> folderList = MusicUtils.queryFolder(getContext());
List<FolderInfo> folderList = MusicUtils.queryFolder(mContext);
for (int i = 0; i < folderList.size(); i++) {
List<MusicInfo> albumList = MusicUtils.queryMusic(MainApplication.context, folderList.get(i).folder_path, IConstants.START_FROM_FOLDER);
folderList.get(i).folder_count = albumList.size();
......@@ -193,7 +193,7 @@ public class FolderFragment extends BaseFragment {
//
// @Override
// protected String doInBackground(String... params) {
// if (getActivity() != null)
// if (mContext != null)
// mAdapter = new Adapter(folderInfos);
// return "Executed";
// }
......@@ -201,7 +201,7 @@ public class FolderFragment extends BaseFragment {
// @Override
// protected void onPostExecute(String result) {
// recyclerView.setAdapter(mAdapter);
// if (getActivity() != null) {
// if (mContext != null) {
// setItemDecoration();
// }
// }
......@@ -284,9 +284,9 @@ public class FolderFragment extends BaseFragment {
@Override
public void onClick(View v) {
FragmentTransaction transaction = ((AppCompatActivity) getContext()).getSupportFragmentManager().beginTransaction();
FragmentTransaction transaction = ((AppCompatActivity) mContext).getSupportFragmentManager().beginTransaction();
FolderDetailFragment fragment = FolderDetailFragment.newInstance(mList.get(getAdapterPosition()).folder_path, false, null);
transaction.hide(((AppCompatActivity) getContext()).getSupportFragmentManager().findFragmentById(R.id.tab_container));
transaction.hide(((AppCompatActivity) mContext).getSupportFragmentManager().findFragmentById(R.id.tab_container));
transaction.add(R.id.tab_container, fragment);
transaction.addToBackStack(null).commit();
}
......
......@@ -3,7 +3,6 @@ package com.wm.remusic.fragment;
import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.AsyncTask;
import android.os.Bundle;
......@@ -47,8 +46,6 @@ public class MainFragment extends BaseFragment {
private List<MainFragmentItem> mList = new ArrayList<>();
private PlaylistInfo playlistInfo; //playlist 管理类
private SwipeRefreshLayout swipeRefresh; //下拉刷新layout
private Context mContext;
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
......@@ -61,7 +58,6 @@ public class MainFragment extends BaseFragment {
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mContext = getContext();
playlistInfo = PlaylistInfo.getInstance(mContext);
if (CommonUtils.isLollipop() && ContextCompat.checkSelfPermission(mContext, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions((Activity) mContext, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 0);
......@@ -94,7 +90,7 @@ public class MainFragment extends BaseFragment {
((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
reloadAdapter();
getActivity().getWindow().setBackgroundDrawableResource(R.color.background_material_light_1);
mContext.getWindow().setBackgroundDrawableResource(R.color.background_material_light_1);
return view;
}
......@@ -134,10 +130,15 @@ public class MainFragment extends BaseFragment {
private void loadCount(boolean has) {
int localMusicCount = 0, recentMusicCount = 0, downLoadCount = 0, artistsCount = 0;
if (has) {
localMusicCount = MusicUtils.queryMusic(mContext, IConstants.START_FROM_LOCAL).size();
recentMusicCount = TopTracksLoader.getCursor(mContext, TopTracksLoader.QueryType.RecentSongs).getCount();
downLoadCount = DownFileStore.getInstance(mContext).getDownLoadedListAll().size();
artistsCount = MusicUtils.queryArtist(mContext).size();
try {
localMusicCount = MusicUtils.queryMusic(mContext, IConstants.START_FROM_LOCAL).size();
recentMusicCount = TopTracksLoader.getCount(mContext, TopTracksLoader.QueryType.RecentSongs);
downLoadCount = DownFileStore.getInstance(mContext).getDownLoadedListAll().size();
artistsCount = MusicUtils.queryArtist(mContext).size();
} catch (Exception e) {
e.printStackTrace();
}
}
setInfo(mContext.getResources().getString(R.string.local_music), localMusicCount, R.drawable.music_icn_local, 0);
setInfo(mContext.getResources().getString(R.string.recent_play), recentMusicCount, R.drawable.music_icn_recent, 1);
......
......@@ -54,7 +54,7 @@ import java.util.List;
/**
* Created by wm on 2016/1/31.
*/
public class MoreFragment extends DialogFragment {
public class MoreFragment extends AttachDialogFragment {
private int type;
private double heightPercent;
private TextView topTitle;
......@@ -140,7 +140,7 @@ public class MoreFragment extends DialogFragment {
View view = inflater.inflate(R.layout.more_fragment, container);
topTitle = (TextView) view.findViewById(R.id.pop_list_title);
recyclerView = (RecyclerView) view.findViewById(R.id.pop_list);
layoutManager = new LinearLayoutManager(getActivity());
layoutManager = new LinearLayoutManager(mContext);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setHasFixedSize(true);
......@@ -152,7 +152,7 @@ public class MoreFragment extends DialogFragment {
//设置分割线
private void setItemDecoration() {
RecyclerView.ItemDecoration itemDecoration = new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST);
RecyclerView.ItemDecoration itemDecoration = new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST);
recyclerView.addItemDecoration(itemDecoration);
}
......@@ -161,6 +161,9 @@ public class MoreFragment extends DialogFragment {
if (type == IConstants.MUSICOVERFLOW) {
// long musicId = Long.parseLong(args.trim());
adapterMusicInfo = getArguments().getParcelable("music");
if (adapterMusicInfo == null) {
adapterMusicInfo = new MusicInfo();
}
artist = adapterMusicInfo.artist;
albumId = adapterMusicInfo.albumId + "";
albumName = adapterMusicInfo.albumName;
......@@ -168,7 +171,7 @@ public class MoreFragment extends DialogFragment {
topTitle.setText("歌曲:" + " " + musicName);
heightPercent = 0.6;
setMusicInfo();
muaicflowAdapter = new MusicFlowAdapter(getActivity(), mlistInfo, adapterMusicInfo);
muaicflowAdapter = new MusicFlowAdapter(mContext, mlistInfo, adapterMusicInfo);
} else {
switch (type) {
......@@ -190,7 +193,7 @@ public class MoreFragment extends DialogFragment {
}
setCommonInfo();
heightPercent = 0.3;
commonAdapter = new OverFlowAdapter(getActivity(), mlistInfo, list);
commonAdapter = new OverFlowAdapter(mContext, mlistInfo, list);
}
......@@ -230,7 +233,7 @@ public class MoreFragment extends DialogFragment {
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + adapterMusicInfo.data));
shareIntent.setType("audio/*");
getActivity().startActivity(Intent.createChooser(shareIntent, getResources().getString(R.string.shared_to)));
mContext.startActivity(Intent.createChooser(shareIntent, getResources().getString(R.string.shared_to)));
dismiss();
break;
case 3:
......@@ -371,7 +374,7 @@ public class MoreFragment extends DialogFragment {
};
} else {
Intent intent = new Intent(getActivity(), AlbumsDetailActivity.class);
Intent intent = new Intent(mContext, AlbumsDetailActivity.class);
intent.putExtra("albumid", adapterMusicInfo.albumId + "");
intent.putExtra("albumart", adapterMusicInfo.albumData);
intent.putExtra("albumname", adapterMusicInfo.albumName);
......@@ -380,10 +383,7 @@ public class MoreFragment extends DialogFragment {
dismiss();
break;
case 6:
if (playlistId != -1) {
PlaylistsManager.getInstance(mContext).deleteMusicInfo(mContext, playlistId, adapterMusicInfo.songId);
} else {
if (adapterMusicInfo.islocal) {
new AlertDialog.Builder(mContext).setTitle(getResources().getString(R.string.sure_to_set_ringtone)).
setPositiveButton(getResources().getString(R.string.sure), new DialogInterface.OnClickListener() {
@Override
......@@ -402,12 +402,14 @@ public class MoreFragment extends DialogFragment {
dialog.dismiss();
}
}).show();
} else {
}
break;
case 7:
MusicDetailFragment detailFrament = MusicDetailFragment.newInstance(adapterMusicInfo);
detailFrament.show(getActivity().getFragmentManager(), "detail");
detailFrament.show(getActivity().getSupportFragmentManager(), "detail");
dismiss();
break;
default:
......@@ -491,7 +493,7 @@ public class MoreFragment extends DialogFragment {
// if (file.exists())
// file.delete();
// if (file.exists() == false) {
// getActivity().sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,
// mContext.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,
// Uri.parse("file://" + music.data)));
// }
// HandlerUtil.CommonHandler handler1 = new HandlerUtil.CommonHandler(mContext);
......@@ -541,7 +543,7 @@ public class MoreFragment extends DialogFragment {
public void onStart() {
super.onStart();
//设置fragment高度 、宽度
int dialogHeight = (int) (getActivity().getResources().getDisplayMetrics().heightPixels * heightPercent);
int dialogHeight = (int) (mContext.getResources().getDisplayMetrics().heightPixels * heightPercent);
;
// WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
// Display display = wm.getDefaultDisplay();
......
......@@ -17,7 +17,7 @@ import com.wm.remusic.uitl.MusicUtils;
/**
* Created by wm on 2016/3/2.
*/
public class MusicDetailFragment extends DialogFragment {
public class MusicDetailFragment extends AttachDialogFragment {
private TextView title, name, time, qua, size, path;
private MusicInfo musicInfo;
......@@ -56,7 +56,7 @@ public class MusicDetailFragment extends DialogFragment {
title.setText(musicInfo.musicName);
name.setText(musicInfo.artist + "-" + musicInfo.musicName);
time.setText(MusicUtils.makeShortTimeString(getActivity(), musicInfo.duration / 1000));
time.setText(MusicUtils.makeShortTimeString(mContext, musicInfo.duration / 1000));
size.setText(musicInfo.size / 1000000 + "m");
path.setText(musicInfo.data);
......@@ -74,7 +74,7 @@ public class MusicDetailFragment extends DialogFragment {
public void onStart() {
super.onStart();
//设置fragment高度 、宽度
int dialogHeight = (int) (getActivity().getResources().getDisplayMetrics().heightPixels * 0.30);
int dialogHeight = (int) (mContext.getResources().getDisplayMetrics().heightPixels * 0.30);
getDialog().getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, dialogHeight);
getDialog().setCanceledOnTouchOutside(true);
......
......@@ -60,17 +60,17 @@ public class MusicFragment extends BaseFragment {
super.setUserVisibleHint(isVisibleToUser);
if (isVisibleToUser) {
if (view == null) {
view = LayoutInflater.from(getActivity()).inflate(R.layout.recylerview, frameLayout, false);
view = LayoutInflater.from(mContext).inflate(R.layout.recylerview, frameLayout, false);
dialogText = (TextView) view.findViewById(R.id.dialog_text);
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
layoutManager = new LinearLayoutManager(getActivity());
layoutManager = new LinearLayoutManager(mContext);
recyclerView.setLayoutManager(layoutManager);
mAdapter = new Adapter(null);
recyclerView.setAdapter(mAdapter);
recyclerView.setHasFixedSize(true);
//fastScroller = (FastScroller) view.findViewById(R.id.fastscroller);
recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
recyclerView.addItemDecoration(new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST));
sideBar = (SideBar) view.findViewById(R.id.sidebar);
sideBar.setOnTouchingLetterChangedListener(new SideBar.OnTouchingLetterChangedListener() {
......@@ -106,7 +106,7 @@ public class MusicFragment extends BaseFragment {
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mPreferences = PreferencesUtility.getInstance(getActivity());
mPreferences = PreferencesUtility.getInstance(mContext);
}
@Override
......@@ -114,7 +114,7 @@ public class MusicFragment extends BaseFragment {
View view = inflater.inflate(R.layout.load_framelayout, container, false);
Log.e("musicfrag", "oncreateview");
frameLayout = (FrameLayout) view.findViewById(R.id.loadframe);
View loadView = LayoutInflater.from(getActivity()).inflate(R.layout.loading, frameLayout, false);
View loadView = LayoutInflater.from(mContext).inflate(R.layout.loading, frameLayout, false);
frameLayout.addView(loadView);
isFirstLoad = true;
isAZSort = mPreferences.getSongSortOrder().equals(SortOrder.SongSortOrder.SONG_A_Z);
......@@ -133,7 +133,7 @@ public class MusicFragment extends BaseFragment {
@Override
protected Void doInBackground(final Void... unused) {
isAZSort = mPreferences.getSongSortOrder().equals(SortOrder.SongSortOrder.SONG_A_Z);
ArrayList<MusicInfo> songList = (ArrayList) MusicUtils.queryMusic(getActivity(), IConstants.START_FROM_LOCAL);
ArrayList<MusicInfo> songList = (ArrayList) MusicUtils.queryMusic(mContext, IConstants.START_FROM_LOCAL);
// 名称排序时,重新排序并加入位置信息
if (isAZSort) {
Collections.sort(songList, new MusicComparator());
......@@ -213,8 +213,8 @@ public class MusicFragment extends BaseFragment {
@Override
protected String doInBackground(String... params) {
if (getActivity() != null) {
musicInfos = (ArrayList<MusicInfo>) MusicUtils.queryMusic(getActivity(), IConstants.START_FROM_LOCAL);
if (mContext != null) {
musicInfos = (ArrayList<MusicInfo>) MusicUtils.queryMusic(mContext, IConstants.START_FROM_LOCAL);
for (int i = 0; i < musicInfos.size(); i++) {
char c = Pinyin.toPinyin(musicInfos.get(i).musicName.charAt(0)).charAt(0);
......@@ -229,8 +229,8 @@ public class MusicFragment extends BaseFragment {
@Override
protected void onPostExecute(String result) {
recyclerView.setAdapter(mAdapter);
if (getActivity() != null)
recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
if (mContext != null)
recyclerView.addItemDecoration(new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST));
}
......@@ -252,7 +252,7 @@ public class MusicFragment extends BaseFragment {
// if (list == null) {
// throw new IllegalArgumentException("model Data must not be null");
// }
handler = HandlerUtil.getInstance(getContext());
handler = HandlerUtil.getInstance(mContext);
mList = list;
}
......@@ -307,10 +307,10 @@ public class MusicFragment extends BaseFragment {
((CommonItemViewHolder) holder).select.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), SelectActivity.class);
Intent intent = new Intent(mContext, SelectActivity.class);
intent.putParcelableArrayListExtra("ids", mList);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
getActivity().startActivity(intent);
mContext.startActivity(intent);
}
});
......
package com.wm.remusic.fragment;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
......@@ -50,7 +49,7 @@ import java.util.List;
/**
* Created by wm on 2016/1/31.
*/
public class NetMoreFragment extends DialogFragment {
public class NetMoreFragment extends AttachDialogFragment {
private int type;
private double heightPercent;
private TextView topTitle;
......@@ -64,7 +63,6 @@ public class NetMoreFragment extends DialogFragment {
private LinearLayoutManager layoutManager;
private String args;
private String musicName, artist, albumId, albumName;
private Context mContext;
private Handler mHandler;
public static NetMoreFragment newInstance(String id, String albumId, String artistId) {
......@@ -123,7 +121,7 @@ public class NetMoreFragment extends DialogFragment {
View view = inflater.inflate(R.layout.more_fragment, container);
topTitle = (TextView) view.findViewById(R.id.pop_list_title);
recyclerView = (RecyclerView) view.findViewById(R.id.pop_list);
layoutManager = new LinearLayoutManager(getActivity());
layoutManager = new LinearLayoutManager(mContext);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(layoutManager);
getList();
......@@ -134,7 +132,7 @@ public class NetMoreFragment extends DialogFragment {
//设置分割线
private void setItemDecoration() {
RecyclerView.ItemDecoration itemDecoration = new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST);
RecyclerView.ItemDecoration itemDecoration = new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST);
recyclerView.addItemDecoration(itemDecoration);
}
......@@ -148,7 +146,7 @@ public class NetMoreFragment extends DialogFragment {
topTitle.setText("歌曲:" + " " + musicName);
heightPercent = 0.6;
setMusicInfo();
muaicflowAdapter = new MusicFlowAdapter(getActivity(), mlistInfo, adapterMusicInfo);
muaicflowAdapter = new MusicFlowAdapter(mContext, mlistInfo, adapterMusicInfo);
}
private void setClick() {
......@@ -184,7 +182,7 @@ public class NetMoreFragment extends DialogFragment {
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + adapterMusicInfo.data));
shareIntent.setType("audio/*");
getActivity().startActivity(Intent.createChooser(shareIntent, getResources().getString(R.string.shared_to)));
mContext.startActivity(Intent.createChooser(shareIntent, getResources().getString(R.string.shared_to)));
dismiss();
break;
case 3:
......@@ -310,7 +308,7 @@ public class NetMoreFragment extends DialogFragment {
} else {
Intent intent = new Intent(getActivity(), AlbumsDetailActivity.class);
Intent intent = new Intent(mContext, AlbumsDetailActivity.class);
intent.putExtra("albumid", adapterMusicInfo.albumId + "");
intent.putExtra("albumart", adapterMusicInfo.albumData);
intent.putExtra("albumname", adapterMusicInfo.albumName);
......@@ -321,7 +319,7 @@ public class NetMoreFragment extends DialogFragment {
break;
case 6:
MusicDetailFragment detailFrament = MusicDetailFragment.newInstance(adapterMusicInfo);
detailFrament.show(getActivity().getFragmentManager(), "detail");
detailFrament.show(getActivity().getSupportFragmentManager(), "detail");
dismiss();
break;
default:
......@@ -350,14 +348,13 @@ public class NetMoreFragment extends DialogFragment {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(DialogFragment.STYLE_NO_FRAME, R.style.CustomDatePickerDialog);
mContext = getContext();
}
@Override
public void onStart() {
super.onStart();
//设置fragment高度 、宽度
int dialogHeight = (int) (getActivity().getResources().getDisplayMetrics().heightPixels * heightPercent);
int dialogHeight = (int) (mContext.getResources().getDisplayMetrics().heightPixels * heightPercent);
;
// WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
// Display display = wm.getDefaultDisplay();
......
package com.wm.remusic.fragment;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
......@@ -38,7 +37,7 @@ import java.util.HashMap;
/**
* Created by wm on 2016/2/4.
*/
public class PlayQueueFragment extends DialogFragment {
public class PlayQueueFragment extends AttachDialogFragment {
private RecyclerView.ItemDecoration itemDecoration;
private PlaylistAdapter adapter;
......@@ -49,7 +48,6 @@ public class PlayQueueFragment extends DialogFragment {
private MusicPlaybackState musicPlaybackState;
private RecyclerView recyclerView; //弹出的activity列表
private LinearLayoutManager layoutManager;
private Context mContext;
private Handler mHandler;
@Override
......@@ -57,8 +55,7 @@ public class PlayQueueFragment extends DialogFragment {
super.onCreate(savedInstanceState);
//设置样式
setStyle(DialogFragment.STYLE_NO_FRAME, R.style.CustomDatePickerDialog);
musicPlaybackState = MusicPlaybackState.getInstance(getContext());
mContext = getContext();
musicPlaybackState = MusicPlaybackState.getInstance(mContext);
mHandler = HandlerUtil.getInstance(mContext);
}
......@@ -101,11 +98,11 @@ public class PlayQueueFragment extends DialogFragment {
public void onClick(View v) {
MusicPlayer.clearQueue();
MusicPlayer.stop();
File file = new File(getContext().getCacheDir().getAbsolutePath() + "playlist");
File file = new File(mContext.getCacheDir().getAbsolutePath() + "playlist");
if (file.exists()) {
file.delete();
}
MusicPlaybackState.getInstance(getContext()).clearQueue();
MusicPlaybackState.getInstance(mContext).clearQueue();
if (adapter != null)
adapter.notifyDataSetChanged();
dismiss();
......@@ -206,7 +203,7 @@ public class PlayQueueFragment extends DialogFragment {
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
return new ItemViewHolder(LayoutInflater.from(getContext()).inflate(R.layout.fragment_playqueue_item, viewGroup, false));
return new ItemViewHolder(LayoutInflater.from(mContext).inflate(R.layout.fragment_playqueue_item, viewGroup, false));
}
@Override
......
......@@ -81,7 +81,7 @@ public class QuickControlsFragment extends BaseFragment {
mProgress.setMax((int) MusicPlayer.duration());
mProgress.setProgress((int) MusicPlayer.position());
mProgress.setProgressTintList(ThemeUtils.getThemeColorStateList(getContext(), R.color.theme_color_primary));
mProgress.setProgressTintList(ThemeUtils.getThemeColorStateList(mContext, R.color.theme_color_primary));
mPlayPause.setOnClickListener(new View.OnClickListener() {
@Override
......@@ -253,7 +253,7 @@ public class QuickControlsFragment extends BaseFragment {
@Override
public void changeTheme() {
super.changeTheme();
mProgress.setProgressTintList(ThemeUtils.getThemeColorStateList(getContext(), R.color.theme_color_primary));
mProgress.setProgressTintList(ThemeUtils.getThemeColorStateList(mContext, R.color.theme_color_primary));
}
......
package com.wm.remusic.fragment;
import android.content.ContentUris;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.media.RingtoneManager;
......@@ -41,7 +40,7 @@ import java.util.List;
/**
* Created by wm on 2016/1/31.
*/
public class SimpleMoreFragment extends DialogFragment {
public class SimpleMoreFragment extends AttachDialogFragment {
private double heightPercent = 0.5;
private TextView topTitle;
......@@ -54,7 +53,6 @@ public class SimpleMoreFragment extends DialogFragment {
private LinearLayoutManager layoutManager;
private long args;
private String musicName;
private Context mContext;
public static SimpleMoreFragment newInstance(long id) {
......@@ -85,7 +83,7 @@ public class SimpleMoreFragment extends DialogFragment {
View view = inflater.inflate(R.layout.more_fragment, container);
topTitle = (TextView) view.findViewById(R.id.pop_list_title);
recyclerView = (RecyclerView) view.findViewById(R.id.pop_list);
layoutManager = new LinearLayoutManager(getActivity());
layoutManager = new LinearLayoutManager(mContext);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(layoutManager);
getList();
......@@ -96,7 +94,7 @@ public class SimpleMoreFragment extends DialogFragment {
//设置分割线
private void setItemDecoration() {
RecyclerView.ItemDecoration itemDecoration = new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST);
RecyclerView.ItemDecoration itemDecoration = new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST);
recyclerView.addItemDecoration(itemDecoration);
}
......@@ -110,7 +108,7 @@ public class SimpleMoreFragment extends DialogFragment {
}
topTitle.setText("歌曲:" + " " + musicName);
setMusicInfo();
musicflowAdapter = new MusicFlowAdapter(getActivity(), mlistInfo, adapterMusicInfo);
musicflowAdapter = new MusicFlowAdapter(mContext, mlistInfo, adapterMusicInfo);
}
......@@ -149,7 +147,7 @@ public class SimpleMoreFragment extends DialogFragment {
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + adapterMusicInfo.data));
shareIntent.setType("audio/*");
getActivity().startActivity(Intent.createChooser(shareIntent, getResources().getString(R.string.shared_to)));
mContext.startActivity(Intent.createChooser(shareIntent, getResources().getString(R.string.shared_to)));
dismiss();
break;
case 3:
......@@ -224,7 +222,7 @@ public class SimpleMoreFragment extends DialogFragment {
break;
case 5:
MusicDetailFragment detailFrament = MusicDetailFragment.newInstance(adapterMusicInfo);
detailFrament.show(getActivity().getFragmentManager(), "detail");
detailFrament.show(getActivity().getSupportFragmentManager(), "detail");
dismiss();
break;
default:
......@@ -253,14 +251,13 @@ public class SimpleMoreFragment extends DialogFragment {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(DialogFragment.STYLE_NO_FRAME, R.style.CustomDatePickerDialog);
mContext = getContext();
}
@Override
public void onStart() {
super.onStart();
//设置fragment高度 、宽度
int dialogHeight = (int) (getActivity().getResources().getDisplayMetrics().heightPixels * heightPercent);
int dialogHeight = (int) (mContext.getResources().getDisplayMetrics().heightPixels * heightPercent);
;
// WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
// Display display = wm.getDefaultDisplay();
......
......@@ -27,7 +27,7 @@ import java.util.List;
/**
* Created by wm on 2016/1/17.
*/
public class TabPagerFragment extends Fragment {
public class TabPagerFragment extends AttachDialogFragment {
//PreferencesUtility mPreferences;
private ViewPager viewPager;
private int page = 0;
......@@ -54,7 +54,7 @@ public class TabPagerFragment extends Fragment {
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// mPreferences = PreferencesUtility.getInstance(getActivity());
// mPreferences = PreferencesUtility.getInstance(mContext);
if (getArguments() != null) {
page = getArguments().getInt("page_number");
title = getArguments().getStringArray("title");
......@@ -67,16 +67,16 @@ public class TabPagerFragment extends Fragment {
R.layout.fragment_tab, container, false);
Toolbar toolbar = (Toolbar) rootView.findViewById(R.id.toolbar);
((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
toolbar.setPadding(0, CommonUtils.getStatusHeight(getActivity()), 0, 0);
((AppCompatActivity) mContext).setSupportActionBar(toolbar);
toolbar.setPadding(0, CommonUtils.getStatusHeight(mContext), 0, 0);
ab = ((AppCompatActivity) getActivity()).getSupportActionBar();
ab = ((AppCompatActivity) mContext).getSupportActionBar();
ab.setHomeAsUpIndicator(R.drawable.actionbar_back);
ab.setDisplayHomeAsUpEnabled(true);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().onBackPressed();
mContext.onBackPressed();
}
});
ImageView search = (ImageView) rootView.findViewById(R.id.bar_search);
......@@ -84,9 +84,9 @@ public class TabPagerFragment extends Fragment {
search.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Intent intent = new Intent(getContext(), LocalSearchActivity.class);
final Intent intent = new Intent(mContext, LocalSearchActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
getActivity().startActivity(intent);
mContext.startActivity(intent);
}
});
......@@ -99,12 +99,12 @@ public class TabPagerFragment extends Fragment {
final TabLayout tabLayout = (TabLayout) rootView.findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager);
tabLayout.setTabTextColors(R.color.text_color, ThemeUtils.getThemeColorStateList(getActivity(), R.color.theme_color_primary).getDefaultColor());
// tabLayout.setTabTextColors(ThemeUtils.getThemeColorStateList(getActivity(),R.color.theme_color_primary));
tabLayout.setTabTextColors(R.color.text_color, ThemeUtils.getThemeColorStateList(mContext, R.color.theme_color_primary).getDefaultColor());
// tabLayout.setTabTextColors(ThemeUtils.getThemeColorStateList(mContext,R.color.theme_color_primary));
// try {
// Field mField = TableLayout.class.getDeclaredField("mTabTextColors");
// mField.setAccessible(true);
// mField.set(tabLayout,ThemeUtils.getThemeColorStateList(getActivity(),R.color.theme_color_primary));
// mField.set(tabLayout,ThemeUtils.getThemeColorStateList(mContext,R.color.theme_color_primary));
// } catch (NoSuchFieldException e) {
// e.printStackTrace();
// } catch (IllegalArgumentException e) {
......@@ -113,7 +113,7 @@ public class TabPagerFragment extends Fragment {
// e.printStackTrace();
// }
tabLayout.setSelectedTabIndicatorColor(ThemeUtils.getThemeColorStateList(getActivity(), R.color.theme_color_primary).getDefaultColor());
tabLayout.setSelectedTabIndicatorColor(ThemeUtils.getThemeColorStateList(mContext, R.color.theme_color_primary).getDefaultColor());
return rootView;
......
package com.wm.remusic.fragment;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -15,7 +14,7 @@ import com.wm.remusic.service.MusicPlayer;
/**
* Created by wm on 2016/3/22.
*/
public class TimingFragment extends DialogFragment implements View.OnClickListener {
public class TimingFragment extends AttachDialogFragment implements View.OnClickListener {
private TextView timing10, timing20, timing30, timing45, timing60, timing90;
......@@ -48,32 +47,32 @@ public class TimingFragment extends DialogFragment implements View.OnClickListen
switch (v.getId()) {
case R.id.timing_10min:
MusicPlayer.timing(10 * 60 * 1000);
Toast.makeText(getContext(), "将在10分钟后停止播放", Toast.LENGTH_SHORT).show();
Toast.makeText(mContext, "将在10分钟后停止播放", Toast.LENGTH_SHORT).show();
dismiss();
break;
case R.id.timing_20min:
MusicPlayer.timing(20 * 60 * 1000);
Toast.makeText(getContext(), "将在20分钟后停止播放", Toast.LENGTH_SHORT).show();
Toast.makeText(mContext, "将在20分钟后停止播放", Toast.LENGTH_SHORT).show();
dismiss();
break;
case R.id.timing_30min:
MusicPlayer.timing(30 * 60 * 1000);
Toast.makeText(getContext(), "将在30分钟后停止播放", Toast.LENGTH_SHORT).show();
Toast.makeText(mContext, "将在30分钟后停止播放", Toast.LENGTH_SHORT).show();
dismiss();
break;
case R.id.timing_45min:
MusicPlayer.timing(45 * 60 * 1000);
Toast.makeText(getContext(), "将在45分钟后停止播放", Toast.LENGTH_SHORT).show();
Toast.makeText(mContext, "将在45分钟后停止播放", Toast.LENGTH_SHORT).show();
dismiss();
break;
case R.id.timing_60min:
MusicPlayer.timing(60 * 60 * 1000);
Toast.makeText(getContext(), "将在60分钟后停止播放", Toast.LENGTH_SHORT).show();
Toast.makeText(mContext, "将在60分钟后停止播放", Toast.LENGTH_SHORT).show();
dismiss();
break;
case R.id.timing_90min:
MusicPlayer.timing(90 * 60 * 1000);
Toast.makeText(getContext(), "将在90分钟后停止播放", Toast.LENGTH_SHORT).show();
Toast.makeText(mContext, "将在90分钟后停止播放", Toast.LENGTH_SHORT).show();
dismiss();
break;
}
......@@ -90,8 +89,8 @@ public class TimingFragment extends DialogFragment implements View.OnClickListen
public void onStart() {
super.onStart();
//设置fragment高度 、宽度
int dialogHeight = (int) (getActivity().getResources().getDisplayMetrics().heightPixels * 0.71);
int dialogWidth = (int) (getActivity().getResources().getDisplayMetrics().widthPixels * 0.79);
int dialogHeight = (int) (mContext.getResources().getDisplayMetrics().heightPixels * 0.71);
int dialogWidth = (int) (mContext.getResources().getDisplayMetrics().widthPixels * 0.79);
getDialog().getWindow().setLayout(dialogWidth, dialogHeight);
getDialog().setCanceledOnTouchOutside(true);
......
......@@ -7,7 +7,6 @@ import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Spannable;
......@@ -30,6 +29,7 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.wm.remusic.R;
import com.wm.remusic.activity.PlaylistActivity;
import com.wm.remusic.fragment.AttachFragment;
import com.wm.remusic.json.GedanInfo;
import com.wm.remusic.net.BMA;
import com.wm.remusic.net.HttpUtil;
......@@ -39,7 +39,7 @@ import java.util.ArrayList;
/**
* Created by wm on 2016/5/15.
*/
public class AllPlaylistFragment extends Fragment {
public class AllPlaylistFragment extends AttachFragment {
FrameLayout frameLayout;
View view;
......@@ -56,7 +56,7 @@ public class AllPlaylistFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.load_framelayout, container, false);
frameLayout = (FrameLayout) view.findViewById(R.id.loadframe);
View loadView = LayoutInflater.from(getActivity()).inflate(R.layout.loading, frameLayout, false);
View loadView = LayoutInflater.from(mContext).inflate(R.layout.loading, frameLayout, false);
frameLayout.addView(loadView);
return view;
}
......@@ -66,9 +66,9 @@ public class AllPlaylistFragment extends Fragment {
super.setUserVisibleHint(isVisibleToUser);
if (isVisibleToUser) {
if (view == null) {
view = LayoutInflater.from(getActivity()).inflate(R.layout.recommend_all_playlist, frameLayout, false);
view = LayoutInflater.from(mContext).inflate(R.layout.recommend_all_playlist, frameLayout, false);
recyclerView = (RecyclerView) view.findViewById(R.id.recommend_playlist_recyclerview);
gridLayoutManager = new GridLayoutManager(getActivity(), 2);
gridLayoutManager = new GridLayoutManager(mContext, 2);
recyclerView.setLayoutManager(gridLayoutManager);
recyclerView.setHasFixedSize(true);
......@@ -184,7 +184,7 @@ public class AllPlaylistFragment extends Fragment {
mList = list;
Bitmap b = BitmapFactory.decodeResource(getResources(), R.mipmap.index_icn_earphone);
ImageSpan imgSpan = new ImageSpan(getActivity(), b, ImageSpan.ALIGN_BASELINE);
ImageSpan imgSpan = new ImageSpan(mContext, b, ImageSpan.ALIGN_BASELINE);
spanString = new SpannableString("icon");
spanString.setSpan(imgSpan, 0, 4, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
......@@ -245,14 +245,14 @@ public class AllPlaylistFragment extends Fragment {
((ItemView) holder).itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), PlaylistActivity.class);
Intent intent = new Intent(mContext, PlaylistActivity.class);
intent.putExtra("playlistid", info.getListid());
intent.putExtra("islocal", false);
intent.putExtra("albumart", info.getPic_300());
intent.putExtra("playlistname", info.getTitle());
intent.putExtra("playlistDetail", info.getTag());
intent.putExtra("playlistcount", info.getListenum());
getActivity().startActivity(intent);
mContext.startActivity(intent);
}
});
}
......
......@@ -2,7 +2,6 @@ package com.wm.remusic.fragmentnet;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -12,6 +11,7 @@ import android.widget.TextView;
import com.google.gson.JsonObject;
import com.wm.remusic.MainApplication;
import com.wm.remusic.R;
import com.wm.remusic.fragment.AttachFragment;
import com.wm.remusic.handler.HandlerUtil;
import com.wm.remusic.json.ArtistInfo;
import com.wm.remusic.net.BMA;
......@@ -20,7 +20,7 @@ import com.wm.remusic.net.HttpUtil;
/**
* Created by wm on 2016/8/3.
*/
public class ArtistInfoFragment extends Fragment {
public class ArtistInfoFragment extends AttachFragment {
FrameLayout frameLayout;
private TextView artistInfoView, artistName;
private String artistid;
......@@ -46,10 +46,10 @@ public class ArtistInfoFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.load_framelayout, container, false);
frameLayout = (FrameLayout) view.findViewById(R.id.loadframe);
View loadView = LayoutInflater.from(getActivity()).inflate(R.layout.loading, frameLayout, false);
View loadView = LayoutInflater.from(mContext).inflate(R.layout.loading, frameLayout, false);
frameLayout.addView(loadView);
v = LayoutInflater.from(getContext()).inflate(R.layout.fragment_artistinfo, frameLayout, false);
v = LayoutInflater.from(mContext).inflate(R.layout.fragment_artistinfo, frameLayout, false);
artistName = (TextView) v.findViewById(R.id.artist_name);
artistInfoView = (TextView) v.findViewById(R.id.artist_info);
if (getArguments() != null) {
......@@ -76,7 +76,7 @@ public class ArtistInfoFragment extends Fragment {
JsonObject object = HttpUtil.getResposeJsonObject(BMA.Artist.artistInfo("", artistid));
artistInfo = MainApplication.gsonInstance().fromJson(object, ArtistInfo.class);
if (artistInfo != null && artistInfo.getAvatar_s500() != null) {
HandlerUtil.getInstance(getContext()).post(new Runnable() {
HandlerUtil.getInstance(mContext).post(new Runnable() {
@Override
public void run() {
artistName.setText(artistInfo.getName());
......
......@@ -67,7 +67,7 @@ public class ArtistInfoMusicFragment extends BaseFragment {
}
Activity parentActivity = getActivity();
recyclerView = (ObservableRecyclerView) view.findViewById(R.id.scroll);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
recyclerView.setHasFixedSize(true);
PlaylistDetailAdapter adapter = new PlaylistDetailAdapter(getActivity(), mList);
recyclerView.setAdapter(adapter);
......@@ -232,7 +232,7 @@ public class ArtistInfoMusicFragment extends BaseFragment {
@Override
public void onClick(View v) {
HandlerUtil.getInstance(getContext()).postDelayed(new Runnable() {
HandlerUtil.getInstance(mContext).postDelayed(new Runnable() {
@Override
public void run() {
HashMap<Long, MusicInfo> infos = new HashMap<Long, MusicInfo>();
......
......@@ -4,7 +4,6 @@ package com.wm.remusic.fragmentnet;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
......@@ -17,6 +16,7 @@ import com.facebook.drawee.view.SimpleDraweeView;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.wm.remusic.R;
import com.wm.remusic.fragment.AttachFragment;
import com.wm.remusic.json.BillboardInfo;
import com.wm.remusic.net.BMA;
import com.wm.remusic.net.HttpUtil;
......@@ -26,7 +26,7 @@ import java.util.ArrayList;
/**
* Created by wm on 2016/5/14.
*/
public class RankingFragment extends Fragment {
public class RankingFragment extends AttachFragment {
//新歌榜
public static int BILLBOARD_NEW_MUSIC = 1;
......@@ -56,9 +56,9 @@ public class RankingFragment extends Fragment {
super.setUserVisibleHint(isVisibleToUser);
if (isVisibleToUser) {
if (view == null) {
view = LayoutInflater.from(getActivity()).inflate(R.layout.ranking, null, false);
view = LayoutInflater.from(mContext).inflate(R.layout.ranking, null, false);
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
linearLayoutManager = new LinearLayoutManager(getActivity());
linearLayoutManager = new LinearLayoutManager(mContext);
recyclerView.setLayoutManager(linearLayoutManager);
rankingAdapter = new RankingAdapter();
recyclerView.setAdapter(rankingAdapter);
......@@ -73,7 +73,7 @@ public class RankingFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.load_framelayout, container, false);
frameLayout = (FrameLayout) view.findViewById(R.id.loadframe);
View loadView = LayoutInflater.from(getActivity()).inflate(R.layout.loading, frameLayout, false);
View loadView = LayoutInflater.from(mContext).inflate(R.layout.loading, frameLayout, false);
frameLayout.addView(loadView);
return view;
......
......@@ -6,7 +6,6 @@ import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Spannable;
......@@ -33,6 +32,7 @@ import com.wm.remusic.activity.AlbumsDetailActivity;
import com.wm.remusic.activity.NetItemChangeActivity;
import com.wm.remusic.activity.PlaylistActivity;
import com.wm.remusic.activity.RadioDetailActivity;
import com.wm.remusic.fragment.AttachFragment;
import com.wm.remusic.json.RecommendListNewAlbumInfo;
import com.wm.remusic.json.RecommendListRadioInfo;
import com.wm.remusic.json.RecommendListRecommendInfo;
......@@ -47,7 +47,7 @@ import java.util.HashMap;
/**
* Created by wm on 2016/4/9.
*/
public class RecommendFragment extends Fragment {
public class RecommendFragment extends AttachFragment {
private RecyclerView recyclerView1, recyclerView2, recyclerView3;
......@@ -78,14 +78,14 @@ public class RecommendFragment extends Fragment {
View view = inflater.inflate(R.layout.recommend, container, false);
String date = Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "";
layoutInflater = LayoutInflater.from(getContext());
layoutInflater = LayoutInflater.from(mContext);
TextView dailyText = (TextView) view.findViewById(R.id.daily_text);
dailyText.setText(date);
itemChanged = (LinearLayout) view.findViewById(R.id.item_change);
viewContent = (LinearLayout) view.findViewById(R.id.recommend_layout);
if (!PreferencesUtility.getInstance(getActivity()).isCurrentDayFirst(date)) {
PreferencesUtility.getInstance(getContext()).setCurrentDate(date);
if (!PreferencesUtility.getInstance(mContext).isCurrentDayFirst(date)) {
PreferencesUtility.getInstance(mContext).setCurrentDate(date);
// loadView = layoutInflater.inflate(R.layout.loading_daymusic,null,false);
// RotateAnimation rotateAnimation = new RotateAnimation(0,360, 1, 0.5F, 1, 0.5F );
// rotateAnimation.setDuration(25000L);
......@@ -111,8 +111,8 @@ public class RecommendFragment extends Fragment {
change.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent itent = new Intent(getContext(), NetItemChangeActivity.class);
getActivity().startActivity(itent);
Intent itent = new Intent(mContext, NetItemChangeActivity.class);
mContext.startActivity(itent);
}
});
......@@ -130,14 +130,14 @@ public class RecommendFragment extends Fragment {
@Override
protected Void doInBackground(Void... params) {
if (NetworkUtils.isConnectInternet(getActivity())) {
if (NetworkUtils.isConnectInternet(mContext)) {
isFromCache = false;
}
//推荐电台
try {
JsonObject list = HttpUtil.getResposeJsonObject("http://tingapi.ting.baidu.com/v1/restserver/ting?from=android&version=5.8.1.0&channel=ppzs&operator=3&method=baidu.ting.plaza.index&cuid=89CF1E1A06826F9AB95A34DC0F6AAA14"
, getActivity(), isFromCache);
, mContext, isFromCache);
JsonObject object = list.get("result").getAsJsonObject();
JsonArray radioArray = object.get("radio").getAsJsonObject().get("result").getAsJsonArray();
......@@ -163,7 +163,7 @@ public class RecommendFragment extends Fragment {
v1 = layoutInflater.inflate(R.layout.recommend_playlist, viewContent, false);
recyclerView1 = (RecyclerView) v1.findViewById(R.id.recommend_playlist_recyclerview);
gridLayoutManager = new GridLayoutManager(getActivity(), 3);
gridLayoutManager = new GridLayoutManager(mContext, 3);
recyclerView1.setLayoutManager(gridLayoutManager);
recyclerView1.setAdapter(recomendAdapter);
recyclerView1.setHasFixedSize(true);
......@@ -178,14 +178,14 @@ public class RecommendFragment extends Fragment {
v2 = layoutInflater.inflate(R.layout.recommend_newalbums, viewContent, false);
recyclerView2 = (RecyclerView) v2.findViewById(R.id.recommend_newalbums_recyclerview);
gridLayoutManager2 = new GridLayoutManager(getActivity(), 3);
gridLayoutManager2 = new GridLayoutManager(mContext, 3);
recyclerView2.setLayoutManager(gridLayoutManager2);
recyclerView2.setAdapter(newAlbumsAdapter);
recyclerView2.setHasFixedSize(true);
v3 = layoutInflater.inflate(R.layout.recommend_radio, viewContent, false);
recyclerView3 = (RecyclerView) v3.findViewById(R.id.recommend_radio_recyclerview);
gridLayoutManager3 = new GridLayoutManager(getActivity(), 3);
gridLayoutManager3 = new GridLayoutManager(mContext, 3);
recyclerView3.setLayoutManager(gridLayoutManager3);
recyclerView3.setAdapter(radioAdapter);
recyclerView3.setHasFixedSize(true);
......@@ -198,7 +198,7 @@ public class RecommendFragment extends Fragment {
hashMap.put("推荐歌单", v1);
hashMap.put("最新专辑", v2);
hashMap.put("主播电台", v3);
position = PreferencesUtility.getInstance(getActivity()).getItemPosition();
position = PreferencesUtility.getInstance(mContext).getItemPosition();
loadView.clearAnimation();
viewContent.removeView(loadView);
......@@ -215,14 +215,14 @@ public class RecommendFragment extends Fragment {
@Override
protected Integer doInBackground(Integer... params) {
if (NetworkUtils.isConnectInternet(getActivity())) {
if (NetworkUtils.isConnectInternet(mContext)) {
isFromCache = false;
}
//推荐电台
try {
JsonObject list = HttpUtil.getResposeJsonObject("http://tingapi.ting.baidu.com/v1/restserver/ting?from=android&version=5.8.1.0&channel=ppzs&operator=3&method=baidu.ting.plaza.index&cuid=89CF1E1A06826F9AB95A34DC0F6AAA14"
, getActivity(), isFromCache);
, mContext, isFromCache);
JsonObject object = list.get("result").getAsJsonObject();
JsonArray radioArray = object.get("radio").getAsJsonObject().get("result").getAsJsonArray();
......@@ -249,8 +249,8 @@ public class RecommendFragment extends Fragment {
tryCount++;
new LoadRecommend().execute(tryCount);
} else {
Toast.makeText(getContext(), "网络连接失败", Toast.LENGTH_SHORT).show();
View tryAgain = LayoutInflater.from(getContext()).inflate(R.layout.try_again, viewContent, false);
Toast.makeText(mContext, "网络连接失败", Toast.LENGTH_SHORT).show();
View tryAgain = LayoutInflater.from(mContext).inflate(R.layout.try_again, viewContent, false);
tryAgain.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......@@ -266,7 +266,7 @@ public class RecommendFragment extends Fragment {
v1 = layoutInflater.inflate(R.layout.recommend_playlist, viewContent, false);
recyclerView1 = (RecyclerView) v1.findViewById(R.id.recommend_playlist_recyclerview);
gridLayoutManager = new GridLayoutManager(getActivity(), 3);
gridLayoutManager = new GridLayoutManager(mContext, 3);
recyclerView1.setLayoutManager(gridLayoutManager);
recyclerView1.setAdapter(recomendAdapter);
TextView more = (TextView) v1.findViewById(R.id.more);
......@@ -280,13 +280,13 @@ public class RecommendFragment extends Fragment {
v2 = layoutInflater.inflate(R.layout.recommend_newalbums, viewContent, false);
recyclerView2 = (RecyclerView) v2.findViewById(R.id.recommend_newalbums_recyclerview);
gridLayoutManager2 = new GridLayoutManager(getActivity(), 3);
gridLayoutManager2 = new GridLayoutManager(mContext, 3);
recyclerView2.setLayoutManager(gridLayoutManager2);
recyclerView2.setAdapter(newAlbumsAdapter);
v3 = layoutInflater.inflate(R.layout.recommend_radio, viewContent, false);
recyclerView3 = (RecyclerView) v3.findViewById(R.id.recommend_radio_recyclerview);
gridLayoutManager3 = new GridLayoutManager(getActivity(), 3);
gridLayoutManager3 = new GridLayoutManager(mContext, 3);
recyclerView3.setLayoutManager(gridLayoutManager3);
recyclerView3.setAdapter(radioAdapter);
......@@ -299,7 +299,7 @@ public class RecommendFragment extends Fragment {
hashMap.put("推荐歌单", v1);
hashMap.put("最新专辑", v2);
hashMap.put("主播电台", v3);
position = PreferencesUtility.getInstance(getActivity()).getItemPosition();
position = PreferencesUtility.getInstance(mContext).getItemPosition();
loadView.clearAnimation();
viewContent.removeView(loadView);
......@@ -326,7 +326,7 @@ public class RecommendFragment extends Fragment {
if (position == null) {
return;
}
String st = PreferencesUtility.getInstance(getActivity()).getItemPosition();
String st = PreferencesUtility.getInstance(mContext).getItemPosition();
if (!st.equals(position)) {
position = st;
viewContent.removeAllViews();
......@@ -342,7 +342,7 @@ public class RecommendFragment extends Fragment {
public RecommendAdapter(ArrayList<RecommendListRecommendInfo> list) {
Bitmap b = BitmapFactory.decodeResource(getResources(), R.mipmap.index_icn_earphone);
ImageSpan imgSpan = new ImageSpan(getActivity(), b, ImageSpan.ALIGN_BASELINE);
ImageSpan imgSpan = new ImageSpan(mContext, b, ImageSpan.ALIGN_BASELINE);
spanString = new SpannableString("icon");
spanString.setSpan(imgSpan, 0, 4, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
......@@ -391,7 +391,7 @@ public class RecommendFragment extends Fragment {
((ItemView) holder).itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), PlaylistActivity.class);
Intent intent = new Intent(mContext, PlaylistActivity.class);
intent.putExtra("playlistid", info.getListid());
intent.putExtra("islocal", false);
intent.putExtra("albumart", info.getPic());
......@@ -399,7 +399,7 @@ public class RecommendFragment extends Fragment {
intent.putExtra("playlistDetail", info.getTag());
intent.putExtra("playlistcount", info.getListenum());
getActivity().startActivity(intent);
mContext.startActivity(intent);
}
});
......@@ -484,12 +484,12 @@ public class RecommendFragment extends Fragment {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), RadioDetailActivity.class);
Intent intent = new Intent(mContext, RadioDetailActivity.class);
intent.putExtra("albumid", info.getAlbum_id());
intent.putExtra("albumart", info.getPic());
intent.putExtra("albumname", info.getTitle());
intent.putExtra("artistname", info.getDesc());
getActivity().startActivity(intent);
mContext.startActivity(intent);
}
});
......@@ -585,7 +585,7 @@ public class RecommendFragment extends Fragment {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), AlbumsDetailActivity.class);
Intent intent = new Intent(mContext, AlbumsDetailActivity.class);
// intent.putExtra("albumid",info.getType_id());
// intent.putExtra("albumart",info.getPic());
// intent.putExtra("albumname",info.getTitle());
......@@ -596,7 +596,7 @@ public class RecommendFragment extends Fragment {
intent.putExtra("albumname", info.getTitle());
intent.putExtra("albumdetail", info.getDesc());
// intent.putExtra("playlistcount",info.get);
getActivity().startActivity(intent);
mContext.startActivity(intent);
// AlbumsDetail fragment = AlbumsDetail.newInstance(info.id, info.coverImgUrl, info.albumName,
// info.artistName, info.publishTime);
......
......@@ -4,7 +4,6 @@ import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
......@@ -16,6 +15,7 @@ import android.widget.TextView;
import com.facebook.drawee.view.SimpleDraweeView;
import com.wm.remusic.R;
import com.wm.remusic.activity.AlbumsDetailActivity;
import com.wm.remusic.fragment.AttachFragment;
import com.wm.remusic.json.SearchAlbumInfo;
import com.wm.remusic.widget.DividerItemDecoration;
......@@ -25,7 +25,7 @@ import java.util.List;
/**
* Created by wm on 2016/5/18.
*/
public class SearchAlbumFragment extends Fragment {
public class SearchAlbumFragment extends AttachFragment {
private LinearLayoutManager layoutManager;
private List<SearchAlbumInfo> mAlbumList = new ArrayList<>();
......@@ -47,7 +47,7 @@ public class SearchAlbumFragment extends Fragment {
View view = inflater.inflate(R.layout.recylerview, container, false);
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
layoutManager = new LinearLayoutManager(getActivity());
layoutManager = new LinearLayoutManager(mContext);
recyclerView.setLayoutManager(layoutManager);
mAdapter = new AlbumAdapter(null);
recyclerView.setAdapter(mAdapter);
......@@ -60,12 +60,12 @@ public class SearchAlbumFragment extends Fragment {
//设置分割线
private void setItemDecoration() {
itemDecoration = new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST);
itemDecoration = new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST);
recyclerView.addItemDecoration(itemDecoration);
}
private void loadAlbums() {
if (getActivity() == null) {
if (mContext == null) {
return;
}
if (getArguments() != null) {
......@@ -137,12 +137,12 @@ public class SearchAlbumFragment extends Fragment {
@Override
public void onClick(View v) {
SearchAlbumInfo model = mList.get(getAdapterPosition());
Intent intent = new Intent(getActivity(), AlbumsDetailActivity.class);
Intent intent = new Intent(mContext, AlbumsDetailActivity.class);
intent.putExtra("albumid", model.getAlbum_id());
intent.putExtra("albumart", model.getPic_small());
intent.putExtra("albumname", model.getTitle());
intent.putExtra("artistname", model.getAuthor());
getActivity().startActivity(intent);
mContext.startActivity(intent);
}
}
......
......@@ -4,7 +4,6 @@ import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
......@@ -16,6 +15,7 @@ import android.widget.TextView;
import com.facebook.drawee.view.SimpleDraweeView;
import com.wm.remusic.R;
import com.wm.remusic.activity.ArtistDetailActivity;
import com.wm.remusic.fragment.AttachFragment;
import com.wm.remusic.json.SearchArtistInfo;
import com.wm.remusic.widget.DividerItemDecoration;
......@@ -24,7 +24,7 @@ import java.util.ArrayList;
/**
* Created by wm on 2016/5/18.
*/
public class SearchArtistFragment extends Fragment {
public class SearchArtistFragment extends AttachFragment {
private ArrayList<SearchArtistInfo> artistInfos;
private RecyclerView recyclerView;
......@@ -46,7 +46,7 @@ public class SearchArtistFragment extends Fragment {
View view = inflater.inflate(R.layout.recylerview, container, false);
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
layoutManager = new LinearLayoutManager(getActivity());
layoutManager = new LinearLayoutManager(mContext);
recyclerView.setLayoutManager(layoutManager);
mAdapter = new ArtistAdapter(null);
recyclerView.setAdapter(mAdapter);
......@@ -61,7 +61,7 @@ public class SearchArtistFragment extends Fragment {
//设置分割线
private void setItemDecoration() {
itemDecoration = new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST);
itemDecoration = new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST);
recyclerView.addItemDecoration(itemDecoration);
}
......@@ -133,13 +133,13 @@ public class SearchArtistFragment extends Fragment {
//加载歌手专辑界面fragment
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), ArtistDetailActivity.class);
Intent intent = new Intent(mContext, ArtistDetailActivity.class);
SearchArtistInfo model = mList.get(getAdapterPosition());
intent.putExtra("artistid", model.getArtist_id());
intent.putExtra("artistart", model.getAvatar_middle());
intent.putExtra("artistname", model.getAuthor());
intent.putExtra("artistUid", model.getTing_uid());
getActivity().startActivity(intent);
mContext.startActivity(intent);
}
}
......
......@@ -4,7 +4,6 @@ import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
......@@ -16,6 +15,7 @@ import android.widget.TextView;
import com.google.gson.JsonArray;
import com.wm.remusic.R;
import com.wm.remusic.adapter.RecentSearchAdapter;
import com.wm.remusic.fragment.AttachFragment;
import com.wm.remusic.json.SearchSongInfo;
import com.wm.remusic.net.BMA;
import com.wm.remusic.net.HttpUtil;
......@@ -29,7 +29,7 @@ import java.util.List;
/**
* Created by wm on 2016/5/21.
*/
public class SearchHotWordFragment extends Fragment implements View.OnClickListener, SearchWords {
public class SearchHotWordFragment extends AttachFragment implements View.OnClickListener, SearchWords {
String[] texts = new String[10];
ArrayList<TextView> views = new ArrayList<>();
SearchWords searchWords;
......@@ -47,7 +47,7 @@ public class SearchHotWordFragment extends Fragment implements View.OnClickListe
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.load_framelayout, container, false);
frameLayout = (FrameLayout) view.findViewById(R.id.loadframe);
loadview = LayoutInflater.from(getActivity()).inflate(R.layout.loading, frameLayout, false);
loadview = LayoutInflater.from(mContext).inflate(R.layout.loading, frameLayout, false);
frameLayout.addView(loadview);
loadWords();
......@@ -69,13 +69,13 @@ public class SearchHotWordFragment extends Fragment implements View.OnClickListe
@Override
protected Boolean doInBackground(Boolean... params) {
if (NetworkUtils.isConnectInternet(getActivity())) {
if (NetworkUtils.isConnectInternet(mContext)) {
isFromCache = false;
}
try {
JsonArray jsonArray = HttpUtil.getResposeJsonObject(BMA.Search.hotWord(), getActivity(), isFromCache).get("result").getAsJsonArray();
JsonArray jsonArray = HttpUtil.getResposeJsonObject(BMA.Search.hotWord(), mContext, isFromCache).get("result").getAsJsonArray();
for (int i = 0; i < 10; i++) {
texts[i] = jsonArray.get(i).getAsJsonObject().get("word").getAsString();
}
......@@ -90,15 +90,15 @@ public class SearchHotWordFragment extends Fragment implements View.OnClickListe
@Override
protected void onPostExecute(Boolean load) {
super.onPostExecute(load);
if (!load && getActivity() == null) {
if (!load && mContext == null) {
return;
}
View view = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_search_hot_words, frameLayout, false);
View view = LayoutInflater.from(mContext).inflate(R.layout.fragment_search_hot_words, frameLayout, false);
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
recyclerView.setHasFixedSize(true);
adapter = new RecentSearchAdapter(getActivity());
adapter = new RecentSearchAdapter(mContext);
adapter.setListenter(SearchHotWordFragment.this);
recyclerView.setAdapter(adapter);
......@@ -127,10 +127,10 @@ public class SearchHotWordFragment extends Fragment implements View.OnClickListe
frameLayout.removeAllViews();
frameLayout.addView(view);
int w = getActivity().getResources().getDisplayMetrics().widthPixels;
int w = mContext.getResources().getDisplayMetrics().widthPixels;
int xdistance = -1;
int ydistance = 0;
int distance = dip2px(getActivity(), 16);
int distance = dip2px(mContext, 16);
for (int i = 0; i < 10; i++) {
views.get(i).setOnClickListener(SearchHotWordFragment.this);
views.get(i).setText(texts[i]);
......
......@@ -4,7 +4,6 @@ import android.content.DialogInterface;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
......@@ -18,6 +17,7 @@ import com.google.gson.JsonObject;
import com.wm.remusic.MainApplication;
import com.wm.remusic.R;
import com.wm.remusic.downmusic.Down;
import com.wm.remusic.fragment.AttachFragment;
import com.wm.remusic.info.MusicInfo;
import com.wm.remusic.json.MusicDetailInfo;
import com.wm.remusic.json.SearchSongInfo;
......@@ -32,7 +32,7 @@ import java.util.HashMap;
/**
* Created by wm on 2016/5/18.
*/
public class SearchMusicFragment extends Fragment {
public class SearchMusicFragment extends AttachFragment {
private MusicAdapter mAdapter;
private ArrayList<SearchSongInfo> songInfos;
......@@ -57,12 +57,12 @@ public class SearchMusicFragment extends Fragment {
}
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
layoutManager = new LinearLayoutManager(getActivity());
layoutManager = new LinearLayoutManager(mContext);
recyclerView.setLayoutManager(layoutManager);
mAdapter = new MusicAdapter(songInfos);
recyclerView.setAdapter(mAdapter);
recyclerView.setHasFixedSize(true);
recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
recyclerView.addItemDecoration(new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST));
return view;
}
......@@ -154,15 +154,15 @@ public class SearchMusicFragment extends Fragment {
@Override
public void onClick(View v) {
final SearchSongInfo model = mList.get(getAdapterPosition());
new AlertDialog.Builder(getActivity()).setTitle("要下载音乐吗").
setPositiveButton(getActivity().getString(R.string.sure), new DialogInterface.OnClickListener() {
new AlertDialog.Builder(mContext).setTitle("要下载音乐吗").
setPositiveButton(mContext.getString(R.string.sure), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Down.downMusic(MainApplication.context, model.getSong_id() + "", model.getTitle(), model.getAuthor());
dialog.dismiss();
}
}).
setNegativeButton(getActivity().getString(R.string.cancel), new DialogInterface.OnClickListener() {
setNegativeButton(mContext.getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
......
......@@ -19,6 +19,7 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.wm.remusic.MainApplication;
import com.wm.remusic.R;
import com.wm.remusic.fragment.AttachFragment;
import com.wm.remusic.json.SearchAlbumInfo;
import com.wm.remusic.json.SearchArtistInfo;
import com.wm.remusic.json.SearchSongInfo;
......@@ -32,7 +33,7 @@ import java.util.List;
/**
* Created by wm on 2016/4/11.
*/
public class SearchTabPagerFragment extends Fragment {
public class SearchTabPagerFragment extends AttachFragment {
private ViewPager viewPager;
private int page = 0;
......@@ -94,10 +95,10 @@ public class SearchTabPagerFragment extends Fragment {
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
if (getActivity() == null) {
if (mContext == null) {
return;
}
contentView = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_net_tab, frameLayout, false);
contentView = LayoutInflater.from(mContext).inflate(R.layout.fragment_net_tab, frameLayout, false);
viewPager = (ViewPager) contentView.findViewById(R.id.viewpager);
if (viewPager != null) {
Adapter adapter = new Adapter(getChildFragmentManager());
......@@ -111,8 +112,8 @@ public class SearchTabPagerFragment extends Fragment {
TabLayout tabLayout = (TabLayout) contentView.findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager);
viewPager.setCurrentItem(page);
tabLayout.setTabTextColors(R.color.text_color, ThemeUtils.getThemeColorStateList(getActivity(), R.color.theme_color_primary).getDefaultColor());
tabLayout.setSelectedTabIndicatorColor(ThemeUtils.getThemeColorStateList(getActivity(), R.color.theme_color_primary).getDefaultColor());
tabLayout.setTabTextColors(R.color.text_color, ThemeUtils.getThemeColorStateList(mContext, R.color.theme_color_primary).getDefaultColor());
tabLayout.setSelectedTabIndicatorColor(ThemeUtils.getThemeColorStateList(mContext, R.color.theme_color_primary).getDefaultColor());
frameLayout.removeAllViews();
frameLayout.addView(contentView);
......@@ -133,7 +134,7 @@ public class SearchTabPagerFragment extends Fragment {
View rootView = inflater.inflate(R.layout.load_framelayout, container, false);
frameLayout = (FrameLayout) rootView.findViewById(R.id.loadframe);
View loadview = LayoutInflater.from(getActivity()).inflate(R.layout.loading, frameLayout, false);
View loadview = LayoutInflater.from(mContext).inflate(R.layout.loading, frameLayout, false);
frameLayout.addView(loadview);
......
......@@ -13,6 +13,7 @@ import android.view.ViewGroup;
import com.bilibili.magicasakura.utils.ThemeUtils;
import com.wm.remusic.R;
import com.wm.remusic.fragment.AttachFragment;
import java.util.ArrayList;
import java.util.List;
......@@ -20,7 +21,7 @@ import java.util.List;
/**
* Created by wm on 2016/4/11.
*/
public class TabNetPagerFragment extends Fragment implements ChangeView {
public class TabNetPagerFragment extends AttachFragment implements ChangeView {
//PreferencesUtility mPreferences;
private ViewPager viewPager;
private int page = 0;
......@@ -62,8 +63,8 @@ public class TabNetPagerFragment extends Fragment implements ChangeView {
}
final TabLayout tabLayout = (TabLayout) rootView.findViewById(R.id.tabs);
tabLayout.setTabTextColors(R.color.text_color, ThemeUtils.getThemeColorStateList(getActivity(), R.color.theme_color_primary).getDefaultColor());
tabLayout.setSelectedTabIndicatorColor(ThemeUtils.getThemeColorStateList(getActivity(), R.color.theme_color_primary).getDefaultColor());
tabLayout.setTabTextColors(R.color.text_color, ThemeUtils.getThemeColorStateList(mContext, R.color.theme_color_primary).getDefaultColor());
tabLayout.setSelectedTabIndicatorColor(ThemeUtils.getThemeColorStateList(mContext, R.color.theme_color_primary).getDefaultColor());
new Thread(new Runnable() {
@Override
public void run() {
......
......@@ -12,6 +12,7 @@ import com.wm.remusic.MainApplication;
import com.wm.remusic.activity.MainActivity;
import com.wm.remusic.provider.MusicPlaybackState;
import com.wm.remusic.uitl.CommonUtils;
import com.wm.remusic.uitl.PreferencesUtility;
import java.io.File;
import java.io.PrintWriter;
......@@ -48,13 +49,17 @@ public class UnceHandler implements Thread.UncaughtExceptionHandler {
}
MusicPlaybackState.getInstance(application).clearQueue();
Intent intent = new Intent(application.getApplicationContext(), MainActivity.class);
if (System.currentTimeMillis() - PreferencesUtility.getInstance(application.getApplicationContext()).lastExit() < 10000) {
android.os.Process.killProcess(android.os.Process.myPid());
return;
}
PendingIntent restartIntent = PendingIntent.getActivity(
application.getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
//退出程序
AlarmManager mgr = (AlarmManager) application.getSystemService(Context.ALARM_SERVICE);
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 300,
restartIntent); // 1秒钟后重启应用
PreferencesUtility.getInstance(MainApplication.context).setExitTime();
android.os.Process.killProcess(android.os.Process.myPid());
}
}
......
......@@ -41,6 +41,15 @@ public class TopTracksLoader extends SongLoader {
return getCursor();
}
public static int getCount(Context context, QueryType queryType) {
Cursor cursor = getCursor(context, queryType);
if (cursor != null) {
return cursor.getCount();
} else {
return 0;
}
}
public static Cursor getCursor() {
SortedCursor retCursor = null;
if (mQueryType == QueryType.TopTracks) {
......
......@@ -17,7 +17,7 @@
package com.wm.remusic.uitl;
/**
* <p/>
* <p>
* 常量接口
*/
public interface IConstants {
......
......@@ -57,6 +57,16 @@ public final class PreferencesUtility {
return sInstance;
}
public long lastExit() {
return mPreferences.getLong("last_err_exit", 0);
}
public void setExitTime() {
final SharedPreferences.Editor editor = mPreferences.edit();
editor.putLong("last_err_exit", System.currentTimeMillis());
editor.commit();
}
public boolean isCurrentDayFirst(String str) {
return mPreferences.getString(CURRENT_DATE, "").equals(str);
}
......
......@@ -31,7 +31,7 @@ import java.util.ArrayList;
* Implementation of {@link android.support.v4.view.PagerAdapter} that
* uses a {@link Fragment} to manage each page. This class also handles
* saving and restoring of fragment's state.
* <p/>
* <p>
* <p>This version of the pager is more useful when there are a large number
* of pages, working more like a list view. When pages are not visible to
* the user, their entire fragment may be destroyed, only keeping the saved
......@@ -39,27 +39,27 @@ import java.util.ArrayList;
* memory associated with each visited page as compared to
* {@link FragmentPagerAdapter} at the cost of potentially more overhead when
* switching between pages.
* <p/>
* <p>
* <p>When using FragmentPagerAdapter the host ViewPager must have a
* valid ID set.</p>
* <p/>
* <p>
* <p>Subclasses only need to implement {@link #getItem(int)}
* and {@link #getCount()} to have a working adapter.
* <p/>
* <p>
* <p>Here is an example implementation of a pager containing fragments of
* lists:
* <p/>
* <p>
* {@sample development/samples/Support13Demos/src/com/example/android/supportv13/app/FragmentStatePagerSupport.java
* complete}
* <p/>
* <p>
* <p>The <code>R.layout.fragment_pager</code> resource of the top-level fragment is:
* <p/>
* <p>
* {@sample development/samples/Support13Demos/res/layout/fragment_pager.xml
* complete}
* <p/>
* <p>
* <p>The <code>R.layout.fragment_pager_list</code> resource containing each
* individual fragment's layout is:
* <p/>
* <p>
* {@sample development/samples/Support13Demos/res/layout/fragment_pager_list.xml
* complete}
*/
......
......@@ -12,7 +12,7 @@ import android.view.ViewGroup;
* specific implementation of this, such as
* {@link android.support.v4.app.FragmentPagerAdapter} or
* {@link android.support.v4.app.FragmentStatePagerAdapter}.
* <p/>
* <p>
* <p>When you implement a PagerAdapter, you must override the following methods
* at minimum:</p>
* <ul>
......@@ -21,7 +21,7 @@ import android.view.ViewGroup;
* <li>{@link #getCount()}</li>
* <li>{@link #isViewFromObject(View, Object)}</li>
* </ul>
* <p/>
* <p>
* <p>PagerAdapter is more general than the adapters used for
* {@link android.widget.AdapterView AdapterViews}. Instead of providing a
* View recycling mechanism directly ViewPager uses callbacks to indicate the
......@@ -29,7 +29,7 @@ import android.view.ViewGroup;
* recycling if desired or use a more sophisticated method of managing page
* Views such as Fragment transactions where each page is represented by its
* own Fragment.</p>
* <p/>
* <p>
* <p>ViewPager associates each page with a key Object instead of working with
* Views directly. This key is used to track and uniquely identify a given page
* independent of its position in the adapter. A call to the PagerAdapter method
......@@ -44,14 +44,14 @@ import android.view.ViewGroup;
* the keys passed to {@link #destroyItem(ViewGroup, int, Object) destroyItem}
* should be removed. The method {@link #isViewFromObject(View, Object)} identifies
* whether a page View is associated with a given key object.</p>
* <p/>
* <p>
* <p>A very simple PagerAdapter may choose to use the page Views themselves
* as key objects, returning them from {@link #instantiateItem(ViewGroup, int)}
* after creation and adding them to the parent ViewGroup. A matching
* {@link #destroyItem(ViewGroup, int, Object)} implementation would remove the
* View from the parent ViewGroup and {@link #isViewFromObject(View, Object)}
* could be implemented as <code>return view == object;</code>.</p>
* <p/>
* <p>
* <p>PagerAdapter supports data set changes. Data set changes must occur on the
* main thread and must end with a call to {@link #notifyDataSetChanged()} similar
* to AdapterView adapters derived from {@link android.widget.BaseAdapter}. A data
......@@ -238,7 +238,7 @@ public abstract class PagerAdapter {
* has changed. Returns {@link #POSITION_UNCHANGED} if the position of the given
* item has not changed or {@link #POSITION_NONE} if the item is no longer present
* in the adapter.
* <p/>
* <p>
* <p>The default implementation assumes that items will never
* change position and always returns {@link #POSITION_UNCHANGED}.
*
......
......@@ -70,12 +70,12 @@ import java.util.List;
* Layout manager that allows the user to flip left and right
* through pages of data. You supply an implementation of a
* {@link PagerAdapter} to generate the pages that the view shows.
* <p/>
* <p>
* <p>Note this class is currently under early design and
* development. The API will likely change in later updates of
* the compatibility library, requiring changes to the source code
* of apps when they are compiled against the newer version.</p>
* <p/>
* <p>
* <p>ViewPager is most often used in conjunction with {@link android.app.Fragment},
* which is a convenient way to supply and manage the lifecycle of each page.
* There are standard adapters implemented for using fragments with the ViewPager,
......@@ -84,15 +84,15 @@ import java.util.List;
* {@link android.support.v4.app.FragmentStatePagerAdapter}; each of these
* classes have simple code showing how to build a full user interface
* with them.
* <p/>
* <p>
* <p>For more information about how to use ViewPager, read <a
* href="{@docRoot}training/implementing-navigation/lateral.html">Creating Swipe Views with
* Tabs</a>.</p>
* <p/>
* <p>
* <p>Below is a more complicated example of ViewPager, using it in conjunction
* with {@link android.app.ActionBar} tabs. You can find other examples of using
* ViewPager in the API 4+ Support Demos and API 13+ Support Demos sample code.
* <p/>
* <p>
* {@sample development/samples/Support13Demos/src/com/example/android/supportv13/app/ActionBarTabsPager.java
* complete}
*/
......@@ -328,7 +328,7 @@ public class RoundViewPager extends ViewGroup {
* A PageTransformer is invoked whenever a visible/attached page is scrolled.
* This offers an opportunity for the application to apply a custom transformation
* to the page views using animation properties.
* <p/>
* <p>
* <p>As property animation is only supported as of Android 3.0 and forward,
* setting a PageTransformer on a ViewPager on earlier platform versions will
* be ignored.</p>
......@@ -692,7 +692,7 @@ public class RoundViewPager extends ViewGroup {
/**
* Add a listener that will be invoked whenever the page changes or is incrementally
* scrolled. See {@link OnPageChangeListener}.
* <p/>
* <p>
* <p>Components that add a listener should take care to remove it when finished.
* Other components that take ownership of a view may call {@link #clearOnPageChangeListeners()}
* to remove all attached listeners.</p>
......@@ -731,7 +731,7 @@ public class RoundViewPager extends ViewGroup {
* Set a {@link PageTransformer} that will be called for each attached page whenever
* the scroll position is changed. This allows the application to apply custom property
* transformations to each page, overriding the default sliding look and feel.
* <p/>
* <p>
* <p><em>Note:</em> Prior to Android 3.0 the property animation APIs did not exist.
* As a result, setting a PageTransformer prior to Android 3.0 (API 11) will have no effect.</p>
*
......@@ -806,14 +806,14 @@ public class RoundViewPager extends ViewGroup {
* Set the number of pages that should be retained to either side of the
* current page in the view hierarchy in an idle state. Pages beyond this
* limit will be recreated from the adapter when needed.
* <p/>
* <p>
* <p>This is offered as an optimization. If you know in advance the number
* of pages you will need to support or have lazy-loading mechanisms in place
* on your pages, tweaking this setting can have benefits in perceived smoothness
* of paging animations and interaction. If you have a small number of pages (3-4)
* that you can keep active all at once, less time will be spent in layout for
* newly created view subtrees as the user pages back and forth.</p>
* <p/>
* <p>
* <p>You should keep this limit low, especially if your pages have complex layouts.
* This setting defaults to 1.</p>
*
......@@ -2472,13 +2472,13 @@ public class RoundViewPager extends ViewGroup {
/**
* Start a fake drag of the pager.
* <p/>
* <p>
* <p>A fake drag can be useful if you want to synchronize the motion of the ViewPager
* with the touch scrolling of another view, while still letting the ViewPager
* control the snapping motion and fling behavior. (e.g. parallax-scrolling tabs.)
* Call {@link #fakeDragBy(float)} to simulate the actual drag motion. Call
* {@link #endFakeDrag()} to complete the fake drag and fling as necessary.
* <p/>
* <p>
* <p>During a fake drag the ViewPager will ignore all touch events. If a real drag
* is already in progress, this method will return false.
*
......
文件已添加
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.wm.remusic">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name = "android.permission.DISABLE_KEYGUARD"/>
<application
android:name=".MainApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".activity.MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activity.LoadingActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.NetSearchWordsActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.PlayingActivity"
android:launchMode="singleTask"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="com.wm.remusic.LAUNCH_NOW_PLAYING_ACTION" />
</intent-filter>
</activity>
<activity
android:name=".activity.LocalSearchActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.SelectActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.PlaylistSelectActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.PlaylistManagerActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.AlbumsDetailActivity"
android:screenOrientation="portrait" />
<activity
android:name=".activity.TabActivity"
android:screenOrientation="portrait" />
<activity android:name=".activity.DownActivity" android:screenOrientation="portrait"/>
<activity android:name=".activity.PlaylistActivity" android:screenOrientation="portrait"/>
<activity android:name=".activity.RecentActivity" android:screenOrientation="portrait"/>
<activity android:name=".activity.NetItemChangeActivity" android:screenOrientation="portrait"/>
<activity android:name=".activity.ArtistDetailActivity" android:screenOrientation="portrait"/>
<activity android:name=".activity.RadioDetailActivity" android:screenOrientation="portrait"/>
<activity android:name=".activity.LockActivity"
android:excludeFromRecents="true"
android:exported="false"
android:launchMode="singleInstance"
android:screenOrientation="portrait"
android:noHistory="true"
android:taskAffinity="com.package.name.lockscreen"
android:theme="@style/LockScreenTheme"/>
<activity android:name=".request.UiMonitorActivity"/>
<service android:name=".downmusic.DownService">
<intent-filter>
<action android:name="com.wm.remusic.downtaskadd"/>
<action android:name="com.wm.remusic.resumestarttask"/>
<action android:name="com.wm.remusic.startalltask"/>
<action android:name="com.wm.remusic.multidowntaskadd"/>
<action android:name="com.wm.remusic.pausetask"/>
<action android:name="com.wm.remusic.pausealltask"/>
<action android:name="com.wm.remusic.cacletask"/>
<action android:name="com.wm.remusic.caclealltask"/>
</intent-filter>
</service>
<service
android:name=".service.MediaService"
android:process=":main" />
<receiver android:name=".receiver.MediaButtonIntentReceiver">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
<action android:name="android.media.AUDIO_BECOMING_NOISY" />
</intent-filter>
</receiver>
<receiver android:name=".receiver.LaunchNowPlayingReceiver">
<intent-filter>
<action android:name="com.wm.remusic.LAUNCH_NOW_PLAYING_ACTION" />
</intent-filter>
</receiver>
<receiver android:name=".widget.SimpleWidgetProvider" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
<action android:name="com.wm.remusic.metachanged"/>
<action android:name="com.wm.remusi.change_music"/>
<action android:name="com.wm.remusic.progress"/>
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/appwidget_info" />
</receiver>
</application>
</manifest>
package com.wm.remusic;
import com.wm.remusic.service.MusicTrack;
interface MediaAidlInterface
{
void openFile(String path);
void open(in Map infos, in long [] list, int position);
void stop();
void pause();
void play();
void prev(boolean forcePrevious);
void next();
void enqueue(in long [] list,in Map infos, int action);
Map getPlayinfos();
void setQueuePosition(int index);
void setShuffleMode(int shufflemode);
void setRepeatMode(int repeatmode);
void moveQueueItem(int from, int to);
void refresh();
void playlistChanged();
boolean isPlaying();
long [] getQueue();
long getQueueItemAtPosition(int position);
int getQueueSize();
int getQueuePosition();
int getQueueHistoryPosition(int position);
int getQueueHistorySize();
int[] getQueueHistoryList();
long duration();
long position();
int secondPosition();
long seek(long pos);
void seekRelative(long deltaInMs);
long getAudioId();
MusicTrack getCurrentTrack();
MusicTrack getTrack(int index);
long getNextAudioId();
long getPreviousAudioId();
long getArtistId();
long getAlbumId();
String getArtistName();
String getTrackName();
boolean isTrackLocal();
String getAlbumName();
String getAlbumPath();
String[] getAlbumPathtAll();
String getPath();
int getShuffleMode();
int removeTracks(int first, int last);
int removeTrack(long id);
boolean removeTrackAtPosition(long id, int position);
int getRepeatMode();
int getMediaMountedCount();
int getAudioSessionId();
void setLockscreenAlbumArt(boolean enabled);
void exit();
void timing(int time);
}
package com.wm.remusic.service;
parcelable MusicTrack;
\ No newline at end of file
/*
* Copyright (C) 2016 Bilibili
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bilibili.magicasakura.drawables;
import android.graphics.ColorFilter;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
import android.util.SparseArray;
/**
* This is an extension to {@link StateListDrawable} that workaround a bug not allowing
* to set a {@link ColorFilter} to the drawable in one of the states., it add a method
* {@link #addState(int[], Drawable, ColorFilter)} for that purpose.
*/
public class FilterableStateListDrawable extends StateListDrawable {
private int currIdx = -1;
private int childrenCount = 0;
private SparseArray<ColorFilter> filterMap;
public FilterableStateListDrawable() {
super();
filterMap = new SparseArray<>();
}
@Override
public void addState(int[] stateSet, Drawable drawable) {
super.addState(stateSet, drawable);
childrenCount++;
}
/**
* Same as {@link #addState(int[], Drawable)}, but allow to set a colorFilter associated to this Drawable.
*
* @param stateSet - An array of resource Ids to associate with the image.
* Switch to this image by calling setState().
* @param drawable -The image to show.
* @param colorFilter - The {@link ColorFilter} to apply to this state
*/
public void addState(int[] stateSet, Drawable drawable, ColorFilter colorFilter) {
if (colorFilter == null) {
addState(stateSet, drawable);
return;
}
// this is a new custom method, does not exist in parent class
int currChild = childrenCount;
addState(stateSet, drawable);
filterMap.put(currChild, colorFilter);
}
@Override
public boolean selectDrawable(int idx) {
boolean result = super.selectDrawable(idx);
// check if the drawable has been actually changed to the one I expect
if (getCurrent() != null) {
currIdx = result ? idx : currIdx;
setColorFilter(getColorFilterForIdx(currIdx));
} else {
currIdx = -1;
setColorFilter(null);
}
return result;
}
private ColorFilter getColorFilterForIdx(int idx) {
return filterMap != null ? filterMap.get(idx) : null;
}
@Override
public ConstantState getConstantState() {
return super.getConstantState();
}
}
\ No newline at end of file
/*
* Copyright (C) 2016 Bilibili
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bilibili.magicasakura.utils;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.graphics.Color;
import android.support.v4.graphics.ColorUtils;
import android.util.AttributeSet;
import android.util.StateSet;
import android.util.TypedValue;
import android.util.Xml;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.LinkedList;
/**
* @author xyczero617@gmail.com
* @time 16/2/22
*/
public class ColorStateListUtils {
static ColorStateList createColorStateList(Context context, int resId) {
if (resId <= 0) return null;
TypedValue value = new TypedValue();
context.getResources().getValue(resId, value, true);
ColorStateList cl = null;
if (value.type >= TypedValue.TYPE_FIRST_COLOR_INT
&& value.type <= TypedValue.TYPE_LAST_COLOR_INT) {
//Assume that "color/theme_color_primary" and "color/theme_color_profile" have the same color value;
//However, "color/theme_color_primary" need to replace by themeId, "color/theme_color_profile" not.
//If use value.data may cause "color/theme_color_profile" still been replaced by themeId
cl = ColorStateList.valueOf(ThemeUtils.replaceColorById(context, value.resourceId));
} else {
final String file = value.string.toString();
try {
if (file.endsWith("xml")) {
final XmlResourceParser rp = context.getResources().getAssets().openXmlResourceParser(
value.assetCookie, file);
final AttributeSet attrs = Xml.asAttributeSet(rp);
int type;
while ((type = rp.next()) != XmlPullParser.START_TAG
&& type != XmlPullParser.END_DOCUMENT) {
// Seek parser to start tag.
}
if (type != XmlPullParser.START_TAG) {
throw new XmlPullParserException("No start tag found");
}
cl = createFromXmlInner(context, rp, attrs);
rp.close();
}
} catch (IOException e) {
e.printStackTrace();
} catch (XmlPullParserException e) {
e.printStackTrace();
}
}
return cl;
}
static ColorStateList createFromXmlInner(Context context, XmlPullParser parser, AttributeSet attrs) throws IOException, XmlPullParserException {
final String name = parser.getName();
if (!name.equals("selector")) {
throw new XmlPullParserException(
parser.getPositionDescription() + ": invalid color state list tag " + name);
}
return inflateColorStateList(context, parser, attrs);
}
static ColorStateList inflateColorStateList(Context context, XmlPullParser parser, AttributeSet attrs) throws IOException, XmlPullParserException {
final int innerDepth = parser.getDepth() + 1;
int depth;
int type;
LinkedList<int[]> stateList = new LinkedList<>();
LinkedList<Integer> colorList = new LinkedList<>();
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
&& ((depth = parser.getDepth()) >= innerDepth || type != XmlPullParser.END_TAG)) {
if (type != XmlPullParser.START_TAG || depth > innerDepth
|| !parser.getName().equals("item")) {
continue;
}
TypedArray a1 = context.obtainStyledAttributes(attrs, new int[]{android.R.attr.color});
final int value = a1.getResourceId(0, Color.MAGENTA);
final int baseColor = value == Color.MAGENTA ? Color.MAGENTA : ThemeUtils.replaceColorById(context, value);
a1.recycle();
TypedArray a2 = context.obtainStyledAttributes(attrs, new int[]{android.R.attr.alpha});
final float alphaMod = a2.getFloat(0, 1.0f);
a2.recycle();
colorList.add(alphaMod != 1.0f
? ColorUtils.setAlphaComponent(baseColor, Math.round(Color.alpha(baseColor) * alphaMod))
: baseColor);
stateList.add(extractStateSet(attrs));
}
if (stateList.size() > 0 && stateList.size() == colorList.size()) {
int[] colors = new int[colorList.size()];
for (int i = 0; i < colorList.size(); i++) {
colors[i] = colorList.get(i);
}
return new ColorStateList(stateList.toArray(new int[stateList.size()][]), colors);
}
return null;
}
protected static int[] extractStateSet(AttributeSet attrs) {
int j = 0;
final int numAttrs = attrs.getAttributeCount();
int[] states = new int[numAttrs];
for (int i = 0; i < numAttrs; i++) {
final int stateResId = attrs.getAttributeNameResource(i);
switch (stateResId) {
case 0:
break;
case android.R.attr.color:
case android.R.attr.alpha:
// Ignore attributes from StateListDrawableItem and
// AnimatedStateListDrawableItem.
continue;
default:
states[j++] = attrs.getAttributeBooleanValue(i, false)
? stateResId : -stateResId;
}
}
states = StateSet.trimStateSet(states, j);
return states;
}
}
/*
* Copyright (C) 2016 Bilibili
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bilibili.magicasakura.utils;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.AttributeSet;
import android.util.StateSet;
import android.util.TypedValue;
import android.util.Xml;
import com.wm.remusic.R;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
/**
* @author xyczero617@gmail.com
* @time 16/2/22
*/
public abstract class DrawableUtils {
protected abstract Drawable inflateDrawable(Context context, XmlPullParser parser, AttributeSet attrs) throws IOException, XmlPullParserException;
static Drawable createDrawable(Context context, int resId) {
if (resId <= 0) return null;
final TypedValue typedValue = new TypedValue();
final Resources res = context.getResources();
res.getValue(resId, typedValue, true);
Drawable dr = null;
if (typedValue.type >= TypedValue.TYPE_FIRST_COLOR_INT
&& typedValue.type <= TypedValue.TYPE_LAST_COLOR_INT) {
dr = new ColorDrawable(ThemeUtils.replaceColorById(context, resId));
} else {
try {
if (typedValue.string != null && typedValue.string.toString().endsWith("xml")) {
final XmlResourceParser rp = res.getXml(resId);
final AttributeSet attrs = Xml.asAttributeSet(rp);
int type;
while ((type = rp.next()) != XmlPullParser.START_TAG &&
type != XmlPullParser.END_DOCUMENT) {
// Empty loop
}
if (type != XmlPullParser.START_TAG) {
throw new XmlPullParserException("No start tag found");
}
dr = createFromXmlInner(context, rp, attrs);
rp.close();
}
} catch (IOException e) {
e.printStackTrace();
} catch (XmlPullParserException e) {
e.printStackTrace();
}
}
return dr;
}
static Drawable createFromXmlInner(Context context, XmlPullParser parser, AttributeSet attrs) throws IOException, XmlPullParserException {
final DrawableUtils drawableUtils;
final String name = parser.getName();
switch (name) {
case "selector":
drawableUtils = new StateListDrawableUtils();
break;
case "shape":
drawableUtils = new GradientDrawableUtils();
break;
case "layer-list":
drawableUtils = new LayerDrawableUtils();
break;
default:
drawableUtils = null;
}
return drawableUtils == null ? null : drawableUtils.inflateDrawable(context, parser, attrs);
}
/**
* Extracts state_ attributes from an attribute set.
*
* @param attrs The attribute set.
* @return An array of state_ attributes.
*/
protected int[] extractStateSet(AttributeSet attrs) {
int j = 0;
final int numAttrs = attrs.getAttributeCount();
int[] states = new int[numAttrs];
for (int i = 0; i < numAttrs; i++) {
final int stateResId = attrs.getAttributeNameResource(i);
if (stateResId == 0) {
break;
} else if (stateResId == android.R.attr.drawable
|| stateResId == android.R.attr.id
|| stateResId == R.attr.drawableTint
|| stateResId == R.attr.drawableTintMode) {
// Ignore attributes from StateListDrawableItem and
// AnimatedStateListDrawableItem.
continue;
} else {
states[j++] = attrs.getAttributeBooleanValue(i, false)
? stateResId : -stateResId;
}
}
states = StateSet.trimStateSet(states, j);
return states;
}
static int getAttrTintColor(Context context, AttributeSet attrs, int attr, int defaultValue) {
final TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[]{attr});
final int tintColor = ThemeUtils.replaceColor(context, a.getColor(0, defaultValue));
a.recycle();
return tintColor;
}
static Drawable getAttrDrawable(Context context, AttributeSet attrs, int attr) {
final TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[]{attr});
final int resId = a.getResourceId(0, 0);
Drawable drawable = null;
if (resId != 0) {
drawable = createDrawable(context, resId);
if (drawable == null) {
drawable = a.getDrawable(0);
}
}
a.recycle();
return drawable;
}
static ColorFilter getAttrColorFilter(Context context, AttributeSet attrs, int tintAttr, int tintModeAttr) {
final int color = getAttrColor(context, attrs, tintAttr, Color.TRANSPARENT);
if (color == Color.TRANSPARENT) return null;
return new PorterDuffColorFilter(color, getTintMode(context, attrs, tintModeAttr));
}
static ColorStateList getTintColorList(Context context, AttributeSet attrs, int tintAttr) {
TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[]{tintAttr});
if (!a.hasValue(0)) {
a.recycle();
return null;
}
final ColorStateList cls = TintManager.get(context).getColorStateList(a.getResourceId(0, 0));
a.recycle();
return cls;
}
static PorterDuff.Mode getTintMode(Context context, AttributeSet attrs, int tintModeAttr) {
TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[]{tintModeAttr});
final int tintModeValue = a.getInt(0, 0);
a.recycle();
return parseTintMode(tintModeValue, PorterDuff.Mode.SRC_IN);
}
static int getAttrDimensionPixelSize(Context context, AttributeSet attrs, int attr) {
return getAttrDimensionPixelSize(context, attrs, attr, 0);
}
static int getAttrDimensionPixelSize(Context context, AttributeSet attrs, int attr, int defaultValue) {
TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[]{attr});
final int value = a.getDimensionPixelSize(0, defaultValue);
a.recycle();
return value;
}
static int getAttrColor(Context context, AttributeSet attrs, int attr, int defaultValue) {
TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[]{attr});
final int colorId = a.getResourceId(0, 0);
final int value = colorId != 0 ? ThemeUtils.replaceColorById(context, colorId) : ThemeUtils.replaceColor(context, a.getColor(0, defaultValue));
a.recycle();
return value;
}
static int getAttrDimensionPixelOffset(Context context, AttributeSet attrs, int attr) {
return getAttrDimensionPixelOffset(context, attrs, attr, 0);
}
static int getAttrDimensionPixelOffset(Context context, AttributeSet attrs, int attr, int defaultValue) {
TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[]{attr});
final int value = a.getDimensionPixelOffset(0, defaultValue);
a.recycle();
return value;
}
static float getAttrDimension(Context context, AttributeSet attrs, int attr) {
return getAttrDimension(context, attrs, attr, 0);
}
static float getAttrDimension(Context context, AttributeSet attrs, int attr, int defaultValue) {
TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[]{attr});
final float value = a.getDimension(0, defaultValue);
a.recycle();
return value;
}
static float getAttrFloat(Context context, AttributeSet attrs, int attr, float defaultValue) {
TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[]{attr});
final float alphaMod = a.getFloat(0, defaultValue);
a.recycle();
return alphaMod;
}
static int getAttrInt(Context context, AttributeSet attrs, int attr, int defaultValue) {
TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[]{attr});
final int value = a.getInt(0, defaultValue);
a.recycle();
return value;
}
static boolean getAttrBoolean(Context context, AttributeSet attrs, int attr, boolean defaultValue) {
TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[]{attr});
final boolean value = a.getBoolean(0, defaultValue);
a.recycle();
return value;
}
static boolean getAttrHasValue(Context context, AttributeSet attrs, int attr) {
TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[]{attr});
final boolean flag = a.hasValue(0);
a.recycle();
return flag;
}
static int getAttrResourceId(Context context, AttributeSet attrs, int attr, int defaultValue) {
TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[]{attr});
final int id = a.getResourceId(0, defaultValue);
a.recycle();
return id;
}
static TypedArray obtainAttributes(
Resources res, Resources.Theme theme, AttributeSet set, int[] attrs) {
if (theme == null) {
return res.obtainAttributes(set, attrs);
}
return theme.obtainStyledAttributes(set, attrs, 0, 0);
}
public static PorterDuff.Mode parseTintMode(int value, PorterDuff.Mode defaultMode) {
switch (value) {
case 3:
return PorterDuff.Mode.SRC_OVER;
case 5:
return PorterDuff.Mode.SRC_IN;
case 9:
return PorterDuff.Mode.SRC_ATOP;
case 14:
return PorterDuff.Mode.MULTIPLY;
case 15:
return PorterDuff.Mode.SCREEN;
case 16:
return Build.VERSION.SDK_INT >= 11 ? PorterDuff.Mode.valueOf("ADD")
: defaultMode;
default:
return defaultMode;
}
}
}
/*
* Copyright (C) 2016 Bilibili
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bilibili.magicasakura.utils;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.os.Build;
import android.support.v4.graphics.ColorUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.lang.reflect.Field;
/**
* @author xyczero617@gmail.com
* @time 16/2/22
*/
public class GradientDrawableUtils extends DrawableUtils {
private static Field sPaddingField;
private static Field sStPaddingField;
private static Field sStGradientPositions;
private static Field sStGradientAngle;
@Override
protected Drawable inflateDrawable(Context context, XmlPullParser parser, AttributeSet attrs) throws XmlPullParserException, IOException {
GradientDrawable gradientDrawable = new GradientDrawable();
inflateGradientRootElement(context, attrs, gradientDrawable);
int type;
final int innerDepth = parser.getDepth() + 1;
int depth;
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
&& ((depth = parser.getDepth()) >= innerDepth
|| type != XmlPullParser.END_TAG)) {
if (type != XmlPullParser.START_TAG) {
continue;
}
if (depth > innerDepth) {
continue;
}
String name = parser.getName();
if (name.equals("size")) {
final int width = getAttrDimensionPixelSize(context, attrs, android.R.attr.width);
final int height = getAttrDimensionPixelSize(context, attrs, android.R.attr.height);
gradientDrawable.setSize(width, height);
} else if (name.equals("gradient") && Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
final float centerX = getAttrFloatOrFraction(context, attrs, android.R.attr.centerX, 0.5f, 1.0f, 1.0f);
final float centerY = getAttrFloatOrFraction(context, attrs, android.R.attr.centerY, 0.5f, 1.0f, 1.0f);
gradientDrawable.setGradientCenter(centerX, centerY);
final boolean useLevel = getAttrBoolean(context, attrs, android.R.attr.useLevel, false);
gradientDrawable.setUseLevel(useLevel);
final int gradientType = getAttrInt(context, attrs, android.R.attr.type, 0);
gradientDrawable.setGradientType(gradientType);
final int startColor = getAttrColor(context, attrs, android.R.attr.startColor, Color.TRANSPARENT);
final int centerColor = getAttrColor(context, attrs, android.R.attr.centerColor, Color.TRANSPARENT);
final int endColor = getAttrColor(context, attrs, android.R.attr.endColor, Color.TRANSPARENT);
if (!getAttrHasValue(context, attrs, android.R.attr.centerColor)) {
gradientDrawable.setColors(new int[]{startColor, endColor});
} else {
gradientDrawable.setColors(new int[]{startColor, centerColor, endColor});
setStGradientPositions(gradientDrawable.getConstantState(), 0.0f, centerX != 0.5f ? centerX : centerY, 1f);
}
if (gradientType == GradientDrawable.LINEAR_GRADIENT) {
int angle = (int) getAttrFloat(context, attrs, android.R.attr.angle, 0.0f);
angle %= 360;
if (angle % 45 != 0) {
throw new XmlPullParserException("<gradient> tag requires"
+ "'angle' attribute to "
+ "be a multiple of 45");
}
setStGradientAngle(gradientDrawable.getConstantState(), angle);
switch (angle) {
case 0:
gradientDrawable.setOrientation(GradientDrawable.Orientation.LEFT_RIGHT);
break;
case 45:
gradientDrawable.setOrientation(GradientDrawable.Orientation.BL_TR);
break;
case 90:
gradientDrawable.setOrientation(GradientDrawable.Orientation.BOTTOM_TOP);
break;
case 135:
gradientDrawable.setOrientation(GradientDrawable.Orientation.BR_TL);
break;
case 180:
gradientDrawable.setOrientation(GradientDrawable.Orientation.RIGHT_LEFT);
break;
case 225:
gradientDrawable.setOrientation(GradientDrawable.Orientation.TR_BL);
break;
case 270:
gradientDrawable.setOrientation(GradientDrawable.Orientation.TOP_BOTTOM);
break;
case 315:
gradientDrawable.setOrientation(GradientDrawable.Orientation.TL_BR);
break;
}
} else {
setGradientRadius(context, attrs, gradientDrawable, gradientType);
}
} else if (name.equals("solid")) {
int color = getAttrColor(context, attrs, android.R.attr.color, Color.TRANSPARENT);
gradientDrawable.setColor(getAlphaColor(color, getAttrFloat(context, attrs, android.R.attr.alpha, 1.0f)));
} else if (name.equals("stroke")) {
final float alphaMod = getAttrFloat(context, attrs, android.R.attr.alpha, 1.0f);
final int strokeColor = getAttrColor(context, attrs, android.R.attr.color, Color.TRANSPARENT);
final int strokeWidth = getAttrDimensionPixelSize(context, attrs, android.R.attr.width);
final float dashWidth = getAttrDimension(context, attrs, android.R.attr.dashWidth);
if (dashWidth != 0.0f) {
final float dashGap = getAttrDimension(context, attrs, android.R.attr.dashGap);
gradientDrawable.setStroke(strokeWidth, getAlphaColor(strokeColor, alphaMod), dashWidth, dashGap);
} else {
gradientDrawable.setStroke(strokeWidth, getAlphaColor(strokeColor, alphaMod));
}
} else if (name.equals("corners")) {
final int radius = getAttrDimensionPixelSize(context, attrs, android.R.attr.radius);
gradientDrawable.setCornerRadius(radius);
final int topLeftRadius = getAttrDimensionPixelSize(context, attrs, android.R.attr.topLeftRadius, radius);
final int topRightRadius = getAttrDimensionPixelSize(context, attrs, android.R.attr.topRightRadius, radius);
final int bottomLeftRadius = getAttrDimensionPixelSize(context, attrs, android.R.attr.bottomLeftRadius, radius);
final int bottomRightRadius = getAttrDimensionPixelSize(context, attrs, android.R.attr.bottomRightRadius, radius);
if (topLeftRadius != radius || topRightRadius != radius ||
bottomLeftRadius != radius || bottomRightRadius != radius) {
// The corner radii are specified in clockwise order (see Path.addRoundRect())
gradientDrawable.setCornerRadii(new float[]{
topLeftRadius, topLeftRadius,
topRightRadius, topRightRadius,
bottomRightRadius, bottomRightRadius,
bottomLeftRadius, bottomLeftRadius
});
}
} else if (name.equals("padding")) {
final int paddingLeft = getAttrDimensionPixelOffset(context, attrs, android.R.attr.left);
final int paddingTop = getAttrDimensionPixelOffset(context, attrs, android.R.attr.top);
final int paddingRight = getAttrDimensionPixelOffset(context, attrs, android.R.attr.right);
final int paddingBottom = getAttrDimensionPixelOffset(context, attrs, android.R.attr.bottom);
if (paddingLeft != 0 || paddingTop != 0 || paddingRight != 0 || paddingBottom != 0) {
final Rect pad = new Rect();
pad.set(paddingLeft, paddingTop, paddingRight, paddingBottom);
try {
if (sPaddingField == null) {
sPaddingField = GradientDrawable.class.getDeclaredField("mPadding");
sPaddingField.setAccessible(true);
}
sPaddingField.set(gradientDrawable, pad);
if (sStPaddingField == null) {
sStPaddingField = Class.forName("android.graphics.drawable.GradientDrawable$GradientState").getDeclaredField("mPadding");
sStPaddingField.setAccessible(true);
}
sStPaddingField.set(gradientDrawable.getConstantState(), pad);
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
} else {
Log.w("drawable", "Bad element under <shape>: " + name);
}
}
return gradientDrawable;
}
void inflateGradientRootElement(Context context, AttributeSet attrs, GradientDrawable gradientDrawable) {
int shape = getAttrInt(context, attrs, android.R.attr.shape, GradientDrawable.RECTANGLE);
gradientDrawable.setShape(shape);
boolean dither = getAttrBoolean(context, attrs, android.R.attr.dither, false);
gradientDrawable.setDither(dither);
}
void setGradientRadius(Context context, AttributeSet attrs, GradientDrawable drawable, int gradientType) throws XmlPullParserException {
TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[]{android.R.attr.gradientRadius});
TypedValue value = a.peekValue(0);
if (value != null) {
boolean radiusRel = value.type == TypedValue.TYPE_FRACTION;
drawable.setGradientRadius(radiusRel ? value.getFraction(1.0f, 1.0f) : value.getFloat());
} else if (gradientType == GradientDrawable.RADIAL_GRADIENT) {
throw new XmlPullParserException(
"<gradient> tag requires 'gradientRadius' "
+ "attribute with radial type");
}
a.recycle();
}
void setStGradientAngle(Drawable.ConstantState constantState, int angle) {
try {
if (sStGradientAngle == null) {
sStGradientAngle = Class.forName("android.graphics.drawable.GradientDrawable$GradientState").getDeclaredField("mAngle");
sStGradientAngle.setAccessible(true);
}
sStGradientAngle.set(constantState, angle);
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
void setStGradientPositions(Drawable.ConstantState constantState, float... positions) {
try {
if (sStGradientPositions == null) {
sStGradientPositions = Class.forName("android.graphics.drawable.GradientDrawable$GradientState").getDeclaredField("mPositions");
sStGradientPositions.setAccessible(true);
}
sStGradientPositions.set(constantState, positions);
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
float getAttrFloatOrFraction(Context context, AttributeSet attrs, int attr, float defaultValue, float base, float pbase) {
TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[]{attr});
TypedValue tv = a.peekValue(0);
float v = defaultValue;
if (tv != null) {
boolean isFraction = tv.type == TypedValue.TYPE_FRACTION;
v = isFraction ? tv.getFraction(base, pbase) : tv.getFloat();
}
a.recycle();
return v;
}
int getAlphaColor(int baseColor, float alpha) {
return alpha != 1.0f
? ColorUtils.setAlphaComponent(baseColor, Math.round(Color.alpha(baseColor) * alpha))
: baseColor;
}
}
package com.bilibili.magicasakura.utils;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputConnectionWrapper;
/**
* just used for fix <pre>java.lang.IndexOutOfBoundsException</pre> while
* invoke {@link InputConnection#setSelection(int, int)}
*
* @author Yann Chou
* @email zhouyanbin1029@gmail.com
* @create 2016-08-29 11:37
*/
public class InputConnectionImpl extends InputConnectionWrapper {
public InputConnectionImpl(InputConnection target, boolean mutable) {
super(target, mutable);
}
@Override
public boolean setSelection(int start, int end) {
if (start < 0 || end < 0) {
// If the given selection is out of bounds, just ignore it.
// Most likely the text was changed out from under the IME,
// and the IME is going to have to update all of its state
// anyway.
return true;
}
return super.setSelection(start, end);
}
}
/*
* Copyright (C) 2016 Bilibili
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bilibili.magicasakura.utils;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.util.AttributeSet;
import com.wm.remusic.R;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
/**
* @author xyczero617@gmail.com
* @time 16/3/17
*/
public class LayerDrawableUtils extends DrawableUtils {
private static final int STEP = 1;
private static final int[] ATTRS = new int[]{
android.R.attr.left, android.R.attr.top, android.R.attr.right,
android.R.attr.bottom, android.R.attr.id};
@Override
protected Drawable inflateDrawable(Context context, XmlPullParser parser, AttributeSet attrs) throws IOException, XmlPullParserException {
final int innerDepth = parser.getDepth() + 1;
int type;
int depth;
int layerAttrUseCount = 0;
int drawableUseCount = 0;
int space = STEP << 1;
//L,T,R,B,S,E,id
int[][] childLayersAttrs = new int[space][ATTRS.length];
Drawable[] drawables = new Drawable[space];
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
&& ((depth = parser.getDepth()) >= innerDepth || type != XmlPullParser.END_TAG)) {
if (type != XmlPullParser.START_TAG) {
continue;
}
if (depth > innerDepth || !parser.getName().equals("item")) {
continue;
}
if (layerAttrUseCount >= childLayersAttrs.length) {
int[][] dstInt = new int[drawables.length + STEP][ATTRS.length];
System.arraycopy(childLayersAttrs, 0, dstInt, 0, childLayersAttrs.length);
childLayersAttrs = dstInt;
}
updateLayerAttrs(context, attrs, childLayersAttrs[layerAttrUseCount]);
layerAttrUseCount++;
Drawable drawable = getAttrDrawable(context, attrs, android.R.attr.drawable);
// If the layer doesn't have a drawable or unresolved theme
// attribute for a drawable, attempt to parse one from the child
// element.
if (drawable == null) {
while ((type = parser.next()) == XmlPullParser.TEXT) {
}
if (type != XmlPullParser.START_TAG) {
throw new XmlPullParserException(parser.getPositionDescription()
+ ": <item> tag requires a 'drawable' attribute or "
+ "child tag defining a drawable");
}
drawable = createFromXmlInner(context, parser, attrs);
} else {
final ColorStateList cls = getTintColorList(context, attrs, R.attr.drawableTint);
if (cls != null) {
drawable = ThemeUtils.tintDrawable(drawable, cls, getTintMode(context, attrs, R.attr.drawableTintMode));
}
}
if (drawable != null) {
if (drawableUseCount >= drawables.length) {
Drawable[] dst = new Drawable[drawables.length + STEP];
System.arraycopy(drawables, 0, dst, 0, drawables.length);
drawables = dst;
}
drawables[drawableUseCount] = drawable;
drawableUseCount++;
}
}
if (drawables[0] == null || drawableUseCount != layerAttrUseCount) {
return null;
} else {
LayerDrawable layerDrawable = new LayerDrawable(drawables);
for (int i = 0; i < drawables.length; i++) {
int[] childLayersAttr = childLayersAttrs[i];
if (childLayersAttr[0] != 0 || childLayersAttr[1] != 0 || childLayersAttr[2] != 0 || childLayersAttr[3] != 0) {
layerDrawable.setLayerInset(i, childLayersAttr[0], childLayersAttr[1], childLayersAttr[2], childLayersAttr[3]);
}
if (childLayersAttr[4] != 0) {
layerDrawable.setId(i, childLayersAttr[4]);
}
}
return layerDrawable;
}
}
void updateLayerAttrs(Context context, AttributeSet attrs, int[] childLayersAttrs) {
childLayersAttrs[0] = getAttrDimensionPixelOffset(context, attrs, ATTRS[0]);
childLayersAttrs[1] = getAttrDimensionPixelOffset(context, attrs, ATTRS[1]);
childLayersAttrs[2] = getAttrDimensionPixelOffset(context, attrs, ATTRS[2]);
childLayersAttrs[3] = getAttrDimensionPixelOffset(context, attrs, ATTRS[3]);
childLayersAttrs[4] = getAttrResourceId(context, attrs, ATTRS[4], 0);
}
}
/*
* Copyright (C) 2016 Bilibili
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bilibili.magicasakura.utils;
import android.content.Context;
import android.graphics.ColorFilter;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
import android.util.AttributeSet;
import android.util.SparseArray;
import com.bilibili.magicasakura.drawables.FilterableStateListDrawable;
import com.wm.remusic.R;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.ArrayList;
/**
* @author xyczero617@gmail.com
* @time 16/2/22
*/
public class StateListDrawableUtils extends DrawableUtils {
@Override
protected Drawable inflateDrawable(Context context, XmlPullParser parser, AttributeSet attrs) throws IOException, XmlPullParserException {
StateListDrawable sd = null;
ArrayList<int[]> states = new ArrayList<>();
ArrayList<Drawable> drawables = new ArrayList<>();
SparseArray<ColorFilter> mColorFilterMap = null;
final int innerDepth = parser.getDepth() + 1;
int type;
int depth;
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
&& ((depth = parser.getDepth()) >= innerDepth
|| type != XmlPullParser.END_TAG)) {
if (type != XmlPullParser.START_TAG) {
continue;
}
if (depth > innerDepth || !parser.getName().equals("item")) {
continue;
}
Drawable dr = getAttrDrawable(context, attrs, android.R.attr.drawable);
states.add(extractStateSet(attrs));
// Loading child elements modifies the state of the AttributeSet's
// underlying parser, so it needs to happen after obtaining
// attributes and extracting states.
if (dr == null) {
while ((type = parser.next()) == XmlPullParser.TEXT) {
}
if (type != XmlPullParser.START_TAG) {
throw new XmlPullParserException(
parser.getPositionDescription()
+ ": <item> tag requires a 'drawable' attribute or "
+ "child tag defining a drawable");
}
dr = createFromXmlInner(context, parser, attrs);
} else {
ColorFilter colorFilter = getAttrColorFilter(context, attrs, R.attr.drawableTint, R.attr.drawableTintMode);
if (colorFilter != null) {
if (mColorFilterMap == null) {
mColorFilterMap = new SparseArray<>();
}
mColorFilterMap.put(drawables.size(), colorFilter);
}
}
drawables.add(dr);
}
if (states.size() >= 1) {
if (mColorFilterMap != null) {
sd = new FilterableStateListDrawable();
for (int i = 0; i < states.size(); i++) {
((FilterableStateListDrawable) sd).addState(states.get(i), drawables.get(i), mColorFilterMap.get(i));
}
} else {
sd = new StateListDrawable();
for (int i = 0; i < states.size(); i++) {
sd.addState(states.get(i), drawables.get(i));
}
}
}
return sd;
}
}
/*
* Copyright (C) 2016 Bilibili
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bilibili.magicasakura.utils;
import android.content.res.ColorStateList;
import android.graphics.PorterDuff;
import java.util.LinkedList;
/**
* @author xyczero617@gmail.com
* @time 15/11/21
*/
public class TintInfo {
public ColorStateList mTintList;
public PorterDuff.Mode mTintMode;
public boolean mHasTintMode;
public boolean mHasTintList;
int[] mTintColors;
int[][] mTintStates;
public TintInfo() {
}
public TintInfo(LinkedList<int[]> stateList, LinkedList<Integer> colorList) {
if (colorList == null || stateList == null) return;
mTintColors = new int[colorList.size()];
for (int i = 0; i < colorList.size(); i++)
mTintColors[i] = colorList.get(i);
mTintStates = stateList.toArray(new int[stateList.size()][]);
}
public boolean isInvalid() {
return mTintColors == null || mTintStates == null || mTintColors.length != mTintStates.length;
}
}
/*
* Copyright (C) 2016 Bilibili
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bilibili.magicasakura.utils;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.util.LruCache;
import android.support.v7.view.ContextThemeWrapper;
import android.util.Log;
import android.util.SparseArray;
import android.view.View;
import com.bilibili.magicasakura.drawables.FilterableStateListDrawable;
import java.lang.ref.WeakReference;
import java.util.Map;
import java.util.WeakHashMap;
/**
* @author xyczero617@gmail.com
* @time 15/9/15
*/
public class TintManager {
private static final String TAG = "TintManager";
private static final boolean DEBUG = false;
private static final PorterDuff.Mode DEFAULT_MODE = PorterDuff.Mode.SRC_IN;
private static final String SKIP_DRAWABLE_TAG = "appcompat_skip_skip";
private static final WeakHashMap<Context, TintManager> INSTANCE_CACHE = new WeakHashMap<>();
private static final ColorFilterLruCache COLOR_FILTER_CACHE = new ColorFilterLruCache(6);
private final Object mDrawableCacheLock = new Object();
private WeakReference<Context> mContextRef;
private SparseArray<ColorStateList> mCacheTintList;
private SparseArray<WeakReference<Drawable.ConstantState>> mCacheDrawables;
private SparseArray<String> mSkipDrawableIdTags;
public static TintManager get(Context context) {
if (context == null) return null;
if (context instanceof ContextThemeWrapper) {
context = ((ContextThemeWrapper) context).getBaseContext();
}
if (context instanceof android.view.ContextThemeWrapper) {
context = ((android.view.ContextThemeWrapper) context).getBaseContext();
}
TintManager tm = INSTANCE_CACHE.get(context);
if (tm == null) {
tm = new TintManager(context);
INSTANCE_CACHE.put(context, tm);
printLog("[get TintManager] create new TintManager.");
}
return tm;
}
private TintManager(Context context) {
mContextRef = new WeakReference<>(context);
}
public static void clearTintCache() {
for (Map.Entry<Context, TintManager> entry : INSTANCE_CACHE.entrySet()) {
TintManager tm = entry.getValue();
if (tm != null)
tm.clear();
}
COLOR_FILTER_CACHE.evictAll();
}
private void clear() {
if (mCacheTintList != null) {
mCacheTintList.clear();
}
if (mCacheDrawables != null) {
mCacheDrawables.clear();
}
if (mSkipDrawableIdTags != null) {
mSkipDrawableIdTags.clear();
}
}
@Nullable
public ColorStateList getColorStateList(@ColorRes int resId) {
if (resId == 0) return null;
final Context context = mContextRef.get();
if (context == null) return null;
ColorStateList colorStateList = mCacheTintList != null ? mCacheTintList.get(resId) : null;
if (colorStateList == null) {
colorStateList = ColorStateListUtils.createColorStateList(context, resId);
if (colorStateList != null) {
if (mCacheTintList == null) {
mCacheTintList = new SparseArray<>();
}
mCacheTintList.append(resId, colorStateList);
}
}
return colorStateList;
}
@Nullable
public Drawable getDrawable(@DrawableRes int resId) {
final Context context = mContextRef.get();
if (context == null) return null;
if (resId == 0) return null;
if (mSkipDrawableIdTags != null) {
final String cachedTagName = mSkipDrawableIdTags.get(resId);
if (SKIP_DRAWABLE_TAG.equals(cachedTagName)) {
printLog("[Match Skip DrawableTag] Skip the drawable which is matched with the skip tag.");
return null;
}
} else {
// Create an id cache as we'll need one later
mSkipDrawableIdTags = new SparseArray<>();
}
// Try the cache first (if it exists)
Drawable drawable = getCacheDrawable(context, resId);
if (drawable == null) {
drawable = DrawableUtils.createDrawable(context, resId);
if (drawable != null && !(drawable instanceof ColorDrawable)) {
if (addCachedDrawable(resId, drawable)) {
printLog("[loadDrawable] Saved drawable to cache: " +
context.getResources().getResourceName(resId));
}
}
}
if (drawable == null) {
mSkipDrawableIdTags.append(resId, SKIP_DRAWABLE_TAG);
}
return drawable;
}
private Drawable getCacheDrawable(@NonNull final Context context, final int key) {
synchronized (mDrawableCacheLock) {
if (mCacheDrawables == null) return null;
final WeakReference<Drawable.ConstantState> weakReference = mCacheDrawables.get(key);
if (weakReference != null) {
Drawable.ConstantState cs = weakReference.get();
if (cs != null) {
printLog("[getCacheDrawable] Get drawable from cache: " +
context.getResources().getResourceName(key));
return cs.newDrawable();
} else {
mCacheDrawables.delete(key);
}
}
}
return null;
}
private boolean addCachedDrawable(final int key, @NonNull final Drawable drawable) {
if (drawable instanceof FilterableStateListDrawable) {
return false;
}
final Drawable.ConstantState cs = drawable.getConstantState();
if (cs != null) {
synchronized (mDrawableCacheLock) {
if (mCacheDrawables == null) {
mCacheDrawables = new SparseArray<>();
}
mCacheDrawables.put(key, new WeakReference<>(cs));
}
return true;
}
return false;
}
private static class ColorFilterLruCache extends LruCache<Integer, PorterDuffColorFilter> {
public ColorFilterLruCache(int maxSize) {
super(maxSize);
}
PorterDuffColorFilter get(int color, PorterDuff.Mode mode) {
return get(generateCacheKey(color, mode));
}
PorterDuffColorFilter put(int color, PorterDuff.Mode mode, PorterDuffColorFilter filter) {
return put(generateCacheKey(color, mode), filter);
}
private static int generateCacheKey(int color, PorterDuff.Mode mode) {
int hashCode = 1;
hashCode = 31 * hashCode + color;
hashCode = 31 * hashCode + mode.hashCode();
return hashCode;
}
}
public static void tintViewBackground(View view, TintInfo tint) {
Drawable background;
if (view == null || (background = view.getBackground()) == null) return;
if (tint.mHasTintList || tint.mHasTintMode) {
background.mutate();
if (background instanceof ColorDrawable) {
((ColorDrawable) background).setColor(ThemeUtils.replaceColor(view.getContext(), tint.mTintList.getColorForState(view.getDrawableState(), tint.mTintList.getDefaultColor())));
} else {
background.setColorFilter(createTintFilter(view.getContext(),
tint.mHasTintList ? tint.mTintList : null,
tint.mHasTintMode ? tint.mTintMode : DEFAULT_MODE,
view.getDrawableState()));
}
} else {
background.clearColorFilter();
}
if (Build.VERSION.SDK_INT <= 23) {
// On Gingerbread, GradientDrawable does not invalidate itself when it's ColorFilter
// has changed, so we need to force an invalidation
background.invalidateSelf();
}
}
public static void tintViewDrawable(View view, Drawable drawable, TintInfo tint) {
if (view == null || drawable == null) return;
if (tint.mHasTintList || tint.mHasTintMode) {
drawable.mutate();
if (drawable instanceof ColorDrawable) {
((ColorDrawable) drawable).setColor(ThemeUtils.replaceColor(view.getContext(), tint.mTintList.getColorForState(view.getDrawableState(), tint.mTintList.getDefaultColor())));
} else {
drawable.setColorFilter(createTintFilter(view.getContext(),
tint.mHasTintList ? tint.mTintList : null,
tint.mHasTintMode ? tint.mTintMode : DEFAULT_MODE,
view.getDrawableState()));
}
} else {
drawable.clearColorFilter();
}
if (Build.VERSION.SDK_INT <= 23) {
// On Gingerbread, GradientDrawable does not invalidate itself when it's ColorFilter
// has changed, so we need to force an invalidation
drawable.invalidateSelf();
}
}
private static PorterDuffColorFilter createTintFilter(Context context, ColorStateList tint, PorterDuff.Mode tintMode, final int[] state) {
if (tint == null || tintMode == null) {
return null;
}
final int color = ThemeUtils.replaceColor(context, tint.getColorForState(state, tint.getDefaultColor()));
return getPorterDuffColorFilter(color, tintMode);
}
private static PorterDuffColorFilter getPorterDuffColorFilter(int color, PorterDuff.Mode mode) {
// First, lets see if the cache already contains the color filter
PorterDuffColorFilter filter = COLOR_FILTER_CACHE.get(color, mode);
if (filter == null) {
// Cache miss, so create a color filter and add it to the cache
filter = new PorterDuffColorFilter(color, mode);
COLOR_FILTER_CACHE.put(color, mode, filter);
}
return filter;
}
private static void printLog(String msg) {
if (DEBUG) {
Log.i(TAG, msg);
}
}
}
/*
* Copyright (C) 2016 Bilibili
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bilibili.magicasakura.widgets;
import android.content.res.TypedArray;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.v4.content.ContextCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.util.AttributeSet;
import android.view.View;
import com.bilibili.magicasakura.utils.DrawableUtils;
import com.bilibili.magicasakura.utils.ThemeUtils;
import com.bilibili.magicasakura.utils.TintInfo;
import com.bilibili.magicasakura.utils.TintManager;
import com.wm.remusic.R;
/**
* @author xyczero617@gmail.com
* @time 15/9/26
*/
public class AppCompatBackgroundHelper extends AppCompatBaseHelper {
private static final int[] ATTR = {
android.R.attr.background,
R.attr.backgroundTint,
R.attr.backgroundTintMode
};
private TintInfo mBackgroundTintInfo;
private int mBackgroundResId;
private int mBackgroundTintResId;
private int mPaddingLeft, mPaddingTop, mPaddingRight, mPaddingBottom;
public AppCompatBackgroundHelper(View view, TintManager tintManager) {
super(view, tintManager);
}
@SuppressWarnings("ResourceType")
@Override
void loadFromAttribute(AttributeSet attrs, int defStyleAttr) {
initPadding();
TypedArray array = mView.getContext().obtainStyledAttributes(attrs, ATTR, defStyleAttr, 0);
if (array.hasValue(1)) {
mBackgroundTintResId = array.getResourceId(1, 0);
if (array.hasValue(2)) {
setSupportBackgroundTintMode(DrawableUtils.parseTintMode(array.getInt(2, 0), null));
}
setSupportBackgroundTint(mBackgroundTintResId);
} else {
Drawable drawable = mTintManager.getDrawable(mBackgroundResId = array.getResourceId(0, 0));
if (drawable != null) {
setBackgroundDrawable(drawable);
}
}
array.recycle();
}
/**
* External use
*
* @param background
*/
public void setBackgroundDrawableExternal(Drawable background) {
if (skipNextApply()) return;
resetTintResource(0);
setSkipNextApply(false);
recoverPadding(background);
}
public void setBackgroundColor(int color) {
if (skipNextApply()) return;
resetTintResource(0);
mView.setBackgroundColor(ThemeUtils.getColor(mView.getContext(), color));
}
public void setBackgroundResId(int resId) {
if (mBackgroundResId != resId) {
resetTintResource(resId);
if (resId != 0) {
Drawable drawable = mTintManager.getDrawable(resId);
setBackgroundDrawable(
drawable != null ? drawable : ContextCompat.getDrawable(mView.getContext(), resId));
}
}
}
public void setBackgroundTintList(int resId, PorterDuff.Mode mode) {
if (mBackgroundTintResId != resId) {
mBackgroundTintResId = resId;
if (mBackgroundTintInfo != null) {
mBackgroundTintInfo.mHasTintList = false;
mBackgroundTintInfo.mTintList = null;
}
setSupportBackgroundTintMode(mode);
setSupportBackgroundTint(resId);
}
}
/**
* Internal use
*/
private void setBackgroundDrawable(Drawable drawable) {
if (skipNextApply()) return;
setBackground(drawable);
recoverPadding(drawable);
}
private boolean setSupportBackgroundTint(int resId) {
if (resId != 0) {
if (mBackgroundTintInfo == null) {
mBackgroundTintInfo = new TintInfo();
}
mBackgroundTintInfo.mHasTintList = true;
mBackgroundTintInfo.mTintList = mTintManager.getColorStateList(resId);
}
return applySupportBackgroundTint();
}
private void setSupportBackgroundTintMode(PorterDuff.Mode mode) {
if (mBackgroundTintResId != 0 && mode != null) {
if (mBackgroundTintInfo == null) {
mBackgroundTintInfo = new TintInfo();
}
mBackgroundTintInfo.mHasTintMode = true;
mBackgroundTintInfo.mTintMode = mode;
}
}
private boolean applySupportBackgroundTint() {
Drawable backgroundDrawable = mView.getBackground();
if (backgroundDrawable != null && mBackgroundTintInfo != null && mBackgroundTintInfo.mHasTintList) {
backgroundDrawable = DrawableCompat.wrap(backgroundDrawable);
backgroundDrawable = backgroundDrawable.mutate();
if (mBackgroundTintInfo.mHasTintList) {
DrawableCompat.setTintList(backgroundDrawable, mBackgroundTintInfo.mTintList);
}
if (mBackgroundTintInfo.mHasTintMode) {
DrawableCompat.setTintMode(backgroundDrawable, mBackgroundTintInfo.mTintMode);
}
if (backgroundDrawable.isStateful()) {
backgroundDrawable.setState(mView.getDrawableState());
}
setBackgroundDrawable(backgroundDrawable);
return true;
}
return false;
}
private void setBackground(Drawable backgroundDrawable) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
mView.setBackgroundDrawable(backgroundDrawable);
} else {
mView.setBackground(backgroundDrawable);
}
}
private void resetTintResource(int resId/*background resource id*/) {
mBackgroundResId = resId;
mBackgroundTintResId = 0;
if (mBackgroundTintInfo != null) {
mBackgroundTintInfo.mHasTintList = false;
mBackgroundTintInfo.mTintList = null;
mBackgroundTintInfo.mHasTintMode = false;
mBackgroundTintInfo.mTintMode = null;
}
}
private void initPadding() {
mPaddingLeft = mView.getPaddingLeft();
mPaddingTop = mView.getPaddingTop();
mPaddingRight = mView.getPaddingRight();
mPaddingBottom = mView.getPaddingBottom();
}
private boolean hasPadding() {
return mPaddingLeft != 0 || mPaddingRight != 0 || mPaddingTop != 0 || mPaddingBottom != 0;
}
private void recoverPadding(Drawable background) {
if (ThemeUtils.containsNinePatch(background) && hasPadding()) {
mView.setPadding(mPaddingLeft, mPaddingTop, mPaddingRight, mPaddingBottom);
}
}
@Override
public void tint() {
if (mBackgroundTintResId == 0 || !setSupportBackgroundTint(mBackgroundTintResId)) {
Drawable drawable = mTintManager.getDrawable(mBackgroundResId);
if (drawable == null) {
drawable = mBackgroundResId == 0 ? null : ContextCompat.getDrawable(mView.getContext(), mBackgroundResId);
}
setBackgroundDrawable(drawable);
}
}
public interface BackgroundExtensible {
void setBackgroundTintList(int resId);
void setBackgroundTintList(int resId, PorterDuff.Mode mode);
}
}
/*
* Copyright (C) 2016 Bilibili
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bilibili.magicasakura.widgets;
import android.util.AttributeSet;
import android.view.View;
import com.bilibili.magicasakura.utils.TintManager;
/**
* @author xyczero617@gmail.com
* @time 15/10/1
*/
public abstract class AppCompatBaseHelper {
protected View mView;
protected TintManager mTintManager;
private boolean mSkipNextApply;
public AppCompatBaseHelper(View view, TintManager tintManager) {
mView = view;
mTintManager = tintManager;
}
protected boolean skipNextApply() {
if (mSkipNextApply) {
mSkipNextApply = false;
return true;
}
mSkipNextApply = true;
return false;
}
protected void setSkipNextApply(boolean flag) {
mSkipNextApply = flag;
}
abstract void loadFromAttribute(AttributeSet attrs, int defStyleAttr);
public abstract void tint();
}
/*
* Copyright (C) 2016 Bilibili
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bilibili.magicasakura.widgets;
import android.content.res.TypedArray;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.v4.content.ContextCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v4.widget.CompoundButtonCompat;
import android.util.AttributeSet;
import android.widget.CompoundButton;
import com.bilibili.magicasakura.utils.DrawableUtils;
import com.bilibili.magicasakura.utils.TintInfo;
import com.bilibili.magicasakura.utils.TintManager;
import com.wm.remusic.R;
/**
* @author xyczero617@gmail.com
* @time 15/11/23
*/
public class AppCompatCompoundButtonHelper extends AppCompatBaseHelper {
private static final int[] ATTRS = {
android.R.attr.button,
R.attr.compoundButtonTint,
R.attr.compoundButtonTintMode
};
private TintInfo mCompoundButtonTintInfo;
private int mCompoundButtonResId;
private int mCompoundButtonTintResId;
public AppCompatCompoundButtonHelper(CompoundButton view, TintManager tintManager) {
super(view, tintManager);
}
@SuppressWarnings("ResourceType")
@Override
void loadFromAttribute(AttributeSet attrs, int defStyleAttr) {
TypedArray array = mView.getContext().obtainStyledAttributes(attrs, ATTRS, defStyleAttr, 0);
if (array.hasValue(1)) {
mCompoundButtonTintResId = array.getResourceId(1, 0);
if (array.hasValue(2)) {
setSupportButtonDrawableTintMode(DrawableUtils.parseTintMode(array.getInt(2, 0), null));
}
setSupportButtonDrawableTint(mCompoundButtonTintResId);
} else {
Drawable drawable = mTintManager.getDrawable(mCompoundButtonResId = array.getResourceId(0, 0));
if (drawable != null) {
setButtonDrawable(drawable);
}
}
array.recycle();
}
/**
* External use
*/
public void setButtonDrawable() {
if (skipNextApply()) return;
resetTintResource(0);
setSkipNextApply(false);
}
public void setButtonDrawable(int resId) {
if (mCompoundButtonTintResId != resId) {
resetTintResource(resId);
if (resId != 0) {
Drawable drawable = mTintManager.getDrawable(resId);
setButtonDrawable(
drawable != null ? drawable : ContextCompat.getDrawable(mView.getContext(), resId));
}
}
}
public void setButtonDrawableTintList(int resId, PorterDuff.Mode mode) {
if (mCompoundButtonTintResId != resId) {
mCompoundButtonTintResId = resId;
if (mCompoundButtonTintInfo != null) {
mCompoundButtonTintInfo.mHasTintList = false;
mCompoundButtonTintInfo.mTintList = null;
mCompoundButtonTintInfo.mHasTintMode = false;
mCompoundButtonTintInfo.mTintMode = null;
}
setSupportButtonDrawableTintMode(mode);
setSupportButtonDrawableTint(resId);
}
}
/**
* Internal use
*/
private void setButtonDrawable(Drawable drawable) {
if (skipNextApply()) return;
((CompoundButton) mView).setButtonDrawable(drawable);
}
public boolean setSupportButtonDrawableTint(int resId) {
if (resId != 0) {
if (mCompoundButtonTintInfo == null) {
mCompoundButtonTintInfo = new TintInfo();
}
mCompoundButtonTintInfo.mHasTintList = true;
mCompoundButtonTintInfo.mTintList = mTintManager.getColorStateList(resId);
}
return applySupportButtonDrawableTint();
}
private void setSupportButtonDrawableTintMode(PorterDuff.Mode mode) {
if (mCompoundButtonTintResId != 0 && mode != null) {
if (mCompoundButtonTintInfo == null) {
mCompoundButtonTintInfo = new TintInfo();
}
mCompoundButtonTintInfo.mHasTintMode = true;
mCompoundButtonTintInfo.mTintMode = mode;
}
}
public boolean applySupportButtonDrawableTint() {
Drawable buttonDrawable = CompoundButtonCompat.getButtonDrawable((CompoundButton) mView);
if (buttonDrawable != null && mCompoundButtonTintInfo != null && mCompoundButtonTintInfo.mHasTintList) {
buttonDrawable = DrawableCompat.wrap(buttonDrawable);
buttonDrawable = buttonDrawable.mutate();
if (mCompoundButtonTintInfo.mHasTintList) {
DrawableCompat.setTintList(buttonDrawable, mCompoundButtonTintInfo.mTintList);
}
if (mCompoundButtonTintInfo.mHasTintMode) {
DrawableCompat.setTintMode(buttonDrawable, mCompoundButtonTintInfo.mTintMode);
}
// The drawable (or one of its children) may not have been
// stateful before applying the tint, so let's try again.
if (buttonDrawable.isStateful()) {
buttonDrawable.setState(mView.getDrawableState());
}
setButtonDrawable(buttonDrawable);
return true;
}
return false;
}
private void resetTintResource(int resId/*background resource id*/) {
mCompoundButtonResId = resId;
mCompoundButtonTintResId = 0;
if (mCompoundButtonTintInfo != null) {
mCompoundButtonTintInfo.mHasTintList = false;
mCompoundButtonTintInfo.mTintList = null;
}
}
public int getCompoundPaddingLeft(int superValue) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
// Before JB-MR1 the button drawable wasn't taken into account for padding. We'll
// workaround that here
Drawable buttonDrawable = CompoundButtonCompat.getButtonDrawable((CompoundButton) mView);
if (buttonDrawable != null) {
superValue += buttonDrawable.getIntrinsicWidth();
}
}
return superValue;
}
@Override
public void tint() {
if (mCompoundButtonTintResId == 0 || !setSupportButtonDrawableTint(mCompoundButtonTintResId)) {
Drawable drawable = mTintManager.getDrawable(mCompoundButtonResId);
if (drawable == null) {
drawable = mCompoundButtonResId == 0 ? null : ContextCompat.getDrawable(mView.getContext(), mCompoundButtonResId);
}
setButtonDrawable(drawable);
}
}
public interface CompoundButtonExtensible {
void setCompoundButtonTintList(int resId);
void setCompoundButtonTintList(int resId, PorterDuff.Mode mode);
}
}
/*
* Copyright (C) 2016 Bilibili
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bilibili.magicasakura.widgets;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import com.bilibili.magicasakura.utils.ThemeUtils;
import com.wm.remusic.R;
/**
* @author xyczero617@gmail.com
* @time 2015/9/1
*/
public class TintAppAlertDialogDividingView extends View {
public static final int[] TINT_ATTRS = {
android.R.attr.background
};
public TintAppAlertDialogDividingView(Context context) {
this(context, null);
}
public TintAppAlertDialogDividingView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public TintAppAlertDialogDividingView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
TypedArray a = context.obtainStyledAttributes(attrs, TINT_ATTRS);
if (a.hasValue(0)) {
if (a.getResourceId(0, 0) == android.R.color.holo_blue_light) {
setBackgroundColor(ThemeUtils.getThemeAttrColor(context, R.attr.themeColorSecondary));
}
}
}
}
/*
* Copyright (C) 2016 Bilibili
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bilibili.magicasakura.widgets;
import android.content.Context;
import android.content.res.ColorStateList;
import android.util.AttributeSet;
import android.widget.ProgressBar;
import com.bilibili.magicasakura.utils.TintManager;
/**
* @author xyczero617@gmail.com
* @time 16/2/4
*/
public class TintProgressBar extends ProgressBar implements Tintable {
private AppCompatProgressBarHelper mProgressBarHelper;
public TintProgressBar(Context context) {
this(context, null);
}
public TintProgressBar(Context context, AttributeSet attrs) {
this(context, attrs, android.R.attr.progressBarStyle);
}
public TintProgressBar(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
if (isInEditMode()) {
return;
}
TintManager tintManage = TintManager.get(context);
mProgressBarHelper = new AppCompatProgressBarHelper(this, tintManage);
mProgressBarHelper.loadFromAttribute(attrs, defStyleAttr);
}
public void setProgressTintList(ColorStateList tint) {
if (mProgressBarHelper != null) {
mProgressBarHelper.setSupportProgressTint(tint);
}
}
@Override
public void tint() {
if (mProgressBarHelper != null) {
mProgressBarHelper.tint();
}
}
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册