Skip to content

Commit

Permalink
updating sample
Browse files Browse the repository at this point in the history
  • Loading branch information
Viven committed Nov 28, 2016
1 parent b7c192a commit 7906b57
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

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

2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ dependencies {
compile 'com.android.support:appcompat-v7:25.0.1'
testCompile 'junit:junit:4.12'
compile project(':library')
compile 'com.android.support:recyclerview-v7:25.0.1'
compile 'com.android.support:support-v4:25.0.1'
}
4 changes: 3 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<activity android:name=".MainActivity" />
<activity android:name=".RecyclerViewActivity" />
<activity android:name=".LaunchActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
16 changes: 16 additions & 0 deletions app/src/main/java/com/viven/imagezoom/sample/LaunchActivity.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
package com.viven.imagezoom.sample;

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

public class LaunchActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_launch);

findViewById(R.id.btnBasic).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(LaunchActivity.this, MainActivity.class));
}
});

findViewById(R.id.btnRecycler).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(LaunchActivity.this, RecyclerViewActivity.class));
}
});
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,73 @@
package com.viven.imagezoom.sample;

import android.os.Handler;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.MotionEvent;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.viven.imagezoom.ImageZoomHelper;

public class RecyclerViewActivity extends AppCompatActivity {

RecyclerView recyclerView;
SwipeRefreshLayout swipeRefreshLayout;

ImageZoomHelper imageZoomHelper;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recycler_view);

recyclerView = (RecyclerView) findViewById(R.id.list);
recyclerView.setLayoutManager(new GridLayoutManager(this, 2, RecyclerView.VERTICAL,
false));
recyclerView.setAdapter(new RecyclerView.Adapter() {
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
ImageView imageView = new ImageView(RecyclerViewActivity.this);
imageView.setImageResource(R.mipmap.ic_launcher);
ImageZoomHelper.setViewZoomable(imageView);
imageView.setMinimumHeight(400);
return new RecyclerView.ViewHolder(imageView) {};
}

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {

}

@Override
public int getItemCount() {
return 20;
}
});

swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeLayout);
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
ImageZoomHelper.setZoom(swipeRefreshLayout, false);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
swipeRefreshLayout.setRefreshing(false);
ImageZoomHelper.setZoom(swipeRefreshLayout, true);
}
}, 2000);
}
});

imageZoomHelper = new ImageZoomHelper(this);
}

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
return imageZoomHelper.onDispatchTouchEvent(ev) || super.dispatchTouchEvent(ev);
}
}
18 changes: 18 additions & 0 deletions app/src/main/res/layout/activity_launch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,22 @@
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.viven.imagezoom.sample.LaunchActivity">

<Button
android:text="Basic zoom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:id="@+id/btnBasic" />

<Button
android:text="Recycler View zoom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/btnBasic"
android:layout_alignLeft="@+id/btnBasic"
android:layout_alignStart="@+id/btnBasic"
android:layout_marginTop="8dp"
android:id="@+id/btnRecycler" />

</RelativeLayout>
12 changes: 12 additions & 0 deletions app/src/main/res/layout/activity_recycler_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,16 @@
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.viven.imagezoom.sample.RecyclerViewActivity">

<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</android.support.v4.widget.SwipeRefreshLayout>

</RelativeLayout>

0 comments on commit 7906b57

Please sign in to comment.