Skip to content

Commit fca3cf8

Browse files
committed
[demo] Fixed redundant type cast warnings
1 parent 59a3e2c commit fca3cf8

File tree

8 files changed

+35
-46
lines changed

8 files changed

+35
-46
lines changed

demo/src/main/java/com/mta/tehreer/demo/BidiAlgorithmActivity.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2016 Muhammad Tayyab Akram
2+
* Copyright (C) 2016-2018 Muhammad Tayyab Akram
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,7 +27,6 @@
2727
import android.widget.Toast;
2828

2929
public class BidiAlgorithmActivity extends AppCompatActivity {
30-
3130
private EditText mBidiEditText;
3231

3332
@Override
@@ -40,7 +39,7 @@ protected void onCreate(Bundle savedInstanceState) {
4039
actionBar.setDisplayHomeAsUpEnabled(true);
4140
}
4241

43-
mBidiEditText = (EditText) findViewById(R.id.bidi_edit_text);
42+
mBidiEditText = findViewById(R.id.bidi_edit_text);
4443
mBidiEditText.setSelection(mBidiEditText.getText().length());
4544
}
4645

demo/src/main/java/com/mta/tehreer/demo/BidiInfoActivity.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017 Muhammad Tayyab Akram
2+
* Copyright (C) 2016-2018 Muhammad Tayyab Akram
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -40,7 +40,6 @@
4040
import com.mta.tehreer.unicode.BidiRun;
4141

