use of it.angelic.mpw.model.MyDateTypeAdapter in project MPW by shineangelic.
the class WalletActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_wallet);
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
minerAddr = pref.getString("wallet_addr", null);
final PoolDbHelper mDbHelper = new PoolDbHelper(this, mPool, mCur);
builder = new GsonBuilder();
builder.registerTypeAdapter(Date.class, new MyDateTypeAdapter());
builder.registerTypeAdapter(Calendar.class, new MyTimeStampTypeAdapter());
hashRateChartTitleText = findViewById(R.id.hashrateText);
walletTitleText = findViewById(R.id.textViewWalletTitle);
walletValueText = findViewById(R.id.textViewWalletValue);
walCurHashrateText = findViewById(R.id.textViewWalCurHashrateValue);
walCurHashrate3HText = findViewById(R.id.textViewWalHashrate3hValue);
walTotSharesText = findViewById(R.id.textViewWalSharesValue);
walOnlineWorkersText = findViewById(R.id.textViewWalOnlineMinersValue);
lineView = findViewById(R.id.line_view_onlineminers);
lineViewRate = findViewById(R.id.line_view_hrate);
textViewWalPaymentsValue = findViewById(R.id.textViewWalPaymentsValue);
textViewWalLastShareValue = findViewById(R.id.textViewWalLastShareValue);
textViewWalLastShare = findViewById(R.id.textViewWalLastShare);
textViewWalRoundSharesPercValue = findViewById(R.id.textViewWalRoundSharesPercValue);
textViewPendingBalanceValue = findViewById(R.id.textViewPendingBalanceValue);
textViewAvgPending = findViewById(R.id.textViewAvgPendingValue);
textViewPaidValue = findViewById(R.id.textViewPaidValue);
fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Async Refresh Sent", Snackbar.LENGTH_LONG).setAction("Action", null).show();
issueRefresh(mDbHelper, builder, Utils.getWalletStatsUrl(PreferenceManager.getDefaultSharedPreferences(WalletActivity.this)) + minerAddr);
}
});
// i grafici hanno controlli globali
RadioGroup radioGroupChartGranularity = findViewById(R.id.radioDifficultyGranularity);
radioGroupBackTo = findViewById(R.id.radioBackto);
RadioGroup.OnCheckedChangeListener mescola = new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
new UpdateUIAsynchTask().execute();
}
};
radioGroupBackTo.setOnCheckedChangeListener(mescola);
radioGroupChartGranularity.setOnCheckedChangeListener(mescola);
NavigationView navigationView = findViewById(R.id.navigation_view);
navigationView.setNavigationItemSelectedListener(this);
// ADS
AdView mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
}
use of it.angelic.mpw.model.MyDateTypeAdapter in project MPW by shineangelic.
the class NoobPoolInstrumentedTest method testJsonRequest.
@Test
public void testJsonRequest() throws Exception {
final GsonBuilder builder = new GsonBuilder();
// gestione UNIX time lungo e non
builder.registerTypeAdapter(Date.class, new MyDateTypeAdapter());
builder.registerTypeAdapter(Calendar.class, new MyTimeStampTypeAdapter());
JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET, Utils.getHomeStatsURL(sharedPreferences), null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(final JSONObject response) {
Log.d(Constants.TAG, response.toString());
Gson gson = builder.create();
// Register an adapter to manage the date types as long values
HomeStats retrieved = gson.fromJson(response.toString(), HomeStats.class);
assertNotNull(retrieved);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d(Constants.TAG, "Error: " + error.getMessage());
fail();
// hide the progress dialog
}
});
// Adding request to request queue
JSONClientSingleton.getInstance(InstrumentationRegistry.getTargetContext()).addToRequestQueue(jsonObjReq);
}
use of it.angelic.mpw.model.MyDateTypeAdapter in project MPW by shineangelic.
the class MaxHashInstrumentedTest method testJsonRequest.
@Test
public void testJsonRequest() throws Exception {
final GsonBuilder builder = new GsonBuilder();
// gestione UNIX time lungo e non
builder.registerTypeAdapter(Date.class, new MyDateTypeAdapter());
builder.registerTypeAdapter(Calendar.class, new MyTimeStampTypeAdapter());
JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET, Utils.getHomeStatsURL(sharedPreferences), null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(final JSONObject response) {
Log.d(Constants.TAG, response.toString());
Gson gson = builder.create();
// Register an adapter to manage the date types as long values
HomeStats retrieved = gson.fromJson(response.toString(), HomeStats.class);
assertNotNull(retrieved);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d(Constants.TAG, "Error: " + error.getMessage());
fail();
// hide the progress dialog
}
});
// Adding request to request queue
JSONClientSingleton.getInstance(InstrumentationRegistry.getTargetContext()).addToRequestQueue(jsonObjReq);
}
use of it.angelic.mpw.model.MyDateTypeAdapter in project MPW by shineangelic.
the class BlocksActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_blocks);
mDbHelper = new PoolDbHelper(this, mPool, mCur);
textViewBlocksTitle = findViewById(R.id.textViewBlocksTitle);
textViewMaxBlockTimeValue = findViewById(R.id.textViewMaxBlockTimeValue);
textViewMinBlockTimeValue = findViewById(R.id.textViewMostPaidMinerValue);
textViewMeanBlockTimeValue = findViewById(R.id.textViewMeanBlockTimeValue);
textViewBlockTimeStdDevValue = findViewById(R.id.textViewBlockTimeStdDevValue);
textViewBlocksPerDayValue = findViewById(R.id.textViewBlocksPerDayValue);
GsonBuilder builder = new GsonBuilder();
mRecyclerView = findViewById(R.id.blocks_recycler_view);
// use this setting to improve performance if you know that changes
// in content do not change the layout size of the RecyclerView
mRecyclerView.setHasFixedSize(true);
LinearLayoutManager mLayoutManager = new GridLayoutManager(this, getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 2 : 1);
mRecyclerView.setLayoutManager(mLayoutManager);
// gestione UNIX time lungo e non
builder.registerTypeAdapter(Date.class, new MyDateTypeAdapter());
builder.registerTypeAdapter(Calendar.class, new MyTimeStampTypeAdapter());
issueRefresh(builder);
}
use of it.angelic.mpw.model.MyDateTypeAdapter in project MPW by shineangelic.
the class MainActivity method onCreate.
/* private static long getAverageBlockSecondsSincePoolsBirth(HomeStats lastHit) {
final Date firstBlockDate = new Date();//2017/07/15
firstBlockDate.setTime(1500099900000L);
long datediffFirst = (new Date().getTime() - firstBlockDate.getTime()) / 1000;
//meno uno perche` il conto parte dal secondo blocco. Il primo boh
return datediffFirst / (lastHit.getMaturedTotal() - 1);
}*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Locale current = getResources().getConfiguration().locale;
mDbHelper = new PoolDbHelper(this, mPool, mCur);
builder = new GsonBuilder();
// gestione UNIX time lungo e non
builder.registerTypeAdapter(Date.class, new MyDateTypeAdapter());
builder.registerTypeAdapter(Calendar.class, new MyTimeStampTypeAdapter());
noobText = findViewById(R.id.textViewWalletTitle);
hashText = findViewById(R.id.hashrateText);
textViewNetDiffTitle = findViewById(R.id.textViewWalHashrateTitle);
poolLastBeat = findViewById(R.id.textViewWalLastShareValue);
textViewNetDiffValue = findViewById(R.id.textViewNetDiffValue);
lastFoundTextLabel = findViewById(R.id.textViewLastBlock);
lastFoundText = findViewById(R.id.textViewWalPaymentsValue);
onlineMinersText = findViewById(R.id.textViewWalCurHashrateValue);
textViewBlockChainHeightValue = findViewById(R.id.textViewBlockChainHeightValue);
poolHashrateText = findViewById(R.id.textViewPoolHashrateValue);
roundSharesText = findViewById(R.id.textViewRoundSharesValue);
textViewVarianceValue = findViewById(R.id.textViewVarianceValue);
FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Async Refresh Sent", Snackbar.LENGTH_SHORT).setAction("Action", null).show();
issueRefresh(mDbHelper, builder);
}
});
// i grafici hanno controlli globali
RadioGroup radioGroupChartGranularity = findViewById(R.id.radioDifficultyGranularity);
radioGroupBackTo = findViewById(R.id.radioBackto);
final RadioButton radioDay = findViewById(R.id.radioButtonDay);
final RadioButton radioMin = findViewById(R.id.radioButtonMinutes);
final RadioGroup.OnCheckedChangeListener mescola = new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
radioGroupBackTo.post(new Runnable() {
@Override
public void run() {
GranularityEnum granoEnum = GranularityEnum.HOUR;
if (radioDay.isChecked())
granoEnum = GranularityEnum.DAY;
else if (radioMin.isChecked())
granoEnum = GranularityEnum.MINUTE;
int radioButtonID = radioGroupBackTo.getCheckedRadioButtonId();
View radioButton = findViewById(radioButtonID);
LinkedMap<Date, HomeStats> storia = mDbHelper.getHistoryData(BackToEnum.valueOf((String) radioButton.getTag()));
ChartUtils.drawDifficultyHistory(textViewNetDiffTitle, PoolQueryGrouper.groupAvgQueryResult(storia, granoEnum), (LineView) findViewById(R.id.line_view_difficulty), granoEnum);
ChartUtils.drawHashrateHistory(hashText, PoolQueryGrouper.groupAvgQueryResult(storia, granoEnum), (LineView) findViewById(R.id.line_view_hashrate), granoEnum);
}
});
}
};
radioGroupBackTo.setOnCheckedChangeListener(mescola);
radioGroupChartGranularity.setOnCheckedChangeListener(mescola);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
DrawerLayout drawer = findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(this));
Job myJob = MPWCoinmarketcapService.getJobUpdate(dispatcher);
dispatcher.schedule(myJob);
// ADS
AdView mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
}
Aggregations