Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

Commit

Permalink
Added setters to the slidr config to dynamically change it's values a…
Browse files Browse the repository at this point in the history
…t runtime when needed

Update example project to demonstrate changing colors dynamically
Pushing 2.0.5-SNAPSHOT
  • Loading branch information
r0adkll committed Nov 30, 2015
1 parent e056d02 commit 75af819
Show file tree
Hide file tree
Showing 12 changed files with 234 additions and 119 deletions.
7 changes: 7 additions & 0 deletions .idea/gradle.xml

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

10 changes: 0 additions & 10 deletions .idea/libraries/deadskunk_1_0_4_SNAPSHOT.xml

This file was deleted.

11 changes: 0 additions & 11 deletions .idea/libraries/gson_2_3_1.xml

This file was deleted.

18 changes: 13 additions & 5 deletions example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,23 @@ android {

}

ext{
supportLibraryVersion = '23.1.1'
kitVersion = '0.4.1'

}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':library')

compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile "com.android.support:appcompat-v7:${supportLibraryVersion}"
compile "com.android.support:recyclerview-v7:${supportLibraryVersion}"
compile "com.android.support:cardview-v7:${supportLibraryVersion}"

compile 'com.52inc:52Kit-core:0.4.1'

compile 'com.jakewharton:butterknife:6.1.0'
compile 'com.github.bumptech.glide:glide:3.6.0'
compile 'com.r0adkll:deadskunk:1.0.4-SNAPSHOT'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.google.code.gson:gson:2.4'
}
44 changes: 21 additions & 23 deletions example/example.iml
Original file line number Diff line number Diff line change
Expand Up @@ -65,44 +65,42 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/cardview-v7/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.jakewharton.timber/timber/4.0.0-SNAPSHOT/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.r0adkll/deadskunk/1.0.4-SNAPSHOT/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.52inc/52Kit-core/0.4.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/cardview-v7/23.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.jakewharton.timber/timber/4.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/io.reactivex/rxandroid/1.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/resources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/tmp" />
<excludeFolder url="file://$MODULE_DIR$/build/ivy.xml" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="gson-2.3.1" level="project" />
<orderEntry type="library" exported="" name="cardview-v7-23.0.1" level="project" />
<orderEntry type="library" exported="" name="timber-4.0.0-SNAPSHOT" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.0.1" level="project" />
<orderEntry type="library" exported="" name="deadskunk-1.0.4-SNAPSHOT" level="project" />
<orderEntry type="library" exported="" name="timber-4.0.1" level="project" />
<orderEntry type="library" exported="" name="rxjava-1.0.14" level="project" />
<orderEntry type="library" exported="" name="rxandroid-1.0.1" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-23.1.1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.1.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.1.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.1.1" level="project" />
<orderEntry type="library" exported="" name="butterknife-7.0.1" level="project" />
<orderEntry type="library" exported="" name="glide-3.6.0" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-23.0.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.0.1" level="project" />
<orderEntry type="library" exported="" name="butterknife-6.1.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.0.1" level="project" />
<orderEntry type="library" exported="" name="52Kit-core-0.4.1" level="project" />
<orderEntry type="library" exported="" name="cardview-v7-23.1.1" level="project" />
<orderEntry type="library" exported="" name="gson-2.4" level="project" />
<orderEntry type="module" module-name="library" exported="" />
</component>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.ftinc.kit.adapter.BetterRecyclerAdapter;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.r0adkll.deadskunk.adapters.BetterRecyclerAdapter;
import com.r0adkll.slidr.example.model.AndroidOS;

import java.io.InputStream;
Expand All @@ -19,12 +20,12 @@
import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.Bind;


