Skip to content
This repository has been archived by the owner on Apr 26, 2022. It is now read-only.

Commit

Permalink
1.1 version
Browse files Browse the repository at this point in the history
  • Loading branch information
tkarakilic committed Jan 5, 2017
1 parent fefbce7 commit 55d7288
Show file tree
Hide file tree
Showing 11 changed files with 472 additions and 159 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.arastta"
minSdkVersion 15
targetSdkVersion 23
versionCode 9
versionName "1.0.9"
versionCode 10
versionName "1.1.0"
}
buildTypes {
release {
Expand Down
44 changes: 23 additions & 21 deletions app/src/main/java/com/arastta/CustomersActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,31 @@ public class CustomersActivity extends MasterActivity
static ArrayList<JSONObject> arrayList = new ArrayList<JSONObject>();
static ListView listView;

RelativeLayout TabLine1;
RelativeLayout TabLine2;
RelativeLayout TabLine3;
static RelativeLayout TabLine1;
static RelativeLayout TabLine2;
static RelativeLayout TabLine3;

TextView TabText1;
TextView TabText2;
TextView TabText3;
static TextView TabText1;
static TextView TabText2;
static TextView TabText3;

void resetAct()
static void resetAct()
{
arrayList.clear();
arrayList = new ArrayList<JSONObject>();
adapter = new CustomersAdapter(context,arrayList);
listView.setAdapter(adapter);
}

void resetTabs()
static void resetTabs(Context context)
{
TabLine1.setVisibility(RelativeLayout.INVISIBLE);
TabLine2.setVisibility(RelativeLayout.INVISIBLE);
TabLine3.setVisibility(RelativeLayout.INVISIBLE);

TabText1.setTextColor(getResources().getColor(R.color.colorHint));
TabText2.setTextColor(getResources().getColor(R.color.colorHint));
TabText3.setTextColor(getResources().getColor(R.color.colorHint));
TabText1.setTextColor(context.getResources().getColor(R.color.colorHint));
TabText2.setTextColor(context.getResources().getColor(R.color.colorHint));
TabText3.setTextColor(context.getResources().getColor(R.color.colorHint));

TabText1.setTypeface(ConstantsAndFunctions.getTypeFace(context,false));
TabText2.setTypeface(ConstantsAndFunctions.getTypeFace(context,false));
Expand Down Expand Up @@ -92,36 +92,36 @@ public void onCreate(Bundle savedInstanceState)
TabText1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
resetTabs();
resetTabs(context);
TabLine1.setVisibility(RelativeLayout.VISIBLE);
TabText1.setTextColor(getResources().getColor(R.color.colorPrimary));
TabText1.setTypeface(ConstantsAndFunctions.getTypeFace(context,true));
day = 1;
xCustomers("");
xCustomers("","","");
}
});

TabText2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
resetTabs();
resetTabs(context);
TabLine2.setVisibility(RelativeLayout.VISIBLE);
TabText2.setTextColor(getResources().getColor(R.color.colorPrimary));
TabText2.setTypeface(ConstantsAndFunctions.getTypeFace(context,true));
day = 30;
xCustomers("");
xCustomers("","","");
}
});

TabText3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
resetTabs();
resetTabs(context);
TabLine3.setVisibility(RelativeLayout.VISIBLE);
TabText3.setTextColor(getResources().getColor(R.color.colorPrimary));
TabText3.setTypeface(ConstantsAndFunctions.getTypeFace(context,true));
day = 365;
xCustomers("");
xCustomers("","","");
}
});

Expand All @@ -133,12 +133,14 @@ public void onClick(View v) {
listView.setHeaderDividersEnabled(false);

day = 1;
xCustomers("");
xCustomers("","","");
}

public static void xCustomers(String text)
public static void xCustomers(String text, String sd, String fd)
{
new getCustomers().execute(text);
if(sd.equals(""))sd = ConstantsAndFunctions.getFromDate(day);
if(fd.equals(""))fd = ConstantsAndFunctions.getTodayDate();
new getCustomers().execute(text,sd,fd);
}

