use of android.view.ViewGroup.LayoutParams in project Anki-Android by Ramblurr.
the class StudyOptionsFragment method updateChart.
private void updateChart(double[][] serieslist) {
if (mSmallChart != null) {
Resources res = getResources();
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
XYSeriesRenderer r = new XYSeriesRenderer();
r.setColor(res.getColor(R.color.stats_young));
renderer.addSeriesRenderer(r);
r = new XYSeriesRenderer();
r.setColor(res.getColor(R.color.stats_mature));
renderer.addSeriesRenderer(r);
for (int i = 1; i < serieslist.length; i++) {
XYSeries series = new XYSeries("");
for (int j = 0; j < serieslist[i].length; j++) {
series.add(serieslist[0][j], serieslist[i][j]);
}
dataset.addSeries(series);
}
renderer.setBarSpacing(0.4);
renderer.setShowLegend(false);
renderer.setLabelsTextSize(13);
renderer.setXAxisMin(-0.5);
renderer.setXAxisMax(7.5);
renderer.setYAxisMin(0);
renderer.setGridColor(Color.LTGRAY);
renderer.setShowGrid(true);
renderer.setBackgroundColor(Color.WHITE);
renderer.setMarginsColor(Color.WHITE);
renderer.setAxesColor(Color.BLACK);
renderer.setLabelsColor(Color.BLACK);
renderer.setYLabelsColor(0, Color.BLACK);
renderer.setYLabelsAngle(-90);
renderer.setXLabelsColor(Color.BLACK);
renderer.setXLabelsAlign(Align.CENTER);
renderer.setYLabelsAlign(Align.CENTER);
renderer.setZoomEnabled(false, false);
// mRenderer.setMargins(new int[] { 15, 48, 30, 10 });
renderer.setAntialiasing(true);
renderer.setPanEnabled(true, false);
GraphicalView chartView = ChartFactory.getBarChartView(getActivity(), dataset, renderer, BarChart.Type.STACKED);
mSmallChart.addView(chartView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
if (mDeckChart.getVisibility() == View.INVISIBLE) {
mDeckChart.setVisibility(View.VISIBLE);
mDeckChart.setAnimation(ViewAnimation.fade(ViewAnimation.FADE_IN, 500, 0));
}
}
}
use of android.view.ViewGroup.LayoutParams in project Anki-Android by Ramblurr.
the class ChartBuilder method onCreate.
// public void setRenderer(int type, int row) {
// Resources res = getResources();
// XYSeriesRenderer renderer = new XYSeriesRenderer();
// if (type <= 2) {
// switch (row) {
// case 0:
// renderer.setColor(res.getColor(R.color.statistics_due_young_cards));
// break;
// case 1:
// renderer.setColor(res.getColor(R.color.statistics_due_mature_cards));
// break;
// case 2:
// // renderer.setColor(res.getColor(R.color.statistics_due_failed_cards));
// break;
// }
// } else if (type == 3) {
// switch (row) {
// case 0:
// // renderer.setColor(res.getColor(R.color.statistics_reps_new_cards));
// break;
// case 1:
// renderer.setColor(res.getColor(R.color.statistics_reps_young_cards));
// break;
// case 2:
// renderer.setColor(res.getColor(R.color.statistics_reps_mature_cards));
// break;
// }
// } else {
// renderer.setColor(res.getColor(R.color.statistics_default));
// }
// mRenderer.addSeriesRenderer(renderer);
// }
@Override
protected void onCreate(Bundle savedInstanceState) {
Log.i(AnkiDroidApp.TAG, "ChartBuilder.OnCreate");
Themes.applyTheme(this);
super.onCreate(savedInstanceState);
restorePreferences();
Resources res = getResources();
Stats stats = Stats.currentStats();
if (stats != null) {
mSeriesList = stats.getSeriesList();
mMeta = stats.getMetaInfo();
} else if (savedInstanceState != null) {
int len = savedInstanceState.getInt("seriesListLen");
mSeriesList = new double[len][];
for (int i = 0; i < len; i++) {
mSeriesList[i] = (double[]) savedInstanceState.getSerializable("seriesList" + i);
}
mMeta = (Object[]) savedInstanceState.getSerializable("meta");
} else {
finish();
}
String title = res.getString((Integer) mMeta[1]);
boolean backwards = (Boolean) mMeta[2];
int[] valueLabels = (int[]) mMeta[3];
int[] barColors = (int[]) mMeta[4];
int[] axisTitles = (int[]) mMeta[5];
String subTitle = (String) mMeta[6];
if (mSeriesList == null || mSeriesList[0].length < 2) {
Log.i(AnkiDroidApp.TAG, "ChartBuilder - Data variable empty, closing chartbuilder");
finish();
return;
}
if (mFullScreen) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
}
View mainView = getLayoutInflater().inflate(R.layout.statistics, null);
setContentView(mainView);
mainView.setBackgroundColor(Color.WHITE);
mTitle = (TextView) findViewById(R.id.statistics_title);
if (mChartView == null) {
if (mFullScreen) {
mTitle.setText(title);
mTitle.setTextColor(Color.BLACK);
} else {
setTitle(title);
AnkiDroidApp.getCompat().setSubtitle(this, subTitle);
mTitle.setVisibility(View.GONE);
}
for (int i = 1; i < mSeriesList.length; i++) {
XYSeries series = new XYSeries(res.getString(valueLabels[i - 1]));
for (int j = 0; j < mSeriesList[i].length; j++) {
series.add(mSeriesList[0][j], mSeriesList[i][j]);
}
mDataset.addSeries(series);
XYSeriesRenderer renderer = new XYSeriesRenderer();
renderer.setColor(res.getColor(barColors[i - 1]));
mRenderer.addSeriesRenderer(renderer);
}
if (mSeriesList.length == 1) {
mRenderer.setShowLegend(false);
}
if (backwards) {
mPan = new double[] { mSeriesList[0][0] - 0.5, 0.5 };
} else {
mPan = new double[] { -0.5, mSeriesList[0][mSeriesList[0].length - 1] + 0.5 };
}
mRenderer.setLegendTextSize(17);
mRenderer.setBarSpacing(0.4);
mRenderer.setLegendHeight(60);
mRenderer.setAxisTitleTextSize(17);
mRenderer.setLabelsTextSize(17);
mRenderer.setXAxisMin(mPan[0]);
mRenderer.setXAxisMax(mPan[1]);
mRenderer.setYAxisMin(0);
mRenderer.setGridColor(Color.LTGRAY);
mRenderer.setShowGrid(true);
mRenderer.setXTitle(res.getStringArray(R.array.due_x_axis_title)[axisTitles[0]]);
mRenderer.setYTitle(res.getString(axisTitles[1]));
mRenderer.setBackgroundColor(Color.WHITE);
mRenderer.setMarginsColor(Color.WHITE);
mRenderer.setAxesColor(Color.BLACK);
mRenderer.setLabelsColor(Color.BLACK);
mRenderer.setYLabelsColor(0, Color.BLACK);
mRenderer.setYLabelsAngle(-90);
mRenderer.setXLabelsColor(Color.BLACK);
mRenderer.setXLabelsAlign(Align.CENTER);
mRenderer.setYLabelsAlign(Align.CENTER);
mRenderer.setZoomEnabled(false, false);
mRenderer.setMargins(new int[] { 15, 48, 30, 10 });
mRenderer.setAntialiasing(true);
mRenderer.setPanEnabled(true, false);
mRenderer.setPanLimits(mPan);
mChartView = ChartFactory.getBarChartView(this, mDataset, mRenderer, BarChart.Type.STACKED);
LinearLayout layout = (LinearLayout) findViewById(R.id.chart);
layout.addView(mChartView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
} else {
mChartView.repaint();
}
gestureDetector = new GestureDetector(new MyGestureDetector());
mChartView.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (gestureDetector.onTouchEvent(event)) {
return true;
}
return false;
}
});
}
use of android.view.ViewGroup.LayoutParams in project Anki-Android by Ramblurr.
the class StyledProgressDialog method show.
public static StyledProgressDialog show(Context context, CharSequence title, CharSequence message, boolean indeterminable, boolean cancelable, DialogInterface.OnCancelListener cancelListener) {
final StyledProgressDialog dialog = new StyledProgressDialog(context);
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.styled_progress_dialog, null);
dialog.addContentView(layout, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
// set title
if (title != null && title.length() > 0) {
((TextView) layout.findViewById(R.id.alertTitle)).setText(title);
// if (icon != 0) {
// ((ImageView) layout.findViewById(R.id.icon)).setImageResource(icon);
// } else {
// layout.findViewById(R.id.icon).setVisibility(View.GONE);
// }
} else {
layout.findViewById(R.id.topPanel).setVisibility(View.GONE);
layout.findViewById(R.id.titleDivider).setVisibility(View.GONE);
}
// set the message
if (message != null) {
TextView tv = (TextView) layout.findViewById(R.id.message);
tv.setText(message);
// if (messageSize != 0) {
// tv.setTextSize(messageSize * context.getResources().getDisplayMetrics().scaledDensity);
// }
}
// set background
try {
Themes.setStyledProgressDialogDialogBackgrounds(layout);
} catch (OutOfMemoryError e) {
Log.e(AnkiDroidApp.TAG, "StyledDialog - Dialog could not be created: " + e);
Themes.showThemedToast(context, context.getResources().getString(R.string.error_insufficient_memory), false);
return null;
}
dialog.setContentView(layout);
dialog.setCancelable(cancelable);
dialog.setOnCancelListener(cancelListener);
if (animationEnabled(context)) {
dialog.show();
}
return dialog;
}
use of android.view.ViewGroup.LayoutParams in project android_frameworks_base by ParanoidAndroid.
the class Activity method dispatchPopulateAccessibilityEvent.
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
event.setClassName(getClass().getName());
event.setPackageName(getPackageName());
LayoutParams params = getWindow().getAttributes();
boolean isFullScreen = (params.width == LayoutParams.MATCH_PARENT) && (params.height == LayoutParams.MATCH_PARENT);
event.setFullScreen(isFullScreen);
CharSequence title = getTitle();
if (!TextUtils.isEmpty(title)) {
event.getText().add(title);
}
return true;
}
use of android.view.ViewGroup.LayoutParams in project android_frameworks_base by ParanoidAndroid.
the class Dialog method dispatchPopulateAccessibilityEvent.
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
event.setClassName(getClass().getName());
event.setPackageName(mContext.getPackageName());
LayoutParams params = getWindow().getAttributes();
boolean isFullScreen = (params.width == LayoutParams.MATCH_PARENT) && (params.height == LayoutParams.MATCH_PARENT);
event.setFullScreen(isFullScreen);
return false;
}
Aggregations