Skip to content

Commit

Permalink
update to add the version of androidx
Browse files Browse the repository at this point in the history
  • Loading branch information
JavaNoober committed Aug 8, 2019
1 parent 471ef5f commit e409b90
Show file tree
Hide file tree
Showing 65 changed files with 3,951 additions and 12 deletions.
2 changes: 2 additions & 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 androidx/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
51 changes: 51 additions & 0 deletions androidx/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 28


defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"

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

}

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

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'androidx.appcompat:appcompat:1.0.0'
// implementation 'com.android.support:support-v4:28.0.0-rc02'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
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'

implementation 'com.trello.rxlifecycle3:rxlifecycle:3.0.0'

// If you want to bind to Android-specific lifecycles
implementation 'com.trello.rxlifecycle3:rxlifecycle-android:3.0.0'

// If you want pre-written Activities and Fragments you can subclass as providers
implementation 'com.trello.rxlifecycle3:rxlifecycle-components:3.0.0'
// implementation project(':libraryx')
implementation 'com.noober.background:corex:1.5.4-ALPHA'
}

repositories{
maven { url 'https://dl.bintray.com/noober/maven' }
}


21 changes: 21 additions & 0 deletions androidx/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.noober.androidx;

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() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("com.noober.androidx.test", appContext.getPackageName());
}
}
18 changes: 18 additions & 0 deletions androidx/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.noober.androidx" >
<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>
</application>
</manifest>
107 changes: 107 additions & 0 deletions androidx/src/main/java/com/noober/androidx/MainActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package com.noober.androidx;

import android.app.ListActivity;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.noober.background.drawable.DrawableCreator;
import com.trello.rxlifecycle3.components.support.RxAppCompatActivity;

public class MainActivity extends RxAppCompatActivity {

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView( R.layout.activity_main);
Button button = findViewById(R.id.btn);

button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(MainActivity.this, ListActivity.class));
}
});

// AnimationDrawable animationDrawable = (AnimationDrawable) vAnim.getBackground();
// animationDrawable.start();

Drawable drawable = new DrawableCreator.Builder().setCornersRadius(30)
.setSolidColor(Color.parseColor("#FFFFFF"))
.setStrokeColor(Color.parseColor("#FFFFFF"))
.setStrokeWidth(10)
.build();
TextView tvTest1 = findViewById(R.id.tvTest1);
tvTest1.setClickable(true);
ColorStateList colors = new DrawableCreator.Builder().setPressedTextColor(Color.RED).setUnPressedTextColor(Color.BLUE).buildTextColor();
tvTest1.setTextColor(colors);

Button btnTest2 = findViewById(R.id.btnTest2);
Drawable drawable2 = new DrawableCreator.Builder().setCornersRadius(dip2px(20))
.setGradientAngle(0).setGradientColor(Color.parseColor("#63B8FF"), Color.parseColor("#4F94CD")).build();
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN){
btnTest2.setBackground(drawable2);
}else {
btnTest2.setBackgroundDrawable(drawable2);
}


Button btnTest3 = findViewById(R.id.btnTest3);
Drawable drawable3 = new DrawableCreator.Builder().setCornersRadius(dip2px(20))
.setRipple(true, Color.parseColor("#71C671"))
.setSolidColor(Color.parseColor("#7CFC00"))
.setStrokeColor(Color.parseColor("#8c6822"))
.setStrokeWidth(dip2px(2))
.build();
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN){
btnTest3.setBackground(drawable3);
}else {
btnTest3.setBackgroundDrawable(drawable3);
}


// TextView tvTest4 = findViewById(R.id.tvTest4);
// Drawable drawable4 = new DrawableCreator.Builder().setCornersRadius(dip2px(20))
// .setPressedDrawable(ContextCompat.getDrawable(this, R.drawable.circle_like_pressed))
// .setUnPressedDrawable(ContextCompat.getDrawable(this, R.drawable.circle_like_normal))
// .build();
// tvTest4.setClickable(true);
// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN){
// tvTest4.setBackground(drawable4);
// }else {
// tvTest4.setBackgroundDrawable(drawable4);
// }


final Button btnEnable = findViewById(R.id.btn_setEnable);
final TextView tvMulti = findViewById(R.id.tv_multi);
btnEnable.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(tvMulti.isEnabled()){
tvMulti.setEnabled(false);
tvMulti.setText("textView一条属性多个状态:enable=false");
}else {
tvMulti.setEnabled(true);
tvMulti.setText("textView一条属性多个状态:enable=true");
}
}
});

}


public int dip2px(float dipValue) {
float scale = getResources().getDisplayMetrics().density;
return (int)(dipValue * scale + 0.5F);
}

}
Loading

0 comments on commit e409b90

Please sign in to comment.