修改demo界面
This commit is contained in:
@@ -16,66 +16,129 @@
|
||||
|
||||
package com.arialyy.simple;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.AppCompatImageView;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import com.arialyy.frame.permission.OnPermissionCallback;
|
||||
import com.arialyy.frame.permission.PermissionManager;
|
||||
import com.arialyy.frame.util.show.T;
|
||||
import com.arialyy.simple.base.BaseActivity;
|
||||
import com.arialyy.simple.base.adapter.AbsHolder;
|
||||
import com.arialyy.simple.base.adapter.AbsRVAdapter;
|
||||
import com.arialyy.simple.base.adapter.RvItemClickSupport;
|
||||
import com.arialyy.simple.databinding.ActivityMainBinding;
|
||||
import com.arialyy.simple.download.DownloadActivity;
|
||||
import com.arialyy.simple.download.FtpDownloadActivity;
|
||||
import com.arialyy.simple.download.group.DownloadGroupActivity;
|
||||
import com.arialyy.simple.download.group.FTPDirDownloadActivity;
|
||||
import com.arialyy.simple.upload.FtpUploadActivity;
|
||||
import com.arialyy.simple.upload.HttpUploadActivity;
|
||||
import com.arialyy.simple.core.download.DownloadActivity;
|
||||
import com.arialyy.simple.core.download.FtpDownloadActivity;
|
||||
import com.arialyy.simple.core.download.group.DownloadGroupActivity;
|
||||
import com.arialyy.simple.core.download.group.FTPDirDownloadActivity;
|
||||
import com.arialyy.simple.core.upload.FtpUploadActivity;
|
||||
import com.arialyy.simple.core.upload.HttpUploadActivity;
|
||||
import com.arialyy.simple.modlue.CommonModule;
|
||||
import com.arialyy.simple.to.NormalTo;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by lyy on 2017/3/1.
|
||||
* 首页
|
||||
*/
|
||||
public class MainActivity extends BaseActivity<ActivityMainBinding>
|
||||
implements View.OnClickListener {
|
||||
public class MainActivity extends BaseActivity<ActivityMainBinding> {
|
||||
public static final String KEY_MAIN_DATA = "KEY_MAIN_DATA";
|
||||
|
||||
@Override protected void init(Bundle savedInstanceState) {
|
||||
super.init(savedInstanceState);
|
||||
setSupportActionBar(mBar);
|
||||
mBar.setTitle("Aria Demo");
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
|
||||
getBinding().download.setOnClickListener(this);
|
||||
getBinding().upload.setOnClickListener(this);
|
||||
getBinding().downloadTaskGroup.setOnClickListener(this);
|
||||
getBinding().ftpDownload.setOnClickListener(this);
|
||||
getBinding().ftpDirDownload.setOnClickListener(this);
|
||||
getBinding().ftpUpload.setOnClickListener(this);
|
||||
getBinding().kotlinDownload.setOnClickListener(this);
|
||||
|
||||
getBinding().list.setLayoutManager(new LinearLayoutManager(this));
|
||||
final List<NormalTo> data = getModule(CommonModule.class).getMainData();
|
||||
getBinding().list.setAdapter(
|
||||
new Adapter(this, data));
|
||||
RvItemClickSupport.addTo(getBinding().list).setOnItemClickListener(
|
||||
new RvItemClickSupport.OnItemClickListener() {
|
||||
@Override public void onItemClicked(RecyclerView recyclerView, int position, View v) {
|
||||
CommonModule module = getModule(CommonModule.class);
|
||||
switch (position) {
|
||||
case 0:
|
||||
module.startNextActivity(data.get(position), DownloadActivity.class);
|
||||
break;
|
||||
case 1:
|
||||
module.startNextActivity(data.get(position), HttpUploadActivity.class);
|
||||
break;
|
||||
case 2:
|
||||
module.startNextActivity(data.get(position), DownloadGroupActivity.class);
|
||||
break;
|
||||
case 3:
|
||||
module.startNextActivity(data.get(position), FtpDownloadActivity.class);
|
||||
break;
|
||||
case 4:
|
||||
module.startNextActivity(data.get(position), FTPDirDownloadActivity.class);
|
||||
break;
|
||||
case 5:
|
||||
module.startNextActivity(data.get(position), FtpUploadActivity.class);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
boolean hasPermission = PermissionManager.getInstance()
|
||||
.checkPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
if (!hasPermission) {
|
||||
PermissionManager.getInstance().requestPermission(this, new OnPermissionCallback() {
|
||||
@Override public void onSuccess(String... permissions) {
|
||||
}
|
||||
|
||||
@Override public void onFail(String... permissions) {
|
||||
T.showShort(MainActivity.this, "没有文件读写权限");
|
||||
finish();
|
||||
}
|
||||
}, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override protected int setLayoutId() {
|
||||
return R.layout.activity_main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.download:
|
||||
startActivity(new Intent(this, DownloadActivity.class));
|
||||
break;
|
||||
case R.id.upload:
|
||||
startActivity(new Intent(this, HttpUploadActivity.class));
|
||||
break;
|
||||
case R.id.download_task_group:
|
||||
startActivity(new Intent(this, DownloadGroupActivity.class));
|
||||
break;
|
||||
case R.id.ftp_download:
|
||||
startActivity(new Intent(this, FtpDownloadActivity.class));
|
||||
break;
|
||||
case R.id.ftp_dir_download:
|
||||
startActivity(new Intent(this, FTPDirDownloadActivity.class));
|
||||
break;
|
||||
case R.id.ftp_upload:
|
||||
startActivity(new Intent(this, FtpUploadActivity.class));
|
||||
break;
|
||||
case R.id.kotlin_download:
|
||||
//startActivity(new Intent(this, KotlinDownloadActivity.class));
|
||||
break;
|
||||
private static class Adapter extends AbsRVAdapter<NormalTo, Adapter.Holder> {
|
||||
|
||||
Adapter(Context context, List<NormalTo> data) {
|
||||
super(context, data);
|
||||
}
|
||||
|
||||
@Override protected Holder getViewHolder(View convertView, int viewType) {
|
||||
return new Holder(convertView);
|
||||
}
|
||||
|
||||
@Override protected int setLayoutId(int type) {
|
||||
return R.layout.item_main;
|
||||
}
|
||||
|
||||
@Override protected void bindData(Holder holder, int position, NormalTo item) {
|
||||
holder.text.setText(item.title);
|
||||
Log.d(TAG, item.icon + "");
|
||||
holder.image.setImageResource(item.icon);
|
||||
}
|
||||
|
||||
private static class Holder extends AbsHolder {
|
||||
TextView text;
|
||||
AppCompatImageView image;
|
||||
|
||||
Holder(View itemView) {
|
||||
super(itemView);
|
||||
text = findViewById(R.id.text);
|
||||
image = findViewById(R.id.image);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import android.view.View;
|
||||
* 通用Holder
|
||||
*/
|
||||
public class AbsHolder extends RecyclerView.ViewHolder {
|
||||
View mView;
|
||||
private View mView;
|
||||
private SparseArray<View> mViews = new SparseArray<>();
|
||||
|
||||
public AbsHolder(View itemView) {
|
||||
@@ -35,7 +35,7 @@ public class AbsHolder extends RecyclerView.ViewHolder {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends View> T getView(@IdRes int id) {
|
||||
public <T extends View> T findViewById(@IdRes int id) {
|
||||
View view = mViews.get(id);
|
||||
if (view == null) {
|
||||
view = mView.findViewById(id);
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
*
|
||||
* 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.arialyy.simple.core.download;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.AppCompatImageView;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import com.arialyy.simple.MainActivity;
|
||||
import com.arialyy.simple.R;
|
||||
import com.arialyy.simple.base.BaseActivity;
|
||||
import com.arialyy.simple.base.adapter.AbsHolder;
|
||||
import com.arialyy.simple.base.adapter.AbsRVAdapter;
|
||||
import com.arialyy.simple.base.adapter.RvItemClickSupport;
|
||||
import com.arialyy.simple.databinding.ActivityDownloadMeanBinding;
|
||||
import com.arialyy.simple.core.download.fragment_download.FragmentActivity;
|
||||
import com.arialyy.simple.core.download.multi_download.MultiTaskActivity;
|
||||
import com.arialyy.simple.core.download.service_download.DownloadService;
|
||||
import com.arialyy.simple.modlue.CommonModule;
|
||||
import com.arialyy.simple.to.NormalTo;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Lyy on 2016/10/13.
|
||||
*/
|
||||
public class DownloadActivity extends BaseActivity<ActivityDownloadMeanBinding> {
|
||||
private NormalTo mTo;
|
||||
|
||||
@Override protected int setLayoutId() {
|
||||
return R.layout.activity_download_mean;
|
||||
}
|
||||
|
||||
@Override protected void init(Bundle savedInstanceState) {
|
||||
super.init(savedInstanceState);
|
||||
mTo = getIntent().getParcelableExtra(MainActivity.KEY_MAIN_DATA);
|
||||
setTitle(mTo.title);
|
||||
final List<NormalTo> data = getModule(CommonModule.class).getDownloadData();
|
||||
getBinding().list.setLayoutManager(new GridLayoutManager(this, 2));
|
||||
getBinding().list.setAdapter(new Adapter(this, data));
|
||||
RvItemClickSupport.addTo(getBinding().list).setOnItemClickListener(
|
||||
new RvItemClickSupport.OnItemClickListener() {
|
||||
@Override public void onItemClicked(RecyclerView recyclerView, int position, View v) {
|
||||
CommonModule module = getModule(CommonModule.class);
|
||||
switch (position) {
|
||||
case 0:
|
||||
module.startNextActivity(data.get(position), SingleTaskActivity.class);
|
||||
break;
|
||||
case 1:
|
||||
module.startNextActivity(data.get(position), MultiTaskActivity.class);
|
||||
break;
|
||||
case 2:
|
||||
module.startNextActivity(data.get(position), HighestPriorityActivity.class);
|
||||
break;
|
||||
case 3:
|
||||
break;
|
||||
case 4:
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//public void onClick(View view) {
|
||||
// switch (view.getId()) {
|
||||
// case R.id.highest_priority:
|
||||
// startActivity(new Intent(this, HighestPriorityActivity.class));
|
||||
// break;
|
||||
// case R.id.service:
|
||||
// startService(new Intent(this, DownloadService.class));
|
||||
// break;
|
||||
// case R.id.single_task:
|
||||
// startActivity(new Intent(this, SingleTaskActivity.class));
|
||||
// break;
|
||||
// case R.id.multi_task:
|
||||
// startActivity(new Intent(this, MultiTaskActivity.class));
|
||||
// break;
|
||||
// case R.id.dialog_task:
|
||||
// DownloadDialog dialog = new DownloadDialog(this);
|
||||
//
|
||||
// dialog.show();
|
||||
// //DownloadDialogFragment dialog = new DownloadDialogFragment(this);
|
||||
// //dialog.show(getSupportFragmentManager(), "dialog");
|
||||
// break;
|
||||
// case R.id.pop_task:
|
||||
// DownloadPopupWindow pop = new DownloadPopupWindow(this);
|
||||
// pop.showAtLocation(mRootView, Gravity.CENTER_VERTICAL, 0, 0);
|
||||
// break;
|
||||
// case R.id.fragment_task:
|
||||
// startActivity(new Intent(this, FragmentActivity.class));
|
||||
// break;
|
||||
// case R.id.notification:
|
||||
// //SimpleNotification notification = new SimpleNotification(this);
|
||||
// //notification.start();
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
|
||||
private static class Adapter extends AbsRVAdapter<NormalTo, Adapter.Holder> {
|
||||
|
||||
Adapter(Context context, List<NormalTo> data) {
|
||||
super(context, data);
|
||||
}
|
||||
|
||||
@Override protected Adapter.Holder getViewHolder(View convertView, int viewType) {
|
||||
return new Adapter.Holder(convertView);
|
||||
}
|
||||
|
||||
@Override protected int setLayoutId(int type) {
|
||||
return R.layout.item_download;
|
||||
}
|
||||
|
||||
@Override protected void bindData(Adapter.Holder holder, int position, NormalTo item) {
|
||||
holder.text.setText(item.title);
|
||||
holder.image.setImageResource(item.icon);
|
||||
}
|
||||
|
||||
private static class Holder extends AbsHolder {
|
||||
TextView text;
|
||||
AppCompatImageView image;
|
||||
|
||||
Holder(View itemView) {
|
||||
super(itemView);
|
||||
text = findViewById(R.id.title);
|
||||
image = findViewById(R.id.image);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.arialyy.simple.download;
|
||||
package com.arialyy.simple.core.download;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Environment;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.arialyy.simple.download;
|
||||
package com.arialyy.simple.core.download;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.arialyy.simple.download;
|
||||
package com.arialyy.simple.core.download;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
@@ -23,7 +23,7 @@ import com.arialyy.aria.core.download.DownloadEntity;
|
||||
import com.arialyy.aria.util.CommonUtil;
|
||||
import com.arialyy.simple.R;
|
||||
import com.arialyy.simple.base.BaseModule;
|
||||
import com.arialyy.simple.download.multi_download.FileListEntity;
|
||||
import com.arialyy.simple.core.download.multi_download.FileListEntity;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.arialyy.simple.download;
|
||||
package com.arialyy.simple.core.download;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.arialyy.simple.download;
|
||||
package com.arialyy.simple.core.download;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.arialyy.simple.download;
|
||||
package com.arialyy.simple.core.download;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
@@ -35,7 +35,7 @@ import com.arialyy.frame.util.show.L;
|
||||
import com.arialyy.simple.R;
|
||||
import com.arialyy.simple.base.BaseActivity;
|
||||
import com.arialyy.simple.databinding.ActivityHighestPriorityBinding;
|
||||
import com.arialyy.simple.download.multi_download.DownloadAdapter;
|
||||
import com.arialyy.simple.core.download.multi_download.DownloadAdapter;
|
||||
import com.arialyy.simple.widget.HorizontalProgressBarWithNumber;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
@@ -1,4 +1,4 @@
|
||||
//package com.arialyy.simple.download
|
||||
//package com.arialyy.simple.core.download
|
||||
//
|
||||
//import android.os.Bundle
|
||||
//import android.os.Environment
|
||||
@@ -14,7 +14,7 @@
|
||||
// * limitations under the License.
|
||||
// */
|
||||
//
|
||||
//package com.arialyy.simple.download;
|
||||
//package com.arialyy.simple.core.download;
|
||||
//
|
||||
//import android.app.NotificationManager;
|
||||
//import android.content.Context;
|
||||
@@ -14,16 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.arialyy.simple.download;
|
||||
package com.arialyy.simple.core.download;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@@ -34,7 +30,6 @@ import android.widget.Toast;
|
||||
|
||||
import com.arialyy.annotations.Download;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.common.RequestEnum;
|
||||
import com.arialyy.aria.core.download.DownloadTarget;
|
||||
import com.arialyy.aria.core.download.DownloadTask;
|
||||
import com.arialyy.aria.core.inf.IEntity;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.arialyy.simple.download.fragment_download;
|
||||
package com.arialyy.simple.core.download.fragment_download;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
@@ -29,7 +29,6 @@ import com.arialyy.aria.util.CommonUtil;
|
||||
import com.arialyy.frame.core.AbsFragment;
|
||||
import com.arialyy.simple.R;
|
||||
import com.arialyy.simple.databinding.FragmentDownloadBinding;
|
||||
import com.arialyy.simple.widget.HorizontalProgressBarWithNumber;
|
||||
|
||||
/**
|
||||
* Created by lyy on 2017/1/4.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.arialyy.simple.download.fragment_download;
|
||||
package com.arialyy.simple.core.download.fragment_download;
|
||||
|
||||
import android.os.Bundle;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.arialyy.simple.download.group;
|
||||
package com.arialyy.simple.core.download.group;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.arialyy.simple.download.group;
|
||||
package com.arialyy.simple.core.download.group;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.arialyy.simple.download.group;
|
||||
package com.arialyy.simple.core.download.group;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.arialyy.simple.download.group;
|
||||
package com.arialyy.simple.core.download.group;
|
||||
|
||||
import android.content.Context;
|
||||
import com.arialyy.simple.R;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.arialyy.simple.download.multi_download;
|
||||
package com.arialyy.simple.core.download.multi_download;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.arialyy.simple.download.multi_download;
|
||||
package com.arialyy.simple.core.download.multi_download;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.arialyy.simple.download.multi_download;
|
||||
package com.arialyy.simple.core.download.multi_download;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
@@ -118,10 +118,10 @@ final class FileListAdapter extends AbsRVAdapter<FileListEntity, FileListAdapter
|
||||
|
||||
FileListHolder(View itemView) {
|
||||
super(itemView);
|
||||
name = getView(R.id.name);
|
||||
url = getView(R.id.download_url);
|
||||
path = getView(R.id.download_path);
|
||||
bt = getView(R.id.bt);
|
||||
name = findViewById(R.id.name);
|
||||
url = findViewById(R.id.download_url);
|
||||
path = findViewById(R.id.download_path);
|
||||
bt = findViewById(R.id.bt);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.arialyy.simple.download.multi_download;
|
||||
package com.arialyy.simple.core.download.multi_download;
|
||||
|
||||
/**
|
||||
* Created by AriaL on 2017/1/6.
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.arialyy.simple.download.multi_download;
|
||||
package com.arialyy.simple.core.download.multi_download;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.arialyy.simple.download.multi_download;
|
||||
package com.arialyy.simple.core.download.multi_download;
|
||||
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
import com.arialyy.aria.core.download.DownloadGroupEntity;
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.arialyy.simple.download.multi_download;
|
||||
package com.arialyy.simple.core.download.multi_download;
|
||||
|
||||
import android.content.Context;
|
||||
import com.arialyy.simple.base.BaseModule;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.arialyy.simple.download.multi_download;
|
||||
package com.arialyy.simple.core.download.multi_download;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
@@ -33,7 +33,7 @@ import com.arialyy.frame.util.FileUtil;
|
||||
import com.arialyy.simple.R;
|
||||
import com.arialyy.simple.base.BaseActivity;
|
||||
import com.arialyy.simple.databinding.ActivityMultiBinding;
|
||||
import com.arialyy.simple.download.DownloadModule;
|
||||
import com.arialyy.simple.core.download.DownloadModule;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.arialyy.simple.download.service_download;
|
||||
package com.arialyy.simple.core.download.service_download;
|
||||
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.arialyy.simple.download.service_download;
|
||||
package com.arialyy.simple.core.download.service_download;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.arialyy.simple.test;
|
||||
package com.arialyy.simple.core.test;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
@@ -8,6 +8,7 @@ import com.arialyy.aria.core.download.DTaskWrapper;
|
||||
import com.arialyy.simple.R;
|
||||
import com.arialyy.simple.base.BaseActivity;
|
||||
import com.arialyy.simple.databinding.ActivityTestBinding;
|
||||
import com.arialyy.simple.modlue.AnyRunnModule;
|
||||
|
||||
/**
|
||||
* Created by laoyuyu on 2018/4/13.
|
||||
@@ -1,15 +1,11 @@
|
||||
package com.arialyy.simple.test;
|
||||
package com.arialyy.simple.core.test;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import com.arialyy.annotations.Upload;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.common.ProtocolType;
|
||||
import com.arialyy.aria.core.common.RequestEnum;
|
||||
import com.arialyy.aria.core.upload.UploadTask;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.CommonUtil;
|
||||
import com.arialyy.simple.R;
|
||||
import com.arialyy.simple.base.BaseActivity;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.arialyy.simple.test;
|
||||
package com.arialyy.simple.core.test;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
@@ -10,7 +10,7 @@ import com.arialyy.frame.util.show.L;
|
||||
import com.arialyy.simple.R;
|
||||
import com.arialyy.simple.base.BaseActivity;
|
||||
import com.arialyy.simple.databinding.ActivityTestBinding;
|
||||
import com.arialyy.simple.download.group.GroupModule;
|
||||
import com.arialyy.simple.core.download.group.GroupModule;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.arialyy.simple.test;
|
||||
package com.arialyy.simple.core.test;
|
||||
|
||||
import android.os.Environment;
|
||||
import android.view.View;
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.arialyy.simple.upload;
|
||||
package com.arialyy.simple.core.upload;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
@@ -22,7 +22,6 @@ import com.arialyy.annotations.Upload;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.upload.UploadEntity;
|
||||
import com.arialyy.aria.core.upload.UploadTask;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.CommonUtil;
|
||||
import com.arialyy.frame.util.FileUtil;
|
||||
import com.arialyy.frame.util.show.T;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.arialyy.simple.upload;
|
||||
package com.arialyy.simple.core.upload;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
@@ -1,120 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
*
|
||||
* 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.arialyy.simple.download;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import com.arialyy.frame.permission.OnPermissionCallback;
|
||||
import com.arialyy.frame.permission.PermissionManager;
|
||||
import com.arialyy.frame.util.show.T;
|
||||
import com.arialyy.simple.R;
|
||||
import com.arialyy.simple.base.BaseActivity;
|
||||
import com.arialyy.simple.databinding.ActivityDownloadMeanBinding;
|
||||
import com.arialyy.simple.download.fragment_download.FragmentActivity;
|
||||
import com.arialyy.simple.download.multi_download.MultiTaskActivity;
|
||||
import com.arialyy.simple.download.service_download.DownloadService;
|
||||
|
||||
/**
|
||||
* Created by Lyy on 2016/10/13.
|
||||
*/
|
||||
public class DownloadActivity extends BaseActivity<ActivityDownloadMeanBinding> {
|
||||
Button mSigleBt;
|
||||
Button mMultiBt;
|
||||
Button mDialogBt;
|
||||
Button mPopBt;
|
||||
|
||||
@Override protected int setLayoutId() {
|
||||
return R.layout.activity_download_mean;
|
||||
}
|
||||
|
||||
@Override protected void init(Bundle savedInstanceState) {
|
||||
super.init(savedInstanceState);
|
||||
setTitle("Aria下载");
|
||||
mSigleBt = getBinding().singleTask;
|
||||
mMultiBt = getBinding().multiTask;
|
||||
mDialogBt = getBinding().dialogTask;
|
||||
mPopBt = getBinding().popTask;
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||
setEnable(true);
|
||||
} else { //6.0处理
|
||||
boolean hasPermission = PermissionManager.getInstance()
|
||||
.checkPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
if (hasPermission) {
|
||||
setEnable(true);
|
||||
} else {
|
||||
setEnable(false);
|
||||
PermissionManager.getInstance().requestPermission(this, new OnPermissionCallback() {
|
||||
@Override public void onSuccess(String... permissions) {
|
||||
setEnable(true);
|
||||
}
|
||||
|
||||
@Override public void onFail(String... permissions) {
|
||||
T.showShort(DownloadActivity.this, "没有文件读写权限");
|
||||
setEnable(false);
|
||||
}
|
||||
}, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setEnable(boolean enable) {
|
||||
mSigleBt.setEnabled(enable);
|
||||
mMultiBt.setEnabled(enable);
|
||||
mDialogBt.setEnabled(enable);
|
||||
mPopBt.setEnabled(enable);
|
||||
}
|
||||
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.highest_priority:
|
||||
startActivity(new Intent(this, HighestPriorityActivity.class));
|
||||
break;
|
||||
case R.id.service:
|
||||
startService(new Intent(this, DownloadService.class));
|
||||
break;
|
||||
case R.id.single_task:
|
||||
startActivity(new Intent(this, SingleTaskActivity.class));
|
||||
break;
|
||||
case R.id.multi_task:
|
||||
startActivity(new Intent(this, MultiTaskActivity.class));
|
||||
break;
|
||||
case R.id.dialog_task:
|
||||
DownloadDialog dialog = new DownloadDialog(this);
|
||||
|
||||
dialog.show();
|
||||
//DownloadDialogFragment dialog = new DownloadDialogFragment(this);
|
||||
//dialog.show(getSupportFragmentManager(), "dialog");
|
||||
break;
|
||||
case R.id.pop_task:
|
||||
DownloadPopupWindow pop = new DownloadPopupWindow(this);
|
||||
pop.showAtLocation(mRootView, Gravity.CENTER_VERTICAL, 0, 0);
|
||||
break;
|
||||
case R.id.fragment_task:
|
||||
startActivity(new Intent(this, FragmentActivity.class));
|
||||
break;
|
||||
case R.id.notification:
|
||||
//SimpleNotification notification = new SimpleNotification(this);
|
||||
//notification.start();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,25 @@
|
||||
package com.arialyy.simple.test;
|
||||
/*
|
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
*
|
||||
* 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.arialyy.simple.modlue;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
import com.arialyy.annotations.Download;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.common.RequestEnum;
|
||||
import com.arialyy.aria.core.download.DownloadTask;
|
||||
import com.arialyy.aria.util.CommonUtil;
|
||||
import com.arialyy.frame.util.show.L;
|
||||
@@ -62,7 +76,7 @@ public class AnyRunnModule {
|
||||
L.d(TAG, "md5Code ==> " + CommonUtil.getFileMD5(new File(task.getDownloadPath())));
|
||||
}
|
||||
|
||||
void start(String url) {
|
||||
public void start(String url) {
|
||||
mUrl = url;
|
||||
String path = Environment.getExternalStorageDirectory().getPath() + "/mmm2.mp4";
|
||||
Aria.download(this)
|
||||
@@ -72,7 +86,7 @@ public class AnyRunnModule {
|
||||
.start();
|
||||
}
|
||||
|
||||
void startFtp(String url) {
|
||||
public void startFtp(String url) {
|
||||
mUrl = url;
|
||||
Aria.download(this)
|
||||
.loadFtp(url)
|
||||
@@ -85,15 +99,15 @@ public class AnyRunnModule {
|
||||
.start();
|
||||
}
|
||||
|
||||
void stop(String url) {
|
||||
public void stop(String url) {
|
||||
Aria.download(this).load(url).stop();
|
||||
}
|
||||
|
||||
void cancel(String url) {
|
||||
public void cancel(String url) {
|
||||
Aria.download(this).load(url).cancel();
|
||||
}
|
||||
|
||||
void unRegister() {
|
||||
public void unRegister() {
|
||||
Aria.download(this).unRegister();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
*
|
||||
* 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.arialyy.simple.modlue;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import com.arialyy.frame.module.AbsModule;
|
||||
import com.arialyy.simple.MainActivity;
|
||||
import com.arialyy.simple.R;
|
||||
import com.arialyy.simple.to.NormalTo;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 通用Modle块
|
||||
*/
|
||||
public class CommonModule extends AbsModule {
|
||||
public CommonModule(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public void startNextActivity(NormalTo to, Class clazz) {
|
||||
Intent intent = new Intent(getContext(), clazz);
|
||||
intent.putExtra(MainActivity.KEY_MAIN_DATA, to);
|
||||
getContext().startActivity(intent);
|
||||
}
|
||||
|
||||
public List<NormalTo> getDownloadData() {
|
||||
List<NormalTo> list = new ArrayList<>();
|
||||
String[] titles = getContext().getResources().getStringArray(R.array.download_items);
|
||||
int[] icons = new int[] {
|
||||
R.drawable.ic_http,
|
||||
R.drawable.ic_http_group,
|
||||
R.drawable.ic_top,
|
||||
R.drawable.ic_server,
|
||||
R.drawable.ic_windows
|
||||
};
|
||||
int i = 0;
|
||||
for (String title : titles) {
|
||||
NormalTo to = new NormalTo();
|
||||
to.icon = icons[i];
|
||||
to.title = title;
|
||||
i++;
|
||||
list.add(to);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<NormalTo> getMainData() {
|
||||
List<NormalTo> list = new ArrayList<>();
|
||||
String[] titles = getContext().getResources().getStringArray(R.array.main_items);
|
||||
int[] icons = new int[] {
|
||||
R.drawable.ic_http,
|
||||
R.drawable.ic_http,
|
||||
R.drawable.ic_http_group,
|
||||
R.drawable.ic_ftp,
|
||||
R.drawable.ic_ftp_dir,
|
||||
R.drawable.ic_ftp
|
||||
};
|
||||
int i = 0;
|
||||
for (String title : titles) {
|
||||
NormalTo to = new NormalTo();
|
||||
to.icon = icons[i];
|
||||
to.title = title;
|
||||
i++;
|
||||
list.add(to);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
54
app/src/main/java/com/arialyy/simple/to/NormalTo.java
Normal file
54
app/src/main/java/com/arialyy/simple/to/NormalTo.java
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||
*
|
||||
* 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.arialyy.simple.to;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/**
|
||||
* 简单列表对象
|
||||
*/
|
||||
public class NormalTo implements Parcelable {
|
||||
public int icon;
|
||||
public String title;
|
||||
|
||||
@Override public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(this.icon);
|
||||
dest.writeString(this.title);
|
||||
}
|
||||
|
||||
public NormalTo() {
|
||||
}
|
||||
|
||||
protected NormalTo(Parcel in) {
|
||||
this.icon = in.readInt();
|
||||
this.title = in.readString();
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<NormalTo> CREATOR = new Parcelable.Creator<NormalTo>() {
|
||||
@Override public NormalTo createFromParcel(Parcel source) {
|
||||
return new NormalTo(source);
|
||||
}
|
||||
|
||||
@Override public NormalTo[] newArray(int size) {
|
||||
return new NormalTo[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user