(getActivity(), android.R.layout.simple_list_item_1, android.R.id.text1, list);
66 | }
67 |
68 | @Override
69 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
70 | Bundle savedInstanceState) {
71 | // TODO Auto-generated method stub
72 | View inView = inflater.inflate(R.layout.fragment_activityforcallback_a, container, false);
73 | mListView = (ListView)inView.findViewById(R.id.callback_listview);
74 | mListView.setAdapter(adapter);
75 | mListView.setOnItemClickListener(this);
76 | return inView;
77 | }
78 |
79 | @Override
80 | public void onPause() {
81 | // TODO Auto-generated method stub
82 | super.onPause();
83 | }
84 |
85 | @Override
86 | public void onItemClick(AdapterView> parent, View view, int position,
87 | long id) {
88 | // TODO Auto-generated method stub
89 | //将选中的列表选项ID和Title传递给实现监听接口的宿主Activity
90 | mArticleSelectedListener.onArticleSelected(position,list.get(position));
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/java/com/androidleaf/fragmentdemo/fragment/ActivityForCallBackFragmentB.java:
--------------------------------------------------------------------------------
1 | package com.androidleaf.fragmentdemo.fragment;
2 |
3 | import com.androidleaf.fragmentdemo.activity.R;
4 | import com.androidleaf.fragmentdemo.fragment.ActivityForCallBackFragmentA.OnArticleSelectedListener;
5 |
6 | import android.annotation.SuppressLint;
7 | import android.app.Fragment;
8 | import android.os.Bundle;
9 | import android.text.TextUtils;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.widget.TextView;
14 | import android.widget.Toast;
15 |
16 | @SuppressLint("NewApi")
17 | public class ActivityForCallBackFragmentB extends Fragment{
18 |
19 | private TextView mTextView;
20 | @Override
21 | public void onCreate(Bundle savedInstanceState) {
22 | // TODO Auto-generated method stub
23 | super.onCreate(savedInstanceState);
24 | }
25 |
26 | @Override
27 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
28 | Bundle savedInstanceState) {
29 | // TODO Auto-generated method stub
30 | View inView = inflater.inflate(R.layout.fragment_activityforcallback_b, container, false);
31 | mTextView = (TextView)inView.findViewById(R.id.callback_textview);
32 | return inView;
33 | }
34 |
35 | @Override
36 | public void onPause() {
37 | // TODO Auto-generated method stub
38 | super.onPause();
39 | }
40 |
41 | public void setContent(String titleContent){
42 | if(!TextUtils.isEmpty(titleContent)){
43 | mTextView.setText(titleContent);
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/java/com/androidleaf/fragmentdemo/fragment/AdapterArticleDetailFragment.java:
--------------------------------------------------------------------------------
1 | package com.androidleaf.fragmentdemo.fragment;
2 |
3 | import com.androidleaf.fragmentdemo.activity.R;
4 | import android.annotation.TargetApi;
5 | import android.app.Fragment;
6 | import android.os.Build;
7 | import android.os.Bundle;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.TextView;
12 |
13 |
14 | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
15 | public class AdapterArticleDetailFragment extends Fragment{
16 |
17 | private TextView titleContent;
18 | public static int index;
19 |
20 | /**
21 | * 实例化 AdapterArticleDetailFragment对象
22 | * @param index
23 | * @return AdapterArticleDetailFragment
24 | */
25 | public static AdapterArticleDetailFragment newInstance(int index){
26 |
27 | AdapterArticleDetailFragment mAdapterArticleDetailFragment = new AdapterArticleDetailFragment();
28 | Bundle mBundle = new Bundle();
29 | mBundle.putInt("index", index);
30 | //保存当前选中的选项ID
31 | mAdapterArticleDetailFragment.setArguments(mBundle);
32 |
33 | return mAdapterArticleDetailFragment;
34 | }
35 |
36 | /**
37 | * 获取当前显示的选项ID
38 | * @return int index
39 | */
40 | public int showIndex(){
41 | if(getArguments() == null){
42 | return 0;
43 | }
44 | return getArguments().getInt("index",0);
45 | }
46 |
47 | @Override
48 | public void onCreate(Bundle savedInstanceState) {
49 | // TODO Auto-generated method stub
50 | super.onCreate(savedInstanceState);
51 | }
52 |
53 | @Override
54 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
55 | Bundle savedInstanceState) {
56 | // TODO Auto-generated method stub
57 | View inView = inflater.inflate(R.layout.fragment_articledetails, container, false);
58 | titleContent = (TextView)inView.findViewById(R.id.articledetails_textview);
59 | //设置详情页的内容
60 | titleContent.setText(AdapterArticleListFragment.articleTitles[getArguments().getInt("index",0)]);
61 | return inView;
62 | }
63 |
64 | @Override
65 | public void onPause() {
66 | // TODO Auto-generated method stub
67 | super.onPause();
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/java/com/androidleaf/fragmentdemo/fragment/AdapterArticleListFragment.java:
--------------------------------------------------------------------------------
1 | package com.androidleaf.fragmentdemo.fragment;
2 |
3 |
4 | import com.androidleaf.fragmentdemo.activity.AdapterArticleDetailActivity;
5 | import com.androidleaf.fragmentdemo.activity.R;
6 |
7 | import android.annotation.SuppressLint;
8 | import android.app.FragmentTransaction;
9 | import android.app.ListFragment;
10 | import android.content.Intent;
11 | import android.os.Bundle;
12 | import android.view.View;
13 | import android.widget.ArrayAdapter;
14 | import android.widget.ListView;
15 |
16 | @SuppressLint("NewApi")
17 | public class AdapterArticleListFragment extends ListFragment{
18 |
19 | /**
20 | * 判断当前加载的是否为大屏幕布局
21 | */
22 | private boolean isScreenPad;
23 | /**
24 | * 用来记录上次选中的项
25 | */
26 | private int mCurrentPosition;
27 |
28 | /**
29 | * 列表测试数据
30 | */
31 | public static String[] articleTitles = {
32 | "a",
33 | "b",
34 | "c",
35 | "d",
36 | "e",
37 | "f",
38 | "g",
39 | };
40 | @Override
41 | public void onCreate(Bundle savedInstanceState) {
42 | // TODO Auto-generated method stub
43 | super.onCreate(savedInstanceState);
44 | }
45 |
46 | @Override
47 | public void onActivityCreated(Bundle savedInstanceState) {
48 | // TODO Auto-generated method stub
49 | super.onActivityCreated(savedInstanceState);
50 |
51 | //绑定数据列表
52 | setListAdapter(new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1, android.R.id.text1, articleTitles));
53 |
54 | View details = getActivity().findViewById(R.id.details_container);
55 | //检测是否使用大屏幕尺寸的布局
56 | isScreenPad = details != null && details.getVisibility() == View.VISIBLE;
57 |
58 | if(savedInstanceState != null){
59 | //获取上次离开界面时列表选项值
60 | mCurrentPosition = savedInstanceState.getInt("currentChoice", 0);
61 | }
62 | if(isScreenPad){
63 | //设置列表选中的选项高亮
64 | getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
65 |
66 | showDetails(mCurrentPosition);
67 | }
68 | }
69 |
70 |
71 |
72 | @Override
73 | public void onListItemClick(ListView l, View v, int position, long id) {
74 | // TODO Auto-generated method stub
75 | super.onListItemClick(l, v, position, id);
76 | showDetails(position);
77 | }
78 |
79 |
80 | /**
81 | * 离开界面时保存当前选中的选项的状态值
82 | */
83 | @Override
84 | public void onSaveInstanceState(Bundle outState) {
85 | // TODO Auto-generated method stub
86 | super.onSaveInstanceState(outState);
87 | outState.putInt("currentChoice", mCurrentPosition);
88 | }
89 |
90 | /**
91 | *
92 | * @param index
93 | */
94 | public void showDetails(int index){
95 | mCurrentPosition = index;
96 | if(isScreenPad){
97 | getListView().setItemChecked(index, true);
98 |
99 | AdapterArticleDetailFragment mDetailFragment = (AdapterArticleDetailFragment) getActivity().getFragmentManager().findFragmentById(R.id.details_container);
100 | //若mDetailFragment为空或选中非当前显示的Fragment
101 | if(mDetailFragment == null || mDetailFragment.showIndex() != index){
102 | mDetailFragment = AdapterArticleDetailFragment.newInstance(index);
103 | //替换Fragment实例对象
104 | getActivity().getFragmentManager().beginTransaction().replace(R.id.details_container, mDetailFragment)
105 | .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
106 | .commit();
107 | }
108 | }else{
109 | Intent mIntent = new Intent();
110 | mIntent.setClass(getActivity(), AdapterArticleDetailActivity.class);
111 | Bundle mBundle = new Bundle();
112 | mBundle.putInt("index", index);
113 | mIntent.putExtras(mBundle);
114 | getActivity().startActivity(mIntent);
115 | }
116 | }
117 |
118 | @Override
119 | public void onPause() {
120 | // TODO Auto-generated method stub
121 | super.onPause();
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/java/com/androidleaf/fragmentdemo/fragment/AddActionBarForFragment.java:
--------------------------------------------------------------------------------
1 | package com.androidleaf.fragmentdemo.fragment;
2 |
3 | import java.util.ArrayList;
4 |
5 | import com.androidleaf.fragmentdemo.activity.R;
6 |
7 | import android.annotation.SuppressLint;
8 | import android.app.ActionBar;
9 | import android.app.Activity;
10 | import android.app.Fragment;
11 | import android.os.Bundle;
12 | import android.view.LayoutInflater;
13 | import android.view.Menu;
14 | import android.view.MenuInflater;
15 | import android.view.MenuItem;
16 | import android.view.View;
17 | import android.view.ViewGroup;
18 | import android.widget.Toast;
19 |
20 | @SuppressLint("NewApi")
21 | public class AddActionBarForFragment extends Fragment{
22 |
23 | @Override
24 | public void onAttach(Activity activity) {
25 | // TODO Auto-generated method stub
26 | super.onAttach(activity);
27 | }
28 |
29 | @Override
30 | public void onCreate(Bundle savedInstanceState) {
31 | // TODO Auto-generated method stub
32 | super.onCreate(savedInstanceState);
33 | //设置是否愿意添加item到选项菜单,true为真(必须设置,否则fragment接受不到onCreateOptionsMenu()的调用)
34 | setHasOptionsMenu(true);
35 | ActionBar mActionBar = getActivity().getActionBar();
36 |
37 | if(mActionBar != null){
38 | mActionBar.setDisplayHomeAsUpEnabled(true);
39 | mActionBar.setIcon(R.mipmap.inchengdu);
40 | mActionBar.setTitle("Fragment");
41 | }
42 |
43 | }
44 |
45 | @Override
46 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
47 | Bundle savedInstanceState) {
48 | // TODO Auto-generated method stub
49 | View inView = inflater.inflate(R.layout.fragment_addactionbar, container, false);
50 | return inView;
51 | }
52 | @Override
53 | public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
54 | // TODO Auto-generated method stub
55 | super.onCreateOptionsMenu(menu, inflater);
56 | inflater.inflate(R.menu.main, menu);
57 | }
58 |
59 | @Override
60 | public boolean onOptionsItemSelected(MenuItem item) {
61 | // TODO Auto-generated method stub
62 | switch (item.getItemId()) {
63 | case android.R.id.home:
64 | getActivity().getFragmentManager().beginTransaction().remove(this).commit();
65 | break;
66 | default:
67 | break;
68 | }
69 | showToast(item.getTitle().toString());
70 | return super.onOptionsItemSelected(item);
71 | }
72 |
73 | public void showToast(String info){
74 | Toast.makeText(getActivity(), info, Toast.LENGTH_SHORT).show();
75 | }
76 |
77 | @Override
78 | public void onPause() {
79 | // TODO Auto-generated method stub
80 | super.onPause();
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/java/com/androidleaf/fragmentdemo/fragment/AddFragmentFirst.java:
--------------------------------------------------------------------------------
1 | package com.androidleaf.fragmentdemo.fragment;
2 |
3 | import com.androidleaf.fragmentdemo.activity.R;
4 |
5 | import android.annotation.SuppressLint;
6 | import android.app.Fragment;
7 | import android.os.Bundle;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 |
12 | @SuppressLint("NewApi")
13 | public class AddFragmentFirst extends Fragment {
14 |
15 | @Override
16 | public void onCreate(Bundle savedInstanceState) {
17 | // TODO Auto-generated method stub
18 | super.onCreate(savedInstanceState);
19 | }
20 |
21 | @Override
22 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
23 | Bundle savedInstanceState) {
24 | // TODO Auto-generated method stub
25 | View inView = inflater.inflate(R.layout.fragment_addfragmentfirst, container, false);
26 | return inView;
27 | }
28 |
29 | @Override
30 | public void onPause() {
31 | // TODO Auto-generated method stub
32 | super.onPause();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/java/com/androidleaf/fragmentdemo/fragment/AddFragmentSecond.java:
--------------------------------------------------------------------------------
1 | package com.androidleaf.fragmentdemo.fragment;
2 |
3 | import com.androidleaf.fragmentdemo.activity.R;
4 |
5 | import android.annotation.SuppressLint;
6 | import android.app.Fragment;
7 | import android.os.Bundle;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 |
12 | @SuppressLint("NewApi")
13 | public class AddFragmentSecond extends Fragment {
14 |
15 | @Override
16 | public void onCreate(Bundle savedInstanceState) {
17 | // TODO Auto-generated method stub
18 | super.onCreate(savedInstanceState);
19 |
20 | }
21 |
22 | @Override
23 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
24 | Bundle savedInstanceState) {
25 | // TODO Auto-generated method stub
26 | View inView = inflater.inflate(R.layout.fragment_addfragmentsecond, container, false);
27 | return inView;
28 | }
29 |
30 | @Override
31 | public void onPause() {
32 | // TODO Auto-generated method stub
33 | super.onPause();
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/java/com/androidleaf/fragmentdemo/fragment/ExampleFirstFragment.java:
--------------------------------------------------------------------------------
1 | package com.androidleaf.fragmentdemo.fragment;
2 |
3 | import com.androidleaf.fragmentdemo.activity.R;
4 |
5 | import android.annotation.SuppressLint;
6 | import android.app.Fragment;
7 | import android.os.Bundle;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 |
12 | @SuppressLint("NewApi")
13 | public class ExampleFirstFragment extends Fragment {
14 |
15 | @Override
16 | public void onCreate(Bundle savedInstanceState) {
17 | // TODO Auto-generated method stub
18 | /**
19 | * 这里主要初始化一些在Fragment需使用和持久化的必要组件
20 | */
21 | super.onCreate(savedInstanceState);
22 |
23 | }
24 |
25 | @Override
26 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
27 | Bundle savedInstanceState) {
28 | // TODO Auto-generated method stub
29 | /**
30 | * 使用inflate()方法加载一个自定义的Layout布局,该布局是Fragment的根布局view.
31 | * inflate()方法的3个参数:
32 | * 1.想要加载的Layout Resource Id;
33 | * 2.加载 Layout的父ViewGroup,目的是将Layout挂靠到container上;
34 | * 3.布尔值,指示是否将Layout附着到ViewGroup中,这里一般指定false,
35 | * 因为Layout已经附着到container上,若为true,系统将为Layout新建一个ViewGroup作为附着对象,多余;
36 | */
37 | View inView = inflater.inflate(R.layout.fragment_main, container, false);
38 |
39 | /**
40 | * 这里主要是初始化Layout中的控件对象
41 | */
42 | return inView;
43 | }
44 |
45 | @Override
46 | public void onPause() {
47 | // TODO Auto-generated method stub
48 | super.onPause();
49 | /**
50 | * 当用户离开此Fragment界面时,系统调用此方法,这里主要保存一些需要持久化的对象状态
51 | */
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/java/com/androidleaf/fragmentdemo/fragment/LifeCycleFragment.java:
--------------------------------------------------------------------------------
1 | package com.androidleaf.fragmentdemo.fragment;
2 |
3 | import com.androidleaf.fragmentdemo.activity.R;
4 |
5 | import android.annotation.SuppressLint;
6 | import android.app.Activity;
7 | import android.app.Fragment;
8 | import android.os.Bundle;
9 | import android.util.Log;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 |
14 | @SuppressLint("NewApi")
15 | public class LifeCycleFragment extends Fragment {
16 |
17 | private static final String TAG = "FragmentLifeCycle";
18 |
19 | @Override
20 | public void onAttach(Activity activity) {
21 | // TODO Auto-generated method stub
22 | super.onAttach(activity);
23 | Log.i(TAG, "onAttach");
24 | }
25 |
26 | @Override
27 | public void onCreate(Bundle savedInstanceState) {
28 | // TODO Auto-generated method stub
29 | super.onCreate(savedInstanceState);
30 | Log.i(TAG, "onCreate");
31 | }
32 |
33 | @Override
34 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
35 | Bundle savedInstanceState) {
36 | // TODO Auto-generated method stub
37 | Log.i(TAG, "onCreateView");
38 |
39 | View rootView = inflater.inflate(R.layout.fragment_lifecycle, container, false);
40 | return rootView;
41 | }
42 |
43 | @Override
44 | public void onActivityCreated(Bundle savedInstanceState) {
45 | // TODO Auto-generated method stub
46 | super.onActivityCreated(savedInstanceState);
47 | Log.i(TAG, "onActivityCreated");
48 | }
49 |
50 | @Override
51 | public void onStart() {
52 | // TODO Auto-generated method stub
53 | super.onStart();
54 | Log.i(TAG, "onStart");
55 | }
56 |
57 | @Override
58 | public void onResume() {
59 | // TODO Auto-generated method stub
60 | super.onResume();
61 | Log.i(TAG, "onResume");
62 | }
63 |
64 | @Override
65 | public void onPause() {
66 | // TODO Auto-generated method stub
67 | super.onPause();
68 | Log.i(TAG, "onPause");
69 | }
70 |
71 | @Override
72 | public void onStop() {
73 | // TODO Auto-generated method stub
74 | super.onStop();
75 | Log.i(TAG, "onStop");
76 | }
77 |
78 | @Override
79 | public void onDestroyView() {
80 | // TODO Auto-generated method stub
81 | super.onDestroyView();
82 | Log.i(TAG, "onDestroyView");
83 | }
84 |
85 | @Override
86 | public void onDestroy() {
87 | // TODO Auto-generated method stub
88 | super.onDestroy();
89 | Log.i(TAG, "onDestroy");
90 | }
91 |
92 | @Override
93 | public void onDetach() {
94 | // TODO Auto-generated method stub
95 | super.onDetach();
96 | Log.i(TAG, "onDetach");
97 | }
98 |
99 | }
100 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/layout-land/activity_adaptermobile_and_pad.xml:
--------------------------------------------------------------------------------
1 |
8 |
15 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/layout/activity_activityforcallback.xml:
--------------------------------------------------------------------------------
1 |
8 |
15 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/layout/activity_adaptermobile_and_pad.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/layout/activity_addactionbar.xml:
--------------------------------------------------------------------------------
1 |
8 |
15 |
16 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/layout/activity_addbydynamic.xml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/layout/activity_addbystatic.xml:
--------------------------------------------------------------------------------
1 |
8 |
15 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/layout/activity_articledetails_activity.xml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/layout/activity_examplefirst.xml:
--------------------------------------------------------------------------------
1 |
8 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/layout/activity_lifecycle.xml:
--------------------------------------------------------------------------------
1 |
8 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
9 |
14 |
20 |
26 |
32 |
38 |
44 |
50 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/layout/fragment_activityforcallback_a.xml:
--------------------------------------------------------------------------------
1 |
11 |
16 |
17 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/layout/fragment_activityforcallback_b.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/layout/fragment_addactionbar.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/layout/fragment_addfragmentfirst.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/layout/fragment_addfragmentsecond.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/layout/fragment_articledetails.xml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/layout/fragment_examplefirst.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/layout/fragment_lifecycle.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/layout/fragment_main.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/menu/main.xml:
--------------------------------------------------------------------------------
1 |
26 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/01FragmentDemo/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/01FragmentDemo/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/mipmap-hdpi/inchengdu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/01FragmentDemo/src/main/res/mipmap-hdpi/inchengdu.png
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/01FragmentDemo/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/01FragmentDemo/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/01FragmentDemo/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/01FragmentDemo/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/01FragmentDemo/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/01FragmentDemo/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/01FragmentDemo/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/01FragmentDemo/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 16dp
5 | 16dp
6 |
7 |
8 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 01FragmentDemo
3 |
4 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/01FragmentDemo/src/test/java/com/androidleaf/fragmentdemo/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.androidleaf.fragmentdemo;
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 | }
--------------------------------------------------------------------------------
/02ServiceDemo/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/02ServiceDemo/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 |
7 | defaultConfig {
8 | applicationId "com.androidleaf.servicedemo"
9 | minSdkVersion 15
10 | targetSdkVersion 25
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 | compile 'com.android.support:appcompat-v7:25.2.0'
31 | compile 'com.android.support.constraint:constraint-layout:1.0.1'
32 | testCompile 'junit:junit:4.12'
33 | }
34 |
--------------------------------------------------------------------------------
/02ServiceDemo/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 G:\DevelopmentSoftWare\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 |
--------------------------------------------------------------------------------
/02ServiceDemo/src/androidTest/java/com/androidleaf/servicedemo/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.androidleaf.servicedemo;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.androidleaf.servicedemo", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/02ServiceDemo/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
12 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/02ServiceDemo/src/main/java/com/androidleaf/servicedemo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.androidleaf.servicedemo;
2 |
3 | import android.app.Activity;
4 | import android.content.ComponentName;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.content.ServiceConnection;
8 | import android.os.Bundle;
9 | import android.os.Handler;
10 | import android.os.IBinder;
11 | import android.os.Message;
12 | import android.os.Messenger;
13 | import android.os.RemoteException;
14 | import android.util.Log;
15 | import android.view.View;
16 | import android.view.View.OnClickListener;
17 | import android.widget.Button;
18 | import android.widget.TextView;
19 | import android.widget.Toast;
20 |
21 | import com.androidleaf.servicedemo.service.MessengerService;
22 | import com.androidleaf.servicedemo.service.MyIntentServiceExecuteDemo;
23 | import com.androidleaf.servicedemo.service.MyServiceDemo;
24 | import com.androidleaf.servicedemo.service.MyServiceExecuteDemo;
25 |
26 | public class MainActivity extends Activity implements OnClickListener{
27 | /** Called when the activity is first created. */
28 |
29 | //声明控件对象
30 | private Button mButton_startservice;
31 | private Button mButton_stopservice;
32 | private Button mButton_intentservice_execute;
33 | private Button mButton_service_execute;
34 | private Button mButton_start_main_execute;
35 | private Button mButton_messenger_boundservice;
36 | private Button mButton_messenger_unboundservice;
37 | private Button mButton_boundservice;
38 | private Button mButton_unboundservice;
39 | private TextView mCallbackText;
40 |
41 | //声明Binder对象
42 | private MyServiceDemo.MyBinder myBinder;
43 | private static final String TAG = "androidLeaf";
44 | private boolean mIsBound = false;
45 | Messenger mService = null;
46 |
47 | @Override
48 | public void onCreate(Bundle savedInstanceState) {
49 | super.onCreate(savedInstanceState);
50 | setContentView(R.layout.main);
51 |
52 | //根据ID得到代表该控件的对象
53 | mButton_startservice = (Button)findViewById(R.id.startservice_button);
54 | mButton_stopservice = (Button)findViewById(R.id.stopservice_button);
55 | mButton_intentservice_execute = (Button)findViewById(R.id.intentservice_execute_button);
56 | mButton_start_main_execute = (Button)findViewById(R.id.start_main_execute);
57 | mButton_service_execute = (Button)findViewById(R.id.service_execute_button);
58 | mButton_messenger_boundservice = (Button)findViewById(R.id.messenger_boundservice_button);
59 | mButton_messenger_unboundservice = (Button)findViewById(R.id.messenger_unboundservice_button);
60 | mButton_boundservice = (Button)findViewById(R.id.boundservice_button);
61 | mButton_unboundservice = (Button)findViewById(R.id.unboundservice_button);
62 | mCallbackText = (TextView)findViewById(R.id.callBack_textview);
63 | //为Button设置事件监听
64 | mButton_startservice.setOnClickListener(this);
65 | mButton_stopservice.setOnClickListener(this);
66 | mButton_intentservice_execute.setOnClickListener(this);
67 | mButton_service_execute.setOnClickListener(this);
68 | mButton_start_main_execute.setOnClickListener(this);
69 | mButton_messenger_boundservice.setOnClickListener(this);
70 | mButton_messenger_unboundservice.setOnClickListener(this);
71 | mButton_boundservice.setOnClickListener(this);
72 | mButton_unboundservice.setOnClickListener(this);
73 |
74 | }
75 |
76 | public void onClick(View v) {
77 | // TODO Auto-generated method stub
78 | int viewID = v.getId();
79 |
80 | switch (viewID) {
81 | case R.id.startservice_button:
82 | startServiceMethod();
83 | break;
84 | case R.id.stopservice_button:
85 | stopServiceMethod();
86 | break;
87 | case R.id.intentservice_execute_button:
88 | intentServiceExecute();
89 | break;
90 | case R.id.service_execute_button:
91 | serviceExecute();
92 | break;
93 | case R.id.start_main_execute:
94 | startMainExecute();
95 | break;
96 | case R.id.messenger_boundservice_button:
97 | messengerBoundServiceMethod();
98 | break;
99 | case R.id.messenger_unboundservice_button:
100 | messengerUnBoundServiceMethod();
101 | break;
102 | case R.id.boundservice_button:
103 | boundServiceMethod();
104 | break;
105 | case R.id.unboundservice_button:
106 | unBoundServiceMethod();
107 | break;
108 | default:
109 | break;
110 | }
111 |
112 | }
113 | //开启Service
114 | public void startServiceMethod()
115 | {
116 | Intent mIntent = new Intent(this,MyServiceDemo.class);
117 |
118 | this.startService(mIntent);
119 | }
120 | //停止Service
121 | public void stopServiceMethod()
122 | {
123 | Intent mIntent = new Intent(this,MyServiceDemo.class);
124 | this.stopService(mIntent);
125 | }
126 | //使用Intentservice执行耗时任务
127 | public void intentServiceExecute()
128 | {
129 | //创建Intent对象
130 | Intent mIntent = new Intent(this,MyIntentServiceExecuteDemo.class);
131 | //开启IntentService
132 | this.startService(mIntent);
133 | }
134 | //使用IntentService执行耗时任务
135 | public void serviceExecute()
136 | {
137 | //创建Intent对象
138 | Intent mIntent = new Intent(this,MyServiceExecuteDemo.class);
139 | //开启IntentService
140 | this.startService(mIntent);
141 |
142 | }
143 | //开启主线程中的耗时操作(这里用线程睡眠来模拟)
144 | public void startMainExecute()
145 | {
146 | waitForMinutes();
147 | }
148 | //耗时操作方法
149 | public void waitForMinutes()
150 | {
151 | for(int i = 0; i < 50;i++)
152 | {
153 | Log.i(TAG, "主线程中执行。。。。。。。"+ (i + 1));
154 | try {
155 | Thread.sleep(500);
156 | } catch (InterruptedException e) {
157 | // TODO Auto-generated catch block
158 | e.printStackTrace();
159 | }
160 | }
161 | }
162 | //创建一个继承Handler的子类IncomingHandler,用于接收Service后台发送过来的Message(本对象的哈希值)
163 | class IncomingHandler extends Handler {
164 | @Override
165 | public void handleMessage(Message msg) {
166 | switch (msg.what) {
167 | case MessengerService.MSG_SET_VALUE:
168 | mCallbackText.setText("Received from service: " + msg.arg1);
169 | break;
170 | default:
171 | super.handleMessage(msg);
172 | }
173 | }
174 | }
175 | //实例化Messenger和IncomingHandler对象并建立两者之间的关联
176 | final Messenger mMessenger = new Messenger(new IncomingHandler());
177 |
178 | //绑定Service
179 | public void messengerBoundServiceMethod()
180 | {
181 | this.bindService(new Intent(MainActivity.this, MessengerService.class), mServiceConnection2, Context.BIND_AUTO_CREATE);
182 | mIsBound = true;
183 | mCallbackText.setText("Binding.");
184 | }
185 | //解除Service绑定
186 | public void messengerUnBoundServiceMethod()
187 | {
188 | if (mIsBound) {
189 | // If we have received the service, and hence registered with
190 | // it, then now is the time to unregister.
191 | if (mService != null) {
192 | try {
193 | //将客户端前台的Messenger发送至Service后台,后台将持有对应该Messenger的对象删除
194 | Message msg = Message.obtain(null,
195 | MessengerService.MSG_UNREGISTER_CLIENT);
196 | msg.replyTo = mMessenger;
197 | mService.send(msg);
198 | } catch (RemoteException e) {
199 | // There is nothing special we need to do if the service
200 | // has crashed.
201 | }
202 | }
203 |
204 | // Detach our existing connection.
205 | unbindService(mServiceConnection2);
206 | mIsBound = false;
207 | mCallbackText.setText("Unbinding.");
208 | }
209 | }
210 | //绑定Service
211 | public void boundServiceMethod()
212 | {
213 | Intent mIntent = new Intent(this,MyServiceDemo.class);
214 | this.bindService(mIntent, mServiceConnection, BIND_AUTO_CREATE);
215 | mIsBound = true;
216 | }
217 | //解除Service绑定
218 | public void unBoundServiceMethod()
219 | { if(mIsBound)
220 | {
221 | this.unbindService(mServiceConnection);
222 | Toast.makeText(getApplicationContext(), "unBound Service", Toast.LENGTH_LONG).show();
223 | }
224 | }
225 |
226 | //使用MyServiceDemo,实例化ServiceConnection对象,建立Activity与后台Service的连接
227 | ServiceConnection mServiceConnection = new ServiceConnection() {
228 |
229 | public void onServiceDisconnected(ComponentName name) {
230 | // TODO Auto-generated method stub
231 | Log.i(TAG, "onServiceDisconnected()");
232 | }
233 | public void onServiceConnected(ComponentName name, IBinder service) {
234 | // TODO Auto-generated method stub
235 | Log.i(TAG, "onServiceConnected()");
236 | myBinder = (MyServiceDemo.MyBinder)service;
237 | myBinder.getString("Mr Li");
238 | }
239 | };
240 |
241 | //使用MessengerService,实例化ServiceConnection对象,建立Activity和后台Service的连接
242 | ServiceConnection mServiceConnection2 = new ServiceConnection() {
243 |
244 | public void onServiceDisconnected(ComponentName name) {
245 | // TODO Auto-generated method stub
246 | // This is called when the connection with the service has been
247 | // unexpectedly disconnected -- that is, its process crashed.
248 | mService = null;
249 | mCallbackText.setText("Disconnected.");
250 |
251 | // As part of the sample, tell the user what happened.
252 | Toast.makeText(MainActivity.this, "remote_service_disconnected",
253 | Toast.LENGTH_SHORT).show();
254 |
255 | }
256 |
257 | public void onServiceConnected(ComponentName name, IBinder service) {
258 | // TODO Auto-generated method stub
259 | //得到从Service发送过来的IBinder对象并初始化成Messenger
260 | mService = new Messenger(service);
261 |
262 | mCallbackText.setText("Attached.");
263 | // We want to monitor the service for as long as we are
264 | // connected to it.
265 | try {
266 | //将客户端前台的Messenger对象发送至Service,并通知后台的Messenger集合持有该对象
267 | Message msg = Message.obtain(null,
268 | MessengerService.MSG_REGISTER_CLIENT);
269 | msg.replyTo = mMessenger;
270 | //发送Message
271 | mService.send(msg);
272 |
273 | // Give it some value as an example.
274 | //将本对象的哈希值发送给Service后台
275 | msg = Message.obtain(null,
276 | MessengerService.MSG_SET_VALUE, this.hashCode(), 0);
277 | mService.send(msg);
278 | } catch (RemoteException e) {
279 | // In this case the service has crashed before we could even
280 | // do anything with it; we can count on soon being
281 | // disconnected (and then reconnected if it can be restarted)
282 | // so there is no need to do anything here.
283 | }
284 | // As part of the sample, tell the user what happened.
285 | Toast.makeText(MainActivity.this,"remote_service_connected",
286 | Toast.LENGTH_SHORT).show();
287 | }
288 | };
289 | }
--------------------------------------------------------------------------------
/02ServiceDemo/src/main/java/com/androidleaf/servicedemo/service/MessengerService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2010 The Android Open Source Project
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.androidleaf.servicedemo.service;
18 |
19 | import android.app.Notification;
20 | import android.app.NotificationManager;
21 | import android.app.PendingIntent;
22 | import android.app.Service;
23 | import android.content.Intent;
24 | import android.os.Binder;
25 | import android.os.Handler;
26 | import android.os.IBinder;
27 | import android.os.Message;
28 | import android.os.Messenger;
29 | import android.os.RemoteException;
30 | import android.util.Log;
31 | import android.widget.Toast;
32 |
33 | import com.androidleaf.servicedemo.MainActivity;
34 | import com.androidleaf.servicedemo.R;
35 |
36 | import java.util.ArrayList;
37 |
38 | // Need the following import to get access to the app resources, since this
39 | // class is in a sub-package.
40 | //import com.example.android.apis.R;
41 | //import com.example.android.apis.app.RemoteService.Controller;
42 |
43 | /**
44 | * This is an example of implementing an application service that uses the
45 | * {@link Messenger} class for communicating with clients. This allows for
46 | * remote interaction with a service, without needing to define an AIDL
47 | * interface.
48 | *
49 | * Notice the use of the {@link NotificationManager} when interesting things
50 | * happen in the service. This is generally how background services should
51 | * interact with the user, rather than doing something more disruptive such as
52 | * calling startActivity().
53 | */
54 |
55 | public class MessengerService extends Service {
56 | /** For showing and hiding our notification. */
57 | NotificationManager mNM;
58 | /** Keeps track of all current registered clients. */
59 | ArrayList mClients = new ArrayList();
60 | /** Holds last value set by a client. */
61 | int mValue = 0;
62 |
63 | /**
64 | * Command to the service to register a client, receiving callbacks
65 | * from the service. The Message's replyTo field must be a Messenger of
66 | * the client where callbacks should be sent.
67 | */
68 | public static final int MSG_REGISTER_CLIENT = 1;
69 |
70 | /**
71 | * Command to the service to unregister a client, ot stop receiving callbacks
72 | * from the service. The Message's replyTo field must be a Messenger of
73 | * the client as previously given with MSG_REGISTER_CLIENT.
74 | */
75 | public static final int MSG_UNREGISTER_CLIENT = 2;
76 |
77 | /**
78 | * Command to service to set a new value. This can be sent to the
79 | * service to supply a new value, and will be sent by the service to
80 | * any registered clients with the new value.
81 | */
82 | public static final int MSG_SET_VALUE = 3;
83 |
84 | /**
85 | * Handler of incoming messages from clients.
86 | */
87 | class IncomingHandler extends Handler {
88 | @Override
89 | public void handleMessage(Message msg) {
90 | switch (msg.what) {
91 | case MSG_REGISTER_CLIENT:
92 | mClients.add(msg.replyTo);
93 | break;
94 | case MSG_UNREGISTER_CLIENT:
95 | mClients.remove(msg.replyTo);
96 | break;
97 | case MSG_SET_VALUE:
98 | mValue = msg.arg1;
99 | for (int i=mClients.size()-1; i>=0; i--) {
100 | try {
101 | mClients.get(i).send(Message.obtain(null,
102 | MSG_SET_VALUE, mValue, 0));
103 | } catch (RemoteException e) {
104 | // The client is dead. Remove it from the list;
105 | // we are going through the list from back to front
106 | // so this is safe to do inside the loop.
107 | mClients.remove(i);
108 | }
109 | }
110 | break;
111 | default:
112 | super.handleMessage(msg);
113 | }
114 | }
115 | }
116 |
117 | /**
118 | * Target we publish for clients to send messages to IncomingHandler.
119 | */
120 | final Messenger mMessenger = new Messenger(new IncomingHandler());
121 |
122 | @Override
123 | public void onCreate() {
124 | mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
125 |
126 | // Display a notification about us starting.
127 | showNotification();
128 | }
129 |
130 | @Override
131 | public void onDestroy() {
132 | // Cancel the persistent notification.
133 | mNM.cancel(R.string.remote_service_started);
134 |
135 | // Tell the user we stopped.
136 | Toast.makeText(this, R.string.remote_service_stopped, Toast.LENGTH_SHORT).show();
137 | }
138 |
139 | /**
140 | * When binding to the service, we return an interface to our messenger
141 | * for sending messages to the service.
142 | */
143 | @Override
144 | public IBinder onBind(Intent intent) {
145 | return mMessenger.getBinder();
146 | }
147 |
148 | /**
149 | * Show a notification while this service is running.
150 | */
151 | private void showNotification() {
152 | // In this sample, we'll use the same text for the ticker and the expanded notification
153 | CharSequence text = getText(R.string.remote_service_started);
154 |
155 | // Set the icon, scrolling text and timestamp
156 | Notification notification = new Notification(R.mipmap.stat_sample, text,
157 | System.currentTimeMillis());
158 |
159 | // The PendingIntent to launch our activity if the user selects this notification
160 | PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
161 | new Intent(this,MainActivity.class), 0);
162 |
163 | // Set the info for the views that show in the notification panel.
164 | // notification.setLatestEventInfo(this, getText(R.string.remote_service_label),
165 | // text, contentIntent);
166 |
167 | // Send the notification.
168 | // We use a string id because it is a unique number. We use it later to cancel.
169 | mNM.notify(R.string.remote_service_started, notification);
170 | }
171 | }
172 |
--------------------------------------------------------------------------------
/02ServiceDemo/src/main/java/com/androidleaf/servicedemo/service/MyIntentServiceExecuteDemo.java:
--------------------------------------------------------------------------------
1 | package com.androidleaf.servicedemo.service;
2 |
3 | import android.app.IntentService;
4 | import android.content.Intent;
5 | import android.util.Log;
6 |
7 | public class MyIntentServiceExecuteDemo extends IntentService {
8 |
9 | private static final String TAG = "androidLeaf";
10 |
11 | public MyIntentServiceExecuteDemo() {
12 | super("MyIntentServiceExecuteDemo");
13 | // TODO Auto-generated constructor stub
14 | }
15 | @Override
16 | protected void onHandleIntent(Intent arg0) {
17 | // TODO Auto-generated method stub
18 | //利用线程睡眠来模拟耗时操作
19 | for(int i = 0; i < 50;i++)
20 | {
21 | Log.i(TAG, "IntentService中子线程执行。。。。。。。"+ (i + 1));
22 | try {
23 | Thread.sleep(500);
24 | } catch (InterruptedException e) {
25 | // TODO Auto-generated catch block
26 | e.printStackTrace();
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/02ServiceDemo/src/main/java/com/androidleaf/servicedemo/service/MyServiceDemo.java:
--------------------------------------------------------------------------------
1 | package com.androidleaf.servicedemo.service;
2 |
3 | import android.app.Service;
4 | import android.content.Intent;
5 | import android.os.Binder;
6 | import android.os.IBinder;
7 | import android.util.Log;
8 | import android.widget.Toast;
9 |
10 | public class MyServiceDemo extends Service {
11 |
12 | private static final String TAG = "androidLeaf";
13 |
14 | @Override
15 | public IBinder onBind(Intent arg0) {
16 | // TODO Auto-generated method stub
17 | Log.i(TAG, "onBind()");
18 | return new MyBinder();
19 | }
20 | @Override
21 | public void onCreate() {
22 | // TODO Auto-generated method stub
23 | Log.i(TAG, "onCreate()");
24 | super.onCreate();
25 | }
26 | @Override
27 | public void onStart(Intent intent, int startId) {
28 | // TODO Auto-generated method stub
29 | Log.i(TAG, "onStart()");
30 | super.onStart(intent, startId);
31 | }
32 | @Override
33 | public int onStartCommand(Intent intent, int flags, int startId) {
34 | // TODO Auto-generated method stub
35 | Log.i(TAG, "onStartCommand()");
36 | return super.onStartCommand(intent, flags, startId);
37 | }
38 | @Override
39 | public void onRebind(Intent intent) {
40 | // TODO Auto-generated method stub
41 | Log.i(TAG, "onRebind()");
42 | super.onRebind(intent);
43 | }
44 | @Override
45 | public boolean onUnbind(Intent intent) {
46 | // TODO Auto-generated method stub
47 | Log.i(TAG, "onUnbind()");
48 | return super.onUnbind(intent);
49 | }
50 | @Override
51 | public void onDestroy() {
52 | // TODO Auto-generated method stub
53 | Log.i(TAG, "onDestroy()");
54 | super.onDestroy();
55 | }
56 | //自定义MyBinder类,继承Binder类
57 | public class MyBinder extends Binder
58 | {
59 | public void getString(String str)
60 | {
61 | Toast.makeText(getApplicationContext(), "Hello, "+ str, Toast.LENGTH_LONG).show();
62 | }
63 | }
64 | }
--------------------------------------------------------------------------------
/02ServiceDemo/src/main/java/com/androidleaf/servicedemo/service/MyServiceExecuteDemo.java:
--------------------------------------------------------------------------------
1 | package com.androidleaf.servicedemo.service;
2 |
3 | import android.app.Service;
4 | import android.content.Intent;
5 | import android.os.Handler;
6 | import android.os.HandlerThread;
7 | import android.os.IBinder;
8 | import android.os.Looper;
9 | import android.os.Message;
10 | import android.util.Log;
11 | import android.widget.Toast;
12 |
13 | public class MyServiceExecuteDemo extends Service {
14 | private Looper mServiceLooper;
15 | private ServiceHandler mServiceHandler;
16 |
17 | private static final String TAG = "androidLeaf";
18 | // Handler that receives messages from the thread
19 | private final class ServiceHandler extends Handler {
20 | public ServiceHandler(Looper looper) {
21 | super(looper);
22 | }
23 | @Override
24 | public void handleMessage(Message msg) {
25 | // Normally we would do some work here, like download a file.
26 | // For our sample, we just sleep for 5 seconds.
27 | for(int i = 0; i < 50;i++)
28 | {
29 | Log.i(TAG, "Service中子线程执行。。。。。。。"+ (i + 1));
30 | try {
31 | Thread.sleep(500);
32 | } catch (InterruptedException e) {
33 | // TODO Auto-generated catch block
34 | e.printStackTrace();
35 | }
36 | }
37 | // Stop the service using the startId, so that we don't stop
38 | // the service in the middle of handling another job
39 | stopSelf(msg.arg1);
40 | }
41 | }
42 |
43 | @Override
44 | public void onCreate() {
45 | // Start up the thread running the service. Note that we create a
46 | // separate thread because the service normally runs in the process's
47 | // main thread, which we don't want to block. We also make it
48 | // background priority so CPU-intensive work will not disrupt our UI.
49 | HandlerThread thread = new HandlerThread("ServiceStartArguments");
50 | thread.start();
51 | // Get the HandlerThread's Looper and use it for our Handler
52 | mServiceLooper = thread.getLooper();
53 | mServiceHandler = new ServiceHandler(mServiceLooper);
54 | }
55 |
56 | @Override
57 | public int onStartCommand(Intent intent, int flags, int startId) {
58 | Toast.makeText(this, "service starting", Toast.LENGTH_SHORT).show();
59 |
60 | // For each start request, send a message to start a job and deliver the
61 | // start ID so we know which request we're stopping when we finish the job
62 | Message msg = mServiceHandler.obtainMessage();
63 | msg.arg1 = startId;
64 | mServiceHandler.sendMessage(msg);
65 |
66 | // If we get killed, after returning from here, restart
67 | return START_STICKY;
68 | }
69 |
70 | @Override
71 | public IBinder onBind(Intent intent) {
72 | // We don't provide binding, so return null
73 | return null;
74 | }
75 |
76 | @Override
77 | public void onDestroy() {
78 | Toast.makeText(this, "service done", Toast.LENGTH_SHORT).show();
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/02ServiceDemo/src/main/res/layout/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
15 |
21 |
27 |
32 |
39 |
46 |
47 |
53 |
59 |
65 |
71 |
77 |
--------------------------------------------------------------------------------
/02ServiceDemo/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/02ServiceDemo/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/02ServiceDemo/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/02ServiceDemo/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/02ServiceDemo/src/main/res/mipmap-hdpi/stat_sample.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/02ServiceDemo/src/main/res/mipmap-hdpi/stat_sample.png
--------------------------------------------------------------------------------
/02ServiceDemo/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/02ServiceDemo/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/02ServiceDemo/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/02ServiceDemo/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/02ServiceDemo/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/02ServiceDemo/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/02ServiceDemo/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/02ServiceDemo/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/02ServiceDemo/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/02ServiceDemo/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/02ServiceDemo/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/02ServiceDemo/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/02ServiceDemo/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/02ServiceDemo/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/02ServiceDemo/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/02ServiceDemo/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/02ServiceDemo/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/02ServiceDemo/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 02ServiceDemo
3 | The service has started
4 | The service has stoped
5 | The Service label
6 |
7 |
--------------------------------------------------------------------------------
/02ServiceDemo/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/02ServiceDemo/src/test/java/com/androidleaf/servicedemo/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.androidleaf.servicedemo;
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 | }
--------------------------------------------------------------------------------
/AndroidBlogSource.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/PluginDemo/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/PluginDemo/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 |
7 | defaultConfig {
8 | applicationId "com.androidleaf.plugindemo"
9 | minSdkVersion 15
10 | targetSdkVersion 25
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 | compile 'com.android.support:appcompat-v7:25.2.0'
31 | compile 'com.android.support.constraint:constraint-layout:1.0.1'
32 | compile 'com.android.support:design:25.2.0'
33 | testCompile 'junit:junit:4.12'
34 | }
35 |
--------------------------------------------------------------------------------
/PluginDemo/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 G:\DevelopmentSoftWare\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 |
--------------------------------------------------------------------------------
/PluginDemo/src/androidTest/java/com/androidleaf/plugindemo/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.androidleaf.plugindemo;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.androidleaf.plugindemo", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/PluginDemo/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/PluginDemo/src/main/java/com/androidleaf/plugindemo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.androidleaf.plugindemo;
2 |
3 | import android.os.Bundle;
4 | import android.support.design.widget.FloatingActionButton;
5 | import android.support.design.widget.Snackbar;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.support.v7.widget.Toolbar;
8 | import android.view.View;
9 | import android.view.Menu;
10 | import android.view.MenuItem;
11 |
12 | public class MainActivity extends AppCompatActivity {
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_main);
18 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
19 | setSupportActionBar(toolbar);
20 |
21 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
22 | fab.setOnClickListener(new View.OnClickListener() {
23 | @Override
24 | public void onClick(View view) {
25 | Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
26 | .setAction("Action", null).show();
27 | }
28 | });
29 | }
30 |
31 | @Override
32 | public boolean onCreateOptionsMenu(Menu menu) {
33 | // Inflate the menu; this adds items to the action bar if it is present.
34 | getMenuInflater().inflate(R.menu.menu_main, menu);
35 | return true;
36 | }
37 |
38 | @Override
39 | public boolean onOptionsItemSelected(MenuItem item) {
40 | // Handle action bar item clicks here. The action bar will
41 | // automatically handle clicks on the Home/Up button, so long
42 | // as you specify a parent activity in AndroidManifest.xml.
43 | int id = item.getItemId();
44 |
45 | //noinspection SimplifiableIfStatement
46 | if (id == R.id.action_settings) {
47 | return true;
48 | }
49 |
50 | return super.onOptionsItemSelected(item);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/PluginDemo/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
10 |
11 |
14 |
15 |
16 |
17 |
18 |
19 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/PluginDemo/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/PluginDemo/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/PluginDemo/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/PluginDemo/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/PluginDemo/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/PluginDemo/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/PluginDemo/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/PluginDemo/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/PluginDemo/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/PluginDemo/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/PluginDemo/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/PluginDemo/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/PluginDemo/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/PluginDemo/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/PluginDemo/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/PluginDemo/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/PluginDemo/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/PluginDemo/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/PluginDemo/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/PluginDemo/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/PluginDemo/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/PluginDemo/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/PluginDemo/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/PluginDemo/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 |
4 |
--------------------------------------------------------------------------------
/PluginDemo/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | PluginDemo
3 | Settings
4 |
5 |
--------------------------------------------------------------------------------
/PluginDemo/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/PluginDemo/src/test/java/com/androidleaf/plugindemo/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.androidleaf.plugindemo;
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 | }
--------------------------------------------------------------------------------
/RecyclerViewDemo/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/RecyclerViewDemo/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 | defaultConfig {
7 | applicationId "com.androidleaf.blogsource"
8 | minSdkVersion 15
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:25.2.0'
28 | compile 'com.android.support.constraint:constraint-layout:1.0.1'
29 | compile 'com.android.support:design:25.2.0'
30 | testCompile 'junit:junit:4.12'
31 | }
32 |
--------------------------------------------------------------------------------
/RecyclerViewDemo/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 G:\DevelopmentSoftWare\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 |
--------------------------------------------------------------------------------
/RecyclerViewDemo/src/androidTest/java/com/androidleaf/blogsource/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.androidleaf.blogsource;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.androidleaf.blogsource", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/RecyclerViewDemo/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/RecyclerViewDemo/src/main/java/com/androidleaf/blogsource/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.androidleaf.blogsource;
2 |
3 | import android.os.Bundle;
4 | import android.support.design.widget.FloatingActionButton;
5 | import android.support.design.widget.Snackbar;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.support.v7.widget.Toolbar;
9 | import android.view.View;
10 | import android.view.Menu;
11 | import android.view.MenuItem;
12 |
13 | public class MainActivity extends AppCompatActivity {
14 |
15 | private RecyclerView recyclerView;
16 |
17 | @Override
18 | protected void onCreate(Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | setContentView(R.layout.activity_main);
21 |
22 | initViews();
23 |
24 |
25 | }
26 |
27 | public void initViews(){
28 | recyclerView = (RecyclerView)findViewById(R.id.recycleview_id);
29 | //设置布局管理器
30 |
31 | //设置adapter
32 |
33 | //设置item增加、移除动画
34 |
35 | //添加分割线
36 |
37 |
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/RecyclerViewDemo/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
36 |
43 |
44 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/RecyclerViewDemo/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/RecyclerViewDemo/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/RecyclerViewDemo/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/RecyclerViewDemo/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/RecyclerViewDemo/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/RecyclerViewDemo/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/RecyclerViewDemo/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/RecyclerViewDemo/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/RecyclerViewDemo/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/RecyclerViewDemo/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/RecyclerViewDemo/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/RecyclerViewDemo/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/RecyclerViewDemo/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/RecyclerViewDemo/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/RecyclerViewDemo/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/RecyclerViewDemo/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/RecyclerViewDemo/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/RecyclerViewDemo/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/RecyclerViewDemo/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/RecyclerViewDemo/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/RecyclerViewDemo/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/RecyclerViewDemo/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/RecyclerViewDemo/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/RecyclerViewDemo/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 |
4 |
--------------------------------------------------------------------------------
/RecyclerViewDemo/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | CSDNBlogSource
3 | Settings
4 |
5 |
--------------------------------------------------------------------------------
/RecyclerViewDemo/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/RecyclerViewDemo/src/test/java/com/androidleaf/blogsource/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.androidleaf.blogsource;
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 | }
--------------------------------------------------------------------------------
/RxjavaDemo/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/RxjavaDemo/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 |
7 | defaultConfig {
8 | applicationId "com.androidleaf.rxjavademo"
9 | minSdkVersion 15
10 | targetSdkVersion 25
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 | compile 'com.android.support:appcompat-v7:25.2.0'
31 | compile 'com.android.support.constraint:constraint-layout:1.0.1'
32 | compile 'com.android.support:design:25.2.0'
33 | testCompile 'junit:junit:4.12'
34 | }
35 |
--------------------------------------------------------------------------------
/RxjavaDemo/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 G:\DevelopmentSoftWare\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 |
--------------------------------------------------------------------------------
/RxjavaDemo/src/androidTest/java/com/androidleaf/rxjavademo/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.androidleaf.rxjavademo;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.androidleaf.rxjavademo", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/RxjavaDemo/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/RxjavaDemo/src/main/java/com/androidleaf/rxjavademo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.androidleaf.rxjavademo;
2 |
3 | import android.os.Bundle;
4 | import android.support.design.widget.FloatingActionButton;
5 | import android.support.design.widget.Snackbar;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.support.v7.widget.Toolbar;
8 | import android.view.View;
9 | import android.view.Menu;
10 | import android.view.MenuItem;
11 |
12 | public class MainActivity extends AppCompatActivity {
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_main);
18 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
19 | setSupportActionBar(toolbar);
20 |
21 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
22 | fab.setOnClickListener(new View.OnClickListener() {
23 | @Override
24 | public void onClick(View view) {
25 | Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
26 | .setAction("Action", null).show();
27 | }
28 | });
29 | }
30 |
31 | @Override
32 | public boolean onCreateOptionsMenu(Menu menu) {
33 | // Inflate the menu; this adds items to the action bar if it is present.
34 | getMenuInflater().inflate(R.menu.menu_main, menu);
35 | return true;
36 | }
37 |
38 | @Override
39 | public boolean onOptionsItemSelected(MenuItem item) {
40 | // Handle action bar item clicks here. The action bar will
41 | // automatically handle clicks on the Home/Up button, so long
42 | // as you specify a parent activity in AndroidManifest.xml.
43 | int id = item.getItemId();
44 |
45 | //noinspection SimplifiableIfStatement
46 | if (id == R.id.action_settings) {
47 | return true;
48 | }
49 |
50 | return super.onOptionsItemSelected(item);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/RxjavaDemo/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
20 |
21 |
22 |
23 |
24 |
25 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/RxjavaDemo/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/RxjavaDemo/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/RxjavaDemo/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/RxjavaDemo/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/RxjavaDemo/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/RxjavaDemo/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/RxjavaDemo/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/RxjavaDemo/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/RxjavaDemo/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/RxjavaDemo/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/RxjavaDemo/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/RxjavaDemo/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/RxjavaDemo/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/RxjavaDemo/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/RxjavaDemo/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/RxjavaDemo/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/RxjavaDemo/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/RxjavaDemo/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/RxjavaDemo/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/RxjavaDemo/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/RxjavaDemo/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/RxjavaDemo/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/RxjavaDemo/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/RxjavaDemo/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 |
4 |
--------------------------------------------------------------------------------
/RxjavaDemo/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | RxJavaDemo
3 | Settings
4 |
5 |
--------------------------------------------------------------------------------
/RxjavaDemo/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/RxjavaDemo/src/test/java/com/androidleaf/rxjavademo/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.androidleaf.rxjavademo;
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 | }
--------------------------------------------------------------------------------
/WebviewDemo/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/WebviewDemo/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 |
7 | defaultConfig {
8 | applicationId "com.androidleaf.webviewdemo"
9 | minSdkVersion 15
10 | targetSdkVersion 25
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 | compile 'com.android.support:appcompat-v7:25.2.0'
31 | compile 'com.android.support.constraint:constraint-layout:1.0.1'
32 | compile 'com.android.support:design:25.2.0'
33 | testCompile 'junit:junit:4.12'
34 | }
35 |
--------------------------------------------------------------------------------
/WebviewDemo/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 G:\DevelopmentSoftWare\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 |
--------------------------------------------------------------------------------
/WebviewDemo/src/androidTest/java/com/androidleaf/webviewdemo/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.androidleaf.webviewdemo;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.androidleaf.webviewdemo", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/WebviewDemo/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/WebviewDemo/src/main/java/com/androidleaf/webviewdemo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.androidleaf.webviewdemo;
2 |
3 | import android.os.Bundle;
4 | import android.support.design.widget.FloatingActionButton;
5 | import android.support.design.widget.Snackbar;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.support.v7.widget.Toolbar;
8 | import android.view.View;
9 | import android.view.Menu;
10 | import android.view.MenuItem;
11 |
12 | public class MainActivity extends AppCompatActivity {
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_main);
18 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
19 | setSupportActionBar(toolbar);
20 |
21 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
22 | fab.setOnClickListener(new View.OnClickListener() {
23 | @Override
24 | public void onClick(View view) {
25 | Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
26 | .setAction("Action", null).show();
27 | }
28 | });
29 | }
30 |
31 | @Override
32 | public boolean onCreateOptionsMenu(Menu menu) {
33 | // Inflate the menu; this adds items to the action bar if it is present.
34 | getMenuInflater().inflate(R.menu.menu_main, menu);
35 | return true;
36 | }
37 |
38 | @Override
39 | public boolean onOptionsItemSelected(MenuItem item) {
40 | // Handle action bar item clicks here. The action bar will
41 | // automatically handle clicks on the Home/Up button, so long
42 | // as you specify a parent activity in AndroidManifest.xml.
43 | int id = item.getItemId();
44 |
45 | //noinspection SimplifiableIfStatement
46 | if (id == R.id.action_settings) {
47 | return true;
48 | }
49 |
50 | return super.onOptionsItemSelected(item);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/WebviewDemo/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
10 |
11 |
14 |
15 |
16 |
17 |
18 |
19 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/WebviewDemo/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/WebviewDemo/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/WebviewDemo/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/WebviewDemo/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/WebviewDemo/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/WebviewDemo/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/WebviewDemo/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/WebviewDemo/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/WebviewDemo/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/WebviewDemo/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/WebviewDemo/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/WebviewDemo/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/WebviewDemo/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/WebviewDemo/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/WebviewDemo/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/WebviewDemo/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/WebviewDemo/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/WebviewDemo/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/WebviewDemo/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/WebviewDemo/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/WebviewDemo/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/WebviewDemo/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/WebviewDemo/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/WebviewDemo/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 |
4 |
--------------------------------------------------------------------------------
/WebviewDemo/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | WebViewDemo
3 | Settings
4 |
5 |
--------------------------------------------------------------------------------
/WebviewDemo/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/WebviewDemo/src/test/java/com/androidleaf/webviewdemo/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.androidleaf.webviewdemo;
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 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/leafye/AndroidBlogSource/ef8745f7c6422432caf4fcfe6e6216549992f3c4/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Mar 13 22:09:55 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.3-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/local.properties:
--------------------------------------------------------------------------------
1 | ## This file is automatically generated by Android Studio.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file should *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 | #
7 | # Location of the SDK. This is only used by Gradle.
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | sdk.dir=G\:\\DevelopmentSoftWare\\AndroidSDK
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':RecyclerViewDemo', ':PluginDemo', ':WebviewDemo', ':RxjavaDemo', ':01ActivityDemo', ':01FragmentDemo', ':02ServiceDemo'
2 |
--------------------------------------------------------------------------------