-
Notifications
You must be signed in to change notification settings - Fork 0
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
loopeer-wanggang
committed
Dec 13, 2016
0 parents
commit 97d8fad
Showing
54 changed files
with
1,779 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.idea |
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,23 @@ | ||
// 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.2' | ||
|
||
// NOTE: Do not place your application dependencies here; they belong | ||
// in the individual module build.gradle files | ||
} | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
jcenter() | ||
} | ||
} | ||
|
||
task clean(type: Delete) { | ||
delete rootProject.buildDir | ||
} |
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,37 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 25 | ||
buildToolsVersion "25.0.1" | ||
|
||
defaultConfig { | ||
applicationId "com.loopeer.android.demo" | ||
minSdkVersion 14 | ||
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' | ||
} | ||
} | ||
|
||
dataBinding { | ||
enabled true | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(include: ['*.jar'], dir: 'libs') | ||
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.0.1' | ||
testCompile 'junit:junit:4.12' | ||
compile project(':library') | ||
} |
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,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in E:\program\AndroidSDk/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 *; | ||
#} |
26 changes: 26 additions & 0 deletions
26
demo/src/androidTest/java/com/loopeer/android/demo/ExampleInstrumentedTest.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,26 @@ | ||
package com.loopeer.android.demo; | ||
|
||
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("com.loopeer.android.demo", appContext.getPackageName()); | ||
} | ||
} |
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,20 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest package="com.loopeer.android.demo" | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
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> |
145 changes: 145 additions & 0 deletions
145
demo/src/main/java/com/loopeer/android/demo/MainActivity.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,145 @@ | ||
package com.loopeer.android.demo; | ||
|
||
import android.databinding.DataBindingUtil; | ||
import android.graphics.Color; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.View; | ||
import android.widget.Toast; | ||
|
||
import com.loopeer.android.demo.databinding.ActivityMainBinding; | ||
import com.loopeer.android.popuputils.RecyclerAdapter; | ||
import com.loopeer.android.popuputils.SimpleThreeLayersPopup; | ||
import com.loopeer.android.popuputils.SimpleTwoLayersPopup; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
|
||
private List<String> mPrimaryData; | ||
private HashMap<String, List<String>> mMapDatas; | ||
|
||
private List<Model> mPrimary; | ||
private List<Model> mSecondary; | ||
private List<Model> mTertiary; | ||
|
||
private SimpleTwoLayersPopup<String, String> mSimpleTwoLayersPopup; | ||
private SimpleThreeLayersPopup<Model, Model, Model> mThreeLayersPopup; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
final ActivityMainBinding bind = DataBindingUtil.setContentView(this, R.layout.activity_main); | ||
setSupportActionBar(bind.anchor); | ||
|
||
mPrimaryData = new ArrayList<>(); | ||
mMapDatas = new HashMap<>(); | ||
|
||
mPrimary = new ArrayList<>(); | ||
mSecondary = new ArrayList<>(); | ||
mTertiary = new ArrayList<>(); | ||
|
||
// buildTwoLayersPopup(); | ||
|
||
buildThreeLayersPopup(); | ||
|
||
bind.btn.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
// mSimpleTwoLayersPopup.show(bind.anchor, 0, 0); | ||
mThreeLayersPopup.show(bind.anchor, 0, 0); | ||
} | ||
}); | ||
} | ||
|
||
|
||
private void buildTwoLayersPopup() { | ||
|
||
for (int i = 0; i < 15; i++) { | ||
String primaryItem = "primaryItem: " + i; | ||
mPrimaryData.add(primaryItem); | ||
List<String> strings = new ArrayList<>(); | ||
for (int j = 0; j < 50; j++) { | ||
strings.add(i + "-secondaryData: " + j); | ||
} | ||
|
||
mMapDatas.put(primaryItem, strings); | ||
} | ||
|
||
mSimpleTwoLayersPopup = new SimpleTwoLayersPopup<>(this); | ||
mSimpleTwoLayersPopup.setTwoLayersAdapter(new SimpleTwoLayersPopup.SimpleTwoLayersAdapter<String, String>() { | ||
@Override | ||
public List<String> setPrimaryData() { | ||
return mPrimaryData; | ||
} | ||
|
||
@Override | ||
public List<String> setSecondaryData(String s) { | ||
return mMapDatas.get(s); | ||
} | ||
}); | ||
|
||
mSimpleTwoLayersPopup.setSecondaryItemClickListener(new RecyclerAdapter.OnItemClickListener<String>() { | ||
|
||
@Override | ||
public void onItemClick(String data, int position) { | ||
Toast.makeText(MainActivity.this, data, Toast.LENGTH_SHORT).show(); | ||
mSimpleTwoLayersPopup.dismiss(); | ||
} | ||
|
||
@Override | ||
public void setItemStyle(RecyclerView.ViewHolder preItemViewHolder, RecyclerView.ViewHolder curItemViewHolder) { | ||
if (preItemViewHolder != null) | ||
preItemViewHolder.itemView.setBackgroundColor(getResources().getColor(R.color.bg_layers)); | ||
if (curItemViewHolder != null) | ||
curItemViewHolder.itemView.setBackgroundColor(Color.LTGRAY); | ||
} | ||
}); | ||
|
||
mSimpleTwoLayersPopup.setPrimaryItemClickListener(null); | ||
} | ||
|
||
private void buildThreeLayersPopup() { | ||
|
||
|
||
for (int i = 0; i < 5; i++) { | ||
Model model1 = new Model("primary--" + i); | ||
List<Model> data1 = new ArrayList<>(); | ||
for (int j = 0; j < 40; j++) { | ||
Model model2 = new Model(i + "secondary--" + i); | ||
List<Model> data2 = new ArrayList<>(); | ||
for (int k = 0; k < 50; k++) { | ||
data2.add(new Model(j + "tertiary--" + k)); | ||
} | ||
model2.setData(data2); | ||
data1.add(model2); | ||
} | ||
model1.setData(data1); | ||
mPrimary.add(model1); | ||
} | ||
|
||
mThreeLayersPopup = new SimpleThreeLayersPopup<>(this); | ||
mThreeLayersPopup.setThreeLayersAdapter(new SimpleThreeLayersPopup.SimpleThreeLayersAdapter<Model, Model, Model>() { | ||
@Override | ||
public List<Model> setTertiaryData(Model model) { | ||
return model.getData(); | ||
} | ||
|
||
@Override | ||
public List<Model> setPrimaryData() { | ||
return mPrimary; | ||
} | ||
|
||
@Override | ||
public List<Model> setSecondaryData(Model model) { | ||
return model.getData(); | ||
} | ||
}); | ||
|
||
/*mThreeLayersPopup.setPrimaryItemClickListener(null); | ||
mThreeLayersPopup.setSecondaryItemClickListener(null);*/ | ||
} | ||
} |
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,38 @@ | ||
package com.loopeer.android.demo; | ||
|
||
import java.util.List; | ||
|
||
public class Model { | ||
String name; | ||
List<Model> data; | ||
|
||
public Model(String name) { | ||
this.name = name; | ||
} | ||
|
||
public Model(List<Model> data, String name) { | ||
this.data = data; | ||
this.name = name; | ||
} | ||
|
||
public List<Model> getData() { | ||
return data; | ||
} | ||
|
||
public void setData(List<Model> data) { | ||
this.data = data; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return name; | ||
} | ||
} |
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,32 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<layout | ||
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"> | ||
|
||
<RelativeLayout | ||
android:id="@+id/activity_main" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context="com.loopeer.android.demo.MainActivity"> | ||
|
||
<android.support.v7.widget.Toolbar | ||
android:id="@+id/anchor" | ||
android:layout_width="match_parent" | ||
android:layout_height="?attr/actionBarSize" | ||
android:background="@color/colorPrimary" | ||
app:titleTextColor="@android:color/white"/> | ||
|
||
<android.support.v7.widget.AppCompatButton | ||
android:id="@+id/btn" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_alignParentBottom="true" | ||
android:layout_centerHorizontal="true" | ||
android:background="@color/colorPrimary" | ||
android:text="Hello World!" | ||
android:textAllCaps="false" | ||
android:textColor="@android:color/white"/> | ||
</RelativeLayout> | ||
</layout> | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<resources> | ||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml | ||
(such as screen margins) for screens with more than 820dp of available width. This | ||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). --> | ||
<dimen name="activity_horizontal_margin">64dp</dimen> | ||
</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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="colorPrimary">#3F51B5</color> | ||
<color name="colorPrimaryDark">#303F9F</color> | ||
<color name="colorAccent">#FF4081</color> | ||
</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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<resources> | ||
<!-- Default screen margins, per the Android Design guidelines. --> | ||
<dimen name="activity_horizontal_margin">16dp</dimen> | ||
<dimen name="activity_vertical_margin">16dp</dimen> | ||
</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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<resources> | ||
<string name="app_name">Demo</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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<resources> | ||
|
||
<!-- Base application theme. --> | ||
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> | ||
<!-- Customize your theme here. --> | ||
<item name="colorPrimary">@color/colorPrimary</item> | ||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> | ||
<item name="colorAccent">@color/colorAccent</item> | ||
</style> | ||
|
||
</resources> |
Oops, something went wrong.