parent
							
								
									f107a9852b
								
							
						
					
					
						commit
						42c374e275
					
				@ -1,114 +1,37 @@ | 
				
			||||
/* | 
				
			||||
 * 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; | 
				
			||||
 | 
				
			||||
import android.Manifest; | 
				
			||||
import android.content.Intent; | 
				
			||||
import android.os.Build; | 
				
			||||
import android.os.Bundle; | 
				
			||||
import android.support.v7.widget.Toolbar; | 
				
			||||
import android.view.Gravity; | 
				
			||||
import android.view.View; | 
				
			||||
import android.widget.Button; | 
				
			||||
import butterknife.Bind; | 
				
			||||
import com.arialyy.frame.permission.OnPermissionCallback; | 
				
			||||
import com.arialyy.frame.permission.PermissionManager; | 
				
			||||
import com.arialyy.frame.util.show.T; | 
				
			||||
import butterknife.OnClick; | 
				
			||||
import com.arialyy.simple.base.BaseActivity; | 
				
			||||
import com.arialyy.simple.databinding.ActivityMainBinding; | 
				
			||||
import com.arialyy.simple.dialog_task.DownloadDialog; | 
				
			||||
import com.arialyy.simple.fragment_task.FragmentActivity; | 
				
			||||
import com.arialyy.simple.multi_task.MultiTaskActivity; | 
				
			||||
import com.arialyy.simple.notification.SimpleNotification; | 
				
			||||
import com.arialyy.simple.pop_task.DownloadPopupWindow; | 
				
			||||
import com.arialyy.simple.single_task.SingleTaskActivity; | 
				
			||||
import com.arialyy.simple.download.DownloadActivity; | 
				
			||||
import com.arialyy.simple.upload.UploadActivity; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * Created by Lyy on 2016/10/13. | 
				
			||||
 * Created by Aria.Lao on 2017/3/1. | 
				
			||||
 */ | 
				
			||||
public class MainActivity extends BaseActivity<ActivityMainBinding> { | 
				
			||||
  @Bind(R.id.toolbar) Toolbar mBar; | 
				
			||||
  @Bind(R.id.single_task) Button mSigleBt; | 
				
			||||
  @Bind(R.id.multi_task) Button mMultiBt; | 
				
			||||
  @Bind(R.id.dialog_task) Button mDialogBt; | 
				
			||||
  @Bind(R.id.pop_task) Button mPopBt; | 
				
			||||
 | 
				
			||||
  @Override protected int setLayoutId() { | 
				
			||||
    return R.layout.activity_main; | 
				
			||||
  } | 
				
			||||
  @Bind(R.id.toolbar) Toolbar mBar; | 
				
			||||
 | 
				
			||||
  @Override protected void init(Bundle savedInstanceState) { | 
				
			||||
    super.init(savedInstanceState); | 
				
			||||
    setSupportActionBar(mBar); | 
				
			||||
    mBar.setTitle("多线程多任务下载"); | 
				
			||||
    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); | 
				
			||||
    mBar.setTitle("Aria  Demo"); | 
				
