Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHubZJY committed Feb 12, 2019
0 parents commit e564cb0
Show file tree
Hide file tree
Showing 68 changed files with 5,804 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
43 changes: 43 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.zjy.zjywidget"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '26.0.2'
}
}
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

compile 'com.github.bumptech.glide:glide:4.0.0'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:cardview-v7:26.0.2'
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.example.zjy.zjywidget;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("com.example.zjy.zjywidget", appContext.getPackageName());
}
}
41 changes: 41 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.zjy.zjywidget">

<!--允许联网 -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity android:name=".sample.CameraViewTestActivity"
android:theme="@style/Theme.AppCompat.NoActionBar"
android:screenOrientation="portrait">

</activity>

<activity android:name=".sample.SkillViewTestActivity"
android:theme="@style/Theme.AppCompat.NoActionBar">

</activity>

<activity android:name=".sample.BannerViewTestActivity">

</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.example.zjy.zjywidget;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.List;

/**
* Created by 74215 on 2019/2/12.
*/

public class EntranceItemAdapter extends RecyclerView.Adapter<EntranceItemAdapter.EntranceViewHolder>{

private Context mContext;
private List<ViewItemBean> mViewItemList;

public EntranceItemAdapter(Context mContext, List<ViewItemBean> mViewItemList) {
this.mContext = mContext;
this.mViewItemList = mViewItemList;
}

@Override
public void onBindViewHolder(EntranceViewHolder holder, int position) {
String name = mViewItemList.get(position).getName();
String describe = mViewItemList.get(position).getDescirbe();
final Class testClass = mViewItemList.get(position).getTestClass();
holder.mRootView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent();
intent.setClass(mContext, testClass);
mContext.startActivity(intent);
}
});
holder.mNameTv.setText(TextUtils.isEmpty(name) ? "" : name);
holder.mDescribeTv.setText(TextUtils.isEmpty(describe) ? "" : describe);
}

@Override
public EntranceViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(mContext).inflate(R.layout.layout_entrance_item, null);
return new EntranceViewHolder(view);
}

@Override
public int getItemCount() {
return mViewItemList == null ? 0 : mViewItemList.size();
}



class EntranceViewHolder extends RecyclerView.ViewHolder{

private CardView mRootView;
private TextView mNameTv;
private TextView mDescribeTv;

public EntranceViewHolder(View itemView) {
super(itemView);
mRootView = itemView.findViewById(R.id.item_root_view);
mNameTv = itemView.findViewById(R.id.view_name_tv);
mDescribeTv = itemView.findViewById(R.id.view_describe_tv);
}
}
}
55 changes: 55 additions & 0 deletions app/src/main/java/com/example/zjy/zjywidget/MainActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.example.zjy.zjywidget;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.example.zjy.zjywidget.sample.BannerViewTestActivity;
import com.example.zjy.zjywidget.sample.CameraViewTestActivity;
import com.example.zjy.zjywidget.sample.SkillViewTestActivity;

import java.util.ArrayList;
import java.util.List;

/**
* 各个自定义View demo的入口列表
* Created by YANG on 2018/02/12.
*/
public class MainActivity extends AppCompatActivity {

private RecyclerView mViewListView;
private EntranceItemAdapter mAdapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

List<ViewItemBean> viewItemBeans = new ArrayList<>();
viewItemBeans.add(new ViewItemBean("YCameraMarkView", "一个带遮罩扫描动画的相机拍摄View,支持自定义裁剪大小、形状,前后置切换,扫描动画", CameraViewTestActivity.class));
viewItemBeans.add(new ViewItemBean("YSkillView", "带动画的6变形技能图,支持自定义颜色以及属性文案,动态设置分数", SkillViewTestActivity.class));
viewItemBeans.add(new ViewItemBean("YBannerView", "封装ViewPager快速集成轮播功能,支持自定义指示器", BannerViewTestActivity.class));
mAdapter = new EntranceItemAdapter(this, viewItemBeans);

mViewListView = findViewById(R.id.view_lv);
mViewListView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
mViewListView.setAdapter(mAdapter);

}

@Override
protected void onPause() {
super.onPause();
}

@Override
protected void onResume() {
super.onResume();
}

@Override
protected void onDestroy() {
super.onDestroy();
}
}
42 changes: 42 additions & 0 deletions app/src/main/java/com/example/zjy/zjywidget/ViewItemBean.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.example.zjy.zjywidget;

/**
* Created by 74215 on 2019/2/12.
*/

public class ViewItemBean {

private String name;
private String descirbe;
private Class testClass;

public ViewItemBean(String name, String descirbe, Class testClass) {
this.name = name;
this.descirbe = descirbe;
this.testClass = testClass;
}

public Class getTestClass() {
return testClass;
}

public void setTestClass(Class testClass) {
this.testClass = testClass;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getDescirbe() {
return descirbe;
}

public void setDescirbe(String descirbe) {
this.descirbe = descirbe;
}
}
Loading

0 comments on commit e564cb0

Please sign in to comment.