Skip to content
Browse files

Update demo

1 parent 385c845 commit 14730de070b3ab2811abec9192fe405e501d5085 @CaMnter committed
View
1 app/build.gradle
@@ -23,5 +23,6 @@ dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.0'
+ compile 'com.camnter.easyrecyclerview:easyrecyclerview:1.2'
compile project(':library')
}
View
3 app/src/main/AndroidManifest.xml
@@ -15,7 +15,8 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
- <activity android:name=".StyleActivity" />
+ <activity android:name=".StyleActivity" />
+ <activity android:name=".ShowActivity" />
</application>
</manifest>
View
57 app/src/main/java/com/camnter/easycountdowntextureview/demo/MainActivity.java
@@ -1,34 +1,57 @@
package com.camnter.easycountdowntextureview.demo;
+import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
-import com.camnter.easycountdowntextureview.EasyCountDownTextureView;
+import com.camnter.easycountdowntextureview.demo.adapter.MainAdapter;
+import com.camnter.easyrecyclerview.holder.EasyRecyclerViewHolder;
+import com.camnter.easyrecyclerview.widget.EasyRecyclerView;
+import com.camnter.easyrecyclerview.widget.decorator.EasyDividerItemDecoration;
-public class MainActivity extends AppCompatActivity implements View.OnClickListener {
+import java.util.ArrayList;
- EasyCountDownTextureView edtv;
+public class MainActivity extends AppCompatActivity {
+
+ private EasyRecyclerView mainRv;
+ private MainAdapter mainAdapter;
+ private ArrayList<Class> classes;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
- this.findViewById(R.id.style_bt).setOnClickListener(this);
- this.edtv = (EasyCountDownTextureView) this.findViewById(R.id.edtv);
+ this.initViews();
+ this.initData();
+ this.initListeners();
}
- /**
- * Called when a view has been clicked.
- *
- * @param v The view that was clicked.
- */
- @Override
- public void onClick(View v) {
- switch (v.getId()) {
- case R.id.style_bt:
- StyleActivity.startActivity(this);
- break;
- }
+ private void initViews() {
+ this.mainRv = (EasyRecyclerView) this.findViewById(R.id.main_rv);
+ EasyDividerItemDecoration decoration = new EasyDividerItemDecoration(this, EasyDividerItemDecoration.VERTICAL_LIST);
+ decoration.bottomDivider = true;
+ this.mainRv.addItemDecoration(decoration);
+ }
+
+ private void initData() {
+ this.classes = new ArrayList<>();
+ this.classes.add(ShowActivity.class);
+ this.classes.add(StyleActivity.class);
+
+ this.mainAdapter = new MainAdapter();
+ this.mainAdapter.setList(this.classes);
+ this.mainRv.setAdapter(this.mainAdapter);
+ }
+
+ private void initListeners() {
+ this.mainAdapter.setOnItemClickListener(new EasyRecyclerViewHolder.OnItemClickListener() {
+ @Override
+ public void onItemClick(View view, int i) {
+ Class c = MainActivity.this.classes.get(i);
+ MainActivity.this.startActivity(new Intent(MainActivity.this, c));
+ }
+ });
}
+
}
View
18 app/src/main/java/com/camnter/easycountdowntextureview/demo/ShowActivity.java
@@ -0,0 +1,18 @@
+package com.camnter.easycountdowntextureview.demo;
+
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+
+/**
+ * Description:ShowActivity
+ * Created by:CaMnter
+ * Time:2016-03-18 13:28
+ */
+public class ShowActivity extends AppCompatActivity {
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ this.setContentView(R.layout.activity_show);
+ }
+}
View
35 app/src/main/java/com/camnter/easycountdowntextureview/demo/StyleActivity.java
@@ -1,25 +1,48 @@
package com.camnter.easycountdowntextureview.demo;
-import android.content.Context;
-import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
+import android.view.View;
+
+import com.camnter.easycountdowntextureview.EasyCountDownTextureView;
/**
* Description:StyleActivity
* Created by:CaMnter
* Time:2016-03-17 17:20
*/
-public class StyleActivity extends AppCompatActivity {
+public class StyleActivity extends AppCompatActivity implements View.OnClickListener {
- public static void startActivity(Context context) {
- context.startActivity(new Intent(context, StyleActivity.class));
- }
+ private EasyCountDownTextureView styleTv;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.activity_style);
+ this.styleTv = (EasyCountDownTextureView) this.findViewById(R.id.style_tv);
+ this.findViewById(R.id.style_hour_bt).setOnClickListener(this);
+ this.findViewById(R.id.style_minute_bt).setOnClickListener(this);
+ this.findViewById(R.id.style_second_bt).setOnClickListener(this);
+ }
+
+ /**
+ * Called when a view has been clicked.
+ *
+ * @param v The view that was clicked.
+ */
+ @Override
+ public void onClick(View v) {
+ switch (v.getId()) {
+ case R.id.style_hour_bt:
+ this.styleTv.setTimeHour(1);
+ break;
+ case R.id.style_minute_bt:
+ this.styleTv.setTimeMinute(1);
+ break;
+ case R.id.style_second_bt:
+ this.styleTv.setTimeSecond(1);
+ break;
+ }
}
}
View
36 app/src/main/java/com/camnter/easycountdowntextureview/demo/adapter/MainAdapter.java
@@ -0,0 +1,36 @@
+package com.camnter.easycountdowntextureview.demo.adapter;
+
+import android.widget.TextView;
+
+import com.camnter.easycountdowntextureview.demo.R;
+import com.camnter.easyrecyclerview.adapter.EasyRecyclerViewAdapter;
+import com.camnter.easyrecyclerview.holder.EasyRecyclerViewHolder;
+
+/**
+ * Description:MainAdapter
+ * Created by:CaMnter
+ * Time:2016-03-18 13:21
+ */
+public class MainAdapter extends EasyRecyclerViewAdapter {
+
+ @Override
+ public int[] getItemLayouts() {
+ return new int[]{R.layout.item_main};
+ }
+
+
+ @Override
+ public void onBindRecycleViewHolder(EasyRecyclerViewHolder viewHolder, int position) {
+ Class c = (Class) this.getList().get(position);
+ if (c == null) return;
+ TextView textView = viewHolder.findViewById(R.id.main_item_tv);
+ textView.setText(c.getSimpleName());
+ }
+
+
+ @Override
+ public int getRecycleViewItemType(int position) {
+ return 0;
+ }
+
+}
View
44 app/src/main/res/layout/activity_main.xml
@@ -1,51 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:orientation="vertical"
- android:paddingBottom="@dimen/activity_vertical_margin"
- android:paddingLeft="@dimen/activity_horizontal_margin"
- android:paddingRight="@dimen/activity_horizontal_margin"
- android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.camnter.easycountdowntextureview.demo.MainActivity">
- <RelativeLayout
+ <com.camnter.easyrecyclerview.widget.EasyRecyclerView
+ android:id="@+id/main_rv"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginBottom="50dp"
- android:background="#ffffffff">
-
- <ImageView
- android:layout_width="196dp"
- android:layout_height="158dp"
- android:layout_marginTop="26dp"
- android:scaleType="centerCrop"
- android:src="@mipmap/bg_fruit" />
-
- <com.camnter.easycountdowntextureview.EasyCountDownTextureView
- android:id="@+id/edtv"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- app:easyCountHour="6"
- app:easyCountMinute="6"
- app:easyCountSecond="26" />
-
- </RelativeLayout>
-
- <Button
- android:id="@+id/style_bt"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
- android:layout_margin="16dp"
- android:paddingBottom="4dp"
- android:paddingEnd="8dp"
- android:paddingLeft="8dp"
- android:paddingRight="8dp"
- android:paddingStart="8dp"
- android:paddingTop="4dp"
- android:text="@string/style_bt" />
+ android:layout_height="match_parent" />
</RelativeLayout>
View
31 app/src/main/res/layout/activity_show.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:padding="16dp">
+
+ <RelativeLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="50dp"
+ android:background="#ffffffff">
+
+ <ImageView
+ android:layout_width="196dp"
+ android:layout_height="158dp"
+ android:layout_marginTop="26dp"
+ android:scaleType="centerCrop"
+ android:src="@mipmap/bg_fruit" />
+
+ <com.camnter.easycountdowntextureview.EasyCountDownTextureView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ app:easyCountHour="6"
+ app:easyCountMinute="6"
+ app:easyCountSecond="26" />
+
+ </RelativeLayout>
+
+</LinearLayout>
View
28 app/src/main/res/layout/activity_style.xml
@@ -12,6 +12,7 @@
tools:context="com.camnter.easycountdowntextureview.demo.MainActivity">
<com.camnter.easycountdowntextureview.EasyCountDownTextureView
+ android:id="@+id/style_tv"
android:layout_width="132dp"
android:layout_height="36dp"
app:easyCountBackgroundColor="#ffdddddd"
@@ -27,5 +28,32 @@
app:easyCountTimeColor="#ff3A94FF"
app:easyCountTimeSize="20sp" />
+ <Button
+ android:id="@+id/style_hour_bt"
+ style="@style/StyleButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:text="@string/style_hour_bt" />
+
+ <Button
+ android:id="@+id/style_minute_bt"
+ style="@style/StyleButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:layout_toEndOf="@id/style_hour_bt"
+ android:layout_toRightOf="@id/style_hour_bt"
+ android:text="@string/style_minute_bt" />
+
+ <Button
+ android:id="@+id/style_second_bt"
+ style="@style/StyleButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:layout_toEndOf="@id/style_minute_bt"
+ android:layout_toRightOf="@id/style_minute_bt"
+ android:text="@string/style_second_bt" />
</RelativeLayout>
View
15 app/src/main/res/layout/item_main.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical" android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <TextView
+ android:id="@+id/main_item_tv"
+ android:textSize="15sp"
+ android:padding="15dp"
+ android:textStyle="bold"
+ android:textColor="#ff58be13"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+
+</LinearLayout>
View
4 app/src/main/res/values/strings.xml
@@ -1,4 +1,8 @@
<resources>
<string name="app_name">EasyCountDownTextureView</string>
<string name="style_bt">Style</string>
+
+ <string name="style_hour_bt">H = 01</string>
+ <string name="style_minute_bt">M = 01</string>
+ <string name="style_second_bt">S = 01</string>
</resources>
View
6 app/src/main/res/values/styles.xml
@@ -8,8 +8,12 @@
<item name="colorAccent">@color/colorAccent</item>
</style>
- <style name="SurfaceViewStyle">
+ <style name="StyleButton">
<item name="android:layout_margin">16dp</item>
+ <item name="android:paddingTop">4dp</item>
+ <item name="android:paddingBottom">4dp</item>
+ <item name="android:paddingLeft">8dp</item>
+ <item name="android:paddingRight">8dp</item>
</style>
</resources>

0 comments on commit 14730de

Please sign in to comment.
Something went wrong with that request. Please try again.