			||||
  } | 
				
			||||
 | 
				
			||||
          @Override public void onFail(String... permissions) { | 
				
			||||
            T.showShort(MainActivity.this, "没有文件读写权限"); | 
				
			||||
            setEnable(false); | 
				
			||||
          } | 
				
			||||
        }, Manifest.permission.WRITE_EXTERNAL_STORAGE); | 
				
			||||
      } | 
				
			||||
    } | 
				
			||||
  @Override protected int setLayoutId() { | 
				
			||||
    return R.layout.activity_main; | 
				
			||||
  } | 
				
			||||
 | 
				
			||||
  private void setEnable(boolean enable) { | 
				
			||||
    mSigleBt.setEnabled(enable); | 
				
			||||
    mMultiBt.setEnabled(enable); | 
				
			||||
    mDialogBt.setEnabled(enable); | 
				
			||||
    mPopBt.setEnabled(enable); | 
				
			||||
  @OnClick(R.id.download) public void downloadDemo() { | 
				
			||||
    startActivity(new Intent(this, DownloadActivity.class)); | 
				
			||||
  } | 
				
			||||
 | 
				
			||||
  public void onClick(View view) { | 
				
			||||
    switch (view.getId()) { | 
				
			||||
      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(); | 
				
			||||
        break; | 
				
			||||
      case R.id.pop_task: | 
				
			||||
        DownloadPopupWindow pop = new DownloadPopupWindow(this); | 
				
			||||
        //pop.showAsDropDown(mRootView);
 | 
				
			||||
        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; | 
				
			||||
    } | 
				
			||||
  @OnClick(R.id.upload) public void uploadDemo() { | 
				
			||||
    startActivity(new Intent(this, UploadActivity.class)); | 
				
			||||
  } | 
				
			||||
} | 
				
			||||
@ -0,0 +1,111 @@ | 
				
			||||
/* | 
				
			||||
 * 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.support.v7.widget.Toolbar; | 
				
			||||
import android.view.Gravity; | 
				
			||||
import android.view.View; | 
				
			||||
import android.widget.Button; | 
				
			||||
import butterknife.Bind; | 
				
			||||
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; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * Created by Lyy on 2016/10/13. | 
				
			||||
 */ | 
				
			||||
public class DownloadActivity extends BaseActivity<ActivityDownloadMeanBinding> { | 
				
			||||
  @Bind(R.id.toolbar) Toolbar mBar; | 
				
			||||
  @Bind(R.id.single_task) Button mSigleBt; | 
				
			||||
  @Bind(R.id.multi_task) Button mMultiBt; | 
				
			||||
  @Bind(R.id.dialog_task) Button mDialogBt; | 
				
			||||
  @Bind(R.id.pop_task) Button mPopBt; | 
				
			||||
 | 
				
			||||
  @Override protected int setLayoutId() { | 
				
			||||
    return R.layout.activity_download_mean; | 
				
			||||
  } | 
				
			||||
 | 
				
			||||
  @Override protected void init(Bundle savedInstanceState) { | 
				
			||||
    super.init(savedInstanceState); | 
				
			||||
    setSupportActionBar(mBar); | 
				
			||||
    mBar.setTitle("多线程多任务下载"); | 
				
			||||
    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.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(); | 
				
			||||
        break; | 
				
			||||
      case R.id.pop_task: | 
				
			||||
        DownloadPopupWindow pop = new DownloadPopupWindow(this); | 
				
			||||
        //pop.showAsDropDown(mRootView);
 | 
				
			||||
        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,4 +1,4 @@ | 
				
			||||
package com.arialyy.simple.dialog_task; | 
				
			||||
package com.arialyy.simple.download; | 
				
			||||
 | 
				
			||||
import android.content.Context; | 
				
			||||
import android.os.Environment; | 
				
			||||
@ -1,4 +1,4 @@ | 
				
			||||
package com.arialyy.simple.pop_task; | 
				
			||||
package com.arialyy.simple.download; | 
				
			||||
 | 
				
			||||
import android.content.Context; | 
				
			||||
import android.graphics.Color; | 
				
			||||
@ -1,4 +1,4 @@ | 
				
			||||
package com.arialyy.simple.notification; | 
				
			||||
package com.arialyy.simple.download; | 
				
			||||
 | 
				
			||||
import android.app.NotificationManager; | 
				
			||||
import android.content.Context; | 
				
			||||
@ -1,4 +1,4 @@ | 
				
			||||
package com.arialyy.simple.fragment_task; | 
				
			||||
package com.arialyy.simple.download.fragment_download; | 
				
			||||
 | 
				
			||||
import android.os.Bundle; | 
				
			||||
import android.os.Environment; | 
				
			||||
@ -1,4 +1,4 @@ | 
				
			||||
package com.arialyy.simple.fragment_task; | 
				
			||||
package com.arialyy.simple.download.fragment_download; | 
				
			||||
 | 
				
			||||
import com.arialyy.simple.R; | 
				
			||||
import com.arialyy.simple.base.BaseActivity; | 
				
			||||
@ -1,4 +1,4 @@ | 
				
			||||
package com.arialyy.simple.multi_task; | 
				
			||||
package com.arialyy.simple.download.multi_download; | 
				
			||||
 | 
				
			||||
import android.content.Context; | 
				
			||||
import android.view.View; | 
				
			||||
@ -1,4 +1,4 @@ | 
				
			||||
package com.arialyy.simple.multi_task; | 
				
			||||
package com.arialyy.simple.download.multi_download; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * Created by AriaL on 2017/1/6. | 
				
			||||
@ -1,71 +0,0 @@ | 
				
			||||
package com.arialyy.simple; | 
				
			||||
 | 
				
			||||
import android.view.View; | 
				
			||||
import android.widget.ProgressBar; | 
				
			||||
import butterknife.Bind; | 
				
			||||
import com.arialyy.aria.core.upload.IUploadListener; | 
				
			||||
import com.arialyy.aria.core.upload.UploadEntity; | 
				
			||||
import com.arialyy.aria.core.upload.UploadTaskEntity; | 
				
			||||
import com.arialyy.aria.core.upload.UploadUtil; | 
				
			||||
import com.arialyy.simple.base.BaseActivity; | 
				
			||||
import com.arialyy.simple.databinding.ActivityUploadBinding; | 
				
			||||
import com.arialyy.simple.widget.HorizontalProgressBarWithNumber; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * Created by Aria.Lao on 2017/2/9. | 
				
			||||
 */ | 
				
			||||
 | 
				
			||||
public class upload extends BaseActivity<ActivityUploadBinding> { | 
				
			||||
 | 
				
			||||
  @Bind(R.id.pb) HorizontalProgressBarWithNumber mPb; | 
				
			||||
 | 
				
			||||
  @Override protected int setLayoutId() { | 
				
			||||
    return R.layout.activity_upload; | 
				
			||||
  } | 
				
			||||
 | 
				
			||||
  public void onClick(View view) { | 
				
			||||
    UploadEntity entity = new UploadEntity(); | 
				
			||||
    entity.setFilePath("/sdcard/Download/test.zip"); | 
				
			||||
    entity.setFileName("test.pdf"); | 
				
			||||
    UploadTaskEntity taskEntity = new UploadTaskEntity(entity); | 
				
			||||
    taskEntity.uploadUrl = "http://172.18.104.189:8080/upload/sign_file"; | 
				
			||||
    taskEntity.attachment = "file"; | 
				
			||||
    UploadUtil util = new UploadUtil(taskEntity, new IUploadListener() { | 
				
			||||
      long fileSize = 0; | 
				
			||||
 | 
				
			||||
      @Override public void onPre() { | 
				
			||||
 | 
				
			||||
      } | 
				
			||||
 | 
				
			||||
      @Override public void onStart(long fileSize) { | 
				
			||||
        this.fileSize = fileSize; | 
				
			||||
      } | 
				
			||||
 | 
				
			||||
      @Override public void onResume(long resumeLocation) { | 
				
			||||
 | 
				
			||||
      } | 
				
			||||
 | 
				
			||||
      @Override public void onStop(long stopLocation) { | 
				
			||||
 | 
				
			||||
      } | 
				
			||||
 | 
				
			||||
      @Override public void onProgress(long currentLocation) { | 
				
			||||
        int p = (int) (currentLocation * 100 / fileSize); | 
				
			||||
        mPb.setProgress(p); | 
				
			||||
      } | 
				
			||||
 | 
				
			||||
      @Override public void onCancel() { | 
				
			||||
 | 
				
			||||
      } | 
				
			||||
 | 
				
			||||
      @Override public void onComplete() { | 
				
			||||
 | 
				
			||||
      } | 
				
			||||
 | 
				
			||||
      @Override public void onFail() { | 
				
			||||
 | 
				
			||||
      } | 
				
			||||
    }); | 
				
			||||
    util.start(); | 
				
			||||
  } | 
				
			||||
} | 
				
			||||
@ -0,0 +1,115 @@ | 
				
			||||
package com.arialyy.simple.upload; | 
				
			||||
 | 
				
			||||
import android.os.Handler; | 
				
			||||
import android.os.Message; | 
				
			||||
import butterknife.Bind; | 
				
			||||
import butterknife.OnClick; | 
				
			||||
import com.arialyy.aria.core.Aria; | 
				
			||||
import com.arialyy.aria.core.upload.UploadTask; | 
				
			||||
import com.arialyy.frame.util.FileUtil; | 
				
			||||
import com.arialyy.frame.util.show.L; | 
				
			||||
import com.arialyy.frame.util.show.T; | 
				
			||||
import com.arialyy.simple.R; | 
				
			||||
import com.arialyy.simple.base.BaseActivity; | 
				
			||||
import com.arialyy.simple.databinding.ActivityUploadMeanBinding; | 
				
			||||
import com.arialyy.simple.widget.HorizontalProgressBarWithNumber; | 
				
			||||
import java.lang.ref.WeakReference; | 
				
			||||
 | 
				
			||||
/** | 
				
			||||
 * Created by Aria.Lao on 2017/2/9. | 
				
			||||
 */ | 
				
			||||
 | 
				
			||||
public class UploadActivity extends BaseActivity<ActivityUploadMeanBinding> { | 
				
			||||
  @Bind(R.id.pb) HorizontalProgressBarWithNumber mPb; | 
				
			||||
  private static final int START = 0; | 
				
			||||
  private static final int STOP = 1; | 
				
			||||
  private static final int CANCEL = 2; | 
				
			||||
  private static final int RUNNING = 3; | 
				
			||||
  private static final int COMPLETE = 4; | 
				
			||||
 | 
				
			||||
  private static final String FILE_PATH = "/sdcard/Download/test.zip"; | 
				
			||||
 | 
				
			||||
  private Handler mHandler = new Handler() { | 
				
			||||
    @Override public void handleMessage(Message msg) { | 
				
			||||
      super.handleMessage(msg); | 
				
			||||
      UploadTask task = (UploadTask) msg.obj; | 
				
			||||
      switch (msg.what) { | 
				
			||||
        case START: | 
				
			||||
          getBinding().setFileSize(FileUtil.formatFileSize(task.getFileSize())); | 
				
			||||
          break; | 
				
			||||
        case STOP: | 
				
			||||
          mPb.setProgress(0); | 
				
			||||
          break; | 
				
			||||
        case CANCEL: | 
				
			||||
          mPb.setProgress(0); | 
				
			||||
          break; | 
				
			||||
        case RUNNING: | 
				
			||||
          int p = (int) (task.getCurrentProgress() * 100 / task.getFileSize()); | 
				
			||||
          L.d(TAG, "p ==> " + p); | 
				
			||||
          mPb.setProgress(p); | 
				
			||||
          break; | 
				
			||||
        case COMPLETE: | 
				
			||||
          T.showShort(UploadActivity.this, "上传完成"); | 
				
			||||
          break; | 
				
			||||
      } | 
				
			||||
    } | 
				
			||||
  }; | 
				
			||||
 | 
				
			||||
  @Override protected int setLayoutId() { | 
				
			||||
    return R.layout.activity_upload_mean; | 
				
			||||
  } | 
				
			||||
 | 
				
			||||
  @OnClick(R.id.upload) void upload() { | 
				
			||||
    Aria.upload(this) | 
				
			||||
        .load(FILE_PATH) | 
				
			||||
        .setUploadUrl("http://172.18.104.50:8080/UploadActivity/sign_file") | 
				
			||||
        .setAttachment("file") | 
				
			||||
        .start(); | 
				
			||||
  } | 
				
			||||
 | 
				
			||||
  @OnClick(R.id.stop) void stop() { | 
				
			||||
    Aria.upload(this).load(FILE_PATH).stop(); | 
				
			||||
  } | 
				
			||||
 | 
				
			||||
  @OnClick(R.id.remove) void remove() { | 
				
			||||
    Aria.upload(this).load(FILE_PATH).cancel(); | 
				
			||||
  } | 
				
			||||
 | 
				
			||||
  @Override protected void onResume() { | 
				
			||||
    super.onResume(); | 
				
			||||
    Aria.upload(this).addSchedulerListener(new UploadListener(mHandler)); | 
				
			||||
  } | 
				
			||||
 | 
				
			||||
  static class UploadListener extends Aria.UploadSchedulerListener { | 
				
			||||
    WeakReference<Handler> handler; | 
				
			||||
 | 
				
			||||
    UploadListener(Handler handler) { | 
				
			||||
      this.handler = new WeakReference<>(handler); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    @Override public void onTaskStart(UploadTask task) { | 
				
			||||
      super.onTaskStart(task); | 
				
			||||
      handler.get().obtainMessage(START, task).sendToTarget(); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    @Override public void onTaskStop(UploadTask task) { | 
				
			||||
      super.onTaskStop(task); | 
				
			||||
      handler.get().obtainMessage(STOP, task).sendToTarget(); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    @Override public void onTaskCancel(UploadTask task) { | 
				
			||||
      super.onTaskCancel(task); | 
				
			||||
      handler.get().obtainMessage(CANCEL, task).sendToTarget(); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    @Override public void onTaskRunning(UploadTask task) { | 
				
			||||
      super.onTaskRunning(task); | 
				
			||||
      handler.get().obtainMessage(RUNNING, task).sendToTarget(); | 
				
			||||
    } | 
				
			||||
 | 
				
			||||
    @Override public void onTaskComplete(UploadTask task) { | 
				
			||||
      super.onTaskComplete(task); | 
				
			||||
      handler.get().obtainMessage(COMPLETE, task).sendToTarget(); | 
				
			||||
    } | 
				
			||||
  } | 
				
			||||
} | 
				
			||||
@ -0,0 +1,69 @@ | 
				
			||||
<?xml version="1.0" encoding="utf-8"?> | 
				
			||||
<layout xmlns:android="http://schemas.android.com/apk/res/android" | 
				
			||||
    > | 
				
			||||
 | 
				
			||||
  <LinearLayout | 
				
			||||
      android:layout_width="match_parent" | 
				
			||||
      android:layout_height="match_parent" | 
				
			||||
      android:fitsSystemWindows="true" | 
				
			||||
      android:orientation="vertical" | 
				
			||||
      > | 
				
			||||
 | 
				
			||||
    <include layout="@layout/layout_bar"/> | 
				
			||||
 | 
				
			||||
    <Button | 
				
			||||
        android:id="@+id/single_task" | 
				
			||||
        android:layout_width="match_parent" | 
				
			||||
        android:layout_height="wrap_content" | 
				
			||||
        android:onClick="onClick" | 
				
			||||
        android:text="单任务下载" | 
				
			||||
        style="?buttonBarButtonStyle" | 
				
			||||
        /> | 
				
			||||
 | 
				
			||||
    <Button | 
				
			||||
        android:id="@+id/multi_task" | 
				
			||||
        android:layout_width="match_parent" | 
				
			||||
        android:layout_height="wrap_content" | 
				
			||||
        android:onClick="onClick" | 
				
			||||
        android:text="多任务下载" | 
				
			||||
        style="?buttonBarButtonStyle" | 
				
			||||
        /> | 
				
			||||
 | 
				
			||||
    <Button | 
				
			||||
        android:id="@+id/dialog_task" | 
				
			||||
        android:layout_width="match_parent" | 
				
			||||
        android:layout_height="wrap_content" | 
				
			||||
        android:onClick="onClick" | 
				
			||||
        android:text="在dialog中使用" | 
				
			||||
        style="?buttonBarButtonStyle" | 
				
			||||
        /> | 
				
			||||
 | 
				
			||||
    <Button | 
				
			||||
        android:id="@+id/pop_task" | 
				
			||||
        android:layout_width="match_parent" | 
				
			||||
        android:layout_height="wrap_content" | 
				
			||||
        android:onClick="onClick" | 
				
			||||
        android:text="在popupwindow中使用" | 
				
			||||
        style="?buttonBarButtonStyle" | 
				
			||||
        /> | 
				
			||||
 | 
				
			||||
    <Button | 
				
			||||
        android:id="@+id/fragment_task" | 
				
			||||
        android:layout_width="match_parent" | 
				
			||||
        android:layout_height="wrap_content" | 
				
			||||
        android:onClick="onClick" | 
				
			||||
        android:text="在Fragment中使用" | 
				
			||||
        style="?buttonBarButtonStyle" | 
				
			||||
        /> | 
				
			||||
 | 
				
			||||
    <Button | 
				
			||||
        android:id="@+id/notification" | 
				
			||||
        android:layout_width="match_parent" | 
				
			||||
        android:layout_height="wrap_content" | 
				
			||||
        android:onClick="onClick" | 
				
			||||
        android:text="在Notification中使用" | 
				
			||||
        style="?buttonBarButtonStyle" | 
				
			||||
        /> | 
				
			||||
 | 
				
			||||
  </LinearLayout> | 
				
			||||
</layout> | 
				
			||||
@ -1,69 +1,28 @@ | 
				
			||||
<?xml version="1.0" encoding="utf-8"?> | 
				
			||||
<layout xmlns:android="http://schemas.android.com/apk/res/android" | 
				
			||||
    > | 
				
			||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"> | 
				
			||||
 | 
				
			||||
  <LinearLayout | 
				
			||||
      android:layout_width="match_parent" | 
				
			||||
      android:layout_height="match_parent" | 
				
			||||
      android:fitsSystemWindows="true" | 
				
			||||
      android:orientation="vertical" | 
				
			||||
      > | 
				
			||||
 | 
				
			||||
    <include layout="@layout/layout_bar"/> | 
				
			||||
 | 
				
			||||
    <Button | 
				
			||||
        android:id="@+id/single_task" | 
				
			||||
        android:layout_width="match_parent" | 
				
			||||
        android:layout_height="wrap_content" | 
				
			||||
        android:onClick="onClick" | 
				
			||||
        android:text="单任务下载" | 
				
			||||
        style="?buttonBarButtonStyle" | 
				
			||||
        /> | 
				
			||||
 | 
				
			||||
    <Button | 
				
			||||
        android:id="@+id/multi_task" | 
				
			||||
        android:layout_width="match_parent" | 
				
			||||
        android:layout_height="wrap_content" | 
				
			||||
        android:onClick="onClick" | 
				
			||||
        android:text="多任务下载" | 
				
			||||
        style="?buttonBarButtonStyle" | 
				
			||||
        /> | 
				
			||||
 | 
				
			||||
    <Button | 
				
			||||
        android:id="@+id/dialog_task" | 
				
			||||
        android:id="@+id/download" | 
				
			||||
        android:layout_width="match_parent" | 
				
			||||
        android:layout_height="wrap_content" | 
				
			||||
        android:onClick="onClick" | 
				
			||||
        android:text="在dialog中使用" | 
				
			||||
        android:text="下载  demo" | 
				
			||||
        style="?buttonBarButtonStyle" | 
				
			||||
        /> | 
				
			||||
 | 
				
			||||
    <Button | 
				
			||||
        android:id="@+id/pop_task" | 
				
			||||
        android:id="@+id/upload" | 
				
			||||
        android:layout_width="match_parent" | 
				
			||||
        android:layout_height="wrap_content" | 
				
			||||
        android:onClick="onClick" | 
				
			||||
        android:text="在popupwindow中使用" | 
				
			||||
        android:text="上传  demo" | 
				
			||||
        style="?buttonBarButtonStyle" | 
				
			||||
        /> | 
				
			||||
 | 
				
			||||
    <Button | 
				
			||||
        android:id="@+id/fragment_task" | 
				
			||||
        android:layout_width="match_parent" | 
				
			||||
        android:layout_height="wrap_content" | 
				
			||||
        android:onClick="onClick" | 
				
			||||
        android:text="在Fragment中使用" | 
				
			||||
        style="?buttonBarButtonStyle" | 
				
			||||
        /> | 
				
			||||
 | 
				
			||||
    <Button | 
				
			||||
        android:id="@+id/notification" | 
				
			||||
        android:layout_width="match_parent" | 
				
			||||
        android:layout_height="wrap_content" | 
				
			||||
        android:onClick="onClick" | 
				
			||||
        android:text="在Notification中使用" | 
				
			||||
        style="?buttonBarButtonStyle" | 
				
			||||
        /> | 
				
			||||
 | 
				
			||||
  </LinearLayout> | 
				
			||||
</layout> | 
				
			||||
 | 
				
			||||
@ -1,31 +0,0 @@ | 
				
			||||
<?xml version="1.0" encoding="utf-8"?> | 
				
			||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"> | 
				
			||||
 | 
				
			||||
  <LinearLayout | 
				
			||||
      android:layout_width="match_parent" | 
				
			||||
      android:layout_height="match_parent" | 
				
			||||
      android:orientation="vertical" | 
				
			||||
      > | 
				
			||||
    <include layout="@layout/layout_bar"/> | 
				
			||||
 | 
				
			||||
    <com.arialyy.simple.widget.HorizontalProgressBarWithNumber | 
				
			||||
        android:id="@+id/pb" | 
				
			||||
        android:layout_width="wrap_content" | 
				
			||||
        android:layout_height="20dp" | 
				
			||||
        android:layout_margin="16dp" | 
				
			||||
        android:max="100" | 
				
			||||
        style="?android:attr/progressBarStyleHorizontal" | 
				
			||||
        /> | 
				
			||||
 | 
				
			||||
    <Button | 
				
			||||
        android:id="@+id/single_task" | 
				
			||||
        android:layout_width="match_parent" | 
				
			||||
        android:layout_height="wrap_content" | 
				
			||||
        android:onClick="onClick" | 
				
			||||
        android:text="上传" | 
				
			||||
        style="?buttonBarButtonStyle" | 
				
			||||
        /> | 
				
			||||
 | 
				
			||||
  </LinearLayout> | 
				
			||||
 | 
				
			||||
</layout> | 
				
			||||
@ -0,0 +1,97 @@ | 
				
			||||
<?xml version="1.0" encoding="utf-8"?> | 
				
			||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"> | 
				
			||||
 | 
				
			||||
  <data> | 
				
			||||
    <variable | 
				
			||||
        name="fileSize" | 
				
			||||
        type="String" | 
				
			||||
        /> | 
				
			||||
    <variable | 
				
			||||
        name="speed" | 
				
			||||
        type="String" | 
				
			||||
        /> | 
				
			||||
 | 
				
			||||
  </data> | 
				
			||||
 | 
				
			||||
  <LinearLayout | 
				
			||||
      android:layout_width="match_parent" | 
				
			||||
      android:layout_height="match_parent" | 
				
			||||
      android:orientation="vertical" | 
				
			||||
      > | 
				
			||||
    <include layout="@layout/layout_bar"/> | 
				
			||||
 | 
				
			||||
    <RelativeLayout | 
				
			||||
        android:id="@+id/top_bar" | 
				
			||||
        android:layout_width="match_parent" | 
				
			||||
        android:layout_height="wrap_content" | 
				
			||||
        android:layout_below="@+id/toolbar" | 
				
			||||
        > | 
				
			||||
 | 
				
			||||
      <com.arialyy.simple.widget.HorizontalProgressBarWithNumber | 
				
			||||
          android:id="@+id/pb" | 
				
			||||
          android:layout_width="wrap_content" | 
				
			||||
          android:layout_height="20dp" | 
				
			||||
          android:layout_margin="16dp" | 
				
			||||
          android:layout_toLeftOf="@+id/size" | 
				
			||||
          android:max="100" | 
				
			||||
          style="?android:attr/progressBarStyleHorizontal" | 
				
			||||
          /> | 
				
			||||
 | 
				
			||||
      <TextView | 
				
			||||
          android:id="@+id/size" | 
				
			||||
          android:layout_width="wrap_content" | 
				
			||||
          android:layout_height="wrap_content" | 
				
			||||
          android:layout_alignParentRight="true" | 
				
			||||
          android:layout_centerVertical="true" | 
				
			||||
          android:layout_marginRight="16dp" | 
				
			||||
          android:text="@{fileSize}" | 
				
			||||
          /> | 
				
			||||
    </RelativeLayout> | 
				
			||||
 | 
				
			||||
 | 
				
			||||
    <LinearLayout | 
				
			||||
        android:layout_width="match_parent" | 
				
			||||
        android:layout_height="wrap_content" | 
				
			||||
        android:orientation="horizontal" | 
				
			||||
        > | 
				
			||||
 | 
				
			||||
      <TextView | 
				
			||||
          android:id="@+id/speed" | 
				
			||||
          android:layout_width="wrap_content" | 
				
			||||
          android:layout_height="wrap_content" | 
				
			||||
          android:layout_marginLeft="16dp" | 
				
			||||
          android:text="@{speed}" | 
				
			||||
          /> | 
				
			||||
 | 
				
			||||
      <Button | 
				
			||||
          android:id="@+id/upload" | 
				
			||||
          android:layout_width="match_parent" | 
				
			||||
          android:layout_height="wrap_content" | 
				
			||||
          android:layout_weight="1" | 
				
			||||
          android:text="上传" | 
				
			||||
          style="?buttonBarButtonStyle" | 
				
			||||
          /> | 
				
			||||
 | 
				
			||||
      <Button | 
				
			||||
          android:id="@+id/stop" | 
				
			||||
          android:layout_width="match_parent" | 
				
			||||
          android:layout_height="wrap_content" | 
				
			||||
          android:layout_weight="1" | 
				
			||||
          android:text="停止" | 
				
			||||
          style="?buttonBarButtonStyle" | 
				
			||||
          /> | 
				
			||||
 | 
				
			||||
      <Button | 
				
			||||
          android:id="@+id/remove" | 
				
			||||
          android:layout_width="match_parent" | 
				
			||||
          android:layout_height="wrap_content" | 
				
			||||
          android:layout_weight="1" | 
				
			||||
          android:text="删除" | 
				
			||||
          style="?buttonBarButtonStyle" | 
				
			||||
          /> | 
				
			||||
 | 
				
			||||
    </LinearLayout> | 
				
			||||
 | 
				
			||||
  </LinearLayout> | 
				
			||||
 | 
				
			||||
</layout> | 
				
			||||
					Loading…
					
					
				
		Reference in new issue