// Path: app/src/main/java/com/secuso/privacyfriendlycodescanner/qrscanner/ui/viewmodel/ResultViewModel.java
// public class ResultViewModel extends AndroidViewModel {
// 
//     private BarcodeResult currentBarcodeResult = null;
// 
//     public HistoryItem currentHistoryItem = null;
//     public ParsedResult mParsedResult = null;
//     public Bitmap mCodeImage = null;
//     public boolean mSavedToHistory = false;
// 
//     private final SharedPreferences mPreferences;
// 
//     public ResultViewModel(@NonNull Application application) {
//         super(application);
// 
//         mPreferences = PreferenceManager.getDefaultSharedPreferences(application);
//     }
// 
//     /**
//      * After this function is called the the following values will not be null:
//      * <ul>
//      *     <li>currentHistoryItem</li>
//      *     <li>mCodeImage</li>
//      *     <li>mSavedToHistory</li>
//      *     <li>mParsedResult</li>
//      * </ul>
//      * If the state can not be created the activity will call {@link AppCompatActivity#finish()}
//      * This method will also update the {@link HistoryItem} in the database with a recreation of the QR Code if the image is missing.
//      */
//     public void initFromHistoryItem(HistoryItem historyItem) {
//         currentHistoryItem = historyItem;
//         mParsedResult = ResultParser.parseResult(currentHistoryItem.getResult());
//         mCodeImage = currentHistoryItem.getImage();
//         if(mCodeImage == null) {
//             mCodeImage = Utils.generateCode(currentHistoryItem.getText(), BarcodeFormat.QR_CODE, null, null);
//             currentHistoryItem.setImage(mCodeImage);
//             currentHistoryItem.setFormat(BarcodeFormat.QR_CODE);
//             updateHistoryItem(currentHistoryItem);
//         }
//         mSavedToHistory = true;
//     }
// 
//     public void initFromScan(BarcodeResult barcodeResult) {
//         currentBarcodeResult = barcodeResult;
//         mParsedResult = ResultParser.parseResult(currentBarcodeResult.getResult());
//         mCodeImage = currentBarcodeResult.getBitmapWithResultPoints(ContextCompat.getColor(getApplication(), R.color.colorAccent));
// 
//         createHistoryItem();
//         if(mPreferences.getBoolean("bool_history",true)){
//             this.saveHistoryItem(currentHistoryItem);
//         }
//     }
// 
//     public void saveHistoryItem(HistoryItem item) {
//         AppRepository.getInstance(getApplication()).insertHistoryEntry(item);
//         mSavedToHistory = true;
//     }
// 
// 
//     public void updateHistoryItem(HistoryItem item) {
//         AppRepository.getInstance(getApplication()).updateHistoryEntry(item);
//     }
// 
//     private void createHistoryItem() {
//         currentHistoryItem = new HistoryItem();
// 
//         Bitmap image;
//         boolean prefSaveRealImage = mPreferences.getBoolean(PREF_SAVE_REAL_IMAGE_TO_HISTORY, false);
//         if(prefSaveRealImage) {
//             float height;
//             float width;
//             if(mCodeImage.getWidth() == 0 || mCodeImage.getWidth() == 0) {
//                 height = 200f;
//                 width = 200f;
//             } else if(mCodeImage.getWidth() > mCodeImage.getHeight()) {
//                 height = (float)mCodeImage.getHeight() / (float)mCodeImage.getWidth() * 200f;
//                 width = 200f;
//             } else {
//                 width = (float)mCodeImage.getWidth() / (float)mCodeImage.getHeight() * 200f;
//                 height = 200f;
//             }
//             image = Bitmap.createScaledBitmap(mCodeImage, (int)width, (int)height, false);
//         } else {
//             image = Utils.generateCode(currentBarcodeResult.getText(), currentBarcodeResult.getBarcodeFormat(), null, currentBarcodeResult.getResult().getResultMetadata());
//         }
//         currentHistoryItem.setImage(image);
// 
//         currentHistoryItem.setFormat(currentBarcodeResult.getResult().getBarcodeFormat());
//         currentHistoryItem.setNumBits(currentBarcodeResult.getResult().getNumBits());
//         currentHistoryItem.setRawBytes(currentBarcodeResult.getResult().getRawBytes());
//         currentHistoryItem.setResultPoints(currentBarcodeResult.getResult().getResultPoints());
//         currentHistoryItem.setText(currentBarcodeResult.getResult().getText());
//         currentHistoryItem.setTimestamp(currentBarcodeResult.getResult().getTimestamp());
//     }
// 
// }


import android.content.Context;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelProviders;
import com.google.zxing.client.result.ParsedResult;
import com.secuso.privacyfriendlycodescanner.qrscanner.R;
import com.secuso.privacyfriendlycodescanner.qrscanner.ui.viewmodel.ResultViewModel;
package com.secuso.privacyfriendlycodescanner.qrscanner.ui.resultfragments;




public abstract class ResultFragment extends Fragment {

