items, OnListFragmentInteractionListener listener) {
28 | mValues = items;
29 | mListener = listener;
30 | }
31 |
32 | @Override
33 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
34 | View view = LayoutInflater.from(parent.getContext())
35 | .inflate(R.layout.fragment_item, parent, false);
36 | return new ViewHolder(view);
37 | }
38 |
39 | @Override
40 | public void onBindViewHolder(final ViewHolder holder, int position) {
41 | holder.mItem = mValues.get(position);
42 | holder.mIdView.setText(mValues.get(position).id);
43 | holder.mContentView.setText(mValues.get(position).content);
44 |
45 | holder.mView.setOnClickListener(new View.OnClickListener() {
46 | @Override
47 | public void onClick(View v) {
48 | if (null != mListener) {
49 | // Notify the active callbacks interface (the activity, if the
50 | // fragment is attached to one) that an item has been selected.
51 | mListener.onListFragmentInteraction(holder.mItem);
52 | }
53 | }
54 | });
55 | }
56 |
57 | @Override
58 | public int getItemCount() {
59 | return mValues.size();
60 | }
61 |
62 | public class ViewHolder extends RecyclerView.ViewHolder {
63 | public final View mView;
64 | @ViewInject(R.id.id)
65 | public TextView mIdView;
66 | @ViewInject(R.id.content)
67 | public TextView mContentView;
68 | public DummyItem mItem;
69 |
70 | public ViewHolder(View view) {
71 | super(view);
72 | AnnotateUtils.inject(ViewHolder.this, view);
73 | mView = view;
74 | // mIdView = (TextView) view.findViewById(R.id.id);
75 | // mContentView = (TextView) view.findViewById(R.id.content);
76 | }
77 |
78 | @Override
79 | public String toString() {
80 | return super.toString() + " '" + mContentView.getText() + "'";
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/Channel2App/src/main/java/com/anno/ui/dummy/DummyContent.java:
--------------------------------------------------------------------------------
1 | package com.anno.ui.dummy;
2 |
3 | import java.util.ArrayList;
4 | import java.util.HashMap;
5 | import java.util.List;
6 | import java.util.Map;
7 |
8 | /**
9 | * Helper class for providing sample content for user interfaces created by
10 | * Android template wizards.
11 | *
12 | * TODO: Replace all uses of this class before publishing your app.
13 | */
14 | public class DummyContent {
15 |
16 | /**
17 | * An array of sample (dummy) items.
18 | */
19 | public static final List ITEMS = new ArrayList();
20 |
21 | /**
22 | * A map of sample (dummy) items, by ID.
23 | */
24 | public static final Map ITEM_MAP = new HashMap();
25 |
26 | private static final int COUNT = 25;
27 |
28 | static {
29 | // Add some sample items.
30 | for (int i = 1; i <= COUNT; i++) {
31 | addItem(createDummyItem(i));
32 | }
33 | }
34 |
35 | private static void addItem(DummyItem item) {
36 | ITEMS.add(item);
37 | ITEM_MAP.put(item.id, item);
38 | }
39 |
40 | private static DummyItem createDummyItem(int position) {
41 | return new DummyItem(String.valueOf(position), "Item " + position, makeDetails(position));
42 | }
43 |
44 | private static String makeDetails(int position) {
45 | StringBuilder builder = new StringBuilder();
46 | builder.append("Details about Item: ").append(position);
47 | for (int i = 0; i < position; i++) {
48 | builder.append("\nMore details information here.");
49 | }
50 | return builder.toString();
51 | }
52 |
53 | /**
54 | * A dummy item representing a piece of content.
55 | */
56 | public static class DummyItem {
57 | public final String id;
58 | public final String content;
59 | public final String details;
60 |
61 | public DummyItem(String id, String content, String details) {
62 | this.id = id;
63 | this.content = content;
64 | this.details = details;
65 | }
66 |
67 | @Override
68 | public String toString() {
69 | return content;
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/Channel2App/src/main/res/drawable/selector_pressed.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Channel2App/src/main/res/layout/activity_binder_service.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
15 |
16 |
22 |
23 |
30 |
31 |
37 |
38 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/Channel2App/src/main/res/layout/activity_detail.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
17 |
18 |
26 |
27 |
32 |
37 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/Channel2App/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
21 |
22 |
29 |
36 |
37 |
38 |
45 |
46 |
--------------------------------------------------------------------------------
/Channel2App/src/main/res/layout/activity_recyclervheelview.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Channel2App/src/main/res/layout/activity_service.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
15 |
16 |
17 |
23 |
24 |
30 |
31 |
37 |
38 |
45 |
46 |
52 |
53 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/Channel2App/src/main/res/layout/activity_web_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
9 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Channel2App/src/main/res/layout/fragment_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
17 |
18 |
25 |
26 |
--------------------------------------------------------------------------------
/Channel2App/src/main/res/layout/fragment_item_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
--------------------------------------------------------------------------------
/Channel2App/src/main/res/layout/toolbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
--------------------------------------------------------------------------------
/Channel2App/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Channel2App/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Channel2App/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/AndroidLearn/b380f8ee58f2a8a87807baf89a42bf0ee4aff301/Channel2App/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Channel2App/src/main/res/mipmap-hdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/AndroidLearn/b380f8ee58f2a8a87807baf89a42bf0ee4aff301/Channel2App/src/main/res/mipmap-hdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/Channel2App/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/AndroidLearn/b380f8ee58f2a8a87807baf89a42bf0ee4aff301/Channel2App/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Channel2App/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/AndroidLearn/b380f8ee58f2a8a87807baf89a42bf0ee4aff301/Channel2App/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Channel2App/src/main/res/mipmap-mdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/AndroidLearn/b380f8ee58f2a8a87807baf89a42bf0ee4aff301/Channel2App/src/main/res/mipmap-mdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/Channel2App/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/AndroidLearn/b380f8ee58f2a8a87807baf89a42bf0ee4aff301/Channel2App/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Channel2App/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/AndroidLearn/b380f8ee58f2a8a87807baf89a42bf0ee4aff301/Channel2App/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Channel2App/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/AndroidLearn/b380f8ee58f2a8a87807baf89a42bf0ee4aff301/Channel2App/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/Channel2App/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/AndroidLearn/b380f8ee58f2a8a87807baf89a42bf0ee4aff301/Channel2App/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Channel2App/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/AndroidLearn/b380f8ee58f2a8a87807baf89a42bf0ee4aff301/Channel2App/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Channel2App/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/AndroidLearn/b380f8ee58f2a8a87807baf89a42bf0ee4aff301/Channel2App/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/Channel2App/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/AndroidLearn/b380f8ee58f2a8a87807baf89a42bf0ee4aff301/Channel2App/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Channel2App/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/AndroidLearn/b380f8ee58f2a8a87807baf89a42bf0ee4aff301/Channel2App/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Channel2App/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/AndroidLearn/b380f8ee58f2a8a87807baf89a42bf0ee4aff301/Channel2App/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png
--------------------------------------------------------------------------------
/Channel2App/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/AndroidLearn/b380f8ee58f2a8a87807baf89a42bf0ee4aff301/Channel2App/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Channel2App/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/Channel2App/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 |
5 |
--------------------------------------------------------------------------------
/Channel2App/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | AnnotationTest
3 |
4 |
--------------------------------------------------------------------------------
/Channel2App/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Channel2App/src/test/java/danxx/channelapp/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package danxx.channelapp;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/Dximageloader/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/Dximageloader/README.md:
--------------------------------------------------------------------------------
1 | # Android DxIamgeLoader Lib
2 |
3 | ## 详细解读博客
4 | http://blog.csdn.net/u010072711/article/details/74502822
5 |
6 | ## 文章导读
7 |
8 | Android DiskLruCache完全解析,硬盘缓存的最佳方案 http://blog.csdn.net/guolin_blog/article/details/28863651
9 |
10 | Android性能优化之使用线程池处理异步任务 http://blog.csdn.net/u010687392/article/details/49850803
11 |
12 | Android开发之高效加载Bitmap http://www.cnblogs.com/absfree/p/5361167.html
13 |
14 | Android线程同步 http://blog.csdn.net/peng6662001/article/details/7277851/
15 |
16 | ## 方法调用顺序
17 |
18 | load --> placeholder --> error --> into
19 |
20 |
21 | ## 图片加载顺序
22 |
23 | loadFromMemoryCache 成功返回bitmap
24 |
25 | loadFromDisk =》addToMemoryCache 获取成功并压缩后把bitmap添加到运行内存 返回bitmap
26 |
27 | ↑
28 |
29 | <--------------------------------
30 |
31 | ↑
32 |
33 | loadFromNet =》 addToDisk =》 loadFromDisk 网络获取成功后调用loadFromDisk添加到文件缓存(返回压缩的bitmap 并添加到运行内存)
34 |
35 | 
36 |
37 | ## Sample:
38 | ``` java
39 | //Application中初始化
40 | public class App extends Application {
41 | @Override
42 | public void onCreate() {
43 | super.onCreate();
44 | //初始化图片加载库
45 | DxImageLoader.getInstance().init(getApplicationContext());
46 | }
47 | }
48 |
49 | //activity中调用
50 | /****调用示例***/
51 | ImageView imageView0 = (ImageView) findViewById(R.id.image0);
52 | DxImageLoader.getInstance().
53 | load(imgUrls[0]). //load图片地址
54 | placeholder(R.drawable.default_pic_loading). //placeholder占位图
55 | error(R.drawable.app_bg). //error错误图
56 | into(imageView0); //into显示图片的imageView
57 | ```
58 |
59 | ## 效果图
60 | 
61 |
--------------------------------------------------------------------------------
/Dximageloader/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion rootProject.ext.compileSdkVersion
5 | buildToolsVersion rootProject.ext.buildToolsVersion
6 |
7 |
8 | defaultConfig {
9 | minSdkVersion rootProject.ext.minSdkVersion
10 | targetSdkVersion rootProject.ext.targetSdkVersion
11 | versionCode 1
12 | versionName "1.0"
13 |
14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15 |
16 | }
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 | }
24 |
25 | dependencies {
26 | compile fileTree(dir: 'libs', include: ['*.jar'])
27 | // androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
28 | // exclude group: 'com.android.support', module: 'support-annotations'
29 | // })
30 |
31 | // compile 'com.android.support:appcompat-v7:25.4.0'
32 | // testCompile 'junit:junit:4.12'
33 | }
34 |
--------------------------------------------------------------------------------
/Dximageloader/img/dximageloadimg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/AndroidLearn/b380f8ee58f2a8a87807baf89a42bf0ee4aff301/Dximageloader/img/dximageloadimg.png
--------------------------------------------------------------------------------
/Dximageloader/img/flow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/AndroidLearn/b380f8ee58f2a8a87807baf89a42bf0ee4aff301/Dximageloader/img/flow.png
--------------------------------------------------------------------------------
/Dximageloader/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\Android_Develop\AndroidSdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/Dximageloader/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Dximageloader/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | DXImageLoader
3 |
4 |
--------------------------------------------------------------------------------
/JavaLib/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/JavaLib/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'java-library'
2 |
3 | dependencies {
4 | implementation fileTree(dir: 'libs', include: ['*.jar'])
5 | }
6 |
7 | sourceCompatibility = "1.7"
8 | targetCompatibility = "1.7"
9 |
--------------------------------------------------------------------------------
/JavaLib/src/main/java/com/danxx/thread/Consumer.java:
--------------------------------------------------------------------------------
1 | package com.danxx.thread;
2 |
3 | /**
4 | * 消费者
5 | * Created by dawish on 2017/7/13.
6 | */
7 |
8 | public class Consumer extends Thread{
9 |
10 | private Storage storage;//仓库
11 |
12 | private String name="";
13 |
14 | public Consumer(Storage storage, String name) {
15 | this.storage = storage;
16 | this.name = name;
17 | }
18 | public void run(){
19 | while(true){
20 | synchronized(storage){
21 | //消费者去仓库拿消息的时候,如果发现仓库数据为空,则等待
22 | String data = storage.get(name);
23 | if(data != null){
24 |
25 | System.out.println(name +"-------------"+ data);
26 |
27 | }
28 | }
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/JavaLib/src/main/java/com/danxx/thread/MainApp.java:
--------------------------------------------------------------------------------
1 | package com.danxx.thread;
2 |
3 | /**
4 | * Java中的多线程会涉及到线程间通信,常见的线程通信方式,例如共享变量、管道流等,
5 | * 这里我们要实现生产者消费者模式,也需要涉及到线程通信,不过这里我们用到了java中的
6 | * wait()、notify()方法:
7 | * wait():进入临界区的线程在运行到一部分后,发现进行后面的任务所需的资源还没有准备充分,
8 | * 所以调用wait()方法,让线程阻塞,等待资源,同时释放临界区的锁,此时线程的状态也从RUNNABLE状态变为WAITING状态;
9 | * notify():准备资源的线程在准备好资源后,调用notify()方法通知需要使用资源的线程,
10 | * 同时释放临界区的锁,将临界区的锁交给使用资源的线程。
11 | * wait()、notify()这两个方法,都必须要在临界区中调用,即是在synchronized同步块中调用,
12 | * 不然会抛出IllegalMonitorStateException的异常。
13 | * Created by dawish on 2017/7/14.
14 | */
15 |
16 | public class MainApp {
17 | public static void main(String[] args) {
18 | Storage storage = new Storage();
19 |
20 | Producer producer1 = new Producer(storage, "Producer-1");
21 | Producer producer2 = new Producer(storage, "Producer-2");
22 | Producer producer3 = new Producer(storage, "Producer-3");
23 | Producer producer4 = new Producer(storage, "Producer-4");
24 |
25 | Consumer consumer1 = new Consumer(storage, "Consumer-1");
26 | Consumer consumer2 = new Consumer(storage, "Consumer-2");
27 |
28 | producer1.start();
29 | producer2.start();
30 | producer3.start();
31 | producer4.start();
32 |
33 | consumer1.start();
34 | consumer2.start();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/JavaLib/src/main/java/com/danxx/thread/Producer.java:
--------------------------------------------------------------------------------
1 | package com.danxx.thread;
2 |
3 | import java.util.UUID;
4 |
5 | /**
6 | * 生产者
7 | * Created by dawish on 2017/7/13.
8 | */
9 | public class Producer extends Thread{
10 |
11 | private Storage storage;//生产者仓库
12 | private String name="";
13 |
14 | public Producer(Storage storage, String name) {
15 | this.storage = storage;
16 | this.name = name;
17 | }
18 | public void run(){
19 | //生产者每隔1s生产1~100消息
20 | long oldTime = System.currentTimeMillis();
21 | while(true){
22 | synchronized(storage){
23 | if (System.currentTimeMillis() - oldTime >= 1000) {
24 | oldTime = System.currentTimeMillis();
25 | String msg = UUID.randomUUID().toString();
26 | storage.put("-ID:" ,name);
27 | }
28 | }
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/JavaLib/src/main/java/com/danxx/thread/Storage.java:
--------------------------------------------------------------------------------
1 | package com.danxx.thread;
2 |
3 | import java.util.LinkedList;
4 | import java.util.Queue;
5 |
6 | /**
7 | * 数据存储仓库和操作
8 | * 一个缓冲区,缓冲区有最大限制,当缓冲区满
9 | * 的时候,生产者是不能将产品放入到缓冲区里面的,
10 | * 当然,当缓冲区是空的时候,消费者也不能从中拿出来产品,
11 | * 这就涉及到了在多线程中的条件判断
12 | * Created by dawish on 2017/7/13.
13 | */
14 | public class Storage {
15 |
16 | private static volatile int goodNumber = 1;
17 |
18 | private final static int MAX_SIZE = 20;
19 | /**
20 | * Queue操作解析:
21 | * add 增加一个元索 如果队列已满, 则抛出一个IIIegaISlabEepeplian异常
22 | * remove 移除并返回队列头部的元素 如果队列为空, 则抛出一个NoSuchElementException异常
23 | * element 返回队列头部的元素 如果队列为空, 则抛出一个NoSuchElementException异常
24 | * offer 添加一个元素并返回true 如果队列已满, 则返回false
25 | * poll 移除并返问队列头部的元素 如果队列为空, 则返回null
26 | * peek 返回队列头部的元素 如果队列为空, 则返回null
27 | * put 添加一个元素 如果队列满, 则阻塞
28 | * take 移除并返回队列头部的元素 如果队列为空, 则阻塞
29 | *
30 | */
31 | Queue storage;
32 | public Storage() {
33 | storage = new LinkedList();
34 | }
35 |
36 | /**
37 | *
38 | * @param dataValue
39 | */
40 | public synchronized void put(String dataValue, String threadName){
41 | if(storage.size() >= MAX_SIZE){
42 | try {
43 | goodNumber = 1;
44 | super.wait(); //当生产满了后让生产线程等待
45 | return;
46 | } catch (InterruptedException e) {
47 | e.printStackTrace();
48 | }
49 | }
50 | storage.add(dataValue + goodNumber++);
51 | System.out.println(threadName + dataValue + goodNumber);
52 | super.notify(); //每次添加一个数据就唤醒一个消费等待的线程来消费
53 | }
54 |
55 | /**
56 | *
57 | * @return
58 | * @throws InterruptedException
59 | */
60 | public synchronized String get(String threadName) {
61 | if(storage.size() == 0){
62 | try {
63 | super.wait(); //当产品仓库为空的时候让消费线程等待
64 | System.out.println(threadName + "wait");
65 | } catch (InterruptedException e) {
66 | e.printStackTrace();
67 | }
68 | return null;
69 | }
70 | super.notify(); //当数据不为空的时候就唤醒一个生产线程来生产
71 | String value = storage.remove();
72 | return value;
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CustomViews
2 | ## 项目结构图
3 | 
4 | ## Android Custom Views 自定义控件
5 | ## Android NDK Demo NDK开发,apk安全,签名验证和加解密
6 | ## Android AOP Demo android aop实现方法拦截和统计
7 | ## Android DxIamgeLoader Lib 打造自己的图片加载库
8 | ## Android JavaLib Java多线程同步 socket实现
9 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | import org.aspectj.bridge.IMessage
3 | import org.aspectj.bridge.MessageHandler
4 | import org.aspectj.tools.ajc.Main
5 |
6 | ext {
7 | compileSdkVersion = 25
8 | buildToolsVersion = "25.0.2"
9 | minSdkVersion = 14
10 | targetSdkVersion = 25
11 |
12 | supportVersion = "25.3.1"
13 |
14 | aspectjrtVersion = "1.8.1"
15 |
16 | ajc = this.&ajc
17 | }
18 |
19 | buildscript {
20 | repositories {
21 | jcenter()
22 | mavenCentral()
23 | }
24 | dependencies {
25 | classpath 'org.aspectj:aspectjtools:1.8.1'
26 | classpath 'org.aspectj:aspectjweaver:1.8.1'
27 | classpath 'com.android.tools.build:gradle:2.3.3'
28 | }
29 |
30 | tasks.withType(JavaCompile) {
31 | options.encoding = "UTF-8"
32 | }
33 | }
34 | allprojects {
35 | repositories {
36 | jcenter()
37 | mavenCentral()
38 | }
39 | }
40 |
41 | task clean(type: Delete) {
42 | delete rootProject.buildDir
43 | }
44 |
45 | def ajc(String androidbootClassFiles, JavaCompile javaCompile) {
46 | def log = project.logger
47 | log.error "========================"
48 | log.error "Aspectj切片开始编织Class!"
49 | log.error "========================"
50 |
51 | String[] args = ["-showWeaveInfo",
52 | "-1.8",
53 | "-inpath", javaCompile.destinationDir.toString(),
54 | "-aspectpath", javaCompile.classpath.asPath,
55 | "-d", javaCompile.destinationDir.toString(),
56 | "-classpath", javaCompile.classpath.asPath,
57 | "-bootclasspath", androidbootClassFiles]
58 | log.error args.toString()
59 |
60 | MessageHandler handler = new MessageHandler(true);
61 | new Main().run(args, handler)
62 |
63 | for (IMessage message : handler.getMessages(null, true)) {
64 | switch (message.getKind()) {
65 | case IMessage.ABORT:
66 | case IMessage.ERROR:
67 | case IMessage.FAIL:
68 | log.error message.message, message.thrown
69 | throw message.thrown
70 | break;
71 | case IMessage.WARNING:
72 | case IMessage.INFO:
73 | log.info message.message, message.thrown
74 | break;
75 | case IMessage.DEBUG:
76 | log.debug message.message, message.thrown
77 | break;
78 | }
79 | }
80 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/AndroidLearn/b380f8ee58f2a8a87807baf89a42bf0ee4aff301/gradle.properties
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/AndroidLearn/b380f8ee58f2a8a87807baf89a42bf0ee4aff301/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Aug 06 15:27:24 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
7 |
8 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/img/project.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dawish/AndroidLearn/b380f8ee58f2a8a87807baf89a42bf0ee4aff301/img/project.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':Channel1App', ':AppLibrary', ':Aoplib', ':Dximageloader', ':JavaLib', ':Channel2App'
2 |
--------------------------------------------------------------------------------