package com.liulishuo.filedownloader.demo;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

import com.liulishuo.filedownloader.FileDownloadMonitor;
import com.liulishuo.filedownloader.FileDownloader;
import com.liulishuo.filedownloader.demo.performance.PerformanceTestActivity;

/**
 * Created by Jacksgong on 12/17/15.
 */
public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        FileDownloadMonitor.setGlobalMonitor(GlobalMonitor.getImpl());
    }

    public void onClickMultitask(final View view) {
        startActivity(new Intent(this, MultitaskTestActivity.class));
    }

    public void onClickSingle(final View view) {
        startActivity(new Intent(this, SingleTaskTestActivity.class));
    }

    public void onClickHybridTest(final View view) {
        startActivity(new Intent(this, HybridTestActivity.class));
    }

    public void onClickTasksManager(final View view) {
        startActivity(new Intent(this, TasksManagerDemoActivity.class));
    }

    public void onClickPerformance(final View view) {
        startActivity(new Intent(this, PerformanceTestActivity.class));
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return super.onCreateOptionsMenu(menu);
    }


    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.menu_github:
                openGitHub();
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }

    private void openGitHub() {
        Uri uri = Uri.parse(getString(R.string.app_github_url));
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        startActivity(intent);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        // unbind and stop service manually if idle
        FileDownloader.getImpl().unBindServiceIfIdle();

        FileDownloadMonitor.releaseGlobalMonitor();
    }
}

@@ -699,24 +699,245 @@
 ity_main);%0A%0A
+        // %E8%BF%99%E6%98%AF%E5%8F%AA%E6%98%AF%E4%B8%BA%E4%BA%86%E5%85%A8%E5%B1%80%E7%9B%91%E6%8E%A7%E3%80%82%E5%A6%82%E6%9E%9C%E4%BD%A0%E6%9C%89%E9%9C%80%E6%B1%82%E9%9C%80%E8%A6%81%E5%85%A8%E5%B1%80%E7%9B%91%E6%8E%A7%EF%BC%88%E6%AF%94%E5%A6%82%E7%94%A8%E4%BA%8E%E6%89%93%E7%82%B9/%E7%BB%9F%E8%AE%A1%EF%BC%89%E5%8F%AF%E4%BB%A5%E4%BD%BF%E7%94%A8%E8%BF%99%E4%B8%AA%E6%96%B9%E5%BC%8F%EF%BC%8C%E5%A6%82%E6%9E%9C%E6%B2%A1%E6%9C%89%E7%B1%BB%E4%BC%BC%E9%9C%80%E6%B1%82%E5%B0%B1%E4%B8%8D%E9%9C%80%E8%A6%81%0A        // You do not have to add below code to your project only if you need monitor the global%0A        // FileDownloader Engine for statistic or others%0A
         File

add necessary tips in demo