Skip to content

Commit

Permalink
Merge pull request #34 from senqing1994/master
Browse files Browse the repository at this point in the history
migrate to androidX
  • Loading branch information
kHRYSTAL committed Jun 8, 2023
2 parents f22353d + cda7b0d commit d555a52
Show file tree
Hide file tree
Showing 27 changed files with 173 additions and 117 deletions.
5 changes: 3 additions & 2 deletions .gitignore
@@ -1,8 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
/.idea
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
47 changes: 34 additions & 13 deletions app/build.gradle
@@ -1,28 +1,49 @@
apply plugin: 'com.android.application'
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
compileSdk 33

defaultConfig {
applicationId "me.khrystal.circlerecyclerviewdemo"
minSdkVersion 13
targetSdkVersion 23
applicationId "com.example.myfirstapplication"
minSdk 29
targetSdk 33
versionCode 1
versionName "1.0"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
// buildFeatures {
// viewBinding true
// }
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.4.0'
compile project(':library')
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'jp.wasabeef:glide-transformations:2.0.1'
}

implementation project(':library')
implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation 'jp.wasabeef:glide-transformations:4.3.0'
// If you want to use the GPU Filters
implementation 'jp.co.cyberagent.android:gpuimage:2.1.0'

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.3.0'
}
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Expand Up @@ -8,7 +8,8 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<activity android:name=".MainActivity" >
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Expand Up @@ -2,10 +2,11 @@

import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import android.view.Menu;
import android.view.MenuItem;

Expand All @@ -18,7 +19,7 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
mToolbar = findViewById(R.id.toolbar);
mToolbar.setTitle("TYPE_CIRCLE");
mToolbar.setTitleTextColor(Color.WHITE);
setSupportActionBar(mToolbar);
Expand Down
@@ -1,6 +1,6 @@
package me.khrystal.circlerecyclerviewdemo;

import android.support.annotation.IntDef;
import androidx.annotation.IntDef;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand Down
@@ -1,22 +1,27 @@
package me.khrystal.circlerecyclerviewdemo;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

//import jp.wasabeef.glide.transformations.CropCircleTransformation;
import jp.wasabeef.glide.transformations.BlurTransformation;
import jp.wasabeef.glide.transformations.CropCircleTransformation;
import me.khrystal.library.widget.CircleRecyclerView;
import me.khrystal.library.widget.CircularHorizontalMode;
Expand Down Expand Up @@ -64,11 +69,11 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
}

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);

int modeType = getArguments().getInt("mode_type");
mCircleRecyclerView = (CircleRecyclerView) view.findViewById(R.id.circle_rv);
mCircleRecyclerView = view.findViewById(R.id.circle_rv);

// find itemViewMode and layoutManager
switch (modeType) {
Expand Down Expand Up @@ -139,8 +144,9 @@ public void onCenterItemClick(View v) {

class A extends RecyclerView.Adapter<VH> {

@NonNull
@Override
public VH onCreateViewHolder(ViewGroup parent, int viewType) {
public VH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
VH h = null;
if (mCircleRecyclerView.getLayoutManager().canScrollHorizontally()) {
h = new VH(LayoutInflater.from(getContext())
Expand All @@ -167,9 +173,15 @@ else if (mItemViewMode instanceof CircularHorizontalBTTMode) {
@Override
public void onBindViewHolder(VH holder, int position) {
holder.tv.setText("Number :" + (position % mImgList.size()));
Glide.with(getContext())

// Glide.with(requireContext())
// .load(mImgList.get(position % mImgList.size()))
// .apply(RequestOptions.bitmapTransform(new BlurTransformation()))
// .into(holder.iv);

Glide.with(requireContext())
.load(mImgList.get(position % mImgList.size()))
.bitmapTransform(new CropCircleTransformation(getContext()))
.apply(RequestOptions.circleCropTransform())
.into(holder.iv);

}
Expand All @@ -181,15 +193,15 @@ public int getItemCount() {
}


class VH extends RecyclerView.ViewHolder {
static class VH extends RecyclerView.ViewHolder {

TextView tv;
ImageView iv;

public VH(View itemView) {
super(itemView);
tv = (TextView) itemView.findViewById(R.id.item_text);
iv = (ImageView) itemView.findViewById(R.id.item_img);
tv = itemView.findViewById(R.id.item_text);
iv = itemView.findViewById(R.id.item_img);
}
}
}
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Expand Up @@ -5,14 +5,14 @@
android:layout_height="match_parent"
android:orientation="vertical">

<android.support.v7.widget.Toolbar
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ActionBarThemeOverlay"></android.support.v7.widget.Toolbar>
app:theme="@style/ActionBarThemeOverlay"></androidx.appcompat.widget.Toolbar>

<FrameLayout
android:id="@+id/fragment_container"
Expand Down
8 changes: 5 additions & 3 deletions app/src/main/res/layout/fragment.xml
@@ -1,10 +1,12 @@
<?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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<me.khrystal.library.widget.CircleRecyclerView
android:id="@+id/circle_rv"
android:layout_width="match_parent"
android:layout_height="match_parent">
</me.khrystal.library.widget.CircleRecyclerView>
android:layout_height="match_parent" />

</LinearLayout>
3 changes: 2 additions & 1 deletion app/src/main/res/layout/item_c_rtl_v.xml
@@ -1,6 +1,7 @@
<?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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="80dp">
<ImageView
android:id="@+id/item_img"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/item_c_v.xml
@@ -1,6 +1,7 @@
<?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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="80dp">
<ImageView
android:id="@+id/item_img"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/item_v.xml
@@ -1,6 +1,7 @@
<?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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="80dp">
<ImageView
android:id="@+id/item_img"
Expand Down
28 changes: 5 additions & 23 deletions build.gradle
@@ -1,24 +1,6 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
jcenter()
mavenCentral()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
plugins {
id 'com.android.application' version '7.4.0' apply false
id 'com.android.library' version '7.4.0' apply false
id 'org.jetbrains.kotlin.android' version '1.7.21' apply false
}
19 changes: 12 additions & 7 deletions gradle.properties
@@ -1,18 +1,23 @@
# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
#Thu Sep 22 12:15:02 CST 2016
#Sun Jan 29 14:43:02 CST 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
zipStoreBase=GRADLE_USER_HOME
30 changes: 21 additions & 9 deletions library/build.gradle
@@ -1,26 +1,38 @@
apply plugin: 'com.android.library'
plugins {
id 'com.android.library'
}

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
compileSdk 33

defaultConfig {
minSdkVersion 13
targetSdkVersion 23
minSdk 29
targetSdk 33
versionCode 1
versionName "1.0"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
// buildFeatures {
// viewBinding true
// }
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.3.0'
}

0 comments on commit d555a52

Please sign in to comment.