|
|
@ -23,13 +23,25 @@ import android.support.v7.widget.ActionMenuView; |
|
|
|
import android.view.View; |
|
|
|
import android.view.View; |
|
|
|
import android.widget.ListView; |
|
|
|
import android.widget.ListView; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.nispok.snackbar.Snackbar; |
|
|
|
|
|
|
|
import com.nispok.snackbar.SnackbarManager; |
|
|
|
|
|
|
|
|
|
|
|
import org.androidannotations.annotations.AfterViews; |
|
|
|
import org.androidannotations.annotations.AfterViews; |
|
|
|
|
|
|
|
import org.androidannotations.annotations.Bean; |
|
|
|
import org.androidannotations.annotations.EFragment; |
|
|
|
import org.androidannotations.annotations.EFragment; |
|
|
|
import org.androidannotations.annotations.InstanceState; |
|
|
|
import org.androidannotations.annotations.InstanceState; |
|
|
|
import org.androidannotations.annotations.ItemClick; |
|
|
|
import org.androidannotations.annotations.ItemClick; |
|
|
|
|
|
|
|
import org.androidannotations.annotations.UiThread; |
|
|
|
import org.androidannotations.annotations.ViewById; |
|
|
|
import org.androidannotations.annotations.ViewById; |
|
|
|
import org.transdroid.R; |
|
|
|
import org.transdroid.R; |
|
|
|
|
|
|
|
import org.transdroid.core.gui.log.Log; |
|
|
|
import org.transdroid.core.gui.remoterss.data.RemoteRssItem; |
|
|
|
import org.transdroid.core.gui.remoterss.data.RemoteRssItem; |
|
|
|
|
|
|
|
import org.transdroid.daemon.Daemon; |
|
|
|
|
|
|
|
import org.transdroid.daemon.IDaemonAdapter; |
|
|
|
|
|
|
|
import org.transdroid.daemon.task.AddByMagnetUrlTask; |
|
|
|
|
|
|
|
import org.transdroid.daemon.task.AddByUrlTask; |
|
|
|
|
|
|
|
import org.transdroid.daemon.task.DaemonTaskResult; |
|
|
|
|
|
|
|
import org.transdroid.daemon.task.DaemonTaskSuccessResult; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
@ -42,6 +54,8 @@ import java.util.List; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@EFragment(R.layout.fragment_remoterss) |
|
|
|
@EFragment(R.layout.fragment_remoterss) |
|
|
|
public class RemoteRssFragment extends Fragment { |
|
|
|
public class RemoteRssFragment extends Fragment { |
|
|
|
|
|
|
|
@Bean |
|
|
|
|
|
|
|
protected Log log; |
|
|
|
|
|
|
|
|
|
|
|
// Local data
|
|
|
|
// Local data
|
|
|
|
@InstanceState |
|
|
|
@InstanceState |
|
|
@ -73,16 +87,6 @@ public class RemoteRssFragment extends Fragment { |
|
|
|
// } else {
|
|
|
|
// } else {
|
|
|
|
// detailsContainer.setBackgroundResource(R.drawable.details_list_background_light);
|
|
|
|
// detailsContainer.setBackgroundResource(R.drawable.details_list_background_light);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if (getActivity() != null && getActivity() instanceof RefreshableActivity) {
|
|
|
|
|
|
|
|
// swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
|
|
// public void onRefresh() {
|
|
|
|
|
|
|
|
// ((RefreshableActivity) getActivity()).refreshScreen();
|
|
|
|
|
|
|
|
// swipeRefreshLayout.setRefreshing(false); // Use our custom indicator
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// Set up details adapter (itself containing the actual lists to show), which allows multi-select and fast
|
|
|
|
// Set up details adapter (itself containing the actual lists to show), which allows multi-select and fast
|
|
|
@ -109,30 +113,34 @@ public class RemoteRssFragment extends Fragment { |
|
|
|
|
|
|
|
|
|
|
|
@ItemClick(resName = "torrents_list") |
|
|
|
@ItemClick(resName = "torrents_list") |
|
|
|
protected void detailsListClicked(int position) { |
|
|
|
protected void detailsListClicked(int position) { |
|
|
|
torrentsList.setItemChecked(position, false); |
|
|
|
RemoteRssActivity activity = (RemoteRssActivity) getActivity(); |
|
|
|
|
|
|
|
RemoteRssItem item = (RemoteRssItem) adapter.getItem(position); |
|
|
|
|
|
|
|
IDaemonAdapter currentConnection = activity.getCurrentConnection(); |
|
|
|
|
|
|
|
DaemonTaskResult result; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (item.isMagnetLink()) { |
|
|
|
|
|
|
|
// Check if it's supported
|
|
|
|
|
|
|
|
if (!Daemon.supportsAddByMagnetUrl(currentConnection.getType())) { |
|
|
|
|
|
|
|
// TODO:
|
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
AddByMagnetUrlTask addByMagnetUrlTask = AddByMagnetUrlTask.create(currentConnection, item.getLink()); |
|
|
|
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
|
|
|
result = addByMagnetUrlTask.execute(log); |
|
|
|
// super.onCreateOptionsMenu(menu, inflater);
|
|
|
|
} |
|
|
|
//
|
|
|
|
else { |
|
|
|
// inflater.inflate(R.menu.fragment_details, menu);
|
|
|
|
result = AddByUrlTask.create(currentConnection, item.getLink(), item.getTitle()).execute(log); |
|
|
|
// }
|
|
|
|
} |
|
|
|
//
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
|
|
|
|
// public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
|
|
|
|
// switch (item.getItemId()) {
|
|
|
|
|
|
|
|
// case R.id.action_start_default:
|
|
|
|
|
|
|
|
//// startTorrentDefault();
|
|
|
|
|
|
|
|
// return true;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// return super.onOptionsItemSelected(item);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @OptionsItem(R.id.action_start_default)
|
|
|
|
if (result instanceof DaemonTaskSuccessResult) { |
|
|
|
// protected void startTorrentDefault() {
|
|
|
|
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_added, item.getTitle())); |
|
|
|
// if (getTasksExecutor() != null)
|
|
|
|
} else { |
|
|
|
// getTasksExecutor().startTorrent(torrent, false);
|
|
|
|
// onCommunicationError((DaemonTaskFailureResult) result, false);
|
|
|
|
// }
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@UiThread |
|
|
|
|
|
|
|
protected void onTaskSucceeded(DaemonTaskSuccessResult result, String successMessage) { |
|
|
|
|
|
|
|
SnackbarManager.show(Snackbar.with(getActivity()).text(successMessage)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|