public class MainActivity extends ActionBarActivity {
public class MainActivity extends AppCompatActivity {

@InjectView(R.id.recycler)
@Bind(R.id.recycler)
RecyclerView mRecycler;

private OSVersionAdapter mAdapter;
Expand All @@ -33,7 +34,7 @@ public class MainActivity extends ActionBarActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.inject(this);
ButterKnife.bind(this);
initRecycler();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import android.view.ViewGroup;
import android.widget.TextView;

import com.r0adkll.deadskunk.adapters.BetterRecyclerAdapter;
import com.ftinc.kit.adapter.BetterRecyclerAdapter;
import com.r0adkll.slidr.example.model.AndroidOS;

import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.Bind;

/**
* Created by r0adkll on 1/11/15.
Expand All @@ -33,12 +33,12 @@ public void onBindViewHolder(OSViewHolder viewHolder, int i) {
}

public static class OSViewHolder extends RecyclerView.ViewHolder{
@InjectView(R.id.title) public TextView title;
@InjectView(R.id.description) public TextView description;
@Bind(R.id.title) public TextView title;
@Bind(R.id.description) public TextView description;

public OSViewHolder(View itemView) {
super(itemView);
ButterKnife.inject(this, itemView);
ButterKnife.bind(this, itemView);
}
}

Expand Down
43 changes: 28 additions & 15 deletions example/src/main/java/com/r0adkll/slidr/example/ViewerActivity.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
package com.r0adkll.slidr.example;

import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.r0adkll.deadskunk.utils.Utils;
import com.r0adkll.deadskunk.views.AspectRatioImageView;
import com.ftinc.kit.util.Utils;
import com.ftinc.kit.widget.AspectRatioImageView;
import com.r0adkll.slidr.Slidr;
import com.r0adkll.slidr.example.model.AndroidOS;
import com.r0adkll.slidr.model.SlidrConfig;
import com.r0adkll.slidr.model.SlidrPosition;

import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.Bind;
import butterknife.OnClick;

/**
* Created by r0adkll on 1/11/15.
Expand All @@ -25,41 +30,42 @@ public class ViewerActivity extends AppCompatActivity {

public static final String EXTRA_OS = "extra_os_version";

@InjectView(R.id.toolbar)
@Bind(R.id.toolbar)
Toolbar mToolbar;
@InjectView(R.id.cover)
@Bind(R.id.cover)
AspectRatioImageView mCover;
@InjectView(R.id.title)
@Bind(R.id.title)
TextView mTitle;
@InjectView(R.id.description)
@Bind(R.id.description)
TextView mDescription;
@InjectView(R.id.date)
@Bind(R.id.date)
TextView mDate;
@InjectView(R.id.version)
@Bind(R.id.version)
TextView mVersion;
@InjectView(R.id.sdk)
@Bind(R.id.sdk)
TextView mSdk;
@InjectView(R.id.position)
@Bind(R.id.position)
TextView mPosition;

private AndroidOS mOS;
private SlidrConfig mConfig;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_viewer);
ButterKnife.inject(this);
ButterKnife.bind(this);

// Get the status bar colors to interpolate between
int primary = getResources().getColor(R.color.primaryDark);
int secondary = getResources().getColor(R.color.transparent);
int secondary = getResources().getColor(R.color.red_500);

// Build the slidr config
int numPositions = SlidrPosition.values().length;
SlidrPosition position = SlidrPosition.values()[Utils.getRandom().nextInt(numPositions)];
mPosition.setText(position.name());

SlidrConfig config = new SlidrConfig.Builder()
mConfig = new SlidrConfig.Builder()
.primaryColor(primary)
.secondaryColor(secondary)
.position(position)
Expand All @@ -70,7 +76,7 @@ protected void onCreate(Bundle savedInstanceState) {
.build();

// Attach the Slidr Mechanism to this activity
Slidr.attach(this, config);
Slidr.attach(this, mConfig);

setSupportActionBar(mToolbar);
getSupportActionBar().setTitle("");
Expand All @@ -92,6 +98,13 @@ protected void onCreate(Bundle savedInstanceState) {
.into(mCover);
}

@OnClick({R.id.color1, R.id.color2, R.id.color3, R.id.color4, R.id.color5})
void onColorClicked(View v){
int color = ((ColorDrawable)v.getBackground()).getColor();
getWindow().setStatusBarColor(color);
mConfig.setColorSecondary(color);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
if(item.getItemId() == android.R.id.home){
Expand Down
Loading

0 comments on commit 75af819

Please sign in to comment.