MP4 muxer +misc modifications
* allow retry downloads with "post-processing failed" error in the new muxer * MPEG-4 muxer ¡¡ no DASH output!! * keep the progress if download fails * remove TODO in SecondaryStreamHelper.java * misc clean-up * delete TestAlgo.java * delete ExtSDDownloadFailedActivity.java and remove it from AndroidManifest.xml * use hardcored version for changing icon colors
This commit is contained in:
parent
99fee300f4
commit
00a65e1c49
15 changed files with 357 additions and 260 deletions
|
|
@ -59,7 +59,7 @@ import static us.shandian.giga.get.DownloadMission.ERROR_HTTP_UNSUPPORTED_RANGE;
|
|||
import static us.shandian.giga.get.DownloadMission.ERROR_NOTHING;
|
||||
import static us.shandian.giga.get.DownloadMission.ERROR_PATH_CREATION;
|
||||
import static us.shandian.giga.get.DownloadMission.ERROR_PERMISSION_DENIED;
|
||||
import static us.shandian.giga.get.DownloadMission.ERROR_POSTPROCESSING_FAILED;
|
||||
import static us.shandian.giga.get.DownloadMission.ERROR_POSTPROCESSING;
|
||||
import static us.shandian.giga.get.DownloadMission.ERROR_SSL_EXCEPTION;
|
||||
import static us.shandian.giga.get.DownloadMission.ERROR_UNKNOWN_EXCEPTION;
|
||||
import static us.shandian.giga.get.DownloadMission.ERROR_UNKNOWN_HOST;
|
||||
|
|
@ -67,7 +67,8 @@ import static us.shandian.giga.get.DownloadMission.ERROR_UNKNOWN_HOST;
|
|||
public class MissionAdapter extends Adapter<ViewHolder> {
|
||||
private static final SparseArray<String> ALGORITHMS = new SparseArray<>();
|
||||
private static final String TAG = "MissionAdapter";
|
||||
private static final String UNDEFINED_SPEED = "--.-%";
|
||||
private static final String UNDEFINED_PROGRESS = "--.-%";
|
||||
|
||||
|
||||
static {
|
||||
ALGORITHMS.put(R.id.md5, "MD5");
|
||||
|
|
@ -178,7 +179,7 @@ public class MissionAdapter extends Adapter<ViewHolder> {
|
|||
if (h.item.mission instanceof DownloadMission) {
|
||||
DownloadMission mission = (DownloadMission) item.mission;
|
||||
String length = Utility.formatBytes(mission.getLength());
|
||||
if (mission.running && !mission.postprocessingRunning) length += " --.- kB/s";
|
||||
if (mission.running && !mission.isPsRunning()) length += " --.- kB/s";
|
||||
|
||||
h.size.setText(length);
|
||||
h.pause.setTitle(mission.unknownLength ? R.string.stop : R.string.pause);
|
||||
|
|
@ -238,11 +239,10 @@ public class MissionAdapter extends Adapter<ViewHolder> {
|
|||
}
|
||||
|
||||
if (hasError) {
|
||||
if (Float.isNaN(progress) || Float.isInfinite(progress))
|
||||
h.progress.setProgress(1f);
|
||||
h.progress.setProgress(isNotFinite(progress) ? 1f : progress);
|
||||
h.status.setText(R.string.msg_error);
|
||||
} else if (Float.isNaN(progress) || Float.isInfinite(progress)) {
|
||||
h.status.setText(UNDEFINED_SPEED);
|
||||
} else if (isNotFinite(progress)) {
|
||||
h.status.setText(UNDEFINED_PROGRESS);
|
||||
} else {
|
||||
h.status.setText(String.format("%.2f%%", progress * 100));
|
||||
h.progress.setProgress(progress);
|
||||
|
|
@ -251,11 +251,11 @@ public class MissionAdapter extends Adapter<ViewHolder> {
|
|||
long length = mission.getLength();
|
||||
|
||||
int state;
|
||||
if (mission.errCode == ERROR_POSTPROCESSING_FAILED) {
|
||||
if (mission.isPsFailed()) {
|
||||
state = 0;
|
||||
} else if (!mission.running) {
|
||||
state = mission.enqueued ? 1 : 2;
|
||||
} else if (mission.postprocessingRunning) {
|
||||
} else if (mission.isPsRunning()) {
|
||||
state = 3;
|
||||
} else {
|
||||
state = 0;
|
||||
|
|
@ -406,7 +406,7 @@ public class MissionAdapter extends Adapter<ViewHolder> {
|
|||
case ERROR_CONNECT_HOST:
|
||||
str.append(mContext.getString(R.string.error_connect_host));
|
||||
break;
|
||||
case ERROR_POSTPROCESSING_FAILED:
|
||||
case ERROR_POSTPROCESSING:
|
||||
str.append(mContext.getString(R.string.error_postprocessing_failed));
|
||||
case ERROR_UNKNOWN_EXCEPTION:
|
||||
break;
|
||||
|
|
@ -447,7 +447,7 @@ public class MissionAdapter extends Adapter<ViewHolder> {
|
|||
if (mission != null) {
|
||||
switch (id) {
|
||||
case R.id.start:
|
||||
h.status.setText(UNDEFINED_SPEED);
|
||||
h.status.setText(UNDEFINED_PROGRESS);
|
||||
h.state = -1;
|
||||
h.size.setText(Utility.formatBytes(mission.getLength()));
|
||||
mDownloadManager.resumeMission(mission);
|
||||
|
|
@ -507,7 +507,7 @@ public class MissionAdapter extends Adapter<ViewHolder> {
|
|||
mIterator.end();
|
||||
|
||||
checkEmptyMessageVisibility();
|
||||
checkClearButtonVisibility(mClear);
|
||||
mClear.setVisible(mIterator.hasFinishedMissions());
|
||||
}
|
||||
|
||||
public void forceUpdate() {
|
||||
|
|
@ -526,20 +526,10 @@ public class MissionAdapter extends Adapter<ViewHolder> {
|
|||
}
|
||||
|
||||
public void setClearButton(MenuItem clearButton) {
|
||||
if (mClear == null) checkClearButtonVisibility(clearButton);
|
||||
if (mClear == null) clearButton.setVisible(mIterator.hasFinishedMissions());
|
||||
mClear = clearButton;
|
||||
}
|
||||
|
||||
private void checkClearButtonVisibility(MenuItem clearButton) {
|
||||
if (mIterator.getOldListSize() < 1) {
|
||||
clearButton.setVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
DownloadManager.MissionItem item = mIterator.getItem(mIterator.getOldListSize() - 1);
|
||||
clearButton.setVisible(item.special == DownloadManager.SPECIAL_FINISHED || item.mission instanceof FinishedMission);
|
||||
}
|
||||
|
||||
private void checkEmptyMessageVisibility() {
|
||||
int flag = mIterator.getOldListSize() > 0 ? View.GONE : View.VISIBLE;
|
||||
if (mEmptyMessage.getVisibility() != flag) mEmptyMessage.setVisibility(flag);
|
||||
|
|
@ -596,6 +586,10 @@ public class MissionAdapter extends Adapter<ViewHolder> {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean isNotFinite(Float value) {
|
||||
return Float.isNaN(value) || Float.isInfinite(value);
|
||||
}
|
||||
|
||||
|
||||
class ViewHolderItem extends RecyclerView.ViewHolder {
|
||||
DownloadManager.MissionItem item;
|
||||
|
|
@ -667,7 +661,7 @@ public class MissionAdapter extends Adapter<ViewHolder> {
|
|||
DownloadMission mission = item.mission instanceof DownloadMission ? (DownloadMission) item.mission : null;
|
||||
|
||||
if (mission != null) {
|
||||
if (!mission.postprocessingRunning) {
|
||||
if (!mission.isPsRunning()) {
|
||||
if (mission.running) {
|
||||
pause.setVisible(true);
|
||||
} else {
|
||||
|
|
@ -678,8 +672,10 @@ public class MissionAdapter extends Adapter<ViewHolder> {
|
|||
queue.setChecked(mission.enqueued);
|
||||
|
||||
delete.setVisible(true);
|
||||
start.setVisible(mission.errCode != ERROR_POSTPROCESSING_FAILED);
|
||||
queue.setVisible(mission.errCode != ERROR_POSTPROCESSING_FAILED);
|
||||
|
||||
boolean flag = !mission.isPsFailed();
|
||||
start.setVisible(flag);
|
||||
queue.setVisible(flag);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -7,16 +7,12 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.AttrRes;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
|
@ -24,6 +20,7 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
|
||||
import org.schabi.newpipe.R;
|
||||
import org.schabi.newpipe.util.ThemeHelper;
|
||||
|
||||
import us.shandian.giga.service.DownloadManager;
|
||||
import us.shandian.giga.service.DownloadManagerService;
|
||||
|
|
@ -192,29 +189,20 @@ public class MissionsFragment extends Fragment {
|
|||
mList.setAdapter(mAdapter);
|
||||
|
||||
if (mSwitch != null) {
|
||||
mSwitch.setIcon(getDrawableFromAttribute(mLinear ? R.attr.ic_grid : R.attr.ic_list));
|
||||
boolean isLight = ThemeHelper.isLightThemeSelected(mContext);
|
||||
int icon;
|
||||
|
||||
if (mLinear)
|
||||
icon = isLight ? R.drawable.ic_list_black_24dp : R.drawable.ic_list_white_24dp;
|
||||
else
|
||||
icon = isLight ? R.drawable.ic_grid_black_24dp : R.drawable.ic_grid_white_24dp;
|
||||
|
||||
mSwitch.setIcon(icon);
|
||||
mSwitch.setTitle(mLinear ? R.string.grid : R.string.list);
|
||||
mPrefs.edit().putBoolean("linear", mLinear).apply();
|
||||
}
|
||||
}
|
||||
|
||||
@DrawableRes
|
||||
private int getDrawableFromAttribute(@AttrRes int attr) {
|
||||
TypedArray styledAttributes = mContext.getTheme().obtainStyledAttributes(new int[]{attr});
|
||||
int resId = styledAttributes.getResourceId(0, 0);
|
||||
styledAttributes.recycle();
|
||||
|
||||
if (resId != 0) {
|
||||
return resId;
|
||||
} else {
|
||||
// work-around
|
||||
styledAttributes = mContext.obtainStyledAttributes(new int[]{attr});
|
||||
resId = styledAttributes.getResourceId(0, 0);
|
||||
styledAttributes.recycle();
|
||||
return resId;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue