Created
September 18, 2017 18:02
-
-
Save rasoulmiri/cac4d62a1b9a135fa0514dde20fcc3bb to your computer and use it in GitHub Desktop.
MainActivity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends AppCompatActivity { | |
private RecyclerView recyclerView; | |
ProgressBar progressBar; | |
ImageView header; | |
private WatchAdapter adapter; | |
private List<Watch> watchList; | |
private int[] thumbnails = new int[]{R.drawable.watch_1, R.drawable.watch_2, R.drawable.watch_3, R.drawable.watch_4}; | |
private String[] brands = new String[]{"Nike Sport Band","Nike Sport Band","Nike Sport Band","Nike Sport Band"}; | |
private String[] colors = new String[]{"Silver/White","Black/Cool","Silver/Volt","Black/Volt"}; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
recyclerView = (RecyclerView) findViewById(R.id.recycler_view); | |
progressBar = (ProgressBar) findViewById(R.id.progress); | |
header = (ImageView) findViewById(R.id.header); | |
//initial data | |
watchList = new ArrayList<>(); | |
for (int i = 0; i < 4; i++) { | |
Watch a = new Watch(brands[i], colors[i], thumbnails[i]); | |
watchList.add(a); | |
} | |
//initial recyclerView | |
adapter = new WatchAdapter(this, watchList); | |
RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(this, 2); | |
recyclerView.setLayoutManager(mLayoutManager); | |
recyclerView.setItemAnimator(new DefaultItemAnimator()); | |
recyclerView.setAdapter(adapter); | |
//after 7 second photo load in imageView | |
//timer for show phoyo | |
new Handler().postDelayed(new Runnable() { | |
@Override | |
public void run() { | |
header.setImageResource(R.drawable.header_watches); | |
//uncomment for remove rectangle overdraw in header | |
//progressBar.setVisibility(View.GONE); | |
} | |
}, 7000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment