1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-12-26 21:01:32 +00:00

Remove unneeded explicit view casts

This commit is contained in:
Felix Ableitner 2017-09-26 11:53:52 +09:00
parent 5aed81a8f3
commit 3f0be34f3e
19 changed files with 56 additions and 67 deletions

View file

@ -159,15 +159,15 @@ public class DeviceActivity extends SyncthingActivity implements View.OnClickLis
setTitle(mIsCreateMode ? R.string.add_device : R.string.edit_device);
mIdContainer = findViewById(R.id.idContainer);
mIdView = (EditText) findViewById(R.id.id);
mIdView = findViewById(R.id.id);
mQrButton = findViewById(R.id.qrButton);
mNameView = (EditText) findViewById(R.id.name);
mAddressesView = (EditText) findViewById(R.id.addresses);
mCurrentAddressView = (TextView) findViewById(R.id.currentAddress);
mNameView = findViewById(R.id.name);
mAddressesView = findViewById(R.id.addresses);
mCurrentAddressView = findViewById(R.id.currentAddress);
mCompressionContainer = findViewById(R.id.compressionContainer);
mCompressionValueView = (TextView) findViewById(R.id.compressionValue);
mIntroducerView = (SwitchCompat) findViewById(R.id.introducer);
mSyncthingVersionView = (TextView) findViewById(R.id.syncthingVersion);
mCompressionValueView = findViewById(R.id.compressionValue);
mIntroducerView = findViewById(R.id.introducer);
mSyncthingVersionView = findViewById(R.id.syncthingVersion);
mQrButton.setOnClickListener(this);
mCompressionContainer.setOnClickListener(this);

View file

@ -43,7 +43,7 @@ public class FirstStartActivity extends Activity implements Button.OnClickListen
}
setContentView(R.layout.activity_first_start);
Button cont = (Button) findViewById(R.id.cont);
Button cont = findViewById(R.id.cont);
cont.setOnClickListener(this);
}

View file

@ -123,13 +123,13 @@ public class FolderActivity extends SyncthingActivity
setTitle(mIsCreateMode ? R.string.create_folder : R.string.edit_folder);
registerOnServiceConnectedListener(this);
mLabelView = (EditText) findViewById(R.id.label);
mIdView = (EditText) findViewById(R.id.id);
mPathView = (TextView) findViewById(R.id.directoryTextView);
mFolderMasterView = (SwitchCompat) findViewById(R.id.master);
mVersioningDescriptionView = (TextView) findViewById(R.id.versioningDescription);
mVersioningTypeView = (TextView) findViewById(R.id.versioningType);
mDevicesContainer = (ViewGroup) findViewById(R.id.devicesContainer);
mLabelView = findViewById(R.id.label);
mIdView = findViewById(R.id.id);
mPathView = findViewById(R.id.directoryTextView);
mFolderMasterView = findViewById(R.id.master);
mVersioningDescriptionView = findViewById(R.id.versioningDescription);
mVersioningTypeView = findViewById(R.id.versioningType);
mDevicesContainer = findViewById(R.id.devicesContainer);
mPathView.setOnClickListener(view ->
startActivityForResult(FolderPickerActivity.createIntent(this, mFolder.path), FolderPickerActivity.DIRECTORY_REQUEST_CODE));

View file

@ -77,7 +77,7 @@ public class FolderPickerActivity extends SyncthingActivity
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_folder_picker);
mListView = (ListView) findViewById(android.R.id.list);
mListView = findViewById(android.R.id.list);
mListView.setOnItemClickListener(this);
mListView.setEmptyView(findViewById(android.R.id.empty));
mFilesAdapter = new FileAdapter(this);
@ -252,7 +252,7 @@ public class FolderPickerActivity extends SyncthingActivity
@NonNull
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
convertView = super.getView(position, convertView, parent);
TextView title = (TextView) convertView.findViewById(android.R.id.text1);
TextView title = convertView.findViewById(android.R.id.text1);
File f = getItem(position);
title.setText(f.getName());
int textColor = (f.isDirectory())
@ -274,7 +274,7 @@ public class FolderPickerActivity extends SyncthingActivity
@NonNull
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
convertView = super.getView(position, convertView, parent);
TextView title = (TextView) convertView.findViewById(android.R.id.text1);
TextView title = convertView.findViewById(android.R.id.text1);
title.setText(getItem(position).getAbsolutePath());
return convertView;
}

