Skip to content

Commit 10720fb

Browse files
committed
support library demo 2015 google io is ok.
1 parent dc438b3 commit 10720fb

21 files changed

Lines changed: 335 additions & 151 deletions

Support-Library-Demo/.idea/encodings.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Support-Library-Demo/.idea/misc.xml

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Support-Library-Demo/.idea/runConfigurations.xml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Support-Library-Demo/Support-Library-Demo.iml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</configuration>
99
</facet>
1010
</component>
11-
<component name="NewModuleRootManager" inherit-compiler-output="true">
11+
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="true">
1212
<exclude-output />
1313
<content url="file://$MODULE_DIR$">
1414
<excludeFolder url="file://$MODULE_DIR$/.gradle" />

Support-Library-Demo/app/app.iml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
1313
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
1414
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
15-
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
1615
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
1716
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" />
18-
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugAndroidTestSources" />
17+
<afterSyncTasks>
18+
<task>generateDebugAndroidTestSources</task>
19+
<task>generateDebugSources</task>
20+
</afterSyncTasks>
1921
<option name="ALLOW_USER_CONFIGURATION" value="false" />
2022
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
2123
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
@@ -24,7 +26,7 @@
2426
</configuration>
2527
</facet>
2628
</component>
27-
<component name="NewModuleRootManager" inherit-compiler-output="false">
29+
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
2830
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
2931
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug" />
3032
<exclude-output />

Support-Library-Demo/app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
<category android:name="android.intent.category.LAUNCHER" />
1717
</intent-filter>
1818
</activity>
19+
20+
<activity android:name=".SubActivity"
21+
android:label="工匠若水详情"></activity>
1922
</application>
2023

2124
</manifest>

Support-Library-Demo/app/src/main/java/com/yanbober/support_library_demo/AgendaFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class AgendaFragment extends Fragment {
3030
@Nullable
3131
@Override
3232
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
33-
mParentView = inflater.inflate(R.layout.info_details_fragment, container, false);
33+
mParentView = inflater.inflate(R.layout.agenda_fragment, container, false);
3434
return mParentView;
3535
}
3636

Support-Library-Demo/app/src/main/java/com/yanbober/support_library_demo/InfoDetailsFragment.java

Lines changed: 7 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@
22

33
import android.os.Bundle;
44
import android.support.annotation.Nullable;
5-
import android.support.design.widget.FloatingActionButton;
6-
import android.support.design.widget.Snackbar;
7-
import android.support.design.widget.TextInputLayout;
85
import android.support.v4.app.Fragment;
9-
import android.text.Editable;
10-
import android.text.TextWatcher;
6+
import android.support.v7.widget.LinearLayoutManager;
7+
import android.support.v7.widget.RecyclerView;
118
import android.view.LayoutInflater;
129
import android.view.View;
1310
import android.view.ViewGroup;
14-
import android.widget.EditText;
1511

1612
/**
1713
* Author : yanbo
@@ -20,69 +16,20 @@
2016
* Description :
2117
*/
2218
public class InfoDetailsFragment extends Fragment {
23-
private View mParentView;
24-
25-
private TextInputLayout mTextInputLayout;
26-
private EditText mEditText;
27-
28-
private FloatingActionButton mFloatingActionButton;
19+
private RecyclerView mRecyclerView;
2920

3021
@Nullable
3122
@Override
3223
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
33-
mParentView = inflater.inflate(R.layout.info_details_fragment, container, false);
34-
return mParentView;
24+
mRecyclerView = (RecyclerView) inflater.inflate(R.layout.info_details_fragment, container, false);
25+
return mRecyclerView;
3526
}
3627

3728
@Override
3829
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
3930
super.onActivityCreated(savedInstanceState);
4031

