aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/org/bienvenidoainternet/baiparser/ViewerActivity.java
diff options
context:
space:
mode:
authorLibravatar Renard 2016-04-26 15:59:17 -0300
committerLibravatar Renard 2016-04-26 15:59:17 -0300
commita5f9e1088f94890c44f70a2ebd4c38d7e86f2adf (patch)
tree6ce7659e46c1da14052fe9d29f1c05a60e99fe91 /app/src/main/java/org/bienvenidoainternet/baiparser/ViewerActivity.java
parent034e14235e987b30d0ebc181b2d24c632035c453 (diff)
downloadBaiApp-a5f9e1088f94890c44f70a2ebd4c38d7e86f2adf.tar.gz
BaiApp-a5f9e1088f94890c44f70a2ebd4c38d7e86f2adf.tar.xz
BaiApp-a5f9e1088f94890c44f70a2ebd4c38d7e86f2adf.zip
packageID, gradle version fix, jsoup license.dev
Diffstat (limited to 'app/src/main/java/org/bienvenidoainternet/baiparser/ViewerActivity.java')
-rw-r--r--app/src/main/java/org/bienvenidoainternet/baiparser/ViewerActivity.java137
1 files changed, 0 insertions, 137 deletions
diff --git a/app/src/main/java/org/bienvenidoainternet/baiparser/ViewerActivity.java b/app/src/main/java/org/bienvenidoainternet/baiparser/ViewerActivity.java
deleted file mode 100644
index 3da7f92..0000000
--- a/app/src/main/java/org/bienvenidoainternet/baiparser/ViewerActivity.java
+++ /dev/null
@@ -1,137 +0,0 @@
-package org.bienvenidoainternet.baiparser;
-
-import android.content.Context;
-import android.content.ContextWrapper;
-import android.media.MediaScannerConnection;
-import android.net.Uri;
-import android.os.Bundle;
-import android.os.Environment;
-import android.support.v4.view.ViewPager;
-import android.support.v7.app.AppCompatActivity;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.widget.ProgressBar;
-import android.widget.Toast;
-
-import org.bienvenidoainternet.baiparser.structure.BoardItemFile;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-
-import layout.FragmentImage;
-
-/**
- * BaiApp - Bienvenido a internet Android Application
- * Copyright (C) 2016 Renard1911(https://github.com/Renard1911)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-public class ViewerActivity extends AppCompatActivity implements FragmentImage.OnFragmentInteractionListener {
- private static final String EXTRA_FILELIST = "fileList", EXTRA_RELATIVEPOSITION = "position";
- private ViewPager imagePager;
- public ProgressBar barDownload;
- private int relativePosition = 0;
-
- public ArrayList<BoardItemFile> fileList = new ArrayList<BoardItemFile>();
- private CustomFragmentPagerAdapter pagerAdapter;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- if (getIntent().getExtras() != null){
- fileList = getIntent().getParcelableArrayListExtra(EXTRA_FILELIST);
- relativePosition = getIntent().getIntExtra(EXTRA_RELATIVEPOSITION, 0);
- }
- setContentView(R.layout.activity_viewer);
- barDownload = (ProgressBar) findViewById(R.id.downloadProgressBar);
- imagePager = (ViewPager) findViewById(R.id.imagePager);
- this.pagerAdapter = new CustomFragmentPagerAdapter(getSupportFragmentManager());
- for (int i = 0; i < fileList.size(); i++){
- Log.v("ImageViewer", fileList.get(i).toString());
- pagerAdapter.addFragment(FragmentImage.newInstance(fileList.get(i)));
- }
- imagePager.setAdapter(pagerAdapter);
- imagePager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
- @Override
- public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
-
- }
-
- @Override
- public void onPageSelected(int position) {
- getSupportActionBar().setSubtitle("(" + (position + 1) + " / " + fileList.size() + ") " + fileList.get(position).file);
- }
-
- @Override
- public void onPageScrollStateChanged(int state) {
-
- }
- });
- imagePager.setCurrentItem(relativePosition);
- this.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- File baiDir = new File(Environment.getExternalStorageDirectory().getPath() + "/Bai/");
- if (!baiDir.exists()){
- baiDir.mkdir();
- }
- if (item.getItemId() == R.id.menu_save_img){
- BoardItemFile boardItemFile = fileList.get(imagePager.getCurrentItem());
- File to = new File(Environment.getExternalStorageDirectory().getPath() + "/Bai/" + boardItemFile.file);
- ContextWrapper cw = new ContextWrapper(getApplicationContext());
- File directory = cw.getDir("src", Context.MODE_PRIVATE);
- File fileSource = new File(directory, boardItemFile.boardDir + "_" + boardItemFile.file);
- try{
- InputStream in = new FileInputStream(fileSource);
- OutputStream out = new FileOutputStream(to);
- byte[] buf = new byte[1024];
- int len;
- while ((len = in.read(buf)) > 0) {
- out.write(buf, 0, len);
- }
- in.close();
- out.close();
- Toast.makeText(getApplicationContext(), boardItemFile.file + " guardado.", Toast.LENGTH_LONG).show();
- MediaScannerConnection.scanFile(this, new String[]{to.getPath()}, new String[]{"image/jpeg"}, null);
- }catch (Exception e){
- e.printStackTrace();
- }
-
- }
- if (item.getItemId() == android.R.id.home) {
- onBackPressed();
- }
- return super.onOptionsItemSelected(item);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.menu_viewer, menu);
- return true;
- }
-
- @Override
- public void onFragmentInteraction(Uri uri) {
-
- }
-}