Novel human protei
Q:
Difference bet
Aberdeen councillo
Nevada Attorney Ge
GABAergic interneu
Boeing CEO Dennis
The purpose of thi
The present invent
Korean Film Archiv
A prospective stud/**
* The MIT License (MIT)
*
* Copyright (C) 2016-2017 Flavien Raymond
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
* persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.flavienraymond.draggerbardemo.views;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import com.flavienraymond.draggerbardemo.R;
import java.util.ArrayList;
import java.util.List;
public class ViewHolderActivity extends ActivityBase {
private List content;
private List thumb;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
thumb = new ArrayList<>();
thumb.add(R.drawable.icon);
thumb.add(R.drawable.icon);
thumb.add(R.drawable.icon);
thumb.add(R.drawable.icon);
thumb.add(R.drawable.icon);
thumb.add(R.drawable.icon);
thumb.add(R.drawable.icon);
thumb.add(R.drawable.icon);
thumb.add(R.drawable.icon);
thumb.add(R.drawable.icon);
thumb.add(R.drawable.icon);
thumb.add(R.drawable.icon);
thumb.add(R.drawable.icon);
thumb.add(R.drawable.icon);
thumb.add(R.drawable.icon);
thumb.add(R.drawable.icon);
thumb.add(R.drawable.icon);
thumb.add(R.drawable.icon);
thumb.add(R.drawable.icon);
thumb.add(R.drawable.icon);
thumb.add(R.drawable.icon);
content = new ArrayList<>();
content.add(R.drawable.ic_launcher_background);
content.add(R.drawable.ic_launcher_background);
content.add(R.drawable.ic_launcher_background);
content.add(R.drawable.ic_launcher_background);
content.add(R.drawable.ic_launcher_background);
content.add(R.drawable.ic_launcher_background);
content.add(R.drawable.ic_launcher_background);
content.add(R.drawable.ic_launcher_background);
content.add(R.drawable.ic_launcher_background);
content.add(R.drawable.ic_launcher_background);
content.add(R.drawable.ic_launcher_background);
content.add(R.drawable.ic_launcher_background);
content.add(R.drawable.ic_launcher_background);
content.add(R.drawable.ic_launcher_background);
content.add(R.drawable.ic_launcher_background);
content.add(R.drawable.ic_launcher_background);
content.add(R.drawable.ic_launcher_background);
content.add(R.drawable.ic_launcher_background);
content.add(R.drawable.ic_launcher_background);
content.add(R.drawable.ic_launcher_background);
content.add(R.drawable.ic_launcher_background);
content.add(R.drawable.ic_launcher_background);
if (savedInstanceState == null) {
getSupportFragmentManager()
.beginTransaction()
.add(R.id.content, new SimpleFragment())
.commit();
}
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setHasFixedSize(true);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(this, DividerItemDecoration.HORIZONTAL);
dividerItemDecoration.setDrawable(getDrawable(R.drawable.divider));
recyclerView.addItemDecoration(dividerItemDecoration);
FrameLayout parentLayout = (FrameLayout) findViewById(R.id.content_container);
FrameLayout viewHolderFrame = (FrameLayout) findViewById(R.id.view_holder_frame);
parentLayout.addView(viewHolderFrame);
recyclerView.setAdapter(new SimpleArrayAdapter(this));
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_settings) {
onBackPressed();
return true;
}
return super.onOptionsItemSelected(item);
}
public void onFragmentBackPressed() {
if (isFinishing()) return;
startActivity(new Intent(this, ViewHolderActivity.class));
finish();
}
public void onBackPressed() {
finish();
}
@Override
public void onDestroy() {
super.onDestroy();
if (thumb != null && thumb.size() > 0) {
for (int i = 0; i < thumb.size(); i++) {
int drawableId = thumb.get(i);
ImageView imageView = (ImageView) findViewById(R.id.icon_placeholder);
imageView.setImageResource(drawableId);
}
}
if (content != null && content.size() > 0) {
for (int i = 0; i < content.size(); i++) {
int drawableId = content.get(i);
ImageView imageView = (ImageView) findViewById(R.id.icon_placeholder);
imageView.setImageResource(drawableId);
}
}
}
public static class SimpleFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_content, container, false);
return rootView;
}
}
public static class SimpleArrayAdapter extends RecyclerView.Adapter {
private List images;
private List texts;
public SimpleArrayAdapter(Context context) {
images = new ArrayList<>();
images.add(R.drawable.ic_launcher_background);
images.add(R.drawable.ic_launcher_background);
images.add(R.drawable.ic_launcher_background);
images.add(R.drawable.ic_launcher_background);
images.add(R.drawable.ic_launcher_background);
images.add(R.drawable.ic_launcher_background);