Permalink
Please sign in to comment.
Showing
with
212 additions
and 66 deletions.
- +1 −0 app/build.gradle
- +2 −1 app/src/main/AndroidManifest.xml
- +40 −17 app/src/main/java/com/camnter/easycountdowntextureview/demo/MainActivity.java
- +18 −0 app/src/main/java/com/camnter/easycountdowntextureview/demo/ShowActivity.java
- +29 −6 app/src/main/java/com/camnter/easycountdowntextureview/demo/StyleActivity.java
- +36 −0 app/src/main/java/com/camnter/easycountdowntextureview/demo/adapter/MainAdapter.java
- +3 −41 app/src/main/res/layout/activity_main.xml
- +31 −0 app/src/main/res/layout/activity_show.xml
- +28 −0 app/src/main/res/layout/activity_style.xml
- +15 −0 app/src/main/res/layout/item_main.xml
- +4 −0 app/src/main/res/values/strings.xml
- +5 −1 app/src/main/res/values/styles.xml
1
app/build.gradle
3
app/src/main/AndroidManifest.xml
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)); | ||
| + } | ||
| + }); | ||
| } | ||
| + | ||
| } |
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); | ||
| + } | ||
| +} |
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; | ||
| + } | ||
| } | ||
| } |
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; | ||
| + } | ||
| + | ||
| +} |
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> |
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> |
28
app/src/main/res/layout/activity_style.xml
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> |
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> |
6
app/src/main/res/values/styles.xml
0 comments on commit
14730de