Revision f3e12931
Added by Leszek Koltunski over 4 years ago
src/main/java/org/distorted/magic/RubikScoresViewPager.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.magic; |
21 | 21 |
|
22 |
import android.content.Context; |
|
23 | 22 |
import android.support.annotation.NonNull; |
23 |
import android.support.v4.app.FragmentActivity; |
|
24 | 24 |
import android.support.v4.view.PagerAdapter; |
25 | 25 |
import android.support.v4.view.ViewPager; |
26 |
import android.view.LayoutInflater; |
|
27 | 26 |
import android.view.View; |
28 | 27 |
import android.view.ViewGroup; |
29 | 28 |
|
30 | 29 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
31 | 30 |
|
32 |
class RubikScoresViewPager extends PagerAdapter |
|
31 |
class RubikScoresViewPager extends PagerAdapter implements RubikScores.ScoresReceiver
|
|
33 | 32 |
{ |
34 |
private Context mContext;
|
|
33 |
private FragmentActivity mAct;
|
|
35 | 34 |
|
36 | 35 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
37 | 36 |
|
38 |
RubikScoresViewPager(Context context, ViewPager viewPager)
|
|
37 |
RubikScoresViewPager(FragmentActivity act, ViewPager viewPager)
|
|
39 | 38 |
{ |
40 |
mContext = context;
|
|
39 |
mAct = act;
|
|
41 | 40 |
viewPager.setAdapter(this); |
42 | 41 |
viewPager.setOffscreenPageLimit( RubikSize.LENGTH-1 ); |
43 | 42 |
} |
44 | 43 |
|
44 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
45 |
// TODO |
|
46 |
|
|
47 |
public void receive(String scores) |
|
48 |
{ |
|
49 |
|
|
50 |
} |
|
51 |
|
|
45 | 52 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
46 | 53 |
|
47 | 54 |
@Override |
48 | 55 |
@NonNull |
49 | 56 |
public Object instantiateItem(@NonNull ViewGroup collection, int position) |
50 | 57 |
{ |
51 |
int scoresTab= RubikSize.getSize(position).getLayout(); |
|
52 |
LayoutInflater inflater = LayoutInflater.from(mContext); |
|
53 |
ViewGroup layout = (ViewGroup) inflater.inflate(scoresTab, collection, false); |
|
54 |
collection.addView(layout); |
|
58 |
RubikScoresView view = new RubikScoresView(mAct,position); |
|
59 |
collection.addView(view); |
|
55 | 60 |
|
56 |
return layout;
|
|
61 |
return view;
|
|
57 | 62 |
} |
58 | 63 |
|
59 | 64 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Improvements