    protected ParsedResult parsedResult;
// Path: app/src/main/java/com/secuso/privacyfriendlycodescanner/qrscanner/ui/viewmodel/ResultViewModel.java
// public class ResultViewModel extends AndroidViewModel {
// 
//     private BarcodeResult currentBarcodeResult = null;
// 
//     public HistoryItem currentHistoryItem = null;
//     public ParsedResult mParsedResult = null;
//     public Bitmap mCodeImage = null;
//     public boolean mSavedToHistory = false;
// 
//     private final SharedPreferences mPreferences;
// 
//     public ResultViewModel(@NonNull Application application) {
//         super(application);
// 
//         mPreferences = PreferenceManager.getDefaultSharedPreferences(application);
//     }
// 
//     /**
//      * After this function is called the the following values will not be null:
//      * <ul>
//      *     <li>currentHistoryItem</li>
//      *     <li>mCodeImage</li>
//      *     <li>mSavedToHistory</li>
//      *     <li>mParsedResult</li>
//      * </ul>
//      * If the state can not be created the activity will call {@link AppCompatActivity#finish()}
//      * This method will also update the {@link HistoryItem} in the database with a recreation of the QR Code if the image is missing.
//      */
//     public void initFromHistoryItem(HistoryItem historyItem) {
//         currentHistoryItem = historyItem;
//         mParsedResult = ResultParser.parseResult(currentHistoryItem.getResult());
//         mCodeImage = currentHistoryItem.getImage();
//         if(mCodeImage == null) {
//             mCodeImage = Utils.generateCode(currentHistoryItem.getText(), BarcodeFormat.QR_CODE, null, null);
//             currentHistoryItem.setImage(mCodeImage);
//             currentHistoryItem.setFormat(BarcodeFormat.QR_CODE);
//             updateHistoryItem(currentHistoryItem);
//         }
//         mSavedToHistory = true;
//     }
// 
//     public void initFromScan(BarcodeResult barcodeResult) {
//         currentBarcodeResult = barcodeResult;
//         mParsedResult = ResultParser.parseResult(currentBarcodeResult.getResult());
//         mCodeImage = currentBarcodeResult.getBitmapWithResultPoints(ContextCompat.getColor(getApplication(), R.color.colorAccent));
// 
//         createHistoryItem();
//         if(mPreferences.getBoolean("bool_history",true)){
//             this.saveHistoryItem(currentHistoryItem);
//         }
//     }
// 
//     public void saveHistoryItem(HistoryItem item) {
//         AppRepository.getInstance(getApplication()).insertHistoryEntry(item);
//         mSavedToHistory = true;
//     }
// 
// 
//     public void updateHistoryItem(HistoryItem item) {
//         AppRepository.getInstance(getApplication()).updateHistoryEntry(item);
//     }
// 
//     private void createHistoryItem() {
//         currentHistoryItem = new HistoryItem();
// 
//         Bitmap image;
//         boolean prefSaveRealImage = mPreferences.getBoolean(PREF_SAVE_REAL_IMAGE_TO_HISTORY, false);
//         if(prefSaveRealImage) {
//             float height;
//             float width;
//             if(mCodeImage.getWidth() == 0 || mCodeImage.getWidth() == 0) {
//                 height = 200f;
//                 width = 200f;
//             } else if(mCodeImage.getWidth() > mCodeImage.getHeight()) {
//                 height = (float)mCodeImage.getHeight() / (float)mCodeImage.getWidth() * 200f;
//                 width = 200f;
//             } else {
//                 width = (float)mCodeImage.getWidth() / (float)mCodeImage.getHeight() * 200f;
//                 height = 200f;
//             }
//             image = Bitmap.createScaledBitmap(mCodeImage, (int)width, (int)height, false);
//         } else {
//             image = Utils.generateCode(currentBarcodeResult.getText(), currentBarcodeResult.getBarcodeFormat(), null, currentBarcodeResult.getResult().getResultMetadata());
//         }
//         currentHistoryItem.setImage(image);
// 
//         currentHistoryItem.setFormat(currentBarcodeResult.getResult().getBarcodeFormat());
//         currentHistoryItem.setNumBits(currentBarcodeResult.getResult().getNumBits());
//         currentHistoryItem.setRawBytes(currentBarcodeResult.getResult().getRawBytes());
//         currentHistoryItem.setResultPoints(currentBarcodeResult.getResult().getResultPoints());
//         currentHistoryItem.setText(currentBarcodeResult.getResult().getText());
//         currentHistoryItem.setTimestamp(currentBarcodeResult.getResult().getTimestamp());
//     }
// 
// }


// Path: app/src/main/java/com/secuso/privacyfriendlycodescanner/qrscanner/ui/resultfragments/ResultFragment.java
import android.content.Context;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelProviders;
import com.google.zxing.client.result.ParsedResult;
import com.secuso.privacyfriendlycodescanner.qrscanner.R;
import com.secuso.privacyfriendlycodescanner.qrscanner.ui.viewmodel.ResultViewModel;

package com.secuso.privacyfriendlycodescanner.qrscanner.ui.resultfragments;




public abstract class ResultFragment extends Fragment {

    protected ParsedResult parsedResult;
    protected ResultViewModel viewModel;