Skip to content

Commit

Permalink
Fixed some issues
Browse files Browse the repository at this point in the history
  • Loading branch information
KaustubhPatange committed Feb 14, 2020
1 parent 04da68e commit 3c68d04
Show file tree
Hide file tree
Showing 18 changed files with 325 additions and 255 deletions.
Binary file modified .gradle/4.6/fileContent/fileContent.lock
Binary file not shown.
4 changes: 2 additions & 2 deletions .gradle/4.6/fileHashes/fileHashes.bin
Git LFS file not shown
Binary file modified .gradle/4.6/fileHashes/fileHashes.lock
Binary file not shown.
4 changes: 2 additions & 2 deletions .gradle/4.6/javaCompile/classAnalysis.bin
Git LFS file not shown
Binary file modified .gradle/4.6/javaCompile/javaCompile.lock
Binary file not shown.
2 changes: 1 addition & 1 deletion .gradle/4.6/javaCompile/taskHistory.bin
Git LFS file not shown
2 changes: 1 addition & 1 deletion .gradle/4.6/taskHistory/taskHistory.bin
Git LFS file not shown
Binary file modified .gradle/4.6/taskHistory/taskHistory.lock
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
430 changes: 229 additions & 201 deletions .idea/workspace.xml

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions app/src/main/java/com/kpstv/youtube/PlayerActivity2.java
Original file line number Diff line number Diff line change
Expand Up @@ -315,12 +315,14 @@ public void onStopTrackingTouch(IndicatorSeekBar seekBar) {

loadAgain();

Palette.generateAsync(MusicService.bitmapIcon, palette -> {
MusicService.nColor = palette.getVibrantColor(activity.getResources().getColor(R.color.light_white));
Log.e(TAG, "onCreate: Changing nColor: "+MusicService.nColor );
backImage.setColorFilter(MusicService.nColor);
backImage1.setColorFilter(MusicService.nColor);
});
if (MusicService.bitmapIcon!=null) {
Palette.generateAsync(MusicService.bitmapIcon, palette -> {
MusicService.nColor = palette.getVibrantColor(activity.getResources().getColor(R.color.light_white));
Log.e(TAG, "onCreate: Changing nColor: " + MusicService.nColor);
backImage.setColorFilter(MusicService.nColor);
backImage1.setColorFilter(MusicService.nColor);
});
}

addToPlaylist.setOnTouchListener((v, motionEvent) -> {
switch (motionEvent.getAction()) {
Expand Down
40 changes: 23 additions & 17 deletions app/src/main/java/com/kpstv/youtube/adapters/PlayerAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import android.support.v4.view.PagerAdapter;
import android.support.v7.graphics.Palette;
import android.support.v7.widget.CardView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -40,6 +41,7 @@ public class PlayerAdapter extends PagerAdapter {
Context context;
ArrayList<String> yturls;
LayoutInflater mLayoutInflater;
private static final String TAG = "PlayerAdapter";

public PlayerAdapter(Context context, ArrayList<String> yturls) {
this.context = context;
Expand Down Expand Up @@ -71,24 +73,25 @@ public Object instantiateItem(ViewGroup container, int position) {
ImageView imageView1 = itemView.findViewById(R.id.mainImage1);

if (MusicService.localPlayBack) {
File f = new File(MusicService.yturls.get(position));
try {
MediaMetadataRetriever mmr = new MediaMetadataRetriever();
mmr.setDataSource(context, Uri.fromFile(f));

byte [] data = mmr.getEmbeddedPicture();
if (MusicService.yturls.get(position)!=null) {
File f = new File(MusicService.yturls.get(position));
try {
MediaMetadataRetriever mmr = new MediaMetadataRetriever();
mmr.setDataSource(context, Uri.fromFile(f));

byte[] data = mmr.getEmbeddedPicture();

if (data != null) {
imageView1.setVisibility(View.GONE);
Bitmap bitmapIcon = BitmapFactory.decodeByteArray(data, 0, data.length);
imageView.setImageBitmap(bitmapIcon);
} else {
imageView1.setVisibility(View.VISIBLE);
}

if(data != null) {
imageView1.setVisibility(View.GONE);
Bitmap bitmapIcon = BitmapFactory.decodeByteArray(data, 0, data.length);
imageView.setImageBitmap(bitmapIcon);
}
else {
imageView1.setVisibility(View.VISIBLE);
} catch (Exception e) {
// TODO: Do something when cannot played...
}

}catch (Exception e) {
// TODO: Do something when cannot played...
}
}else {
if (yturls.get(position).contains("soundcloud.com")) {
Expand Down Expand Up @@ -128,9 +131,12 @@ protected Void doInBackground(Void... voids) {
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}else {
imageView1.setVisibility(View.GONE);
String imageUrl = YTutils.getImageUrl(yturls.get(position));
Log.e(TAG, "Imageurl: "+imageUrl);

Glide.with(context)
.asBitmap()
.load(YTutils.getImageUrl(yturls.get(position)))
.load(imageUrl)
.into(new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
Expand Down
51 changes: 31 additions & 20 deletions app/src/main/java/com/kpstv/youtube/fragments/PlaylistFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,13 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
activity.startActivity(intent);
});

nestedScrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
@Override
public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
nestedScrollView.setOnScrollChangeListener((NestedScrollView.OnScrollChangeListener) (v, scrollX, scrollY, oldScrollX, oldScrollY) -> {

if (scrollY > oldScrollY) {
fabCreate.hide();
}
if (scrollY < oldScrollY) {
fabCreate.show();
}
if (scrollY > oldScrollY) {
fabCreate.hide();
}
if (scrollY < oldScrollY) {
fabCreate.show();
}
});

Expand Down Expand Up @@ -169,17 +166,17 @@ void setAdapterClicks() {
break;
case R.id.action_delete:
if (playlist_csv!=null&&!playlist_csv.isEmpty()) {
ArrayList<String> lines = new ArrayList<>(Arrays.asList(playlist_csv.split("\r|\n")));
for(int i=0;i<lines.size();i++) {
if (lines.get(i).contains(","+model.getTitle())) {
data.remove(data.size()-1-i);
lines.remove(i);
YTutils.writeContent(activity,"playlist.csv",
YTutils.convertListToStringMethod(lines));
adapter.notifyDataSetChanged();
break;
}
}
if (model.getTimeseconds()>0) {
new AlertDialog.Builder(getContext())
.setTitle("Delete")
.setMessage("Are you sure? This cannot be undone.")
.setNegativeButton("Cancel",null)
.setPositiveButton("Yes",(dialogInterface, i) -> {
deleteFunc(playlist_csv,model);
})
.show();
}else
deleteFunc(playlist_csv,model);
}
break;
}
Expand All @@ -188,6 +185,20 @@ void setAdapterClicks() {
});
}

private void deleteFunc(String playlist_csv, PlaylistModel model) {
ArrayList<String> lines = new ArrayList<>(Arrays.asList(playlist_csv.split("\r|\n")));
for(int i=0;i<lines.size();i++) {
if (lines.get(i).contains(","+model.getTitle())) {
data.remove(data.size()-1-i);
lines.remove(i);
YTutils.writeContent(activity,"playlist.csv",
YTutils.convertListToStringMethod(lines));
adapter.notifyDataSetChanged();
break;
}
}
}

class getData extends AsyncTask<Void,Void,Void> {

@SuppressLint("StaticFieldLeak")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,8 +477,19 @@ private void mp3Task() {
if (currentModel.getVideoID().contains("soundcloud.com"))
imageUri = currentModel.getImageUrl();
else imageUri = YTutils.getImageUrlID_MAX(currentModel.getVideoID());
setProgress(0, true);
icon = YTutils.getBitmapFromURL(imageUri);
if (icon==null && !currentModel.getVideoID().contains("soundcloud.com")) {
String refreshedUri = YTutils.getImageUrlID_MQ(YTutils.getVideoID_ImageUri(imageUri));
Log.e(TAG, "mp3Task: Error Image, Refreshing... "+refreshedUri );
icon = YTutils.getBitmapFromURL(refreshedUri);
if (icon!=null) {
imageUri = refreshedUri;
}
}
setProgress(0, false);

Glide.with(context).asBitmap().load(imageUri).into(new CustomTarget<Bitmap>() {
/*Glide.with(context).asBitmap().load(imageUri).into(new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
icon = resource;
Expand All @@ -489,7 +500,7 @@ public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? sup
public void onLoadCleared(@Nullable Drawable placeholder) {
}
});
});*/

/** Set Prefix for path... */
String prefixName = (currentModel.getTitle().trim() + "_" + currentModel.getChannelTitle().trim())
Expand Down
16 changes: 13 additions & 3 deletions app/src/main/java/com/kpstv/youtube/services/MusicService.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public void onDestroy() {
notificationManager.deleteNotificationChannel("channel_01");
notificationManager.deleteNotificationChannel("channel_02");
}

isEqualizerSet = false;
if (PlayerActivity2.activity!=null) {
PlayerActivity2.activity.finish();
}
Expand Down Expand Up @@ -706,9 +706,19 @@ protected Void doInBackground(String... arg0) {
ytConfigs = dataModel.getConfigs();
}
}
if (imgUrl!=null) {
if (MusicService.imgUrl!=null) {
Log.e(TAG, "doInBackground: Downloading Image..." );
bitmapIcon = YTutils.getBitmapFromURL(imgUrl);
try {
bitmapIcon = YTutils.getBitmapFromURL(MusicService.imgUrl);
}catch (Exception ignored){
}
if (bitmapIcon==null) {
Log.e(TAG, "doInBackground: Error: occurred, Refreshing" );
String modifiedImageUrl = YTutils.getImageUrlID_MQ(YTutils.getVideoID_ImageUri(MusicService.imgUrl));
bitmapIcon = YTutils.getBitmapFromURL(modifiedImageUrl);
if (bitmapIcon != null) MusicService.imgUrl = modifiedImageUrl;
Log.e(TAG, "doInBackground: New Image Url: "+MusicService.imgUrl);
}
}
return null;
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_paypal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
android:background="@android:color/darker_gray"
android:textColor="@android:color/black"
android:gravity="center"
android:onClick="demoClick"
android:text="Do not press back until the payment is completed"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/menu/playlist_context.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
android:title="Modify"
app:showAsAction="never"
/>

<item android:id="@+id/action_delete"
android:title="Delete"
app:showAsAction="never"
Expand Down

0 comments on commit 3c68d04

Please sign in to comment.