View file

@ -45,8 +45,8 @@ public class LogActivity extends SyncthingActivity {
invalidateOptionsMenu();
}
mLog = (TextView) findViewById(R.id.log);
mScrollView = (ScrollView) findViewById(R.id.scroller);
mLog = findViewById(R.id.log);
mScrollView = findViewById(R.id.scroller);
updateLog();
}

View file

@ -206,12 +206,12 @@ public class MainActivity extends StateDialogActivity
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerLayout = findViewById(R.id.drawer_layout);
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager = findViewById(R.id.pager);
mViewPager.setAdapter(mSectionsPagerAdapter);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabContainer);
TabLayout tabLayout = findViewById(R.id.tabContainer);
tabLayout.setupWithViewPager(mViewPager);
if (savedInstanceState != null) {
@ -283,8 +283,8 @@ public class MainActivity extends StateDialogActivity
outState.putBoolean(IS_SHOWING_RESTART_DIALOG, mRestartDialog != null && mRestartDialog.isShowing());
if(mQrCodeDialog != null && mQrCodeDialog.isShowing()) {
outState.putBoolean(IS_QRCODE_DIALOG_DISPLAYED, true);
ImageView qrCode = (ImageView) mQrCodeDialog.findViewById(R.id.qrcode_image_view);
TextView deviceID = (TextView) mQrCodeDialog.findViewById(R.id.device_id);
ImageView qrCode = mQrCodeDialog.findViewById(R.id.qrcode_image_view);
TextView deviceID = mQrCodeDialog.findViewById(R.id.device_id);
outState.putParcelable(QRCODE_BITMAP_KEY, ((BitmapDrawable) qrCode.getDrawable()).getBitmap());
outState.putString(DEVICEID_KEY, deviceID.getText().toString());
}
@ -329,9 +329,9 @@ public class MainActivity extends StateDialogActivity
public void showQrCodeDialog(String deviceId, Bitmap qrCode) {
@SuppressLint("InflateParams")
View qrCodeDialogView = this.getLayoutInflater().inflate(R.layout.dialog_qrcode, null);
TextView deviceIdTextView = (TextView) qrCodeDialogView.findViewById(R.id.device_id);
TextView shareDeviceIdTextView = (TextView) qrCodeDialogView.findViewById(R.id.actionShareId);
ImageView qrCodeImageView = (ImageView) qrCodeDialogView.findViewById(R.id.qrcode_image_view);
TextView deviceIdTextView = qrCodeDialogView.findViewById(R.id.device_id);
TextView shareDeviceIdTextView = qrCodeDialogView.findViewById(R.id.actionShareId);
ImageView qrCodeImageView = qrCodeDialogView.findViewById(R.id.qrcode_image_view);
deviceIdTextView.setText(deviceId);
deviceIdTextView.setOnClickListener(v -> Util.copyDeviceId(this, deviceIdTextView.getText().toString()));
@ -463,7 +463,7 @@ public class MainActivity extends StateDialogActivity
@SuppressLint("InflateParams")
View v = LayoutInflater.from(MainActivity.this)
.inflate(R.layout.dialog_usage_reporting, null);
TextView tv = (TextView) v.findViewById(R.id.example);
TextView tv = v.findViewById(R.id.example);
tv.setText(report);
new AlertDialog.Builder(MainActivity.this)
.setTitle(R.string.usage_reporting_dialog_title)

View file

@ -28,7 +28,6 @@ import com.nutomic.syncthingandroid.util.Util;
import com.nutomic.syncthingandroid.views.WifiSsidPreference;
import java.security.InvalidParameterException;
import java.util.List;
import eu.chainfire.libsuperuser.Shell;

View file

@ -56,7 +56,7 @@ public class ShareActivity extends StateDialogActivity
this, android.R.layout.simple_spinner_item, folders);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
Spinner sItems = (Spinner) findViewById(R.id.folders);
Spinner sItems = findViewById(R.id.folders);
sItems.setAdapter(adapter);
}
@ -80,11 +80,11 @@ public class ShareActivity extends StateDialogActivity
registerOnServiceConnectedListener(this);
Spinner mFoldersSpinner = (Spinner) findViewById(R.id.folders);
Button mShareButton = (Button) findViewById(R.id.share_button);
Button mCancelButton = (Button) findViewById(R.id.cancel_button);
EditText mShareName = (EditText) findViewById(R.id.name);
TextView mShareTitle = (TextView) findViewById(R.id.namesTitle);
Spinner mFoldersSpinner = findViewById(R.id.folders);
Button mShareButton = findViewById(R.id.share_button);
Button mCancelButton = findViewById(R.id.cancel_button);
EditText mShareName = findViewById(R.id.name);
TextView mShareTitle = findViewById(R.id.namesTitle);
// TODO: add support for EXTRA_TEXT (notes, memos sharing)
ArrayList<Uri> extrasToCopy = new ArrayList<>();

