Skip to content
This repository has been archived by the owner on Dec 20, 2017. It is now read-only.

Commit

Permalink
graphenej lib scheme updates and gradle update
Browse files Browse the repository at this point in the history
  • Loading branch information
computationalcore committed Jun 30, 2017
1 parent 920cfd8 commit 5593847
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@
import de.bitsharesmunich.graphenej.models.BlockHeader;
import de.bitsharesmunich.graphenej.models.BucketObject;
import de.bitsharesmunich.graphenej.models.HistoricalTransfer;
import de.bitsharesmunich.graphenej.models.Market;
import de.bitsharesmunich.graphenej.models.WitnessResponse;
import de.bitsharesmunich.graphenej.models.api.GetLimitOrders;
import de.bitsharesmunich.graphenej.objects.Memo;
import de.bitsharesmunich.graphenej.operations.TransferOperation;
import de.codecrafters.tableview.SortableTableView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
/**
* A custom Map implementation that will return a default value
* specified in the constructor.
*
* <p>
* Created by nelson on 12/24/16.
*/
public class DefaultHashMap<K,V> extends HashMap<K,V> {
public class DefaultHashMap<K, V> extends HashMap<K, V> {
protected V defaultValue;

public DefaultHashMap(V defaultValue) {
this.defaultValue = defaultValue;
}

@Override
public V get(Object k) {
return containsKey(k) ? super.get(k) : defaultValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
import java.util.Arrays;
import java.util.List;

import de.bitshares_munich.interfaces.PdfGeneratorListener;
import de.bitshares_munich.database.HistoricalTransferEntry;
import de.bitshares_munich.interfaces.PdfGeneratorListener;
import de.bitshares_munich.smartcoinswallet.PdfTable;
import de.bitsharesmunich.graphenej.UserAccount;

/**
* AsyncTask subclass used to move the PDF generation procedure to a background thread
* and inform the UI of the progress.
*
* <p>
* Created by nelson on 12/28/16.
*/
public class PdfGeneratorTask extends AsyncTask<HistoricalTransferEntry, Float, String> {
private Context mContext;
private UserAccount userAccount;
private PdfGeneratorListener mListener;

public PdfGeneratorTask(Context context, UserAccount user, PdfGeneratorListener listener){
public PdfGeneratorTask(Context context, UserAccount user, PdfGeneratorListener listener) {
this.mContext = context;
this.userAccount = user;
this.mListener = listener;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
*/
public class PermissionManager {

public PermissionManager()
{
public PermissionManager() {

}

Expand All @@ -24,7 +23,7 @@ public PermissionManager()

/**
* Checks if the app has permission to write to device storage
*
* <p>
* If the app does not has permission then the user will be prompted to grant permissions
*
* @param activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* Created by root on 1/21/16.
*/
public class ServiceGenerator{
public class ServiceGenerator {
public static String TAG = "ServiceGenerator";
public static String API_BASE_URL;
private static HttpLoggingInterceptor logging;
Expand All @@ -24,7 +24,7 @@ public class ServiceGenerator{
private static HashMap<Class<?>, Object> Services;

public ServiceGenerator(String apiBaseUrl) {
API_BASE_URL= apiBaseUrl;
API_BASE_URL = apiBaseUrl;
logging = new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY);
clientBuilder = new OkHttpClient.Builder().addInterceptor(logging);
builder = new Retrofit.Builder().baseUrl(API_BASE_URL).addConverterFactory(GsonConverterFactory.create());
Expand Down
131 changes: 63 additions & 68 deletions app/src/main/java/de/bitshares_munich/utils/SupportMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,69 +36,61 @@ public class SupportMethods {
public static String extStorage = Environment.getExternalStorageDirectory().getAbsolutePath();
public static File extStorageFile = new File(extStorage);

public static String ConvertValueintoPrecision(String precision, String number){
public static String ConvertValueintoPrecision(String precision, String number) {
Double ok = 1.0;
Double pre = Double.valueOf(precision);
Double value = Double.valueOf(number);
for(int k = 0 ; k<pre ; k++ ){
ok = ok*10;
for (int k = 0; k < pre; k++) {
ok = ok * 10;
}
return Double.toString(value/ok);
return Double.toString(value / ok);
}

public static double convertAssetAmountToDouble(String precision,String number){
public static double convertAssetAmountToDouble(String precision, String number) {
Double ok = 1.0;
Double pre = Double.valueOf(precision);
Double value = Double.valueOf(number);
for(int k = 0 ; k<pre ; k++ ){
ok = ok*10;
for (int k = 0; k < pre; k++) {
ok = ok * 10;
}
return value/ok;
return value / ok;
}

public static double convertAssetAmountToFiat(double amount,double exchanegrate){
return amount*exchanegrate;
public static double convertAssetAmountToFiat(double amount, double exchanegrate) {
return amount * exchanegrate;
}

public static double convertAssetAmountToFiat(double amount,String exchanegrate){
public static double convertAssetAmountToFiat(double amount, String exchanegrate) {
double eR = Double.valueOf(exchanegrate);
return convertAssetAmountToFiat(amount,eR);
return convertAssetAmountToFiat(amount, eR);
}

public static String ParseJsonObject(String Json , String Req)
{
try
{
if(Json.contains(Req))
{
public static String ParseJsonObject(String Json, String Req) {
try {
if (Json.contains(Req)) {
JSONObject myJson = new JSONObject(Json);
return myJson.getString(Req);
return myJson.getString(Req);
}
}
catch (Exception e)
{
testing("SupportMethods",e,"ParseJsonObject");
} catch (Exception e) {
testing("SupportMethods", e, "ParseJsonObject");
}
return "";
}
public static String ParseObjectFromJsonArray(String Json , int position)
{
try
{

public static String ParseObjectFromJsonArray(String Json, int position) {
try {
JSONArray myArray = new JSONArray(Json);
if(myArray.length()>=position){
return myArray.get(position).toString();
if (myArray.length() >= position) {
return myArray.get(position).toString();
}
}
catch (Exception e)
{
testing("SupportMethods",e,"ParseObjectFromJsonArray");
} catch (Exception e) {
testing("SupportMethods", e, "ParseObjectFromJsonArray");
}
return "";
}

@Nullable
public static HashMap<String,ArrayList<String>> ParseJsonArray(String Json , String req){
public static HashMap<String, ArrayList<String>> ParseJsonArray(String Json, String req) {
try {
JSONArray myArray = new JSONArray(Json);
ArrayList<String> array = new ArrayList<>();
Expand All @@ -116,13 +108,13 @@ public static HashMap<String,ArrayList<String>> ParseJsonArray(String Json , Str

}
return pairs;
}catch (Exception e){
testing("SupportMethods",e,"ParseJsonArray");
} catch (Exception e) {
testing("SupportMethods", e, "ParseJsonArray");
}
return null;
}

public static void testing(String msg , Exception e , String nameOfObject){
public static void testing(String msg, Exception e, String nameOfObject) {
try {
StackTraceElement[] stackTrace = e.getStackTrace();
String fullClassName = stackTrace[stackTrace.length - 1].getClassName();
Expand All @@ -131,47 +123,48 @@ public static void testing(String msg , Exception e , String nameOfObject){
String methodName = stackTrace[stackTrace.length - 1].getMethodName();
int lineNumber = stackTrace[stackTrace.length - 1].getLineNumber();
Log.i("Saiyed_Testing", "=> Msg : " + msg + " : nameOfObject : " + nameOfObject + " : " + fullClassName + "--" + className + "--" + methodName + "--" + lineNumber);
}
catch (Exception ex)
{
} catch (Exception ex) {

}
}
public static int CheckJsonFormat(String s){

public static int CheckJsonFormat(String s) {
try {
Object json = new JSONTokener(s).nextValue();
if (json instanceof JSONObject){
if (json instanceof JSONObject) {
return 0;
}
else if(json instanceof JSONArray){
} else if (json instanceof JSONArray) {
return 1;
}
}catch (Exception e){
testing("SupportMethods",e,"CheckJsonFormat");
} catch (Exception e) {
testing("SupportMethods", e, "CheckJsonFormat");
}
return -1;
}
public static int TotalArraysOfObj(String Json){

public static int TotalArraysOfObj(String Json) {
try {
JSONArray myArray = new JSONArray(Json);
return myArray.length();
}catch (Exception e){ testing("SupportMethods",e,"TotalArraysOfObj");
} catch (Exception e) {
testing("SupportMethods", e, "TotalArraysOfObj");
}
return -1;
}
public static void openPdf(Context context,String file){

public static void openPdf(Context context, String file) {
try {
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.fromFile(new File(extStorageFile, file + ".pdf"));
intent.setDataAndType(uri, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
context.startActivity(intent);
}
catch (Exception e){
testing("SupportMethods",e,"openPdf");
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.fromFile(new File(extStorageFile, file + ".pdf"));
intent.setDataAndType(uri, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
context.startActivity(intent);
} catch (Exception e) {
testing("SupportMethods", e, "openPdf");
}
}
public static void sendPdfViaEmail(Context context,String file,String subject , String emailBody ){

public static void sendPdfViaEmail(Context context, String file, String subject, String emailBody) {
try {
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, "");
Expand All @@ -182,12 +175,12 @@ public static void sendPdfViaEmail(Context context,String file,String subject ,
email.setType("application/pdf");
email.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(email);
}
catch (Exception e){
testing("SupportMethods",e,"sendPdfViaEmail");
} catch (Exception e) {
testing("SupportMethods", e, "sendPdfViaEmail");
}
}
public static void sendPngViaEmail(Context context, ImageView image){

public static void sendPngViaEmail(Context context, ImageView image) {
image.buildDrawingCache();
Bitmap bitmap = image.getDrawingCache();
OutputStream outStream = null;
Expand All @@ -208,14 +201,14 @@ public static void sendPngViaEmail(Context context, ImageView image){
sharingIntent.setType("image/png");
sharingIntent.putExtra(Intent.EXTRA_STREAM, uri);
context.startActivity(Intent.createChooser(sharingIntent, "Hello Sir"));
}
catch (Exception e){
testing("SupportMethods",e,"sendPngViaEmail");
} catch (Exception e) {
testing("SupportMethods", e, "sendPngViaEmail");
}
}
public static Bitmap highlightImage(float radiusBlurMaskFilter , Bitmap src) {

public static Bitmap highlightImage(float radiusBlurMaskFilter, Bitmap src) {
// create new bitmap, which will be painted and becomes result image
Bitmap bmOut = Bitmap.createBitmap(src.getWidth() , src.getHeight() , Bitmap.Config.ARGB_8888);
Bitmap bmOut = Bitmap.createBitmap(src.getWidth(), src.getHeight(), Bitmap.Config.ARGB_8888);
// setup canvas for painting
Canvas canvas = new Canvas(bmOut);
// setup default color
Expand All @@ -240,6 +233,7 @@ public static Bitmap highlightImage(float radiusBlurMaskFilter , Bitmap src) {
// return out final image
return bmOut;
}

public static boolean isEmailValid(String emailAddress) {
boolean isValid = false;

Expand All @@ -253,7 +247,8 @@ public static boolean isEmailValid(String emailAddress) {
}
return isValid;
}
public static void setLocale(Context base ,String language){

public static void setLocale(Context base, String language) {
Locale locale = new Locale(language);
Locale.setDefault(locale);
Configuration config = new Configuration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import de.bitshares_munich.fragments.BalancesFragment;
import de.bitshares_munich.smartcoinswallet.R;
import de.bitshares_munich.smartcoinswallet.eReceipt;
import de.bitsharesmunich.graphenej.TransferOperation;
import de.bitsharesmunich.graphenej.operations.TransferOperation;
import de.codecrafters.tableview.listeners.TableDataClickListener;

/**
Expand All @@ -39,7 +39,7 @@ public TableViewClickListener(Context _context) {
@Override
public void onDataClicked(int rowIndex, HistoricalTransferEntry historicalTransferEntry) {
Log.i(TAG, "onDataClicked: " + !BalancesFragment.onClicked);
if(!BalancesFragment.onClicked) {
if (!BalancesFragment.onClicked) {
TransferOperation operation = historicalTransferEntry.getHistoricalTransfer().getOperation();
BalancesFragment.onClicked = true;
long timestamp = historicalTransferEntry.getTimestamp() * 1000;
Expand All @@ -52,7 +52,7 @@ public void onDataClicked(int rowIndex, HistoricalTransferEntry historicalTransf
intent.putExtra("Memo", operation.getMemo().getPlaintextMessage());
intent.putExtra("Date", Helper.convertDateToGMT(new Date(timestamp), myContext));
intent.putExtra("Time", Helper.convertDateToGMTWithYear(new Date(timestamp), myContext));
intent.putExtra("TimeZone", Helper.convertTimeToGMT(new Date(timestamp),myContext));
intent.putExtra("TimeZone", Helper.convertTimeToGMT(new Date(timestamp), myContext));
intent.putExtra("To", operation.getTo().getAccountName());
intent.putExtra("From", operation.getFrom().getAccountName());
intent.putExtra("Sent", true);
Expand Down
Loading

0 comments on commit 5593847

Please sign in to comment.