mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Don't pass Activity into WelcomePagerAdapter.
This commit is contained in:
parent
dea43c04b9
commit
de1a3144cc
2 changed files with 6 additions and 18 deletions
|
|
@ -28,8 +28,7 @@ public class WelcomeActivity extends BaseActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpAdapter() {
|
private void setUpAdapter() {
|
||||||
WelcomePagerAdapter adapter = new WelcomePagerAdapter(this);
|
pager.setAdapter(new WelcomePagerAdapter());
|
||||||
pager.setAdapter(adapter);
|
|
||||||
indicator.setViewPager(pager);
|
indicator.setViewPager(pager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package fr.free.nrw.commons;
|
package fr.free.nrw.commons;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
|
||||||
import android.support.v4.view.PagerAdapter;
|
import android.support.v4.view.PagerAdapter;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
@ -11,9 +10,6 @@ import butterknife.ButterKnife;
|
||||||
import butterknife.OnClick;
|
import butterknife.OnClick;
|
||||||
|
|
||||||
public class WelcomePagerAdapter extends PagerAdapter {
|
public class WelcomePagerAdapter extends PagerAdapter {
|
||||||
|
|
||||||
private Context context;
|
|
||||||
|
|
||||||
private static final int PAGE_FINAL = 4;
|
private static final int PAGE_FINAL = 4;
|
||||||
|
|
||||||
static final int[] PAGE_LAYOUTS = new int[]{
|
static final int[] PAGE_LAYOUTS = new int[]{
|
||||||
|
|
@ -24,10 +20,6 @@ public class WelcomePagerAdapter extends PagerAdapter {
|
||||||
R.layout.welcome_final
|
R.layout.welcome_final
|
||||||
};
|
};
|
||||||
|
|
||||||
public WelcomePagerAdapter(Context context) {
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return PAGE_LAYOUTS.length;
|
return PAGE_LAYOUTS.length;
|
||||||
|
|
@ -40,11 +32,11 @@ public class WelcomePagerAdapter extends PagerAdapter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object instantiateItem(ViewGroup container, int position) {
|
public Object instantiateItem(ViewGroup container, int position) {
|
||||||
LayoutInflater inflater = LayoutInflater.from(context);
|
LayoutInflater inflater = LayoutInflater.from(container.getContext());
|
||||||
ViewGroup layout = (ViewGroup) inflater.inflate(PAGE_LAYOUTS[position], container, false);
|
ViewGroup layout = (ViewGroup) inflater.inflate(PAGE_LAYOUTS[position], container, false);
|
||||||
|
|
||||||
if (position == PAGE_FINAL) {
|
if (position == PAGE_FINAL) {
|
||||||
ViewHolder holder = new ViewHolder(layout, context);
|
ViewHolder holder = new ViewHolder(layout);
|
||||||
layout.setTag(holder);
|
layout.setTag(holder);
|
||||||
}
|
}
|
||||||
container.addView(layout);
|
container.addView(layout);
|
||||||
|
|
@ -57,16 +49,13 @@ public class WelcomePagerAdapter extends PagerAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ViewHolder {
|
public static class ViewHolder {
|
||||||
private Context context;
|
public ViewHolder(View view) {
|
||||||
|
|
||||||
public ViewHolder(View view, Context context) {
|
|
||||||
ButterKnife.bind(this, view);
|
ButterKnife.bind(this, view);
|
||||||
this.context = context;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.welcomeYesButton)
|
@OnClick(R.id.welcomeYesButton)
|
||||||
void onClicked() {
|
void onClicked(View view) {
|
||||||
((Activity) context).finish();
|
((Activity) view.getContext()).finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue