I am creating a Chinese learning app, with a section for correctly pronouncing certain sounds. To organise these sounds into a table, I have created a UICollectionView, where each UICollectionViewCell contains a UITableView.

Each UICollectionViewCell acts as a column, and contains a UITableView.

Each UITableViewCell acts as a row in each column.

This results in the following appearance.

UICollectionView containing UITableViews

However, although I can easily detect taps on each UICollectionViewCell using collectionView:didSelectItemAtIndexPath: , I am unable to detect any touches at all on the UITableViewCells within.

Whether I convert the view in the Cell to be a button, or whether I as a UITapGestureRecognizer, or whether I use the function tableView:didSelectItemAtIndexPath, no touches at all are detected in the UITableView.

How can I allow my code to correctly detect these touches on the UITableViewCells within the UICollectionView?

Thanks!

Update 1:

Here is the @interfact of the Column .h file (UICollectionViewCell)

@interface PronounciationColumn : UICollectionViewCell <UITableViewDelegate, UITableViewDataSource>

In the .m of the UICollectionViewCell, the delegate and dataSource of the tableView is set to self.

Update 2:

Another user had a really neat idea of setting the delegate of the tableView to it's own collectionViewCell using the following code:

- (PronounciationColumn *)collectionView:(nonnull UICollectionView *)collectionView cellForItemAtIndexPath:(nonnull NSIndexPath *)indexPath {

    PronounciationColumn *column;
    NSString *columnIdentifier = [self getIdentifier:collectionView];
    if (column == nil) {
        column = (PronounciationColumn *)[collectionView dequeueReusableCellWithReuseIdentifier:columnIdentifier forIndexPath:indexPath];
        column.arrayOfFinals = [[self getArrayOfPinyins:collectionView] objectAtIndex:indexPath.item];
    }
    column.tableOfFinals.delegate = column;
    column.tableOfFinals.dataSource = column;
    return column;
}

The tableView continues to be populated correctly, however, the touches are still not detected on the cells, as tableView:didSelectRowAtIndexPath: is still not called.

I wanted to create a video player using AVKit and AVFoundation but I was unable to find any documentation related to Objective C. I already have a MPMMovie player implemented I just needed to migrate it to AVPlayer...How can I create a videoPlayer using AVKit and how can i use Apis to play video in that player??

I have tried creating a videoPlayer but i am a bit foggy about where the url should be passed in order the video to be played

I am hiding my navigation bar and tab bar when I scroll.

extendedLayoutIncludesOpaqueBars is set to true.

The scrollView extend below the Tab Bar alright.

The problem is that when the navigation bar and tab bar becomes hidden, the collectionView (a ASCollectionNode actually) expands to make up for the navigation bar height. You can see the extra cells appears and looks odd.

How can I force the extended layout to render further below?

I am using a table view and have a UITextField inside it, but this text view don't detect the click on the cell, how I can fix this.

Within Apple's iOS, what are the differences between an MVC "View Controller" and and an MVVM "ViewModel"? I think conceptually there is little difference. In practical terms they appear different. I'd like to see a list of both conceptual and practical differences.

How can I send action (similar kind of tap event) from sub class of UIImageView to View Controller.

Here is reference answer, that I want to apply for UIImageView. (UIImageView does not have UIControl in its super class hierarchy)

Following is my code but not working as I don't know, how to implement, what I need.

class TappableImageView: UIImageView {
  // Initializer methods.....

   //------------------------------------------
    private func addTapGesture(){
        let tapOnImage = UITapGestureRecognizer(target: self, action: #selector(TappableImageView.handleTapGesture(tapGesture:)))
        self.isUserInteractionEnabled = true
        self.addGestureRecognizer(tapOnImage)

    }


    //----------------------------------------------
    @objc func handleTapGesture(tapGesture: UITapGestureRecognizer) {
        // how can I send tap/click event to all view controllers, where I've used this image  from this point. 
    }
}

Is there any alternate/other solution that may work for me?

I'd like to present/show a ViewController (let's call it ViewController2) that is somehow hidden (or have a 0 size) and, after some time, it'll be resized to a specific size (or fullscreen) meanwhile keeping the content of the ViewController (let's call it ViewController1) presenting/showing it interactive.

ViewControllers flow


Just to give some more context on why I want to do that.

I'm trying to load a WKWebView in the background and, ideally, would like to present the ViewController only when the webview is fully loaded. Unfortunately, iOS seems to "pause" javascript evaluation and its timers after a very short time when the webview is not presented to the user.

I can confirm code like setTimeout stop working when the webview is attached to a ViewController which is not presented to the user and resumes working when that controller is presented/shown.

My idea here is, presenting the controller right away but somehow hidden (while keeping the app interactive) and when getting the right signal from the webview, I'd show/resize it to the user.

What I want is to close a viewController after performing a segue so that the back button of the navigation controller on the new view doesn't go back to the view that I just closed, but it goes to the view that precedes it in the storyboard like it is the first time that it is loaded

storyboard screenshot

I already tried stuff like dismiss and so but it doesn't really work for me as it only closes the view in which the button that I pressed for performing the function is located :

@objc func goToList(){
   self.dismiss(animated: true, completion: nil)
   performSegue(withIdentifier: "goToList", sender: nil)
}

I have tableview, 1 cell and 1 view in cell. Constraints for view: top, right, bottom, left equal to superview height = 250 And there is an error.

class ViewController: UITableViewController {

override func viewDidLoad() {
    super.viewDidLoad()

    tableView.delegate = self
    tableView.dataSource = self
    tableView.estimatedRowHeight = 250
    tableView.rowHeight = UITableView.automaticDimension
}

}

extension ViewController { override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 1 }

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = UITableViewCell()
    let view = UIView()

    view.translatesAutoresizingMaskIntoConstraints = false
    cell.contentView.addSubview(view)
    view.backgroundColor = UIColor.red
    view.heightAnchor.constraint(equalToConstant: 250).isActive = true
    view.topAnchor.constraint(equalTo: view.superview!.topAnchor).isActive = true
    view.bottomAnchor.constraint(equalTo: view.superview!.bottomAnchor).isActive = true
    view.leftAnchor.constraint(equalTo: view.superview!.leftAnchor).isActive = true
    view.rightAnchor.constraint(equalTo: view.superview!.rightAnchor).isActive = true
    return cell
}

}

I expected no error messages, but here there are.

2019-10-21 18:05:41.265530+0300 ffffffffff[73908:5577499] [LayoutConstraints] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. ( "", "", "", "" )

Will attempt to recover by breaking constraint

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in may also be helpful.

I don't want a notification badge on app icon. Can someone help me with this? Here is my code:

NotificationCompat.Builder notificationBuilder = new 
NotificationCompat.Builder(getApplicationContext(),NOTIFICATION_CHANNEL_ID)
.setShowWhen(false)
// set the notification style
.setStyle(new androidx.media.app.NotificationCompat.MediaStyle()
// attach our mMediaSessionCompat token
.setMediaSession(mMediaSessionCompat.getSessionToken())
// show our playback controls in the compact notification view
.setShowActionsInCompactView(0, 1, 2))
// set the large and small icons
.setLargeIcon(largeIcon)
.setSmallIcon(android.R.drawable.stat_sys_headset)
.setCategory(NotificationCompat.CATEGORY_SERVICE)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
// add playback actions
.addAction(notificationAction, "pause", play_pauseAction)

NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

if (notificationManager != null)
notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build());

I hope you can understand and help me. Thank you...

I am working an android app for learning. and facing some problem. Can't set a button center of two. I already set two button with this Now I need another button in the center of this two and The view will be as like as this

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_gravity="start"
        android:gravity="start">

        <Button
            android:id="@+id/dialog_positive_btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Set"
            android:background="#dde5ad" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_gravity="end"
        android:gravity="end">

        <Button
            android:id="@+id/dialog_negative_btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="No"
            android:background="#dde5ad" />
    </LinearLayout>

I need exactly center of this two.

Android Studio 3.5

In app/build.gradle :

   buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

            configBuildType(delegate, RELEASE_APP_NAME)
        }
        debug {
            configBuildType(delegate, DEBUG_APP_NAME, DEBUG_APP_VERSION)
        }
    }


    def configBuildType(buildType, appName, appVersion) {
        buildType.resValue("string", "application_name", appName)
        buildType.buildConfigField("String", "APP_VERSION", appVersion)
     }

Nice it's work.

But I how I can convert my custom task to build.gradle.kts ?

I am new to couch db, I would like to know when we need to use couch-db and is it better than sq-lite?

I had a few group in my constraint layout, which I use it to show/hide its component. But then I notice I can add constraint to group(saw the Constraint Widget at Attributes). I tried resizing the group, adding constraint at Attributes, but nothing changed.

The only thing i found online regarding to group is that i can show/hide its component. Even according to https://developer.android.com/reference/android/support/constraint/Group , it doesnt seems like it's possible to add constraint to group.

My question is, is it possible to add constraint to the group instead of adding constraint to every single view?

I'm using Android-R8 and the following R8-warnings are present:

R8 warnings     
Missing class: javax.xml.stream.XMLStreamReader 
Missing class: javax.xml.stream.util.XMLEventAllocator  
Missing class: javax.xml.stream.events.Characters   
Missing class: javax.xml.stream.events.DTD  
Missing class: javax.xml.stream.XMLOutputFactory    
Missing class: javax.xml.stream.EventFilter 
Missing class: javax.xml.stream.events.Comment  
Missing class: javax.xml.stream.events.Attribute    
Missing class: javax.xml.stream.events.NotationDeclaration  
Missing class: javax.xml.stream.events.ProcessingInstruction    
Missing class: javax.xml.stream.events.EndElement   
Missing class: javax.xml.stream.events.StartDocument    
Missing class: javax.xml.stream.Location    
Missing class: javax.xml.stream.util.XMLEventConsumer   
Missing class: javax.xml.stream.events.EndDocument  
Missing class: javax.xml.stream.events.XMLEvent 
Missing class: javax.xml.stream.XMLInputFactory 
Missing class: javax.xml.stream.events.EntityDeclaration    
Missing class: javax.xml.stream.XMLEventWriter  
Missing class: javax.xml.stream.events.Namespace    
Missing class: javax.xml.stream.StreamFilter    
Missing class: javax.xml.stream.events.EntityReference  
Missing class: javax.xml.stream.events.StartElement 
Missing class: javax.xml.stream.XMLEventFactory 
Missing class: javax.xml.stream.XMLStreamWriter 
Missing class: javax.xml.stream.XMLEventReader 

The APK is successfully built but cannot be installed. Does anyone have similar problem ?

I have followed the Room + LiveData + View + Model + ViewModel schema to implement a recyclerview with entries. I then added DiffUtils and a swipe listener to implement deleting the items by swiping. After this, some of views of the entries don't show until I swipe on them and then undo the deleting by inserting the same object into Room again. When this happens, some other elements which were not showing appear again, so this must be some of the cached/recycled elements.

Here is the exact behaviour:

  • When the app opens, all entries that are on the screen are visible.
  • When you scroll down, 4 elements are missing, then there are visible elements again, then some invisible ones.
  • If you delete one of the invisible ones by swiping over it (you can also click it and it shows the right behaviour) and undo the delete, the item becomes visible again and other elements that were missing show as well (the ones using the same recycled view).

Has anyone have to deal with something like this?

RecordListFragment.java

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    RecyclerView recyclerView = getView().findViewById(R.id.recyclerview);
    final RecordListAdapter adapter = new RecordListAdapter();

    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
    linearLayoutManager.setReverseLayout(true); //show records in inverse order
    linearLayoutManager.setStackFromEnd(true); // idem
    recyclerView.setLayoutManager(linearLayoutManager);
    recyclerView.setAdapter(adapter);

    ItemTouchHelper itemTouchHelper = new
            ItemTouchHelper(new SwipeToDeleteCallback(adapter, getActivity(), this));
    itemTouchHelper.attachToRecyclerView(recyclerView);

    mRecordViewModel = ViewModelProviders.of(this).get(RecordViewModel.class);
    mRecordViewModel.getAllRecords().observe(this, records -> adapter.submitList(records));
    super.onViewCreated(view, savedInstanceState);
}

RecordListAdapter.java

public class RecordListAdapter extends ListAdapter<Record, 
  RecordListAdapter.RecordViewHolder> {
  private int lastPosition = -1;

  public  RecordListAdapter() {
     super(diffCallback);
}

private static final DiffUtil.ItemCallback<Record> diffCallback = new DiffUtil.ItemCallback<Record>() {
    @Override
    public boolean areItemsTheSame(@NonNull RBRecord oldItem, @NonNull RBRecord newItem) {
        return oldItem.getId() == newItem.getId();
    }

    @Override
    public boolean areContentsTheSame(@NonNull RBRecord oldItem, @NonNull RBRecord newItem) {
        return oldItem.getDataPath().equals(newItem.getDataPath()) &&
                oldItem.getComment().equals(newItem.getComment());
    }
};

class RecordViewHolder extends RecyclerView.ViewHolder {
    private final TextView recordItemViewType, recordItemViewDate, recordItemViewDuration;
    private final Button commButton;
    final View mView;

    private RecordViewHolder(View itemView) {
        super(itemView);
        mView = itemView;
        recordItemViewType = itemView.findViewById(R.id.textView);
        commButton = itemView.findViewById(R.id.komm_button);
    }
}


@Override
public RecordViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View itemView = LayoutInflater.from(parent.getContext())
            .inflate(R.layout.recyclerview_item, parent, false);
    return new RBRecordViewHolder(itemView);
}

@Override
public void onBindViewHolder(RBRecordViewHolder holder, int position) {
    RBRecord current = getItem(position);
    holder.recordItemViewType.setText(
            current.getActivity());

    holder.mView.setOnClickListener(v -> {
        Intent intent = new Intent(holder.itemView.getContext(), RecordViewActivity.class);
        intent.putExtra("name", current.getDataPath());
        holder.itemView.getContext().startActivity(intent);
    });

    holder.commButton.setOnClickListener(v -> {
        AlertDialog.Builder builder = new AlertDialog.Builder(holder.mView.getContext());
        LayoutInflater inflater = (LayoutInflater) holder.mView.getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE );
        View mView = inflater.inflate(R.layout.dialog_record_comment, null);
        EditText commText = (EditText) mView.findViewById(R.id.comment);
        commText.setText(current.getComment());
        builder.setView(mView)
                .setTitle("Comment:")
                .setPositiveButton("Save", (dialog, id) -> RecordListFragment.addCommentToRecord(commText.getText().toString(), current))
                .setNegativeButton("Back", (dialog, id) -> {
                });
        AlertDialog dialog = builder.create();
        dialog.show();

    });
}

A variables of the calendar class isn't String. I want to know how to pass time variable values ​​to the board using Via Bluetooth. pickerTime is a TimePicker in actitvity_main.xml , buttonSetAlarm is a button to set alarm

This is the source:

        pickerTime.setCurrentMinute(now.get(Calendar.MINUTE));
        ///------------------------ALARM
        buttonSetAlarm = (Button)findViewById(R.id.setalarm);
        buttonSetAlarm.setOnClickListener(new OnClickListener(){

            @Override
            public void onClick(View arg0) {
                Calendar current = Calendar.getInstance();

                Calendar cal = Calendar.getInstance();
                cal.set(pickerDate.getYear(),
                        pickerDate.getMonth(),
                        pickerDate.getDayOfMonth(),
                        pickerTime.getCurrentHour(),
                        pickerTime.getCurrentMinute(),00);

                if(cal.compareTo(current) <= 0){
                    //The set Date/Time already passed
                    Toast.makeText(getApplicationContext(),
                            "Invalid Date/Time",
                            Toast.LENGTH_LONG).show();
                }else{
                    setAlarm(cal);

                }

            }}); 

