Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bosphere committed Jan 19, 2017
0 parents commit 0d04d7a
Show file tree
Hide file tree
Showing 37 changed files with 1,099 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
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
22 changes: 22 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
28 changes: 28 additions & 0 deletions app/build.gradle
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')
}
17 changes: 17 additions & 0 deletions app/proguard-rules.pro
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 *;
#}
20 changes: 20 additions & 0 deletions app/src/main/AndroidManifest.xml
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>
122 changes: 122 additions & 0 deletions app/src/main/java/com/bosphere/demo/MainActivity.java
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);
}
}
}
Loading

0 comments on commit 0d04d7a

Please sign in to comment.