public static class getCustomers extends AsyncTask<String, Void, String>
Expand All @@ -158,7 +160,7 @@ protected void onPreExecute()
@Override
protected String doInBackground(String... params)
{
ResultText = ConstantsAndFunctions.getHtml(username,password,url,"customers"+"?date_from="+ConstantsAndFunctions.getFromDate(day)+"&date_to="+ConstantsAndFunctions.getTodayDate()+params[0]);//stats?date_from=2016-04-01&date_to=2016-09-07
ResultText = ConstantsAndFunctions.getHtml(username,password,url,"customers"+"?date_from="+params[1]+"&date_to="+params[2]+params[0]);//stats?date_from=2016-04-01&date_to=2016-09-07

return ResultText;
}
Expand Down
95 changes: 45 additions & 50 deletions app/src/main/java/com/arastta/DashboardActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
Expand All @@ -12,9 +11,6 @@
import android.widget.TextView;
import android.widget.Toast;

import com.arastta.GraphLib.Line;
import com.arastta.GraphLib.LineGraph;
import com.arastta.GraphLib.LinePoint;
import com.jjoe64.graphview.GraphView;
import com.jjoe64.graphview.series.DataPoint;
import com.jjoe64.graphview.series.LineGraphSeries;
Expand All @@ -24,44 +20,37 @@
import org.json.JSONObject;
import org.json.JSONTokener;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.StringTokenizer;

public class DashboardActivity extends MasterActivity
{
Context context;
String ScreenName = "";
static Context context;
static String ScreenName = "";

boolean Working = false;
int day = 1;
static boolean Working = false;
static int day = 1;

TextView ValueSales;
TextView ValueOrders;
TextView ValueCustomers;
TextView ValueProducts;
static TextView ValueSales;
static TextView ValueOrders;
static TextView ValueCustomers;
static TextView ValueProducts;

TextView DashboardDetailValue1;
TextView DashboardDetailValue2;
TextView DashboardDetailValue3;
TextView DashboardDetailValue4;
static TextView DashboardDetailValue1;
static TextView DashboardDetailValue2;
static TextView DashboardDetailValue3;
static TextView DashboardDetailValue4;

RelativeLayout TabLine1;
RelativeLayout TabLine2;
RelativeLayout TabLine3;
static RelativeLayout TabLine1;
static RelativeLayout TabLine2;
static RelativeLayout TabLine3;

TextView TabText1;
TextView TabText2;
TextView TabText3;
static TextView TabText1;
static TextView TabText2;
static TextView TabText3;

LineGraph li;
GraphView graphView;
static GraphView graphView;

void resetAct()
static void resetAct()
{
ValueSales.setText("0");
ValueOrders.setText("0");
Expand All @@ -74,15 +63,15 @@ void resetAct()
DashboardDetailValue4.setText("0");
}

void resetTabs()
static void resetTabs(Context context)
{
TabLine1.setVisibility(RelativeLayout.INVISIBLE);
TabLine2.setVisibility(RelativeLayout.INVISIBLE);
TabLine3.setVisibility(RelativeLayout.INVISIBLE);

TabText1.setTextColor(getResources().getColor(R.color.colorHint));
TabText2.setTextColor(getResources().getColor(R.color.colorHint));
TabText3.setTextColor(getResources().getColor(R.color.colorHint));
TabText1.setTextColor(context.getResources().getColor(R.color.colorHint));
TabText2.setTextColor(context.getResources().getColor(R.color.colorHint));
TabText3.setTextColor(context.getResources().getColor(R.color.colorHint));

TabText1.setTypeface(ConstantsAndFunctions.getTypeFace(context,false));
TabText2.setTypeface(ConstantsAndFunctions.getTypeFace(context,false));
Expand All @@ -105,7 +94,6 @@ public void onCreate(Bundle savedInstanceState)
context = DashboardActivity.this;
ScreenName = "DashboardActivity";

li = (LineGraph)findViewById(R.id.linegraph);
graphView = (GraphView) findViewById(R.id.graphView);


Expand Down Expand Up @@ -143,36 +131,36 @@ public void onCreate(Bundle savedInstanceState)
TabText1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
resetTabs();
resetTabs(context);
TabLine1.setVisibility(RelativeLayout.VISIBLE);
TabText1.setTextColor(getResources().getColor(R.color.colorPrimary));
TabText1.setTypeface(ConstantsAndFunctions.getTypeFace(context,true));
day = 1;
new getDashboard().execute();
xDashboard("","");
}
});

TabText2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
resetTabs();
resetTabs(context);
TabLine2.setVisibility(RelativeLayout.VISIBLE);
TabText2.setTextColor(getResources().getColor(R.color.colorPrimary));
TabText2.setTypeface(ConstantsAndFunctions.getTypeFace(context,true));
day = 30;
new getDashboard().execute();
xDashboard("","");
}
});

TabText3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
resetTabs();
resetTabs(context);
TabLine3.setVisibility(RelativeLayout.VISIBLE);
TabText3.setTextColor(getResources().getColor(R.color.colorPrimary));
TabText3.setTypeface(ConstantsAndFunctions.getTypeFace(context,true));
day = 365;
new getDashboard().execute();
xDashboard("","");
}
});

Expand Down Expand Up @@ -237,10 +225,17 @@ public void onClick(View v)
});

day = 1;
new getDashboard().execute();
xDashboard("","");
}

private class getDashboard extends AsyncTask<String, Void, String>
public static void xDashboard (String sd, String fd)
{
if(sd.equals(""))sd = ConstantsAndFunctions.getFromDate(day);
if(fd.equals(""))fd = ConstantsAndFunctions.getTodayDate();
new getDashboard().execute(sd,fd);
}

private static class getDashboard extends AsyncTask<String, Void, String>
{
String ResultText = "";

Expand All @@ -257,7 +252,7 @@ protected void onPreExecute()
@Override
protected String doInBackground(String... params)
{
ResultText = ConstantsAndFunctions.getHtml(username,password,url,"stats"+"?date_from="+ConstantsAndFunctions.getFromDate(day)+"&date_to="+ConstantsAndFunctions.getTodayDate());//stats?date_from=2016-04-01&date_to=2016-09-07
ResultText = ConstantsAndFunctions.getHtml(username,password,url,"stats"+"?date_from="+params[0]+"&date_to="+params[1]);//stats?date_from=2016-04-01&date_to=2016-09-07

return ResultText;
}
Expand All @@ -273,7 +268,7 @@ protected void onPostExecute(String result)

if(ResultText.equals("error"))
{
Toast.makeText(context, getResources().getString(R.string.connection_failed), Toast.LENGTH_SHORT).show();
Toast.makeText(context, context.getResources().getString(R.string.connection_failed), Toast.LENGTH_SHORT).show();
}
else
{
Expand Down Expand Up @@ -329,7 +324,7 @@ protected void onPostExecute(String result)


LineGraphSeries<DataPoint> series = new LineGraphSeries<DataPoint>();
series.setColor(getResources().getColor(R.color.colorPrimary));
series.setColor(context.getResources().getColor(R.color.colorPrimary));
try
{
if (prices.size() > 0)
Expand All @@ -348,9 +343,9 @@ protected void onPostExecute(String result)
graphView.getViewport().setXAxisBoundsManual(true);
graphView.getViewport().setMinX(0);
graphView.getViewport().setMaxX(daily.length());
graphView.getGridLabelRenderer().setGridColor(getResources().getColor(R.color.colorAccent));
graphView.getGridLabelRenderer().setVerticalLabelsColor(getResources().getColor(R.color.colorAccent));
graphView.getGridLabelRenderer().setHorizontalLabelsColor(getResources().getColor(R.color.colorAccent));
graphView.getGridLabelRenderer().setGridColor(context.getResources().getColor(R.color.colorAccent));
graphView.getGridLabelRenderer().setVerticalLabelsColor(context.getResources().getColor(R.color.colorAccent));
graphView.getGridLabelRenderer().setHorizontalLabelsColor(context.getResources().getColor(R.color.colorAccent));
graphView.removeAllSeries();
graphView.addSeries(series);

Expand Down
Loading

0 comments on commit 55d7288

Please sign in to comment.