Skip to content

Commit

Permalink
add touchmode
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel163 committed Apr 29, 2017
1 parent ea15dcc commit 35722e6
Show file tree
Hide file tree
Showing 17 changed files with 281 additions and 97 deletions.
7 changes: 4 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ dependencies {
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.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'

compile project(":library")
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:design:25.3.1'
testCompile 'junit:junit:4.12'
}
8 changes: 6 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ebr163.bifacialview">

<uses-permission android:name="android.permission.INTERNET"/>

<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
Expand All @@ -19,6 +18,11 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ViewPagerActivity"
android:label="@string/title_activity_view_pager"
android:theme="@style/AppTheme.NoActionBar" />
<activity android:name=".SimpleActivity"></activity>
</application>

</manifest>
49 changes: 49 additions & 0 deletions app/src/main/java/com/ebr163/bifacialview/CustomPagerAdapter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.ebr163.bifacialview;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
* Created by ergashev on 29.04.17.
*/

public class CustomPagerAdapter extends PagerAdapter {

private Context mContext;

public CustomPagerAdapter(Context context) {
mContext = context;
}

@Override
public Object instantiateItem(ViewGroup collection, int position) {
LayoutInflater inflater = LayoutInflater.from(mContext);
ViewGroup layout = (ViewGroup) inflater.inflate(R.layout.page, collection, false);
collection.addView(layout);
return layout;
}

@Override
public void destroyItem(ViewGroup collection, int position, Object view) {
collection.removeView((View) view);
}

@Override
public int getCount() {
return 3;
}

@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}

@Override
public CharSequence getPageTitle(int position) {
return "Title";
}

}
46 changes: 11 additions & 35 deletions app/src/main/java/com/ebr163/bifacialview/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,49 +1,25 @@
package com.ebr163.bifacialview;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.Target;
import com.ebr163.bifacialview.view.BifacialView;

public class MainActivity extends AppCompatActivity {
public class MainActivity extends AppCompatActivity implements View.OnClickListener {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final BifacialView view = (BifacialView) findViewById(R.id.view);
Glide.with(this)
.load("https://files4.adme.ru/files/news/part_149/1494765/29530665-262592-3-0-1491487588-1491487592-650-bf845cd25e-1491558012.jpg")
.listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
return false;
}

@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
view.setDrawableLeft(resource);
return false;
}
}).preload();

Glide.with(this)
.load("https://files3.adme.ru/files/news/part_149/1494765/29530265-262592-33-0-1491489159-1491489163-650-8edb1df01d-1491558012.jpg")
.listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
return false;
}
}

@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
view.setDrawableRight(resource);
return false;
}
}).preload();
@Override
public void onClick(View v) {
if (v.getId() == R.id.simple_screen) {
startActivity(new Intent(this, SimpleActivity.class));
} else {
startActivity(new Intent(this, ViewPagerActivity.class));
}
}
}
49 changes: 49 additions & 0 deletions app/src/main/java/com/ebr163/bifacialview/SimpleActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.ebr163.bifacialview;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.Target;
import com.ebr163.bifacialview.view.BifacialView;

public class SimpleActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_simple);
final BifacialView view = (BifacialView) findViewById(R.id.view);
Glide.with(this)
.load("https://files4.adme.ru/files/news/part_149/1494765/29530665-262592-3-0-1491487588-1491487592-650-bf845cd25e-1491558012.jpg")
.listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
return false;
}

@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
view.setDrawableRight(resource);
return false;
}
}).preload();

Glide.with(this)
.load("https://files3.adme.ru/files/news/part_149/1494765/29530265-262592-33-0-1491489159-1491489163-650-8edb1df01d-1491558012.jpg")
.listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
return false;
}

@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
view.setDrawableLeft(resource);
return false;
}
}).preload();
}
}
20 changes: 20 additions & 0 deletions app/src/main/java/com/ebr163/bifacialview/ViewPagerActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.ebr163.bifacialview;

import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;

public class ViewPagerActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_pager);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ViewPager view = (ViewPager) findViewById(R.id.viewpager);
view.setAdapter(new CustomPagerAdapter(this));
}

}
36 changes: 18 additions & 18 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="@android:color/black"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
android:orientation="vertical">

<com.ebr163.bifacialview.view.BifacialView
android:id="@+id/view"
android:layout_centerInParent="true"
android:layout_width="match_parent"
android:layout_height="226dp"
app:drawableLeft="@drawable/left"
app:drawableRight="@drawable/right"
app:arrowVisibility="true"
app:leftText="before"
app:rightText="after"
app:textSize="20sp"
app:delimiterColor="@android:color/white"
app:arrowColor="@android:color/holo_orange_light"
app:textColor="@android:color/holo_orange_light" />
<Button
android:id="@+id/simple_screen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:onClick="onClick"
android:text="Simple" />

</RelativeLayout>
<Button
android:id="@+id/vp_screen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:onClick="onClick"
android:text="ViewPager" />

</LinearLayout>
24 changes: 24 additions & 0 deletions app/src/main/res/layout/activity_simple.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context="com.ebr163.bifacialview.SimpleActivity">

<com.ebr163.bifacialview.view.BifacialView
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="256dp"
android:layout_centerInParent="true"
app:arrowColor="@color/colorAccent"
app:arrowVisibility="true"
app:drawableLeft="@drawable/left"
app:drawableRight="@drawable/right"
app:leftText="before"
app:rightText="after"
app:textColor="@color/colorPrimary"
app:textSize="20sp" />


</RelativeLayout>
25 changes: 25 additions & 0 deletions app/src/main/res/layout/activity_view_pager.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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"
tools:context="com.ebr163.bifacialview.ViewPagerActivity">

<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />

</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_view_pager" />

</android.support.design.widget.CoordinatorLayout>
10 changes: 10 additions & 0 deletions app/src/main/res/layout/content_view_pager.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/viewpager"
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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.ebr163.bifacialview.ViewPagerActivity"
tools:showIn="@layout/activity_view_pager" />
24 changes: 24 additions & 0 deletions app/src/main/res/layout/page.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context="com.ebr163.bifacialview.SimpleActivity">

<com.ebr163.bifacialview.view.BifacialView
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="256dp"
android:layout_centerInParent="true"
app:arrowColor="@color/colorAccent"
app:arrowVisibility="true"
app:drawableLeft="@drawable/left"
app:drawableRight="@drawable/right"
app:leftText="before"
app:rightText="after"
app:touchMode="delimiter"
app:textColor="@color/colorPrimary"
app:textSize="20sp" />

</RelativeLayout>
3 changes: 3 additions & 0 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<dimen name="fab_margin">16dp</dimen>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<resources>
<string name="app_name">BifacialView</string>
<string name="title_activity_view_pager">ViewPagerActivity</string>
</resources>
9 changes: 9 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,13 @@
<item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

</resources>
Loading

0 comments on commit 35722e6

Please sign in to comment.