41-
demoTextInputLayout();
42-
43-
demomFloatingActionButton();
44-
}
45-
46-
private void demoTextInputLayout() {
47-
mTextInputLayout = (TextInputLayout) mParentView.findViewById(R.id.text_input_layout);
48-
mEditText = mTextInputLayout.getEditText();
49-
mTextInputLayout.setHint("请输入4位学号");
50-
51-
mEditText.addTextChangedListener(new TextWatcher() {
52-
@Override
53-
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
54-
if (s.length() > 4) {
55-
mTextInputLayout.setError("学号输入错误!");
56-
mTextInputLayout.setErrorEnabled(true);
57-
} else {
58-
mTextInputLayout.setErrorEnabled(false);
59-
}
60-
}
61-
62-
@Override
63-
public void onTextChanged(CharSequence s, int start, int before, int count) {
64-
}
65-
66-
@Override
67-
public void afterTextChanged(Editable s) {
68-
}
69-
});
70-
}
71-
72-
private void demomFloatingActionButton() {
73-
mFloatingActionButton = (FloatingActionButton) mParentView.findViewById(R.id.action_button);
74-
mFloatingActionButton.setOnClickListener(new View.OnClickListener() {
75-
@Override
76-
public void onClick(View v) {
77-
Snackbar.make(v, "结束当前Acitivty", Snackbar.LENGTH_LONG)
78-
.setAction("确定", new View.OnClickListener() {
79-
@Override
80-
public void onClick(View v) {
81-
getActivity().finish();
82-
}
83-
})
84-
.show();
85-
}
86-
});
32+
mRecyclerView.setLayoutManager(new LinearLayoutManager(mRecyclerView.getContext()));
33+
mRecyclerView.setAdapter(new RecyclerViewAdapter(getActivity()));
8734
}
8835
}

Support-Library-Demo/app/src/main/java/com/yanbober/support_library_demo/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import java.util.List;
1717
/**
1818
* 一个中文版Demo App搞定所有Android的Support Library新增所有兼容控件
19-
* 2015 Google I/O大会Android Design Support Library
19+
* 支持最新2015 Google I/O大会Android Design Support Library
2020
*/
2121
public class MainActivity extends ActionBarActivity {
2222
//将ToolBar与TabLayout结合放入AppBarLayout
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.yanbober.support_library_demo;
2+
3+
import android.content.Context;
4+
import android.content.Intent;
5+
import android.support.v7.widget.RecyclerView;
6+
import android.view.LayoutInflater;
7+
import android.view.View;
8+
import android.view.ViewGroup;
9+
import android.widget.TextView;
10+
11+
/**
12+
* Author : yanbo
13+
* Date : 2015-06-02
14+
* Time : 09:47
15+
* Description :
16+
*/
17+
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.ViewHolder> {
18+
private int[] colors = {R.color.color_0, R.color.color_1, R.color.color_2, R.color.color_3,
19+
R.color.color_4, R.color.color_5, R.color.color_6, R.color.color_7,
20+
R.color.color_8, R.color.color_9,};
21+
22+
private Context mContext;
23+
24+
public RecyclerViewAdapter(Context mContext) {
25+
this.mContext = mContext;
26+
}
27+
28+
@Override
29+
public RecyclerViewAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
30+
TextView view = (TextView) LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item, parent, false);
31+
return new ViewHolder(view);
32+
}
33+
34+
@Override
35+
public void onBindViewHolder(RecyclerViewAdapter.ViewHolder holder, int position) {
36+
holder.mTextView.setBackgroundColor(mContext.getResources().getColor(colors[position%(colors.length)]));
37+
holder.mTextView.setText(position + "");
38+
39+
holder.mTextView.setOnClickListener(new View.OnClickListener() {
40+
@Override
41+
public void onClick(View v) {
42+
mContext.startActivity(new Intent(mContext, SubActivity.class));
43+
}
44+
});
45+
}
46+
47+
@Override
48+
public int getItemCount() {
49+
return colors.length * 2;
50+
}
51+
52+
public static class ViewHolder extends RecyclerView.ViewHolder {
53+
public final TextView mTextView;
54+
55+
public ViewHolder(TextView view) {
56+
super(view);
57+
mTextView = view;
58+
}
59+
}
60+
}

0 commit comments

Comments
 (0)