Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
248 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
app/src/main/java/com/zyyoona7/easypopup/easypop/RecyclerPopAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
app/src/main/java/com/zyyoona7/easypopup/easypop/RecyclerViewActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} | ||
}); | ||
} | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.+' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<resources> | ||
<string name="app_name">Lib-kt</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
include ':app', ':lib' | ||
include ':app', ':lib', ':lib-kt' | ||
|