Skip to content

Commit

Permalink
add module
Browse files Browse the repository at this point in the history
  • Loading branch information
Carson-Ho committed Aug 11, 2017
1 parent ffb3484 commit bd2b5a9
Show file tree
Hide file tree
Showing 24 changed files with 222 additions and 106 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.carson_ho:Super_EditText:1.0.0'
compile project(':searchview')
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import scut.carson_ho.searchview.SearchView;

public class MainActivity extends AppCompatActivity {


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

searchView = (Search_View)findViewById(R.id.search_layout);
searchView = (SearchView) findViewById(R.id.search_layout);

// searchView.setOnClickSearch(new ICallBack() {
// @Override
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
android:background="@color/colorBackground"
tools:context="scut.carson_ho.search_layout.MainActivity">

<scut.carson_ho.search_layout.Search_View
<scut.carson_ho.searchview.SearchView
android:id="@+id/search_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:textSizeSearch="5dp"
app:textColorSearch="#3F51B5"
app:textHintSearch="输入查询关键字"
app:searchBlockHeight="150"
app:searchBlockColor="#ffffff"
android:id="@+id/search_layout"/>
/>
</RelativeLayout>
1 change: 1 addition & 0 deletions searchview/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
31 changes: 31 additions & 0 deletions searchview/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"

defaultConfig {
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
}
25 changes: 25 additions & 0 deletions searchview/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/Carson_Ho/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# 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 scut.carson_ho.searchview;

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.*;

/**
* Instrumentation 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("scut.carson_ho.searchview.test", appContext.getPackageName());
}
}
10 changes: 10 additions & 0 deletions searchview/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="scut.carson_ho.searchview">

<application android:allowBackup="true" android:label="@string/app_name"
android:supportsRtl="true">

</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package scut.carson_ho.search_layout;
package scut.carson_ho.searchview;

import android.content.Context;
import android.graphics.Rect;
Expand Down Expand Up @@ -38,7 +38,7 @@ public EditText_Clear(Context context, AttributeSet attrs, int defStyleAttr) {
* 步骤2:初始化 图标资源
*/
private void init() {
clearDrawable = getResources().getDrawable(R.drawable.delete);
clearDrawable = getResources().getDrawable(R.drawable.clear);
searchDrawable = getResources().getDrawable(R.drawable.search);

setCompoundDrawablesWithIntrinsicBounds(searchDrawable, null,
Expand All @@ -51,8 +51,8 @@ private void init() {

// 另外一个相似的方法:setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom)介绍
// 与setCompoundDrawablesWithIntrinsicBounds()的区别:可设置图标大小
// 传入的Drawable对象必须已经setBounds(x,y,width,height),即必须设置过初始位置、宽和高等信息
// x:组件在容器X轴上的起点 y:组件在容器Y轴上的起点 width:组件的长度 height:组件的高度
// 传入的Drawable对象必须已经setBounds(x,y,width,height),即必须设置过初始位置、宽和高等信息
// x:组件在容器X轴上的起点 y:组件在容器Y轴上的起点 width:组件的长度 height:组件的高度
}


Expand Down Expand Up @@ -117,5 +117,3 @@ public boolean onTouchEvent(MotionEvent event) {

}



Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package scut.carson_ho.search_layout;
package scut.carson_ho.searchview;

/**
* Created by Carson_Ho on 17/8/4.
* Created by Carson_Ho on 17/8/10.
*/

public interface ICallBack {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package scut.carson_ho.search_layout;
package scut.carson_ho.searchview;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
* Created by Carson_Ho on 16/11/15.
* Created by Carson_Ho on 17/8/10.
*/

// 继承自SQLiteOpenHelper数据库类的子类
public class RecordSQLiteOpenHelper extends SQLiteOpenHelper {

Expand All @@ -28,5 +29,4 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

}


}
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
package scut.carson_ho.search_layout;
package scut.carson_ho.searchview;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ListView;

/**
* Created by Carson_Ho on 16/11/15.
* Created by Carson_Ho on 17/8/10.
*/
//解决ListView和ScrollView的冲突
public class Search_Listview extends ListView {
public Search_Listview(Context context) {

public class SearchListView extends ListView {
public SearchListView(Context context) {
super(context);
}

public Search_Listview(Context context, AttributeSet attrs) {
public SearchListView(Context context, AttributeSet attrs) {
super(context, attrs);
}

public Search_Listview(Context context, AttributeSet attrs, int defStyle) {
public SearchListView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}

//通过复写其onMeasure方法、达到对ScrollView适配的效果

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
Expand Down
Loading

0 comments on commit bd2b5a9

Please sign in to comment.