public class MVCActivity extends AppCompatActivity {
    private static final String TAG = "MVCActivity";

    private Context mContext;
    private ImageView mImageView;
    private ProgressDialog progressDialog;


    final Handler mHandler = new Handler(Looper.getMainLooper()) {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what) {
                case 300:
                    int percent = msg.arg1;
                    if (percent < 100) {
                        progressDialog.setProgress(percent);
                    } else {
                        progressDialog.dismiss();
                        Glide.with(mContext).load(Constants.LOCAL_FILE_PATH).into(mImageView);
                    }
                    break;
                case 404:
                    progressDialog.dismiss();
                    Toast.makeText(mContext, "Download fail !", Toast.LENGTH_SHORT).show();
                    break;
                default:
                    break;
            }
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mvc);
        mContext = this;
        init();
    }

    private void init() {
        //view init
        mImageView = findViewById(R.id.image);
        progressDialog = new ProgressDialog(mContext);
        progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancle", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                progressDialog.dismiss();
            }
        });
        progressDialog.setCanceledOnTouchOutside(false);
        progressDialog.setTitle("下载文件");
        progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);


        //click-event
        findViewById(R.id.downloadBtn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                progressDialog.show();
                HttpUtil.HttpGet(Constants.DOWNLOAD_URL, new DownloadCallback(mHandler));
            }
        });

        findViewById(R.id.downloadBtn1).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                progressDialog.show();
                HttpUtil.HttpGet(Constants.DOWNLOAD_ERROR_URL, new DownloadCallback(mHandler));
            }
        });


        Looper mLooper = getMainLooper();
        Thread mThread=mLooper.getThread();
        String threadName = mThread.getName();

        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
            MessageQueue mMessageQueue=mLooper.getQueue();
        }


        Log.e(TAG, "threadName: "+threadName);

    }


} public class MVPActivity extends AppCompatActivity implements IDownloadView {
    private Context mContext;
    private ImageView mImageView;
    private ProgressDialog progressDialog;

    private DownloadPresenter mDownloadPresenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mContext = this;
        setContentView(R.layout.activity_mvp);
        init();
    }

    private void init() {
        mDownloadPresenter = new DownloadPresenter(this);
        //view init
        mImageView = findViewById(R.id.image);
        findViewById(R.id.downloadBtn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mDownloadPresenter.download(Constants.DOWNLOAD_URL);
            }
        });

        findViewById(R.id.downloadBtn1).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mDownloadPresenter.download(Constants.DOWNLOAD_ERROR_URL);
            }
        });

        progressDialog = new ProgressDialog(mContext);
        progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancle", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                progressDialog.dismiss();
            }
        });
        progressDialog.setCanceledOnTouchOutside(false);
        progressDialog.setTitle("下载文件");
        progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);

    }

    @Override
    public void showProgressBar(boolean show) {
        if (show) {
            progressDialog.show();
        } else {
            progressDialog.dismiss();
        }
    }

    @Override
    public void setProcessProgress(int progress) {
        progressDialog.setProgress(progress);
    }

    @Override
    public void setView(String result) {
        Glide.with(mContext).load(result).into(mImageView);
    }

    @Override
    public void showFailToast() {
        Toast.makeText(mContext, "Download fail !", Toast.LENGTH_SHORT).show();
    }
} public class BroadcastReceiverActivity extends AppCompatActivity {
    private static final String MY_ACTION = "huiyifei.mymvp.broadcast";
    private static final String MY_ACTION_1 = "huiyifei.mymvp.broadcast_1";
    private static final String MY_ACTION_LOCAL = "huiyifei.mymvp.broadcast_local";

    private Context mContext;


    private MyReceiver mMyReceiver;
    private SecondReceiver mSecondReceiver;
    private ThirdReceiver mThirdReceiver;

    //
    private LocalBroadcastManager mLocalBroadcastManager;

    private TextView battery;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mContext = this;
        setContentView(R.layout.activity_broadcast_receiver);
        mMyReceiver = new MyReceiver();
        mSecondReceiver = new SecondReceiver();
        mThirdReceiver = new ThirdReceiver();

        findViewById(R.id.send).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setAction(MY_ACTION);
                intent.putExtra("date", Tools.getCurrentTime());
                sendBroadcast(intent);
            }
        });

        findViewById(R.id.sendSecond).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setAction(MY_ACTION_1);
                intent.putExtra("msg", String.valueOf(System.currentTimeMillis()));
                sendBroadcast(intent);
            }
        });

        findViewById(R.id.sendLocal).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mLocalBroadcastManager = LocalBroadcastManager.getInstance(mContext);
                mLocalBroadcastManager.registerReceiver(mThirdReceiver, new IntentFilter(MY_ACTION_LOCAL));
                Intent intent = new Intent();
                intent.setAction(MY_ACTION_LOCAL);
                intent.putExtra("msg", "This is local broadcast");
                mLocalBroadcastManager.sendBroadcast(intent);
            }
        });


        getBattery();
    }

    /**
     * 获取系统电量
     */
    private void getBattery() {
        battery = findViewById(R.id.battery);
        IntentFilter batteryFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
        Intent batteryIntent = getApplicationContext().registerReceiver(null, batteryFilter);
        int total = batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, 1);
        int current = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
        float percent = current * 100 / total;
        battery.setText(String.valueOf(percent));
    }

    @Override
    protected void onResume() {
        super.onResume();
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(MY_ACTION);
        registerReceiver(mMyReceiver, intentFilter);


        IntentFilter intentFilter1 = new IntentFilter();
        intentFilter1.addAction(MY_ACTION_1);
        registerReceiver(mSecondReceiver, intentFilter1);
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        unregisterReceiver(mMyReceiver);
        unregisterReceiver(mSecondReceiver);


        if (mLocalBroadcastManager != null) {
            mLocalBroadcastManager.unregisterReceiver(mThirdReceiver);
        }

    }
} public class ClassLoaderActivity extends AppCompatActivity {
    private static final String TAG = "ClassLoaderActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_class_loader);
        Toolbar toolbar = findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        FloatingActionButton fab = findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });

        ClassLoader mClassLoader = ClassLoaderActivity.class.getClassLoader();
        while (mClassLoader != null) {
            Log.e(TAG, "onCreate: mClassLoader=" + mClassLoader);
            mClassLoader = mClassLoader.getParent();
        }

    }

} public class SimpleHotFixActivity extends AppCompatActivity {

    @BindView(R.id.loadPatch)
    Button mLoadPatch;
    @BindView(R.id.testBug)
    Button mTestBug;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_simple_hot_fix);
        ButterKnife.bind(this);
    }

    @OnClick({R.id.loadPatch, R.id.testBug})
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.loadPatch:
                FixDexUtils.loadFixedDex(this, Environment.getExternalStorageDirectory());
                break;
            case R.id.testBug:
                SimpleHotFixBugTest mBugTest=new SimpleHotFixBugTest();
                mBugTest.getBug(this);
                break;
            default:
                break;
        }
    }
} public class DataStorageActivity extends AppCompatActivity {
    private Context mContext;
    //View
    private CheckBox mCheckBox;
    private EditText mEditText;
    private Button write, read;
    private TextView content;
    private Button insert, getall, delall, get, del, greendao;
    private TextView resultTv;
    private Button getContacts;
    private ListView mListView;
    //
    private SharedPreferences sp;
    private final String SP_NAME = "only";
    //
    private String FILENAME = "ONLY.txt";
    //Sqlite
    private MySqliteHelper sqHelper;
    //ContentResolver
    private ContentResolver mContentResolver;
    private List<String> datas = new ArrayList<>();

    private final String CONTACTS = android.Manifest.permission.READ_CONTACTS;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mContext = this;
        setContentView(R.layout.activity_data_storage);
        initView();
        initSetup();

        //
        sqHelper = new MySqliteHelper(mContext);

        FILENAME.toCharArray();
    }

    private void initSetup() {
        sp = getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);
        if (sp != null) {
            boolean isChecked = sp.getBoolean("checked", false);
            mCheckBox.setChecked(isChecked);
            if (isChecked) {
                Toast.makeText(mContext, "Last time checked", Toast.LENGTH_SHORT).show();
            } else {
                Toast.makeText(mContext, "Last time not checked", Toast.LENGTH_SHORT).show();
            }
        }


    }

    private void initView() {
        mCheckBox = findViewById(R.id.checkBox);

        mCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                sp.edit().putBoolean("checked", isChecked).apply();
            }
        });

        ///
        mEditText=findViewById(R.id.et);
        write = findViewById(R.id.write);
        read = findViewById(R.id.read);
        write.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String content = mEditText.getText().toString();
                if (!TextUtils.isEmpty(content)) {
                    try {
                        FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
                        fos.write(content.getBytes());
                        fos.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        });
        content = findViewById(R.id.content);
        read.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mEditText.setText("");
                String str = "";
                try {
                    FileInputStream fis = openFileInput(FILENAME);
                    int hasRead = 0;
                    byte[] bytes = new byte[1024];
                    while ((hasRead = fis.read(bytes)) != -1) {
                        str = new String(bytes, 0, hasRead);
                    }
                    content.setText("");
                    content.setText(str);
                    fis.close();
                } catch (FileNotFoundException e) {
                    e.printStackTrace();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });
        //

        resultTv = findViewById(R.id.resultTv);
        insert = findViewById(R.id.insert);
        insert.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (!TextUtils.isEmpty(mEditText.getText().toString())) {
                    ContentValues values = new ContentValues();
                    values.put("content", mEditText.getText().toString());
                    String date =
                            Calendar.getInstance(Locale.CHINA).get(Calendar.MONTH) + "-" +
                                    Calendar.getInstance(Locale.CHINA).get(Calendar.DAY_OF_MONTH) + " " +
                                    Calendar.getInstance(Locale.CHINA).get(Calendar.HOUR_OF_DAY) + ":" +
                                    Calendar.getInstance(Locale.CHINA).get(Calendar.MINUTE);
                    values.put("times", date);
                    sqHelper.insertData(values);
                } else {
                    Toast.makeText(mContext, "can not null", Toast.LENGTH_SHORT).show();
                }


            }
        });

        getall = findViewById(R.id.getall);

        getall.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                List<DataBean> dataBeanList = sqHelper.queryAll();
                if (dataBeanList != null) {
                    StringBuffer sb = new StringBuffer();
                    for (int i = 0; i < dataBeanList.size(); i++) {
                        sb.append(dataBeanList.get(i).getContent() + " " + dataBeanList.get(i).getTimes() + "\n");
                    }
                    resultTv.setText(sb.toString());
                }
            }
        });

        delall = findViewById(R.id.delall);
        delall.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (sqHelper.delAll()) {
                    Toast.makeText(mContext, "del success", Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(mContext, "del fail", Toast.LENGTH_SHORT).show();

                }
            }
        });

        get = findViewById(R.id.get);
        get.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String selections = "content= ?";
                String temp = mEditText.getText().toString();
                String[] selectionsArgs = new String[]{temp};
                DataBean bean = sqHelper.query(selections, selectionsArgs);
                if (bean != null) {
                    resultTv.setText(bean.getContent() + " " + bean.getTimes());
                }
            }
        });

        del = findViewById(R.id.del);
        del.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String whereClause = "content=?";
                String temp = mEditText.getText().toString();
                if (!TextUtils.isEmpty(temp)) {
                    String[] whereArgs = new String[]{temp};
                    if (sqHelper.del(whereClause, whereArgs)) {
                        Toast.makeText(mContext, "del success", Toast.LENGTH_SHORT).show();
                    } else {
                        Toast.makeText(mContext, "del fail", Toast.LENGTH_SHORT).show();
                    }
                }
            }
        });



        mListView = findViewById(R.id.listView);
        getContacts = findViewById(R.id.getContacts);

        getContacts.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (PermissionChecker.checkSelfPermission(mContext, CONTACTS) == PermissionChecker.PERMISSION_GRANTED) {
                    readContacts();
                } else {
                    ActivityCompat.requestPermissions(DataStorageActivity.this, new String[]{CONTACTS}, 100);
                }
            }
        });

        findViewById(R.id.room).setOnClickListener(v -> startActivity(new Intent(mContext,RoomActivity.class)));


    }


    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        if (requestCode == 100) {
            if (grantResults[0] == PermissionChecker.PERMISSION_GRANTED) {
                readContacts();
            } else {
                Toast.makeText(mContext, "Permission denied !", Toast.LENGTH_SHORT).show();
            }
        }
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    }

    private void readContacts() {
        mContentResolver = getContentResolver();
        //联系人URI
        Uri contactsUri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
        Cursor cursor = mContentResolver.query(contactsUri, null, null, null, null);
        assert cursor != null;
        cursor.moveToFirst();
        while (cursor.moveToNext()) {
            String name = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
            String phone = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NORMALIZED_NUMBER));
            datas.add(name + "----" + phone);
        }
        cursor.close();
        ArrayAdapter arrayAdapter = new ArrayAdapter(mContext, android.R.layout.simple_list_item_1, datas);
        mListView.setAdapter(arrayAdapter);
    }
} public class HandlerOneActivity extends AppCompatActivity {

    private static final String TAG = "HandlerOneActivity";

    private static class MyHandler extends Handler {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            String info = "";
            switch (msg.what) {

                case 100:
                     info = (String) msg.obj;
                    Log.e(TAG, "handleMessage: info==" + info);
                    break;
                case 200:
                     info = (String) msg.obj;
                    Log.e(TAG, "handleMessage: act-1-info==" + info);
                    break;
                default:
                    break;
            }

        }
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_handler_one);
        findViewById(R.id.button6).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Message mMessage=Message.obtain();
                mMessage.what=100;
                mMessage.obj="from-activity-1";
                Handler mHandler=new MyHandler();
                Log.e(TAG, "onClick: looper=="+mHandler.getLooper() );
                Log.e(TAG, "onClick: messageQueue=="+mHandler.getLooper().getQueue() );
                mHandler.sendMessage(mMessage);
            }
        });
        findViewById(R.id.button8).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(HandlerOneActivity.this, HandlerTwoActivity.class));
            }
        });
    }
} public class MemoryLeakActivity extends AppCompatActivity {

    private MyHandler mLeakyHandler = new MyHandler(this);

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_memory_leak);
        mLeakyHandler.postDelayed(new Job(), 10 * 1000);

    }

    private class Job implements Runnable {

        @Override
        public void run() {
            finish();
        }
    }


    private static class MyHandler extends Handler {
        private final WeakReference<MemoryLeakActivity> mActivity;

        public MyHandler(MemoryLeakActivity activity) {
            mActivity = new WeakReference<>(activity);
        }

        @Override
        public void handleMessage(Message msg) {
            MemoryLeakActivity activity = mActivity.get();
            if (activity != null) {
                Log.e("handleMessage", "0");
            }
        }
    }
} public class ServiceActivity extends AppCompatActivity {
    private Context mContext;
    private Intent mIntent;
    //
    private MyServiceConnection connection;

    private Object mObject;

    /**
     * [Service 生命周期]("http://www.jianshu.com/p/8d0cde35eb10")
     *
     * @param savedInstanceState
     */

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mContext = this;
        setContentView(R.layout.activity_service);
        mIntent = new Intent(mContext, MyService.class);
        //
        connection = new MyServiceConnection();
        actionView();



    }

    private void actionView() {
        findViewById(R.id.startService).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startService(mIntent);
            }
        });

        findViewById(R.id.stopService).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                stopService(mIntent);
            }
        });
        findViewById(R.id.bindService).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                bindService(mIntent, connection, BIND_AUTO_CREATE);
            }
        });

        findViewById(R.id.unbindService).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                unbindService(connection);
            }
        });

        /**
         * http://www.jianshu.com/p/8a3c44a9173a Android多线程全面解析：IntentService用法&源码
         */
        findViewById(R.id.intentService).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {


                MyIntentService.startActionBaz(mContext, "Hello ", "Baz");
                MyIntentService.startActionFoo(mContext, "Hello", "Foo");
            }
        });
    }

} public class AIDLActivity extends AppCompatActivity {
    private static final String TAG = "AIDLActivity";
    private Intent mIntent;

    private IMyAidlInterface mIMyAidlInterface;
    private boolean isConnected = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_aidl);
        mIntent = new Intent(this, CustomRemoteService.class);
        mIntent.setPackage(getPackageName());
        findViewById(R.id.bind).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                isConnected = true;
                bindService(mIntent, mConnection, Context.BIND_AUTO_CREATE);
            }
        });
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (isConnected && mConnection != null) {


            unbindService(mConnection);
        }
    }

    private ServiceConnection mConnection = new ServiceConnection() {
        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
            Log.e(TAG, "onServiceConnected: " + name);
            Log.e(TAG, "onServiceConnected: " + service.toString());
            try {
                mIMyAidlInterface = IMyAidlInterface.Stub.asInterface(service);
                int result = mIMyAidlInterface.add(10, 20);
                Log.e(TAG, "onServiceConnected: 10+20=" + result);
                String msg = mIMyAidlInterface.reback();
                Log.e(TAG, "onServiceConnected: msg=" + msg);

                String info = mIMyAidlInterface.loadData("http://www.baidu.com");
                Log.e(TAG, "onServiceConnected: info=" + info);


                int pos = mIMyAidlInterface.binarySearch(5);
                Log.e(TAG, "onServiceConnected: find 5 at pos=" + pos);

            } catch (RemoteException e) {
                e.printStackTrace();
            }

        }

        @Override
        public void onServiceDisconnected(ComponentName name) {
            Log.e(TAG, "onServiceDisconnected: " + name);
        }
    };
} public class HashMapActivity extends AppCompatActivity implements View.OnClickListener {
    private static final String TAG = "HashMapActivity";
    private HashMap<String, String> mHashMap;


    private EditText mKey, mValue;
    private TextView mResult;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_hash_map);

        mHashMap = new HashMap<>();


        Button mPut = findViewById(R.id.put);
        mPut.setOnClickListener(this);
        Button mGet = findViewById(R.id.get);
        mGet.setOnClickListener(this);
        Button mRemove = findViewById(R.id.remove);
        mRemove.setOnClickListener(this);
        mKey = findViewById(R.id.key);
        mValue = findViewById(R.id.value);
        mResult = findViewById(R.id.result);


        mHashMap.put("a", "Apple");
        mHashMap.put("b", "basket");
        mHashMap.put("c", "cell");
        mHashMap.put("d", "dog");
        mHashMap.put("e", "Earth");
        mHashMap.put("f", "football");


        Log.e(TAG, "onCreate: mHashMap=" + mHashMap);

        TreeMap mTreeMap = new TreeMap();
        mTreeMap.putAll(mHashMap);

        Log.e(TAG, "onCreate: mTreeMap=" + mTreeMap);


        // 按照Value对map进行排序
        TreeMap mTreeMap1=new TreeMap(new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return mHashMap.get(o1).compareTo(mHashMap.get(o2));
            }


        });

        mTreeMap1.putAll(mHashMap);
        Log.e(TAG, "onCreate: mTreeMap1=" + mTreeMap1);


    }

    @Override
    public void onClick(View view) {
        String result;
        String key = mKey.getText().toString().trim();
        String value = mValue.getText().toString().trim();
        switch (view.getId()) {
            case R.id.put:
                if (!TextUtils.isEmpty(key) && !TextUtils.isEmpty(value)) {
                    mHashMap.put(key, value);
                }
                break;
            case R.id.get:
                if (!TextUtils.isEmpty(key)) {
                    result = mHashMap.get(key);
                    mResult.setText(result);
                }

                break;
            case R.id.remove:
                if (!TextUtils.isEmpty(key)) {
                    result = mHashMap.remove(key);
                    Toast.makeText(this, result + " has been removed !", Toast.LENGTH_SHORT).show();
                }
                break;
            default:
                break;
        }
    }
}
import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import cn.hikyson.godeye.core.GodEye;
import cn.hikyson.godeye.core.internal.modules.fps.Fps;
import cn.hikyson.godeye.core.internal.modules.fps.FpsInfo;
import cn.hikyson.godeye.monitor.GodEyeMonitor;
import huyifei.mymvp.architecture.mvc.MVCActivity;
import huyifei.mymvp.architecture.mvp.MVPActivity;
import huyifei.mymvp.broadcastreceiver.BroadcastReceiverActivity;
import huyifei.mymvp.classloader.ClassLoaderActivity;
import huyifei.mymvp.classloader.SimpleHotFixActivity;
import huyifei.mymvp.datastorage.DataStorageActivity;
import huyifei.mymvp.handler.HandlerOneActivity;
import huyifei.mymvp.memoryleak.MemoryLeakActivity;
import huyifei.mymvp.service.ServiceActivity;
import huyifei.mymvp.service.ThreadLocalTestActivity;
import huyifei.mymvp.service.ipc.AIDLActivity;
import huyifei.mymvp.test.HashMapActivity;
import io.reactivex.functions.Consumer;

        String address = Environment.getExternalStorageDirectory() + File.separator + "rotate.jpg";
        String url = new File(address).toURI().toString();


        Log.e(TAG, "arrayTest: url=" + url);

        Uri uri = Uri.parse(url);

        Log.e(TAG, "arrayTest: uri.scheme==" + uri.getHost());

        String zhihu = "https://www.zhihu.com";
        Uri zhihuUri = Uri.parse(zhihu);

        Log.e(TAG, "arrayTest: zhihu.host==" + zhihuUri.getHost());
        Log.e(TAG, "arrayTest: zhihu.scheme==" + zhihuUri.getScheme());
    }

    private String fixImageQuality(String url, String oldQuality, String newQuality) {
        String result = url;

        Pattern r = Pattern.compile(oldQuality);
        Matcher m = r.matcher(url);

        if (m.find()) {
            // 图片地址中包含有可替换的元素,直接替换
            result = result.replace(m.group(), newQuality);
        } else {
            // 图片中原来没有质量系数，需要添加
            if (!TextUtils.isEmpty(newQuality)) {
                result = result.replace("com/", "com" + newQuality);
            }
        }

        return result;
    }

    /**
     * 打印系统目录信息
     */

    //<editor-fold desc="print system dir info">
    private void PrintSystemDirInfo() {


        final int version = Build.VERSION.SDK_INT;
        final String mRelease = Build.VERSION.RELEASE;
        final String mSerial = Build.SERIAL;
        String android_id = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
        String filepath = Environment.getExternalStorageDirectory().getAbsolutePath();
        //
        String getDataDirectory = Environment.getDataDirectory().getAbsolutePath();
        String getRootDirectory = Environment.getRootDirectory().getAbsolutePath();
        String getDownloadCacheDirectory = Environment.getDownloadCacheDirectory().getAbsolutePath();
        //
        String DIRECTORY_DCIM = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getAbsolutePath();
        String DIRECTORY_DOCUMENTS = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath();
        String DIRECTORY_PICTURES = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).getAbsolutePath();
        String DIRECTORY_DOWNLOADS = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath();
        //
        String cacheDir = mContext.getCacheDir().getAbsolutePath();
        String filesDir = mContext.getFilesDir().getAbsolutePath();
        //
        String getExternalCacheDir = mContext.getExternalCacheDir().getAbsolutePath();
        String getExternalFilesDir_DIRECTORY_PICTURES = mContext.getExternalFilesDir(Environment.DIRECTORY_PICTURES).getAbsolutePath();
        String getExternalFilesDir_DIRECTORY_DOCUMENTS = mContext.getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath();


        String[] files = new String[mContext.getExternalCacheDirs().length];
        for (int i = 0; i < mContext.getExternalCacheDirs().length; i++) {
            File mFile = mContext.getExternalCacheDirs()[i];
            files[i] = mFile.getAbsolutePath() + "\n";
        }


        Log.e(TAG, "android.os.Build.VERSION.SDK_INT = " + version);
        Log.e(TAG, "android.os.Build.VERSION.RELEASE = " + mRelease);
        Log.e(TAG, "android.os.Build.SERIAL = " + mSerial);
        Log.e(TAG, "Secure.ANDROID_ID = " + android_id);
        Log.e(TAG, "--------------------------------------------------");
        Log.e(TAG, "Environment.getExternalStorageDirectory() = " + filepath);
        Log.e(TAG, "Environment.getDataDirectory() = " + getDataDirectory);
        Log.e(TAG, "Environment.getRootDirectory() = " + getRootDirectory);
        Log.e(TAG, "Environment.getDownloadCacheDirectory() = " + getDownloadCacheDirectory);
        Log.e(TAG, "--------------------------------------------------");
        Log.e(TAG, "Environment.getExternalStorageDirectory(Environment.DIRECTORY_DCIM) = " + DIRECTORY_DCIM);
        Log.e(TAG, "Environment.getExternalStorageDirectory(Environment.DIRECTORY_DOCUMENTS) = " + DIRECTORY_DOCUMENTS);
        Log.e(TAG, "Environment.getExternalStorageDirectory(Environment.DIRECTORY_PICTURES) = " + DIRECTORY_PICTURES);
        Log.e(TAG, "Environment.getExternalStorageDirectory(Environment.DIRECTORY_DOWNLOADS) = " + DIRECTORY_DOWNLOADS);
        Log.e(TAG, "--------------------------------------------------");
        Log.e(TAG, "mContext.getCacheDir() = " + cacheDir);
        Log.e(TAG, "mContext.getFilesDir() = " + filesDir);
        Log.e(TAG, "--------------------------------------------------");
        Log.e(TAG, "mContext.getExternalCacheDir() = " + getExternalCacheDir);
        Log.e(TAG, "mContext.getExternalFilesDir(Environment.DIRECTORY_PICTURES) = " + getExternalFilesDir_DIRECTORY_PICTURES);
        Log.e(TAG, "mContext.getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS) = " + getExternalFilesDir_DIRECTORY_DOCUMENTS);
        Log.e(TAG, "mContext.getExternalCacheDirs() size=" + files.length + " :" + Arrays.toString(files));
        ActivityManager mManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
        int size = mManager.getMemoryClass();

        Log.e(TAG, "mManager.getMemoryClass()  应用可用内存 = " + size + " M");


    }
    //</editor-fold>

    private void setData() {
        demos.add(new ItemInfo(R.string.lifeCycle, LifeCycleActivity.class));
        demos.add(new ItemInfo(R.string.lifeCycle, JacksonActivity.class));
        demos.add(new ItemInfo(R.string.classloader, ClassLoaderActivity.class));
        demos.add(new ItemInfo(R.string.hotfix, SimpleHotFixActivity.class));
        demos.add(new ItemInfo(R.string.memory_leak, MemoryLeakActivity.class));
//        demos.add(new ItemInfo(R.string.memory_leak, MemoryLeakWithRxActivity.class));
//        demos.add(new ItemInfo(R.string.memory_leak, MemoryLeakWithRx2Activity.class));
//        demos.add(new ItemInfo(R.string.RxJava2, RxJava2MainActivity.class));
        demos.add(new ItemInfo(R.string.MVC, MVCActivity.class));
        demos.add(new ItemInfo(R.string.Mvp, MVPActivity.class));
        demos.add(new ItemInfo(R.string.GlideUse, GlideActivity.class));
        demos.add(new ItemInfo(R.string.DataStorage, DataStorageActivity.class));
        demos.add(new ItemInfo(R.string.BroadcastReceiver, BroadcastReceiverActivity.class));
        demos.add(new ItemInfo(R.string.service, ServiceActivity.class));