Skip to content

Commit

Permalink
add new sample
Browse files Browse the repository at this point in the history
  • Loading branch information
zyyoona7 committed Sep 14, 2017
1 parent f90b894 commit a7cb2d6
Show file tree
Hide file tree
Showing 17 changed files with 248 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Expand Up @@ -22,10 +22,10 @@ android {
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':lib')

compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.blankj:utilcode:1.8.1'
compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.26'

}
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Expand Up @@ -24,6 +24,8 @@
android:name=".easypop.EasyPopActivity"
android:theme="@style/AppTheme.NoActionBar">
</activity>
<activity android:name=".easypop.RecyclerViewActivity">
</activity>
</application>

</manifest>
15 changes: 13 additions & 2 deletions app/src/main/java/com/zyyoona7/easypopup/MainActivity.java
Expand Up @@ -6,6 +6,7 @@
import com.zyyoona7.easypopup.base.BaseActivity;
import com.zyyoona7.easypopup.basic.BasicActivity;
import com.zyyoona7.easypopup.easypop.EasyPopActivity;
import com.zyyoona7.easypopup.easypop.RecyclerViewActivity;

public class MainActivity extends BaseActivity {

Expand All @@ -15,6 +16,8 @@ public class MainActivity extends BaseActivity {

private Button mEasyBtn;

private Button mRvBtn;

@Override
protected int setLayoutId() {
return R.layout.activity_main;
Expand All @@ -27,8 +30,9 @@ protected void initVariables() {

@Override
protected void initViews() {
mBasicBtn= (Button) findViewById(R.id.btn_basic);
mEasyBtn= (Button) findViewById(R.id.btn_easy);
mBasicBtn = (Button) findViewById(R.id.btn_basic);
mEasyBtn = (Button) findViewById(R.id.btn_easy);
mRvBtn = (Button) findViewById(R.id.btn_recycler);
}

@Override
Expand All @@ -46,5 +50,12 @@ public void onClick(View v) {
goTo(EasyPopActivity.class);
}
});

mRvBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
goTo(RecyclerViewActivity.class);
}
});
}
}
@@ -0,0 +1,21 @@
package com.zyyoona7.easypopup.easypop;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.zyyoona7.easypopup.R;

/**
* Created by zyyoona7 on 2017/9/14.
*/

public class RecyclerPopAdapter extends BaseQuickAdapter<String, BaseViewHolder> {

public RecyclerPopAdapter() {
super(R.layout.layout_item_pop, null);
}

@Override
protected void convert(BaseViewHolder baseViewHolder, String s) {
baseViewHolder.addOnClickListener(R.id.iv_close);
}
}
@@ -0,0 +1,72 @@
package com.zyyoona7.easypopup.easypop;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.zyyoona7.easypopup.R;
import com.zyyoona7.lib.EasyPopup;
import com.zyyoona7.lib.HorizontalGravity;
import com.zyyoona7.lib.VerticalGravity;

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

public class RecyclerViewActivity extends AppCompatActivity {
private static final String TAG = "RecyclerViewActivity";

private RecyclerPopAdapter mPopAdapter;
private RecyclerView mRecyclerView;
private EasyPopup mRvPop;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recycler_view);
mRecyclerView = (RecyclerView) findViewById(R.id.rv_pop);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
List<String> list = new ArrayList<>();
for (int i = 0; i < 10; i++) {
list.add("");
}
mPopAdapter = new RecyclerPopAdapter();
mPopAdapter.setNewData(list);
mRecyclerView.setAdapter(mPopAdapter);
initPop();
initEvents();
}

private void initPop() {
mRvPop = new EasyPopup(this)
.setContentView(R.layout.layout_right_pop)
.setAnimationStyle(R.style.QQPopAnim)
.setFocusAndOutsideEnable(true)
// .setBackgroundDimEnable(true)
// .setDimValue(0.5f)
// .setDimColor(Color.RED)
// .setDimView(mTitleBar)
.createPopup();
mRvPop.getPopupWindow().setClippingEnabled(false);
}

private void initEvents() {
mPopAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
@Override
public void onItemChildClick(BaseQuickAdapter baseQuickAdapter, View view, int i) {
int[] locations = new int[2];
view.getLocationOnScreen(locations);
Log.i(TAG, Arrays.toString(locations));
if (locations[1] > getResources().getDisplayMetrics().heightPixels / 2) {
mRvPop.showAtAnchorView(view, VerticalGravity.ABOVE, HorizontalGravity.LEFT);
}else {
mRvPop.showAtAnchorView(view, VerticalGravity.BELOW, HorizontalGravity.LEFT);
}
}
});
}
}
Binary file added app/src/main/res/drawable-xhdpi/face_id.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/ic_close.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/iphonex.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Expand Up @@ -19,4 +19,9 @@
android:layout_height="wrap_content"
android:text="Easy"
android:id="@+id/btn_easy"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="RecyclerView"
android:id="@+id/btn_recycler"/>
</LinearLayout>
16 changes: 16 additions & 0 deletions app/src/main/res/layout/activity_recycler_view.xml
@@ -0,0 +1,16 @@
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.zyyoona7.easypopup.easypop.RecyclerViewActivity">

<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/rv_pop"
/>
</LinearLayout>
50 changes: 50 additions & 0 deletions app/src/main/res/layout/layout_item_pop.xml
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="15dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="iPhone X 发布"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">

<ImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:src="@drawable/iphonex"
android:scaleType="centerCrop"/>

<ImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:src="@drawable/face_id"
android:scaleType="centerCrop"
android:layout_marginLeft="10dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:layout_gravity="right">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="不感兴趣"
/>
<ImageView
android:id="@+id/iv_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_close"
android:layout_marginLeft="10dp"/>
</LinearLayout>
</LinearLayout>
1 change: 1 addition & 0 deletions lib-kt/.gitignore
@@ -0,0 +1 @@
/build
25 changes: 25 additions & 0 deletions lib-kt/build.gradle
@@ -0,0 +1,25 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 25
buildToolsVersion "25.0.1"

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

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

dependencies {
provided fileTree(dir: 'libs', include: ['*.jar'])
provided 'com.android.support:appcompat-v7:25.+'
}
25 changes: 25 additions & 0 deletions lib-kt/proguard-rules.pro
@@ -0,0 +1,25 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/zyyoona7/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
13 changes: 13 additions & 0 deletions lib-kt/src/main/AndroidManifest.xml
@@ -0,0 +1,13 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="com.zyyoona7.lib_kt"
>

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

</application>

</manifest>
3 changes: 3 additions & 0 deletions lib-kt/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">Lib-kt</string>
</resources>
2 changes: 1 addition & 1 deletion settings.gradle
@@ -1,2 +1,2 @@
include ':app', ':lib'
include ':app', ':lib', ':lib-kt'

0 comments on commit a7cb2d6

Please sign in to comment.