This is send data method via bluetooth

public void setSendData(String sendData) {
            byte[] magBuffer = sendData.getBytes();
            try {
                mmOutStream.write(magBuffer);

            } catch (IOException e) {

            }
        }

Please,help me because I don't know how to pass the time value. and Thank you.

This is the line where always getting error

        String sess = "workid_token=" + AppHelper.getCurrSession().getIdToken().getJWTToken() + ";base_token=" + AppHelper.getCurrSession().getRefreshToken().getToken() + ";" + getsess + ";";

I am implementing amazon web services in my android app.After implementation i am always getting error in the above line please help me to sort this issue

I've designed a beautiful app Yes Jobs on latest ionic's android platform.

I have used HTTPS apis for secured connection.

I have generated debug.apk ionic cordova build android --prod ==> working fine through side loading app through USB

I have generated release.apk ionic cordova build android --prod --release ==> app is open but the first API of login itself doesn't work, ultimately application on working on release version

I have read some where about the generate keystore in every version of release.

Please tell me the reason or solution why application in debug.apk is working but not the release version

This is my viewmodel class :

class MainViewModel(
    private val schedulerProvider: BaseSchedulerProvider,
    private val api : StorytelService
) : BaseViewModel() {

    private val _posts = MutableLiveData<List<Post>>()
    val posts: LiveData<List<Post>>
        get() = _posts

    private val _status = MutableLiveData<Status>()
    val status: LiveData<Status>
        get() = _status

    init {
        showPhotos()
    }

    fun showPhotos() {
        EspressoIdlingResource.increment() // App is busy until further notice
        _status.postValue(Status.LOADING)
        compositeDisposable.add(api.getPhotos()
            .subscribeOn(schedulerProvider.io())
            .observeOn(schedulerProvider.ui())
            .doFinally {
                if (!EspressoIdlingResource.countingIdlingResource.isIdleNow) {
                    EspressoIdlingResource.decrement() // Set app as idle.
                }
            }
            .subscribe({
                _status.postValue(Status.SUCCESS)
                showPosts(it)
            }) {
                _status.postValue(Status.ERROR)
                Timber.e(it)
            })
    }

    private fun showPosts(networkPhotos: List<NetworkPhoto>) {
        EspressoIdlingResource.increment() // App is busy until further notice
        _status.postValue(Status.LOADING)
        compositeDisposable.add(api.getPosts()
            .subscribeOn(schedulerProvider.io())
            .observeOn(schedulerProvider.ui())
            .doFinally {
                if (!EspressoIdlingResource.countingIdlingResource.isIdleNow) {
                    EspressoIdlingResource.decrement() // Set app as idle.
                }
            }
            .subscribe({ networkPosts ->
                _status.postValue(Status.SUCCESS)
                _posts.postValue(
                    PostAndImages(networkPosts, networkPhotos).asDomaineModel()
                )
            }) {
                _status.postValue(Status.ERROR)
                Timber.e(it)
            })
    }

This is my recyclerView in layout :

<androidx.recyclerview.widget.RecyclerView
            android:id="@+id/recycler_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            app:showData="@{vm.status}"
            tools:listitem="@layout/post_item" />

And here is binding adapter :

@BindingAdapter("showData")
fun View.showData(status: Status) {
    visibility = if (status == Status.SUCCESS) View.VISIBLE else View.GONE
}

As you notice I am using EspressoIdlingResource, but when I run following espresso test, it fails :

    @Test
    fun shouldBeAbleToLoadList() {
        onView(withId(R.id.recycler_view)).check(matches(isDisplayed()))
    } 

If I add Thread.sleep(5000) in the beginning of the test, it works. How to resolve it?