View file

@ -27,9 +27,8 @@ public abstract class StateDialogActivity extends SyncthingActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
registerOnServiceConnectedListener(() -> {
getService().registerOnApiChangeListener(this::onApiChange);
});
registerOnServiceConnectedListener(() ->
getService().registerOnApiChangeListener(this::onApiChange));
}
@Override
@ -96,7 +95,7 @@ public abstract class StateDialogActivity extends SyncthingActivity {
LayoutInflater inflater = getLayoutInflater();
@SuppressLint("InflateParams")
View dialogLayout = inflater.inflate(R.layout.dialog_loading, null);
TextView loadingText = (TextView) dialogLayout.findViewById(R.id.loading_text);
TextView loadingText = dialogLayout.findViewById(R.id.loading_text);
loadingText.setText((getIntent().getBooleanExtra(EXTRA_FIRST_START, false))
? R.string.web_gui_creating_key
: R.string.api_loading);

View file

@ -46,9 +46,7 @@ public abstract class SyncthingActivity extends ToolbarBindingActivity implement
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
SyncthingServiceBinder binder = (SyncthingServiceBinder) iBinder;
mSyncthingService = binder.getService();
for (OnServiceConnectedListener listener : mServiceConnectedListeners) {
listener.onServiceConnected();
}
mServiceConnectedListeners.forEach(OnServiceConnectedListener::onServiceConnected);
mServiceConnectedListeners.clear();
}

View file