4242
public class BidiInfoActivity extends AppCompatActivity {
43-
4443
public static final String BIDI_TEXT = "bidi_text";
4544

4645
private static final char LRI = '\u2066';
@@ -67,7 +66,7 @@ protected void onCreate(Bundle savedInstanceState) {
6766
SpannableStringBuilder builder = new SpannableStringBuilder();
6867
writeBidiText(builder);
6968

70-
TextView bidiTextView = (TextView) findViewById(R.id.text_view_bidi);
69+
TextView bidiTextView = findViewById(R.id.text_view_bidi);
7170
bidiTextView.setMovementMethod(ScrollingMovementMethod.getInstance());
7271
bidiTextView.setText(builder);
7372
}

demo/src/main/java/com/mta/tehreer/demo/MainActivity.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017 Muhammad Tayyab Akram
2+
* Copyright (C) 2016-2018 Muhammad Tayyab Akram
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,7 +29,7 @@ protected void onCreate(Bundle savedInstanceState) {
2929
super.onCreate(savedInstanceState);
3030
setContentView(R.layout.activity_main);
3131

32-
Button bidiAlgorithmButton = (Button) findViewById(R.id.button_bidi_algorithm);
32+
Button bidiAlgorithmButton = findViewById(R.id.button_bidi_algorithm);
3333
bidiAlgorithmButton.setOnClickListener(new View.OnClickListener() {
3434
@Override
3535
public void onClick(View view) {
@@ -38,7 +38,7 @@ public void onClick(View view) {
3838
}
3939
});
4040

41-
Button typefaceInfoButton = (Button) findViewById(R.id.button_typeface_info);
41+
Button typefaceInfoButton = findViewById(R.id.button_typeface_info);
4242
typefaceInfoButton.setOnClickListener(new View.OnClickListener() {
4343
@Override
4444
public void onClick(View view) {
@@ -47,7 +47,7 @@ public void onClick(View view) {
4747
}
4848
});
4949

50-
Button typefaceGlyphsButton = (Button) findViewById(R.id.button_typeface_glyphs);
50+
Button typefaceGlyphsButton = findViewById(R.id.button_typeface_glyphs);
5151
typefaceGlyphsButton.setOnClickListener(new View.OnClickListener() {
5252
@Override
5353
public void onClick(View view) {
@@ -56,7 +56,7 @@ public void onClick(View view) {
5656
}
5757
});
5858

59-
Button opentypeShapingButton = (Button) findViewById(R.id.button_opentype_shaping);
59+
Button opentypeShapingButton = findViewById(R.id.button_opentype_shaping);
6060
opentypeShapingButton.setOnClickListener(new View.OnClickListener() {
6161
@Override
6262
public void onClick(View view) {
@@ -65,7 +65,7 @@ public void onClick(View view) {
6565
}
6666
});
6767

68-
Button labelWidgetButton = (Button) findViewById(R.id.button_label_widget);
68+
Button labelWidgetButton = findViewById(R.id.button_label_widget);
6969
labelWidgetButton.setOnClickListener(new View.OnClickListener() {
7070
@Override
7171
public void onClick(View view) {
@@ -74,7 +74,7 @@ public void onClick(View view) {
7474
}
7575
});
7676

77-
Button openSourceLicensesButton = (Button) findViewById(R.id.button_open_source_licenses);
77+
Button openSourceLicensesButton = findViewById(R.id.button_open_source_licenses);
7878
openSourceLicensesButton.setOnClickListener(new View.OnClickListener() {
7979
@Override
8080
public void onClick(View view) {

demo/src/main/java/com/mta/tehreer/demo/OpenSourceLicensesActivity.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017 Muhammad Tayyab Akram
2+
* Copyright (C) 2017-2018 Muhammad Tayyab Akram
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,12 +33,12 @@ protected void onCreate(Bundle savedInstanceState) {
3333
actionBar.setDisplayHomeAsUpEnabled(true);
3434
}
3535

36-
WebView licensesView = (WebView) findViewById(R.id.web_view_licenses);
36+
WebView licensesView = findViewById(R.id.web_view_licenses);
3737
licensesView.loadUrl("file:///android_asset/OpenSourceLicenses.html");
3838
}
3939

4040
@Override
41-
public boolean onSupportNavigateUp(){
41+
public boolean onSupportNavigateUp() {
4242
onBackPressed();
4343
return true;
4444
}

demo/src/main/java/com/mta/tehreer/demo/OpenTypeInfoActivity.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,35 +58,32 @@ private static class ClusterHolder {
5858
final ViewGroup glyphDetail;
5959

6060
ClusterHolder(View layout) {
61-
charDetail = (ViewGroup) layout.findViewById(R.id.layout_char_detail);
62-
glyphDetail = (ViewGroup) layout.findViewById(R.id.layout_glyph_detail);
61+
charDetail = layout.findViewById(R.id.layout_char_detail);
62+
glyphDetail = layout.findViewById(R.id.layout_glyph_detail);
6363
}
6464
}
6565

6666
private static class CharHolder {
67-
6867
final TextView character;
6968

7069
CharHolder(View layout) {
71-
character = (TextView) layout.findViewById(R.id.text_view_character);
70+
character = layout.findViewById(R.id.text_view_character);
7271
}
7372
}
7473

7574
private static class GlyphHolder {
76-
7775
final TextView glyphId;
7876
final TextView offset;
7977
final TextView advance;
8078

8179
GlyphHolder(View layout) {
82-
glyphId = (TextView) layout.findViewById(R.id.text_view_glyph_id);
83-
offset = (TextView) layout.findViewById(R.id.text_view_offset);
84-
advance = (TextView) layout.findViewById(R.id.text_view_advance);
80+
glyphId = layout.findViewById(R.id.text_view_glyph_id);
81+
offset = layout.findViewById(R.id.text_view_offset);
82+
advance = layout.findViewById(R.id.text_view_advance);
8583
}
8684
}
8785

8886
private static class GlyphSpan extends ReplacementSpan {
89-
9087
static final PointList OFFSET = PointList.of(new float[] { 0, 0 });
9188
static final FloatList ADVANCE = FloatList.of(new float[] { 0 });
9289
static final int PADDING = 4;
@@ -324,7 +321,7 @@ protected void onCreate(Bundle savedInstanceState) {
324321
}
325322
initials[++cluster] = length;
326323

327-
ListView infoListView = (ListView) findViewById(R.id.list_view_info);
324+
ListView infoListView = findViewById(R.id.list_view_info);
328325
infoListView.setAdapter(new ClusterAdapter(this, renderer, sourceText, shapingResult,
329326
IntList.of(initials).subList(0, cluster + 1)));
330327
}

demo/src/main/java/com/mta/tehreer/demo/OpenTypeShapingActivity.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import com.mta.tehreer.sfnt.SfntTag;
3434

3535
public class OpenTypeShapingActivity extends AppCompatActivity {
36-
3736
private EditText mTypeSizeField;
3837
private EditText mScriptTagField;
3938
private EditText mLanguageTagField;
@@ -50,7 +49,7 @@ protected void onCreate(Bundle savedInstanceState) {
5049
actionBar.setDisplayHomeAsUpEnabled(true);
5150
}
5251

53-
Spinner typefaceSpinner = (Spinner) findViewById(R.id.spinner_typeface);
52+
Spinner typefaceSpinner = findViewById(R.id.spinner_typeface);
5453
typefaceSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
5554

5655
@Override
@@ -65,10 +64,10 @@ public void onNothingSelected(AdapterView<?> adapterView) {
6564
typefaceSpinner.setAdapter(new TypefaceAdapter(this));
6665
typefaceSpinner.setSelection(0);
6766

68-
mTypeSizeField = (EditText) findViewById(R.id.field_type_size);
69-
mScriptTagField = (EditText) findViewById(R.id.field_script_tag);
70-
mLanguageTagField = (EditText) findViewById(R.id.field_language_tag);
71-
mTextField = (EditText) findViewById(R.id.field_text);
67+
mTypeSizeField = findViewById(R.id.field_type_size);
68+
mScriptTagField = findViewById(R.id.field_script_tag);
69+
mLanguageTagField = findViewById(R.id.field_language_tag);
70+
mTextField = findViewById(R.id.field_text);
7271
}
7372

7473
@Override

demo/src/main/java/com/mta/tehreer/demo/TypefaceGlyphsActivity.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017 Muhammad Tayyab Akram
2+
* Copyright (C) 2016-2018 Muhammad Tayyab Akram
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -44,23 +44,20 @@
4444
import com.mta.tehreer.graphics.Typeface;
4545

4646
public class TypefaceGlyphsActivity extends AppCompatActivity {
47-
4847
private GridView mGlyphsGridView;
4948
private Typeface mTypeface;
5049

5150
private static class GlyphHolder {
52-
5351
final ImageView glyphShape;
5452
final TextView glyphId;
5553

5654
GlyphHolder(View layout) {
57-
glyphShape = (ImageView) layout.findViewById(R.id.image_view_glyph_shape);
58-
glyphId = (TextView) layout.findViewById(R.id.text_view_glyph_id);
55+
glyphShape = layout.findViewById(R.id.image_view_glyph_shape);
56+
glyphId = layout.findViewById(R.id.text_view_glyph_id);
5957
}
6058
}
6159

6260
private static class GlyphAdapter extends BaseAdapter {
63-
6461
final Context context;
6562
final Renderer renderer;
6663

@@ -106,7 +103,6 @@ public View getView(int i, View convertView, ViewGroup parent) {
106103
}
107104

108105
private static class GlyphDrawable extends Drawable {
109-
110106
static final PointList OFFSET = PointList.of(new float[] { 0, 0 });
111107
static final FloatList ADVANCE = FloatList.of(new float[] { 0 });
112108

@@ -167,7 +163,7 @@ protected void onCreate(Bundle savedInstanceState) {
167163
actionBar.setDisplayHomeAsUpEnabled(true);
168164
}
169165

170-
mGlyphsGridView = (GridView) findViewById(R.id.grid_view_glyphs);
166+
mGlyphsGridView = findViewById(R.id.grid_view_glyphs);
171167
mGlyphsGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
172168

173169
@Override
@@ -176,7 +172,7 @@ public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
176172
}
177173
});
178174

179-
Spinner typefaceSpinner = (Spinner) findViewById(R.id.spinner_typeface);
175+
Spinner typefaceSpinner = findViewById(R.id.spinner_typeface);
180176
typefaceSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
181177

182178
@Override

demo/src/main/java/com/mta/tehreer/demo/TypefaceInfoActivity.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017 Muhammad Tayyab Akram
2+
* Copyright (C) 2016-2018 Muhammad Tayyab Akram
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,7 +34,6 @@
3434
import java.util.List;
3535

3636
public class TypefaceInfoActivity extends AppCompatActivity {
37-
3837
private static final int WINDOWS_PLATFORM = 3;
3938

4039
private static final int COPYRIGHT = 0;
@@ -75,7 +74,7 @@ protected void onCreate(Bundle savedInstanceState) {
7574
actionBar.setDisplayHomeAsUpEnabled(true);
7675
}
7776

78-
Spinner typefaceSpinner = (Spinner) findViewById(R.id.spinner_typeface);
77+
Spinner typefaceSpinner = findViewById(R.id.spinner_typeface);
7978
typefaceSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
8079

8180
@Override
@@ -115,7 +114,7 @@ private List<String> getNames(NameTable nameTable, int nameId, int platformId) {
115114
}
116115

117116
private void configureName(int layoutResId, NameTable nameTable, int nameId) {
118-
LinearLayout nameLayout = (LinearLayout) findViewById(layoutResId);
117+
LinearLayout nameLayout = findViewById(layoutResId);
119118
List<String> nameList = getNames(nameTable, nameId, WINDOWS_PLATFORM);
120119

121120
if (nameList.size() > 0) {
@@ -173,7 +172,7 @@ private void loadTypeface(Typeface typeface) {
173172
configureName(R.id.layout_dark_background_palette, nameTable, DARK_BACKGROUND_PALETTE);
174173
configureName(R.id.layout_variations_postscript_name_prefix, nameTable, VARIATIONS_POST_SCRIPT_NAME_PREFIX);
175174

176-
ScrollView scrollView = (ScrollView) findViewById(R.id.scroll_view_font_info);
175+
ScrollView scrollView = findViewById(R.id.scroll_view_font_info);
177176
scrollView.invalidate();
178177
scrollView.scrollTo(0, 0);
179178
}

0 commit comments

Comments
 (0)