-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 25 | ||
buildToolsVersion "25.0.2" | ||
defaultConfig { | ||
applicationId "com.bosphere.fadingedgelayout" | ||
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' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
compile 'com.android.support:appcompat-v7:25.1.0' | ||
compile 'com.android.support:recyclerview-v7:25.1.0' | ||
compile 'com.android.support:gridlayout-v7:25.1.0' | ||
compile project(':library') | ||
} |
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 /Volumes/Data/Users/bo/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 *; | ||
#} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest package="com.bosphere.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="com.bosphere.demo.MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
|
||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
package com.bosphere.demo; | ||
|
||
import android.graphics.Color; | ||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.GridLayoutManager; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.support.v7.widget.SwitchCompat; | ||
import android.util.TypedValue; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.SeekBar; | ||
|
||
import com.bosphere.fadingedgelayout.FadingEdgeLayout; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
|
||
private static final int MAX_FADE_LENGTH = 400; // dp | ||
|
||
private FadingEdgeLayout mFadingEdgeLayout; | ||
private RecyclerView mRecyclerView; | ||
private GridLayoutManager mLayoutManager; | ||
private Adapter mAdapter; | ||
private boolean mEnableTop = false; | ||
private boolean mEnableLeft = false; | ||
private boolean mEnableBottom = false; | ||
private boolean mEnableRight = false; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
|
||
mFadingEdgeLayout = (FadingEdgeLayout) findViewById(R.id.fading_edge_layout); | ||
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view); | ||
mLayoutManager = new GridLayoutManager(this, 4); | ||
mRecyclerView.setLayoutManager(mLayoutManager); | ||
mAdapter = new Adapter(); | ||
mRecyclerView.setAdapter(mAdapter); | ||
|
||
SeekBar sb = (SeekBar) findViewById(R.id.sb_size); | ||
sb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { | ||
@Override | ||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { | ||
float percent = progress / 100f; | ||
int len = (int) (MAX_FADE_LENGTH * percent); | ||
int lenPx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, len, | ||
getResources().getDisplayMetrics()); | ||
mFadingEdgeLayout.setFadeSizes(lenPx, lenPx, lenPx, lenPx); | ||
} | ||
|
||
@Override | ||
public void onStartTrackingTouch(SeekBar seekBar) { } | ||
|
||
@Override | ||
public void onStopTrackingTouch(SeekBar seekBar) { } | ||
}); | ||
sb.setProgress(20); | ||
} | ||
|
||
public void onClickedOrientation(View view) { | ||
switch (view.getId()) { | ||
case R.id.rb_horizontal: | ||
mLayoutManager.setOrientation(GridLayoutManager.HORIZONTAL); | ||
break; | ||
case R.id.rb_vertical: | ||
mLayoutManager.setOrientation(GridLayoutManager.VERTICAL); | ||
break; | ||
} | ||
} | ||
|
||
public void onClickedSwitch(View view) { | ||
SwitchCompat sw = (SwitchCompat) view; | ||
switch (sw.getId()) { | ||
case R.id.sw_top: | ||
mEnableTop = sw.isChecked(); | ||
mFadingEdgeLayout.setFadeEdges(mEnableTop, mEnableLeft, mEnableBottom, mEnableRight); | ||
break; | ||
case R.id.sw_left: | ||
mEnableLeft = sw.isChecked(); | ||
mFadingEdgeLayout.setFadeEdges(mEnableTop, mEnableLeft, mEnableBottom, mEnableRight); | ||
break; | ||
case R.id.sw_bottom: | ||
mEnableBottom = sw.isChecked(); | ||
mFadingEdgeLayout.setFadeEdges(mEnableTop, mEnableLeft, mEnableBottom, mEnableRight); | ||
break; | ||
case R.id.sw_right: | ||
mEnableRight = sw.isChecked(); | ||
mFadingEdgeLayout.setFadeEdges(mEnableTop, mEnableLeft, mEnableBottom, mEnableRight); | ||
break; | ||
} | ||
} | ||
|
||
private static class Adapter extends RecyclerView.Adapter<ViewHolder> { | ||
|
||
@Override | ||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | ||
View square = new View(parent.getContext()); | ||
square.setBackgroundColor(Color.MAGENTA); | ||
RecyclerView.LayoutParams params = new RecyclerView.LayoutParams(200, 200); | ||
params.leftMargin = params.topMargin = params.rightMargin = params.bottomMargin = 20; | ||
square.setLayoutParams(params); | ||
return new ViewHolder(square); | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(ViewHolder holder, int position) { | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return 80; | ||
} | ||
} | ||
|
||
private static class ViewHolder extends RecyclerView.ViewHolder { | ||
|
||
public ViewHolder(View itemView) { | ||
super(itemView); | ||
} | ||
} | ||
} |