@ -21,7 +21,7 @@ public abstract class ToolbarBindingActivity extends AppCompatActivity {
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
Toolbar toolbar = findViewById(R.id.toolbar);
if (toolbar == null)
return;

View file

@ -45,7 +45,7 @@ public class VersioningDialogActivity extends AppCompatActivity {
}
private void initiateFinishBtn() {
Button finishBtn = (Button) findViewById(R.id.finish_btn);
Button finishBtn = findViewById(R.id.finish_btn);
finishBtn.setOnClickListener(v -> {
saveConfiguration();
finish();
@ -59,7 +59,7 @@ public class VersioningDialogActivity extends AppCompatActivity {
}
private void initiateSpinner() {
Spinner versioningTypeSpinner = (Spinner) findViewById(R.id.versioningTypeSpinner);
Spinner versioningTypeSpinner = findViewById(R.id.versioningTypeSpinner);
versioningTypeSpinner.setSelection(mTypes.indexOf(getIntent().getExtras().getString("type")));
versioningTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override

View file

@ -125,7 +125,7 @@ public class WebGuiActivity extends StateDialogActivity
mConfig = new ConfigXml(this);
loadCaCert();
mWebView = (WebView) findViewById(R.id.webview);
mWebView = findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebViewClient(mWebViewClient);
mWebView.clearCache(true);

View file

@ -90,13 +90,13 @@ public class DrawerFragment extends Fragment implements View.OnClickListener {
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
mCpuUsage = (TextView) view.findViewById(R.id.cpu_usage);
mRamUsage = (TextView) view.findViewById(R.id.ram_usage);
mDownload = (TextView) view.findViewById(R.id.download);
mUpload = (TextView) view.findViewById(R.id.upload);
mAnnounceServer = (TextView) view.findViewById(R.id.announce_server);
mVersion = (TextView) view.findViewById(R.id.version);
mExitButton = (TextView) view.findViewById(R.id.drawerActionExit);
mCpuUsage = view.findViewById(R.id.cpu_usage);
mRamUsage = view.findViewById(R.id.ram_usage);
mDownload = view.findViewById(R.id.download);
mUpload = view.findViewById(R.id.upload);
mAnnounceServer = view.findViewById(R.id.announce_server);
mVersion = view.findViewById(R.id.version);
mExitButton = view.findViewById(R.id.drawerActionExit);
view.findViewById(R.id.drawerActionWebGui)
.setOnClickListener(this);

View file

@ -43,7 +43,7 @@ public class ExternalVersioningFragment extends Fragment {
}
private void initateTextView() {
TextView commandTextView = (TextView) mView.findViewById(R.id.commandTextView);
TextView commandTextView = mView.findViewById(R.id.commandTextView);
commandTextView.setText(getCommand());
commandTextView.addTextChangedListener(new TextWatcher() {

View file

@ -60,7 +60,7 @@ public class StaggeredVersioningFragment extends Fragment {
}
private void initiateVersionsPathTextView() {
mPathView = (TextView) mView.findViewById(R.id.directoryTextView);
mPathView = mView.findViewById(R.id.directoryTextView);
String currentPath = getVersionsPath();
mPathView.setText(currentPath);

View file

@ -1,9 +1,6 @@
package com.nutomic.syncthingandroid.util;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Build;
import android.os.Environment;
import android.text.TextUtils;
@ -11,7 +8,6 @@ import android.util.Log;
import com.nutomic.syncthingandroid.R;
import com.nutomic.syncthingandroid.service.SyncthingRunnable;
import com.nutomic.syncthingandroid.service.SyncthingService;
import com.nutomic.syncthingandroid.util.Util;
import org.mindrot.jbcrypt.BCrypt;
@ -23,7 +19,6 @@ import org.xml.sax.SAXException;
import java.io.File;
import java.io.IOException;
import java.io.DataOutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Locale;
@ -37,7 +32,6 @@ import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import eu.chainfire.libsuperuser.Shell;
/**
* Provides direct access to the config.xml file in the file system.
*

View file

@ -2,7 +2,6 @@ package com.nutomic.syncthingandroid.util;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.widget.Toast;
import android.util.Log;
import android.content.Context;

View file

@ -36,10 +36,10 @@ public class DevicesAdapter extends ArrayAdapter<Device> {
convertView = inflater.inflate(R.layout.item_device_list, parent, false);
}
TextView name = (TextView) convertView.findViewById(R.id.name);
TextView status = (TextView) convertView.findViewById(R.id.status);
TextView download = (TextView) convertView.findViewById(R.id.download);
TextView upload = (TextView) convertView.findViewById(R.id.upload);
TextView name = convertView.findViewById(R.id.name);
TextView status = convertView.findViewById(R.id.status);
TextView download = convertView.findViewById(R.id.download);
TextView upload = convertView.findViewById(R.id.upload);
String deviceId = getItem(position).deviceID;