Kate Mobile v109.1版本的 MD5 值为:fcd76ded5f363ecbfac46035a4ed2a23
以下内容为反编译后的 AudioClickHelper.java 源代码,内容仅作参考
package com.perm.kate;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.text.TextUtils;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import com.perm.kate.api.Audio;
import com.perm.kate.photoupload.PhotoChooser;
import com.perm.kate.session.Callback;
import com.perm.kate.session.Session;
import com.perm.utils.AdEvents;
import com.perm.utils.LeakDetector;
import com.perm.utils.Mp3InfoHelper;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
public abstract class AudioClickHelper {
AudioClickHelperCallback audioCallback;
final Callback callback_add;
final Callback callback_delete;
BaseActivity context;
public String tag;
public class AnonymousClass13 extends Thread {
final Audio val$audio_original;
final ArrayList val$audios_original;
final AudioClickHelperCallback2 val$callback2;
AnonymousClass13(Audio audio, AudioClickHelperCallback2 audioClickHelperCallback2, ArrayList arrayList) {
this.val$audio_original = audio;
this.val$callback2 = audioClickHelperCallback2;
this.val$audios_original = arrayList;
}
@Override
public void run() {
Callback callback = new Callback(AudioClickHelper.this.context) {
@Override
public void ready(Object obj) {
BaseActivity baseActivity;
final ArrayList arrayList = (ArrayList) obj;
if (arrayList == null || arrayList.size() == 0) {
return;
}
KApplication.db.createOrUpdateAudios(arrayList);
HashMap makeMap = AudioClickHelper.this.makeMap(arrayList);
final Audio audio = (Audio) makeMap.get(AnonymousClass13.this.val$audio_original.owner_id + "_" + AnonymousClass13.this.val$audio_original.aid);
if (audio == null || (baseActivity = AudioClickHelper.this.context) == null || baseActivity.isFinishing()) {
return;
}
AudioClickHelper.this.context.runOnUiThread(new Runnable() {
@Override
public void run() {
AnonymousClass13.this.val$callback2.audiosDownloaded(audio, arrayList);
}
});
}
};
String makeAudiosString = AudioClickHelper.this.makeAudiosString(this.val$audios_original);
BaseActivity baseActivity = AudioClickHelper.this.context;
if (baseActivity == null || baseActivity.isFinishing()) {
return;
}
AudioClickHelper.this.context.showProgressBar(true);
KApplication.session.getAudioById(makeAudiosString, callback, AudioClickHelper.this.context);
BaseActivity baseActivity2 = AudioClickHelper.this.context;
if (baseActivity2 != null) {
baseActivity2.showProgressBar(false);
}
}
}
public static class AudioClickHelperCallback {
public void audioSelectForDelete(long j) {
}
public abstract void audioSelectForMove(long j, boolean z, long j2);
}
public AudioClickHelper(BaseActivity baseActivity, AudioClickHelperCallback audioClickHelperCallback) {
this.tag = "null";
this.callback_add = new Callback(this.context) {
@Override
public void error(Throwable th) {
super.error(th);
BaseActivity baseActivity2 = AudioClickHelper.this.context;
if (baseActivity2 != null) {
baseActivity2.showProgressBar(false);
}
}
@Override
public void ready(Object obj) {
BaseActivity baseActivity2 = AudioClickHelper.this.context;
if (baseActivity2 != null) {
baseActivity2.runOnUiThread(new Runnable() {
@Override
public void run() {
BaseActivity baseActivity3 = AudioClickHelper.this.context;
if (baseActivity3 != null) {
baseActivity3.showProgressBar(false);
}
Toast.makeText(KApplication.current, (int) R.string.done, 0).show();
}
});
}
}
};
this.callback_delete = new Callback(this.context) {
@Override
public void ready(Object obj) {
BaseActivity baseActivity2 = AudioClickHelper.this.context;
if (baseActivity2 != null) {
baseActivity2.displayToast(R.string.done);
}
}
};
LeakDetector.getInstance().monitorObject(this);
this.context = baseActivity;
if (baseActivity != null) {
this.tag = baseActivity.getClass().getSimpleName();
}
this.audioCallback = audioClickHelperCallback;
if (audioClickHelperCallback == null) {
this.audioCallback = new AudioClickHelperCallback() {
@Override
public void audioSelectForMove(long j, boolean z, long j2) {
AudioClickHelper audioClickHelper = AudioClickHelper.this;
audioClickHelper.showAlbumActivityForMove(new ArrayList(Arrays.asList(j2 + "_" + j)), Long.parseLong(KApplication.session.getMid()));
}
};
}
}
public static void PlayAudio(Audio audio, Context context, ArrayList arrayList, boolean z, int i) {
if (restricted(audio)) {
restrictedToast();
return;
}
try {
if (TextUtils.isEmpty(audio.url)) {
return;
}
PlaybackService.trackAudioPlay(null);
PlaybackService.episode = audio;
if (!z) {
PlaybackService.setAudios(arrayList);
}
PlaybackService.source = i;
Intent intent = new Intent(context, PlaybackService.class);
intent.setAction("play");
context.startService(intent);
} catch (Throwable th) {
th.printStackTrace();
Helper.reportError(th);
}
}
public void copyPodcast(Audio audio) {
Helper.copyText("https://vk.com/podcast" + audio.owner_id + "_" + audio.aid, this.context);
}
public void editAudio(long j, long j2, Fragment fragment) {
Intent intent = new Intent(this.context, EditAudioActivity.class);
intent.putExtra("com.perm.kate.audio_id", j);
intent.putExtra("com.perm.kate.audio_owner_id", j2);
PhotoChooser.startActivity(this.context, fragment, intent, 11);
}
public String makeAudiosString(ArrayList arrayList) {
Iterator it = arrayList.iterator();
String str = "";
while (it.hasNext()) {
Audio audio = (Audio) it.next();
if (str.length() != 0) {
str = str + ",";
}
String str2 = str + audio.owner_id + "_" + audio.aid;
if (TextUtils.isEmpty(audio.access_key)) {
str = str2;
} else {
str = str2 + "_" + audio.access_key;
}
}
return str;
}
public HashMap makeMap(ArrayList arrayList) {
HashMap hashMap = new HashMap();
Iterator it = arrayList.iterator();
while (it.hasNext()) {
Audio audio = (Audio) it.next();
hashMap.put(audio.owner_id + "_" + audio.aid, audio);
}
return hashMap;
}
public void repostToGroup() {
Intent intent = new Intent();
intent.setClass(this.context, GroupsActivity2.class);
intent.putExtra("com.perm.kate.select_group", true);
this.context.startActivityForResult(intent, 12);
}
public static boolean restricted(Audio audio) {
return false;
}
public static void restrictedToast() {
Toast.makeText(KApplication.current, (int) R.string.music_restricted_warning, 1).show();
}
public static void searchSongArtist(BaseActivity baseActivity, String str) {
Intent intent = new Intent(baseActivity, SearchActivity.class);
intent.putExtra("com.perm.kate.search_audio", true);
intent.putExtra("com.perm.kate.search_audio_artist", str);
baseActivity.startActivity(intent);
}
public void sendToFriend(long j, long j2, String str) {
String str2 = "audio" + j + "_" + j2;
if (!TextUtils.isEmpty(str)) {
str2 = str2 + "_" + str;
}
Intent intent = new Intent();
intent.setClass(this.context, MembersActivity.class);
intent.putExtra("com.perm.kate.only_members", false);
intent.putExtra("com.perm.kate.new_message", true);
intent.putExtra("com.perm.kate.photo_attachment", str2);
this.context.startActivity(intent);
}
public void sendToFriend(Audio audio) {
Intent intent = new Intent();
intent.setClass(this.context, MembersActivity.class);
intent.putExtra("com.perm.kate.only_members", false);
intent.putExtra("com.perm.kate.new_message", true);
intent.putExtra("com.perm.kate.photo_attachment", "podcast" + audio.owner_id + "_" + audio.aid);
this.context.startActivity(intent);
}
public void sharePodcast(Audio audio) {
Helper.share("https://vk.com/podcast" + audio.owner_id + "_" + audio.aid, this.context);
}
public void showBitrate(final Audio audio) {
if (restricted(audio)) {
restrictedToast();
} else if (audio.duration == 0) {
} else {
new Mp3InfoHelper(new Mp3InfoHelper.Mp3InfoCallback() {
@Override
public void completed(long j) {
BaseActivity baseActivity = AudioClickHelper.this.context;
if (baseActivity == null || baseActivity.isFinishing()) {
return;
}
BaseActivity baseActivity2 = AudioClickHelper.this.context;
baseActivity2.displayToast(AudioClickHelper.this.context.getString(R.string.label_bitrate) + ": " + ((((int) ((j / audio.duration) * 8)) / 1000) + " " + AudioClickHelper.this.context.getString(R.string.label_kbps)));
}
}).getLength(audio.url);
}
}
public void showLyricsActivity(long j, long j2) {
Intent intent = new Intent(this.context, LyricsActivity.class);
intent.putExtra("audio_id", j);
intent.putExtra("owner_id", j2);
this.context.startActivity(intent);
}
public void showShareDialogForPodcast(final Audio audio) {
final ArrayList arrayList = new ArrayList();
arrayList.add(new MenuItemDetails((int) R.string.label_menu_send_to_friend, 0));
arrayList.add(new MenuItemDetails((int) R.string.publish_desc, 1));
arrayList.add(new MenuItemDetails((int) R.string.publish_to_group, 2));
arrayList.add(new MenuItemDetails((int) R.string.label_send_to, 3));
arrayList.add(new MenuItemDetails((int) R.string.label_copy_video_link, 4));
AlertDialog create = new AlertDialog.Builder(this.context).setItems(MenuItemDetails.toArray(arrayList), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
try {
int i2 = ((MenuItemDetails) arrayList.get(i)).code;
if (i2 == 0) {
AudioClickHelper.this.sendToFriend(audio);
} else if (i2 == 1) {
AudioClickHelper.this.sendToWall(audio, 0L);
} else if (i2 == 2) {
AudioClickHelper.this.repostToGroup();
} else if (i2 == 3) {
AudioClickHelper.this.sharePodcast(audio);
} else if (i2 == 4) {
AudioClickHelper.this.copyPodcast(audio);
}
} catch (Throwable th) {
th.printStackTrace();
Helper.reportError(th);
}
}
}).create();
create.setCanceledOnTouchOutside(true);
create.show();
}
public void showSimilarAudio(Audio audio) {
Intent intent = new Intent(this.context, AudioActivity2.class);
intent.putExtra("target_audio", audio.owner_id + "_" + audio.aid);
this.context.startActivity(intent);
}
protected void AddAudio(final Long l, final Long l2, final String str) {
new Thread() {
@Override
public void run() {
AudioClickHelper.this.context.showProgressBar(true);
Session session = KApplication.session;
Long l3 = l;
Long l4 = l2;
String str2 = str;
AudioClickHelper audioClickHelper = AudioClickHelper.this;
session.addAudio(l3, l4, null, str2, audioClickHelper.callback_add, audioClickHelper.context);
}
}.start();
}
public void CreateContextMenu(Audio audio, boolean z, ArrayList arrayList, boolean z2, int i) {
CreateContextMenu(audio, z, arrayList, z2, null, true, true, i, 0L, null, null, null, false, false, false);
}
public void CreateContextMenu(final Audio audio, boolean z, final ArrayList arrayList, boolean z2, final AudioFragment audioFragment, boolean z3, boolean z4, final int i, final long j, final String str, final String str2, final String str3, final boolean z5, boolean z6, boolean z7) {
Audio audio2;
Player player;
int i2;
final ArrayList arrayList2 = new ArrayList();
arrayList2.add(new MenuItemDetails((int) R.string.label_menu_play_audio, 0));
if (z4 && (player = PlaybackService.player) != null && ((i2 = player.state) == 0 || i2 == 3 || i2 == 1)) {
arrayList2.add(new MenuItemDetails((int) R.string.play_next, 15));
}
arrayList2.add(new MenuItemDetails((int) R.string.similar_audio, 14));
arrayList2.add(new MenuItemDetails((int) R.string.label_search_artist, 16));
Long l = audio.lyrics_id;
if (l != null && l.longValue() > 0) {
arrayList2.add(new MenuItemDetails((int) R.string.label_menu_show_audio_text, 5));
}
arrayList2.add(new MenuItemDetails((int) R.string.label_menu_send_to_friend, 11));
arrayList2.add(new MenuItemDetails((int) R.string.add_to_album, 6));
if (z7) {
arrayList2.add(new MenuItemDetails((int) R.string.add_to_group_album, 18));
}
if (z) {
if (z2) {
arrayList2.add(new MenuItemDetails((int) R.string.label_delete_from_album, 7));
}
arrayList2.add(new MenuItemDetails((int) R.string.label_edit, 12));
}
if (z6 && (audio2 = PlaybackService.episode) != null && audio2 != audio) {
arrayList2.add(new MenuItemDetails((int) R.string.delete_from_queue, 17));
}
if (z) {
arrayList2.add(new MenuItemDetails((int) R.string.label_menu_delete_audio, 2));
} else {
arrayList2.add(new MenuItemDetails((int) R.string.label_menu_add_audio, 1));
}
KApplication.db.isAudioCached(audio.aid, audio.owner_id);
if (z3) {
arrayList2.add(new MenuItemDetails((int) R.string.label_show_bitrate, 13));
}
AlertDialog create = new AlertDialog.Builder(this.context).setItems(MenuItemDetails.toArray(arrayList2), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i3) {
int i4 = ((MenuItemDetails) arrayList2.get(i3)).code;
if (i4 == 0) {
AudioClickHelper.PlayAudio(audio, AudioClickHelper.this.context, arrayList, false, i);
if (TextUtils.isEmpty(str2)) {
return;
}
AdEvents.reportAudioStart(str, str2, str3);
} else if (i4 == 1) {
if (AudioClickHelper.restricted(audio)) {
AudioClickHelper.restrictedToast();
} else {
AudioClickHelper.this.AddAudio(Long.valueOf(audio.aid), Long.valueOf(audio.owner_id), audio.access_key);
}
} else if (i4 == 2) {
if (z5) {
AudioClickHelper.this.audioCallback.audioSelectForDelete(audio.aid);
} else {
AudioClickHelper.this.confirmDeleteAudio(Long.valueOf(audio.aid), Long.valueOf(audio.owner_id));
}
} else if (i4 == 5) {
AudioClickHelper audioClickHelper = AudioClickHelper.this;
Audio audio3 = audio;
audioClickHelper.showLyricsActivity(audio3.aid, audio3.owner_id);
} else if (i4 == 6) {
AudioClickHelperCallback audioClickHelperCallback = AudioClickHelper.this.audioCallback;
Audio audio4 = audio;
audioClickHelperCallback.audioSelectForMove(audio4.aid, true, audio4.owner_id);
} else if (i4 == 7) {
AudioClickHelper audioClickHelper2 = AudioClickHelper.this;
Audio audio5 = audio;
audioClickHelper2.deleteFromAlbum(audio5.aid, Long.valueOf(audio5.owner_id), audioFragment, j);
} else {
switch (i4) {
case 11:
if (AudioClickHelper.restricted(audio)) {
AudioClickHelper.restrictedToast();
return;
}
KApplication.db.createOrUpdateAudio(audio);
AudioClickHelper audioClickHelper3 = AudioClickHelper.this;
Audio audio6 = audio;
audioClickHelper3.sendToFriend(audio6.owner_id, audio6.aid, audio6.access_key);
return;
case 12:
AudioClickHelper audioClickHelper4 = AudioClickHelper.this;
Audio audio7 = audio;
audioClickHelper4.editAudio(audio7.aid, audio7.owner_id, audioFragment);
return;
case 13:
AudioClickHelper.this.showBitrate(audio);
return;
case 14:
AudioClickHelper.this.showSimilarAudio(audio);
return;
case 15:
PlaybackService.playNext(audio);
return;
case 16:
AudioClickHelper.searchSongArtist(AudioClickHelper.this.context, audio.artist);
return;
case 17:
PlaybackService.deleteFromQueue(audio);
return;
case 18:
AudioClickHelperCallback audioClickHelperCallback2 = AudioClickHelper.this.audioCallback;
Audio audio8 = audio;
audioClickHelperCallback2.audioSelectForMove(audio8.aid, false, audio8.owner_id);
return;
default:
return;
}
}
}
}).create();
create.setCanceledOnTouchOutside(true);
create.show();
}
protected void DeleteAudio(final Long l, final Long l2) {
new Thread() {
@Override
public void run() {
AudioClickHelper.this.context.showProgressBar(true);
Session session = KApplication.session;
ArrayList arrayList = new ArrayList(Arrays.asList(l));
long longValue = l2.longValue();
AudioClickHelper audioClickHelper = AudioClickHelper.this;
session.deleteAudios(arrayList, longValue, audioClickHelper.callback_delete, audioClickHelper.context);
BaseActivity baseActivity = AudioClickHelper.this.context;
if (baseActivity != null) {
baseActivity.showProgressBar(false);
}
}
}.start();
}
public void click(Audio audio, ArrayList arrayList, final int i, final String str, final String str2, final String str3) {
try {
AudioClickHelperCallback2 audioClickHelperCallback2 = new AudioClickHelperCallback2() {
@Override
public void audiosDownloaded(Audio audio2, ArrayList arrayList2) {
if (AudioClickHelper.this.context.isFinishing()) {
return;
}
AudioClickHelper.this.CreateContextMenu(audio2, false, arrayList2, false, null, true, true, i, 0L, str, str2, str3, false, false, false);
}
};
if (!audio.isPodcast() || TextUtils.isEmpty(audio.url)) {
downloadAudios(audio, arrayList, audioClickHelperCallback2);
} else {
createPodcastMenu(audio, arrayList, i, str, str2, str3);
}
} catch (Throwable th) {
Helper.reportError(th);
th.printStackTrace();
}
}
protected void confirmDeleteAudio(final Long l, final Long l2) {
AlertDialog create = new AlertDialog.Builder(this.context).setMessage(R.string.label_confirm_delete).setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
AudioClickHelper.this.DeleteAudio(l, l2);
}
}).setNegativeButton(R.string.no, (DialogInterface.OnClickListener) null).create();
create.setCanceledOnTouchOutside(true);
create.show();
}
public void createPodcastMenu(final Audio audio, final ArrayList arrayList, final int i, final String str, final String str2, final String str3) {
final ArrayList arrayList2 = new ArrayList();
arrayList2.add(new MenuItemDetails((int) R.string.label_menu_play_audio, 0));
arrayList2.add(new MenuItemDetails((int) R.string.label_menu_show_audio_text, 5));
arrayList2.add(new MenuItemDetails((int) R.string.label_open_profile, 200));
arrayList2.add(new MenuItemDetails((int) R.string.label_share, 202));
AlertDialog create = new AlertDialog.Builder(this.context).setItems(MenuItemDetails.toArray(arrayList2), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i2) {
int i3 = ((MenuItemDetails) arrayList2.get(i2)).code;
if (i3 == 0) {
AudioClickHelper.PlayAudio(audio, AudioClickHelper.this.context, arrayList, false, i);
if (TextUtils.isEmpty(str2)) {
return;
}
AdEvents.reportAudioStart(str, str2, str3);
} else if (i3 == 5) {
AudioClickHelper audioClickHelper = AudioClickHelper.this;
Audio audio2 = audio;
audioClickHelper.showLyricsActivity(audio2.aid, audio2.owner_id);
} else if (i3 != 200) {
if (i3 != 202) {
return;
}
AudioClickHelper.this.showShareDialogForPodcast(audio);
} else {
long j = audio.owner_id;
if (j > 0) {
Helper.ShowProfile(j, AudioClickHelper.this.context);
} else {
Helper.showGroup(j * (-1), AudioClickHelper.this.context);
}
}
}
}).create();
create.setCanceledOnTouchOutside(true);
create.show();
}
protected void deleteFromAlbum(long j, Long l, AudioFragment audioFragment, long j2) {
if (audioFragment != null) {
audioFragment.removeFromAlbum(Long.valueOf(j), l, Long.valueOf(j2));
}
}
public void destroy() {
this.context = null;
this.audioCallback = null;
}
void downloadAudios(Audio audio, ArrayList arrayList, AudioClickHelperCallback2 audioClickHelperCallback2) {
new AnonymousClass13(audio, audioClickHelperCallback2, arrayList).start();
}
public void fetchAndPlayAudio(Audio audio, final Activity activity, ArrayList arrayList, final int i) {
try {
AudioClickHelperCallback2 audioClickHelperCallback2 = new AudioClickHelperCallback2() {
@Override
public void audiosDownloaded(Audio audio2, ArrayList arrayList2) {
AudioClickHelper.PlayAudio(audio2, activity, arrayList2, false, i);
}
};
if (!audio.isPodcast() || TextUtils.isEmpty(audio.url)) {
downloadAudios(audio, arrayList, audioClickHelperCallback2);
} else {
ArrayList arrayList2 = new ArrayList();
arrayList2.add(audio);
PlayAudio(audio, activity, arrayList2, false, i);
}
} catch (Throwable th) {
Helper.reportError(th);
th.printStackTrace();
}
}
public void sendToWall(Audio audio, long j) {
Intent intent = new Intent();
intent.setClass(this.context, WallPostActivity.class);
if (j != 0) {
intent.putExtra("com.perm.kate.owner_id", j);
}
intent.putExtra("com.perm.kate.audio_attachment", "podcast" + audio.owner_id + "_" + audio.aid);
this.context.startActivity(intent);
}
public void showAlbumActivityForMove(ArrayList arrayList, long j) {
Intent intent = new Intent(this.context, AudioAlbumsActivity.class);
intent.putExtra("audio_ids", arrayList);
intent.putExtra("com.perm.kate.owner_id", j);
intent.putExtra("com.perm.kate.is_move", true);
this.context.startActivity(intent);
}
}